@tinycloud/web-sdk 2.1.0-beta.0 → 2.1.0-beta.2

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.
@@ -34,8 +34,8 @@ export declare const SessionConfigSchema: z.ZodObject<{
34
34
  jwk: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
35
35
  }, "strip", z.ZodTypeAny, {
36
36
  domain?: string;
37
- spaceId?: string;
38
37
  actions?: Record<string, Record<string, string[]>>;
38
+ spaceId?: string;
39
39
  address?: string;
40
40
  chainId?: number;
41
41
  issuedAt?: string;
@@ -45,8 +45,8 @@ export declare const SessionConfigSchema: z.ZodObject<{
45
45
  jwk?: Record<string, unknown>;
46
46
  }, {
47
47
  domain?: string;
48
- spaceId?: string;
49
48
  actions?: Record<string, Record<string, string[]>>;
49
+ spaceId?: string;
50
50
  address?: string;
51
51
  chainId?: number;
52
52
  issuedAt?: string;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Pure core of the `TinyCloudWeb.requestPermissions` escalation flow.
3
+ *
4
+ * Exposed as a standalone function so unit tests can exercise the
5
+ * control flow (validation → modal → compose → signOut → signIn) without
6
+ * instantiating the full `TinyCloudWeb` class (which wants a real WASM
7
+ * binding and browser wallet signer).
8
+ *
9
+ * Not re-exported from the package entry point — test surface only.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import type { ClientSession, Manifest, PermissionEntry } from "@tinycloud/sdk-core";
14
+ export interface RequestPermissionsCoreDeps {
15
+ /** Current stored manifest. Must be defined — caller validates first. */
16
+ manifest: Manifest;
17
+ /**
18
+ * Show the permission request modal. Resolves with `{ approved }`
19
+ * once the user interacts. In tests this is a stub; in production it
20
+ * is `ModalManager.showPermissionRequestModal`.
21
+ */
22
+ showModal: (opts: {
23
+ appName: string;
24
+ appIcon?: string;
25
+ additional: PermissionEntry[];
26
+ }) => Promise<{
27
+ approved: boolean;
28
+ }>;
29
+ /**
30
+ * Tear down the SDK-side session state. Wallet stays connected.
31
+ */
32
+ signOut: () => Promise<void>;
33
+ /**
34
+ * Run a fresh sign-in with the composed manifest already stored on
35
+ * the caller. Returns the new client session on success.
36
+ */
37
+ signIn: () => Promise<ClientSession>;
38
+ /**
39
+ * Write-through hook so the caller can update its stored manifest
40
+ * before the new sign-in runs. Called once, with the composed manifest,
41
+ * only on the approve path.
42
+ */
43
+ writeManifest: (next: Manifest) => void;
44
+ }
45
+ export interface RequestPermissionsCoreResult {
46
+ approved: boolean;
47
+ session?: ClientSession;
48
+ }
49
+ /**
50
+ * Validate the additional permissions array and throw with a clear
51
+ * message if empty. Exported so the caller (`TinyCloudWeb`) can share
52
+ * the same error text.
53
+ */
54
+ export declare function validateAdditionalPermissions(additional: PermissionEntry[]): void;
55
+ /**
56
+ * Core escalation flow. See the TinyCloudWeb.requestPermissions JSDoc
57
+ * for the full spec-level description — this function is the plumbing.
58
+ */
59
+ export declare function requestPermissionsCore(additional: PermissionEntry[], deps: RequestPermissionsCoreDeps): Promise<RequestPermissionsCoreResult>;
60
+ //# sourceMappingURL=requestPermissionsCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestPermissionsCore.d.ts","sourceRoot":"","sources":["../../src/modules/requestPermissionsCore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACR,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,0BAA0B;IACzC,yEAAyE;IACzE,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;;OAIG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,eAAe,EAAE,CAAC;KAC/B,KAAK,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACrC;;OAEG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B;;;OAGG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IACrC;;;;OAIG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,eAAe,EAAE,GAC5B,IAAI,CAMN;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,eAAe,EAAE,EAC7B,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,4BAA4B,CAAC,CA2BvC"}
@@ -9,7 +9,8 @@
9
9
  *
10
10
  * @packageDocumentation
11
11
  */
12
- import { IKVService, ISQLService, IDuckDbService, IDataVaultService, ISpaceService, ISpace, ISharingService, ICapabilityKeyRegistry, IHooksService, DelegationManager, Delegation, CreateDelegationParams, Result, DelegationError, ClientSession, Extension, ISpaceCreationHandler } from "@tinycloud/sdk-core";
12
+ import { type DelegateToOptions, type DelegateToResult } from "@tinycloud/node-sdk/core";
13
+ import { IKVService, ISQLService, IDuckDbService, IDataVaultService, ISpaceService, ISpace, ISharingService, ICapabilityKeyRegistry, IHooksService, DelegationManager, Delegation, CreateDelegationParams, Result, DelegationError, ClientSession, Extension, ISpaceCreationHandler, type Manifest, type PermissionEntry } from "@tinycloud/sdk-core";
13
14
  import type { providers } from "ethers";
14
15
  import { RPCProviders, ClientConfig } from "../providers";
15
16
  import type { NotificationConfig } from "../notifications/types";
@@ -43,6 +44,31 @@ export interface Config extends ClientConfig {
43
44
  domain?: string;
44
45
  /** Shorthand for passing a Web3 provider */
45
46
  provider?: any;
47
+ /**
48
+ * App manifest used for sign-in and escalation flows. When set,
49
+ * the SIWE recap issued at sign-in covers the union of the app's
50
+ * own permissions and every manifest-declared delegation's
51
+ * permissions — which is what enables
52
+ * `tcw.delegateTo(manifestDeclaredDid, permissions)` to run via
53
+ * the session-key UCAN path (no wallet prompt).
54
+ *
55
+ * When provided, {@link TinyCloudWeb.requestPermissions} uses the
56
+ * manifest's `name` and `icon` to title the permission modal and
57
+ * composes escalation requests against the manifest's existing
58
+ * permission set. The manifest is forwarded into the underlying
59
+ * {@link TinyCloudNode} so `signIn()` drives its SIWE recap from
60
+ * it directly.
61
+ */
62
+ manifest?: Manifest;
63
+ }
64
+ /**
65
+ * Result of {@link TinyCloudWeb.requestPermissions}. Populated with the
66
+ * fresh session on approve; empty on decline so callers can branch on
67
+ * `approved` without dereferencing a stale session.
68
+ */
69
+ export interface RequestPermissionsResult {
70
+ approved: boolean;
71
+ session?: ClientSession;
46
72
  }
47
73
  /**
48
74
  * Result of receiving a share link.
@@ -70,6 +96,26 @@ export declare class TinyCloudWeb {
70
96
  private _initPromise;
71
97
  /** User config */
72
98
  private config;
99
+ /**
100
+ * App manifest stored from config (or updated via `setManifest`).
101
+ *
102
+ * `requestPermissions` reads this for the modal title/icon and for
103
+ * composing an expanded manifest on approve. `_init` forwards this
104
+ * value into the underlying {@link TinyCloudNode} so `signIn()`
105
+ * drives its SIWE recap from the manifest. `setManifest` mirrors
106
+ * any post-construction updates onto the node so the next sign-in
107
+ * picks them up.
108
+ */
109
+ private _manifest?;
110
+ /**
111
+ * Test hook — override the modal shower and sign-in function used by
112
+ * {@link requestPermissions}. Not part of the public API. Tests set
113
+ * these via `(tcw as any)._testHooks = { ... }` so they can exercise
114
+ * the escalation control flow without a real DOM or wallet.
115
+ *
116
+ * @internal
117
+ */
118
+ private _testHooks?;
73
119
  constructor(config?: Config);
74
120
  /**
75
121
  * Async initialization: ensure WASM is ready, then create TinyCloudNode.
@@ -125,6 +171,53 @@ export declare class TinyCloudWeb {
125
171
  disableSubDelegation?: boolean;
126
172
  expiryMs?: number;
127
173
  }): Promise<PortableDelegation>;
174
+ /**
175
+ * Issue a delegation using the capability-chain flow (spec:
176
+ * `.claude/specs/capability-chain.md`). When the requested permissions
177
+ * are a subset of the current session's recap, no wallet prompt is
178
+ * shown — the delegation is signed by the session key via WASM. When
179
+ * they are not, this throws `PermissionNotInManifestError` so callers
180
+ * can trigger an escalation flow via {@link requestPermissions}.
181
+ *
182
+ * Pass `{ forceWalletSign: true }` to bypass the derivability check and
183
+ * always use the wallet-signed SIWE path.
184
+ *
185
+ * Current limitation: exactly one {@link PermissionEntry} per call.
186
+ */
187
+ delegateTo: (did: string, permissions: PermissionEntry[], options?: DelegateToOptions) => Promise<DelegateToResult>;
188
+ /**
189
+ * Get the stored manifest (if any). Returns a shallow clone so callers
190
+ * can't accidentally mutate our internal state.
191
+ */
192
+ getManifest(): Manifest | undefined;
193
+ /**
194
+ * Install or replace the stored manifest. Used by apps that compose
195
+ * their manifest at runtime (e.g. after fetching a backend's advertised
196
+ * permissions) and by the escalation flow inside
197
+ * {@link requestPermissions}.
198
+ *
199
+ * The manifest is forwarded to the underlying TinyCloudNode so the
200
+ * next `signIn()` picks it up. If the node has not been constructed
201
+ * yet (pre-init), the manifest is stored locally and forwarded
202
+ * later inside `_init`.
203
+ */
204
+ setManifest(manifest: Manifest): void;
205
+ /**
206
+ * Request additional permissions on top of the currently-signed
207
+ * session. Shows a confirmation modal; on approve, signs out the
208
+ * current session (without disconnecting the wallet) and runs a fresh
209
+ * `signIn` with the composed manifest. On decline, returns
210
+ * `{ approved: false }` with no state changes.
211
+ *
212
+ * Spec: `.claude/specs/capability-chain.md` §requestPermissions.
213
+ *
214
+ * On approve, this composes the expanded manifest, signs out the
215
+ * current session, and calls `signIn()` — which now drives its
216
+ * SIWE recap from `this._manifest` directly, so the fresh session
217
+ * is signed with the expanded capability set in a single wallet
218
+ * prompt.
219
+ */
220
+ requestPermissions(additional: PermissionEntry[]): Promise<RequestPermissionsResult>;
128
221
  useDelegation(delegation: PortableDelegation): Promise<DelegatedAccess>;
129
222
  createSubDelegation(parentDelegation: PortableDel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EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACA,OAAO,CAAC,kBAAkB,CAAC;IAKxB,QAAQ,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAKtF,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IAKrE,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,eAAe,CAAC,CAAC;IAKjE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAS9F;;;OAGG;WACiB,YAAY,CAAC,CAAC,GAAG,OAAO,EAC1C,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;CA4H3D"}
@@ -1,5 +1,6 @@
1
1
  import { type SpaceCreationModalOptions, type SpaceCreationResult } from './SpaceCreationModal';
2
2
  import { type NodeSelectionModalOptions, type NodeSelectionResult } from './NodeSelectionModal';
3
+ import { type PermissionRequestModalOptions, type PermissionRequestResult } from './PermissionRequestModal';
3
4
  export declare class ModalManager {
4
5
  private static instance;
5
6
  private activeModal;
@@ -7,9 +8,11 @@ export declare class ModalManager {
7
8
  static getInstance(): ModalManager;
8
9
  showSpaceCreationModal(options: SpaceCreationModalOptions): Promise<SpaceCreationResult>;
9
10
  showNodeSelectionModal(options: NodeSelectionModalOptions): Promise<NodeSelectionResult>;
11
+ showPermissionRequestModal(options: PermissionRequestModalOptions): Promise<PermissionRequestResult>;
10
12
  closeActiveModal(): void;
11
13
  hasActiveModal(): boolean;
12
14
  }
13
15
  export declare const showSpaceCreationModal: (options: SpaceCreationModalOptions) => Promise<SpaceCreationResult>;
14
16
  export declare const showNodeSelectionModal: (options: NodeSelectionModalOptions) => Promise<NodeSelectionResult>;
17
+ export declare const showPermissionRequestModal: (options: PermissionRequestModalOptions) => Promise<PermissionRequestResult>;
15
18
  //# sourceMappingURL=ModalManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModalManager.d.ts","sourceRoot":"","sources":["../../src/notifications/ModalManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACrH,OAAO,EAA+B,KAAK,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE7H,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IACtC,OAAO,CAAC,WAAW,CAAkE;IAErF,OAAO;WAEO,WAAW,IAAI,YAAY;IAOlC,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAuBxF,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAuBxF,gBAAgB,IAAI,IAAI;IAOxB,cAAc,IAAI,OAAO;CAGjC;AAGD,eAAO,MAAM,sBAAsB,YAAa,yBAAyB,KAAG,OAAO,CAAC,mBAAmB,CAEtG,CAAC;AAEF,eAAO,MAAM,sBAAsB,YAAa,yBAAyB,KAAG,OAAO,CAAC,mBAAmB,CAEtG,CAAC"}
1
+ {"version":3,"file":"ModalManager.d.ts","sourceRoot":"","sources":["../../src/notifications/ModalManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACrH,OAAO,EAA+B,KAAK,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC7H,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC7B,MAAM,0BAA0B,CAAC;AAElC,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IACtC,OAAO,CAAC,WAAW,CAIH;IAEhB,OAAO;WAEO,WAAW,IAAI,YAAY;IAOlC,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAuBxF,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAuBxF,0BAA0B,CAC/B,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,uBAAuB,CAAC;IAmB5B,gBAAgB,IAAI,IAAI;IAOxB,cAAc,IAAI,OAAO;CAGjC;AAGD,eAAO,MAAM,sBAAsB,YAAa,yBAAyB,KAAG,OAAO,CAAC,mBAAmB,CAEtG,CAAC;AAEF,eAAO,MAAM,sBAAsB,YAAa,yBAAyB,KAAG,OAAO,CAAC,mBAAmB,CAEtG,CAAC;AAEF,eAAO,MAAM,0BAA0B,YAC5B,6BAA6B,KACrC,OAAO,CAAC,uBAAuB,CAEjC,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * PermissionRequestModal
3
+ *
4
+ * Web Component that shows the user a list of additional capabilities an
5
+ * app wants to request on top of the currently-signed session. Used by
6
+ * `TinyCloudWeb.requestPermissions` as the confirmation step before we
7
+ * tear down the current session and run a fresh signIn with an expanded
8
+ * manifest.
9
+ *
10
+ * Matches the `SpaceCreationModal` pattern: a Web Component with a shadow
11
+ * DOM, returning a completion promise via `getCompletionPromise()`. The
12
+ * DOM lifecycle (append / remove) is managed by `ModalManager`.
13
+ *
14
+ * Canonical spec: `.claude/specs/capability-chain.md`.
15
+ */
16
+ import type { PermissionEntry } from "@tinycloud/sdk-core";
17
+ export interface PermissionRequestModalOptions {
18
+ /** Display name of the app requesting permissions (from the manifest). */
19
+ appName: string;
20
+ /** Optional app icon URL (from the manifest). */
21
+ appIcon?: string;
22
+ /** The additional permissions the app wants on top of its current session. */
23
+ additional: PermissionEntry[];
24
+ /** Called when the user clicks Decline or dismisses the modal. */
25
+ onDismiss?: () => void;
26
+ }
27
+ export interface PermissionRequestResult {
28
+ /** True when the user clicked Approve, false when they declined or dismissed. */
29
+ approved: boolean;
30
+ }
31
+ export declare class TinyCloudPermissionRequestModal extends HTMLElement {
32
+ private options;
33
+ private isVisible;
34
+ private resolveResult;
35
+ private completionPromise;
36
+ constructor(options: PermissionRequestModalOptions);
37
+ getCompletionPromise(): Promise<PermissionRequestResult>;
38
+ connectedCallback(): void;
39
+ disconnectedCallback(): void;
40
+ private render;
41
+ private renderEntry;
42
+ private getModalStyles;
43
+ private setupEventListeners;
44
+ private handleKeyDown;
45
+ private handleApprove;
46
+ private show;
47
+ private hide;
48
+ private dismiss;
49
+ }
50
+ //# sourceMappingURL=PermissionRequestModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionRequestModal.d.ts","sourceRoot":"","sources":["../../src/notifications/PermissionRequestModal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,WAAW,6BAA6B;IAC5C,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC,iFAAiF;IACjF,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,+BAAgC,SAAQ,WAAW;IAC9D,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,aAAa,CACd;IACP,OAAO,CAAC,iBAAiB,CAAmC;gBAEhD,OAAO,EAAE,6BAA6B;IAW3C,oBAAoB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAI/D,iBAAiB;IAKjB,oBAAoB;IAIpB,OAAO,CAAC,MAAM;IAqDd,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,cAAc;IAuItB,OAAO,CAAC,mBAAmB;IAmB3B,OAAO,CAAC,aAAa,CAInB;IAEF,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,IAAI;IASZ,OAAO,CAAC,IAAI;IAWZ,OAAO,CAAC,OAAO;CAKhB"}
@@ -53,10 +53,10 @@ export declare const ToastSchema: z.ZodObject<{
53
53
  }>>;
54
54
  timestamp: z.ZodNumber;
55
55
  }, "strip", z.ZodTypeAny, {
56
- type?: "error" | "success" | "warning" | "info" | "loading";
56
+ type?: "error" | "loading" | "success" | "warning" | "info";
57
+ title?: string;
57
58
  description?: string;
58
59
  id?: string;
59
- title?: string;
60
60
  duration?: number;
61
61
  action?: {
62
62
  label?: string;
@@ -64,10 +64,10 @@ export declare const ToastSchema: z.ZodObject<{
64
64
  };
65
65
  timestamp?: number;
66
66
  }, {
67
- type?: "error" | "success" | "warning" | "info" | "loading";
67
+ type?: "error" | "loading" | "success" | "warning" | "info";
68
+ title?: string;
68
69
  description?: string;
69
70
  id?: string;
70
- title?: string;
71
71
  duration?: number;
72
72
  action?: {
73
73
  label?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/web-sdk",
3
- "version": "2.1.0-beta.0",
3
+ "version": "2.1.0-beta.2",
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",
@@ -38,9 +38,9 @@
38
38
  "@metamask/detect-provider": "^1.2.0",
39
39
  "@multiformats/multiaddr": "^13.0.1",
40
40
  "@multiformats/multiaddr-to-uri": "^12.0.0",
41
- "@tinycloud/node-sdk": "2.1.0-beta.0",
42
- "@tinycloud/sdk-core": "2.1.0-beta.0",
43
- "@tinycloud/web-sdk-wasm": "1.7.1",
41
+ "@tinycloud/node-sdk": "2.1.0-beta.2",
42
+ "@tinycloud/sdk-core": "2.1.0-beta.2",
43
+ "@tinycloud/web-sdk-wasm": "1.7.2-beta.2",
44
44
  "axios": "^1.7.9",
45
45
  "ethers": "^5.7.2",
46
46
  "lodash.merge": "^4.6.2",