@le-space/core 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.
Files changed (3) hide show
  1. package/index.d.ts +0 -3
  2. package/index.js +30 -42
  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;
@@ -2698,8 +2694,6 @@ function normalizeRelayBootstrapPostRecord(value) {
2698
2694
  function buildRelayBootstrapPostContent(args) {
2699
2695
  const now = args.now ?? Date.now() / 1e3;
2700
2696
  const updatedAt = args.now ?? Date.now();
2701
- const postType = args.postType ?? DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE;
2702
- const compact = args.compact ?? compactPostType(postType);
2703
2697
  const fullMultiaddrs = filterPublicMultiaddrs(args.multiaddrs);
2704
2698
  const fullBrowserMultiaddrs = args.browserMultiaddrs ? filterPublicMultiaddrs(args.browserMultiaddrs, {
2705
2699
  browserDialableOnly: true
@@ -2709,13 +2703,13 @@ function buildRelayBootstrapPostContent(args) {
2709
2703
  args.compactMultiaddrLimit
2710
2704
  );
2711
2705
  return {
2712
- type: postType,
2706
+ type: DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE,
2713
2707
  address: args.sender,
2714
2708
  ...args.ref ? { ref: args.ref } : {},
2715
2709
  content: {
2716
2710
  peerId: args.peerId,
2717
- multiaddrs: compact ? compactMultiaddrs : fullMultiaddrs,
2718
- browserMultiaddrs: compact ? void 0 : fullBrowserMultiaddrs,
2711
+ multiaddrs: compactMultiaddrs,
2712
+ browserMultiaddrs: void 0,
2719
2713
  registrationId: args.registrationId,
2720
2714
  profile: args.profile,
2721
2715
  version: args.version,
@@ -2738,14 +2732,12 @@ async function createRelayBootstrapPost(args) {
2738
2732
  browserMultiaddrs: args.browserMultiaddrs,
2739
2733
  registrationId: args.registrationId,
2740
2734
  ref: args.ref ?? DEFAULT_ALEPH_BOOTSTRAP_REF,
2741
- postType: args.postType ?? DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE,
2742
2735
  profile: args.profile,
2743
2736
  version: args.version,
2744
2737
  ownerAddress: args.ownerAddress,
2745
2738
  publisherAddress: args.publisherAddress,
2746
2739
  authorization: args.authorization,
2747
2740
  relayProof: args.relayProof,
2748
- compact: args.compact,
2749
2741
  compactMultiaddrLimit: args.compactMultiaddrLimit,
2750
2742
  now: nowMillis
2751
2743
  });
@@ -2792,12 +2784,11 @@ async function signRelayBootstrapProof(args) {
2792
2784
  fullBrowserMultiaddrs && fullBrowserMultiaddrs.length > 0 ? fullBrowserMultiaddrs : fullMultiaddrs,
2793
2785
  args.compactMultiaddrLimit
2794
2786
  );
2795
- const compact = args.compact ?? false;
2796
2787
  const payload = {
2797
2788
  peerId: args.peerId,
2798
- multiaddrs: compact ? void 0 : fullMultiaddrs,
2799
- browserMultiaddrs: compact ? void 0 : fullBrowserMultiaddrs,
2800
- multiaddrsHash: compact ? relayBootstrapMultiaddrsHash(compactMultiaddrs) : void 0,
2789
+ multiaddrs: void 0,
2790
+ browserMultiaddrs: void 0,
2791
+ multiaddrsHash: relayBootstrapMultiaddrsHash(compactMultiaddrs),
2801
2792
  registrationId: args.registrationId,
2802
2793
  profile: args.profile,
2803
2794
  version: args.version,
@@ -2827,10 +2818,7 @@ async function fetchAlephBootstrapPosts(options = {}) {
2827
2818
  options.channel ?? DEFAULT_ALEPH_BOOTSTRAP_CHANNEL
2828
2819
  );
2829
2820
  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
- );
2821
+ url.searchParams.set("types", DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE);
2834
2822
  url.searchParams.set(
2835
2823
  "pagination",
2836
2824
  String(options.pagination ?? DEFAULT_BOOTSTRAP_PAGINATION)
@@ -2844,7 +2832,21 @@ async function fetchAlephBootstrapPosts(options = {}) {
2844
2832
  throw new Error(`Aleph bootstrap post lookup failed: ${response.status}`);
2845
2833
  }
2846
2834
  const payload = await response.json();
2847
- return (payload.posts ?? []).map((entry) => normalizeRelayBootstrapPostRecord(entry)).filter((entry) => entry != null).sort((left, right) => compareRelayBootstrapPostRecency(right, left));
2835
+ const posts = (payload.posts ?? []).map((entry) => normalizeRelayBootstrapPostRecord(entry)).filter((entry) => entry != null).sort((left, right) => compareRelayBootstrapPostRecency(right, left));
2836
+ posts.forEach(assertSupportedRelayBootstrapPost);
2837
+ return posts;
2838
+ }
2839
+ function assertSupportedRelayBootstrapPost(post) {
2840
+ if (post.type === "relay-bootstrap") {
2841
+ throw new Error(
2842
+ "Legacy relay-bootstrap record encountered. Only relay-bootstrap-v2 is supported."
2843
+ );
2844
+ }
2845
+ if (post.type && post.type !== DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE) {
2846
+ throw new Error(
2847
+ `Unsupported relay bootstrap post type: ${post.type}. Expected ${DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE}.`
2848
+ );
2849
+ }
2848
2850
  }
2849
2851
  function compareRelayBootstrapPostRecency(left, right) {
2850
2852
  const leftUpdatedAt = left.content?.updatedAt ?? 0;
@@ -2866,6 +2868,7 @@ function selectCurrentRelayBootstrapPosts(posts, options = {}) {
2866
2868
  const now = options.now ?? Date.now();
2867
2869
  const selected = /* @__PURE__ */ new Map();
2868
2870
  for (const post of posts) {
2871
+ assertSupportedRelayBootstrapPost(post);
2869
2872
  const content = post.content;
2870
2873
  if (!content) continue;
2871
2874
  if (now - content.updatedAt > maxAgeMs) continue;
@@ -2891,14 +2894,12 @@ async function waitForRelayBootstrapRegistration(args) {
2891
2894
  const expectedSender = args.sender?.trim().toLowerCase() || null;
2892
2895
  const expectedRegistrationId = args.registrationId?.trim() || null;
2893
2896
  const expectedPeerId = args.peerId?.trim() || null;
2894
- const postType = args.postType ?? DEFAULT_ALEPH_BOOTSTRAP_COMPACT_POST_TYPE;
2895
2897
  const sleepImpl = args.sleep ?? sleep;
2896
2898
  for (let attempt = 0; attempt < attempts; attempt += 1) {
2897
2899
  const posts = await fetchAlephBootstrapPosts({
2898
2900
  apiHost: args.apiHost ?? DEFAULT_ALEPH_API_HOST2,
2899
2901
  channel: args.channel,
2900
2902
  ref: args.ref,
2901
- postType,
2902
2903
  fetch: args.fetch
2903
2904
  });
2904
2905
  const currentPosts = selectCurrentRelayBootstrapPosts(posts);
@@ -2937,8 +2938,6 @@ async function waitForRelayBootstrapRegistration(args) {
2937
2938
  async function publishRelayBootstrapRegistration(args) {
2938
2939
  const publisherAddress = args.publisherAddress ?? args.sender;
2939
2940
  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
2941
  let ownerAuthorization = args.ownerAuthorization;
2943
2942
  let relayProof = args.relayProof;
2944
2943
  if (!ownerAuthorization && ownerAddress && args.ownerSigner) {
@@ -2965,7 +2964,6 @@ async function publishRelayBootstrapRegistration(args) {
2965
2964
  profile: args.profile,
2966
2965
  version: args.version,
2967
2966
  updatedAt: args.now ?? Date.now(),
2968
- compact,
2969
2967
  compactMultiaddrLimit: args.compactMultiaddrLimit,
2970
2968
  signer: args.publisherSigner
2971
2969
  });
@@ -2978,14 +2976,12 @@ async function publishRelayBootstrapRegistration(args) {
2978
2976
  registrationId: args.registrationId,
2979
2977
  channel: args.channel,
2980
2978
  ref: args.ref,
2981
- postType,
2982
2979
  profile: args.profile,
2983
2980
  version: args.version,
2984
2981
  ownerAddress,
2985
2982
  publisherAddress,
2986
2983
  authorization: ownerAuthorization,
2987
2984
  relayProof,
2988
- compact,
2989
2985
  compactMultiaddrLimit: args.compactMultiaddrLimit,
2990
2986
  now: args.now,
2991
2987
  hasher: args.hasher
@@ -3008,18 +3004,12 @@ async function publishRelayBootstrapRegistration(args) {
3008
3004
  let forgottenHashes = [];
3009
3005
  let forgetResult;
3010
3006
  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();
3007
+ const previousPosts = await fetchAlephBootstrapPosts({
3008
+ apiHost: args.apiHost ?? DEFAULT_ALEPH_API_HOST2,
3009
+ channel: args.channel,
3010
+ ref: args.ref,
3011
+ fetch: args.fetch
3012
+ });
3023
3013
  const forgottenHashSet = new Set(
3024
3014
  previousPosts.filter((post) => {
3025
3015
  const hash = post.itemHash ?? post.hash;
@@ -3505,7 +3495,6 @@ async function reconcileOwnerRelayBootstrapRegistrations(args) {
3505
3495
  apiHost: args.apiHost,
3506
3496
  channel: args.channel,
3507
3497
  ref: args.ref,
3508
- postType: args.postType,
3509
3498
  peerId: relayMetadata.peerId,
3510
3499
  multiaddrs: relayMetadata.probeMultiaddrs,
3511
3500
  browserMultiaddrs: relayMetadata.browserBootstrapMultiaddrs,
@@ -3535,7 +3524,6 @@ async function reconcileOwnerRelayBootstrapRegistrations(args) {
3535
3524
  apiHost: args.apiHost ?? DEFAULT_ALEPH_API_HOST,
3536
3525
  channel: args.channel,
3537
3526
  ref: args.ref,
3538
- postType: args.postType,
3539
3527
  fetch: args.fetch
3540
3528
  });
3541
3529
  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.25",
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.25",
28
+ "@le-space/shared-types": "0.6.25"
29
29
  }
30
30
  }