@asgardeo/browser 0.2.10 → 0.4.1
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/__legacy__/client.d.ts +91 -4
- package/dist/__legacy__/http-client/clients/axios-http-client.d.ts +15 -6
- package/dist/__legacy__/http-client/models/http-client.d.ts +1 -1
- package/dist/__legacy__/worker/worker-core.d.ts +1 -1
- package/dist/cjs/index.js +192 -72
- package/dist/cjs/index.js.map +2 -2
- package/dist/index.js +192 -72
- package/dist/index.js.map +2 -2
- package/dist/utils/http.d.ts +25 -4
- package/package.json +4 -4
|
@@ -23,6 +23,8 @@ import { AuthSPAClientConfig, LegacyConfig as Config, HttpRequestConfig, HttpRes
|
|
|
23
23
|
import { BrowserStorage } from './models/storage';
|
|
24
24
|
/**
|
|
25
25
|
* This class provides the necessary methods to implement authentication in a Single Page Application.
|
|
26
|
+
* Implements a Multiton pattern to support multi-tenancy scenarios where multiple authentication
|
|
27
|
+
* contexts need to coexist in the same application.
|
|
26
28
|
*
|
|
27
29
|
* @export
|
|
28
30
|
* @class AsgardeoSPAClient
|
|
@@ -69,15 +71,22 @@ export declare class AsgardeoSPAClient {
|
|
|
69
71
|
*/
|
|
70
72
|
private _validateMethod;
|
|
71
73
|
/**
|
|
72
|
-
* This method returns the instance of the
|
|
74
|
+
* This method returns the instance of the client for the specified ID.
|
|
75
|
+
* Implements a Multiton pattern to support multiple authentication contexts.
|
|
73
76
|
* If an ID is provided, it will return the instance with the given ID.
|
|
74
|
-
* If no ID is provided, it will return the default instance
|
|
77
|
+
* If no ID is provided, it will return the default instance (ID: 0).
|
|
75
78
|
*
|
|
76
|
-
* @
|
|
79
|
+
* @param {number} id - Optional unique identifier for the instance.
|
|
80
|
+
* @return {AsgardeoSPAClient} - Returns the instance associated with the ID.
|
|
77
81
|
*
|
|
78
82
|
* @example
|
|
79
83
|
* ```
|
|
84
|
+
* // Single tenant application (default instance)
|
|
80
85
|
* const auth = AsgardeoSPAClient.getInstance();
|
|
86
|
+
*
|
|
87
|
+
* // Multi-instance application
|
|
88
|
+
* const instance1 = AsgardeoSPAClient.getInstance(1);
|
|
89
|
+
* const instance2 = AsgardeoSPAClient.getInstance(2);
|
|
81
90
|
* ```
|
|
82
91
|
*
|
|
83
92
|
* @link https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master#getinstance
|
|
@@ -86,7 +95,85 @@ export declare class AsgardeoSPAClient {
|
|
|
86
95
|
*
|
|
87
96
|
* @preserve
|
|
88
97
|
*/
|
|
89
|
-
static getInstance(id?: number): AsgardeoSPAClient
|
|
98
|
+
static getInstance(id?: number): AsgardeoSPAClient;
|
|
99
|
+
/**
|
|
100
|
+
* This method checks if an instance exists for the given ID.
|
|
101
|
+
*
|
|
102
|
+
* @param {number} id - Optional unique identifier for the instance.
|
|
103
|
+
* @return {boolean} - Returns true if an instance exists for the ID.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```
|
|
107
|
+
* if (AsgardeoSPAClient.hasInstance(1)) {
|
|
108
|
+
* const auth = AsgardeoSPAClient.getInstance(1);
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @memberof AsgardeoSPAClient
|
|
113
|
+
*/
|
|
114
|
+
static hasInstance(id?: number): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* This method removes and cleans up a specific instance.
|
|
117
|
+
* Useful when an instance is no longer needed.
|
|
118
|
+
*
|
|
119
|
+
* @param {number} id - Optional unique identifier for the instance to destroy.
|
|
120
|
+
* @return {boolean} - Returns true if the instance was found and removed.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```
|
|
124
|
+
* // Remove a specific instance
|
|
125
|
+
* AsgardeoSPAClient.destroyInstance(1);
|
|
126
|
+
*
|
|
127
|
+
* // Remove the default instance
|
|
128
|
+
* AsgardeoSPAClient.destroyInstance();
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @memberof AsgardeoSPAClient
|
|
132
|
+
*/
|
|
133
|
+
static destroyInstance(id?: number): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* This method returns all active instance IDs.
|
|
136
|
+
* Useful for debugging or managing multiple instances.
|
|
137
|
+
*
|
|
138
|
+
* @return {number[]} - Returns an array of all active instance IDs.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```
|
|
142
|
+
* const activeInstances = AsgardeoSPAClient.getInstanceKeys();
|
|
143
|
+
* console.log('Active instances:', activeInstances);
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @memberof AsgardeoSPAClient
|
|
147
|
+
*/
|
|
148
|
+
static getInstanceKeys(): number[];
|
|
149
|
+
/**
|
|
150
|
+
* This method removes all instances.
|
|
151
|
+
* Useful for cleanup in testing scenarios or application teardown.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```
|
|
155
|
+
* AsgardeoSPAClient.destroyAllInstances();
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @memberof AsgardeoSPAClient
|
|
159
|
+
*/
|
|
160
|
+
static destroyAllInstances(): void;
|
|
161
|
+
/**
|
|
162
|
+
* This method returns the instance ID for this client instance.
|
|
163
|
+
*
|
|
164
|
+
* @return {number} - The instance ID.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```
|
|
168
|
+
* const auth = AsgardeoSPAClient.getInstance(1);
|
|
169
|
+
* console.log(auth.getInstanceId()); // 1
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @memberof AsgardeoSPAClient
|
|
173
|
+
*
|
|
174
|
+
* @preserve
|
|
175
|
+
*/
|
|
176
|
+
getInstanceId(): number;
|
|
90
177
|
/**
|
|
91
178
|
* This method initializes the `AsgardeoSPAClient` instance.
|
|
92
179
|
*
|
|
@@ -36,9 +36,9 @@ import { HttpClientInstance, HttpClientInterface } from '../models';
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export declare class HttpClient implements HttpClientInterface<HttpRequestConfig, HttpResponse, HttpError> {
|
|
39
|
-
private static
|
|
40
|
-
private static
|
|
41
|
-
private
|
|
39
|
+
private static instances;
|
|
40
|
+
private static clientInstances;
|
|
41
|
+
private isHandlerEnabled;
|
|
42
42
|
private attachToken;
|
|
43
43
|
private requestStartCallback;
|
|
44
44
|
private requestSuccessCallback;
|
|
@@ -53,11 +53,20 @@ export declare class HttpClient implements HttpClientInterface<HttpRequestConfig
|
|
|
53
53
|
*/
|
|
54
54
|
private constructor();
|
|
55
55
|
/**
|
|
56
|
-
* Returns an
|
|
56
|
+
* Returns an instance-specific HttpClient instance.
|
|
57
|
+
* Each instance ID gets its own axios instance and HttpClient to avoid state conflicts.
|
|
57
58
|
*
|
|
58
|
-
* @
|
|
59
|
+
* @param instanceId - The instance ID for multi-auth context support. Defaults to 0.
|
|
60
|
+
* @return {HttpClientInstance}
|
|
59
61
|
*/
|
|
60
|
-
static getInstance(): HttpClientInstance;
|
|
62
|
+
static getInstance(instanceId?: number): HttpClientInstance;
|
|
63
|
+
/**
|
|
64
|
+
* Destroys and cleans up an HttpClient instance.
|
|
65
|
+
* This should be called during provider teardown to prevent memory leaks.
|
|
66
|
+
*
|
|
67
|
+
* @param instanceId - The instance ID to destroy. Defaults to 0.
|
|
68
|
+
*/
|
|
69
|
+
static destroyInstance(instanceId?: number): void;
|
|
61
70
|
/**
|
|
62
71
|
* Intercepts all the requests.
|
|
63
72
|
* If the `isHandlerEnabled` flag is set to true, fires the `requestStartCallback`
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
import { AsgardeoAuthClient, AuthClientConfig } from '@asgardeo/javascript';
|
|
19
19
|
import { AuthenticationHelper, SPAHelper } from '../helpers';
|
|
20
20
|
import { WebWorkerClientConfig, WebWorkerCoreInterface } from '../models';
|
|
21
|
-
export declare const WebWorkerCore: (config: AuthClientConfig<WebWorkerClientConfig>, getAuthHelper: (authClient: AsgardeoAuthClient<WebWorkerClientConfig>, spaHelper: SPAHelper<WebWorkerClientConfig>) => AuthenticationHelper<WebWorkerClientConfig>) => Promise<WebWorkerCoreInterface>;
|
|
21
|
+
export declare const WebWorkerCore: (instanceID: number, config: AuthClientConfig<WebWorkerClientConfig>, getAuthHelper: (authClient: AsgardeoAuthClient<WebWorkerClientConfig>, spaHelper: SPAHelper<WebWorkerClientConfig>) => AuthenticationHelper<WebWorkerClientConfig>) => Promise<WebWorkerCoreInterface>;
|