@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.
@@ -1096,6 +1096,21 @@ declare class TinyCloudNode {
1096
1096
  private registerPrimarySessionGrant;
1097
1097
  private writeManifestRegistryRecords;
1098
1098
  private scheduleAccountRegistrySync;
1099
+ /**
1100
+ * Whether the current primary session may invoke `tinycloud.space/list`.
1101
+ *
1102
+ * A session with NO parseable recap (session-only / restored-without-siwe)
1103
+ * yields zero recap operations — we preserve today's behavior and let
1104
+ * `syncAccessible()` run. A session whose parseable recap has entries but
1105
+ * none granting `tinycloud.space/list` cannot list owned spaces; the guard
1106
+ * skips. Every wallet SIWE session in this stack carries a recap (manifest
1107
+ * sessions and the default non-manifest recap alike), and none grant
1108
+ * `space/list`, so all of them skip.
1109
+ *
1110
+ * Reuses the TC-111 {@link recapOperationsFromSession} primitive — no second
1111
+ * recap parser.
1112
+ */
1113
+ private currentSessionCanListSpaces;
1099
1114
  private withAccountRegistryRetry;
1100
1115
  private requestedEncryptionNetworkIds;
1101
1116
  private ensureRequestedEncryptionNetworks;
@@ -1096,6 +1096,21 @@ declare class TinyCloudNode {
1096
1096
  private registerPrimarySessionGrant;
1097
1097
  private writeManifestRegistryRecords;
1098
1098
  private scheduleAccountRegistrySync;
1099
+ /**
1100
+ * Whether the current primary session may invoke `tinycloud.space/list`.
1101
+ *
1102
+ * A session with NO parseable recap (session-only / restored-without-siwe)
1103
+ * yields zero recap operations — we preserve today's behavior and let
1104
+ * `syncAccessible()` run. A session whose parseable recap has entries but
1105
+ * none granting `tinycloud.space/list` cannot list owned spaces; the guard
1106
+ * skips. Every wallet SIWE session in this stack carries a recap (manifest
1107
+ * sessions and the default non-manifest recap alike), and none grant
1108
+ * `space/list`, so all of them skip.
1109
+ *
1110
+ * Reuses the TC-111 {@link recapOperationsFromSession} primitive — no second
1111
+ * recap parser.
1112
+ */
1113
+ private currentSessionCanListSpaces;
1099
1114
  private withAccountRegistryRetry;
1100
1115
  private requestedEncryptionNetworkIds;
1101
1116
  private ensureRequestedEncryptionNetworks;
package/dist/core.cjs CHANGED
@@ -2518,12 +2518,38 @@ var _TinyCloudNode = class _TinyCloudNode {
2518
2518
  void this.withAccountRegistryRetry(async () => {
2519
2519
  void this.account.index.ensure();
2520
2520
  await this.writeManifestRegistryRecords();
2521
- const spaces = await this.account.spaces.syncAccessible();
2522
- if (!spaces.ok) {
2523
- throw new Error(`Failed to sync account spaces: ${spaces.error.message}`);
2521
+ if (this.currentSessionCanListSpaces()) {
2522
+ const spaces = await this.account.spaces.syncAccessible();
2523
+ if (!spaces.ok) {
2524
+ throw new Error(`Failed to sync account spaces: ${spaces.error.message}`);
2525
+ }
2524
2526
  }
2525
2527
  });
2526
2528
  }
2529
+ /**
2530
+ * Whether the current primary session may invoke `tinycloud.space/list`.
2531
+ *
2532
+ * A session with NO parseable recap (session-only / restored-without-siwe)
2533
+ * yields zero recap operations — we preserve today's behavior and let
2534
+ * `syncAccessible()` run. A session whose parseable recap has entries but
2535
+ * none granting `tinycloud.space/list` cannot list owned spaces; the guard
2536
+ * skips. Every wallet SIWE session in this stack carries a recap (manifest
2537
+ * sessions and the default non-manifest recap alike), and none grant
2538
+ * `space/list`, so all of them skip.
2539
+ *
2540
+ * Reuses the TC-111 {@link recapOperationsFromSession} primitive — no second
2541
+ * recap parser.
2542
+ */
2543
+ currentSessionCanListSpaces() {
2544
+ const session = this.currentTinyCloudSession();
2545
+ const operations = session ? this.recapOperationsFromSession(session) : [];
2546
+ if (operations.length === 0) {
2547
+ return true;
2548
+ }
2549
+ return operations.some(
2550
+ (operation) => operation.service === "space" && this.actionContains(operation.action, "tinycloud.space/list")
2551
+ );
2552
+ }
2527
2553
  async withAccountRegistryRetry(task) {
2528
2554
  const delays = [250, 1e3, 3e3];
2529
2555
  let lastError;
@@ -2532,6 +2558,14 @@ var _TinyCloudNode = class _TinyCloudNode {
2532
2558
  await task();
2533
2559
  return;
2534
2560
  } catch (error) {
2561
+ const message = error instanceof Error ? error.message : String(error);
2562
+ if (/Unauthorized Action|\b401\b/.test(message)) {
2563
+ console.warn(
2564
+ "TinyCloud account registry sync stopped: authorization verdict is not retryable",
2565
+ error
2566
+ );
2567
+ return;
2568
+ }
2535
2569
  lastError = error;
2536
2570
  if (attempt < delays.length - 1) {
2537
2571
  await new Promise((resolve) => setTimeout(resolve, delays[attempt]));