@versini/auth0-react-thin 2.23.0 → 2.24.0
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 +161 -41
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +148 -47
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +161 -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 +71 -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.0`](https://www.npmjs.com/package/@auth0/auth0-react/v/2.24.0)
|
|
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
|
@@ -4,6 +4,25 @@
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var auth0SpaJs = require('@auth0/auth0-spa-js');
|
|
6
6
|
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
25
|
+
|
|
7
26
|
/******************************************************************************
|
|
8
27
|
Copyright (c) Microsoft Corporation.
|
|
9
28
|
|
|
@@ -256,7 +275,7 @@ var toAuth0ClientOptions = function (opts) {
|
|
|
256
275
|
deprecateRedirectUri(opts);
|
|
257
276
|
return __assign(__assign({}, opts), { auth0Client: {
|
|
258
277
|
name: 'auth0-react',
|
|
259
|
-
version: '2.
|
|
278
|
+
version: '2.24.0',
|
|
260
279
|
} });
|
|
261
280
|
};
|
|
262
281
|
/**
|
|
@@ -266,6 +285,22 @@ var defaultOnRedirectCallback = function (appState) {
|
|
|
266
285
|
var _a;
|
|
267
286
|
window.history.replaceState({}, document.title, (_a = appState.returnTo) !== null && _a !== void 0 ? _a : window.location.pathname);
|
|
268
287
|
};
|
|
288
|
+
/**
|
|
289
|
+
* @ignore
|
|
290
|
+
*/
|
|
291
|
+
var createInitDeferred = function () {
|
|
292
|
+
var resolve;
|
|
293
|
+
var reject;
|
|
294
|
+
var promise = new Promise(function (res, rej) {
|
|
295
|
+
resolve = res;
|
|
296
|
+
reject = rej;
|
|
297
|
+
});
|
|
298
|
+
// Avoid unhandled-rejection warnings when no one is consuming the promise
|
|
299
|
+
// (i.e. useAuth0Suspense is not used). useAuth0Suspense attaches its own
|
|
300
|
+
// handler via use().
|
|
301
|
+
promise.catch(function () { return undefined; });
|
|
302
|
+
return { promise: promise, resolve: resolve, reject: reject };
|
|
303
|
+
};
|
|
269
304
|
/**
|
|
270
305
|
* ```jsx
|
|
271
306
|
* <Auth0Provider
|
|
@@ -292,55 +327,94 @@ var Auth0Provider = function (opts) {
|
|
|
292
327
|
}
|
|
293
328
|
var client = React.useState(function () { return providedClient !== null && providedClient !== void 0 ? providedClient : new auth0SpaJs.Auth0Client(toAuth0ClientOptions(clientOpts)); })[0];
|
|
294
329
|
var _d = React.useReducer((reducer), initialAuthState), state = _d[0], dispatch = _d[1];
|
|
330
|
+
// In state so the init retry below can swap in a fresh, non-rejected promise.
|
|
331
|
+
// Without that swap the first rejection would re-throw on every later render,
|
|
332
|
+
// making Error Boundary retries useless.
|
|
333
|
+
var _e = React.useState(createInitDeferred), initDeferred = _e[0], setInitDeferred = _e[1];
|
|
334
|
+
// Set only once initialization has genuinely rejected. State, not a ref, so
|
|
335
|
+
// the retry effect re-evaluates when init fails *after* the app has become
|
|
336
|
+
// authenticated by some other means.
|
|
337
|
+
var _f = React.useState(false), initFailed = _f[0], setInitFailed = _f[1];
|
|
338
|
+
// Guards against retrying more than once: a retry that also fails would
|
|
339
|
+
// otherwise re-trigger the effect for as long as the user stays signed in.
|
|
340
|
+
var initRetried = React.useRef(false);
|
|
295
341
|
var didInitialise = React.useRef(false);
|
|
296
342
|
var handleError = React.useCallback(function (error) {
|
|
297
343
|
dispatch({ type: 'ERROR', error: error });
|
|
298
344
|
return error;
|
|
299
345
|
}, []);
|
|
346
|
+
// Settles `deferred` according to what initialization actually did, so
|
|
347
|
+
// `_initPromise` never claims success that did not happen. `allowRedirect`
|
|
348
|
+
// is false on a retry: the redirect callback is single-use, so a retry can
|
|
349
|
+
// only re-verify the session.
|
|
350
|
+
var runInit = React.useCallback(function (deferred, allowRedirect) { return __awaiter(void 0, void 0, void 0, function () {
|
|
351
|
+
var user, _a, _b, appState, response_type, result, error_1, err;
|
|
352
|
+
return __generator(this, function (_c) {
|
|
353
|
+
switch (_c.label) {
|
|
354
|
+
case 0:
|
|
355
|
+
_c.trys.push([0, 7, , 8]);
|
|
356
|
+
user = void 0;
|
|
357
|
+
if (!(allowRedirect && hasAuthParams() && !skipRedirectCallback)) return [3 /*break*/, 3];
|
|
358
|
+
return [4 /*yield*/, client.handleRedirectCallback()];
|
|
359
|
+
case 1:
|
|
360
|
+
_a = _c.sent(), _b = _a.appState, appState = _b === void 0 ? {} : _b, response_type = _a.response_type, result = __rest(_a, ["appState", "response_type"]);
|
|
361
|
+
return [4 /*yield*/, client.getUser()];
|
|
362
|
+
case 2:
|
|
363
|
+
user = _c.sent();
|
|
364
|
+
appState.response_type = response_type;
|
|
365
|
+
if (response_type === auth0SpaJs.ResponseType.ConnectCode) {
|
|
366
|
+
appState.connectedAccount = result;
|
|
367
|
+
}
|
|
368
|
+
onRedirectCallback(appState, user);
|
|
369
|
+
return [3 /*break*/, 6];
|
|
370
|
+
case 3: return [4 /*yield*/, client.checkSession()];
|
|
371
|
+
case 4:
|
|
372
|
+
_c.sent();
|
|
373
|
+
return [4 /*yield*/, client.getUser()];
|
|
374
|
+
case 5:
|
|
375
|
+
user = _c.sent();
|
|
376
|
+
_c.label = 6;
|
|
377
|
+
case 6:
|
|
378
|
+
dispatch({ type: 'INITIALISED', user: user });
|
|
379
|
+
deferred.resolve();
|
|
380
|
+
return [3 /*break*/, 8];
|
|
381
|
+
case 7:
|
|
382
|
+
error_1 = _c.sent();
|
|
383
|
+
err = loginError(error_1);
|
|
384
|
+
handleError(err);
|
|
385
|
+
setInitFailed(true);
|
|
386
|
+
deferred.reject(err);
|
|
387
|
+
return [3 /*break*/, 8];
|
|
388
|
+
case 8: return [2 /*return*/];
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}); }, [client, onRedirectCallback, skipRedirectCallback, handleError]);
|
|
300
392
|
React.useEffect(function () {
|
|
301
393
|
if (didInitialise.current) {
|
|
302
394
|
return;
|
|
303
395
|
}
|
|
304
396
|
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]);
|
|
397
|
+
// Always the first deferred: `didInitialise` means this only ever runs once,
|
|
398
|
+
// so a later swap by the retry effect re-runs this effect but returns above.
|
|
399
|
+
void runInit(initDeferred, true);
|
|
400
|
+
}, [runInit, initDeferred]);
|
|
401
|
+
// A rejected promise stays rejected forever, so React.use() would re-throw on
|
|
402
|
+
// every later render and an Error Boundary retry could never recover. Once
|
|
403
|
+
// init has failed but the app has since become authenticated by some other
|
|
404
|
+
// means (loginWithPopup, a silent token, a passkey login), re-run the session
|
|
405
|
+
// check against a fresh deferred. The promise then reflects a real
|
|
406
|
+
// checkSession() outcome rather than an assumption that things are fine --
|
|
407
|
+
// if the session is still bad it rejects again and the boundary keeps showing
|
|
408
|
+
// the error.
|
|
409
|
+
React.useEffect(function () {
|
|
410
|
+
if (!initFailed || initRetried.current || !state.isAuthenticated) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
initRetried.current = true;
|
|
414
|
+
var retry = createInitDeferred();
|
|
415
|
+
setInitDeferred(retry);
|
|
416
|
+
void runInit(retry, false);
|
|
417
|
+
}, [initFailed, state.isAuthenticated, runInit]);
|
|
344
418
|
var loginWithRedirect = React.useCallback(function (opts) {
|
|
345
419
|
deprecateRedirectUri(opts);
|
|
346
420
|
return client.loginWithRedirect(opts);
|
|
@@ -624,7 +698,7 @@ var Auth0Provider = function (opts) {
|
|
|
624
698
|
}); }, [client]);
|
|
625
699
|
var passkey = React.useMemo(function () { return ({ signup: passkeySignup, login: passkeyLogin }); }, [passkeySignup, passkeyLogin]);
|
|
626
700
|
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 });
|
|
701
|
+
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
702
|
}, [
|
|
629
703
|
state,
|
|
630
704
|
getAccessTokenSilently,
|
|
@@ -647,6 +721,7 @@ var Auth0Provider = function (opts) {
|
|
|
647
721
|
mfa,
|
|
648
722
|
passkey,
|
|
649
723
|
myAccount,
|
|
724
|
+
initDeferred,
|
|
650
725
|
]);
|
|
651
726
|
return React.createElement(context.Provider, { value: contextValue }, children);
|
|
652
727
|
};
|
|
@@ -680,6 +755,50 @@ var useAuth0 = function (context) {
|
|
|
680
755
|
return React.useContext(context);
|
|
681
756
|
};
|
|
682
757
|
|
|
758
|
+
/**
|
|
759
|
+
* ```jsx
|
|
760
|
+
* <Suspense fallback={<Spinner />}>
|
|
761
|
+
* <Profile />
|
|
762
|
+
* </Suspense>
|
|
763
|
+
*
|
|
764
|
+
* function Profile() {
|
|
765
|
+
* const { user, isAuthenticated } = useAuth0Suspense();
|
|
766
|
+
* return isAuthenticated ? <p>Hello {user.name}</p> : <p>Please log in</p>;
|
|
767
|
+
* }
|
|
768
|
+
* ```
|
|
769
|
+
*
|
|
770
|
+
* Suspense-enabled variant of `useAuth0`. Suspends the component until Auth0
|
|
771
|
+
* initialization completes (letting the nearest `<Suspense>` fallback render),
|
|
772
|
+
* and throws initialization errors so the nearest Error Boundary can handle
|
|
773
|
+
* them. Requires React 19 or later.
|
|
774
|
+
*
|
|
775
|
+
* If initialization fails and the app later becomes authenticated by other
|
|
776
|
+
* means, the session is re-checked once; retrying the Error Boundary then
|
|
777
|
+
* renders if that check succeeded, or throws again if it did not.
|
|
778
|
+
*
|
|
779
|
+
* TUser is an optional type param to provide a type to the `user` field.
|
|
780
|
+
*/
|
|
781
|
+
var useAuth0Suspense = function (context) {
|
|
782
|
+
if (context === void 0) { context = Auth0Context; }
|
|
783
|
+
if (typeof React__namespace.use !== 'function') {
|
|
784
|
+
throw new Error('useAuth0Suspense requires React 19 or later (React.use is unavailable).');
|
|
785
|
+
}
|
|
786
|
+
var ctx = React__namespace.useContext(context);
|
|
787
|
+
if (!ctx._initPromise) {
|
|
788
|
+
throw new Error('useAuth0Suspense must be used within an <Auth0Provider>.');
|
|
789
|
+
}
|
|
790
|
+
// Suspends until the init promise resolves; re-throws if it rejected.
|
|
791
|
+
React__namespace.use(ctx._initPromise);
|
|
792
|
+
// Memoized so the returned object is referentially stable across renders,
|
|
793
|
+
// matching useAuth0, which hands back the provider's memoized context.
|
|
794
|
+
// Without this, `useEffect(..., [auth])` in a consumer re-runs every render.
|
|
795
|
+
return React__namespace.useMemo(function () {
|
|
796
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
797
|
+
ctx.isLoading; ctx._initPromise; var rest = __rest(ctx, ["isLoading", "_initPromise"]);
|
|
798
|
+
return rest;
|
|
799
|
+
}, [ctx]);
|
|
800
|
+
};
|
|
801
|
+
|
|
683
802
|
/**
|
|
684
803
|
* ```jsx
|
|
685
804
|
* class MyComponent extends Component {
|
|
@@ -887,6 +1006,7 @@ exports.Auth0Provider = Auth0Provider;
|
|
|
887
1006
|
exports.OAuthError = OAuthError;
|
|
888
1007
|
exports.initialContext = initialContext;
|
|
889
1008
|
exports.useAuth0 = useAuth0;
|
|
1009
|
+
exports.useAuth0Suspense = useAuth0Suspense;
|
|
890
1010
|
exports.withAuth0 = withAuth0;
|
|
891
1011
|
exports.withAuthenticationRequired = withAuthenticationRequired;
|
|
892
1012
|
//# sourceMappingURL=auth0-react.cjs.js.map
|