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.js
CHANGED
|
@@ -1809,7 +1809,16 @@ var RefreshFlow = class {
|
|
|
1809
1809
|
error: error instanceof Error ? error.message : String(error)
|
|
1810
1810
|
});
|
|
1811
1811
|
}
|
|
1812
|
-
const
|
|
1812
|
+
const tenantKeyFromRuntime = getTenantKeyFromRuntime(getUrl(), runtime.configProvider);
|
|
1813
|
+
const tenantKeyFromStorage = getStorage(getStorageKey("tenant_key"));
|
|
1814
|
+
const tenantKeyFromConfig = runtime.configProvider.getClientCode?.() ?? "";
|
|
1815
|
+
const tenantKey = (tenantKeyFromRuntime || tenantKeyFromStorage || tenantKeyFromConfig)?.trim();
|
|
1816
|
+
log.debug("[RefreshFlow] Tenant key resolved", {
|
|
1817
|
+
tenantKey: tenantKey ?? "(null)",
|
|
1818
|
+
fromRuntime: tenantKeyFromRuntime ?? "(null)",
|
|
1819
|
+
fromStorage: tenantKeyFromStorage ?? "(null)",
|
|
1820
|
+
fromConfig: tenantKeyFromConfig || "(null)"
|
|
1821
|
+
});
|
|
1813
1822
|
if (!tenantKey) {
|
|
1814
1823
|
throw new SanitizedError(
|
|
1815
1824
|
"TENANT_KEY_RESOLUTION_FAILED",
|
|
@@ -1843,7 +1852,17 @@ var TenantSwitchFlow = class {
|
|
|
1843
1852
|
emitAuthEvent(AuthEventNames.TENANT_SWITCHED, { tenantKey: newTenantKey ?? void 0 });
|
|
1844
1853
|
removeStorage(getStorageKey("tenant_switched"));
|
|
1845
1854
|
removeStorage(getStorageKey("new_tenant_key"));
|
|
1846
|
-
const
|
|
1855
|
+
const tenantKeyFromRuntime = getTenantKeyFromRuntime(getUrl(), runtime.configProvider);
|
|
1856
|
+
const tenantKeyFromStorage = getStorage(getStorageKey("tenant_key"));
|
|
1857
|
+
const tenantKeyFromConfig = runtime.configProvider.getClientCode?.() ?? "";
|
|
1858
|
+
const tenantKey = (newTenantKey || tenantKeyFromRuntime || tenantKeyFromStorage || tenantKeyFromConfig)?.trim();
|
|
1859
|
+
log.debug("[TenantSwitchFlow] Tenant key resolved", {
|
|
1860
|
+
tenantKey: tenantKey ?? "(null)",
|
|
1861
|
+
fromNewTenantKey: newTenantKey ?? "(null)",
|
|
1862
|
+
fromRuntime: tenantKeyFromRuntime ?? "(null)",
|
|
1863
|
+
fromStorage: tenantKeyFromStorage ?? "(null)",
|
|
1864
|
+
fromConfig: tenantKeyFromConfig || "(null)"
|
|
1865
|
+
});
|
|
1847
1866
|
if (!tenantKey) {
|
|
1848
1867
|
throw new SanitizedError(
|
|
1849
1868
|
"TENANT_KEY_RESOLUTION_FAILED",
|
|
@@ -1883,8 +1902,16 @@ var LoginFlow = class {
|
|
|
1883
1902
|
}
|
|
1884
1903
|
const wasStateMismatch = getStorage(getStorageKey("state_mismatch")) === "true";
|
|
1885
1904
|
if (wasStateMismatch) removeStorage(getStorageKey("state_mismatch"));
|
|
1886
|
-
const
|
|
1887
|
-
|
|
1905
|
+
const tenantKeyFromRuntime = getTenantKeyFromRuntime(url, runtime.configProvider);
|
|
1906
|
+
const tenantKeyFromStorage = getStorage(getStorageKey("tenant_key"));
|
|
1907
|
+
const tenantKeyFromConfig = runtime.configProvider.getClientCode?.() ?? "";
|
|
1908
|
+
const tenantKey = (tenantKeyFromRuntime || tenantKeyFromStorage || tenantKeyFromConfig)?.trim();
|
|
1909
|
+
log.debug("[LoginFlow] Tenant key resolved", {
|
|
1910
|
+
tenantKey: tenantKey ?? "(null)",
|
|
1911
|
+
fromRuntime: tenantKeyFromRuntime ?? "(null)",
|
|
1912
|
+
fromStorage: tenantKeyFromStorage ?? "(null)",
|
|
1913
|
+
fromConfig: tenantKeyFromConfig || "(null)"
|
|
1914
|
+
});
|
|
1888
1915
|
if (!tenantKey) {
|
|
1889
1916
|
throw new SanitizedError(
|
|
1890
1917
|
"TENANT_KEY_RESOLUTION_FAILED",
|
|
@@ -2961,9 +2988,9 @@ function AuthProvider({
|
|
|
2961
2988
|
};
|
|
2962
2989
|
}, [resolvedTenantKey, appId, storageAdapter]);
|
|
2963
2990
|
react.useEffect(() => {
|
|
2964
|
-
const resolvedTenantKey2 =
|
|
2991
|
+
const resolvedTenantKey2 = mergedTenantCode ?? Config.getClientCode();
|
|
2965
2992
|
logger.debug("[AuthProvider] Props from host app", {
|
|
2966
|
-
tenantCode:
|
|
2993
|
+
tenantCode: mergedTenantCode ?? "(not provided)",
|
|
2967
2994
|
appId: appId ?? "",
|
|
2968
2995
|
resolvedTenantKey: resolvedTenantKey2
|
|
2969
2996
|
});
|
|
@@ -3011,7 +3038,7 @@ function AuthProvider({
|
|
|
3011
3038
|
} else {
|
|
3012
3039
|
logger.debug("[AuthProvider] No tenant code determined");
|
|
3013
3040
|
}
|
|
3014
|
-
}, [
|
|
3041
|
+
}, [mergedTenantCode, appId]);
|
|
3015
3042
|
const [state, setState] = react.useState({
|
|
3016
3043
|
isAuthenticated: false,
|
|
3017
3044
|
accessToken: null,
|
|
@@ -3075,7 +3102,7 @@ function AuthProvider({
|
|
|
3075
3102
|
return () => {
|
|
3076
3103
|
cancelled = true;
|
|
3077
3104
|
};
|
|
3078
|
-
}, [autoInit,
|
|
3105
|
+
}, [autoInit, mergedTenantCode, syncAuthState]);
|
|
3079
3106
|
react.useEffect(() => {
|
|
3080
3107
|
if (!autoInit) {
|
|
3081
3108
|
setState((prev) => ({ ...prev, isLoading: false }));
|
|
@@ -3119,7 +3146,7 @@ function AuthProvider({
|
|
|
3119
3146
|
stopCookieWatcher();
|
|
3120
3147
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
3121
3148
|
try {
|
|
3122
|
-
await engineRef.current?.logout({ tenantKey:
|
|
3149
|
+
await engineRef.current?.logout({ tenantKey: mergedTenantCode });
|
|
3123
3150
|
resetCookieWatcher();
|
|
3124
3151
|
} finally {
|
|
3125
3152
|
stopStorageWatcher();
|
|
@@ -3131,7 +3158,7 @@ function AuthProvider({
|
|
|
3131
3158
|
error: null
|
|
3132
3159
|
});
|
|
3133
3160
|
}
|
|
3134
|
-
}, [
|
|
3161
|
+
}, [mergedTenantCode]);
|
|
3135
3162
|
const refreshToken = react.useCallback(async () => {
|
|
3136
3163
|
try {
|
|
3137
3164
|
const newToken = await engineRef.current?.refresh() ?? "";
|