@phreshos/client 0.1.35 → 0.1.36

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.
package/dist/main.d.ts CHANGED
@@ -3,4 +3,4 @@ export { desktop } from "./desktop/desktop.js";
3
3
  export { context, type Context, type ContextCapture, type ContextEvents, type ContextMessage, type ContextServer } from "./context.js";
4
4
  export { ClientService, ServerService, Service, clientPermissionCatalog, isPermissionName, type ServiceKey, } from "@phreshos/core";
5
5
  export { ClientEndpoint, Endpoint, Process, Program, ServerEndpoint, type Window, type ProgramProcess, type ProgramProcessRunEvent, type ProgramProcessRunOptions, type AnswerCapture, type AnswerMessage, type AnswerSubscriber, type AskCapture, type AskMessage, type AskSubscriber, type ClientTraffic, type EndpointTraffic, type ServerTraffic, type TrafficCapture, type TrafficEvents, type TrafficMessage } from "./domain.js";
6
- export type { Askable, AnswerOutcome, ClientContext, Capture, Captures, CaptureSubscriber, ClientLaunch, ClientDeclaration, Cleanup, DirectoryStat, EndpointDeclaration, EndpointLifecycle, EndpointLifecycleEvents, EntryStat, EventMessage, EventName, EventOptions, EventSubscriber, Exit, FileStat, Launch, ServerLaunch, ShellEvent, ShellOptions, Layer, LogKind, LogRecord, LogSource, Message, OtherStat, Permission, PermissionChange, PermissionDefinition, PermissionDefinitions, PermissionInput, PermissionName, PermissionRequest, PermissionValue, PermissionValueDomain, Permissions, ClientPermissionDeclarations, ClientPermissions, ContextPermissions, ProgramPermissions, TimedContextPermissions, Position, Storage, ProgramEvents, ProgramProcessEvents, ProgramProcessExit, ProgramStartup, ProgramSql, ProgramStore, ProcessEvents, Publishable, System, SystemUploads, Upload, Size, Subscribable, SubscribableEvents, SubscribableFallback, TimedAskable, Timeoutable, Appearance, AppearanceEvents, AppearanceSource, AppearanceSurface, AnimationsPreference, DesktopPreferences, DesktopPreferencesEvents, DesktopPreferencesSource, DesktopPreferencesUpdate, Desktop, DesktopSize, DesktopSurfaceEvents, DesktopSurfaceSnapshot, DesktopSurfaceSource, WritableDesktopPreferencesSource, ThemedValue, Theme, ThemePreference, Value, WindowEvents, WindowGeometry, WindowLayer, WindowState, Easing, LocalWindow, LocalWindowOperations, Transaction } from "@phreshos/core";
6
+ export type { Askable, AnswerOutcome, ClientContext, Capture, Captures, CaptureSubscriber, ClientLaunch, ClientDeclaration, Cleanup, DirectoryStat, EndpointDeclaration, EndpointLifecycle, EndpointLifecycleEvents, EntryStat, EventMessage, EventName, EventOptions, EventSubscriber, Exit, FileStat, Launch, ServerLaunch, ShellEvent, ShellOptions, Layer, LogKind, LogRecord, LogSource, Message, OtherStat, Permission, PermissionDefinition, PermissionDefinitions, PermissionInput, PermissionName, PermissionRequest, PermissionValue, PermissionValueDomain, Permissions, ClientPermissionDeclarations, ClientPermissions, ContextPermissions, ProgramPermissions, TimedContextPermissions, Position, Storage, ProgramEvents, ProgramProcessEvents, ProgramProcessExit, ProgramStartup, ProgramSql, ProgramStore, ProcessEvents, Publishable, System, SystemUploads, Upload, Size, Subscribable, SubscribableEvents, SubscribableFallback, TimedAskable, Timeoutable, Appearance, AppearanceEvents, AppearanceSource, AppearanceSurface, AnimationsPreference, DesktopPreferences, DesktopPreferencesEvents, DesktopPreferencesSource, DesktopPreferencesUpdate, Desktop, DesktopSize, DesktopSurfaceEvents, DesktopSurfaceSnapshot, DesktopSurfaceSource, WritableDesktopPreferencesSource, ThemedValue, Theme, ThemePreference, Value, WindowEvents, WindowGeometry, WindowLayer, WindowState, Easing, LocalWindow, LocalWindowOperations, Transaction } from "@phreshos/core";
@@ -1,4 +1,4 @@
1
- import { parsePermission, parsePermissionChange, parsePermissions } from "@phreshos/core";
1
+ import { parsePermission, parsePermissions } from "@phreshos/core";
2
2
  import wire from "./wire.js";
3
3
  export const defaultPermissionTimeout = 120_000;
4
4
  /** Bind authoritative stored grants to one exact Program handle. */
@@ -7,8 +7,9 @@ export function programPermissions(program) {
7
7
  return {
8
8
  async get(name) { return parsePermission(name, (await operate("get", name))[0]); },
9
9
  async all() { return parsePermissions((await operate("all"))[0]); },
10
- async set(name, permission) { return parsePermissionChange(name, (await operate("set", name, permission))[0]); },
11
- async delete(name) { return parsePermissionChange(name, (await operate("delete", name))[0]); }
10
+ async allows(name, permission = true) { return (await operate("allows", name, permission))[0] === true; },
11
+ async set(name, permission) { await operate("set", name, permission); },
12
+ async delete(name) { await operate("delete", name); }
12
13
  };
13
14
  }
14
15
  /** Stored grants and owner requests belonging to the current Client Endpoint. */
@@ -17,15 +18,16 @@ export function contextPermissions() {
17
18
  async request(name, permission = true) {
18
19
  const identity = crypto.randomUUID();
19
20
  const result = await wire.requestOrNull(["context-permission-request", identity, name, permission], timeout);
20
- return result === null
21
- ? Object.freeze({ permission: null, needReload: false })
22
- : parsePermissionChange(name, result[0]);
21
+ return result === null ? null : parsePermission(name, result[0]);
23
22
  }
24
23
  });
25
24
  return {
26
25
  async get(name) {
27
26
  return parsePermission(name, (await wire.request(["context-permission-get", name]))[0]);
28
27
  },
28
+ async allows(name, permission = true) {
29
+ return (await wire.request(["context-permission-allows", name, permission]))[0] === true;
30
+ },
29
31
  request: timed(defaultPermissionTimeout).request,
30
32
  timeout(milliseconds) {
31
33
  if (!Number.isFinite(milliseconds) || milliseconds < 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/client",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "The SDK used by a Program's client endpoint.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -47,13 +47,13 @@
47
47
  "prepack": "node --run build"
48
48
  },
49
49
  "peerDependencies": {
50
- "@phreshos/core": "^0.1.39"
50
+ "@phreshos/core": "^0.1.40"
51
51
  },
52
52
  "dependencies": {
53
53
  "@the-link/messagepack": "^0.1.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@phreshos/core": "^0.1.39",
56
+ "@phreshos/core": "^0.1.40",
57
57
  "typescript": "^6.0.3"
58
58
  }
59
59
  }