tenneo-auth-plugin 0.1.10 → 1.0.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/index.js +37 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1803,7 +1803,16 @@ var RefreshFlow = class {
|
|
|
1803
1803
|
error: error instanceof Error ? error.message : String(error)
|
|
1804
1804
|
});
|
|
1805
1805
|
}
|
|
1806
|
-
const
|
|
1806
|
+
const tenantKeyFromRuntime = getTenantKeyFromRuntime(getUrl(), runtime.configProvider);
|
|
1807
|
+
const tenantKeyFromStorage = getStorage(getStorageKey("tenant_key"));
|
|
1808
|
+
const tenantKeyFromConfig = runtime.configProvider.getClientCode?.() ?? "";
|
|
1809
|
+
const tenantKey = (tenantKeyFromRuntime || tenantKeyFromStorage || tenantKeyFromConfig)?.trim();
|
|
1810
|
+
log.debug("[RefreshFlow] Tenant key resolved", {
|
|
1811
|
+
tenantKey: tenantKey ?? "(null)",
|
|
1812
|
+
fromRuntime: tenantKeyFromRuntime ?? "(null)",
|
|
1813
|
+
fromStorage: tenantKeyFromStorage ?? "(null)",
|
|
1814
|
+
fromConfig: tenantKeyFromConfig || "(null)"
|
|
1815
|
+
});
|
|
1807
1816
|
if (!tenantKey) {
|
|
1808
1817
|
throw new SanitizedError(
|
|
1809
1818
|
"TENANT_KEY_RESOLUTION_FAILED",
|
|
@@ -1837,7 +1846,17 @@ var TenantSwitchFlow = class {
|
|
|
1837
1846
|
emitAuthEvent(AuthEventNames.TENANT_SWITCHED, { tenantKey: newTenantKey ?? void 0 });
|
|
1838
1847
|
removeStorage(getStorageKey("tenant_switched"));
|
|
1839
1848
|
removeStorage(getStorageKey("new_tenant_key"));
|
|
1840
|
-
const
|
|
1849
|
+
const tenantKeyFromRuntime = getTenantKeyFromRuntime(getUrl(), runtime.configProvider);
|
|
1850
|
+
const tenantKeyFromStorage = getStorage(getStorageKey("tenant_key"));
|
|
1851
|
+
const tenantKeyFromConfig = runtime.configProvider.getClientCode?.() ?? "";
|
|
1852
|
+
const tenantKey = (newTenantKey || tenantKeyFromRuntime || tenantKeyFromStorage || tenantKeyFromConfig)?.trim();
|
|
1853
|
+
log.debug("[TenantSwitchFlow] Tenant key resolved", {
|
|
1854
|
+
tenantKey: tenantKey ?? "(null)",
|
|
1855
|
+
fromNewTenantKey: newTenantKey ?? "(null)",
|
|
1856
|
+
fromRuntime: tenantKeyFromRuntime ?? "(null)",
|
|
1857
|
+
fromStorage: tenantKeyFromStorage ?? "(null)",
|
|
1858
|
+
fromConfig: tenantKeyFromConfig || "(null)"
|
|
1859
|
+
});
|
|
1841
1860
|
if (!tenantKey) {
|
|
1842
1861
|
throw new SanitizedError(
|
|
1843
1862
|
"TENANT_KEY_RESOLUTION_FAILED",
|
|
@@ -1877,8 +1896,16 @@ var LoginFlow = class {
|
|
|
1877
1896
|
}
|
|
1878
1897
|
const wasStateMismatch = getStorage(getStorageKey("state_mismatch")) === "true";
|
|
1879
1898
|
if (wasStateMismatch) removeStorage(getStorageKey("state_mismatch"));
|
|
1880
|
-
const
|
|
1881
|
-
|
|
1899
|
+
const tenantKeyFromRuntime = getTenantKeyFromRuntime(url, runtime.configProvider);
|
|
1900
|
+
const tenantKeyFromStorage = getStorage(getStorageKey("tenant_key"));
|
|
1901
|
+
const tenantKeyFromConfig = runtime.configProvider.getClientCode?.() ?? "";
|
|
1902
|
+
const tenantKey = (tenantKeyFromRuntime || tenantKeyFromStorage || tenantKeyFromConfig)?.trim();
|
|
1903
|
+
log.debug("[LoginFlow] Tenant key resolved", {
|
|
1904
|
+
tenantKey: tenantKey ?? "(null)",
|
|
1905
|
+
fromRuntime: tenantKeyFromRuntime ?? "(null)",
|
|
1906
|
+
fromStorage: tenantKeyFromStorage ?? "(null)",
|
|
1907
|
+
fromConfig: tenantKeyFromConfig || "(null)"
|
|
1908
|
+
});
|
|
1882
1909
|
if (!tenantKey) {
|
|
1883
1910
|
throw new SanitizedError(
|
|
1884
1911
|
"TENANT_KEY_RESOLUTION_FAILED",
|
|
@@ -2955,9 +2982,9 @@ function AuthProvider({
|
|
|
2955
2982
|
};
|
|
2956
2983
|
}, [resolvedTenantKey, appId, storageAdapter]);
|
|
2957
2984
|
useEffect(() => {
|
|
2958
|
-
const resolvedTenantKey2 =
|
|
2985
|
+
const resolvedTenantKey2 = mergedTenantCode ?? Config.getClientCode();
|
|
2959
2986
|
logger.debug("[AuthProvider] Props from host app", {
|
|
2960
|
-
tenantCode:
|
|
2987
|
+
tenantCode: mergedTenantCode ?? "(not provided)",
|
|
2961
2988
|
appId: appId ?? "",
|
|
2962
2989
|
resolvedTenantKey: resolvedTenantKey2
|
|
2963
2990
|
});
|
|
@@ -3005,7 +3032,7 @@ function AuthProvider({
|
|
|
3005
3032
|
} else {
|
|
3006
3033
|
logger.debug("[AuthProvider] No tenant code determined");
|
|
3007
3034
|
}
|
|
3008
|
-
}, [
|
|
3035
|
+
}, [mergedTenantCode, appId]);
|
|
3009
3036
|
const [state, setState] = useState({
|
|
3010
3037
|
isAuthenticated: false,
|
|
3011
3038
|
accessToken: null,
|
|
@@ -3069,7 +3096,7 @@ function AuthProvider({
|
|
|
3069
3096
|
return () => {
|
|
3070
3097
|
cancelled = true;
|
|
3071
3098
|
};
|
|
3072
|
-
}, [autoInit,
|
|
3099
|
+
}, [autoInit, mergedTenantCode, syncAuthState]);
|
|
3073
3100
|
useEffect(() => {
|
|
3074
3101
|
if (!autoInit) {
|
|
3075
3102
|
setState((prev) => ({ ...prev, isLoading: false }));
|
|
@@ -3113,7 +3140,7 @@ function AuthProvider({
|
|
|
3113
3140
|
stopCookieWatcher();
|
|
3114
3141
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
3115
3142
|
try {
|
|
3116
|
-
await engineRef.current?.logout({ tenantKey:
|
|
3143
|
+
await engineRef.current?.logout({ tenantKey: mergedTenantCode });
|
|
3117
3144
|
resetCookieWatcher();
|
|
3118
3145
|
} finally {
|
|
3119
3146
|
stopStorageWatcher();
|
|
@@ -3125,7 +3152,7 @@ function AuthProvider({
|
|
|
3125
3152
|
error: null
|
|
3126
3153
|
});
|
|
3127
3154
|
}
|
|
3128
|
-
}, [
|
|
3155
|
+
}, [mergedTenantCode]);
|
|
3129
3156
|
const refreshToken = useCallback(async () => {
|
|
3130
3157
|
try {
|
|
3131
3158
|
const newToken = await engineRef.current?.refresh() ?? "";
|