@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/changelog.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 1.3.4
|
|
2
2
|
|
|
3
|
+
## 0.8.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Auth status state machine and session reconciliation: add `AuthStatus` type (`bootstrapping`, `authenticated`, `recovering`, `reauth_required`, `signed_out`), replace `window.location.reload()` cross-tab handlers with in-place state updates, add `reconcileSession` for sync/visibility/online recovery, handle `tokenUpdateAck` in sync protocol, and expose `authStatus` + `authErrorCode` from `useBasic()`
|
|
8
|
+
|
|
3
9
|
## 0.8.0-beta.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -256,6 +256,26 @@ type User = {
|
|
|
256
256
|
email?: string;
|
|
257
257
|
picture?: string;
|
|
258
258
|
};
|
|
259
|
+
/**
|
|
260
|
+
* High-level auth lifecycle state.
|
|
261
|
+
*
|
|
262
|
+
* - `bootstrapping` — SDK is initializing; not yet determined if a session exists.
|
|
263
|
+
* - `authenticated` — User has a valid access token and active session.
|
|
264
|
+
* - `recovering` — A session likely exists (refresh token / cached user) but
|
|
265
|
+
* the SDK hasn't confirmed it yet (e.g. offline, mid-refresh).
|
|
266
|
+
* - `reauth_required` — The session is definitively invalid (revoked, expired
|
|
267
|
+
* refresh token, etc.). The user must sign in again.
|
|
268
|
+
* NOTE: `isSignedIn` remains `true` in this state so the UI
|
|
269
|
+
* can display user info while prompting re-authentication.
|
|
270
|
+
* Use `authStatus === 'reauth_required'` to distinguish
|
|
271
|
+
* this from a healthy signed-in state.
|
|
272
|
+
* - `signed_out` — No session. User is not authenticated.
|
|
273
|
+
*
|
|
274
|
+
* TODO: revisit naming and ergonomics — consider adding a `needsReauth` or
|
|
275
|
+
* `shouldPromptSignIn` convenience getter so consumers don't need to inspect
|
|
276
|
+
* the raw status to decide between "sign in" vs "sign out" UI.
|
|
277
|
+
*/
|
|
278
|
+
type AuthStatus = 'bootstrapping' | 'authenticated' | 'recovering' | 'reauth_required' | 'signed_out';
|
|
259
279
|
type AuthResult = {
|
|
260
280
|
success: boolean;
|
|
261
281
|
error?: string;
|
|
@@ -272,7 +292,16 @@ declare enum DBStatus {
|
|
|
272
292
|
ONLINE = "ONLINE",
|
|
273
293
|
SYNCING = "SYNCING",
|
|
274
294
|
ERROR = "ERROR",
|
|
295
|
+
/** Sync-layer error with automatic retry (maps from dexie-syncable status 4). */
|
|
275
296
|
ERROR_WILL_RETRY = "ERROR_WILL_RETRY",
|
|
297
|
+
/**
|
|
298
|
+
* Auth-driven status: set by the provider when `authStatus` transitions to
|
|
299
|
+
* `reauth_required`, causing sync to disconnect. Unlike the other statuses
|
|
300
|
+
* this is NOT mapped from a dexie-syncable status code — it is set
|
|
301
|
+
* programmatically by `BasicProvider` to signal that the token is
|
|
302
|
+
* definitively invalid and the user must re-authenticate before sync can
|
|
303
|
+
* resume.
|
|
304
|
+
*/
|
|
276
305
|
ERROR_TOKEN_EXPIRED = "ERROR_TOKEN_EXPIRED"
|
|
277
306
|
}
|
|
278
307
|
/** Snapshot of local schema vs server (for dev toolbar and debugging). */
|
|
@@ -290,6 +319,8 @@ type BasicSchemaDevInfo = {
|
|
|
290
319
|
type BasicContextType = {
|
|
291
320
|
isReady: boolean;
|
|
292
321
|
isSignedIn: boolean;
|
|
322
|
+
authStatus: AuthStatus;
|
|
323
|
+
authErrorCode: string | null;
|
|
293
324
|
user: User | null;
|
|
294
325
|
did: string | null;
|
|
295
326
|
scope: string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -256,6 +256,26 @@ type User = {
|
|
|
256
256
|
email?: string;
|
|
257
257
|
picture?: string;
|
|
258
258
|
};
|
|
259
|
+
/**
|
|
260
|
+
* High-level auth lifecycle state.
|
|
261
|
+
*
|
|
262
|
+
* - `bootstrapping` — SDK is initializing; not yet determined if a session exists.
|
|
263
|
+
* - `authenticated` — User has a valid access token and active session.
|
|
264
|
+
* - `recovering` — A session likely exists (refresh token / cached user) but
|
|
265
|
+
* the SDK hasn't confirmed it yet (e.g. offline, mid-refresh).
|
|
266
|
+
* - `reauth_required` — The session is definitively invalid (revoked, expired
|
|
267
|
+
* refresh token, etc.). The user must sign in again.
|
|
268
|
+
* NOTE: `isSignedIn` remains `true` in this state so the UI
|
|
269
|
+
* can display user info while prompting re-authentication.
|
|
270
|
+
* Use `authStatus === 'reauth_required'` to distinguish
|
|
271
|
+
* this from a healthy signed-in state.
|
|
272
|
+
* - `signed_out` — No session. User is not authenticated.
|
|
273
|
+
*
|
|
274
|
+
* TODO: revisit naming and ergonomics — consider adding a `needsReauth` or
|
|
275
|
+
* `shouldPromptSignIn` convenience getter so consumers don't need to inspect
|
|
276
|
+
* the raw status to decide between "sign in" vs "sign out" UI.
|
|
277
|
+
*/
|
|
278
|
+
type AuthStatus = 'bootstrapping' | 'authenticated' | 'recovering' | 'reauth_required' | 'signed_out';
|
|
259
279
|
type AuthResult = {
|
|
260
280
|
success: boolean;
|
|
261
281
|
error?: string;
|
|
@@ -272,7 +292,16 @@ declare enum DBStatus {
|
|
|
272
292
|
ONLINE = "ONLINE",
|
|
273
293
|
SYNCING = "SYNCING",
|
|
274
294
|
ERROR = "ERROR",
|
|
295
|
+
/** Sync-layer error with automatic retry (maps from dexie-syncable status 4). */
|
|
275
296
|
ERROR_WILL_RETRY = "ERROR_WILL_RETRY",
|
|
297
|
+
/**
|
|
298
|
+
* Auth-driven status: set by the provider when `authStatus` transitions to
|
|
299
|
+
* `reauth_required`, causing sync to disconnect. Unlike the other statuses
|
|
300
|
+
* this is NOT mapped from a dexie-syncable status code — it is set
|
|
301
|
+
* programmatically by `BasicProvider` to signal that the token is
|
|
302
|
+
* definitively invalid and the user must re-authenticate before sync can
|
|
303
|
+
* resume.
|
|
304
|
+
*/
|
|
276
305
|
ERROR_TOKEN_EXPIRED = "ERROR_TOKEN_EXPIRED"
|
|
277
306
|
}
|
|
278
307
|
/** Snapshot of local schema vs server (for dev toolbar and debugging). */
|
|
@@ -290,6 +319,8 @@ type BasicSchemaDevInfo = {
|
|
|
290
319
|
type BasicContextType = {
|
|
291
320
|
isReady: boolean;
|
|
292
321
|
isSignedIn: boolean;
|
|
322
|
+
authStatus: AuthStatus;
|
|
323
|
+
authErrorCode: string | null;
|
|
293
324
|
user: User | null;
|
|
294
325
|
did: string | null;
|
|
295
326
|
scope: string | null;
|