@basictech/react 0.8.0-beta.3 → 0.8.0-beta.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.
- package/changelog.md +6 -0
- package/dist/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +537 -141
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +545 -142
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme.md +99 -97
- package/src/AuthContext.tsx +513 -415
- package/src/context.tsx +19 -1
- package/src/core/auth/AuthManager.ts +1235 -746
- package/src/sync/syncProtocol.js +23 -7
package/src/context.tsx
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react'
|
|
2
2
|
import type { BasicDB } from './core/db'
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
User,
|
|
5
|
+
AuthResult,
|
|
6
|
+
GetTokenOptions,
|
|
7
|
+
AuthStatus,
|
|
8
|
+
} from './core/auth/AuthManager'
|
|
4
9
|
import type { DBMode } from './core/db'
|
|
5
10
|
|
|
6
11
|
export enum DBStatus {
|
|
@@ -10,7 +15,16 @@ export enum DBStatus {
|
|
|
10
15
|
ONLINE = 'ONLINE',
|
|
11
16
|
SYNCING = 'SYNCING',
|
|
12
17
|
ERROR = 'ERROR',
|
|
18
|
+
/** Sync-layer error with automatic retry (maps from dexie-syncable status 4). */
|
|
13
19
|
ERROR_WILL_RETRY = 'ERROR_WILL_RETRY',
|
|
20
|
+
/**
|
|
21
|
+
* Auth-driven status: set by the provider when `authStatus` transitions to
|
|
22
|
+
* `reauth_required`, causing sync to disconnect. Unlike the other statuses
|
|
23
|
+
* this is NOT mapped from a dexie-syncable status code — it is set
|
|
24
|
+
* programmatically by `BasicProvider` to signal that the token is
|
|
25
|
+
* definitively invalid and the user must re-authenticate before sync can
|
|
26
|
+
* resume.
|
|
27
|
+
*/
|
|
14
28
|
ERROR_TOKEN_EXPIRED = 'ERROR_TOKEN_EXPIRED',
|
|
15
29
|
}
|
|
16
30
|
|
|
@@ -30,6 +44,8 @@ export type BasicSchemaDevInfo = {
|
|
|
30
44
|
export type BasicContextType = {
|
|
31
45
|
isReady: boolean
|
|
32
46
|
isSignedIn: boolean
|
|
47
|
+
authStatus: AuthStatus
|
|
48
|
+
authErrorCode: string | null
|
|
33
49
|
user: User | null
|
|
34
50
|
did: string | null
|
|
35
51
|
scope: string | null
|
|
@@ -69,6 +85,8 @@ const noDb: BasicDB = {
|
|
|
69
85
|
export const BasicContext = createContext<BasicContextType>({
|
|
70
86
|
isReady: false,
|
|
71
87
|
isSignedIn: false,
|
|
88
|
+
authStatus: 'bootstrapping',
|
|
89
|
+
authErrorCode: null,
|
|
72
90
|
user: null,
|
|
73
91
|
did: null,
|
|
74
92
|
scope: null,
|