@asgardeo/browser 0.2.9 → 0.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/dist/__legacy__/client.d.ts +91 -4
- package/dist/cjs/index.js +137 -30
- package/dist/cjs/index.js.map +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +137 -30
- package/dist/index.js.map +3 -3
- package/dist/utils/hasCalledForThisInstanceInUrl.d.ts +26 -0
- 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
|
*
|