@interop/was-react 0.1.4 → 0.1.6
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/auth/loginRequest.d.ts +4 -9
- package/dist/auth/loginRequest.d.ts.map +1 -1
- package/dist/auth/loginRequest.js +2 -13
- package/dist/auth/loginRequest.js.map +1 -1
- package/dist/auth/walletRequestTypes.d.ts +3 -2
- package/dist/auth/walletRequestTypes.d.ts.map +1 -1
- package/dist/config.d.ts +22 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -1
- package/dist/grants.d.ts +10 -8
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +12 -9
- package/dist/grants.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/mui/ClearDataDialog.d.ts +12 -0
- package/dist/mui/ClearDataDialog.d.ts.map +1 -0
- package/dist/mui/ClearDataDialog.js +30 -0
- package/dist/mui/ClearDataDialog.js.map +1 -0
- package/dist/mui/LogoutDialog.d.ts +12 -0
- package/dist/mui/LogoutDialog.d.ts.map +1 -0
- package/dist/mui/LogoutDialog.js +30 -0
- package/dist/mui/LogoutDialog.js.map +1 -0
- package/dist/mui/ProtectedRoute.d.ts +2 -2
- package/dist/mui/ProtectedRoute.d.ts.map +1 -1
- package/dist/mui/ProtectedRoute.js +30 -23
- package/dist/mui/ProtectedRoute.js.map +1 -1
- package/dist/mui/index.d.ts +2 -0
- package/dist/mui/index.d.ts.map +1 -1
- package/dist/mui/index.js +2 -0
- package/dist/mui/index.js.map +1 -1
- package/dist/react/WasSessionProvider.d.ts.map +1 -1
- package/dist/react/WasSessionProvider.js +8 -4
- package/dist/react/WasSessionProvider.js.map +1 -1
- package/dist/react/hooks.d.ts +19 -4
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/hooks.js +22 -6
- package/dist/react/hooks.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/session/authStore.d.ts +84 -21
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +231 -79
- package/dist/session/authStore.js.map +1 -1
- package/dist/session/index.d.ts +3 -4
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +2 -3
- package/dist/session/index.js.map +1 -1
- package/dist/storage/entityStore.d.ts +3 -2
- package/dist/storage/entityStore.d.ts.map +1 -1
- package/dist/storage/entityStore.js +28 -3
- package/dist/storage/entityStore.js.map +1 -1
- package/dist/storage/localStore.d.ts +7 -0
- package/dist/storage/localStore.d.ts.map +1 -1
- package/dist/storage/localStore.js +9 -0
- package/dist/storage/localStore.js.map +1 -1
- package/dist/sync/types.d.ts +5 -1
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/types.js.map +1 -1
- package/dist/sync/wasSyncPort.d.ts.map +1 -1
- package/dist/sync/wasSyncPort.js +19 -6
- package/dist/sync/wasSyncPort.js.map +1 -1
- package/package.json +1 -1
- package/dist/session/appReadyStore.d.ts +0 -10
- package/dist/session/appReadyStore.d.ts.map +0 -1
- package/dist/session/appReadyStore.js +0 -22
- package/dist/session/appReadyStore.js.map +0 -1
package/dist/mui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mui/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mui/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WasSessionProvider.d.ts","sourceRoot":"","sources":["../../src/react/WasSessionProvider.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE5E;;;GAGG;AACH,eAAO,MAAM,iBAAiB,8CAA2C,CAAA;AAEzE;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,QAAQ,EACR,QAAQ,EACT,EAAE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,QAAQ,EAAE,aAAa,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;CACpB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"WasSessionProvider.d.ts","sourceRoot":"","sources":["../../src/react/WasSessionProvider.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE5E;;;GAGG;AACH,eAAO,MAAM,iBAAiB,8CAA2C,CAAA;AAEzE;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,QAAQ,EACR,QAAQ,EACT,EAAE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,QAAQ,EAAE,aAAa,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;CACpB,GAAG,SAAS,CAsBZ"}
|
|
@@ -30,11 +30,15 @@ export const WasSessionContext = createContext(null);
|
|
|
30
30
|
*/
|
|
31
31
|
export function WasSessionProvider({ config, registry, children }) {
|
|
32
32
|
const [store] = useState(() => createAuthStore({ config, registry }));
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
33
|
+
// Kick off boot on mount (so a local-first app that never renders
|
|
34
|
+
// `ProtectedRoute` still boots), and tear the live session down on unmount so
|
|
35
|
+
// an abandoned provider never leaves the expiry-watch interval and the
|
|
36
|
+
// replication loop firing against a store no one is reading (reliably hit by
|
|
37
|
+
// React StrictMode dev remounts and by tests). `destroy()` returns the store
|
|
38
|
+
// to `boot` with both persisted seeds intact, so a StrictMode remount's
|
|
39
|
+
// `boot()` re-opens the same session (or fresh local).
|
|
37
40
|
useEffect(() => {
|
|
41
|
+
void store.getState().boot();
|
|
38
42
|
return () => {
|
|
39
43
|
void store.getState().destroy();
|
|
40
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WasSessionProvider.js","sourceRoot":"","sources":["../../src/react/WasSessionProvider.tsx"],"names":[],"mappings":";AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAA;AAE1E,OAAO,EAAE,eAAe,EAAqB,MAAM,yBAAyB,CAAA;AAE5E;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAsB,IAAI,CAAC,CAAA;AAEzE;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,MAAM,EACN,QAAQ,EACR,QAAQ,EAKT;IACC,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAe,GAAG,EAAE,CAC1C,eAAe,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CACtC,CAAA;IACD,8EAA8E;IAC9E
|
|
1
|
+
{"version":3,"file":"WasSessionProvider.js","sourceRoot":"","sources":["../../src/react/WasSessionProvider.tsx"],"names":[],"mappings":";AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAA;AAE1E,OAAO,EAAE,eAAe,EAAqB,MAAM,yBAAyB,CAAA;AAE5E;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAsB,IAAI,CAAC,CAAA;AAEzE;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,MAAM,EACN,QAAQ,EACR,QAAQ,EAKT;IACC,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAe,GAAG,EAAE,CAC1C,eAAe,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CACtC,CAAA;IACD,kEAAkE;IAClE,8EAA8E;IAC9E,uEAAuE;IACvE,6EAA6E;IAC7E,6EAA6E;IAC7E,wEAAwE;IACxE,uDAAuD;IACvD,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAA;QAC5B,OAAO,GAAG,EAAE;YACV,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAA;QACjC,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IACX,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACrC,QAAQ,GACkB,CAC9B,CAAA;AACH,CAAC"}
|
package/dist/react/hooks.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { WasAuthStore } from '../session/authStore.js';
|
|
2
2
|
import { type SyncRollup } from '../storage/syncStatusStore.js';
|
|
3
|
-
export { useAppReady } from '../session/appReadyStore.js';
|
|
4
3
|
/**
|
|
5
4
|
* The bound auth store from the nearest {@link WasSessionProvider}. Throws a
|
|
6
5
|
* helpful error when used outside a provider.
|
|
@@ -16,6 +15,8 @@ export declare function useAuthStore(): WasAuthStore;
|
|
|
16
15
|
*/
|
|
17
16
|
export declare function useSession(): {
|
|
18
17
|
status: ReturnType<WasAuthStore['getState']>['status'];
|
|
18
|
+
onboarding: ReturnType<WasAuthStore['getState']>['onboarding'];
|
|
19
|
+
authenticating: boolean;
|
|
19
20
|
phase: ReturnType<WasAuthStore['getState']>['phase'];
|
|
20
21
|
error: string | null;
|
|
21
22
|
controllerDid: string | null;
|
|
@@ -24,22 +25,36 @@ export declare function useSession(): {
|
|
|
24
25
|
reconnecting: boolean;
|
|
25
26
|
};
|
|
26
27
|
/**
|
|
27
|
-
* The login action plus the state the login page renders
|
|
28
|
+
* The login action plus the state the login page renders. `authenticating` is
|
|
29
|
+
* the in-flight flag (the `status` stays `local` during login); `status` is
|
|
30
|
+
* exposed so a login page can redirect once it reads `connected`.
|
|
28
31
|
*
|
|
29
32
|
* @returns {object}
|
|
30
33
|
*/
|
|
31
34
|
export declare function useLogin(): {
|
|
32
35
|
login: () => Promise<void>;
|
|
36
|
+
authenticating: boolean;
|
|
33
37
|
status: ReturnType<WasAuthStore['getState']>['status'];
|
|
34
38
|
phase: ReturnType<WasAuthStore['getState']>['phase'];
|
|
35
39
|
error: string | null;
|
|
36
40
|
};
|
|
37
41
|
/**
|
|
38
|
-
* The logout action
|
|
42
|
+
* The logout action; accepts `{ wipe }` to delete the connected replica rather
|
|
43
|
+
* than keep it on the device.
|
|
44
|
+
*
|
|
45
|
+
* @returns {(options?: { wipe?: boolean }) => Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
export declare function useLogout(): (options?: {
|
|
48
|
+
wipe?: boolean;
|
|
49
|
+
}) => Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* The clear-data action: deletes the local replica, discards the anonymous
|
|
52
|
+
* seed, and mints a fresh anonymous seed/DID + replica (the `local`-mode
|
|
53
|
+
* "Clear data" affordance).
|
|
39
54
|
*
|
|
40
55
|
* @returns {() => Promise<void>}
|
|
41
56
|
*/
|
|
42
|
-
export declare function
|
|
57
|
+
export declare function useClearData(): () => Promise<void>;
|
|
43
58
|
/**
|
|
44
59
|
* The expired-access reconnect: the banner flags plus the reconnect action.
|
|
45
60
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/react/hooks.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,+BAA+B,CAAA;AAEtC
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/react/hooks.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,+BAA+B,CAAA;AAEtC;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,YAAY,CAS3C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI;IAC5B,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACtD,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;IAC9D,cAAc,EAAE,OAAO,CAAA;IACvB,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IACpD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,aAAa,EAAE,OAAO,CAAA;IACtB,YAAY,EAAE,OAAO,CAAA;CACtB,CAgBA;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,IAAI;IAC1B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACtD,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IACpD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB,CAaA;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,CAAC,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAG3E;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,MAAM,OAAO,CAAC,IAAI,CAAC,CAGlD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI;IAC9B,aAAa,EAAE,OAAO,CAAA;IACtB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC/B,CAWA;AAED;;;GAGG;AACH,YAAY,EAAE,UAAU,EAAE,CAAA;AAE1B;;;;;;;GAOG;AACH,wBAAgB,aAAa,IAAI;IAC/B,KAAK,EAAE,UAAU,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAKA"}
|
package/dist/react/hooks.js
CHANGED
|
@@ -11,7 +11,6 @@ import { useStore } from 'zustand';
|
|
|
11
11
|
import { useShallow } from 'zustand/react/shallow';
|
|
12
12
|
import { WasSessionContext } from './WasSessionProvider.js';
|
|
13
13
|
import { useSyncStatusStore, deriveSyncRollup } from '../storage/syncStatusStore.js';
|
|
14
|
-
export { useAppReady } from '../session/appReadyStore.js';
|
|
15
14
|
/**
|
|
16
15
|
* The bound auth store from the nearest {@link WasSessionProvider}. Throws a
|
|
17
16
|
* helpful error when used outside a provider.
|
|
@@ -36,6 +35,8 @@ export function useSession() {
|
|
|
36
35
|
const store = useAuthStore();
|
|
37
36
|
return useStore(store, useShallow(state => ({
|
|
38
37
|
status: state.status,
|
|
38
|
+
onboarding: state.onboarding,
|
|
39
|
+
authenticating: state.authenticating,
|
|
39
40
|
phase: state.phase,
|
|
40
41
|
error: state.error,
|
|
41
42
|
controllerDid: state.controllerDid,
|
|
@@ -45,29 +46,44 @@ export function useSession() {
|
|
|
45
46
|
})));
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
|
-
* The login action plus the state the login page renders
|
|
49
|
+
* The login action plus the state the login page renders. `authenticating` is
|
|
50
|
+
* the in-flight flag (the `status` stays `local` during login); `status` is
|
|
51
|
+
* exposed so a login page can redirect once it reads `connected`.
|
|
49
52
|
*
|
|
50
53
|
* @returns {object}
|
|
51
54
|
*/
|
|
52
55
|
export function useLogin() {
|
|
53
56
|
const store = useAuthStore();
|
|
54
57
|
const login = useStore(store, state => state.login);
|
|
55
|
-
const { status, phase, error } = useStore(store, useShallow(state => ({
|
|
58
|
+
const { authenticating, status, phase, error } = useStore(store, useShallow(state => ({
|
|
59
|
+
authenticating: state.authenticating,
|
|
56
60
|
status: state.status,
|
|
57
61
|
phase: state.phase,
|
|
58
62
|
error: state.error
|
|
59
63
|
})));
|
|
60
|
-
return { login, status, phase, error };
|
|
64
|
+
return { login, authenticating, status, phase, error };
|
|
61
65
|
}
|
|
62
66
|
/**
|
|
63
|
-
* The logout action
|
|
67
|
+
* The logout action; accepts `{ wipe }` to delete the connected replica rather
|
|
68
|
+
* than keep it on the device.
|
|
64
69
|
*
|
|
65
|
-
* @returns {() => Promise<void>}
|
|
70
|
+
* @returns {(options?: { wipe?: boolean }) => Promise<void>}
|
|
66
71
|
*/
|
|
67
72
|
export function useLogout() {
|
|
68
73
|
const store = useAuthStore();
|
|
69
74
|
return useStore(store, state => state.logout);
|
|
70
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The clear-data action: deletes the local replica, discards the anonymous
|
|
78
|
+
* seed, and mints a fresh anonymous seed/DID + replica (the `local`-mode
|
|
79
|
+
* "Clear data" affordance).
|
|
80
|
+
*
|
|
81
|
+
* @returns {() => Promise<void>}
|
|
82
|
+
*/
|
|
83
|
+
export function useClearData() {
|
|
84
|
+
const store = useAuthStore();
|
|
85
|
+
return useStore(store, state => state.clearLocalData);
|
|
86
|
+
}
|
|
71
87
|
/**
|
|
72
88
|
* The expired-access reconnect: the banner flags plus the reconnect action.
|
|
73
89
|
*
|
package/dist/react/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAE3D,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,+BAA+B,CAAA;AAEtC
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAE3D,OAAO,EACL,k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BAAgB,CAAC,MAAM,CAAC,CAAA;AACjC,CAAC"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
* `./mui` subpath.
|
|
8
8
|
*/
|
|
9
9
|
export { WasSessionProvider, WasSessionContext } from './WasSessionProvider.js';
|
|
10
|
-
export { useAuthStore, useSession, useLogin, useLogout, useReconnect, useSyncStatus,
|
|
10
|
+
export { useAuthStore, useSession, useLogin, useLogout, useClearData, useReconnect, useSyncStatus, type SyncRollup } from './hooks.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,KAAK,UAAU,EAChB,MAAM,YAAY,CAAA"}
|
package/dist/react/index.js
CHANGED
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
* `./mui` subpath.
|
|
8
8
|
*/
|
|
9
9
|
export { WasSessionProvider, WasSessionContext } from './WasSessionProvider.js';
|
|
10
|
-
export { useAuthStore, useSession, useLogin, useLogout, useReconnect, useSyncStatus
|
|
10
|
+
export { useAuthStore, useSession, useLogin, useLogout, useClearData, useReconnect, useSyncStatus } from './hooks.js';
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,aAAa,EAEd,MAAM,YAAY,CAAA"}
|
|
@@ -2,17 +2,24 @@
|
|
|
2
2
|
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The session auth store (zustand): a four-state machine
|
|
6
|
+
* (`boot` | `local` | `connected` | `reconnect`) that owns the whole session
|
|
7
|
+
* lifecycle -- boot (hot restore or fall to an anonymous local replica), Login
|
|
8
|
+
* With Wallet, the non-CHAPI `connectWithGrants` path, logout, clear-data, and
|
|
9
|
+
* the expired-access reconnect -- plus the open/hydrate/sync ordering.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* `boot` attempts a zero-popup session restore. A restore hit opens the
|
|
12
|
+
* encrypted {@link LocalStore} under the session seed, hydrates the entity
|
|
13
|
+
* stores, starts WAS replication, and lands `connected`. A restore miss (or any
|
|
14
|
+
* error) opens the store under a persisted ANONYMOUS seed instead and lands
|
|
15
|
+
* `local`: a fully usable, encrypted, local-only replica with no remote. Both
|
|
16
|
+
* successors finish open+hydrate before leaving `boot`, so "app ready" is simply
|
|
17
|
+
* `status !== 'boot'`.
|
|
13
18
|
*
|
|
14
|
-
* `
|
|
15
|
-
*
|
|
19
|
+
* Login (or `connectWithGrants`) tears the anonymous replica down and opens the
|
|
20
|
+
* connected replica under the wallet-derived seed. Logout returns to a fresh
|
|
21
|
+
* `local` (optionally wiping the connected replica); `clearLocalData` mints a
|
|
22
|
+
* brand-new anonymous seed and replica.
|
|
16
23
|
*
|
|
17
24
|
* The library cannot bind a module-level store to app config, so this is a
|
|
18
25
|
* FACTORY: {@link createAuthStore} captures the app's {@link WasAppConfig} and
|
|
@@ -21,12 +28,34 @@
|
|
|
21
28
|
*/
|
|
22
29
|
import { type StoreApi } from 'zustand/vanilla';
|
|
23
30
|
import type { RxStorage } from 'rxdb/plugins/core';
|
|
31
|
+
import type { IZcap } from '@interop/data-integrity-core';
|
|
24
32
|
import { type StoreRegistry, type WasAppConfig } from '../config.js';
|
|
25
33
|
import { type SeedStore } from '../identity/seedStore.js';
|
|
26
34
|
import { type LoginPhase } from '../auth/loginFlow.js';
|
|
27
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The four session states:
|
|
37
|
+
* - `boot`: attempting hot restore; both successors open + hydrate before this
|
|
38
|
+
* status is left.
|
|
39
|
+
* - `local`: an encrypted anonymous-seed replica, no remote (the pre-connection
|
|
40
|
+
* product state; tier-1 apps may stay here indefinitely).
|
|
41
|
+
* - `connected`: a wallet-derived identity, parsed grants, replication.
|
|
42
|
+
* - `reconnect`: connected but access expired/revoked; the replica stays usable,
|
|
43
|
+
* remote invocations paused until re-login.
|
|
44
|
+
*/
|
|
45
|
+
export type SessionStatus = 'boot' | 'local' | 'connected' | 'reconnect';
|
|
28
46
|
export interface AuthState {
|
|
29
|
-
status:
|
|
47
|
+
status: SessionStatus;
|
|
48
|
+
/**
|
|
49
|
+
* The app's onboarding mode. Read by `ProtectedRoute` to decide whether to
|
|
50
|
+
* render the app or redirect to login while in `local`; never affects the
|
|
51
|
+
* store's own transitions.
|
|
52
|
+
*/
|
|
53
|
+
onboarding: 'local-first' | 'login-gated';
|
|
54
|
+
/**
|
|
55
|
+
* A Login With Wallet flow is in flight (the transient the login page's busy
|
|
56
|
+
* state keys off; distinct from the `status`, which stays `local` throughout).
|
|
57
|
+
*/
|
|
58
|
+
authenticating: boolean;
|
|
30
59
|
/**
|
|
31
60
|
* The current login phase, for the login page's progress line.
|
|
32
61
|
*/
|
|
@@ -34,32 +63,66 @@ export interface AuthState {
|
|
|
34
63
|
error: string | null;
|
|
35
64
|
controllerDid: string | null;
|
|
36
65
|
/**
|
|
37
|
-
* ISO expiry of the current grant set (earliest zcap expiry)
|
|
66
|
+
* ISO expiry of the current grant set (earliest zcap expiry); `null` in
|
|
67
|
+
* `local` (no grants).
|
|
38
68
|
*/
|
|
39
69
|
expires: string | null;
|
|
40
70
|
/**
|
|
41
|
-
* A live 401/403 was seen mid-session: show the
|
|
71
|
+
* A live 401/403 was seen mid-session (or a proactive near-expiry): show the
|
|
72
|
+
* reconnect banner. Always true iff `status === 'reconnect'`.
|
|
42
73
|
*/
|
|
43
74
|
accessExpired: boolean;
|
|
44
75
|
reconnecting: boolean;
|
|
45
76
|
/**
|
|
46
|
-
*
|
|
77
|
+
* Attempt a zero-popup hot restore; a restore hit lands `connected`, any
|
|
78
|
+
* miss/error falls to `local` (a fresh anonymous replica), never a dead login
|
|
79
|
+
* screen. No-op once the status has left `boot`.
|
|
47
80
|
*/
|
|
48
|
-
|
|
81
|
+
boot: () => Promise<void>;
|
|
49
82
|
/**
|
|
50
|
-
* Full Login With Wallet (first-run or returning).
|
|
83
|
+
* Full Login With Wallet (first-run or returning). On success tears down the
|
|
84
|
+
* anonymous replica and opens the connected one.
|
|
51
85
|
*/
|
|
52
86
|
login: () => Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Non-CHAPI connect from an explicit seed + grants (dev/test and provisioned
|
|
89
|
+
* grants). Tears down the current replica and opens the connected one.
|
|
90
|
+
*
|
|
91
|
+
* @param options {object}
|
|
92
|
+
* @param options.seed {Uint8Array}
|
|
93
|
+
* @param options.grants {IZcap[]}
|
|
94
|
+
* @returns {Promise<void>}
|
|
95
|
+
*/
|
|
96
|
+
connectWithGrants: (options: {
|
|
97
|
+
seed: Uint8Array;
|
|
98
|
+
grants: IZcap[];
|
|
99
|
+
}) => Promise<void>;
|
|
53
100
|
/**
|
|
54
101
|
* Re-run the grants flow with the existing seed (expired access).
|
|
55
102
|
*/
|
|
56
103
|
reconnect: () => Promise<void>;
|
|
57
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Detach the wallet and return to a fresh `local` replica. `wipe` deletes the
|
|
106
|
+
* connected replica's database; otherwise it is kept on the device.
|
|
107
|
+
*
|
|
108
|
+
* @param [options] {object}
|
|
109
|
+
* @param [options.wipe] {boolean}
|
|
110
|
+
* @returns {Promise<void>}
|
|
111
|
+
*/
|
|
112
|
+
logout: (options?: {
|
|
113
|
+
wipe?: boolean;
|
|
114
|
+
}) => Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Delete the local replica, discard the anonymous seed, and mint a fresh
|
|
117
|
+
* anonymous seed/DID + replica. The shared reset primitive behind the
|
|
118
|
+
* `local`-mode "Clear data" button.
|
|
119
|
+
*/
|
|
120
|
+
clearLocalData: () => Promise<void>;
|
|
58
121
|
notifyAccessExpired: () => void;
|
|
59
122
|
/**
|
|
60
|
-
* Tears down the live
|
|
61
|
-
* wiping the persisted session record, and returns to `
|
|
62
|
-
* `
|
|
123
|
+
* Tears down the live replica (expiry watch, controller, local store) WITHOUT
|
|
124
|
+
* wiping the persisted session record, and returns to `boot` so a fresh
|
|
125
|
+
* `boot()` can re-open it. Called from the provider's unmount cleanup so an
|
|
63
126
|
* unmount (or a React StrictMode dev remount) never orphans the replication
|
|
64
127
|
* loop or the expiry-watch interval.
|
|
65
128
|
*/
|
|
@@ -70,7 +133,7 @@ export interface AuthState {
|
|
|
70
133
|
*/
|
|
71
134
|
export type WasAuthStore = StoreApi<AuthState>;
|
|
72
135
|
/**
|
|
73
|
-
* Builds the
|
|
136
|
+
* Builds the session auth store bound to an app's config and store registry.
|
|
74
137
|
* Call once (the React provider does) and share the returned store through
|
|
75
138
|
* context; the hooks read it via `useStore`.
|
|
76
139
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authStore.d.ts","sourceRoot":"","sources":["../../src/session/authStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"authStore.d.ts","sourceRoot":"","sources":["../../src/session/authStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAA;AAIrB,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAQ1E,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAA;AAuB7B;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,CAAA;AAUxE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,aAAa,CAAA;IACrB;;;;OAIG;IACH,UAAU,EAAE,aAAa,GAAG,aAAa,CAAA;IACzC;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,aAAa,EAAE,MAAM,GAAG,IAAI,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