@tinycloud/node-sdk 2.6.0 → 2.6.1-beta.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.
package/dist/index.cjs CHANGED
@@ -19535,12 +19535,38 @@ var _TinyCloudNode = class _TinyCloudNode {
19535
19535
  void this.withAccountRegistryRetry(async () => {
19536
19536
  void this.account.index.ensure();
19537
19537
  await this.writeManifestRegistryRecords();
19538
- const spaces = await this.account.spaces.syncAccessible();
19539
- if (!spaces.ok) {
19540
- throw new Error(`Failed to sync account spaces: ${spaces.error.message}`);
19538
+ if (this.currentSessionCanListSpaces()) {
19539
+ const spaces = await this.account.spaces.syncAccessible();
19540
+ if (!spaces.ok) {
19541
+ throw new Error(`Failed to sync account spaces: ${spaces.error.message}`);
19542
+ }
19541
19543
  }
19542
19544
  });
19543
19545
  }
19546
+ /**
19547
+ * Whether the current primary session may invoke `tinycloud.space/list`.
19548
+ *
19549
+ * A session with NO parseable recap (session-only / restored-without-siwe)
19550
+ * yields zero recap operations — we preserve today's behavior and let
19551
+ * `syncAccessible()` run. A session whose parseable recap has entries but
19552
+ * none granting `tinycloud.space/list` cannot list owned spaces; the guard
19553
+ * skips. Every wallet SIWE session in this stack carries a recap (manifest
19554
+ * sessions and the default non-manifest recap alike), and none grant
19555
+ * `space/list`, so all of them skip.
19556
+ *
19557
+ * Reuses the TC-111 {@link recapOperationsFromSession} primitive — no second
19558
+ * recap parser.
19559
+ */
19560
+ currentSessionCanListSpaces() {
19561
+ const session = this.currentTinyCloudSession();
19562
+ const operations = session ? this.recapOperationsFromSession(session) : [];
19563
+ if (operations.length === 0) {
19564
+ return true;
19565
+ }
19566
+ return operations.some(
19567
+ (operation) => operation.service === "space" && this.actionContains(operation.action, "tinycloud.space/list")
19568
+ );
19569
+ }
19544
19570
  async withAccountRegistryRetry(task) {
19545
19571
  const delays = [250, 1e3, 3e3];
19546
19572
  let lastError;
@@ -19549,6 +19575,14 @@ var _TinyCloudNode = class _TinyCloudNode {
19549
19575
  await task();
19550
19576
  return;
19551
19577
  } catch (error) {
19578
+ const message = error instanceof Error ? error.message : String(error);
19579
+ if (/Unauthorized Action|\b401\b/.test(message)) {
19580
+ console.warn(
19581
+ "TinyCloud account registry sync stopped: authorization verdict is not retryable",
19582
+ error
19583
+ );
19584
+ return;
19585
+ }
19552
19586
  lastError = error;
19553
19587
  if (attempt < delays.length - 1) {
19554
19588
  await new Promise((resolve) => setTimeout(resolve, delays[attempt]));