@le-space/core 0.6.24 → 0.6.26

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.
Files changed (3) hide show
  1. package/index.d.ts +0 -3
  2. package/index.js +48 -48
  3. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -790,7 +790,6 @@ declare function waitForRelayBootstrapRegistration(args: {
790
790
  apiHost?: string;
791
791
  channel?: string;
792
792
  ref?: string;
793
- postType?: string;
794
793
  attempts?: number;
795
794
  delayMs?: number;
796
795
  sleep?: (ms: number) => Promise<void>;
@@ -808,7 +807,6 @@ declare function publishRelayBootstrapRegistration(args: {
808
807
  apiHost?: string;
809
808
  channel?: string;
810
809
  ref?: string;
811
- postType?: string;
812
810
  compactMultiaddrLimit?: number;
813
811
  profile?: string;
814
812
  version?: string;
@@ -954,7 +952,6 @@ declare function reconcileOwnerRelayBootstrapRegistrations(args: {
954
952
  apiHost?: string;
955
953
  channel?: string;
956
954
  ref?: string;
957
- postType?: string;
958
955
  version?: string;
959
956
  ownerAddress?: string;
960
957
  ownerSigner?: MessageSigner;
package/index.js CHANGED
@@ -2431,8 +2431,7 @@ async function verifyUcGoPeerReachability(args) {
2431
2431
  var DEFAULT_ALEPH_API_HOST2 = "https://api.aleph.im";
2432
2432
  var DEFAULT_ALEPH_BOOTSTRAP_CHANNEL = "simple-todo";
2433
2433
  var DEFAULT_ALEPH_BOOTSTRAP_REF = "simple-todo-bootstrap";
2434
- var DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE = "relay-bootstrap";
2435
- var DEFAULT_ALEPH_BOOTSTRAP_COMPACT_POST_TYPE = "relay-bootstrap-v2";
2434
+ var DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE = "relay-bootstrap-v2";
2436
2435
  var DEFAULT_BOOTSTRAP_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
2437
2436
  var DEFAULT_BOOTSTRAP_PAGINATION = 50;
2438
2437
  var DEFAULT_BOOTSTRAP_COMPACT_MULTIADDR_LIMIT = 3;
@@ -2466,9 +2465,6 @@ function serializeRelayProofPayload(payload) {
2466
2465
  function relayBootstrapMultiaddrsHash(addrs) {
2467
2466
  return keccak256(stringToHex(JSON.stringify(dedupeMultiaddrs(addrs))));
2468
2467
  }
2469
- function compactPostType(postType) {
2470
- return (postType ?? DEFAULT_ALEPH_BOOTSTRAP_COMPACT_POST_TYPE) === DEFAULT_ALEPH_BOOTSTRAP_COMPACT_POST_TYPE;
2471
- }
2472
2468
  function browserMultiaddrPreference(addr) {
2473
2469
  const normalized = addr.toLowerCase();
2474
2470
  if (normalized.includes("/tcp/443/tls/ws/")) return 0;
@@ -2482,7 +2478,8 @@ function browserMultiaddrTransport(addr) {
2482
2478
  const normalized = addr.toLowerCase();
2483
2479
  if (normalized.includes("/webtransport/")) return "webtransport";
2484
2480
  if (normalized.includes("/webrtc-direct/")) return "webrtc";
2485
- if (normalized.includes("/ws") || normalized.includes("/wss")) return "websocket";
2481
+ if (normalized.includes("/ws") || normalized.includes("/wss"))
2482
+ return "websocket";
2486
2483
  return "other";
2487
2484
  }
2488
2485
  function selectCompactRelayBootstrapMultiaddrs(addrs, limit = DEFAULT_BOOTSTRAP_COMPACT_MULTIADDR_LIMIT) {
@@ -2559,7 +2556,10 @@ function hasPeerId(addr) {
2559
2556
  }
2560
2557
  function isBrowserDialableMultiaddr(addr) {
2561
2558
  const normalized = addr.toLowerCase();
2562
- return normalized.includes("/ws") || normalized.includes("/wss") || normalized.includes("/webtransport") || normalized.includes("/webrtc-direct");
2559
+ if (normalized.includes("/webtransport") || normalized.includes("/webrtc-direct")) {
2560
+ return normalized.includes("/certhash/");
2561
+ }
2562
+ return normalized.includes("/ws") || normalized.includes("/wss");
2563
2563
  }
2564
2564
  function dedupeMultiaddrs(addrs) {
2565
2565
  const seen = /* @__PURE__ */ new Set();
@@ -2605,8 +2605,12 @@ function normalizeRelayBootstrapContent(value) {
2605
2605
  const peerId = asTrimmedString(content.peerId);
2606
2606
  const updatedAt = asNumber3(content.updatedAt);
2607
2607
  if (!peerId || updatedAt == null) return null;
2608
- const multiaddrs = Array.isArray(content.multiaddrs) ? content.multiaddrs.filter((entry) => typeof entry === "string") : [];
2609
- const browserMultiaddrs = Array.isArray(content.browserMultiaddrs) ? content.browserMultiaddrs.filter((entry) => typeof entry === "string") : void 0;
2608
+ const multiaddrs = Array.isArray(content.multiaddrs) ? content.multiaddrs.filter(
2609
+ (entry) => typeof entry === "string"
2610
+ ) : [];
2611
+ const browserMultiaddrs = Array.isArray(content.browserMultiaddrs) ? content.browserMultiaddrs.filter(
2612
+ (entry) => typeof entry === "string"
2613
+ ) : void 0;
2610
2614
  return {
2611
2615
  peerId,
2612
2616
  multiaddrs: dedupeMultiaddrs(multiaddrs),
@@ -2659,8 +2663,12 @@ function normalizeRelayBootstrapProofPayload(value) {
2659
2663
  const peerId = asTrimmedString(payload.peerId);
2660
2664
  const updatedAt = asNumber3(payload.updatedAt);
2661
2665
  if (!peerId || updatedAt == null) return null;
2662
- const multiaddrs = Array.isArray(payload.multiaddrs) ? payload.multiaddrs.filter((entry) => typeof entry === "string") : [];
2663
- const browserMultiaddrs = Array.isArray(payload.browserMultiaddrs) ? payload.browserMultiaddrs.filter((entry) => typeof entry === "string") : void 0;
2666
+ const multiaddrs = Array.isArray(payload.multiaddrs) ? payload.multiaddrs.filter(
2667
+ (entry) => typeof entry === "string"
2668
+ ) : [];
2669
+ const browserMultiaddrs = Array.isArray(payload.browserMultiaddrs) ? payload.browserMultiaddrs.filter(
2670
+ (entry) => typeof entry === "string"
2671
+ ) : void 0;
2664
2672
  return {
2665
2673
  peerId,
2666
2674
  multiaddrs: multiaddrs.length > 0 ? dedupeMultiaddrs(multiaddrs) : void 0,
@@ -2698,8 +2706,6 @@ function normalizeRelayBootstrapPostRecord(value) {
2698
2706
  function buildRelayBootstrapPostContent(args) {
2699
2707
  const now = args.now ?? Date.now() / 1e3;
2700
2708
  const updatedAt = args.now ?? Date.now();
2701
- const postType = args.postType ?? DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE;
2702
- const compact = args.compact ?? compactPostType(postType);
2703
2709
  const fullMultiaddrs = filterPublicMultiaddrs(args.multiaddrs);
2704
2710
  const fullBrowserMultiaddrs = args.browserMultiaddrs ? filterPublicMultiaddrs(args.browserMultiaddrs, {
2705
2711
  browserDialableOnly: true
@@ -2709,13 +2715,13 @@ function buildRelayBootstrapPostContent(args) {
2709
2715
  args.compactMultiaddrLimit
2710
2716
  );
2711
2717
  return {
2712
- type: postType,
2718
+ type: DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE,
2713
2719
  address: args.sender,
2714
2720
  ...args.ref ? { ref: args.ref } : {},
2715
2721
  content: {
2716
2722
  peerId: args.peerId,
2717
- multiaddrs: compact ? compactMultiaddrs : fullMultiaddrs,
2718
- browserMultiaddrs: compact ? void 0 : fullBrowserMultiaddrs,
2723
+ multiaddrs: compactMultiaddrs,
2724
+ browserMultiaddrs: void 0,
2719
2725
  registrationId: args.registrationId,
2720
2726
  profile: args.profile,
2721
2727
  version: args.version,
@@ -2738,14 +2744,12 @@ async function createRelayBootstrapPost(args) {
2738
2744
  browserMultiaddrs: args.browserMultiaddrs,
2739
2745
  registrationId: args.registrationId,
2740
2746
  ref: args.ref ?? DEFAULT_ALEPH_BOOTSTRAP_REF,
2741
- postType: args.postType ?? DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE,
2742
2747
  profile: args.profile,
2743
2748
  version: args.version,
2744
2749
  ownerAddress: args.ownerAddress,
2745
2750
  publisherAddress: args.publisherAddress,
2746
2751
  authorization: args.authorization,
2747
2752
  relayProof: args.relayProof,
2748
- compact: args.compact,
2749
2753
  compactMultiaddrLimit: args.compactMultiaddrLimit,
2750
2754
  now: nowMillis
2751
2755
  });
@@ -2792,12 +2796,11 @@ async function signRelayBootstrapProof(args) {
2792
2796
  fullBrowserMultiaddrs && fullBrowserMultiaddrs.length > 0 ? fullBrowserMultiaddrs : fullMultiaddrs,
2793
2797
  args.compactMultiaddrLimit
2794
2798
  );
2795
- const compact = args.compact ?? false;
2796
2799
  const payload = {
2797
2800
  peerId: args.peerId,
2798
- multiaddrs: compact ? void 0 : fullMultiaddrs,
2799
- browserMultiaddrs: compact ? void 0 : fullBrowserMultiaddrs,
2800
- multiaddrsHash: compact ? relayBootstrapMultiaddrsHash(compactMultiaddrs) : void 0,
2801
+ multiaddrs: void 0,
2802
+ browserMultiaddrs: void 0,
2803
+ multiaddrsHash: relayBootstrapMultiaddrsHash(compactMultiaddrs),
2801
2804
  registrationId: args.registrationId,
2802
2805
  profile: args.profile,
2803
2806
  version: args.version,
@@ -2827,10 +2830,7 @@ async function fetchAlephBootstrapPosts(options = {}) {
2827
2830
  options.channel ?? DEFAULT_ALEPH_BOOTSTRAP_CHANNEL
2828
2831
  );
2829
2832
  url.searchParams.set("refs", options.ref ?? DEFAULT_ALEPH_BOOTSTRAP_REF);
2830
- url.searchParams.set(
2831
- "types",
2832
- options.postType ?? DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE
2833
- );
2833
+ url.searchParams.set("types", DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE);
2834
2834
  url.searchParams.set(
2835
2835
  "pagination",
2836
2836
  String(options.pagination ?? DEFAULT_BOOTSTRAP_PAGINATION)
@@ -2844,7 +2844,21 @@ async function fetchAlephBootstrapPosts(options = {}) {
2844
2844
  throw new Error(`Aleph bootstrap post lookup failed: ${response.status}`);
2845
2845
  }
2846
2846
  const payload = await response.json();
2847
- return (payload.posts ?? []).map((entry) => normalizeRelayBootstrapPostRecord(entry)).filter((entry) => entry != null).sort((left, right) => compareRelayBootstrapPostRecency(right, left));
2847
+ const posts = (payload.posts ?? []).map((entry) => normalizeRelayBootstrapPostRecord(entry)).filter((entry) => entry != null).sort((left, right) => compareRelayBootstrapPostRecency(right, left));
2848
+ posts.forEach(assertSupportedRelayBootstrapPost);
2849
+ return posts;
2850
+ }
2851
+ function assertSupportedRelayBootstrapPost(post) {
2852
+ if (post.type === "relay-bootstrap") {
2853
+ throw new Error(
2854
+ "Legacy relay-bootstrap record encountered. Only relay-bootstrap-v2 is supported."
2855
+ );
2856
+ }
2857
+ if (post.type && post.type !== DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE) {
2858
+ throw new Error(
2859
+ `Unsupported relay bootstrap post type: ${post.type}. Expected ${DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE}.`
2860
+ );
2861
+ }
2848
2862
  }
2849
2863
  function compareRelayBootstrapPostRecency(left, right) {
2850
2864
  const leftUpdatedAt = left.content?.updatedAt ?? 0;
@@ -2866,6 +2880,7 @@ function selectCurrentRelayBootstrapPosts(posts, options = {}) {
2866
2880
  const now = options.now ?? Date.now();
2867
2881
  const selected = /* @__PURE__ */ new Map();
2868
2882
  for (const post of posts) {
2883
+ assertSupportedRelayBootstrapPost(post);
2869
2884
  const content = post.content;
2870
2885
  if (!content) continue;
2871
2886
  if (now - content.updatedAt > maxAgeMs) continue;
@@ -2891,14 +2906,12 @@ async function waitForRelayBootstrapRegistration(args) {
2891
2906
  const expectedSender = args.sender?.trim().toLowerCase() || null;
2892
2907
  const expectedRegistrationId = args.registrationId?.trim() || null;
2893
2908
  const expectedPeerId = args.peerId?.trim() || null;
2894
- const postType = args.postType ?? DEFAULT_ALEPH_BOOTSTRAP_COMPACT_POST_TYPE;
2895
2909
  const sleepImpl = args.sleep ?? sleep;
2896
2910
  for (let attempt = 0; attempt < attempts; attempt += 1) {
2897
2911
  const posts = await fetchAlephBootstrapPosts({
2898
2912
  apiHost: args.apiHost ?? DEFAULT_ALEPH_API_HOST2,
2899
2913
  channel: args.channel,
2900
2914
  ref: args.ref,
2901
- postType,
2902
2915
  fetch: args.fetch
2903
2916
  });
2904
2917
  const currentPosts = selectCurrentRelayBootstrapPosts(posts);
@@ -2937,8 +2950,6 @@ async function waitForRelayBootstrapRegistration(args) {
2937
2950
  async function publishRelayBootstrapRegistration(args) {
2938
2951
  const publisherAddress = args.publisherAddress ?? args.sender;
2939
2952
  const ownerAddress = args.ownerAddress;
2940
- const postType = args.postType ?? DEFAULT_ALEPH_BOOTSTRAP_COMPACT_POST_TYPE;
2941
- const compact = postType === DEFAULT_ALEPH_BOOTSTRAP_COMPACT_POST_TYPE;
2942
2953
  let ownerAuthorization = args.ownerAuthorization;
2943
2954
  let relayProof = args.relayProof;
2944
2955
  if (!ownerAuthorization && ownerAddress && args.ownerSigner) {
@@ -2965,7 +2976,6 @@ async function publishRelayBootstrapRegistration(args) {
2965
2976
  profile: args.profile,
2966
2977
  version: args.version,
2967
2978
  updatedAt: args.now ?? Date.now(),
2968
- compact,
2969
2979
  compactMultiaddrLimit: args.compactMultiaddrLimit,
2970
2980
  signer: args.publisherSigner
2971
2981
  });
@@ -2978,14 +2988,12 @@ async function publishRelayBootstrapRegistration(args) {
2978
2988
  registrationId: args.registrationId,
2979
2989
  channel: args.channel,
2980
2990
  ref: args.ref,
2981
- postType,
2982
2991
  profile: args.profile,
2983
2992
  version: args.version,
2984
2993
  ownerAddress,
2985
2994
  publisherAddress,
2986
2995
  authorization: ownerAuthorization,
2987
2996
  relayProof,
2988
- compact,
2989
2997
  compactMultiaddrLimit: args.compactMultiaddrLimit,
2990
2998
  now: args.now,
2991
2999
  hasher: args.hasher
@@ -3008,18 +3016,12 @@ async function publishRelayBootstrapRegistration(args) {
3008
3016
  let forgottenHashes = [];
3009
3017
  let forgetResult;
3010
3018
  if (args.forgetPrevious && args.registrationId) {
3011
- const previousPostTypes = compact ? [postType, DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE] : [postType];
3012
- const previousPosts = (await Promise.all(
3013
- previousPostTypes.map(
3014
- (previousPostType) => fetchAlephBootstrapPosts({
3015
- apiHost: args.apiHost ?? DEFAULT_ALEPH_API_HOST2,
3016
- channel: args.channel,
3017
- ref: args.ref,
3018
- postType: previousPostType,
3019
- fetch: args.fetch
3020
- })
3021
- )
3022
- )).flat();
3019
+ const previousPosts = await fetchAlephBootstrapPosts({
3020
+ apiHost: args.apiHost ?? DEFAULT_ALEPH_API_HOST2,
3021
+ channel: args.channel,
3022
+ ref: args.ref,
3023
+ fetch: args.fetch
3024
+ });
3023
3025
  const forgottenHashSet = new Set(
3024
3026
  previousPosts.filter((post) => {
3025
3027
  const hash = post.itemHash ?? post.hash;
@@ -3505,7 +3507,6 @@ async function reconcileOwnerRelayBootstrapRegistrations(args) {
3505
3507
  apiHost: args.apiHost,
3506
3508
  channel: args.channel,
3507
3509
  ref: args.ref,
3508
- postType: args.postType,
3509
3510
  peerId: relayMetadata.peerId,
3510
3511
  multiaddrs: relayMetadata.probeMultiaddrs,
3511
3512
  browserMultiaddrs: relayMetadata.browserBootstrapMultiaddrs,
@@ -3535,7 +3536,6 @@ async function reconcileOwnerRelayBootstrapRegistrations(args) {
3535
3536
  apiHost: args.apiHost ?? DEFAULT_ALEPH_API_HOST,
3536
3537
  channel: args.channel,
3537
3538
  ref: args.ref,
3538
- postType: args.postType,
3539
3539
  fetch: args.fetch
3540
3540
  });
3541
3541
  const currentPosts = selectCurrentRelayBootstrapPosts(bootstrapPosts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/core",
3
- "version": "0.6.24",
3
+ "version": "0.6.26",
4
4
  "description": "Reusable Aleph deployment, runtime, and guest lifecycle logic.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/NiKrause/relay-button/issues"
25
25
  },
26
26
  "dependencies": {
27
- "@le-space/aleph-bootstrap": "0.6.24",
28
- "@le-space/shared-types": "0.6.24"
27
+ "@le-space/aleph-bootstrap": "0.6.26",
28
+ "@le-space/shared-types": "0.6.26"
29
29
  }
30
30
  }