@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
package/dist/index.d.ts
CHANGED
|
@@ -33,3 +33,4 @@ export { AsgardeoBrowserConfig } from './models/config';
|
|
|
33
33
|
export { default as hasAuthParamsInUrl } from './utils/hasAuthParamsInUrl';
|
|
34
34
|
export { default as AsgardeoBrowserClient } from './AsgardeoBrowserClient';
|
|
35
35
|
export * from '@asgardeo/javascript';
|
|
36
|
+
export { detectThemeMode, createClassObserver, createMediaQueryListener, BrowserThemeDetection, } from './theme/themeDetection';
|
package/dist/index.js
CHANGED
|
@@ -2957,7 +2957,7 @@ var MainThreadClient = async (instanceID, config, getAuthHelper) => {
|
|
|
2957
2957
|
tokenRequestConfig
|
|
2958
2958
|
);
|
|
2959
2959
|
const getUser = async () => _authenticationHelper.getUser();
|
|
2960
|
-
const getDecodedIdToken = async () => _authenticationHelper.getDecodedIdToken();
|
|
2960
|
+
const getDecodedIdToken = async (sessionId) => _authenticationHelper.getDecodedIdToken(sessionId);
|
|
2961
2961
|
const getCrypto = async () => _authenticationHelper.getCrypto();
|
|
2962
2962
|
const getIdToken = async () => _authenticationHelper.getIdToken();
|
|
2963
2963
|
const getOpenIDProviderEndpoints = async () => _authenticationHelper.getOpenIDProviderEndpoints();
|
|
@@ -3448,8 +3448,8 @@ var AuthenticationHelper = class {
|
|
|
3448
3448
|
async getUser() {
|
|
3449
3449
|
return this._authenticationClient.getUser();
|
|
3450
3450
|
}
|
|
3451
|
-
async getDecodedIdToken() {
|
|
3452
|
-
return this._authenticationClient.getDecodedIdToken();
|
|
3451
|
+
async getDecodedIdToken(sessionId) {
|
|
3452
|
+
return this._authenticationClient.getDecodedIdToken(sessionId);
|
|
3453
3453
|
}
|
|
3454
3454
|
async getDecodedIDPIDToken() {
|
|
3455
3455
|
return this._authenticationClient.getDecodedIdToken();
|
|
@@ -3883,7 +3883,7 @@ var WebWorkerClient = async (instanceID, config, webWorker, getAuthHelper) => {
|
|
|
3883
3883
|
return Promise.reject(error);
|
|
3884
3884
|
});
|
|
3885
3885
|
};
|
|
3886
|
-
const getDecodedIdToken = () => {
|
|
3886
|
+
const getDecodedIdToken = (sessionId) => {
|
|
3887
3887
|
const message = {
|
|
3888
3888
|
type: GET_DECODED_ID_TOKEN
|
|
3889
3889
|
};
|
|
@@ -4003,7 +4003,7 @@ var WebWorkerClient = async (instanceID, config, webWorker, getAuthHelper) => {
|
|
|
4003
4003
|
|
|
4004
4004
|
// src/__legacy__/client.ts
|
|
4005
4005
|
var DefaultConfig = {
|
|
4006
|
-
autoLogoutOnTokenRefreshError:
|
|
4006
|
+
autoLogoutOnTokenRefreshError: false,
|
|
4007
4007
|
checkSessionInterval: 3,
|
|
4008
4008
|
enableOIDCSessionManagement: false,
|
|
4009
4009
|
periodicTokenRefresh: false,
|
|
@@ -4582,9 +4582,9 @@ var _AsgardeoSPAClient = class _AsgardeoSPAClient {
|
|
|
4582
4582
|
*
|
|
4583
4583
|
* @preserve
|
|
4584
4584
|
*/
|
|
4585
|
-
async getDecodedIdToken() {
|
|
4585
|
+
async getDecodedIdToken(sessionId) {
|
|
4586
4586
|
await this._validateMethod();
|
|
4587
|
-
return this._client?.getDecodedIdToken();
|
|
4587
|
+
return this._client?.getDecodedIdToken(sessionId);
|
|
4588
4588
|
}
|
|
4589
4589
|
/**
|
|
4590
4590
|
* This method returns the IsomorphicCrypto instance.
|
|
@@ -5062,8 +5062,8 @@ var WebWorkerCore = async (config, getAuthHelper) => {
|
|
|
5062
5062
|
const getUser = async () => {
|
|
5063
5063
|
return _authenticationHelper.getUser();
|
|
5064
5064
|
};
|
|
5065
|
-
const getDecodedIdToken = async () => {
|
|
5066
|
-
return _authenticationHelper.getDecodedIdToken();
|
|
5065
|
+
const getDecodedIdToken = async (sessionId) => {
|
|
5066
|
+
return _authenticationHelper.getDecodedIdToken(sessionId);
|
|
5067
5067
|
};
|
|
5068
5068
|
const getCrypto = async () => {
|
|
5069
5069
|
return _authenticationHelper.getCrypto();
|
|
@@ -5350,6 +5350,73 @@ var AsgardeoBrowserClient_default = AsgardeoBrowserClient;
|
|
|
5350
5350
|
|
|
5351
5351
|
// src/index.ts
|
|
5352
5352
|
export * from "@asgardeo/javascript";
|
|
5353
|
+
|
|
5354
|
+
// src/theme/themeDetection.ts
|
|
5355
|
+
var detectThemeMode = (mode, config = {}) => {
|
|
5356
|
+
const {
|
|
5357
|
+
darkClass = "dark",
|
|
5358
|
+
lightClass = "light",
|
|
5359
|
+
targetElement = typeof document !== "undefined" ? document.documentElement : null
|
|
5360
|
+
} = config;
|
|
5361
|
+
if (mode === "light") return "light";
|
|
5362
|
+
if (mode === "dark") return "dark";
|
|
5363
|
+
if (mode === "system") {
|
|
5364
|
+
if (typeof window !== "undefined" && window.matchMedia) {
|
|
5365
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
5366
|
+
}
|
|
5367
|
+
return "light";
|
|
5368
|
+
}
|
|
5369
|
+
if (mode === "class") {
|
|
5370
|
+
if (!targetElement) {
|
|
5371
|
+
console.warn("ThemeDetection: targetElement is required for class-based detection, falling back to light mode");
|
|
5372
|
+
return "light";
|
|
5373
|
+
}
|
|
5374
|
+
const classList = targetElement.classList;
|
|
5375
|
+
if (classList.contains(darkClass)) {
|
|
5376
|
+
return "dark";
|
|
5377
|
+
}
|
|
5378
|
+
if (classList.contains(lightClass)) {
|
|
5379
|
+
return "light";
|
|
5380
|
+
}
|
|
5381
|
+
return "light";
|
|
5382
|
+
}
|
|
5383
|
+
return "light";
|
|
5384
|
+
};
|
|
5385
|
+
var createClassObserver = (targetElement, callback, config = {}) => {
|
|
5386
|
+
const { darkClass = "dark", lightClass = "light" } = config;
|
|
5387
|
+
const observer = new MutationObserver((mutations) => {
|
|
5388
|
+
mutations.forEach((mutation) => {
|
|
5389
|
+
if (mutation.type === "attributes" && mutation.attributeName === "class") {
|
|
5390
|
+
const classList = targetElement.classList;
|
|
5391
|
+
if (classList.contains(darkClass)) {
|
|
5392
|
+
callback(true);
|
|
5393
|
+
} else if (classList.contains(lightClass)) {
|
|
5394
|
+
callback(false);
|
|
5395
|
+
}
|
|
5396
|
+
}
|
|
5397
|
+
});
|
|
5398
|
+
});
|
|
5399
|
+
observer.observe(targetElement, {
|
|
5400
|
+
attributes: true,
|
|
5401
|
+
attributeFilter: ["class"]
|
|
5402
|
+
});
|
|
5403
|
+
return observer;
|
|
5404
|
+
};
|
|
5405
|
+
var createMediaQueryListener = (callback) => {
|
|
5406
|
+
if (typeof window === "undefined" || !window.matchMedia) {
|
|
5407
|
+
return null;
|
|
5408
|
+
}
|
|
5409
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
5410
|
+
const handleChange = (e) => {
|
|
5411
|
+
callback(e.matches);
|
|
5412
|
+
};
|
|
5413
|
+
if (mediaQuery.addEventListener) {
|
|
5414
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
5415
|
+
} else {
|
|
5416
|
+
mediaQuery.addListener(handleChange);
|
|
5417
|
+
}
|
|
5418
|
+
return mediaQuery;
|
|
5419
|
+
};
|
|
5353
5420
|
export {
|
|
5354
5421
|
AsgardeoBrowserClient_default as AsgardeoBrowserClient,
|
|
5355
5422
|
AsgardeoSPAClient,
|
|
@@ -5373,6 +5440,9 @@ export {
|
|
|
5373
5440
|
TOKEN_REQUEST_CONFIG_KEY,
|
|
5374
5441
|
WebWorkerClass,
|
|
5375
5442
|
WebWorkerClient,
|
|
5443
|
+
createClassObserver,
|
|
5444
|
+
createMediaQueryListener,
|
|
5445
|
+
detectThemeMode,
|
|
5376
5446
|
hasAuthParamsInUrl_default as hasAuthParamsInUrl,
|
|
5377
5447
|
workerReceiver
|
|
5378
5448
|
};
|