@base44-preview/sdk 0.8.24-pr.134.4e99e37 → 0.8.24-pr.134.d84bc67

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.
@@ -57,7 +57,6 @@ function loginViaPopup(url, expectedOrigin, onToken) {
57
57
  */
58
58
  export function createAuthModule(axios, functionsAxiosClient, appId, options) {
59
59
  const listeners = new Set();
60
- let hasToken = false;
61
60
  function notify(event, data = {}) {
62
61
  listeners.forEach((cb) => cb(event, data));
63
62
  }
@@ -107,6 +106,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
107
106
  const popupLoginUrl = `${loginUrl}&popup_origin=${encodeURIComponent(window.location.origin)}`;
108
107
  return loginViaPopup(popupLoginUrl, window.location.origin, (token) => {
109
108
  this.setToken(token);
109
+ notify("SIGNED_IN", { access_token: token });
110
110
  });
111
111
  }
112
112
  // Default: full-page redirect
@@ -116,7 +116,6 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
116
116
  logout(redirectUrl) {
117
117
  // Remove token from axios headers (always do this)
118
118
  delete axios.defaults.headers.common["Authorization"];
119
- hasToken = false;
120
119
  notify("SIGNED_OUT");
121
120
  // Only do the rest if in a browser environment
122
121
  if (typeof window !== "undefined") {
@@ -142,7 +141,6 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
142
141
  setToken(token, saveToStorage = true) {
143
142
  if (!token)
144
143
  return;
145
- const event = hasToken ? "TOKEN_REFRESHED" : "SIGNED_IN";
146
144
  // handle token change for axios clients
147
145
  axios.defaults.headers.common["Authorization"] = `Bearer ${token}`;
148
146
  functionsAxiosClient.defaults.headers.common["Authorization"] = `Bearer ${token}`;
@@ -159,8 +157,6 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
159
157
  console.error("Failed to save token to localStorage:", e);
160
158
  }
161
159
  }
162
- hasToken = true;
163
- notify(event, { access_token: token });
164
160
  },
165
161
  // Login using username and password
166
162
  async loginViaEmailPassword(email, password, turnstileToken) {
@@ -174,6 +170,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
174
170
  const { access_token, user } = response;
175
171
  if (access_token) {
176
172
  this.setToken(access_token);
173
+ notify("SIGNED_IN", { access_token });
177
174
  }
178
175
  return {
179
176
  access_token,
@@ -96,7 +96,7 @@ export interface AuthModuleOptions {
96
96
  /**
97
97
  * Auth state change event types.
98
98
  */
99
- export type AuthEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED";
99
+ export type AuthEvent = "SIGNED_IN" | "SIGNED_OUT";
100
100
  /**
101
101
  * Data passed to auth state change callbacks.
102
102
  */
@@ -499,7 +499,6 @@ export interface AuthModule {
499
499
  * Events:
500
500
  * - `SIGNED_IN` — fired after a successful login (email/password, OAuth, or popup).
501
501
  * - `SIGNED_OUT` — fired after logout.
502
- * - `TOKEN_REFRESHED` — fired when `setToken` is called while already authenticated.
503
502
  *
504
503
  * Returns an unsubscribe function. Call it to stop receiving events.
505
504
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.24-pr.134.4e99e37",
3
+ "version": "0.8.24-pr.134.d84bc67",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",