@basictech/react 0.11.0 → 0.12.0-beta.1
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 +585 -0
- package/README.md +32 -25
- package/dist/index.d.mts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +95 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -109
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -18,22 +18,24 @@ its package metadata.
|
|
|
18
18
|
|
|
19
19
|
## Install
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
This README describes the `0.12.0-beta.1` release candidate. After publication, install
|
|
22
|
+
matching versions of the React SDK and the schema package you import directly:
|
|
22
23
|
|
|
23
24
|
```bash
|
|
24
|
-
npm install @basictech/react @basictech/schema
|
|
25
|
+
npm install @basictech/react@0.12.0-beta.1 @basictech/schema@0.12.0-beta.1
|
|
25
26
|
```
|
|
26
27
|
|
|
27
28
|
React is a peer dependency and must already be installed by your application.
|
|
28
29
|
|
|
29
30
|
## Auth update guide
|
|
30
31
|
|
|
31
|
-
Upgrade the packages you use together
|
|
32
|
+
Upgrade the packages you use together. npm's `latest` channel remains on `0.11.0` and
|
|
33
|
+
does not contain all of the API changes described here:
|
|
32
34
|
|
|
33
35
|
```bash
|
|
34
|
-
npm install @basictech/react@
|
|
36
|
+
npm install @basictech/react@0.12.0-beta.1 @basictech/schema@0.12.0-beta.1
|
|
35
37
|
# If you import core directly, update that dependency too:
|
|
36
|
-
npm install @basictech/core@
|
|
38
|
+
npm install @basictech/core@0.12.0-beta.1
|
|
37
39
|
```
|
|
38
40
|
|
|
39
41
|
Keep the public packages on matching versions. No browser storage reset or persisted-profile
|
|
@@ -42,9 +44,8 @@ that an older installed beta contains the update.
|
|
|
42
44
|
|
|
43
45
|
### Update auth checks and editing controls
|
|
44
46
|
|
|
45
|
-
- Replace `useAuth().status === 'reauth_required'` with `status === 'expired'`.
|
|
46
|
-
|
|
47
|
-
retains the legacy compatibility state.
|
|
47
|
+
- Replace `useAuth().status === 'reauth_required'` with `status === 'expired'`. The
|
|
48
|
+
`reauth_required` state no longer exists anywhere, including low-level `AuthSession`.
|
|
48
49
|
- Use `auth.canWrite` to disable mutation controls and `auth.readOnlyReason` for explanation.
|
|
49
50
|
It is account eligibility, not a guarantee of connectivity or permission to a particular source.
|
|
50
51
|
Catch imperative mutation errors too: auth can expire after the UI renders. Newly attempted
|
|
@@ -72,8 +73,10 @@ function AuthNotice() {
|
|
|
72
73
|
|
|
73
74
|
### Render per-account status
|
|
74
75
|
|
|
75
|
-
`useAccounts().accounts`
|
|
76
|
-
|
|
76
|
+
`useAccounts().accounts` returns `BasicAccount[]`, including anonymous and expired accounts, and
|
|
77
|
+
`useAccounts().activeAccount` is this tab's selection. The former `profiles`/`users`/`activeUser`
|
|
78
|
+
snapshot aliases and the `active` hook field are gone. Each account adds
|
|
79
|
+
`auth: { status, reason, checkedAt }` to the existing profile fields:
|
|
77
80
|
|
|
78
81
|
| Account status | Meaning |
|
|
79
82
|
| --- | --- |
|
|
@@ -90,6 +93,11 @@ is expired; otherwise an unverified remembered account is checking. The active a
|
|
|
90
93
|
has `auth.status: 'anon'`, while top-level `useAuth()` reports `status: 'signed_out'` and
|
|
91
94
|
`isAnonymous: true`. REST exposes one remembered account, not a multi-account registry.
|
|
92
95
|
|
|
96
|
+
`account.auth.reason` is exactly `'AUTH_EXPIRED' | null`. Raw active-account diagnostics such as
|
|
97
|
+
`invalid_grant` remain available as `useAuth().error`. Sign-in prerequisite errors returned by
|
|
98
|
+
server-backed hooks are stable within each hook but intentionally distinct objects from that raw
|
|
99
|
+
diagnostic; an expired hook can report `AUTH_EXPIRED` while the auth diagnostic is `invalid_grant`.
|
|
100
|
+
|
|
93
101
|
Ordinary network loss is not expiry, and anonymous editing still works. `goOnline()` cannot
|
|
94
102
|
bypass expired read-only enforcement. Reauthorization resumes retained queued work; already
|
|
95
103
|
accepted server requests cannot be undone by client cancellation. REST has no offline cache.
|
|
@@ -278,7 +286,7 @@ The package also exports the adapters for explicit composition: `BrowserKeyValue
|
|
|
278
286
|
`browserStorage`, `BrowserTokenStore`, `PersistenceStore`, `browserUploadTransport`,
|
|
279
287
|
`createBrowserMessageChannel`, `createBrowserAuthChannelFactory`, `browserNavigate`,
|
|
280
288
|
`browserCurrentUrl`, and `browserReplaceUrl`. Most applications only need `createBasic`, which
|
|
281
|
-
installs them.
|
|
289
|
+
installs them. `supportsAccessTokenAdoption` is internal and is not a public React export.
|
|
282
290
|
|
|
283
291
|
### Token storage
|
|
284
292
|
|
|
@@ -352,8 +360,8 @@ unknown table names and infer fields in reads, writes, and queries.
|
|
|
352
360
|
| `isAnonymous` | `boolean` | The active sync profile is anonymous and not signed in |
|
|
353
361
|
| `status` | `'bootstrapping' \| 'signed_out' \| 'authenticated' \| 'recovering' \| 'expired'` | Current public auth lifecycle |
|
|
354
362
|
| `canWrite` | `boolean` | Active-account write eligibility; source permissions still apply |
|
|
355
|
-
| `readOnlyReason` | `
|
|
356
|
-
| `error` | `BasicError \| null` |
|
|
363
|
+
| `readOnlyReason` | `ReadOnlyReason \| null` | `'AUTH_EXPIRED' \| 'AUTH_CHECKING' \| 'AUTHORIZATION_REQUIRED' \| 'CLIENT_NOT_STARTED'`; switch exhaustively for banners |
|
|
364
|
+
| `error` | `BasicError \| null` | Raw active auth diagnostic; same object while its code and expired state are unchanged |
|
|
357
365
|
| `user` | `AuthUser \| null` | OIDC user info (`sub`, `pds_url`, and optional `email`, `name`, `picture`, `handle`) |
|
|
358
366
|
| `did` | `string \| null` | Signed-in account DID |
|
|
359
367
|
| `handle` | `string \| null` | Resolved account handle |
|
|
@@ -399,10 +407,10 @@ replicas and returns to another local profile or a fresh anonymous one when enab
|
|
|
399
407
|
|
|
400
408
|
### `basic.useAccounts()`
|
|
401
409
|
|
|
402
|
-
`useAccounts()` returns `{ accounts,
|
|
410
|
+
`useAccounts()` returns `{ accounts, activeAccount, switchAccount, addAccount, removeAccount }`:
|
|
403
411
|
|
|
404
412
|
- `accounts: BasicAccount[]` lists local profiles with per-account auth summaries.
|
|
405
|
-
- `
|
|
413
|
+
- `activeAccount: BasicAccount | null` is this tab's selected profile and auth summary.
|
|
406
414
|
- `switchAccount(id): Promise<void>` changes the active profile in this tab.
|
|
407
415
|
- `addAccount(): Promise<BasicProfile>` creates and activates a new anonymous profile from which to
|
|
408
416
|
start another sign-in.
|
|
@@ -418,12 +426,12 @@ replicas and returns to another local profile or a fresh anonymous one when enab
|
|
|
418
426
|
import { basic } from './basic'
|
|
419
427
|
|
|
420
428
|
export function AccountSwitcher() {
|
|
421
|
-
const { accounts,
|
|
429
|
+
const { accounts, activeAccount, switchAccount, addAccount, removeAccount } = basic.useAccounts()
|
|
422
430
|
|
|
423
431
|
return (
|
|
424
432
|
<section>
|
|
425
433
|
<select
|
|
426
|
-
value={
|
|
434
|
+
value={activeAccount?.id ?? ''}
|
|
427
435
|
onChange={(event) => void switchAccount(event.currentTarget.value)}
|
|
428
436
|
>
|
|
429
437
|
{accounts.map((account) => (
|
|
@@ -433,7 +441,7 @@ export function AccountSwitcher() {
|
|
|
433
441
|
))}
|
|
434
442
|
</select>
|
|
435
443
|
<button onClick={() => void addAccount()}>Add account</button>
|
|
436
|
-
{
|
|
444
|
+
{activeAccount && <button onClick={() => void removeAccount(activeAccount.id)}>Remove local profile</button>}
|
|
437
445
|
</section>
|
|
438
446
|
)
|
|
439
447
|
}
|
|
@@ -821,9 +829,8 @@ Shares v2 is capability-gated and requires sign-in. `useOutgoingShares()` return
|
|
|
821
829
|
```text
|
|
822
830
|
{
|
|
823
831
|
data: OutgoingShareInfo[]
|
|
824
|
-
outgoingShares: OutgoingShareInfo[] // alias of data
|
|
825
832
|
isLoading: boolean
|
|
826
|
-
error: BasicError | null
|
|
833
|
+
error: BasicError | null // load failure, or AUTHORIZATION_REQUIRED / AUTH_EXPIRED while not signed in
|
|
827
834
|
refresh(): void
|
|
828
835
|
create(input: CreateOutgoingShareInput): Promise<OutgoingShareInfo>
|
|
829
836
|
get(id: string): Promise<OutgoingShareInfo>
|
|
@@ -869,7 +876,7 @@ export function OutgoingShares() {
|
|
|
869
876
|
<button onClick={() => location.assign(shares.manageUrl())}>Manage in Basic ID</button>
|
|
870
877
|
{shares.error && <p>{shares.error.code}</p>}
|
|
871
878
|
<ul>
|
|
872
|
-
{shares.
|
|
879
|
+
{shares.data.map((share) => (
|
|
873
880
|
<li key={share.id}>
|
|
874
881
|
{share.recipientDid}: {share.effectiveState}
|
|
875
882
|
{share.state === 'pending' && (
|
|
@@ -907,9 +914,8 @@ management belong there. `client.shares.leave()` is intentionally owner-only and
|
|
|
907
914
|
```text
|
|
908
915
|
{
|
|
909
916
|
data: MountInfo[]
|
|
910
|
-
mounts: MountInfo[] // alias of data
|
|
911
917
|
isLoading: boolean
|
|
912
|
-
error: BasicError | null
|
|
918
|
+
error: BasicError | null // load failure, or AUTHORIZATION_REQUIRED / AUTH_EXPIRED while not signed in
|
|
913
919
|
refresh(): void
|
|
914
920
|
open(mountId: string): Promise<MountHandle<S>>
|
|
915
921
|
manageUrl(): string
|
|
@@ -955,7 +961,7 @@ export function IncomingMounts() {
|
|
|
955
961
|
<section>
|
|
956
962
|
<button onClick={() => location.assign(mounts.manageUrl())}>Manage mounts</button>
|
|
957
963
|
<ul>
|
|
958
|
-
{mounts.
|
|
964
|
+
{mounts.data.map((mount) => (
|
|
959
965
|
<li key={mount.id}>
|
|
960
966
|
{mount.role} from {mount.originOwnerDid}
|
|
961
967
|
<button onClick={() => void open(mount.id)}>Open</button>
|
|
@@ -1090,7 +1096,8 @@ The unbound exports mirror the bound hooks:
|
|
|
1090
1096
|
| `useMounts()`, `useOutgoingShares()` | Same share results |
|
|
1091
1097
|
|
|
1092
1098
|
Every unbound hook must run below `BasicProvider`; otherwise it throws `Basic hooks must be used
|
|
1093
|
-
within a <BasicProvider>`.
|
|
1099
|
+
within a <BasicProvider>`. Bound hooks likewise throw outside their own `basic.Provider`, because
|
|
1100
|
+
the Provider is what starts and stops the client.
|
|
1094
1101
|
|
|
1095
1102
|
## Error handling
|
|
1096
1103
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { BasicSchema, BasicConfig, BasicClient, BasicAccount, BasicProfile, AuthStatus, BasicError, AuthUser, BasicSyncStatus, BasicRejection, BasicConflict, SourceRef, SchemaStatus, BasicDb, Repo, FileRecord, MountFileInfo, StorageInfo, FileListQuery, MountInfo, MountHandle, OutgoingShareInfo, CreateOutgoingShareInput, MountsQuery, JsonObject, BasicRecord, Query, MountViewerFiles, OwnerFiles, TableNames, Collection, InferValue, KeyValueStorage, TokenStore, AuthMessageChannel, ReplicaStoreFactory, StoragePartition, ReplicaStore, UploadTransportAdapter } from '@basictech/core';
|
|
3
|
+
import { BasicSchema, BasicConfig, BasicClient, BasicAccount, BasicProfile, ReadOnlyReason, AuthStatus, BasicError, AuthUser, BasicSyncStatus, BasicRejection, BasicConflict, SourceRef, SchemaStatus, BasicDb, Repo, FileRecord, MountFileInfo, StorageInfo, FileListQuery, MountInfo, MountHandle, OutgoingShareInfo, CreateOutgoingShareInput, MountsQuery, JsonObject, BasicRecord, Query, MountViewerFiles, OwnerFiles, TableNames, Collection, InferValue, KeyValueStorage, TokenStore, AuthChannelContext, AuthMessageChannel, ReplicaStoreFactory, StoragePartition, ReplicaStore, UploadTransportAdapter } from '@basictech/core';
|
|
4
4
|
|
|
5
5
|
type BrowserBasicConfig<S extends BasicSchema = BasicSchema> = BasicConfig<S>;
|
|
6
6
|
/** Create a core client with the complete browser adapter set installed. */
|
|
@@ -8,7 +8,7 @@ declare function createBasicClient<S extends BasicSchema>(config: BrowserBasicCo
|
|
|
8
8
|
|
|
9
9
|
interface UseAccountsResult {
|
|
10
10
|
accounts: BasicAccount[];
|
|
11
|
-
|
|
11
|
+
activeAccount: BasicAccount | null;
|
|
12
12
|
switchAccount(id: string): Promise<void>;
|
|
13
13
|
addAccount(): Promise<BasicProfile>;
|
|
14
14
|
removeAccount(id: string): Promise<void>;
|
|
@@ -20,8 +20,9 @@ interface UseAuthResult {
|
|
|
20
20
|
isSignedIn: boolean;
|
|
21
21
|
isAnonymous: boolean;
|
|
22
22
|
canWrite: boolean;
|
|
23
|
-
readOnlyReason:
|
|
23
|
+
readOnlyReason: ReadOnlyReason | null;
|
|
24
24
|
status: AuthStatus;
|
|
25
|
+
/** Raw auth diagnostic; stable identity while its code and expired state are unchanged. */
|
|
25
26
|
error: BasicError | null;
|
|
26
27
|
user: AuthUser | null;
|
|
27
28
|
did: string | null;
|
|
@@ -64,6 +65,7 @@ declare function useFiles(query?: FileListQuery, options?: {
|
|
|
64
65
|
interface UseStorageInfoResult {
|
|
65
66
|
data: StorageInfo | null;
|
|
66
67
|
isLoading: boolean;
|
|
68
|
+
/** Load failure, or the sign-in requirement while no account is signed in. */
|
|
67
69
|
error: BasicError | null;
|
|
68
70
|
refresh(): void;
|
|
69
71
|
}
|
|
@@ -71,8 +73,8 @@ declare function useStorageInfo(): UseStorageInfoResult;
|
|
|
71
73
|
|
|
72
74
|
interface UseMountsResult<S extends BasicSchema = BasicSchema> {
|
|
73
75
|
data: MountInfo[];
|
|
74
|
-
mounts: MountInfo[];
|
|
75
76
|
isLoading: boolean;
|
|
77
|
+
/** Load failure, or the sign-in requirement while no account is signed in. */
|
|
76
78
|
error: BasicError | null;
|
|
77
79
|
refresh(): void;
|
|
78
80
|
open(mountId: string): Promise<MountHandle<S>>;
|
|
@@ -81,8 +83,8 @@ interface UseMountsResult<S extends BasicSchema = BasicSchema> {
|
|
|
81
83
|
declare function useMounts(query?: MountsQuery): UseMountsResult;
|
|
82
84
|
interface UseOutgoingSharesResult {
|
|
83
85
|
data: OutgoingShareInfo[];
|
|
84
|
-
outgoingShares: OutgoingShareInfo[];
|
|
85
86
|
isLoading: boolean;
|
|
87
|
+
/** Load failure, or the sign-in requirement while no account is signed in. */
|
|
86
88
|
error: BasicError | null;
|
|
87
89
|
refresh(): void;
|
|
88
90
|
create(input: CreateOutgoingShareInput): Promise<OutgoingShareInfo>;
|
|
@@ -211,6 +213,8 @@ declare class BrowserTokenStore implements TokenStore {
|
|
|
211
213
|
private waitForAccessToken;
|
|
212
214
|
}
|
|
213
215
|
|
|
216
|
+
/** The subset of BrowserTokenStore the auth channel needs; any token store providing it works. */
|
|
217
|
+
type AccessTokenAdopter = Pick<BrowserTokenStore, 'accessToken' | 'adoptAccessToken'>;
|
|
214
218
|
interface BrowserMessageChannel {
|
|
215
219
|
postMessage(message: unknown): void;
|
|
216
220
|
close(): void;
|
|
@@ -223,9 +227,11 @@ declare function createBrowserMessageChannel(name: string): BrowserMessageChanne
|
|
|
223
227
|
/**
|
|
224
228
|
* Access tokens may cross tabs transiently but are never written to browser
|
|
225
229
|
* storage. The receiving adapter adopts the token before core handles the
|
|
226
|
-
* ordinary token-rotation notification.
|
|
230
|
+
* ordinary token-rotation notification. Core supplies the token key for the
|
|
231
|
+
* profile's auth channel; channels without a context (the accounts channel)
|
|
232
|
+
* are plain BroadcastChannels.
|
|
227
233
|
*/
|
|
228
|
-
declare function createBrowserAuthChannelFactory(
|
|
234
|
+
declare function createBrowserAuthChannelFactory(tokenStore: AccessTokenAdopter): (name: string, context?: AuthChannelContext) => AuthMessageChannel;
|
|
229
235
|
|
|
230
236
|
declare function browserNavigate(url: string): void;
|
|
231
237
|
declare function browserCurrentUrl(): string;
|
|
@@ -269,4 +275,4 @@ declare class PersistenceStore implements ReplicaStoreFactory {
|
|
|
269
275
|
/** Browser multipart transport with upload progress, adapted from the Drive UI. */
|
|
270
276
|
declare const browserUploadTransport: UploadTransportAdapter;
|
|
271
277
|
|
|
272
|
-
export { BasicProvider, type BasicProviderProps, type BoundBasicProviderProps, type BrowserBasicConfig, BrowserKeyValueStorage, type BrowserLockManager, type BrowserMessageChannel, BrowserTokenStore, type CreateBasicConfig, type CreatedBasic, PersistenceStore, type PersistenceStoreOptions, type UseAccountsResult, type UseAuthResult, type UseBasicResult, type UseFilesResult, type UseMountsResult, type UseOutgoingSharesResult, type UseQueryResult, type UseReposResult, type UseStorageInfoResult, type UseSyncStatusResult, browserCurrentUrl, browserNavigate, browserReplaceUrl, browserStorage, browserUploadTransport, createBasic, createBasicClient, createBrowserAuthChannelFactory, createBrowserMessageChannel, useAccounts, useAuth, useBasic, useCollection, useDb, useFiles, useMounts, useOutgoingShares, useQuery, useRepos, useSchemaStatus, useStorageInfo, useSyncStatus };
|
|
278
|
+
export { type AccessTokenAdopter, BasicProvider, type BasicProviderProps, type BoundBasicProviderProps, type BrowserBasicConfig, BrowserKeyValueStorage, type BrowserLockManager, type BrowserMessageChannel, BrowserTokenStore, type CreateBasicConfig, type CreatedBasic, PersistenceStore, type PersistenceStoreOptions, type UseAccountsResult, type UseAuthResult, type UseBasicResult, type UseFilesResult, type UseMountsResult, type UseOutgoingSharesResult, type UseQueryResult, type UseReposResult, type UseStorageInfoResult, type UseSyncStatusResult, browserCurrentUrl, browserNavigate, browserReplaceUrl, browserStorage, browserUploadTransport, createBasic, createBasicClient, createBrowserAuthChannelFactory, createBrowserMessageChannel, useAccounts, useAuth, useBasic, useCollection, useDb, useFiles, useMounts, useOutgoingShares, useQuery, useRepos, useSchemaStatus, useStorageInfo, useSyncStatus };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { BasicSchema, BasicConfig, BasicClient, BasicAccount, BasicProfile, AuthStatus, BasicError, AuthUser, BasicSyncStatus, BasicRejection, BasicConflict, SourceRef, SchemaStatus, BasicDb, Repo, FileRecord, MountFileInfo, StorageInfo, FileListQuery, MountInfo, MountHandle, OutgoingShareInfo, CreateOutgoingShareInput, MountsQuery, JsonObject, BasicRecord, Query, MountViewerFiles, OwnerFiles, TableNames, Collection, InferValue, KeyValueStorage, TokenStore, AuthMessageChannel, ReplicaStoreFactory, StoragePartition, ReplicaStore, UploadTransportAdapter } from '@basictech/core';
|
|
3
|
+
import { BasicSchema, BasicConfig, BasicClient, BasicAccount, BasicProfile, ReadOnlyReason, AuthStatus, BasicError, AuthUser, BasicSyncStatus, BasicRejection, BasicConflict, SourceRef, SchemaStatus, BasicDb, Repo, FileRecord, MountFileInfo, StorageInfo, FileListQuery, MountInfo, MountHandle, OutgoingShareInfo, CreateOutgoingShareInput, MountsQuery, JsonObject, BasicRecord, Query, MountViewerFiles, OwnerFiles, TableNames, Collection, InferValue, KeyValueStorage, TokenStore, AuthChannelContext, AuthMessageChannel, ReplicaStoreFactory, StoragePartition, ReplicaStore, UploadTransportAdapter } from '@basictech/core';
|
|
4
4
|
|
|
5
5
|
type BrowserBasicConfig<S extends BasicSchema = BasicSchema> = BasicConfig<S>;
|
|
6
6
|
/** Create a core client with the complete browser adapter set installed. */
|
|
@@ -8,7 +8,7 @@ declare function createBasicClient<S extends BasicSchema>(config: BrowserBasicCo
|
|
|
8
8
|
|
|
9
9
|
interface UseAccountsResult {
|
|
10
10
|
accounts: BasicAccount[];
|
|
11
|
-
|
|
11
|
+
activeAccount: BasicAccount | null;
|
|
12
12
|
switchAccount(id: string): Promise<void>;
|
|
13
13
|
addAccount(): Promise<BasicProfile>;
|
|
14
14
|
removeAccount(id: string): Promise<void>;
|
|
@@ -20,8 +20,9 @@ interface UseAuthResult {
|
|
|
20
20
|
isSignedIn: boolean;
|
|
21
21
|
isAnonymous: boolean;
|
|
22
22
|
canWrite: boolean;
|
|
23
|
-
readOnlyReason:
|
|
23
|
+
readOnlyReason: ReadOnlyReason | null;
|
|
24
24
|
status: AuthStatus;
|
|
25
|
+
/** Raw auth diagnostic; stable identity while its code and expired state are unchanged. */
|
|
25
26
|
error: BasicError | null;
|
|
26
27
|
user: AuthUser | null;
|
|
27
28
|
did: string | null;
|
|
@@ -64,6 +65,7 @@ declare function useFiles(query?: FileListQuery, options?: {
|
|
|
64
65
|
interface UseStorageInfoResult {
|
|
65
66
|
data: StorageInfo | null;
|
|
66
67
|
isLoading: boolean;
|
|
68
|
+
/** Load failure, or the sign-in requirement while no account is signed in. */
|
|
67
69
|
error: BasicError | null;
|
|
68
70
|
refresh(): void;
|
|
69
71
|
}
|
|
@@ -71,8 +73,8 @@ declare function useStorageInfo(): UseStorageInfoResult;
|
|
|
71
73
|
|
|
72
74
|
interface UseMountsResult<S extends BasicSchema = BasicSchema> {
|
|
73
75
|
data: MountInfo[];
|
|
74
|
-
mounts: MountInfo[];
|
|
75
76
|
isLoading: boolean;
|
|
77
|
+
/** Load failure, or the sign-in requirement while no account is signed in. */
|
|
76
78
|
error: BasicError | null;
|
|
77
79
|
refresh(): void;
|
|
78
80
|
open(mountId: string): Promise<MountHandle<S>>;
|
|
@@ -81,8 +83,8 @@ interface UseMountsResult<S extends BasicSchema = BasicSchema> {
|
|
|
81
83
|
declare function useMounts(query?: MountsQuery): UseMountsResult;
|
|
82
84
|
interface UseOutgoingSharesResult {
|
|
83
85
|
data: OutgoingShareInfo[];
|
|
84
|
-
outgoingShares: OutgoingShareInfo[];
|
|
85
86
|
isLoading: boolean;
|
|
87
|
+
/** Load failure, or the sign-in requirement while no account is signed in. */
|
|
86
88
|
error: BasicError | null;
|
|
87
89
|
refresh(): void;
|
|
88
90
|
create(input: CreateOutgoingShareInput): Promise<OutgoingShareInfo>;
|
|
@@ -211,6 +213,8 @@ declare class BrowserTokenStore implements TokenStore {
|
|
|
211
213
|
private waitForAccessToken;
|
|
212
214
|
}
|
|
213
215
|
|
|
216
|
+
/** The subset of BrowserTokenStore the auth channel needs; any token store providing it works. */
|
|
217
|
+
type AccessTokenAdopter = Pick<BrowserTokenStore, 'accessToken' | 'adoptAccessToken'>;
|
|
214
218
|
interface BrowserMessageChannel {
|
|
215
219
|
postMessage(message: unknown): void;
|
|
216
220
|
close(): void;
|
|
@@ -223,9 +227,11 @@ declare function createBrowserMessageChannel(name: string): BrowserMessageChanne
|
|
|
223
227
|
/**
|
|
224
228
|
* Access tokens may cross tabs transiently but are never written to browser
|
|
225
229
|
* storage. The receiving adapter adopts the token before core handles the
|
|
226
|
-
* ordinary token-rotation notification.
|
|
230
|
+
* ordinary token-rotation notification. Core supplies the token key for the
|
|
231
|
+
* profile's auth channel; channels without a context (the accounts channel)
|
|
232
|
+
* are plain BroadcastChannels.
|
|
227
233
|
*/
|
|
228
|
-
declare function createBrowserAuthChannelFactory(
|
|
234
|
+
declare function createBrowserAuthChannelFactory(tokenStore: AccessTokenAdopter): (name: string, context?: AuthChannelContext) => AuthMessageChannel;
|
|
229
235
|
|
|
230
236
|
declare function browserNavigate(url: string): void;
|
|
231
237
|
declare function browserCurrentUrl(): string;
|
|
@@ -269,4 +275,4 @@ declare class PersistenceStore implements ReplicaStoreFactory {
|
|
|
269
275
|
/** Browser multipart transport with upload progress, adapted from the Drive UI. */
|
|
270
276
|
declare const browserUploadTransport: UploadTransportAdapter;
|
|
271
277
|
|
|
272
|
-
export { BasicProvider, type BasicProviderProps, type BoundBasicProviderProps, type BrowserBasicConfig, BrowserKeyValueStorage, type BrowserLockManager, type BrowserMessageChannel, BrowserTokenStore, type CreateBasicConfig, type CreatedBasic, PersistenceStore, type PersistenceStoreOptions, type UseAccountsResult, type UseAuthResult, type UseBasicResult, type UseFilesResult, type UseMountsResult, type UseOutgoingSharesResult, type UseQueryResult, type UseReposResult, type UseStorageInfoResult, type UseSyncStatusResult, browserCurrentUrl, browserNavigate, browserReplaceUrl, browserStorage, browserUploadTransport, createBasic, createBasicClient, createBrowserAuthChannelFactory, createBrowserMessageChannel, useAccounts, useAuth, useBasic, useCollection, useDb, useFiles, useMounts, useOutgoingShares, useQuery, useRepos, useSchemaStatus, useStorageInfo, useSyncStatus };
|
|
278
|
+
export { type AccessTokenAdopter, BasicProvider, type BasicProviderProps, type BoundBasicProviderProps, type BrowserBasicConfig, BrowserKeyValueStorage, type BrowserLockManager, type BrowserMessageChannel, BrowserTokenStore, type CreateBasicConfig, type CreatedBasic, PersistenceStore, type PersistenceStoreOptions, type UseAccountsResult, type UseAuthResult, type UseBasicResult, type UseFilesResult, type UseMountsResult, type UseOutgoingSharesResult, type UseQueryResult, type UseReposResult, type UseStorageInfoResult, type UseSyncStatusResult, browserCurrentUrl, browserNavigate, browserReplaceUrl, browserStorage, browserUploadTransport, createBasic, createBasicClient, createBrowserAuthChannelFactory, createBrowserMessageChannel, useAccounts, useAuth, useBasic, useCollection, useDb, useFiles, useMounts, useOutgoingShares, useQuery, useRepos, useSchemaStatus, useStorageInfo, useSyncStatus };
|