@spidy092/auth-client 1.0.11 → 1.0.12

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.
Files changed (2) hide show
  1. package/core.js +25 -0
  2. package/package.json +1 -1
package/core.js CHANGED
@@ -176,3 +176,28 @@ function clientLogout(clientKey, accountUiUrl) {
176
176
  const logoutUrl = `${accountUiUrl}/login?client=${clientKey}&logout=true`;
177
177
  window.location.href = logoutUrl;
178
178
  }
179
+
180
+
181
+ export async function refreshToken() {
182
+ const { clientKey, authBaseUrl } = getConfig();
183
+
184
+ console.log('🔄 Refreshing token:', { clientKey, mode: isRouterMode() ? 'ROUTER' : 'CLIENT' });
185
+
186
+ try {
187
+ const response = await fetch(`${authBaseUrl}/refresh/${clientKey}`, {
188
+ method: 'POST',
189
+ credentials: 'include',
190
+ });
191
+
192
+ if (!response.ok) {
193
+ throw new Error('Refresh failed');
194
+ }
195
+
196
+ const { access_token } = await response.json();
197
+ setToken(access_token);
198
+ return access_token;
199
+ } catch (err) {
200
+ clearToken();
201
+ throw err;
202
+ }
203
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spidy092/auth-client",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Scalable frontend auth SDK for centralized login using Keycloak + Auth Service.",
5
5
  "main": "index.js",
6
6
  "module": "index.js",