@le-space/aleph-bootstrap 0.6.32 → 0.6.34
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/index.d.ts +15 -1
- package/index.js +15 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -87,6 +87,15 @@ interface DiscoverAlephBootstrapOptions {
|
|
|
87
87
|
browserDialableOnly?: boolean;
|
|
88
88
|
requireDualKeyAttestation?: boolean;
|
|
89
89
|
verifyDualKeyAttestation?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Restrict discovery to registrations published under this relay profile
|
|
92
|
+
* (e.g. `"orbitdb-relay"`). Multiple relay implementations register in the
|
|
93
|
+
* same Aleph channel; without this scope a consumer would pick up relays it
|
|
94
|
+
* cannot use (an orbitdb app connecting to a `uc-go-peer` relay never gets a
|
|
95
|
+
* shared circuit → `candidates: 0`). Accepts a single profile or a list.
|
|
96
|
+
* When omitted, posts of every profile are returned (previous behaviour).
|
|
97
|
+
*/
|
|
98
|
+
profile?: string | readonly string[];
|
|
90
99
|
fetch?: typeof fetch;
|
|
91
100
|
}
|
|
92
101
|
interface FilterPublicMultiaddrsOptions {
|
|
@@ -182,10 +191,15 @@ declare function fetchAlephBootstrapPosts(options?: DiscoverAlephBootstrapOption
|
|
|
182
191
|
declare function selectCurrentRelayBootstrapPosts(posts: readonly RelayBootstrapPostRecord[], options?: Pick<DiscoverAlephBootstrapOptions, "maxAgeMs"> & {
|
|
183
192
|
now?: number;
|
|
184
193
|
}): RelayBootstrapPostRecord[];
|
|
194
|
+
/**
|
|
195
|
+
* Keep only posts whose registration profile matches the requested profile(s).
|
|
196
|
+
* A missing/empty filter is a no-op so existing callers are unaffected.
|
|
197
|
+
*/
|
|
198
|
+
declare function filterRelayBootstrapPostsByProfile(posts: readonly RelayBootstrapPostRecord[], profile?: string | readonly string[]): RelayBootstrapPostRecord[];
|
|
185
199
|
declare function discoverAlephBootstrapMultiaddrs(options?: DiscoverAlephBootstrapOptions): Promise<string[]>;
|
|
186
200
|
declare function createLibp2pAlephBootstrap(options?: DiscoverAlephBootstrapOptions & {
|
|
187
201
|
timeout?: number;
|
|
188
202
|
tagName?: string;
|
|
189
203
|
}): Promise<ReturnType<typeof bootstrap>>;
|
|
190
204
|
|
|
191
|
-
export { type CreateRelayBootstrapPostOptions, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_BOOTSTRAP_CHANNEL, DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE, DEFAULT_ALEPH_BOOTSTRAP_REF, DEFAULT_BOOTSTRAP_COMPACT_MULTIADDR_LIMIT, DEFAULT_BOOTSTRAP_MAX_AGE_MS, DEFAULT_BOOTSTRAP_MAX_PAGES, DEFAULT_BOOTSTRAP_PAGINATION, type DiscoverAlephBootstrapOptions, type FilterPublicMultiaddrsOptions, RELAY_BOOTSTRAP_SIGNATURE_SCHEME, type RelayBootstrapAuthorizationPayload, type RelayBootstrapAuthorizationRecord, type RelayBootstrapContent, type RelayBootstrapPostContent, type RelayBootstrapPostRecord, type RelayBootstrapProofPayload, type RelayBootstrapProofRecord, type RelayBootstrapProofSigner, type RelayBootstrapTrustMode, type RelayBootstrapVerificationResult, buildRelayBootstrapPostContent, createLibp2pAlephBootstrap, createRelayBootstrapPost, dedupeMultiaddrs, discoverAlephBootstrapMultiaddrs, fetchAlephBootstrapPosts, filterPublicMultiaddrs, isPublicMultiaddr, relayBootstrapMultiaddrsHash, relayBootstrapTrustMode, selectCompactRelayBootstrapMultiaddrs, selectCurrentRelayBootstrapPosts, signRelayBootstrapAuthorization, signRelayBootstrapProof, verifyRelayBootstrapAuthorization, verifyRelayBootstrapDualKeyContent, verifyRelayBootstrapProof };
|
|
205
|
+
export { type CreateRelayBootstrapPostOptions, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_BOOTSTRAP_CHANNEL, DEFAULT_ALEPH_BOOTSTRAP_POST_TYPE, DEFAULT_ALEPH_BOOTSTRAP_REF, DEFAULT_BOOTSTRAP_COMPACT_MULTIADDR_LIMIT, DEFAULT_BOOTSTRAP_MAX_AGE_MS, DEFAULT_BOOTSTRAP_MAX_PAGES, DEFAULT_BOOTSTRAP_PAGINATION, type DiscoverAlephBootstrapOptions, type FilterPublicMultiaddrsOptions, RELAY_BOOTSTRAP_SIGNATURE_SCHEME, type RelayBootstrapAuthorizationPayload, type RelayBootstrapAuthorizationRecord, type RelayBootstrapContent, type RelayBootstrapPostContent, type RelayBootstrapPostRecord, type RelayBootstrapProofPayload, type RelayBootstrapProofRecord, type RelayBootstrapProofSigner, type RelayBootstrapTrustMode, type RelayBootstrapVerificationResult, buildRelayBootstrapPostContent, createLibp2pAlephBootstrap, createRelayBootstrapPost, dedupeMultiaddrs, discoverAlephBootstrapMultiaddrs, fetchAlephBootstrapPosts, filterPublicMultiaddrs, filterRelayBootstrapPostsByProfile, isPublicMultiaddr, relayBootstrapMultiaddrsHash, relayBootstrapTrustMode, selectCompactRelayBootstrapMultiaddrs, selectCurrentRelayBootstrapPosts, signRelayBootstrapAuthorization, signRelayBootstrapProof, verifyRelayBootstrapAuthorization, verifyRelayBootstrapDualKeyContent, verifyRelayBootstrapProof };
|
package/index.js
CHANGED
|
@@ -629,6 +629,14 @@ function selectCurrentRelayBootstrapPosts(posts, options = {}) {
|
|
|
629
629
|
(left, right) => compareRelayBootstrapPostRecency(right, left)
|
|
630
630
|
);
|
|
631
631
|
}
|
|
632
|
+
function filterRelayBootstrapPostsByProfile(posts, profile) {
|
|
633
|
+
const wanted = (typeof profile === "string" ? [profile] : profile ?? []).map((entry) => entry.trim()).filter(Boolean);
|
|
634
|
+
if (wanted.length === 0) return [...posts];
|
|
635
|
+
const allowed = new Set(wanted);
|
|
636
|
+
return posts.filter(
|
|
637
|
+
(post) => post.content != null && allowed.has(String(post.content.profile))
|
|
638
|
+
);
|
|
639
|
+
}
|
|
632
640
|
async function filterTrustedRelayBootstrapPosts(posts, options = {}) {
|
|
633
641
|
const requireDualKeyAttestation = options.requireDualKeyAttestation ?? false;
|
|
634
642
|
const verifyDualKeyAttestation = options.verifyDualKeyAttestation ?? true;
|
|
@@ -668,9 +676,12 @@ async function discoverAlephBootstrapMultiaddrs(options = {}) {
|
|
|
668
676
|
pagination
|
|
669
677
|
});
|
|
670
678
|
collectedPosts.push(...pagePosts);
|
|
671
|
-
const selectedPosts =
|
|
672
|
-
|
|
673
|
-
|
|
679
|
+
const selectedPosts = filterRelayBootstrapPostsByProfile(
|
|
680
|
+
selectCurrentRelayBootstrapPosts(collectedPosts, {
|
|
681
|
+
maxAgeMs: options.maxAgeMs
|
|
682
|
+
}),
|
|
683
|
+
options.profile
|
|
684
|
+
);
|
|
674
685
|
const trustedPosts = await filterTrustedRelayBootstrapPosts(selectedPosts, {
|
|
675
686
|
requireDualKeyAttestation: options.requireDualKeyAttestation,
|
|
676
687
|
verifyDualKeyAttestation: options.verifyDualKeyAttestation
|
|
@@ -727,6 +738,7 @@ export {
|
|
|
727
738
|
discoverAlephBootstrapMultiaddrs,
|
|
728
739
|
fetchAlephBootstrapPosts,
|
|
729
740
|
filterPublicMultiaddrs,
|
|
741
|
+
filterRelayBootstrapPostsByProfile,
|
|
730
742
|
isPublicMultiaddr,
|
|
731
743
|
relayBootstrapMultiaddrsHash,
|
|
732
744
|
relayBootstrapTrustMode,
|