@le-space/rootfs 0.6.24 → 0.6.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/rootfs",
3
- "version": "0.6.24",
3
+ "version": "0.6.25",
4
4
  "description": "Shared rootfs contract parsing, reference profile assets, and build helpers.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,9 +27,7 @@ DESCRIBE_SCRIPT = os.environ.get(
27
27
  DEFAULT_API_HOST = os.environ.get("ALEPH_BOOTSTRAP_API_HOST", "https://api.aleph.im")
28
28
  DEFAULT_CHANNEL = os.environ.get("ALEPH_BOOTSTRAP_CHANNEL", "simple-todo")
29
29
  DEFAULT_REF = os.environ.get("ALEPH_BOOTSTRAP_REF", "simple-todo-bootstrap")
30
- COMPACT_POST_TYPE = "relay-bootstrap-v2"
31
- LEGACY_POST_TYPE = "relay-bootstrap"
32
- DEFAULT_POST_TYPE = os.environ.get("ALEPH_BOOTSTRAP_POST_TYPE", COMPACT_POST_TYPE)
30
+ POST_TYPE = "relay-bootstrap-v2"
33
31
  DEFAULT_PROFILE = os.environ.get("ALEPH_BOOTSTRAP_PROFILE", "orbitdb-relay")
34
32
  MAX_PREVIOUS_PAGES = int(os.environ.get("ALEPH_BOOTSTRAP_MAX_PREVIOUS_PAGES", "5"))
35
33
  PAGINATION = int(os.environ.get("ALEPH_BOOTSTRAP_PAGINATION", "50"))
@@ -430,6 +428,15 @@ def parse_post_record(entry: object) -> dict[str, object] | None:
430
428
  item_content = None
431
429
 
432
430
  content_source = item_content if isinstance(item_content, dict) else entry
431
+ record_type = content_source.get("type")
432
+ if record_type == "relay-bootstrap":
433
+ raise RuntimeError(
434
+ "Legacy relay-bootstrap record encountered. Only relay-bootstrap-v2 is supported."
435
+ )
436
+ if isinstance(record_type, str) and record_type and record_type != POST_TYPE:
437
+ raise RuntimeError(
438
+ f"Unsupported relay bootstrap post type: {record_type}. Expected {POST_TYPE}."
439
+ )
433
440
  content = content_source.get("content")
434
441
  if not isinstance(content, dict):
435
442
  return None
@@ -465,7 +472,7 @@ def fetch_previous_hashes(
465
472
  api_host: str,
466
473
  channel: str,
467
474
  ref: str,
468
- post_types: list[str],
475
+ post_type: str,
469
476
  sender: str,
470
477
  current_item_hash: str,
471
478
  now_ms: int,
@@ -473,38 +480,37 @@ def fetch_previous_hashes(
473
480
  stale_cutoff_ms = now_ms - (STALE_RECORD_MAX_AGE_SECONDS * 1000)
474
481
  normalized_sender = normalize_address(sender)
475
482
  found: list[str] = []
476
- for post_type in post_types:
477
- for page in range(1, MAX_PREVIOUS_PAGES + 1):
478
- url = (
479
- f"{api_host.rstrip('/')}/api/v0/posts.json?"
480
- f"channels={urllib.parse.quote(channel)}&"
481
- f"refs={urllib.parse.quote(ref)}&"
482
- f"types={urllib.parse.quote(post_type)}&"
483
- f"pagination={PAGINATION}&page={page}"
484
- )
485
- payload = get_json(url)
486
- posts = payload.get("posts")
487
- if not isinstance(posts, list):
488
- break
489
-
490
- for entry in posts:
491
- parsed = parse_post_record(entry)
492
- if parsed is None:
493
- continue
494
- same_publisher = normalized_sender in {
495
- normalize_address(parsed["sender"]),
496
- normalize_address(parsed["publisher_address"]),
497
- }
498
- if not same_publisher:
499
- continue
500
- if parsed["item_hash"] == current_item_hash:
501
- continue
502
- updated_at = timestamp_ms(parsed["updated_at"])
503
- if updated_at is not None and updated_at < stale_cutoff_ms:
504
- found.append(str(parsed["item_hash"]))
505
-
506
- if len(posts) < PAGINATION:
507
- break
483
+ for page in range(1, MAX_PREVIOUS_PAGES + 1):
484
+ url = (
485
+ f"{api_host.rstrip('/')}/api/v0/posts.json?"
486
+ f"channels={urllib.parse.quote(channel)}&"
487
+ f"refs={urllib.parse.quote(ref)}&"
488
+ f"types={urllib.parse.quote(post_type)}&"
489
+ f"pagination={PAGINATION}&page={page}"
490
+ )
491
+ payload = get_json(url)
492
+ posts = payload.get("posts")
493
+ if not isinstance(posts, list):
494
+ break
495
+
496
+ for entry in posts:
497
+ parsed = parse_post_record(entry)
498
+ if parsed is None:
499
+ continue
500
+ same_publisher = normalized_sender in {
501
+ normalize_address(parsed["sender"]),
502
+ normalize_address(parsed["publisher_address"]),
503
+ }
504
+ if not same_publisher:
505
+ continue
506
+ if parsed["item_hash"] == current_item_hash:
507
+ continue
508
+ updated_at = timestamp_ms(parsed["updated_at"])
509
+ if updated_at is not None and updated_at < stale_cutoff_ms:
510
+ found.append(str(parsed["item_hash"]))
511
+
512
+ if len(posts) < PAGINATION:
513
+ break
508
514
 
509
515
  return dedupe(found)
510
516
 
@@ -568,18 +574,16 @@ def main() -> None:
568
574
  version = env_values.get("ALEPH_BOOTSTRAP_VERSION", "").strip() or None
569
575
  channel = env_values.get("ALEPH_BOOTSTRAP_CHANNEL", DEFAULT_CHANNEL).strip() or DEFAULT_CHANNEL
570
576
  ref = env_values.get("ALEPH_BOOTSTRAP_REF", DEFAULT_REF).strip() or DEFAULT_REF
571
- post_type = env_values.get("ALEPH_BOOTSTRAP_POST_TYPE", DEFAULT_POST_TYPE).strip() or DEFAULT_POST_TYPE
577
+ post_type = env_values.get("ALEPH_BOOTSTRAP_POST_TYPE", POST_TYPE).strip() or POST_TYPE
578
+ if post_type != POST_TYPE:
579
+ raise RuntimeError(
580
+ f"Unsupported ALEPH_BOOTSTRAP_POST_TYPE: {post_type}. Expected {POST_TYPE}."
581
+ )
572
582
  api_host = env_values.get("ALEPH_BOOTSTRAP_API_HOST", DEFAULT_API_HOST).strip() or DEFAULT_API_HOST
573
- compact = post_type == COMPACT_POST_TYPE
574
- published_multiaddrs = (
575
- select_compact_multiaddrs(browser_multiaddrs or multiaddrs)
576
- if compact
577
- else multiaddrs
578
- )
579
- published_browser_multiaddrs = [] if compact else browser_multiaddrs
583
+ published_multiaddrs = select_compact_multiaddrs(browser_multiaddrs or multiaddrs)
584
+ published_browser_multiaddrs: list[str] = []
580
585
  if not published_multiaddrs:
581
- reason = "no public browser multiaddrs" if compact else "no public multiaddrs"
582
- print(json_dumps({"status": "skipped", "reason": reason}))
586
+ print(json_dumps({"status": "skipped", "reason": "no public browser multiaddrs"}))
583
587
  return
584
588
 
585
589
  owner_authorization = load_owner_authorization(
@@ -634,7 +638,7 @@ def main() -> None:
634
638
  api_host,
635
639
  channel,
636
640
  ref,
637
- [post_type, LEGACY_POST_TYPE] if compact else [post_type],
641
+ post_type,
638
642
  publisher_address,
639
643
  str(unsigned_message["item_hash"]),
640
644
  now_ms,
@@ -23,7 +23,7 @@ DESCRIBE_SCRIPT = os.environ.get("DESCRIBE_SCRIPT", "/usr/local/sbin/uc-go-peer-
23
23
  DEFAULT_API_HOST = os.environ.get("ALEPH_BOOTSTRAP_API_HOST", "https://api.aleph.im")
24
24
  DEFAULT_CHANNEL = os.environ.get("ALEPH_BOOTSTRAP_CHANNEL", "simple-todo")
25
25
  DEFAULT_REF = os.environ.get("ALEPH_BOOTSTRAP_REF", "simple-todo-bootstrap")
26
- DEFAULT_POST_TYPE = os.environ.get("ALEPH_BOOTSTRAP_POST_TYPE", "relay-bootstrap")
26
+ POST_TYPE = "relay-bootstrap-v2"
27
27
  MAX_PREVIOUS_PAGES = int(os.environ.get("ALEPH_BOOTSTRAP_MAX_PREVIOUS_PAGES", "5"))
28
28
  PAGINATION = int(os.environ.get("ALEPH_BOOTSTRAP_PAGINATION", "50"))
29
29
 
@@ -185,6 +185,16 @@ def parse_post_record(entry: object) -> dict[str, object] | None:
185
185
  if not isinstance(item_content, dict):
186
186
  return None
187
187
 
188
+ record_type = item_content.get("type")
189
+ if record_type == "relay-bootstrap":
190
+ raise RuntimeError(
191
+ "Legacy relay-bootstrap record encountered. Only relay-bootstrap-v2 is supported."
192
+ )
193
+ if isinstance(record_type, str) and record_type and record_type != POST_TYPE:
194
+ raise RuntimeError(
195
+ f"Unsupported relay bootstrap post type: {record_type}. Expected {POST_TYPE}."
196
+ )
197
+
188
198
  content = item_content.get("content")
189
199
  if not isinstance(content, dict):
190
200
  return None
@@ -297,7 +307,11 @@ def main() -> None:
297
307
  peer_id = load_peer_id()
298
308
  channel = env_values.get("ALEPH_BOOTSTRAP_CHANNEL", DEFAULT_CHANNEL).strip() or DEFAULT_CHANNEL
299
309
  ref = env_values.get("ALEPH_BOOTSTRAP_REF", DEFAULT_REF).strip() or DEFAULT_REF
300
- post_type = env_values.get("ALEPH_BOOTSTRAP_POST_TYPE", DEFAULT_POST_TYPE).strip() or DEFAULT_POST_TYPE
310
+ post_type = env_values.get("ALEPH_BOOTSTRAP_POST_TYPE", POST_TYPE).strip() or POST_TYPE
311
+ if post_type != POST_TYPE:
312
+ raise RuntimeError(
313
+ f"Unsupported ALEPH_BOOTSTRAP_POST_TYPE: {post_type}. Expected {POST_TYPE}."
314
+ )
301
315
  api_host = env_values.get("ALEPH_BOOTSTRAP_API_HOST", DEFAULT_API_HOST).strip() or DEFAULT_API_HOST
302
316
 
303
317
  hashes = fetch_current_hashes(
@@ -25,9 +25,7 @@ DESCRIBE_SCRIPT = os.environ.get("DESCRIBE_SCRIPT", "/usr/local/sbin/uc-go-peer-
25
25
  DEFAULT_API_HOST = os.environ.get("ALEPH_BOOTSTRAP_API_HOST", "https://api.aleph.im")
26
26
  DEFAULT_CHANNEL = os.environ.get("ALEPH_BOOTSTRAP_CHANNEL", "simple-todo")
27
27
  DEFAULT_REF = os.environ.get("ALEPH_BOOTSTRAP_REF", "simple-todo-bootstrap")
28
- COMPACT_POST_TYPE = "relay-bootstrap-v2"
29
- LEGACY_POST_TYPE = "relay-bootstrap"
30
- DEFAULT_POST_TYPE = os.environ.get("ALEPH_BOOTSTRAP_POST_TYPE", COMPACT_POST_TYPE)
28
+ POST_TYPE = "relay-bootstrap-v2"
31
29
  DEFAULT_PROFILE = os.environ.get("ALEPH_BOOTSTRAP_PROFILE", "uc-go-peer")
32
30
  MAX_PREVIOUS_PAGES = int(os.environ.get("ALEPH_BOOTSTRAP_MAX_PREVIOUS_PAGES", "5"))
33
31
  PAGINATION = int(os.environ.get("ALEPH_BOOTSTRAP_PAGINATION", "50"))
@@ -442,6 +440,15 @@ def parse_post_record(entry: object) -> dict[str, object] | None:
442
440
  item_content = None
443
441
 
444
442
  content_source = item_content if isinstance(item_content, dict) else entry
443
+ record_type = content_source.get("type")
444
+ if record_type == "relay-bootstrap":
445
+ raise RuntimeError(
446
+ "Legacy relay-bootstrap record encountered. Only relay-bootstrap-v2 is supported."
447
+ )
448
+ if isinstance(record_type, str) and record_type and record_type != POST_TYPE:
449
+ raise RuntimeError(
450
+ f"Unsupported relay bootstrap post type: {record_type}. Expected {POST_TYPE}."
451
+ )
445
452
  content = content_source.get("content")
446
453
  if not isinstance(content, dict):
447
454
  return None
@@ -477,7 +484,7 @@ def fetch_previous_hashes(
477
484
  api_host: str,
478
485
  channel: str,
479
486
  ref: str,
480
- post_types: list[str],
487
+ post_type: str,
481
488
  sender: str,
482
489
  current_item_hash: str,
483
490
  now_ms: int,
@@ -485,38 +492,37 @@ def fetch_previous_hashes(
485
492
  stale_cutoff_ms = now_ms - (STALE_RECORD_MAX_AGE_SECONDS * 1000)
486
493
  normalized_sender = normalize_address(sender)
487
494
  found: list[str] = []
488
- for post_type in post_types:
489
- for page in range(1, MAX_PREVIOUS_PAGES + 1):
490
- url = (
491
- f"{api_host.rstrip('/')}/api/v0/posts.json?"
492
- f"channels={urllib.parse.quote(channel)}&"
493
- f"refs={urllib.parse.quote(ref)}&"
494
- f"types={urllib.parse.quote(post_type)}&"
495
- f"pagination={PAGINATION}&page={page}"
496
- )
497
- payload = get_json(url)
498
- posts = payload.get("posts")
499
- if not isinstance(posts, list):
500
- break
501
-
502
- for entry in posts:
503
- parsed = parse_post_record(entry)
504
- if parsed is None:
505
- continue
506
- same_publisher = normalized_sender in {
507
- normalize_address(parsed["sender"]),
508
- normalize_address(parsed["publisher_address"]),
509
- }
510
- if not same_publisher:
511
- continue
512
- if parsed["item_hash"] == current_item_hash:
513
- continue
514
- updated_at = timestamp_ms(parsed["updated_at"])
515
- if updated_at is not None and updated_at < stale_cutoff_ms:
516
- found.append(str(parsed["item_hash"]))
517
-
518
- if len(posts) < PAGINATION:
519
- break
495
+ for page in range(1, MAX_PREVIOUS_PAGES + 1):
496
+ url = (
497
+ f"{api_host.rstrip('/')}/api/v0/posts.json?"
498
+ f"channels={urllib.parse.quote(channel)}&"
499
+ f"refs={urllib.parse.quote(ref)}&"
500
+ f"types={urllib.parse.quote(post_type)}&"
501
+ f"pagination={PAGINATION}&page={page}"
502
+ )
503
+ payload = get_json(url)
504
+ posts = payload.get("posts")
505
+ if not isinstance(posts, list):
506
+ break
507
+
508
+ for entry in posts:
509
+ parsed = parse_post_record(entry)
510
+ if parsed is None:
511
+ continue
512
+ same_publisher = normalized_sender in {
513
+ normalize_address(parsed["sender"]),
514
+ normalize_address(parsed["publisher_address"]),
515
+ }
516
+ if not same_publisher:
517
+ continue
518
+ if parsed["item_hash"] == current_item_hash:
519
+ continue
520
+ updated_at = timestamp_ms(parsed["updated_at"])
521
+ if updated_at is not None and updated_at < stale_cutoff_ms:
522
+ found.append(str(parsed["item_hash"]))
523
+
524
+ if len(posts) < PAGINATION:
525
+ break
520
526
 
521
527
  return dedupe(found)
522
528
 
@@ -580,18 +586,16 @@ def main() -> None:
580
586
  version = env_values.get("ALEPH_BOOTSTRAP_VERSION", "").strip() or None
581
587
  channel = env_values.get("ALEPH_BOOTSTRAP_CHANNEL", DEFAULT_CHANNEL).strip() or DEFAULT_CHANNEL
582
588
  ref = env_values.get("ALEPH_BOOTSTRAP_REF", DEFAULT_REF).strip() or DEFAULT_REF
583
- post_type = env_values.get("ALEPH_BOOTSTRAP_POST_TYPE", DEFAULT_POST_TYPE).strip() or DEFAULT_POST_TYPE
589
+ post_type = env_values.get("ALEPH_BOOTSTRAP_POST_TYPE", POST_TYPE).strip() or POST_TYPE
590
+ if post_type != POST_TYPE:
591
+ raise RuntimeError(
592
+ f"Unsupported ALEPH_BOOTSTRAP_POST_TYPE: {post_type}. Expected {POST_TYPE}."
593
+ )
584
594
  api_host = env_values.get("ALEPH_BOOTSTRAP_API_HOST", DEFAULT_API_HOST).strip() or DEFAULT_API_HOST
585
- compact = post_type == COMPACT_POST_TYPE
586
- published_multiaddrs = (
587
- select_compact_multiaddrs(browser_multiaddrs or multiaddrs)
588
- if compact
589
- else multiaddrs
590
- )
591
- published_browser_multiaddrs = [] if compact else browser_multiaddrs
595
+ published_multiaddrs = select_compact_multiaddrs(browser_multiaddrs or multiaddrs)
596
+ published_browser_multiaddrs: list[str] = []
592
597
  if not published_multiaddrs:
593
- reason = "no public browser multiaddrs" if compact else "no public multiaddrs"
594
- print(json_dumps({"status": "skipped", "reason": reason}))
598
+ print(json_dumps({"status": "skipped", "reason": "no public browser multiaddrs"}))
595
599
  return
596
600
 
597
601
  owner_authorization = load_owner_authorization(
@@ -646,7 +650,7 @@ def main() -> None:
646
650
  api_host,
647
651
  channel,
648
652
  ref,
649
- [post_type, LEGACY_POST_TYPE] if compact else [post_type],
653
+ post_type,
650
654
  publisher_address,
651
655
  str(unsigned_message["item_hash"]),
652
656
  now_ms,