@versini/auth0-react-thin 2.23.0 → 2.24.1
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/README.md +1 -1
- package/dist/auth0-context.d.ts +9 -0
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +142 -41
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +142 -42
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +142 -41
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +1 -1
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/use-auth0-suspense.d.ts +35 -0
- package/dist/use-auth0-suspense.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/auth0-context.tsx +10 -0
- package/src/auth0-provider.tsx +82 -10
- package/src/index.tsx +4 -0
- package/src/use-auth0-suspense.tsx +73 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Unofficial, community-maintained fork of [`@auth0/auth0-react`](https://www.npmjs.com/package/@auth0/auth0-react) — NOT affiliated with, endorsed by, sponsored by, or supported by Auth0 or Okta.**
|
|
4
4
|
|
|
5
|
-
This is [`@auth0/auth0-react@2.
|
|
5
|
+
This is [`@auth0/auth0-react@2.24.1`](https://www.npmjs.com/package/@auth0/auth0-react/v/2.24.1)
|
|
6
6
|
rebuilt with a single one-line Rollup change (`external: ['@auth0/auth0-spa-js']`) so it no
|
|
7
7
|
longer inlines that dependency. That drops ~26 KB gzip of first-paint weight for apps that use
|
|
8
8
|
only basic Auth0 login (no MFA/Passkey/MyAccount/DPoP). The public runtime API is otherwise
|
package/dist/auth0-context.d.ts
CHANGED
|
@@ -412,6 +412,15 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
412
412
|
* ```
|
|
413
413
|
*/
|
|
414
414
|
myAccount: MyAccountApiClient;
|
|
415
|
+
/**
|
|
416
|
+
* Internal. A promise that resolves when Auth0 initialization completes and
|
|
417
|
+
* rejects with the initialization error if it fails. Consumed by
|
|
418
|
+
* `useAuth0Suspense`, which also treats its absence as "no provider" — do not
|
|
419
|
+
* add a stub value for this field to `initialContext`. Not part of the
|
|
420
|
+
* supported public API.
|
|
421
|
+
* @ignore
|
|
422
|
+
*/
|
|
423
|
+
_initPromise?: Promise<void>;
|
|
415
424
|
}
|
|
416
425
|
/**
|
|
417
426
|
* @ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-context.d.ts","sourceRoot":"","sources":["../src/auth0-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,OAAO,EACP,aAAa,IAAI,gBAAgB,EACjC,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,IAAI,EACJ,+BAA+B,EAC/B,oBAAoB,IAAI,uBAAuB,EAC/C,KAAK,WAAW,EAChB,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC;CAAG;AAE9E,MAAM,WAAW,oBAAoB,CAAC,SAAS,GAAG,QAAQ,CACxD,SAAQ,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;CAAG;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,CAC9D,S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OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;CACvD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,IAClE,wBAAwB,CAAC,KAAK,CAAC,GAAG,kBAAkB,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,8BAA8B,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,IAClE,wBAAwB,CAAC,KAAK,CAAC,GAAG;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,IACtD,8BAA8B,CAAC,KAAK,CAAC,GACrC,8BAA8B,CAAC,KAAK,CAAC,CAAC;AA8D1C;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,aAAa,GAAI,KAAK,SAAS,IAAI,GAAG,IAAI,EAAE,MAAM,oBAAoB,CAAC,KAAK,CAAC,sBA+XlF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/dist/auth0-react.cjs.js
CHANGED
|
@@ -256,7 +256,7 @@ var toAuth0ClientOptions = function (opts) {
|
|
|
256
256
|
deprecateRedirectUri(opts);
|
|
257
257
|
return __assign(__assign({}, opts), { auth0Client: {
|
|
258
258
|
name: 'auth0-react',
|
|
259
|
-
version: '2.
|
|
259
|
+
version: '2.24.1',
|
|
260
260
|
} });
|
|
261
261
|
};
|
|
262
262
|
/**
|
|
@@ -266,6 +266,22 @@ var defaultOnRedirectCallback = function (appState) {
|
|
|
266
266
|
var _a;
|
|
267
267
|
window.history.replaceState({}, document.title, (_a = appState.returnTo) !== null && _a !== void 0 ? _a : window.location.pathname);
|
|
268
268
|
};
|
|
269
|
+
/**
|
|
270
|
+
* @ignore
|
|
271
|
+
*/
|
|
272
|
+
var createInitDeferred = function () {
|
|
273
|
+
var resolve;
|
|
274
|
+
var reject;
|
|
275
|
+
var promise = new Promise(function (res, rej) {
|
|
276
|
+
resolve = res;
|
|
277
|
+
reject = rej;
|
|
278
|
+
});
|
|
279
|
+
// Avoid unhandled-rejection warnings when no one is consuming the promise
|
|
280
|
+
// (i.e. useAuth0Suspense is not used). useAuth0Suspense attaches its own
|
|
281
|
+
// handler via use().
|
|
282
|
+
promise.catch(function () { return undefined; });
|
|
283
|
+
return { promise: promise, resolve: resolve, reject: reject };
|
|
284
|
+
};
|
|
269
285
|
/**
|
|
270
286
|
* ```jsx
|
|
271
287
|
* <Auth0Provider
|
|
@@ -292,55 +308,94 @@ var Auth0Provider = function (opts) {
|
|
|
292
308
|
}
|
|
293
309
|
var client = React.useState(function () { return providedClient !== null && providedClient !== void 0 ? providedClient : new auth0SpaJs.Auth0Client(toAuth0ClientOptions(clientOpts)); })[0];
|
|
294
310
|
var _d = React.useReducer((reducer), initialAuthState), state = _d[0], dispatch = _d[1];
|
|
311
|
+
// In state so the init retry below can swap in a fresh, non-rejected promise.
|
|
312
|
+
// Without that swap the first rejection would re-throw on every later render,
|
|
313
|
+
// making Error Boundary retries useless.
|
|
314
|
+
var _e = React.useState(createInitDeferred), initDeferred = _e[0], setInitDeferred = _e[1];
|
|
315
|
+
// Set only once initialization has genuinely rejected. State, not a ref, so
|
|
316
|
+
// the retry effect re-evaluates when init fails *after* the app has become
|
|
317
|
+
// authenticated by some other means.
|
|
318
|
+
var _f = React.useState(false), initFailed = _f[0], setInitFailed = _f[1];
|
|
319
|
+
// Guards against retrying more than once: a retry that also fails would
|
|
320
|
+
// otherwise re-trigger the effect for as long as the user stays signed in.
|
|
321
|
+
var initRetried = React.useRef(false);
|
|
295
322
|
var didInitialise = React.useRef(false);
|
|
296
323
|
var handleError = React.useCallback(function (error) {
|
|
297
324
|
dispatch({ type: 'ERROR', error: error });
|
|
298
325
|
return error;
|
|
299
326
|
}, []);
|
|
327
|
+
// Settles `deferred` according to what initialization actually did, so
|
|
328
|
+
// `_initPromise` never claims success that did not happen. `allowRedirect`
|
|
329
|
+
// is false on a retry: the redirect callback is single-use, so a retry can
|
|
330
|
+
// only re-verify the session.
|
|
331
|
+
var runInit = React.useCallback(function (deferred, allowRedirect) { return __awaiter(void 0, void 0, void 0, function () {
|
|
332
|
+
var user, _a, _b, appState, response_type, result, error_1, err;
|
|
333
|
+
return __generator(this, function (_c) {
|
|
334
|
+
switch (_c.label) {
|
|
335
|
+
case 0:
|
|
336
|
+
_c.trys.push([0, 7, , 8]);
|
|
337
|
+
user = void 0;
|
|
338
|
+
if (!(allowRedirect && hasAuthParams() && !skipRedirectCallback)) return [3 /*break*/, 3];
|
|
339
|
+
return [4 /*yield*/, client.handleRedirectCallback()];
|
|
340
|
+
case 1:
|
|
341
|
+
_a = _c.sent(), _b = _a.appState, appState = _b === void 0 ? {} : _b, response_type = _a.response_type, result = __rest(_a, ["appState", "response_type"]);
|
|
342
|
+
return [4 /*yield*/, client.getUser()];
|
|
343
|
+
case 2:
|
|
344
|
+
user = _c.sent();
|
|
345
|
+
appState.response_type = response_type;
|
|
346
|
+
if (response_type === auth0SpaJs.ResponseType.ConnectCode) {
|
|
347
|
+
appState.connectedAccount = result;
|
|
348
|
+
}
|
|
349
|
+
onRedirectCallback(appState, user);
|
|
350
|
+
return [3 /*break*/, 6];
|
|
351
|
+
case 3: return [4 /*yield*/, client.checkSession()];
|
|
352
|
+
case 4:
|
|
353
|
+
_c.sent();
|
|
354
|
+
return [4 /*yield*/, client.getUser()];
|
|
355
|
+
case 5:
|
|
356
|
+
user = _c.sent();
|
|
357
|
+
_c.label = 6;
|
|
358
|
+
case 6:
|
|
359
|
+
dispatch({ type: 'INITIALISED', user: user });
|
|
360
|
+
deferred.resolve();
|
|
361
|
+
return [3 /*break*/, 8];
|
|
362
|
+
case 7:
|
|
363
|
+
error_1 = _c.sent();
|
|
364
|
+
err = loginError(error_1);
|
|
365
|
+
handleError(err);
|
|
366
|
+
setInitFailed(true);
|
|
367
|
+
deferred.reject(err);
|
|
368
|
+
return [3 /*break*/, 8];
|
|
369
|
+
case 8: return [2 /*return*/];
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}); }, [client, onRedirectCallback, skipRedirectCallback, handleError]);
|
|
300
373
|
React.useEffect(function () {
|
|
301
374
|
if (didInitialise.current) {
|
|
302
375
|
return;
|
|
303
376
|
}
|
|
304
377
|
didInitialise.current = true;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
case 4:
|
|
327
|
-
_c.sent();
|
|
328
|
-
return [4 /*yield*/, client.getUser()];
|
|
329
|
-
case 5:
|
|
330
|
-
user = _c.sent();
|
|
331
|
-
_c.label = 6;
|
|
332
|
-
case 6:
|
|
333
|
-
dispatch({ type: 'INITIALISED', user: user });
|
|
334
|
-
return [3 /*break*/, 8];
|
|
335
|
-
case 7:
|
|
336
|
-
error_1 = _c.sent();
|
|
337
|
-
handleError(loginError(error_1));
|
|
338
|
-
return [3 /*break*/, 8];
|
|
339
|
-
case 8: return [2 /*return*/];
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
}); })();
|
|
343
|
-
}, [client, onRedirectCallback, skipRedirectCallback, handleError]);
|
|
378
|
+
// Always the first deferred: `didInitialise` means this only ever runs once,
|
|
379
|
+
// so a later swap by the retry effect re-runs this effect but returns above.
|
|
380
|
+
void runInit(initDeferred, true);
|
|
381
|
+
}, [runInit, initDeferred]);
|
|
382
|
+
// A rejected promise stays rejected forever, so React.use() would re-throw on
|
|
383
|
+
// every later render and an Error Boundary retry could never recover. Once
|
|
384
|
+
// init has failed but the app has since become authenticated by some other
|
|
385
|
+
// means (loginWithPopup, a silent token, a passkey login), re-run the session
|
|
386
|
+
// check against a fresh deferred. The promise then reflects a real
|
|
387
|
+
// checkSession() outcome rather than an assumption that things are fine --
|
|
388
|
+
// if the session is still bad it rejects again and the boundary keeps showing
|
|
389
|
+
// the error.
|
|
390
|
+
React.useEffect(function () {
|
|
391
|
+
if (!initFailed || initRetried.current || !state.isAuthenticated) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
initRetried.current = true;
|
|
395
|
+
var retry = createInitDeferred();
|
|
396
|
+
setInitDeferred(retry);
|
|
397
|
+
void runInit(retry, false);
|
|
398
|
+
}, [initFailed, state.isAuthenticated, runInit]);
|
|
344
399
|
var loginWithRedirect = React.useCallback(function (opts) {
|
|
345
400
|
deprecateRedirectUri(opts);
|
|
346
401
|
return client.loginWithRedirect(opts);
|
|
@@ -624,7 +679,7 @@ var Auth0Provider = function (opts) {
|
|
|
624
679
|
}); }, [client]);
|
|
625
680
|
var passkey = React.useMemo(function () { return ({ signup: passkeySignup, login: passkeyLogin }); }, [passkeySignup, passkeyLogin]);
|
|
626
681
|
var contextValue = React.useMemo(function () {
|
|
627
|
-
return __assign(__assign({}, state), { getAccessTokenSilently: getAccessTokenSilently, getAccessTokenWithPopup: getAccessTokenWithPopup, getIdTokenClaims: getIdTokenClaims, loginWithCustomTokenExchange: loginWithCustomTokenExchange, customTokenExchange: customTokenExchange, exchangeToken: exchangeToken, loginWithRedirect: loginWithRedirect, loginWithPopup: loginWithPopup, connectAccountWithRedirect: connectAccountWithRedirect, logout: logout, revokeRefreshToken: revokeRefreshToken, handleRedirectCallback: handleRedirectCallback, getDpopNonce: getDpopNonce, setDpopNonce: setDpopNonce, generateDpopProof: generateDpopProof, createFetcher: createFetcher, getConfiguration: getConfiguration, mfa: mfa, passkey: passkey, myAccount: myAccount });
|
|
682
|
+
return __assign(__assign({}, state), { getAccessTokenSilently: getAccessTokenSilently, getAccessTokenWithPopup: getAccessTokenWithPopup, getIdTokenClaims: getIdTokenClaims, loginWithCustomTokenExchange: loginWithCustomTokenExchange, customTokenExchange: customTokenExchange, exchangeToken: exchangeToken, loginWithRedirect: loginWithRedirect, loginWithPopup: loginWithPopup, connectAccountWithRedirect: connectAccountWithRedirect, logout: logout, revokeRefreshToken: revokeRefreshToken, handleRedirectCallback: handleRedirectCallback, getDpopNonce: getDpopNonce, setDpopNonce: setDpopNonce, generateDpopProof: generateDpopProof, createFetcher: createFetcher, getConfiguration: getConfiguration, mfa: mfa, passkey: passkey, myAccount: myAccount, _initPromise: initDeferred.promise });
|
|
628
683
|
}, [
|
|
629
684
|
state,
|
|
630
685
|
getAccessTokenSilently,
|
|
@@ -647,6 +702,7 @@ var Auth0Provider = function (opts) {
|
|
|
647
702
|
mfa,
|
|
648
703
|
passkey,
|
|
649
704
|
myAccount,
|
|
705
|
+
initDeferred,
|
|
650
706
|
]);
|
|
651
707
|
return React.createElement(context.Provider, { value: contextValue }, children);
|
|
652
708
|
};
|
|
@@ -680,6 +736,50 @@ var useAuth0 = function (context) {
|
|
|
680
736
|
return React.useContext(context);
|
|
681
737
|
};
|
|
682
738
|
|
|
739
|
+
/**
|
|
740
|
+
* ```jsx
|
|
741
|
+
* <Suspense fallback={<Spinner />}>
|
|
742
|
+
* <Profile />
|
|
743
|
+
* </Suspense>
|
|
744
|
+
*
|
|
745
|
+
* function Profile() {
|
|
746
|
+
* const { user, isAuthenticated } = useAuth0Suspense();
|
|
747
|
+
* return isAuthenticated ? <p>Hello {user.name}</p> : <p>Please log in</p>;
|
|
748
|
+
* }
|
|
749
|
+
* ```
|
|
750
|
+
*
|
|
751
|
+
* Suspense-enabled variant of `useAuth0`. Suspends the component until Auth0
|
|
752
|
+
* initialization completes (letting the nearest `<Suspense>` fallback render),
|
|
753
|
+
* and throws initialization errors so the nearest Error Boundary can handle
|
|
754
|
+
* them. Requires React 19 or later.
|
|
755
|
+
*
|
|
756
|
+
* If initialization fails and the app later becomes authenticated by other
|
|
757
|
+
* means, the session is re-checked once; retrying the Error Boundary then
|
|
758
|
+
* renders if that check succeeded, or throws again if it did not.
|
|
759
|
+
*
|
|
760
|
+
* TUser is an optional type param to provide a type to the `user` field.
|
|
761
|
+
*/
|
|
762
|
+
var useAuth0Suspense = function (context) {
|
|
763
|
+
if (context === void 0) { context = Auth0Context; }
|
|
764
|
+
if (typeof React.use !== 'function') {
|
|
765
|
+
throw new Error('useAuth0Suspense requires React 19 or later (React.use is unavailable).');
|
|
766
|
+
}
|
|
767
|
+
var ctx = React.useContext(context);
|
|
768
|
+
if (!ctx._initPromise) {
|
|
769
|
+
throw new Error('useAuth0Suspense must be used within an <Auth0Provider>.');
|
|
770
|
+
}
|
|
771
|
+
// Suspends until the init promise resolves; re-throws if it rejected.
|
|
772
|
+
React.use(ctx._initPromise);
|
|
773
|
+
// Memoized so the returned object is referentially stable across renders,
|
|
774
|
+
// matching useAuth0, which hands back the provider's memoized context.
|
|
775
|
+
// Without this, `useEffect(..., [auth])` in a consumer re-runs every render.
|
|
776
|
+
return React.useMemo(function () {
|
|
777
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
778
|
+
ctx.isLoading; ctx._initPromise; var rest = __rest(ctx, ["isLoading", "_initPromise"]);
|
|
779
|
+
return rest;
|
|
780
|
+
}, [ctx]);
|
|
781
|
+
};
|
|
782
|
+
|
|
683
783
|
/**
|
|
684
784
|
* ```jsx
|
|
685
785
|
* class MyComponent extends Component {
|
|
@@ -887,6 +987,7 @@ exports.Auth0Provider = Auth0Provider;
|
|
|
887
987
|
exports.OAuthError = OAuthError;
|
|
888
988
|
exports.initialContext = initialContext;
|
|
889
989
|
exports.useAuth0 = useAuth0;
|
|
990
|
+
exports.useAuth0Suspense = useAuth0Suspense;
|
|
890
991
|
exports.withAuth0 = withAuth0;
|
|
891
992
|
exports.withAuthenticationRequired = withAuthenticationRequired;
|
|
892
993
|
//# sourceMappingURL=auth0-react.cjs.js.map
|