@tinycloud/web-sdk 3.14.0-beta.11 → 3.14.0-beta.13

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.
@@ -39,5 +39,35 @@ export declare function reuseRuntimeGrants(store: RuntimeGrantStore, address: st
39
39
  readonly budgetMs?: number;
40
40
  readonly isCurrent?: () => boolean;
41
41
  }): Promise<void>;
42
+ /** A stored grant. `askedBy` names the apps it was approved for (the `onBehalfOf` of each approving request). */
43
+ export type StoredRuntimeGrant = PortableDelegation & {
44
+ readonly askedBy?: readonly string[];
45
+ };
46
+ /** The apps a stored grant was approved for; anything else in the field is ignored. */
47
+ export declare function storedGrantAskers(grant: PortableDelegation): readonly string[];
48
+ /**
49
+ * True when a grant entry is elevated: any service this module does not know (decrypt and key creation among them),
50
+ * anything in the secrets space, or a caveat of any shape. Failing closed: an entry this function cannot classify is
51
+ * elevated, and an elevated grant is never written to storage.
52
+ */
53
+ export declare function isElevatedResource(resource: {
54
+ readonly service: string;
55
+ readonly space?: string | undefined;
56
+ readonly caveats?: unknown;
57
+ }): boolean;
58
+ /** True when every resource is in a space the owner owns and none is elevated. An empty set is not rememberable. */
59
+ export declare function isRememberableResourceSet(resources: readonly Resource[], owner: {
60
+ readonly address: string;
61
+ readonly chainId: number;
62
+ }): boolean;
63
+ /** True when `grant` is an unexpired, non-elevated grant of the session owned by `address`. */
64
+ export declare function isRememberableGrant(grant: PortableDelegation, address: string): boolean;
65
+ /**
66
+ * Stores the non-elevated grants among `grants` for `address`, with `asker` added to the apps each was approved for,
67
+ * replacing a stored grant with the same cid. An elevated grant is never stored. A signed grant that spans several
68
+ * spaces arrives as several delegations with one cid; it is not stored, because a restore rebuilds its resources from
69
+ * the signed bytes, not from the delegation. A stored grant keeps its own signed expiry.
70
+ */
71
+ export declare function rememberAskedGrants(store: RuntimeGrantStore, address: string, grants: readonly PortableDelegation[], asker: string | undefined, isCurrent?: () => boolean): Promise<void>;
42
72
  export {};
43
73
  //# sourceMappingURL=runtimeGrantPersistence.d.ts.map
@@ -466,8 +466,23 @@ export declare class TinyCloudWeb {
466
466
  session: () => ClientSession | undefined;
467
467
  address: () => string | undefined;
468
468
  chainId: () => number | undefined;
469
- /** Returns whether the session or an unexpired runtime grant covers all entries. Never prompts. */
470
- hasPermissions(entries: PermissionEntry[]): boolean;
469
+ /**
470
+ * Returns whether the session or an unexpired runtime grant covers all entries. Never prompts. With
471
+ * `options.onBehalfOf`, only the session's own permissions and the grants approved for that app count; a grant
472
+ * approved for no app, or for another one, does not. Without it, every grant counts.
473
+ */
474
+ hasPermissions(entries: PermissionEntry[], options?: {
475
+ readonly onBehalfOf?: string;
476
+ }): boolean;
477
+ /** The apps each installed grant was approved for, by cid. Per node, so a new sign-in starts empty. */
478
+ private readonly grantAskers;
479
+ private grantAskersOf;
480
+ private grantCidsAskedBy;
481
+ /**
482
+ * Resolves once the grants kept from before a page reload are active again, or after at most four seconds. Never
483
+ * rejects. Call it before `hasPermissions` right after a reload, so an app is not under-granted.
484
+ */
485
+ permissionsReady(): Promise<void>;
471
486
  get did(): string;
472
487
  get sessionDid(): string;
473
488
  get credentialHolderDid(): string;
@@ -568,10 +583,22 @@ export declare class TinyCloudWeb {
568
583
  * `expiryMs` does not apply to them.
569
584
  *
570
585
  * `options.onBehalfOf` names the app the permissions are for when this
571
- * app asks on its behalf; the prompt names both. `options.allowPromptSuppression: false`
572
- * always shows the prompt, ignoring an earlier 30-day opt-out, and offers none.
586
+ * app asks on its behalf; the prompt names both. With it, only the session's own
587
+ * permissions and approvals given for that app count as already covering the request,
588
+ * and a new approval is signed for it even when another app's approval covers the same
589
+ * access. `options.allowPromptSuppression: false`
590
+ * always shows the prompt, ignoring an earlier 30-day opt-out, and offers none; a request
591
+ * to decrypt, create keys or read secrets always does so.
592
+ *
593
+ * An approved request that is not elevated (no decrypt or key creation, nothing in the secrets
594
+ * space, no caveats) is kept with the session and active again after a page reload, with its own
595
+ * signed expiry. An elevated one is not kept across a reload.
573
596
  */
574
597
  requestPermissions(additional: PermissionEntry[], options?: RequestPermissionsOptions): Promise<RequestPermissionsResult>;
598
+ /** `requestPermissions`; `keep` stores the issued non-elevated grants beside the session. The panel stores its own. */
599
+ private requestPermissionsKeeping;
600
+ /** Records which app approved each grant, and stores the non-elevated ones when `keep`. */
601
+ private keepGrants;
575
602
  /**
576
603
  * The signer a valid `setRuntimePermissionSigner` call bound to the current session, or undefined. A signer bound to a
577
604
  * session that has ended or been replaced is cleared.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/web-sdk",
3
- "version": "3.14.0-beta.11",
3
+ "version": "3.14.0-beta.13",
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",
@@ -67,9 +67,9 @@
67
67
  "@multiformats/multiaddr": "^13.0.1",
68
68
  "@multiformats/multiaddr-to-uri": "^12.0.0",
69
69
  "@noble/curves": "^1.9.7",
70
- "@tinycloud/node-sdk": "3.14.0-beta.11",
70
+ "@tinycloud/node-sdk": "3.14.0-beta.13",
71
71
  "@tinycloud/replica": "0.4.7-beta.0",
72
- "@tinycloud/sdk-core": "3.14.0-beta.11",
72
+ "@tinycloud/sdk-core": "3.14.0-beta.13",
73
73
  "@tinycloud/share-envelope": "1.6.0",
74
74
  "@tinycloud/share-sdk": "1.6.0",
75
75
  "@tinycloud/web-sdk-wasm": "1.8.0-beta.0",