@passflow/react 0.16.0 → 0.17.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/CHANGELOG.md +15 -0
- package/README.md +42 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +90 -90
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/provider/passflow-provider.d.ts.map +1 -1
- package/dist/src/components/provider/use-dispose-on-replace.d.cts +17 -0
- package/dist/src/components/provider/use-dispose-on-replace.d.ts +17 -0
- package/dist/src/components/provider/use-dispose-on-replace.d.ts.map +1 -0
- package/dist/src/context/auth-context.d.cts +5 -4
- package/dist/src/context/auth-context.d.ts +5 -4
- package/dist/src/context/auth-context.d.ts.map +1 -1
- package/dist/src/hooks/index.d.cts +2 -1
- package/dist/src/hooks/index.d.ts +2 -1
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/use-refresh-status.d.cts +36 -0
- package/dist/src/hooks/use-refresh-status.d.ts +36 -0
- package/dist/src/hooks/use-refresh-status.d.ts.map +1 -0
- package/dist/src/hooks/use-session-expired.d.cts +8 -4
- package/dist/src/hooks/use-session-expired.d.ts +8 -4
- package/dist/src/hooks/use-session-expired.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passflow-provider.d.ts","sourceRoot":"","sources":["../../../../src/components/provider/passflow-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,cAAc,EAA2B,MAAM,gBAAgB,CAAC;AAC7G,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,SAAS,EAAiE,MAAM,OAAO,CAAC;AACtH,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"passflow-provider.d.ts","sourceRoot":"","sources":["../../../../src/components/provider/passflow-provider.tsx"],"names":[],"mappings":"AAAA,O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AAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IAKvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;;;;;;GAMG;AACH,KAAK,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAmLtF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAwCF,eAAO,MAAM,mBAAmB,yCAE9B,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CA0JtD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Passflow } from '@passflow/core';
|
|
2
|
+
type Disposable = Pick<Passflow, 'dispose'>;
|
|
3
|
+
/**
|
|
4
|
+
* Disposes a Passflow instance once it is replaced (a new `useMemo` value) or the
|
|
5
|
+
* provider unmounts. Each instance owns refresh timers, a BroadcastChannel and Web
|
|
6
|
+
* Locks; one left undisposed keeps acting as an extra tab.
|
|
7
|
+
*
|
|
8
|
+
* Why the dispose is deferred: React StrictMode runs effect cleanup and setup again
|
|
9
|
+
* for the same instance in one commit, while `useMemo` keeps that instance live. An
|
|
10
|
+
* immediate dispose in cleanup would kill the instance the app keeps using, and core
|
|
11
|
+
* forbids using an instance after `dispose()`. So cleanup only schedules the dispose
|
|
12
|
+
* (`setTimeout(0)`); a setup that sees the same instance cancels it. A different
|
|
13
|
+
* instance or a real unmount leaves the timer to fire.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useDisposeOnReplace(instance: Disposable): void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=use-dispose-on-replace.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Passflow } from '@passflow/core';
|
|
2
|
+
type Disposable = Pick<Passflow, 'dispose'>;
|
|
3
|
+
/**
|
|
4
|
+
* Disposes a Passflow instance once it is replaced (a new `useMemo` value) or the
|
|
5
|
+
* provider unmounts. Each instance owns refresh timers, a BroadcastChannel and Web
|
|
6
|
+
* Locks; one left undisposed keeps acting as an extra tab.
|
|
7
|
+
*
|
|
8
|
+
* Why the dispose is deferred: React StrictMode runs effect cleanup and setup again
|
|
9
|
+
* for the same instance in one commit, while `useMemo` keeps that instance live. An
|
|
10
|
+
* immediate dispose in cleanup would kill the instance the app keeps using, and core
|
|
11
|
+
* forbids using an instance after `dispose()`. So cleanup only schedules the dispose
|
|
12
|
+
* (`setTimeout(0)`); a setup that sees the same instance cancels it. A different
|
|
13
|
+
* instance or a real unmount leaves the timer to fire.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useDisposeOnReplace(instance: Disposable): void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=use-dispose-on-replace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dispose-on-replace.d.ts","sourceRoot":"","sources":["../../../../src/components/provider/use-dispose-on-replace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,KAAK,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAO5C;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,CAe9D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ParsedTokens, type Tokens } from '@passflow/core';
|
|
1
|
+
import { type ParsedTokens, type SessionExpiredReason, type Tokens } from '@passflow/core';
|
|
2
2
|
import { type FC, type PropsWithChildren } from 'react';
|
|
3
|
-
export type SessionExpiredHandler = (reason:
|
|
3
|
+
export type SessionExpiredHandler = (reason: SessionExpiredReason) => void;
|
|
4
4
|
export type AuthContextValue = {
|
|
5
5
|
isAuthenticated: () => boolean;
|
|
6
6
|
logout: () => void;
|
|
@@ -14,8 +14,9 @@ export type AuthContextValue = {
|
|
|
14
14
|
export declare const AuthContext: import("react").Context<AuthContextValue | undefined>;
|
|
15
15
|
export type AuthProviderProps = PropsWithChildren<{
|
|
16
16
|
/**
|
|
17
|
-
* Called when the session
|
|
18
|
-
*
|
|
17
|
+
* Called when the session has really ended: last auth strike, no successor token pair
|
|
18
|
+
* in time, or another user's tokens in storage. A transient refresh failure keeps the
|
|
19
|
+
* session and does not call this. Use this to redirect to your login page.
|
|
19
20
|
*/
|
|
20
21
|
onSessionExpired?: SessionExpiredHandler;
|
|
21
22
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ParsedTokens, type Tokens } from '@passflow/core';
|
|
1
|
+
import { type ParsedTokens, type SessionExpiredReason, type Tokens } from '@passflow/core';
|
|
2
2
|
import { type FC, type PropsWithChildren } from 'react';
|
|
3
|
-
export type SessionExpiredHandler = (reason:
|
|
3
|
+
export type SessionExpiredHandler = (reason: SessionExpiredReason) => void;
|
|
4
4
|
export type AuthContextValue = {
|
|
5
5
|
isAuthenticated: () => boolean;
|
|
6
6
|
logout: () => void;
|
|
@@ -14,8 +14,9 @@ export type AuthContextValue = {
|
|
|
14
14
|
export declare const AuthContext: import("react").Context<AuthContextValue | undefined>;
|
|
15
15
|
export type AuthProviderProps = PropsWithChildren<{
|
|
16
16
|
/**
|
|
17
|
-
* Called when the session
|
|
18
|
-
*
|
|
17
|
+
* Called when the session has really ended: last auth strike, no successor token pair
|
|
18
|
+
* in time, or another user's tokens in storage. A transient refresh failure keeps the
|
|
19
|
+
* session and does not call this. Use this to redirect to your login page.
|
|
19
20
|
*/
|
|
20
21
|
onSessionExpired?: SessionExpiredHandler;
|
|
21
22
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-context.d.ts","sourceRoot":"","sources":["../../../src/context/auth-context.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"auth-context.d.ts","sourceRoot":"","sources":["../../../src/context/auth-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAGjB,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAiB,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AAGzG,MAAM,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;AAE3E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,EAAE,MAAM,OAAO,CAAC;IAC/B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,YAAY,GAAG,SAAS,CAAA;KAAE,CAAC,CAAC;CACpH,CAAC;AAEF,eAAO,MAAM,WAAW,uDAAyD,CAAC;AAElF,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;IAChD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,qBAAqB,CAAC;CAC1C,CAAC,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAkE9C,CAAC"}
|
|
@@ -11,8 +11,9 @@ export { useOutsideClick } from './use-outsideclick.cjs';
|
|
|
11
11
|
export { usePassflow } from './use-passflow.cjs';
|
|
12
12
|
export { type UsePasswordlessCompleteProps, usePasswordlessComplete } from './use-passwordless-complete.cjs';
|
|
13
13
|
export { type UseProviderProps, useProvider } from './use-provider.cjs';
|
|
14
|
+
export { type UseRefreshStatusResult, useRefreshStatus } from './use-refresh-status.cjs';
|
|
14
15
|
export { type UseResetPasswordProps, useResetPassword } from './use-reset-password.cjs';
|
|
15
|
-
export { type
|
|
16
|
+
export { type UseSessionExpiredOptions, type UseSessionExpiredResult, useSessionExpired, } from './use-session-expired.cjs';
|
|
16
17
|
export { type UseSignInProps, useSignIn } from './use-signin.cjs';
|
|
17
18
|
export { type UseSignUpProps, useSignUp } from './use-signup.cjs';
|
|
18
19
|
export { type UseTrustedDevicesProps, useTrustedDevices } from './use-trusted-devices.cjs';
|
|
@@ -11,8 +11,9 @@ export { useOutsideClick } from './use-outsideclick.js';
|
|
|
11
11
|
export { usePassflow } from './use-passflow.js';
|
|
12
12
|
export { type UsePasswordlessCompleteProps, usePasswordlessComplete } from './use-passwordless-complete.js';
|
|
13
13
|
export { type UseProviderProps, useProvider } from './use-provider.js';
|
|
14
|
+
export { type UseRefreshStatusResult, useRefreshStatus } from './use-refresh-status.js';
|
|
14
15
|
export { type UseResetPasswordProps, useResetPassword } from './use-reset-password.js';
|
|
15
|
-
export { type
|
|
16
|
+
export { type UseSessionExpiredOptions, type UseSessionExpiredResult, useSessionExpired, } from './use-session-expired.js';
|
|
16
17
|
export { type UseSignInProps, useSignIn } from './use-signin.js';
|
|
17
18
|
export { type UseSignUpProps, useSignUp } from './use-signup.js';
|
|
18
19
|
export { type UseTrustedDevicesProps, useTrustedDevices } from './use-trusted-devices.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,oBAAoB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BAAiB,EAAE,MAAM,wBAAwB,CAAC;AACjH,OAAO,EAAE,KAAK,gCAAgC,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAEtH,OAAO,EAAE,KAAK,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,KAAK,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE3F,OAAO,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,KAAK,oBAAoB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface UseRefreshStatusResult {
|
|
2
|
+
/**
|
|
3
|
+
* True inside a transient-failure episode: a token refresh failed for a reason that
|
|
4
|
+
* does not end the session (network, 5xx) and core is retrying. The session is kept.
|
|
5
|
+
*/
|
|
6
|
+
isFailing: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Epoch ms of the episode's first transient failure (`RefreshFailing.since`).
|
|
9
|
+
*/
|
|
10
|
+
since: number | null;
|
|
11
|
+
/**
|
|
12
|
+
* Epoch ms of the pending retry, when core knows it (`RefreshFailing.nextRetryAt`).
|
|
13
|
+
*/
|
|
14
|
+
nextRetryAt: number | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Hook to show a "connection trouble" notice while token refresh is failing transiently.
|
|
18
|
+
*
|
|
19
|
+
* Set by `RefreshFailing`; cleared by `RefreshRecovered`, and by `SessionExpired`,
|
|
20
|
+
* `SignOut`, `SignIn` and `Register`, which end or replace the session the episode
|
|
21
|
+
* belonged to. A real end of the session is reported by `useSessionExpired`, not here.
|
|
22
|
+
*
|
|
23
|
+
* Core reports the episode only as events (there is no getter to read on mount), so a
|
|
24
|
+
* component that mounts after `RefreshFailing` starts idle. Call the hook in a component
|
|
25
|
+
* that lives for the whole app, near `PassflowProvider`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* function ConnectionNotice() {
|
|
30
|
+
* const { isFailing } = useRefreshStatus();
|
|
31
|
+
* return isFailing ? <Banner>Reconnecting...</Banner> : null;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function useRefreshStatus(): UseRefreshStatusResult;
|
|
36
|
+
//# sourceMappingURL=use-refresh-status.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface UseRefreshStatusResult {
|
|
2
|
+
/**
|
|
3
|
+
* True inside a transient-failure episode: a token refresh failed for a reason that
|
|
4
|
+
* does not end the session (network, 5xx) and core is retrying. The session is kept.
|
|
5
|
+
*/
|
|
6
|
+
isFailing: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Epoch ms of the episode's first transient failure (`RefreshFailing.since`).
|
|
9
|
+
*/
|
|
10
|
+
since: number | null;
|
|
11
|
+
/**
|
|
12
|
+
* Epoch ms of the pending retry, when core knows it (`RefreshFailing.nextRetryAt`).
|
|
13
|
+
*/
|
|
14
|
+
nextRetryAt: number | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Hook to show a "connection trouble" notice while token refresh is failing transiently.
|
|
18
|
+
*
|
|
19
|
+
* Set by `RefreshFailing`; cleared by `RefreshRecovered`, and by `SessionExpired`,
|
|
20
|
+
* `SignOut`, `SignIn` and `Register`, which end or replace the session the episode
|
|
21
|
+
* belonged to. A real end of the session is reported by `useSessionExpired`, not here.
|
|
22
|
+
*
|
|
23
|
+
* Core reports the episode only as events (there is no getter to read on mount), so a
|
|
24
|
+
* component that mounts after `RefreshFailing` starts idle. Call the hook in a component
|
|
25
|
+
* that lives for the whole app, near `PassflowProvider`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* function ConnectionNotice() {
|
|
30
|
+
* const { isFailing } = useRefreshStatus();
|
|
31
|
+
* return isFailing ? <Banner>Reconnecting...</Banner> : null;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function useRefreshStatus(): UseRefreshStatusResult;
|
|
36
|
+
//# sourceMappingURL=use-refresh-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-refresh-status.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-refresh-status.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAaD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CA4BzD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { type SessionExpiredReason } from '@passflow/core';
|
|
2
2
|
export interface UseSessionExpiredOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Called when the session expires.
|
|
@@ -23,9 +23,13 @@ export interface UseSessionExpiredResult {
|
|
|
23
23
|
/**
|
|
24
24
|
* Hook to handle session expiration events.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Core emits SessionExpired only when the session has really ended: the last
|
|
27
|
+
* auth strike (`'refresh_failed'`), no successor token pair in time
|
|
28
|
+
* (`'successor_timeout'`), or another user's tokens in storage
|
|
29
|
+
* (`'identity_changed'`). A transient refresh failure (network, 5xx) keeps the
|
|
30
|
+
* session and is reported as RefreshFailing / RefreshRecovered instead; see
|
|
31
|
+
* `useRefreshStatus`. This hook lets you react to the real end and redirect
|
|
32
|
+
* users to your login page.
|
|
29
33
|
*
|
|
30
34
|
* @example
|
|
31
35
|
* ```tsx
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { type SessionExpiredReason } from '@passflow/core';
|
|
2
2
|
export interface UseSessionExpiredOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Called when the session expires.
|
|
@@ -23,9 +23,13 @@ export interface UseSessionExpiredResult {
|
|
|
23
23
|
/**
|
|
24
24
|
* Hook to handle session expiration events.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Core emits SessionExpired only when the session has really ended: the last
|
|
27
|
+
* auth strike (`'refresh_failed'`), no successor token pair in time
|
|
28
|
+
* (`'successor_timeout'`), or another user's tokens in storage
|
|
29
|
+
* (`'identity_changed'`). A transient refresh failure (network, 5xx) keeps the
|
|
30
|
+
* session and is reported as RefreshFailing / RefreshRecovered instead; see
|
|
31
|
+
* `useRefreshStatus`. This hook lets you react to the real end and redirect
|
|
32
|
+
* users to your login page.
|
|
29
33
|
*
|
|
30
34
|
* @example
|
|
31
35
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-session-expired.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-session-expired.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-session-expired.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-session-expired.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAInG,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,aAAa,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,uBAAuB,CAsC7F"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@passflow/react",
|
|
3
3
|
"description": "Passflow React UI Kit",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.17.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@passflow/core": "^0.
|
|
52
|
+
"@passflow/core": "^0.21.0",
|
|
53
53
|
"@radix-ui/react-dialog": "^1.3.1",
|
|
54
54
|
"@radix-ui/react-popover": "^1.3.1",
|
|
55
55
|
"@simplewebauthn/browser": "^14.0.0",
|