@asgardeo/react 0.9.1 → 0.9.2
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/AsgardeoReactClient.d.ts +2 -0
- package/dist/__temp__/api.d.ts +8 -0
- package/dist/cjs/index.js +33 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/index.js +40 -8
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
|
@@ -64,5 +64,7 @@ declare class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactC
|
|
|
64
64
|
requestAll(requestConfigs?: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
|
|
65
65
|
getAccessToken(sessionId?: string): Promise<string>;
|
|
66
66
|
clearSession(sessionId?: string): void;
|
|
67
|
+
setSession(sessionData: Record<string, unknown>, sessionId?: string): Promise<void>;
|
|
68
|
+
decodeJwtToken<T = Record<string, unknown>>(token: string): Promise<T>;
|
|
67
69
|
}
|
|
68
70
|
export default AsgardeoReactClient;
|
package/dist/__temp__/api.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ declare class AuthAPI {
|
|
|
44
44
|
* @returns {Promise<AuthClientConfig<Config>>} - A promise that resolves with the configuration data.
|
|
45
45
|
*/
|
|
46
46
|
getConfigData(): Promise<AuthClientConfig<Config>>;
|
|
47
|
+
getStorageManager(): Promise<any>;
|
|
47
48
|
/**
|
|
48
49
|
* Method to get the configuration data.
|
|
49
50
|
*
|
|
@@ -129,6 +130,13 @@ declare class AuthAPI {
|
|
|
129
130
|
* @return {HttpClientInstance} - The Axios HTTP client.
|
|
130
131
|
*/
|
|
131
132
|
getHttpClient(): Promise<HttpClientInstance>;
|
|
133
|
+
/**
|
|
134
|
+
* This method decodes a JWT token payload and returns it.
|
|
135
|
+
*
|
|
136
|
+
* @param token - The token to decode.
|
|
137
|
+
* @returns The decoded token payload.
|
|
138
|
+
*/
|
|
139
|
+
decodeJwtToken<T = Record<string, unknown>>(token: string): Promise<T>;
|
|
132
140
|
/**
|
|
133
141
|
* This method decodes the payload of the id token and returns it.
|
|
134
142
|
*
|
package/dist/cjs/index.js
CHANGED
|
@@ -254,6 +254,9 @@ var _AuthAPI = class _AuthAPI {
|
|
|
254
254
|
async getConfigData() {
|
|
255
255
|
return this._client.getConfigData();
|
|
256
256
|
}
|
|
257
|
+
async getStorageManager() {
|
|
258
|
+
return this._client.getStorageManager();
|
|
259
|
+
}
|
|
257
260
|
/**
|
|
258
261
|
* Method to get the configuration data.
|
|
259
262
|
*
|
|
@@ -402,6 +405,15 @@ var _AuthAPI = class _AuthAPI {
|
|
|
402
405
|
async getHttpClient() {
|
|
403
406
|
return this._client.getHttpClient();
|
|
404
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* This method decodes a JWT token payload and returns it.
|
|
410
|
+
*
|
|
411
|
+
* @param token - The token to decode.
|
|
412
|
+
* @returns The decoded token payload.
|
|
413
|
+
*/
|
|
414
|
+
async decodeJwtToken(token) {
|
|
415
|
+
return this._client.decodeJwtToken(token);
|
|
416
|
+
}
|
|
405
417
|
/**
|
|
406
418
|
* This method decodes the payload of the id token and returns it.
|
|
407
419
|
*
|
|
@@ -876,12 +888,26 @@ var AsgardeoReactClient = class extends import_browser6.AsgardeoBrowserClient {
|
|
|
876
888
|
const authId = authIdFromUrl || authIdFromStorage;
|
|
877
889
|
const baseUrlFromStorage = sessionStorage.getItem("asgardeo_base_url");
|
|
878
890
|
const baseUrl = config?.baseUrl || baseUrlFromStorage;
|
|
879
|
-
|
|
891
|
+
const response = await (0, import_browser6.executeEmbeddedSignInFlowV2)({
|
|
880
892
|
payload: arg1,
|
|
881
893
|
url: arg2?.url,
|
|
882
894
|
baseUrl,
|
|
883
895
|
authId
|
|
884
896
|
});
|
|
897
|
+
if (isV2Platform && response && typeof response === "object" && response["flowStatus"] === import_browser6.EmbeddedSignInFlowStatusV2.Complete && response["assertion"]) {
|
|
898
|
+
const decodedAssertion = await this.decodeJwtToken(response["assertion"]);
|
|
899
|
+
const createdAt = decodedAssertion.iat ? decodedAssertion.iat * 1e3 : Date.now();
|
|
900
|
+
const expiresIn = decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;
|
|
901
|
+
await this.setSession({
|
|
902
|
+
access_token: response["assertion"],
|
|
903
|
+
id_token: response["assertion"],
|
|
904
|
+
token_type: "Bearer",
|
|
905
|
+
expires_in: expiresIn,
|
|
906
|
+
created_at: createdAt,
|
|
907
|
+
scope: decodedAssertion.scope
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
return response;
|
|
885
911
|
}
|
|
886
912
|
if (typeof arg1 === "object" && "flowId" in arg1 && typeof arg2 === "object" && "url" in arg2) {
|
|
887
913
|
return (0, import_browser6.executeEmbeddedSignInFlow)({
|
|
@@ -945,6 +971,12 @@ var AsgardeoReactClient = class extends import_browser6.AsgardeoBrowserClient {
|
|
|
945
971
|
clearSession(sessionId) {
|
|
946
972
|
this.asgardeo.clearSession(sessionId);
|
|
947
973
|
}
|
|
974
|
+
async setSession(sessionData, sessionId) {
|
|
975
|
+
return await (await this.asgardeo.getStorageManager()).setSessionData(sessionData, sessionId);
|
|
976
|
+
}
|
|
977
|
+
decodeJwtToken(token) {
|
|
978
|
+
return this.asgardeo.decodeJwtToken(token);
|
|
979
|
+
}
|
|
948
980
|
};
|
|
949
981
|
var AsgardeoReactClient_default = AsgardeoReactClient;
|
|
950
982
|
|
|
@@ -7621,7 +7653,6 @@ var BaseSignInContent2 = ({
|
|
|
7621
7653
|
setIsSubmitting(true);
|
|
7622
7654
|
setApiError(null);
|
|
7623
7655
|
clearMessages();
|
|
7624
|
-
console.log("Submitting component:", component, "with data:", data);
|
|
7625
7656
|
try {
|
|
7626
7657
|
const filteredInputs = {};
|
|
7627
7658
|
if (data) {
|