@tinycloud/web-sdk 2.0.4 → 2.1.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.
@@ -5,6 +5,7 @@ export declare const makeSpaceId: TinyCloudModule['makeSpaceId'];
5
5
  export declare const prepareSession: TinyCloudModule['prepareSession'];
6
6
  export declare const completeSessionSetup: TinyCloudModule['completeSessionSetup'];
7
7
  export declare const invoke: InvokeFunction;
8
+ export declare const invokeAny: TinyCloudModule['invokeAny'];
8
9
  export declare const generateHostSIWEMessage: TinyCloudModule['generateHostSIWEMessage'];
9
10
  export declare const siweToDelegationHeaders: TinyCloudModule['siweToDelegationHeaders'];
10
11
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../src/modules/Storage/tinycloud/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,KAAK,eAAe,GAAG,OAAO,SAAS,CAAC;AAYxC,eAAO,MAAM,WAAW,EAAE,eAAe,CAAC,aAAa,CAMtD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,eAAe,CAAC,gBAAgB,CAM5D,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,eAAe,CAAC,sBAAsB,CAQxE,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,cAMpB,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,yBAAyB,CAO5E,CAAC;AAEJ,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,yBAAyB,CAO5E,CAAC"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../src/modules/Storage/tinycloud/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,KAAK,eAAe,GAAG,OAAO,SAAS,CAAC;AAYxC,eAAO,MAAM,WAAW,EAAE,eAAe,CAAC,aAAa,CAMtD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,eAAe,CAAC,gBAAgB,CAM5D,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,eAAe,CAAC,sBAAsB,CAQxE,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,cAMpB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,eAAe,CAAC,WAAW,CAMlD,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,yBAAyB,CAW5E,CAAC;AAEJ,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,yBAAyB,CAW5E,CAAC"}
@@ -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, 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,25 @@ 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.
49
+ *
50
+ * When provided, {@link TinyCloudWeb.requestPermissions} uses the
51
+ * manifest's `name` and `icon` to title the permission modal and
52
+ * composes escalation requests against the manifest's existing
53
+ * permission set. Phase 4 stores the manifest verbatim; the
54
+ * manifest-driven sign-in path itself lands in Phase 5.
55
+ */
56
+ manifest?: Manifest;
57
+ }
58
+ /**
59
+ * Result of {@link TinyCloudWeb.requestPermissions}. Populated with the
60
+ * fresh session on approve; empty on decline so callers can branch on
61
+ * `approved` without dereferencing a stale session.
62
+ */
63
+ export interface RequestPermissionsResult {
64
+ approved: boolean;
65
+ session?: ClientSession;
46
66
  }
47
67
  /**
48
68
  * Result of receiving a share link.
@@ -70,6 +90,24 @@ export declare class TinyCloudWeb {
70
90
  private _initPromise;
71
91
  /** User config */
72
92
  private config;
93
+ /**
94
+ * App manifest stored from config (or updated via `setManifest`).
95
+ *
96
+ * `requestPermissions` reads this for the modal title/icon and for
97
+ * composing an expanded manifest on approve. Phase 4 treats this as a
98
+ * simple passthrough container — the manifest-driven sign-in flow lands
99
+ * in Phase 5, where `signIn` will consume this field directly.
100
+ */
101
+ private _manifest?;
102
+ /**
103
+ * Test hook — override the modal shower and sign-in function used by
104
+ * {@link requestPermissions}. Not part of the public API. Tests set
105
+ * these via `(tcw as any)._testHooks = { ... }` so they can exercise
106
+ * the escalation control flow without a real DOM or wallet.
107
+ *
108
+ * @internal
109
+ */
110
+ private _testHooks?;
73
111
  constructor(config?: Config);
74
112
  /**
75
113
  * Async initialization: ensure WASM is ready, then create TinyCloudNode.
@@ -95,11 +133,13 @@ export declare class TinyCloudWeb {
95
133
  get kv(): IKVService;
96
134
  get sql(): ISQLService;
97
135
  get duckdb(): IDuckDbService;
136
+ get hooks(): IHooksService;
98
137
  get vault(): IDataVaultService;
99
138
  get spaces(): ISpaceService;
100
139
  get sharing(): ISharingService;
101
140
  get delegations(): DelegationManager;
102
141
  get capabilityRegistry(): ICapabilityKeyRegistry;
142
+ get spaceId(): string | undefined;
103
143
  space(nameOrUri: string): ISpace;
104
144
  get kvPrefix(): string;
105
145
  signIn: () => Promise<ClientSession>;
@@ -123,6 +163,48 @@ export declare class TinyCloudWeb {
123
163
  disableSubDelegation?: boolean;
124
164
  expiryMs?: number;
125
165
  }): Promise<PortableDelegation>;
166
+ /**
167
+ * Issue a delegation using the capability-chain flow (spec:
168
+ * `.claude/specs/capability-chain.md`). When the requested permissions
169
+ * are a subset of the current session's recap, no wallet prompt is
170
+ * shown — the delegation is signed by the session key via WASM. When
171
+ * they are not, this throws `PermissionNotInManifestError` so callers
172
+ * can trigger an escalation flow via {@link requestPermissions}.
173
+ *
174
+ * Pass `{ forceWalletSign: true }` to bypass the derivability check and
175
+ * always use the wallet-signed SIWE path.
176
+ *
177
+ * Current limitation: exactly one {@link PermissionEntry} per call.
178
+ */
179
+ delegateTo: (did: string, permissions: PermissionEntry[], options?: DelegateToOptions) => Promise<DelegateToResult>;
180
+ /**
181
+ * Get the stored manifest (if any). Returns a shallow clone so callers
182
+ * can't accidentally mutate our internal state.
183
+ */
184
+ getManifest(): Manifest | undefined;
185
+ /**
186
+ * Install or replace the stored manifest. Used by apps that compose
187
+ * their manifest at runtime (e.g. after fetching a backend's advertised
188
+ * permissions) and by the escalation flow inside
189
+ * {@link requestPermissions}.
190
+ */
191
+ setManifest(manifest: Manifest): void;
192
+ /**
193
+ * Request additional permissions on top of the currently-signed
194
+ * session. Shows a confirmation modal; on approve, signs out the
195
+ * current session (without disconnecting the wallet) and runs a fresh
196
+ * `signIn` with the composed manifest. On decline, returns
197
+ * `{ approved: false }` with no state changes.
198
+ *
199
+ * Spec: `.claude/specs/capability-chain.md` §requestPermissions.
200
+ *
201
+ * Phase 4 note: the actual manifest-driven `signIn` is Phase 5. For
202
+ * now, the escalation composes an updated manifest, signs out, and
203
+ * calls `signIn()` — which still uses the current sign-in path. The
204
+ * updated `_manifest` field is available for the Phase 5 refactor to
205
+ * pick up directly.
206
+ */
207
+ requestPermissions(additional: PermissionEntry[]): Promise<RequestPermissionsResult>;
126
208
  useDelegation(delegation: PortableDelegation): Promise<DelegatedAccess>;
127
209
  createSubDelegation(parentDelegation: PortableDelegation, params: {
128
210
  path: string;
@@ -1 +1 @@
1
- {"version":3,"file":"tcw.d.ts","sourceRoot":"","sources":["../../src/modules/tcw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,sBAAsB,EACtB,MAAM,EACN,eAAe,EAEf,aAAa,EACb,SAAS,EAKT,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAMxC,OAAO,EAAE,YAAY,EAAE,YAAY,EAA8B,MAAM,cAAc,CAAC;AAKtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,QAAQ,CAAC,EAAE,GAAG,CAAC;KAChB;CACF;AAID;;;;GAIG;AACH,MAAM,WAAW,MAAO,SAAQ,YAAY;IAC1C,6DAA6D;IAC7D,aAAa,CAAC,EAAE,kBAAkB,CAAC;IAEnC,0CAA0C;IAC1C,QA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AQ,EAAE,QAAQ,GAAG,IAAI;IAIrC;;;;;;;;;;;;;;OAcG;IACG,kBAAkB,CACtB,UAAU,EAAE,eAAe,EAAE,GAC5B,OAAO,CAAC,wBAAwB,CAAC;IA+B9B,aAAa,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAKvE,mBAAmB,CACvB,gBAAgB,EAAE,kBAAkB,EACpC,MAAM,EAAE;QACN,IAAI,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.0.4",
3
+ "version": "2.1.0-beta.1",
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.0.4",
42
- "@tinycloud/sdk-core": "2.0.4",
43
- "@tinycloud/web-sdk-wasm": "1.7.1",
41
+ "@tinycloud/node-sdk": "2.1.0-beta.1",
42
+ "@tinycloud/sdk-core": "2.1.0-beta.1",
43
+ "@tinycloud/web-sdk-wasm": "1.7.2-beta.1",
44
44
  "axios": "^1.7.9",
45
45
  "ethers": "^5.7.2",
46
46
  "lodash.merge": "^4.6.2",