@tinycloud/web-sdk 3.17.0 → 3.19.0

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.
@@ -13,7 +13,7 @@ import { TinyCloudNode, TinyCloudNodeConfig, type OpenKeyAuthorizeTinyCloud, typ
13
13
  import type { NodeSignOutStatus } from "@tinycloud/node-sdk";
14
14
  import { type LocalCopyPurgeFailedEvent } from "./replica-wiring";
15
15
  import { IKVService, ISQLService, IDuckDbService, IDataVaultService, ISecretsService, ISpaceService, ISpace, ISharingService, ICapabilityKeyRegistry, IHooksService, IEncryptionService, DelegationManager, Delegation, DelegationRevocationReceipt, Result, DelegationError, ClientSession, type ClientSignInResult, Extension, type TelemetryConfig, type RetryPolicy, ISpaceCreationHandler, type Manifest, type ComposedManifestRequest, type AccountService, type ResolvedDelegate, type PermissionEntry, type NetworkDescriptor, type CreateOwnerDelegationParams, type OwnerDelegationReceipt, type LocalNodeIdentityStore, type OnNodeNotFound, type RegistrySequenceStore, SignInOptions, type RegistryCacheStore, type StorageFullEvent, type IStorageService } from "@tinycloud/sdk-core";
16
- import type { RegistryPublishOutcome } from "../registry-publish";
16
+ import type { OwnerRegistryRecordState, RegistryPublishOutcome, RegistryRepairOutcome } from "../registry-publish";
17
17
  import { type RequestPermissionsOptions } from "./requestPermissionsCore";
18
18
  import { type OpenKeySignPresentation } from "./openKeySignPresentation";
19
19
  import { type BrowserProvider, type BrowserWalletProvider } from "../adapters/browserProvider";
@@ -181,8 +181,10 @@ export interface Config extends ClientConfig {
181
181
  /** Floating button, panel, and toasts. `false` creates no host, button, toasts, or listeners. See {@link UiConfig}. */
182
182
  ui?: UiConfig | false;
183
183
  /**
184
- * Notified on every error from {@link TinyCloudWeb.ensureOwnerRegistryRecord} (verdict
185
- * lookup, signer resolution, registry 4xx/5xx). Hosts can fold it into their own
184
+ * Notified on every error from {@link TinyCloudWeb.ensureOwnerRegistryRecord},
185
+ * {@link TinyCloudWeb.inspectOwnerRegistryRecord} and
186
+ * {@link TinyCloudWeb.repairOwnerRegistryRecord} (verdict lookup, signer resolution,
187
+ * registry 4xx/5xx). Hosts can fold it into their own
186
188
  * telemetry. The method's return value carries the outcome.
187
189
  */
188
190
  onRegistryPublishError?: (error: unknown) => void;
@@ -197,6 +199,20 @@ export interface RequestPermissionsResult {
197
199
  session?: ClientSession;
198
200
  delegations?: readonly PortableDelegation[];
199
201
  }
202
+ /**
203
+ * `account.setup.pending`: the owner signed in, but has no account record yet (TC-4344). Their own space is hosted, so
204
+ * nothing is blocked; OpenKey can set the account up in one step.
205
+ */
206
+ export interface AccountSetupPendingEvent {
207
+ /** The signed-in owner's address. */
208
+ readonly address: string;
209
+ /**
210
+ * Opens OpenKey's account setup for the signing key. Call it from a click: it opens a window. Resolves true once
211
+ * OpenKey reports the account set up; false when the owner closed it, or the owner signed out or changed since.
212
+ * Never rejects. The current session keeps working either way.
213
+ */
214
+ finishSetup(): Promise<boolean>;
215
+ }
200
216
  export type SessionRestoreStatus = "idle" | "disabled" | "restoring" | "restored" | "missing" | "expired" | "corrupt" | "storage-unavailable" | "restore-failed" | "stale" | "logging-in";
201
217
  export interface SessionRestoreResult {
202
218
  status: Exclude<SessionRestoreStatus, "idle" | "restoring" | "logging-in">;
@@ -269,6 +285,9 @@ export declare class TinyCloudWeb {
269
285
  private _shareReceiverService?;
270
286
  private readonly storageFullHandlers;
271
287
  private readonly purgeFailedHandlers;
288
+ private readonly accountSetupHandlers;
289
+ /** The setup the account-setup toast's button runs: the latest sign-in's offer, which refuses once that session ends. */
290
+ private latestAccountSetupOffer?;
272
291
  /** Promise that resolves when WASM + node are ready */
273
292
  private _initPromise;
274
293
  /** User config */
@@ -345,6 +364,13 @@ export declare class TinyCloudWeb {
345
364
  * retries now. Safe to call before initialization finishes. Returns the unsubscribe function.
346
365
  */
347
366
  on(event: "replica.purge.failed", handler: (event: LocalCopyPurgeFailedEvent) => void): () => void;
367
+ /**
368
+ * Subscribe to `account.setup.pending`. It fires at the end of a `signIn()` that succeeded for an owner with no
369
+ * account record whose OpenKey key can be set up from here, so the app can offer "finish setup" in its own UI; call
370
+ * the event's `finishSetup` from the owner's click. While any handler is subscribed, the SDK shows no setup toast
371
+ * of its own. Safe to call before initialization finishes. Returns the unsubscribe function.
372
+ */
373
+ on(event: "account.setup.pending", handler: (event: AccountSetupPendingEvent) => void): () => void;
348
374
  /** The owner's TinyCloud storage; `storage.status()` reads usage and plan from the node. */
349
375
  get storage(): IStorageService;
350
376
  /** Browser UI API: `open`, `close`, `toggle`, `isOpen`, and `available`. Inert when `ui: false` or the page cannot render UI. */
@@ -469,6 +495,12 @@ export declare class TinyCloudWeb {
469
495
  * when the owner cancelled or setup did not finish, so the caller keeps its `AccountSetupRequiredError`.
470
496
  */
471
497
  private setUpOpenKeyAccount;
498
+ /**
499
+ * After a sign-in that succeeded for an owner with no account record (the hosted-owner proof, TC-4344): the
500
+ * `account.setup.pending` event, or with no handler subscribed, a toast whose button opens OpenKey's setup. It never
501
+ * opens anything by itself and never blocks the sign-in. Only a managed OpenKey key of the signed-in owner is offered.
502
+ */
503
+ private offerAccountSetup;
472
504
  /**
473
505
  * The sign-in again once OpenKey set the account up; its preparation reads the registry afresh. The owner's clicks
474
506
  * went to OpenKey's window, so this one may no longer open a popup: a blocked popup asks in OpenKey's frame instead.
@@ -497,6 +529,39 @@ export declare class TinyCloudWeb {
497
529
  * This method never throws.
498
530
  */
499
531
  ensureOwnerRegistryRecord(): Promise<RegistryPublishOutcome>;
532
+ /**
533
+ * Read the owner's verified registry record and say whether it routes every account space.
534
+ * Read-only: never signs or writes.
535
+ *
536
+ * Returns `"complete"` (all six account spaces listed and an encryption node named),
537
+ * `"incomplete"` (an account space is missing or the encryption node is null; offer
538
+ * {@link TinyCloudWeb.repairOwnerRegistryRecord}), `"absent"` (no record; see
539
+ * {@link TinyCloudWeb.ensureOwnerRegistryRecord}) or `"unavailable"` (registry unreachable,
540
+ * not signed in, or not a `did:pkh` owner). This method never throws.
541
+ */
542
+ inspectOwnerRegistryRecord(): Promise<OwnerRegistryRecordState>;
543
+ /**
544
+ * Complete an owner's existing registry record that is missing account spaces or the
545
+ * encryption node. The owner's wallet or OpenKey signature prompt is the consent: one
546
+ * signature, only when something is missing.
547
+ *
548
+ * The repair only adds: each missing account space, read-write on the record's node, and
549
+ * that node as the encryption node when there is none. Existing entries are never removed or
550
+ * changed, and the signature is not requested if the registry's record changed since it was
551
+ * read. Only TinyCloud One and Home repair; elsewhere (or when OpenKey refuses) an
552
+ * incomplete record gets `"needs-one"`.
553
+ *
554
+ * Returns `"repaired"`, `"already-complete"`, `"absent"` (use
555
+ * {@link TinyCloudWeb.ensureOwnerRegistryRecord}), `"needs-one"` or `"unavailable"`.
556
+ * This method never throws.
557
+ */
558
+ repairOwnerRegistryRecord(): Promise<RegistryRepairOutcome>;
559
+ /**
560
+ * Shared by the owner registry record methods: the owner's options for the registry-publish
561
+ * module, or `signedOut` without a `did:pkh` session. Errors are reported through
562
+ * `onRegistryPublishError` and return `"unavailable"`.
563
+ */
564
+ private withOwnerRegistry;
500
565
  /**
501
566
  * Sign out: end the session on this instance and clear the persisted
502
567
  * session. Afterwards accessors return `undefined` and service calls remain
@@ -43,11 +43,11 @@ export declare const SpaceCreationResultSchema: z.ZodObject<{
43
43
  /** Whether the modal was dismissed without creating */
44
44
  dismissed: z.ZodBoolean;
45
45
  }, "strip", z.ZodTypeAny, {
46
- dismissed?: boolean;
47
46
  success?: boolean;
48
- }, {
49
47
  dismissed?: boolean;
48
+ }, {
50
49
  success?: boolean;
50
+ dismissed?: boolean;
51
51
  }>;
52
52
  export type SpaceCreationResult = z.infer<typeof SpaceCreationResultSchema>;
53
53
  /**