@logto/react 3.0.2 → 3.0.4

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.
@@ -87,6 +87,7 @@ const useLogto = () => {
87
87
  getOrganizationTokenClaims: proxy(client.getOrganizationTokenClaims.bind(client)),
88
88
  getIdToken: proxy(client.getIdToken.bind(client)),
89
89
  getIdTokenClaims: proxy(client.getIdTokenClaims.bind(client)),
90
+ // eslint-disable-next-line no-restricted-syntax -- TypeScript cannot infer the correct type.
90
91
  signIn: proxy(client.signIn.bind(client), false),
91
92
  // We deliberately do NOT set isAuthenticated to false in the function below, because the app state
92
93
  // may change immediately even before navigating to the oidc end session endpoint, which might cause
@@ -7,7 +7,7 @@ type Logto = {
7
7
  isAuthenticated: boolean;
8
8
  isLoading: boolean;
9
9
  error?: Error;
10
- } & OptionalPromiseReturn<Pick<LogtoClient, 'getRefreshToken' | 'getAccessToken' | 'getAccessTokenClaims' | 'getOrganizationToken' | 'getOrganizationTokenClaims' | 'getIdToken' | 'getIdTokenClaims' | 'signIn' | 'signOut' | 'fetchUserInfo'>>;
10
+ } & OptionalPromiseReturn<Pick<LogtoClient, 'getRefreshToken' | 'getAccessToken' | 'getAccessTokenClaims' | 'getOrganizationToken' | 'getOrganizationTokenClaims' | 'getIdToken' | 'getIdTokenClaims' | 'signOut' | 'fetchUserInfo'>> & Pick<LogtoClient, 'signIn'>;
11
11
  declare const useHandleSignInCallback: (callback?: () => void) => {
12
12
  isLoading: boolean;
13
13
  isAuthenticated: boolean;
@@ -85,6 +85,7 @@ const useLogto = () => {
85
85
  getOrganizationTokenClaims: proxy(client.getOrganizationTokenClaims.bind(client)),
86
86
  getIdToken: proxy(client.getIdToken.bind(client)),
87
87
  getIdTokenClaims: proxy(client.getIdTokenClaims.bind(client)),
88
+ // eslint-disable-next-line no-restricted-syntax -- TypeScript cannot infer the correct type.
88
89
  signIn: proxy(client.signIn.bind(client), false),
89
90
  // We deliberately do NOT set isAuthenticated to false in the function below, because the app state
90
91
  // may change immediately even before navigating to the oidc end session endpoint, which might cause
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { LogtoContextProps, LogtoContext } from './context.js';
2
- export type { LogtoConfig, IdTokenClaims, UserInfoResponse, LogtoErrorCode, LogtoClientErrorCode, InteractionMode, } from '@logto/browser';
2
+ export type { LogtoConfig, IdTokenClaims, UserInfoResponse, LogtoErrorCode, LogtoClientErrorCode, InteractionMode, AccessTokenClaims, } from '@logto/browser';
3
3
  export { LogtoError, LogtoRequestError, LogtoClientError, OidcError, Prompt, ReservedScope, ReservedResource, UserScope, organizationUrnPrefix, buildOrganizationUrn, getOrganizationIdFromUrn, PersistKey, } from '@logto/browser';
4
4
  export * from './provider.js';
5
5
  export { useLogto, useHandleSignInCallback } from './hooks/index.js';
package/lib/provider.cjs CHANGED
@@ -9,9 +9,9 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
 
10
10
  var LogtoClient__default = /*#__PURE__*/_interopDefault(LogtoClient);
11
11
 
12
- const LogtoProvider = ({ config, children, unstable_enableCache = false, }) => {
12
+ const LogtoProvider = ({ config, LogtoClientClass = LogtoClient__default.default, children, unstable_enableCache = false, }) => {
13
13
  const [loadingCount, setLoadingCount] = react.useState(1);
14
- const memorizedLogtoClient = react.useMemo(() => ({ logtoClient: new LogtoClient__default.default(config, unstable_enableCache) }), [config, unstable_enableCache]);
14
+ const memorizedLogtoClient = react.useMemo(() => ({ logtoClient: new LogtoClientClass(config, unstable_enableCache) }), [LogtoClientClass, config, unstable_enableCache]);
15
15
  const [isAuthenticated, setIsAuthenticated] = react.useState(false);
16
16
  const [error, setError] = react.useState();
17
17
  const isLoading = react.useMemo(() => loadingCount > 0, [loadingCount]);
package/lib/provider.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type LogtoConfig } from '@logto/browser';
1
+ import LogtoClient, { type LogtoConfig } from '@logto/browser';
2
2
  import { type ReactNode } from 'react';
3
3
  export type LogtoProviderProps = {
4
4
  config: LogtoConfig;
@@ -7,6 +7,7 @@ export type LogtoProviderProps = {
7
7
  * @default false
8
8
  */
9
9
  unstable_enableCache?: boolean;
10
+ LogtoClientClass?: typeof LogtoClient;
10
11
  children?: ReactNode;
11
12
  };
12
- export declare const LogtoProvider: ({ config, children, unstable_enableCache, }: LogtoProviderProps) => import("react/jsx-runtime.js").JSX.Element;
13
+ export declare const LogtoProvider: ({ config, LogtoClientClass, children, unstable_enableCache, }: LogtoProviderProps) => import("react/jsx-runtime.js").JSX.Element;
package/lib/provider.js CHANGED
@@ -3,9 +3,9 @@ import LogtoClient from '@logto/browser';
3
3
  import { useState, useMemo, useCallback, useEffect } from 'react';
4
4
  import { LogtoContext } from './context.js';
5
5
 
6
- const LogtoProvider = ({ config, children, unstable_enableCache = false, }) => {
6
+ const LogtoProvider = ({ config, LogtoClientClass = LogtoClient, children, unstable_enableCache = false, }) => {
7
7
  const [loadingCount, setLoadingCount] = useState(1);
8
- const memorizedLogtoClient = useMemo(() => ({ logtoClient: new LogtoClient(config, unstable_enableCache) }), [config, unstable_enableCache]);
8
+ const memorizedLogtoClient = useMemo(() => ({ logtoClient: new LogtoClientClass(config, unstable_enableCache) }), [LogtoClientClass, config, unstable_enableCache]);
9
9
  const [isAuthenticated, setIsAuthenticated] = useState(false);
10
10
  const [error, setError] = useState();
11
11
  const isLoading = useMemo(() => loadingCount > 0, [loadingCount]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/react",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "type": "module",
5
5
  "main": "./lib/index.cjs",
6
6
  "module": "./lib/index.js",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@silverhand/essentials": "^2.8.7",
25
- "@logto/browser": "^2.2.4"
25
+ "@logto/browser": "^2.2.6"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@silverhand/eslint-config": "^5.0.0",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/react": "^14.2.1",
35
35
  "@types/jest": "^29.5.0",
36
36
  "@types/react": "^18.2.56",
37
- "eslint": "^8.44.0",
37
+ "eslint": "^8.57.0",
38
38
  "jest": "^29.5.0",
39
39
  "lint-staged": "^15.0.0",
40
40
  "postcss": "^8.4.31",