@tinycloud/node-sdk 2.3.1-beta.0 → 2.4.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.
package/dist/index.cjs CHANGED
@@ -18987,6 +18987,52 @@ var _TinyCloudNode = class _TinyCloudNode {
18987
18987
  );
18988
18988
  }
18989
18989
  }
18990
+ /**
18991
+ * Host one of this user's owned spaces by name (e.g. `"applications"`).
18992
+ *
18993
+ * Resolves the name to the owned space URI
18994
+ * (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`) and registers it on the
18995
+ * server via the host-SIWE delegation flow, so subsequent KV/SQL writes to
18996
+ * that space succeed instead of returning `404 - Space not found`. The
18997
+ * caller is the root authority of their own owned spaces, so no additional
18998
+ * delegation is required.
18999
+ *
19000
+ * Unlike {@link ensureOwnedSpaceHosted}, this always submits the host
19001
+ * delegation rather than inferring hosting from session activation: a space
19002
+ * the current session has never referenced is reported neither as
19003
+ * `activated` nor `skipped`, so activation-based detection would wrongly
19004
+ * skip the host. The host SIWE is idempotent server-side, so re-hosting an
19005
+ * existing space is a safe no-op. Must be called after {@link signIn}.
19006
+ *
19007
+ * @param name - The owned space name (e.g. `"applications"`).
19008
+ * @returns The hosted space URI.
19009
+ */
19010
+ async hostOwnedSpace(name) {
19011
+ if (!this.auth || !this.auth.tinyCloudSession) {
19012
+ throw new Error("Not signed in. Call signIn() first.");
19013
+ }
19014
+ const spaceId = this.ownedSpaceId(name);
19015
+ const host = this.hosts[0] ?? this.config.host;
19016
+ if (!host) {
19017
+ throw new Error("Owned space hosting requires a TinyCloud host");
19018
+ }
19019
+ const hosted = await this.auth.hostOwnedSpace(
19020
+ spaceId
19021
+ );
19022
+ if (!hosted) {
19023
+ throw new Error(`Failed to host owned space: ${spaceId}`);
19024
+ }
19025
+ const activation = await (0, import_sdk_core5.activateSessionWithHost)(
19026
+ host,
19027
+ this.auth.tinyCloudSession.delegationHeader
19028
+ );
19029
+ if (!activation.success || activation.skipped?.includes(spaceId)) {
19030
+ throw new Error(
19031
+ `Failed to activate session for owned space ${spaceId}: ${activation.error ?? "space was skipped"}`
19032
+ );
19033
+ }
19034
+ return spaceId;
19035
+ }
18990
19036
  /**
18991
19037
  * Restore a previously established session from stored delegation data.
18992
19038
  *