@tinycloud/web-sdk 3.3.2-beta.1 → 3.4.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.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Every web-sdk root-bundle line that wires the optional replica. This file is the whole
3
+ * replica-owned part of the root: `tcw.ts` and `index.ts` call into it and must hold no other
4
+ * replica code (enforced by `scripts/replica-wiring-boundary.test.ts`), so an edit to them is not
5
+ * charged to the replica size allowance.
6
+ */
7
+ import { type ReplicationModuleLoaders, type TinyCloudNodeConfig } from "@tinycloud/node-sdk/core";
8
+ import type { BrowserWalletSigner } from "../adapters/BrowserWalletSigner";
9
+ export { actionContains as __replicaActionContains, KV as __replicaKV, canonicalizeRecapCaveats as __replicaCanonicalizeRecapCaveats, isCapabilitySubset as __replicaIsCapabilitySubset, parsePkhDid as __replicaParsePkhDid, parseSpaceUri as __replicaParseSpaceUri, pkhDid as __replicaPkhDid, principalDid as __replicaPrincipalDid, SiweMessage as __replicaSiweMessage, } from "@tinycloud/sdk-core";
10
+ /** Supplied by the optional web replica entry; importing that entry does not register it. */
11
+ export interface BrowserReplicaPlugin {
12
+ readonly loaders: ReplicationModuleLoaders;
13
+ readonly validateConfig: (replication: NonNullable<TinyCloudNodeConfig["replication"]>) => void;
14
+ readonly recover: (replication: NonNullable<TinyCloudNodeConfig["replication"]>, signer?: BrowserWalletSigner) => Promise<NonNullable<TinyCloudNodeConfig["replication"]>>;
15
+ }
16
+ /**
17
+ * Register in the root bundle so a separately built plugin shares its Node loader registry. The
18
+ * registry keeps a frozen copy, so mutating the supplied plugin later changes nothing.
19
+ */
20
+ export declare function registerBrowserReplica(plugin: BrowserReplicaPlugin): void;
21
+ type ReplicationConfigHolder = {
22
+ readonly replication?: TinyCloudNodeConfig["replication"];
23
+ };
24
+ export declare function validateReplicationConfig(config: ReplicationConfigHolder): void;
25
+ /** The replication value for the node config (a promise when recovery runs); undefined when none is configured. */
26
+ export declare function resolveReplicationConfig(config: ReplicationConfigHolder, signer?: BrowserWalletSigner): TinyCloudNodeConfig["replication"] | Promise<NonNullable<TinyCloudNodeConfig["replication"]>>;
27
+ //# sourceMappingURL=replica-wiring.d.ts.map
@@ -33,12 +33,16 @@ export interface RequestPermissionsCoreDeps {
33
33
  /** Persist a successful opt-out from the SDK explainer prompt. */
34
34
  suppressPromptFor30Days?: () => void;
35
35
  /** Store approved permissions as runtime delegations. */
36
- grantPermissions: (additional: PermissionEntry[]) => Promise<readonly PortableDelegation[] | void>;
36
+ grantPermissions: (additional: PermissionEntry[], options?: RequestPermissionsOptions) => Promise<readonly PortableDelegation[] | void>;
37
37
  }
38
38
  export interface RequestPermissionsCoreResult {
39
39
  approved: boolean;
40
40
  delegations?: readonly PortableDelegation[];
41
41
  }
42
+ export interface RequestPermissionsOptions {
43
+ /** Requested lifetime of the issued delegation, in milliseconds. */
44
+ expiryMs?: number;
45
+ }
42
46
  /**
43
47
  * Validate the additional permissions array and throw with a clear
44
48
  * message if empty. Exported so the caller (`TinyCloudWeb`) can share
@@ -48,6 +52,10 @@ export declare function validateAdditionalPermissions(additional: PermissionEntr
48
52
  /**
49
53
  * Core escalation flow. See the TinyCloudWeb.requestPermissions JSDoc
50
54
  * for the full spec-level description — this function is the plumbing.
55
+ *
56
+ * `options.expiryMs` requests the lifetime of the issued step-up
57
+ * delegation. The node clamps it to the session expiry, so the issued
58
+ * delegation never outlives the session.
51
59
  */
52
- export declare function requestPermissionsCore(additional: PermissionEntry[], deps: RequestPermissionsCoreDeps): Promise<RequestPermissionsCoreResult>;
60
+ export declare function requestPermissionsCore(additional: PermissionEntry[], deps: RequestPermissionsCoreDeps, options?: RequestPermissionsOptions): Promise<RequestPermissionsCoreResult>;
53
61
  //# sourceMappingURL=requestPermissionsCore.d.ts.map
@@ -9,10 +9,10 @@
9
9
  *
10
10
  * @packageDocumentation
11
11
  */
12
- import { TinyCloudNode, type ReplicationModuleLoaders, TinyCloudNodeConfig, type BootstrapWarning, type DelegateToOptions, type DelegateToResult, type ISessionStorage, type SignStrategy, type ValidatedRuntimeDelegation, type UnifiedOwnerRootInput, type UnifiedOwnerRootReceipt, type RegisterPolicyV3Input, type RegisterPolicyV3Receipt } from "@tinycloud/node-sdk/core";
12
+ import { TinyCloudNode, TinyCloudNodeConfig, type BootstrapWarning, type DelegateToOptions, type DelegateToResult, type ISessionStorage, type SignStrategy, type ValidatedRuntimeDelegation, type UnifiedOwnerRootInput, type UnifiedOwnerRootReceipt, type RegisterPolicyV3Input, type RegisterPolicyV3Receipt } from "@tinycloud/node-sdk/core";
13
13
  import { IKVService, ISQLService, IDuckDbService, IDataVaultService, ISecretsService, ISpaceService, ISpace, ISharingService, ICapabilityKeyRegistry, IHooksService, IEncryptionService, DelegationManager, Delegation, DelegationRevocationReceipt, Result, DelegationError, ClientSession, 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 RegistryPolicy, type RegistrySequenceStore, SignInOptions, type StorageFullEvent, type IStorageService } from "@tinycloud/sdk-core";
14
+ import { type RequestPermissionsOptions } from "./requestPermissionsCore";
14
15
  import { type BrowserProvider, type BrowserWalletProvider } from "../adapters/browserProvider";
15
- import { BrowserWalletSigner } from "../adapters/BrowserWalletSigner";
16
16
  import { RPCProviders, ClientConfig } from "../providers";
17
17
  import type { NotificationConfig } from "../notifications/types";
18
18
  import type { PortableDelegation, DelegatedAccess } from "@tinycloud/node-sdk/core";
@@ -154,17 +154,6 @@ export interface SessionRestoreResult {
154
154
  session?: ClientSession;
155
155
  error?: Error;
156
156
  }
157
- /** Supplied by the optional web replica entry; importing that entry does not register it. */
158
- export interface BrowserReplicaPlugin {
159
- readonly loaders: ReplicationModuleLoaders;
160
- readonly validateConfig: (replication: NonNullable<TinyCloudNodeConfig["replication"]>) => void;
161
- readonly recover: (replication: NonNullable<TinyCloudNodeConfig["replication"]>, signer?: BrowserWalletSigner) => Promise<NonNullable<TinyCloudNodeConfig["replication"]>>;
162
- }
163
- /**
164
- * Register in the root bundle so a separately built plugin shares its Node loader registry. The
165
- * registry keeps a frozen copy, so mutating the supplied plugin later changes nothing.
166
- */
167
- export declare function registerBrowserReplica(plugin: BrowserReplicaPlugin): void;
168
157
  /**
169
158
  * Result of receiving a share link.
170
159
  */
@@ -344,6 +333,8 @@ export declare class TinyCloudWeb {
344
333
  session: () => ClientSession | undefined;
345
334
  address: () => string | undefined;
346
335
  chainId: () => number | undefined;
336
+ /** Returns whether the session or an unexpired runtime grant covers all entries. Never prompts. */
337
+ hasPermissions(entries: PermissionEntry[]): boolean;
347
338
  get did(): string;
348
339
  get sessionDid(): string;
349
340
  get credentialHolderDid(): string;
@@ -430,8 +421,20 @@ export declare class TinyCloudWeb {
430
421
  * On approve, this does not mutate the manifest or force a new sign-in.
431
422
  * The underlying node creates a secondary delegation to the current
432
423
  * session key and records it in the invocation permission map.
424
+ *
425
+ * `options.expiryMs` sets the requested lifetime of the issued step-up
426
+ * delegation, in milliseconds. Omitted, the node's default applies. The
427
+ * node clamps the lifetime to the session expiry, so the issued
428
+ * delegation never outlives the session. The expiry applies when new
429
+ * permissions are requested. Permissions already covered by the session
430
+ * or an existing runtime grant return without a new delegation, so
431
+ * `expiryMs` does not apply to them.
432
+ *
433
+ * Decrypt grants (including wildcards) with `expiryMs` over one hour
434
+ * reject with `DECRYPT_EXPIRY_TOO_LONG` before the modal opens. Covered
435
+ * permissions skip this check.
433
436
  */
434
- requestPermissions(additional: PermissionEntry[]): Promise<RequestPermissionsResult>;
437
+ requestPermissions(additional: PermissionEntry[], options?: RequestPermissionsOptions): Promise<RequestPermissionsResult>;
435
438
  getRuntimePermissionDelegations(permissions?: PermissionEntry[]): readonly PortableDelegation[];
436
439
  useRuntimeDelegation(delegation: PortableDelegation): Promise<void>;
437
440
  useDelegation(delegation: PortableDelegation): Promise<DelegatedAccess>;
package/dist/replica.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BrowserReplicaPlugin } from "./modules/tcw";
1
+ import type { BrowserReplicaPlugin } from "./modules/replica-wiring";
2
2
  /** Static import cannot serve CJS: @tinycloud/replica/kv-storage exposes only an ESM entry. */
3
3
  export declare function loadIndexedDbReplicaStorage(): Promise<typeof import("@tinycloud/replica/kv-storage").indexedDbReplicaStorage>;
4
4
  export declare const browserReplicaPlugin: BrowserReplicaPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/web-sdk",
3
- "version": "3.3.2-beta.1",
3
+ "version": "3.4.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",
@@ -54,11 +54,11 @@
54
54
  "@multiformats/multiaddr": "^13.0.1",
55
55
  "@multiformats/multiaddr-to-uri": "^12.0.0",
56
56
  "@noble/curves": "^1.9.7",
57
- "@tinycloud/node-sdk": "3.3.2-beta.1",
58
- "@tinycloud/replica": "0.3.1-beta.0",
59
- "@tinycloud/sdk-core": "3.3.2-beta.1",
57
+ "@tinycloud/node-sdk": "3.4.0",
58
+ "@tinycloud/replica": "0.3.1",
59
+ "@tinycloud/sdk-core": "3.4.0",
60
60
  "@tinycloud/share-envelope": "1.2.1",
61
- "@tinycloud/share-sdk": "1.3.0-beta.0",
61
+ "@tinycloud/share-sdk": "1.3.0",
62
62
  "@tinycloud/web-sdk-wasm": "1.7.7",
63
63
  "axios": "^1.7.9",
64
64
  "viem": "^2.45.0",