@asgardeo/browser 0.1.1 → 0.1.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/__legacy__/client.d.ts +1 -1
- package/dist/__legacy__/helpers/authentication-helper.d.ts +1 -1
- package/dist/__legacy__/models/client.d.ts +2 -2
- package/dist/__legacy__/models/web-worker.d.ts +1 -1
- package/dist/cjs/index.js +79 -9
- package/dist/cjs/index.js.map +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +79 -9
- package/dist/index.js.map +3 -3
- package/dist/theme/themeDetection.d.ts +40 -0
- package/package.json +2 -2
|
@@ -399,7 +399,7 @@ export declare class AsgardeoSPAClient {
|
|
|
399
399
|
*
|
|
400
400
|
* @preserve
|
|
401
401
|
*/
|
|
402
|
-
getDecodedIdToken(): Promise<IdToken | undefined>;
|
|
402
|
+
getDecodedIdToken(sessionId?: string): Promise<IdToken | undefined>;
|
|
403
403
|
/**
|
|
404
404
|
* This method returns the IsomorphicCrypto instance.
|
|
405
405
|
*
|
|
@@ -46,7 +46,7 @@ export declare class AuthenticationHelper<T extends MainThreadClientConfig | Web
|
|
|
46
46
|
handleSignIn(shouldStopAuthn: () => Promise<boolean>, checkSession: () => Promise<void>, tryRetrievingUserInfo?: () => Promise<User | undefined>): Promise<User | undefined>;
|
|
47
47
|
attachTokenToRequestConfig(request: HttpRequestConfig): Promise<void>;
|
|
48
48
|
getUser(): Promise<User>;
|
|
49
|
-
getDecodedIdToken(): Promise<IdToken>;
|
|
49
|
+
getDecodedIdToken(sessionId?: string): Promise<IdToken>;
|
|
50
50
|
getDecodedIDPIDToken(): Promise<IdToken>;
|
|
51
51
|
getCrypto(): Promise<IsomorphicCrypto>;
|
|
52
52
|
getIdToken(): Promise<string>;
|
|
@@ -36,7 +36,7 @@ export interface MainThreadClientInterface {
|
|
|
36
36
|
refreshAccessToken(): Promise<User>;
|
|
37
37
|
revokeAccessToken(): Promise<boolean>;
|
|
38
38
|
getUser(): Promise<User>;
|
|
39
|
-
getDecodedIdToken(): Promise<IdToken>;
|
|
39
|
+
getDecodedIdToken(sessionId?: string): Promise<IdToken>;
|
|
40
40
|
getCrypto(): Promise<IsomorphicCrypto>;
|
|
41
41
|
getConfigData(): Promise<AuthClientConfig<MainThreadClientConfig>>;
|
|
42
42
|
getIdToken(): Promise<string>;
|
|
@@ -65,7 +65,7 @@ export interface WebWorkerClientInterface {
|
|
|
65
65
|
getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
|
|
66
66
|
getUser(): Promise<User>;
|
|
67
67
|
getConfigData(): Promise<AuthClientConfig<WebWorkerClientConfig>>;
|
|
68
|
-
getDecodedIdToken(): Promise<IdToken>;
|
|
68
|
+
getDecodedIdToken(sessionId?: string): Promise<IdToken>;
|
|
69
69
|
getDecodedIDPIDToken(): Promise<IdToken>;
|
|
70
70
|
getCrypto(): Promise<IsomorphicCrypto>;
|
|
71
71
|
getIdToken(): Promise<string>;
|
|
@@ -41,7 +41,7 @@ export interface WebWorkerCoreInterface {
|
|
|
41
41
|
refreshAccessToken(): Promise<User>;
|
|
42
42
|
revokeAccessToken(): Promise<boolean>;
|
|
43
43
|
getUser(): Promise<User>;
|
|
44
|
-
getDecodedIdToken(): Promise<IdToken>;
|
|
44
|
+
getDecodedIdToken(sessionId?: string): Promise<IdToken>;
|
|
45
45
|
getDecodedIDPIDToken(): Promise<IdToken>;
|
|
46
46
|
getCrypto(): Promise<IsomorphicCrypto>;
|
|
47
47
|
getIdToken(): Promise<string>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1943,6 +1943,9 @@ __export(index_exports, {
|
|
|
1943
1943
|
TOKEN_REQUEST_CONFIG_KEY: () => TOKEN_REQUEST_CONFIG_KEY,
|
|
1944
1944
|
WebWorkerClass: () => WebWorkerClass,
|
|
1945
1945
|
WebWorkerClient: () => WebWorkerClient,
|
|
1946
|
+
createClassObserver: () => createClassObserver,
|
|
1947
|
+
createMediaQueryListener: () => createMediaQueryListener,
|
|
1948
|
+
detectThemeMode: () => detectThemeMode,
|
|
1946
1949
|
hasAuthParamsInUrl: () => hasAuthParamsInUrl_default,
|
|
1947
1950
|
workerReceiver: () => workerReceiver
|
|
1948
1951
|
});
|
|
@@ -2986,7 +2989,7 @@ var MainThreadClient = async (instanceID, config, getAuthHelper) => {
|
|
|
2986
2989
|
tokenRequestConfig
|
|
2987
2990
|
);
|
|
2988
2991
|
const getUser = async () => _authenticationHelper.getUser();
|
|
2989
|
-
const getDecodedIdToken = async () => _authenticationHelper.getDecodedIdToken();
|
|
2992
|
+
const getDecodedIdToken = async (sessionId) => _authenticationHelper.getDecodedIdToken(sessionId);
|
|
2990
2993
|
const getCrypto = async () => _authenticationHelper.getCrypto();
|
|
2991
2994
|
const getIdToken = async () => _authenticationHelper.getIdToken();
|
|
2992
2995
|
const getOpenIDProviderEndpoints = async () => _authenticationHelper.getOpenIDProviderEndpoints();
|
|
@@ -3469,8 +3472,8 @@ var AuthenticationHelper = class {
|
|
|
3469
3472
|
async getUser() {
|
|
3470
3473
|
return this._authenticationClient.getUser();
|
|
3471
3474
|
}
|
|
3472
|
-
async getDecodedIdToken() {
|
|
3473
|
-
return this._authenticationClient.getDecodedIdToken();
|
|
3475
|
+
async getDecodedIdToken(sessionId) {
|
|
3476
|
+
return this._authenticationClient.getDecodedIdToken(sessionId);
|
|
3474
3477
|
}
|
|
3475
3478
|
async getDecodedIDPIDToken() {
|
|
3476
3479
|
return this._authenticationClient.getDecodedIdToken();
|
|
@@ -3904,7 +3907,7 @@ var WebWorkerClient = async (instanceID, config, webWorker, getAuthHelper) => {
|
|
|
3904
3907
|
return Promise.reject(error);
|
|
3905
3908
|
});
|
|
3906
3909
|
};
|
|
3907
|
-
const getDecodedIdToken = () => {
|
|
3910
|
+
const getDecodedIdToken = (sessionId) => {
|
|
3908
3911
|
const message = {
|
|
3909
3912
|
type: GET_DECODED_ID_TOKEN
|
|
3910
3913
|
};
|
|
@@ -4024,7 +4027,7 @@ var WebWorkerClient = async (instanceID, config, webWorker, getAuthHelper) => {
|
|
|
4024
4027
|
|
|
4025
4028
|
// src/__legacy__/client.ts
|
|
4026
4029
|
var DefaultConfig = {
|
|
4027
|
-
autoLogoutOnTokenRefreshError:
|
|
4030
|
+
autoLogoutOnTokenRefreshError: false,
|
|
4028
4031
|
checkSessionInterval: 3,
|
|
4029
4032
|
enableOIDCSessionManagement: false,
|
|
4030
4033
|
periodicTokenRefresh: false,
|
|
@@ -4603,9 +4606,9 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
|
|
|
4603
4606
|
*
|
|
4604
4607
|
* @preserve
|
|
4605
4608
|
*/
|
|
4606
|
-
async getDecodedIdToken() {
|
|
4609
|
+
async getDecodedIdToken(sessionId) {
|
|
4607
4610
|
await this._validateMethod();
|
|
4608
|
-
return this._client?.getDecodedIdToken();
|
|
4611
|
+
return this._client?.getDecodedIdToken(sessionId);
|
|
4609
4612
|
}
|
|
4610
4613
|
/**
|
|
4611
4614
|
* This method returns the IsomorphicCrypto instance.
|
|
@@ -5067,8 +5070,8 @@ var WebWorkerCore = async (config, getAuthHelper) => {
|
|
|
5067
5070
|
const getUser = async () => {
|
|
5068
5071
|
return _authenticationHelper.getUser();
|
|
5069
5072
|
};
|
|
5070
|
-
const getDecodedIdToken = async () => {
|
|
5071
|
-
return _authenticationHelper.getDecodedIdToken();
|
|
5073
|
+
const getDecodedIdToken = async (sessionId) => {
|
|
5074
|
+
return _authenticationHelper.getDecodedIdToken(sessionId);
|
|
5072
5075
|
};
|
|
5073
5076
|
const getCrypto = async () => {
|
|
5074
5077
|
return _authenticationHelper.getCrypto();
|
|
@@ -5355,6 +5358,73 @@ var AsgardeoBrowserClient_default = AsgardeoBrowserClient;
|
|
|
5355
5358
|
|
|
5356
5359
|
// src/index.ts
|
|
5357
5360
|
__reExport(index_exports, require("@asgardeo/javascript"), module.exports);
|
|
5361
|
+
|
|
5362
|
+
// src/theme/themeDetection.ts
|
|
5363
|
+
var detectThemeMode = (mode, config = {}) => {
|
|
5364
|
+
const {
|
|
5365
|
+
darkClass = "dark",
|
|
5366
|
+
lightClass = "light",
|
|
5367
|
+
targetElement = typeof document !== "undefined" ? document.documentElement : null
|
|
5368
|
+
} = config;
|
|
5369
|
+
if (mode === "light") return "light";
|
|
5370
|
+
if (mode === "dark") return "dark";
|
|
5371
|
+
if (mode === "system") {
|
|
5372
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
5373
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
5374
|
+
}
|
|
5375
|
+
return "light";
|
|
5376
|
+
}
|
|
5377
|
+
if (mode === "class") {
|
|
5378
|
+
if (!targetElement) {
|
|
5379
|
+
console.warn("ThemeDetection: targetElement is required for class-based detection, falling back to light mode");
|
|
5380
|
+
return "light";
|
|
5381
|
+
}
|
|
5382
|
+
const classList = targetElement.classList;
|
|
5383
|
+
if (classList.contains(darkClass)) {
|
|
5384
|
+
return "dark";
|
|
5385
|
+
}
|
|
5386
|
+
if (classList.contains(lightClass)) {
|
|
5387
|
+
return "light";
|
|
5388
|
+
}
|
|
5389
|
+
return "light";
|
|
5390
|
+
}
|
|
5391
|
+
return "light";
|
|
5392
|
+
};
|
|
5393
|
+
var createClassObserver = (targetElement, callback, config = {}) => {
|
|
5394
|
+
const { darkClass = "dark", lightClass = "light" } = config;
|
|
5395
|
+
const observer = new MutationObserver((mutations) => {
|
|
5396
|
+
mutations.forEach((mutation) => {
|
|
5397
|
+
if (mutation.type === "attributes" && mutation.attributeName === "class") {
|
|
5398
|
+
const classList = targetElement.classList;
|
|
5399
|
+
if (classList.contains(darkClass)) {
|
|
5400
|
+
callback(true);
|
|
5401
|
+
} else if (classList.contains(lightClass)) {
|
|
5402
|
+
callback(false);
|
|
5403
|
+
}
|
|
5404
|
+
}
|
|
5405
|
+
});
|
|
5406
|
+
});
|
|
5407
|
+
observer.observe(targetElement, {
|
|
5408
|
+
attributes: true,
|
|
5409
|
+
attributeFilter: ["class"]
|
|
5410
|
+
});
|
|
5411
|
+
return observer;
|
|
5412
|
+
};
|
|
5413
|
+
var createMediaQueryListener = (callback) => {
|
|
5414
|
+
if (typeof window === "undefined" || !window.matchMedia) {
|
|
5415
|
+
return null;
|
|
5416
|
+
}
|
|
5417
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
5418
|
+
const handleChange = (e) => {
|
|
5419
|
+
callback(e.matches);
|
|
5420
|
+
};
|
|
5421
|
+
if (mediaQuery.addEventListener) {
|
|
5422
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
5423
|
+
} else {
|
|
5424
|
+
mediaQuery.addListener(handleChange);
|
|
5425
|
+
}
|
|
5426
|
+
return mediaQuery;
|
|
5427
|
+
};
|
|
5358
5428
|
/*! Bundled license information:
|
|
5359
5429
|
|
|
5360
5430
|
ieee754/index.js:
|