@basictech/react 0.8.0-beta.1 → 0.8.0-beta.3

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @basictech/react@0.7.0 build
3
+ > @basictech/react@0.8.0-beta.1 build
4
4
  > tsup
5
5
 
6
6
  CLI Building entry: src/index.ts
@@ -11,14 +11,14 @@
11
11
  CLI Cleaning output folder
12
12
  CJS Build start
13
13
  ESM Build start
14
- ESM dist/index.mjs 60.82 KB
15
- ESM dist/index.mjs.map 128.64 KB
16
- ESM ⚡️ Build success in 30ms
17
- CJS dist/index.js 63.30 KB
18
- CJS dist/index.js.map 128.74 KB
19
- CJS ⚡️ Build success in 30ms
14
+ CJS dist/index.js 97.02 KB
15
+ CJS dist/index.js.map 187.81 KB
16
+ CJS ⚡️ Build success in 36ms
17
+ ESM dist/index.mjs 93.09 KB
18
+ ESM dist/index.mjs.map 187.75 KB
19
+ ESM ⚡️ Build success in 37ms
20
20
  DTS Build start
21
- DTS ⚡️ Build success in 908ms
22
- DTS dist/index.d.ts 11.15 KB
23
- DTS dist/index.d.mts 11.15 KB
21
+ DTS ⚡️ Build success in 1091ms
22
+ DTS dist/index.d.ts 12.66 KB
23
+ DTS dist/index.d.mts 12.66 KB
24
24
  ⠙
package/changelog.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # 1.3.4
2
2
 
3
+ ## 0.8.0-beta.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix PWA/mobile logout issues: harden auth for offline resilience, prevent spurious logouts on transient server errors, proactive token refresh on app resume, and fix potential deadlock in token refresh flow
8
+
9
+ ## 0.8.0-beta.2
10
+
11
+ ### Minor Changes
12
+
13
+ - added debug bar
14
+
3
15
  ## 0.8.0-beta.1
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React from 'react';
2
+ import react from 'react';
3
3
  export { useLiveQuery as useQuery } from 'dexie-react-hooks';
4
4
 
5
5
  /**
@@ -265,35 +265,6 @@ type GetTokenOptions = {
265
265
  forceRefresh?: boolean;
266
266
  };
267
267
 
268
- type AuthConfig = {
269
- scopes?: string | string[];
270
- /** @deprecated Use pds_url instead */
271
- server_url?: string;
272
- /** PDS URL for auth and data (default: https://pds.basic.id) */
273
- pds_url?: string;
274
- /** Admin server URL for connect reporting (default: https://api.basic.tech) */
275
- admin_url?: string;
276
- ws_url?: string;
277
- };
278
- type BasicProviderProps = {
279
- children: React.ReactNode;
280
- /**
281
- * @deprecated Project ID is now extracted from schema.project_id.
282
- * This prop is kept for backward compatibility but can be omitted.
283
- */
284
- project_id?: string;
285
- /** The Basic schema object containing project_id and table definitions */
286
- schema?: any;
287
- debug?: boolean;
288
- storage?: BasicStorage;
289
- auth?: AuthConfig;
290
- /**
291
- * Database mode - determines which implementation is used
292
- * - 'sync': Uses Dexie + WebSocket for local-first sync (default)
293
- * - 'remote': Uses REST API calls directly to server
294
- */
295
- dbMode?: DBMode;
296
- };
297
268
  declare enum DBStatus {
298
269
  LOADING = "LOADING",
299
270
  OFFLINE = "OFFLINE",
@@ -301,11 +272,18 @@ declare enum DBStatus {
301
272
  ONLINE = "ONLINE",
302
273
  SYNCING = "SYNCING",
303
274
  ERROR = "ERROR",
304
- /** Sync reported an error but will retry (e.g. expired token). Used for status code 4 from dexie-syncable. */
305
275
  ERROR_WILL_RETRY = "ERROR_WILL_RETRY",
306
- /** Token expired; the SDK is refreshing and will reconnect automatically. */
307
276
  ERROR_TOKEN_EXPIRED = "ERROR_TOKEN_EXPIRED"
308
277
  }
278
+ /** Snapshot of local schema vs server (for dev toolbar and debugging). */
279
+ type BasicSchemaDevInfo = {
280
+ projectId: string | null;
281
+ localVersion: number | undefined;
282
+ status: string;
283
+ valid: boolean;
284
+ lastCheckedAt: number;
285
+ error?: string;
286
+ };
309
287
  /**
310
288
  * Context type for useBasic hook
311
289
  */
@@ -313,13 +291,9 @@ type BasicContextType = {
313
291
  isReady: boolean;
314
292
  isSignedIn: boolean;
315
293
  user: User | null;
316
- /** The user's DID (Decentralized Identifier), extracted from the access token `sub` claim */
317
294
  did: string | null;
318
- /** Space-separated scope string from the access token */
319
295
  scope: string | null;
320
- /** Check if a specific scope is granted (e.g., hasScope('profile')) */
321
296
  hasScope: (scope: string) => boolean;
322
- /** Returns scopes that were requested but not granted in the current token */
323
297
  missingScopes: () => string[];
324
298
  signIn: () => Promise<void>;
325
299
  signInWithHandle: (handle: string) => Promise<void>;
@@ -330,20 +304,62 @@ type BasicContextType = {
330
304
  db: BasicDB;
331
305
  dbStatus: DBStatus;
332
306
  dbMode: DBMode;
333
- /** @deprecated Use isReady instead */
307
+ /** Local schema vs server status; null if no schema on the provider. */
308
+ devInfo: BasicSchemaDevInfo | null;
309
+ /** Re-run remote schema check (dev toolbar). */
310
+ refreshSchemaStatus: () => Promise<void>;
334
311
  isAuthReady: boolean;
335
- /** @deprecated Use signIn instead */
336
312
  signin: () => Promise<void>;
337
- /** @deprecated Use signOut instead */
338
313
  signout: () => Promise<void>;
339
- /** @deprecated Use signInWithCode instead */
340
314
  signinWithCode: (code: string, state?: string) => Promise<AuthResult>;
341
- /** @deprecated Use getSignInUrl instead */
342
315
  getSignInLink: (redirectUri?: string) => Promise<string>;
343
316
  };
344
- declare function BasicProvider({ children, project_id: project_id_prop, schema, debug, storage, auth, dbMode }: BasicProviderProps): react_jsx_runtime.JSX.Element;
345
317
  declare function useBasic(): BasicContextType;
346
318
 
319
+ type AuthConfig = {
320
+ scopes?: string | string[];
321
+ /** @deprecated Use pds_url instead */
322
+ server_url?: string;
323
+ /** PDS URL for auth and data (default: https://pds.basic.id) */
324
+ pds_url?: string;
325
+ /** Admin server URL for connect reporting (default: https://api.basic.tech) */
326
+ admin_url?: string;
327
+ ws_url?: string;
328
+ };
329
+ type BasicProviderProps = {
330
+ children: react.ReactNode;
331
+ /**
332
+ * @deprecated Project ID is now extracted from schema.project_id.
333
+ * This prop is kept for backward compatibility but can be omitted.
334
+ */
335
+ project_id?: string;
336
+ /** The Basic schema object containing project_id and table definitions */
337
+ schema?: any;
338
+ debug?: boolean;
339
+ storage?: BasicStorage;
340
+ auth?: AuthConfig;
341
+ /**
342
+ * Database mode - determines which implementation is used
343
+ * - 'sync': Uses Dexie + WebSocket for local-first sync (default)
344
+ * - 'remote': Uses REST API calls directly to server
345
+ */
346
+ dbMode?: DBMode;
347
+ /** Show floating dev toolbar (localhost, NODE_ENV=development, or debug=true). */
348
+ devToolbar?: boolean;
349
+ };
350
+ declare function BasicProvider({ children, project_id: project_id_prop, schema, debug, storage, auth, dbMode, devToolbar, }: BasicProviderProps): react_jsx_runtime.JSX.Element;
351
+
352
+ type BasicDevToolbarProps = {
353
+ /** When false, toolbar does not render. Defaults to true when used standalone. */
354
+ enabled?: boolean;
355
+ /** Same as BasicProvider `debug` — when true, toolbar shows even off localhost. */
356
+ debug?: boolean;
357
+ };
358
+ /**
359
+ * Floating dev-only toolbar: auth, DB/sync, and schema status. Requires `BasicProvider` with `debug` or localhost / NODE_ENV=development for visibility unless `enabled` is forced.
360
+ */
361
+ declare function BasicDevToolbar({ enabled, debug }: BasicDevToolbarProps): react_jsx_runtime.JSX.Element | null;
362
+
347
363
  type ResolvedDid = {
348
364
  did: string;
349
365
  handle?: string;
@@ -371,4 +387,4 @@ declare function resolveDid(did: string): Promise<ResolvedDid>;
371
387
  */
372
388
  declare function resolveHandle(handle: string): Promise<ResolvedDid>;
373
389
 
374
- export { type AuthConfig, type AuthError, type AuthResult, type BasicContextType, type BasicDB, BasicProvider, type BasicProviderProps, type BasicStorage, type Collection, type DBMode, DBStatus, type GetTokenOptions$1 as GetTokenOptions, LocalStorageAdapter, NotAuthenticatedError, RemoteCollection, RemoteDB, type RemoteDBConfig, RemoteDBError, type ResolvedDid, STORAGE_KEYS, resolveDid, resolveDidWebUrl, resolveHandle, useBasic };
390
+ export { type AuthConfig, type AuthError, type AuthResult, type BasicContextType, type BasicDB, BasicDevToolbar, type BasicDevToolbarProps, BasicProvider, type BasicProviderProps, type BasicSchemaDevInfo, type BasicStorage, type Collection, type DBMode, DBStatus, type GetTokenOptions$1 as GetTokenOptions, LocalStorageAdapter, NotAuthenticatedError, RemoteCollection, RemoteDB, type RemoteDBConfig, RemoteDBError, type ResolvedDid, STORAGE_KEYS, resolveDid, resolveDidWebUrl, resolveHandle, useBasic };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React from 'react';
2
+ import react from 'react';
3
3
  export { useLiveQuery as useQuery } from 'dexie-react-hooks';
4
4
 
5
5
  /**
@@ -265,35 +265,6 @@ type GetTokenOptions = {
265
265
  forceRefresh?: boolean;
266
266
  };
267
267
 
268
- type AuthConfig = {
269
- scopes?: string | string[];
270
- /** @deprecated Use pds_url instead */
271
- server_url?: string;
272
- /** PDS URL for auth and data (default: https://pds.basic.id) */
273
- pds_url?: string;
274
- /** Admin server URL for connect reporting (default: https://api.basic.tech) */
275
- admin_url?: string;
276
- ws_url?: string;
277
- };
278
- type BasicProviderProps = {
279
- children: React.ReactNode;
280
- /**
281
- * @deprecated Project ID is now extracted from schema.project_id.
282
- * This prop is kept for backward compatibility but can be omitted.
283
- */
284
- project_id?: string;
285
- /** The Basic schema object containing project_id and table definitions */
286
- schema?: any;
287
- debug?: boolean;
288
- storage?: BasicStorage;
289
- auth?: AuthConfig;
290
- /**
291
- * Database mode - determines which implementation is used
292
- * - 'sync': Uses Dexie + WebSocket for local-first sync (default)
293
- * - 'remote': Uses REST API calls directly to server
294
- */
295
- dbMode?: DBMode;
296
- };
297
268
  declare enum DBStatus {
298
269
  LOADING = "LOADING",
299
270
  OFFLINE = "OFFLINE",
@@ -301,11 +272,18 @@ declare enum DBStatus {
301
272
  ONLINE = "ONLINE",
302
273
  SYNCING = "SYNCING",
303
274
  ERROR = "ERROR",
304
- /** Sync reported an error but will retry (e.g. expired token). Used for status code 4 from dexie-syncable. */
305
275
  ERROR_WILL_RETRY = "ERROR_WILL_RETRY",
306
- /** Token expired; the SDK is refreshing and will reconnect automatically. */
307
276
  ERROR_TOKEN_EXPIRED = "ERROR_TOKEN_EXPIRED"
308
277
  }
278
+ /** Snapshot of local schema vs server (for dev toolbar and debugging). */
279
+ type BasicSchemaDevInfo = {
280
+ projectId: string | null;
281
+ localVersion: number | undefined;
282
+ status: string;
283
+ valid: boolean;
284
+ lastCheckedAt: number;
285
+ error?: string;
286
+ };
309
287
  /**
310
288
  * Context type for useBasic hook
311
289
  */
@@ -313,13 +291,9 @@ type BasicContextType = {
313
291
  isReady: boolean;
314
292
  isSignedIn: boolean;
315
293
  user: User | null;
316
- /** The user's DID (Decentralized Identifier), extracted from the access token `sub` claim */
317
294
  did: string | null;
318
- /** Space-separated scope string from the access token */
319
295
  scope: string | null;
320
- /** Check if a specific scope is granted (e.g., hasScope('profile')) */
321
296
  hasScope: (scope: string) => boolean;
322
- /** Returns scopes that were requested but not granted in the current token */
323
297
  missingScopes: () => string[];
324
298
  signIn: () => Promise<void>;
325
299
  signInWithHandle: (handle: string) => Promise<void>;
@@ -330,20 +304,62 @@ type BasicContextType = {
330
304
  db: BasicDB;
331
305
  dbStatus: DBStatus;
332
306
  dbMode: DBMode;
333
- /** @deprecated Use isReady instead */
307
+ /** Local schema vs server status; null if no schema on the provider. */
308
+ devInfo: BasicSchemaDevInfo | null;
309
+ /** Re-run remote schema check (dev toolbar). */
310
+ refreshSchemaStatus: () => Promise<void>;
334
311
  isAuthReady: boolean;
335
- /** @deprecated Use signIn instead */
336
312
  signin: () => Promise<void>;
337
- /** @deprecated Use signOut instead */
338
313
  signout: () => Promise<void>;
339
- /** @deprecated Use signInWithCode instead */
340
314
  signinWithCode: (code: string, state?: string) => Promise<AuthResult>;
341
- /** @deprecated Use getSignInUrl instead */
342
315
  getSignInLink: (redirectUri?: string) => Promise<string>;
343
316
  };
344
- declare function BasicProvider({ children, project_id: project_id_prop, schema, debug, storage, auth, dbMode }: BasicProviderProps): react_jsx_runtime.JSX.Element;
345
317
  declare function useBasic(): BasicContextType;
346
318
 
319
+ type AuthConfig = {
320
+ scopes?: string | string[];
321
+ /** @deprecated Use pds_url instead */
322
+ server_url?: string;
323
+ /** PDS URL for auth and data (default: https://pds.basic.id) */
324
+ pds_url?: string;
325
+ /** Admin server URL for connect reporting (default: https://api.basic.tech) */
326
+ admin_url?: string;
327
+ ws_url?: string;
328
+ };
329
+ type BasicProviderProps = {
330
+ children: react.ReactNode;
331
+ /**
332
+ * @deprecated Project ID is now extracted from schema.project_id.
333
+ * This prop is kept for backward compatibility but can be omitted.
334
+ */
335
+ project_id?: string;
336
+ /** The Basic schema object containing project_id and table definitions */
337
+ schema?: any;
338
+ debug?: boolean;
339
+ storage?: BasicStorage;
340
+ auth?: AuthConfig;
341
+ /**
342
+ * Database mode - determines which implementation is used
343
+ * - 'sync': Uses Dexie + WebSocket for local-first sync (default)
344
+ * - 'remote': Uses REST API calls directly to server
345
+ */
346
+ dbMode?: DBMode;
347
+ /** Show floating dev toolbar (localhost, NODE_ENV=development, or debug=true). */
348
+ devToolbar?: boolean;
349
+ };
350
+ declare function BasicProvider({ children, project_id: project_id_prop, schema, debug, storage, auth, dbMode, devToolbar, }: BasicProviderProps): react_jsx_runtime.JSX.Element;
351
+
352
+ type BasicDevToolbarProps = {
353
+ /** When false, toolbar does not render. Defaults to true when used standalone. */
354
+ enabled?: boolean;
355
+ /** Same as BasicProvider `debug` — when true, toolbar shows even off localhost. */
356
+ debug?: boolean;
357
+ };
358
+ /**
359
+ * Floating dev-only toolbar: auth, DB/sync, and schema status. Requires `BasicProvider` with `debug` or localhost / NODE_ENV=development for visibility unless `enabled` is forced.
360
+ */
361
+ declare function BasicDevToolbar({ enabled, debug }: BasicDevToolbarProps): react_jsx_runtime.JSX.Element | null;
362
+
347
363
  type ResolvedDid = {
348
364
  did: string;
349
365
  handle?: string;
@@ -371,4 +387,4 @@ declare function resolveDid(did: string): Promise<ResolvedDid>;
371
387
  */
372
388
  declare function resolveHandle(handle: string): Promise<ResolvedDid>;
373
389
 
374
- export { type AuthConfig, type AuthError, type AuthResult, type BasicContextType, type BasicDB, BasicProvider, type BasicProviderProps, type BasicStorage, type Collection, type DBMode, DBStatus, type GetTokenOptions$1 as GetTokenOptions, LocalStorageAdapter, NotAuthenticatedError, RemoteCollection, RemoteDB, type RemoteDBConfig, RemoteDBError, type ResolvedDid, STORAGE_KEYS, resolveDid, resolveDidWebUrl, resolveHandle, useBasic };
390
+ export { type AuthConfig, type AuthError, type AuthResult, type BasicContextType, type BasicDB, BasicDevToolbar, type BasicDevToolbarProps, BasicProvider, type BasicProviderProps, type BasicSchemaDevInfo, type BasicStorage, type Collection, type DBMode, DBStatus, type GetTokenOptions$1 as GetTokenOptions, LocalStorageAdapter, NotAuthenticatedError, RemoteCollection, RemoteDB, type RemoteDBConfig, RemoteDBError, type ResolvedDid, STORAGE_KEYS, resolveDid, resolveDidWebUrl, resolveHandle, useBasic };