@tinycloud/web-sdk 3.8.0-beta.8 → 3.8.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.
@@ -36,10 +36,10 @@ export declare const SessionConfigSchema: z.ZodObject<{
36
36
  domain?: string;
37
37
  actions?: Record<string, Record<string, string[]>>;
38
38
  spaceId?: string;
39
+ jwk?: Record<string, unknown>;
39
40
  address?: string;
40
41
  chainId?: number;
41
42
  issuedAt?: string;
42
- jwk?: Record<string, unknown>;
43
43
  notBefore?: string;
44
44
  expirationTime?: string;
45
45
  parents?: string[];
@@ -47,10 +47,10 @@ export declare const SessionConfigSchema: z.ZodObject<{
47
47
  domain?: string;
48
48
  actions?: Record<string, Record<string, string[]>>;
49
49
  spaceId?: string;
50
+ jwk?: Record<string, unknown>;
50
51
  address?: string;
51
52
  chainId?: number;
52
53
  issuedAt?: string;
53
- jwk?: Record<string, unknown>;
54
54
  notBefore?: string;
55
55
  expirationTime?: string;
56
56
  parents?: string[];
@@ -10,11 +10,13 @@
10
10
  *
11
11
  * @packageDocumentation
12
12
  */
13
- import type { Manifest, PermissionEntry } from "@tinycloud/sdk-core";
13
+ import { type Manifest, type PermissionEntry } from "@tinycloud/sdk-core";
14
14
  import type { PortableDelegation } from "@tinycloud/node-sdk/core";
15
15
  export interface RequestPermissionsCoreDeps {
16
16
  /** Current stored manifest. Must be defined — caller validates first. */
17
17
  manifest: Manifest;
18
+ /** Authenticated owner from the current node, never from a requested resource. */
19
+ ownerDid?: string;
18
20
  /**
19
21
  * Show the permission request modal. Resolves with `{ approved }`
20
22
  * once the user interacts. In tests this is a stub; in production it
@@ -49,6 +51,11 @@ export interface RequestPermissionsOptions {
49
51
  * the same error text.
50
52
  */
51
53
  export declare function validateAdditionalPermissions(additional: PermissionEntry[]): void;
54
+ /**
55
+ * Normalize only encryption key creation here. Other runtime entries retain
56
+ * their existing Web consent representation; the node validates them.
57
+ */
58
+ export declare function normalizeRuntimeKeyCreatePermissions(additional: PermissionEntry[], ownerDid?: string): PermissionEntry[];
52
59
  /**
53
60
  * Core escalation flow. See the TinyCloudWeb.requestPermissions JSDoc
54
61
  * for the full spec-level description — this function is the plumbing.
@@ -0,0 +1,41 @@
1
+ import type { PortableDelegation } from "@tinycloud/node-sdk/core";
2
+ export interface RuntimeGrantStore {
3
+ loadRuntimeGrants(address: string): Promise<PortableDelegation[]>;
4
+ saveRuntimeGrants(address: string, grants: readonly PortableDelegation[]): Promise<void>;
5
+ }
6
+ /** How long a restore waits for stored grants to be activated before it carries on without them. */
7
+ export declare const RESTORE_GRANT_BUDGET_MS = 4000;
8
+ interface Resource {
9
+ readonly service: string;
10
+ readonly space: string;
11
+ readonly path: string;
12
+ readonly actions: readonly string[];
13
+ readonly caveats?: readonly unknown[] | undefined;
14
+ }
15
+ /**
16
+ * True when `resources` are exactly one tab's entry for this owner: that service, the resolved space, that path,
17
+ * exactly those actions, no caveats. A grant that carries anything more (an app's larger grant) is not a panel grant.
18
+ */
19
+ export declare function isPanelResourceSet(resources: readonly Resource[], owner: {
20
+ readonly address: string;
21
+ readonly chainId: number;
22
+ }): boolean;
23
+ /** True when `grant` is exactly a panel grant of the session owned by `address`. */
24
+ export declare function isPanelGrant(grant: PortableDelegation, address: string): boolean;
25
+ /**
26
+ * Stores the panel's own grants among `grants` for `address`, replacing a stored grant with the same cid. Other
27
+ * delegations (an app's larger grant that already covered the request) are never stored.
28
+ */
29
+ export declare function rememberRuntimeGrants(store: RuntimeGrantStore, address: string, grants: readonly PortableDelegation[]): Promise<void>;
30
+ /**
31
+ * Activates each stored grant through `use` (the SDK's validated activation). A grant refused for good is removed from
32
+ * storage; the others stay, including one whose activation failed for a transient reason. Waits at most `budgetMs`;
33
+ * activations still running then finish in the background. Never throws. `isCurrent` false (signed out meanwhile)
34
+ * stops any write to storage.
35
+ */
36
+ export declare function reuseRuntimeGrants(store: RuntimeGrantStore, address: string, use: (grant: PortableDelegation) => Promise<unknown>, options?: {
37
+ readonly budgetMs?: number;
38
+ readonly isCurrent?: () => boolean;
39
+ }): Promise<void>;
40
+ export {};
41
+ //# sourceMappingURL=runtimeGrantPersistence.d.ts.map
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * @packageDocumentation
11
11
  */
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";
12
+ import { TinyCloudNode, TinyCloudNodeConfig, type OpenKeyAuthorizeTinyCloud, 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 { type LocalCopyPurgeFailedEvent } from "./replica-wiring";
14
14
  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";
15
15
  import { type RequestPermissionsOptions } from "./requestPermissionsCore";
@@ -31,6 +31,11 @@ declare global {
31
31
  * Extends ClientConfig with browser-specific options.
32
32
  */
33
33
  export interface Config extends ClientConfig {
34
+ /** OpenKey authorize-sign client. Requires @openkey/sdk >=0.12.2; popup is the default mode. */
35
+ openkey?: {
36
+ client: OpenKeyAuthorizeTinyCloud;
37
+ mode?: "iframe" | "popup" | "redirect";
38
+ };
34
39
  /** Notifications. `throwErrors` rethrows each error's raw message asynchronously, once per burst of identical errors (200 ms window). It applies unless `ui: false` or `ui.toasts: false`, which turn off toasts and throws together, as the old `popups: false` did; `ui.button: false` leaves throws on. Toast placement and visibility are set through `ui`. */
35
40
  notifications?: NotificationConfig;
36
41
  /** Optional prefix for KV service keys */
@@ -170,6 +175,10 @@ export interface ShareReceiveResult<T = unknown> {
170
175
  host: string;
171
176
  }
172
177
  export declare class TinyCloudWeb {
178
+ private openkeySignInInFlight;
179
+ private prepareSignInToken;
180
+ private preparedSignIn?;
181
+ private invalidatePreparedSignIn;
173
182
  /** The connected wallet's raw EIP-1193 provider. */
174
183
  provider: BrowserProvider;
175
184
  /** The normalized EIP-1193 provider used by the SDK. */
@@ -348,7 +357,15 @@ export declare class TinyCloudWeb {
348
357
  restoreSession(address?: string): Promise<SessionRestoreResult>;
349
358
  clearPersistedSession(address?: string): Promise<void>;
350
359
  private configuredManifestPermissions;
360
+ /**
361
+ * Prepare an OpenKey SIWE before showing an approval button. Call after
362
+ * OpenKey connect(), then call signIn() from the button's click handler.
363
+ * A prepared request is single-use and valid for five minutes; call this
364
+ * method again if the approval button remains visible longer.
365
+ */
366
+ prepareSignIn(): Promise<void>;
351
367
  signIn: (options?: SignInOptions) => Promise<ClientSession>;
368
+ private performSignIn;
352
369
  /**
353
370
  * Sign out: end the session on this instance and clear the persisted
354
371
  * session. Afterwards accessors return `undefined` and service calls remain
@@ -446,6 +463,8 @@ export declare class TinyCloudWeb {
446
463
  * On approve, this does not mutate the manifest or force a new sign-in.
447
464
  * The underlying node creates a secondary delegation to the current
448
465
  * session key and records it in the invocation permission map.
466
+ * Exact current-owner `default/share/<id>` key creation is bound to this
467
+ * live signed session across consent. Native shells cannot request it.
449
468
  *
450
469
  * `options.expiryMs` sets the requested lifetime of the issued step-up
451
470
  * delegation, in milliseconds. Omitted, the node's default applies. The
@@ -456,6 +475,14 @@ export declare class TinyCloudWeb {
456
475
  * `expiryMs` does not apply to them.
457
476
  */
458
477
  requestPermissions(additional: PermissionEntry[], options?: RequestPermissionsOptions): Promise<RequestPermissionsResult>;
478
+ /** True when the panel may ask for a permission: a manifest, a page signer and a live session exist. */
479
+ private canRequestPanelPermissions;
480
+ /**
481
+ * The panel's request for one tab's entry. A grant is kept with the stored session record so it survives a reload;
482
+ * the entry is not stored when the user signed out while the prompt was open.
483
+ */
484
+ private requestPanelPermissions;
485
+ private runtimeGrantStore;
459
486
  getRuntimePermissionDelegations(permissions?: PermissionEntry[]): readonly PortableDelegation[];
460
487
  useRuntimeDelegation(delegation: PortableDelegation): Promise<void>;
461
488
  useDelegation(delegation: PortableDelegation): Promise<DelegatedAccess>;