@tinycloud/node-sdk 3.8.0-beta.11 → 3.8.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.
@@ -106,6 +106,26 @@ declare class FileSessionStorage implements ISessionStorage {
106
106
  isAvailable(): boolean;
107
107
  }
108
108
 
109
+ /**
110
+ * Whether sign-in at `origin` can be granted named-key abilities for the app
111
+ * whose manifest `keys_app_id` (or `app_id`) is `keysAppId`.
112
+ *
113
+ * "Bound" means the key app id equals the reversed host of the origin, or
114
+ * extends it with further dot-separated labels: `tinycloud.chat` binds
115
+ * `chat.tinycloud.tinychat` and `chat.tinycloud.tinychat.worker`. Origins with
116
+ * no registrable host (`localhost`, `tauri.localhost`, IP addresses) or with
117
+ * lookalike hosts (`evil-tinycloud.chat`, `tinycloud.chat.evil.com`) are not
118
+ * bound. `origin` is a URL, an origin string such as `https://tinycloud.chat`,
119
+ * or a bare SIWE domain such as `tinycloud.chat`; the host (including any
120
+ * non-default port, which makes the origin unbound) is what is checked.
121
+ *
122
+ * This is the check `NodeUserAuthorization` applies when it decides whether a
123
+ * manifest's `keys` rows are granted at sign-in. A bound origin still needs a
124
+ * node that lists `encryption-named-keys-v1` in `/info` to actually receive
125
+ * the row.
126
+ */
127
+ declare function isAppKeyHostBound(keysAppId: string, origin: string | URL): boolean;
128
+
109
129
  /**
110
130
  * WasmKeyProvider - KeyProvider implementation using WASM session manager.
111
131
  *
@@ -214,4 +234,4 @@ declare class WasmKeyProvider implements KeyProvider {
214
234
  */
215
235
  declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
216
236
 
217
- export { FileSessionStorage as F, MemorySessionStorage as M, WasmKeyProvider as W, type WasmKeyProviderConfig as a, createWasmKeyProvider as c };
237
+ export { FileSessionStorage as F, MemorySessionStorage as M, WasmKeyProvider as W, type WasmKeyProviderConfig as a, createWasmKeyProvider as c, isAppKeyHostBound as i };
@@ -106,6 +106,26 @@ declare class FileSessionStorage implements ISessionStorage {
106
106
  isAvailable(): boolean;
107
107
  }
108
108
 
109
+ /**
110
+ * Whether sign-in at `origin` can be granted named-key abilities for the app
111
+ * whose manifest `keys_app_id` (or `app_id`) is `keysAppId`.
112
+ *
113
+ * "Bound" means the key app id equals the reversed host of the origin, or
114
+ * extends it with further dot-separated labels: `tinycloud.chat` binds
115
+ * `chat.tinycloud.tinychat` and `chat.tinycloud.tinychat.worker`. Origins with
116
+ * no registrable host (`localhost`, `tauri.localhost`, IP addresses) or with
117
+ * lookalike hosts (`evil-tinycloud.chat`, `tinycloud.chat.evil.com`) are not
118
+ * bound. `origin` is a URL, an origin string such as `https://tinycloud.chat`,
119
+ * or a bare SIWE domain such as `tinycloud.chat`; the host (including any
120
+ * non-default port, which makes the origin unbound) is what is checked.
121
+ *
122
+ * This is the check `NodeUserAuthorization` applies when it decides whether a
123
+ * manifest's `keys` rows are granted at sign-in. A bound origin still needs a
124
+ * node that lists `encryption-named-keys-v1` in `/info` to actually receive
125
+ * the row.
126
+ */
127
+ declare function isAppKeyHostBound(keysAppId: string, origin: string | URL): boolean;
128
+
109
129
  /**
110
130
  * WasmKeyProvider - KeyProvider implementation using WASM session manager.
111
131
  *
@@ -214,4 +234,4 @@ declare class WasmKeyProvider implements KeyProvider {
214
234
  */
215
235
  declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
216
236
 
217
- export { FileSessionStorage as F, MemorySessionStorage as M, WasmKeyProvider as W, type WasmKeyProviderConfig as a, createWasmKeyProvider as c };
237
+ export { FileSessionStorage as F, MemorySessionStorage as M, WasmKeyProvider as W, type WasmKeyProviderConfig as a, createWasmKeyProvider as c, isAppKeyHostBound as i };
package/dist/core.cjs CHANGED
@@ -111,6 +111,7 @@ __export(core_exports, {
111
111
  getNodeReplicationLoaders: () => getNodeReplicationLoaders,
112
112
  getTinyCloudDebugLogs: () => import_sdk_core13.getTinyCloudDebugLogs,
113
113
  installTinyCloudDebugGlobals: () => import_sdk_core13.installTinyCloudDebugGlobals,
114
+ isAppKeyHostBound: () => isAppKeyHostBound,
114
115
  isCapabilitySubset: () => import_sdk_core14.isCapabilitySubset,
115
116
  isEvmAddress: () => import_sdk_core13.isEvmAddress,
116
117
  loadManifest: () => import_sdk_core14.loadManifest,
@@ -374,6 +375,18 @@ function appKeyHostBinding(domain, appId) {
374
375
  const reversed = labels.reverse().join(".");
375
376
  return appId === reversed || appId.startsWith(`${reversed}.`);
376
377
  }
378
+ function isAppKeyHostBound(keysAppId, origin) {
379
+ if (typeof origin === "string" && !origin.includes("://")) {
380
+ return appKeyHostBinding(origin, keysAppId);
381
+ }
382
+ let url;
383
+ try {
384
+ url = typeof origin === "string" ? new URL(origin) : origin;
385
+ } catch {
386
+ return false;
387
+ }
388
+ return appKeyHostBinding(url.host, keysAppId);
389
+ }
377
390
 
378
391
  // src/replication/authority-sign-in.ts
379
392
  var import_sdk_core2 = require("@tinycloud/sdk-core");
@@ -10325,6 +10338,7 @@ var import_sdk_core23 = require("@tinycloud/sdk-core");
10325
10338
  getNodeReplicationLoaders,
10326
10339
  getTinyCloudDebugLogs,
10327
10340
  installTinyCloudDebugGlobals,
10341
+ isAppKeyHostBound,
10328
10342
  isCapabilitySubset,
10329
10343
  isEvmAddress,
10330
10344
  loadManifest,