@tinycloud/web-sdk 3.18.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;
@@ -527,6 +529,39 @@ export declare class TinyCloudWeb {
527
529
  * This method never throws.
528
530
  */
529
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;
530
565
  /**
531
566
  * Sign out: end the session on this instance and clear the persisted
532
567
  * session. Afterwards accessors return `undefined` and service calls remain
@@ -58,6 +58,10 @@ export interface EnsureOwnerRegistryRecordOptions {
58
58
  * `"needs-one"` before anything is signed.
59
59
  * 3. The record's node identity comes only from `node.activeNodeIdentity()`, never from
60
60
  * caller input: a signed record pointing at the wrong node is the real attacker gain.
61
+ * The record lists every account space (`BOOTSTRAP_SPACE_NAMES`, as OpenKey's account
62
+ * setup does) plus `node.spaceId`, all on that node, and names it as the encryption
63
+ * node. The router treats a record as complete: a space it leaves out, or a null
64
+ * encryption node, stops routing for that owner.
61
65
  * 4. An existing record is never overwritten or merged. `publishLocationRecordV2`'s
62
66
  * pre-sign re-read refuses the publish if a record has appeared since the verdict.
63
67
  * 5. `assertCurrent` runs after each await here and last in `onPrepared`, before the
@@ -68,5 +72,44 @@ export interface EnsureOwnerRegistryRecordOptions {
68
72
  * swallowed and funnelled through `onError`; this never throws.
69
73
  */
70
74
  export declare function ensureOwnerRegistryRecord(options: EnsureOwnerRegistryRecordOptions): Promise<RegistryPublishOutcome>;
75
+ /** What the owner's verified v2 record holds. Returned by `tcw.inspectOwnerRegistryRecord`. */
76
+ export type OwnerRegistryRecordState = "complete" | "incomplete" | "absent" | "unavailable";
77
+ /** Outcome of `tcw.repairOwnerRegistryRecord`. */
78
+ export type RegistryRepairOutcome = "repaired" | "already-complete" | "absent" | "needs-one" | "unavailable";
79
+ export type InspectOwnerRegistryRecordOptions = Pick<EnsureOwnerRegistryRecordOptions, "subject" | "registryUrl" | "registryChainId" | "registrySequenceStore" | "registryCacheStore" | "registryVerdictCache" | "onError" | "assertCurrent" | "fetch">;
80
+ type RecordNode = {
81
+ did: string;
82
+ url: string;
83
+ };
84
+ /**
85
+ * Read-only: the state of the owner's verified v2 record. Never signs or writes. Errors are
86
+ * reported through `onError` and return `"unavailable"`; this never throws.
87
+ */
88
+ export declare function inspectOwnerRegistryRecord(options: InspectOwnerRegistryRecordOptions): Promise<OwnerRegistryRecordState>;
89
+ /**
90
+ * True when `proposed` is exactly `current` plus the planned additions: every node, space
91
+ * membership and the encryption node of `current` unchanged; the only new things are `node`
92
+ * (if the record did not name it), the `added` spaces read-write on `node` only, and the
93
+ * encryption node when `current` had none; the sequence is the next one.
94
+ */
95
+ export declare function isRepairSuperset(proposed: Readonly<LocationRecordV2Payload>, current: Readonly<LocationRecordV2Payload>, node: RecordNode, added: readonly string[]): boolean;
96
+ /**
97
+ * Called by `tcw.repairOwnerRegistryRecord`. Completes an existing record; never creates one.
98
+ *
99
+ * 1. The record is inspected first: `"absent"`, `"already-complete"` or `"unavailable"` return
100
+ * without a signature.
101
+ * 2. An origin outside `REGISTRY_PUBLISH_ORIGINS` returns `"needs-one"` before anything is
102
+ * signed; OpenKey's sign refusal also maps to `"needs-one"`.
103
+ * 3. The node added to is the record's only node, or the active node when the record already
104
+ * names it with the same URL. Anything else is ambiguous: `"unavailable"`.
105
+ * 4. Only additions: each missing account space read-write on that node, and that node as the
106
+ * encryption node when the record has none. Existing memberships, nodes and the encryption
107
+ * node are never removed or changed.
108
+ * 5. `onPrepared` checks that the registry's live record is the one inspected and that the
109
+ * merged record is exactly it plus the planned additions with the next sequence; otherwise
110
+ * nothing is signed and the call returns `"unavailable"`.
111
+ * 6. `assertCurrent` guards as in `ensureOwnerRegistryRecord`. Never throws.
112
+ */
113
+ export declare function repairOwnerRegistryRecord(options: EnsureOwnerRegistryRecordOptions): Promise<RegistryRepairOutcome>;
71
114
  export type { LocationRecordV2, LocationRecordV2Payload };
72
115
  //# sourceMappingURL=registry-publish.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/web-sdk",
3
- "version": "3.18.0",
3
+ "version": "3.19.0",
4
4
  "description": "A set of tools and utilities to help you build your app with TinyCloud.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -68,11 +68,11 @@
68
68
  "@multiformats/multiaddr": "^13.0.1",
69
69
  "@multiformats/multiaddr-to-uri": "^12.0.0",
70
70
  "@noble/curves": "^1.9.7",
71
- "@tinycloud/node-sdk": "3.18.0",
71
+ "@tinycloud/node-sdk": "3.18.1",
72
72
  "@tinycloud/replica": "0.4.8",
73
- "@tinycloud/sdk-core": "3.15.0",
73
+ "@tinycloud/sdk-core": "3.18.1",
74
74
  "@tinycloud/share-envelope": "1.7.0",
75
- "@tinycloud/share-sdk": "1.6.0",
75
+ "@tinycloud/share-sdk": "1.7.0",
76
76
  "@tinycloud/web-sdk-wasm": "1.8.0",
77
77
  "axios": "^1.7.9",
78
78
  "viem": "^2.45.0",