dynim-react 1.0.42 → 1.0.44
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/DynimProvider.d.ts
CHANGED
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
import { type ReactNode } from 'react';
|
|
10
10
|
import type { CodeMessage } from 'dynim-core';
|
|
11
11
|
export interface DynimConfig {
|
|
12
|
-
/**
|
|
13
|
-
sessionToken?: string;
|
|
14
|
-
/** Function to fetch a new session when current one expires */
|
|
12
|
+
/** Function to fetch a session token for authentication */
|
|
15
13
|
getSession?: () => Promise<{
|
|
16
14
|
token: string;
|
|
17
15
|
refreshToken?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EAQZ,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAKV,WAAW,EAEZ,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,WAAW;IAC1B,
|
|
1
|
+
{"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EAQZ,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAKV,WAAW,EAEZ,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrE,kCAAkC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,KAAK,IAAI,CAAC;IACzC,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,qBAAqB;IACrB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,yBAAyB;IACzB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,oCAAoC;IACpC,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,yDAAyD;IACzD,WAAW,EAAE,WAAW,CAAC;IACzB,2CAA2C;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,gCAAgC;IAChC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,MAAW,GACZ,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAiYlC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAM5C"}
|
package/dist/DynimProvider.js
CHANGED
|
@@ -86,14 +86,10 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
}, []);
|
|
89
|
-
// Get auth token
|
|
89
|
+
// Get auth token (cached after first call)
|
|
90
90
|
const getAuthToken = useCallback(async () => {
|
|
91
|
-
const {
|
|
92
|
-
//
|
|
93
|
-
if (sessionToken) {
|
|
94
|
-
return sessionToken;
|
|
95
|
-
}
|
|
96
|
-
// Fast path: return cached token
|
|
91
|
+
const { getSession } = configRef.current;
|
|
92
|
+
// Return cached token if available
|
|
97
93
|
if (cachedTokenRef.current)
|
|
98
94
|
return cachedTokenRef.current;
|
|
99
95
|
// Reuse in-flight promise if one exists
|
|
@@ -199,35 +195,8 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
199
195
|
cleanup();
|
|
200
196
|
}
|
|
201
197
|
catch (error) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
setIsBundleLoaded(false);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
// 401 = token expired - refresh via getSession and retry
|
|
208
|
-
if (error instanceof BundleAuthError) {
|
|
209
|
-
cachedTokenRef.current = null; // Clear stale token
|
|
210
|
-
const { getSession } = configRef.current;
|
|
211
|
-
if (getSession) {
|
|
212
|
-
try {
|
|
213
|
-
const session = await getSession();
|
|
214
|
-
cachedTokenRef.current = session.token;
|
|
215
|
-
// Retry with fresh token
|
|
216
|
-
const { App, cleanup } = await loader.load(bundleUrl);
|
|
217
|
-
setTenantApp(() => App);
|
|
218
|
-
setIsBundleLoaded(true);
|
|
219
|
-
cleanup();
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
catch (retryError) {
|
|
223
|
-
if (retryError instanceof BundleNotFoundError) {
|
|
224
|
-
setTenantApp(null);
|
|
225
|
-
setIsBundleLoaded(false);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
// Retry also failed - show children
|
|
229
|
-
}
|
|
230
|
-
}
|
|
198
|
+
// 404 = no bundle, 401 = not authenticated - show children
|
|
199
|
+
if (error instanceof BundleNotFoundError || error instanceof BundleAuthError) {
|
|
231
200
|
setTenantApp(null);
|
|
232
201
|
setIsBundleLoaded(false);
|
|
233
202
|
return;
|
|
@@ -275,9 +244,9 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
275
244
|
if (hasAttemptedInitialLoadRef.current)
|
|
276
245
|
return;
|
|
277
246
|
hasAttemptedInitialLoadRef.current = true;
|
|
278
|
-
const {
|
|
247
|
+
const { getSession } = configRef.current;
|
|
279
248
|
// No auth configured = skip bundle load
|
|
280
|
-
if (!
|
|
249
|
+
if (!getSession) {
|
|
281
250
|
setIsInitialLoadComplete(true);
|
|
282
251
|
return;
|
|
283
252
|
}
|