@base44-preview/sdk 0.8.48-pr.282.7b5ff6d → 0.8.48-pr.282.7c5a459
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/client.js +18 -23
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -59,29 +59,6 @@ export function createClient(config) {
|
|
|
59
59
|
// Normalize appBaseUrl to always be a string (empty if not provided or invalid)
|
|
60
60
|
const normalizedAppBaseUrl = typeof appBaseUrl === "string" ? appBaseUrl : "";
|
|
61
61
|
const embedOtt = takeEmbedTokenFromUrl();
|
|
62
|
-
// Asked again on every use, so a session that arrives later — from the
|
|
63
|
-
// exchange, or from a login — reaches the socket and every other module.
|
|
64
|
-
// A declaration, not a const, so this block can stay above the auth module.
|
|
65
|
-
function getToken() {
|
|
66
|
-
var _a;
|
|
67
|
-
return (_a = userAuthModule.getToken()) !== null && _a !== void 0 ? _a : (embedOtt ? null : getAccessToken());
|
|
68
|
-
}
|
|
69
|
-
const socketConfig = {
|
|
70
|
-
serverUrl,
|
|
71
|
-
mountPath: "/ws-user-apps/socket.io/",
|
|
72
|
-
transports: ["websocket"],
|
|
73
|
-
appId,
|
|
74
|
-
getToken,
|
|
75
|
-
};
|
|
76
|
-
let socket = null;
|
|
77
|
-
const getSocket = () => {
|
|
78
|
-
if (!socket) {
|
|
79
|
-
socket = RoomsSocket({
|
|
80
|
-
config: socketConfig,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return socket;
|
|
84
|
-
};
|
|
85
62
|
// In a frame the caller's token is the OTT itself, which is not a session.
|
|
86
63
|
const token = embedOtt ? undefined : config.token;
|
|
87
64
|
const headers = {
|
|
@@ -132,6 +109,9 @@ export function createClient(config) {
|
|
|
132
109
|
baseURL: `${serverUrl}/api`,
|
|
133
110
|
headers,
|
|
134
111
|
});
|
|
112
|
+
// Declared before the auth module so `onSessionChange` can reach it; the
|
|
113
|
+
// socket itself is still only built on first use, below.
|
|
114
|
+
let socket = null;
|
|
135
115
|
const userAuthModule = createAuthModule(axiosClient, functionsAxiosClient, appId, {
|
|
136
116
|
appBaseUrl: normalizedAppBaseUrl,
|
|
137
117
|
serverUrl,
|
|
@@ -154,6 +134,21 @@ export function createClient(config) {
|
|
|
154
134
|
userAuthModule.setToken(accessToken);
|
|
155
135
|
}
|
|
156
136
|
}
|
|
137
|
+
// Live token for every module; outside a frame it still falls back to storage.
|
|
138
|
+
const getToken = () => { var _a; return (_a = userAuthModule.getToken()) !== null && _a !== void 0 ? _a : (embedOtt ? null : getAccessToken()); };
|
|
139
|
+
const socketConfig = {
|
|
140
|
+
serverUrl,
|
|
141
|
+
mountPath: "/ws-user-apps/socket.io/",
|
|
142
|
+
transports: ["websocket"],
|
|
143
|
+
appId,
|
|
144
|
+
getToken,
|
|
145
|
+
};
|
|
146
|
+
const getSocket = () => {
|
|
147
|
+
if (!socket) {
|
|
148
|
+
socket = RoomsSocket({ config: socketConfig });
|
|
149
|
+
}
|
|
150
|
+
return socket;
|
|
151
|
+
};
|
|
157
152
|
// The exchange belongs to the frame, not to one client: the token is off the
|
|
158
153
|
// URL after the first `createClient`, so a second one in the same document
|
|
159
154
|
// joins the session already being negotiated rather than going anonymous.
|