@le-space/core 0.3.17 → 0.3.19
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 +22 -1
- package/index.js +58 -10
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -704,6 +704,27 @@ interface RelayBootstrapPublicationResult {
|
|
|
704
704
|
forgottenHashes?: string[];
|
|
705
705
|
forgetResult?: Awaited<ReturnType<typeof forgetAlephMessages>>;
|
|
706
706
|
}
|
|
707
|
+
interface RelayBootstrapVisibilityResult {
|
|
708
|
+
itemHash: string | null;
|
|
709
|
+
hash: string | null;
|
|
710
|
+
sender?: string | null;
|
|
711
|
+
registrationId?: string;
|
|
712
|
+
peerId?: string;
|
|
713
|
+
multiaddrs: string[];
|
|
714
|
+
browserMultiaddrs: string[];
|
|
715
|
+
}
|
|
716
|
+
declare function waitForRelayBootstrapRegistration(args: {
|
|
717
|
+
sender?: string;
|
|
718
|
+
fetch: JsonFetchLike$1;
|
|
719
|
+
registrationId?: string;
|
|
720
|
+
peerId?: string;
|
|
721
|
+
apiHost?: string;
|
|
722
|
+
channel?: string;
|
|
723
|
+
ref?: string;
|
|
724
|
+
postType?: string;
|
|
725
|
+
attempts?: number;
|
|
726
|
+
delayMs?: number;
|
|
727
|
+
}): Promise<RelayBootstrapVisibilityResult | null>;
|
|
707
728
|
declare function publishRelayBootstrapRegistration(args: {
|
|
708
729
|
sender: string;
|
|
709
730
|
signer: MessageSigner;
|
|
@@ -841,4 +862,4 @@ declare function reconcileOwnerRelayBootstrapRegistrations(args: {
|
|
|
841
862
|
} | null;
|
|
842
863
|
}): Promise<OwnerRelayBootstrapReconcileResult>;
|
|
843
864
|
|
|
844
|
-
export { type CrnCapacitySpec, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_CHANNEL, DEFAULT_COUNTRY_LOOKUP_BASE_URL, DEFAULT_CRN_LIST_URL, DEFAULT_DNS_RESOLVE_URL, DEFAULT_INSTANCE_PORT_FORWARDS, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_SCHEDULER_ALLOCATION_URL, DEFAULT_TWO_N_SIX_HASH_URL, type FetchLike, type FetchLikeResponse, type HttpProbeResult, ITEM_HASH_RE, type JsonFetchLike$1 as JsonFetchLike, type JsonFetchLikeResponse, type OwnerRelayBootstrapReconcileResult, type PaymentQuote, type RelayBootstrapPublicationResult, type RelayMetadataShape, type RetentionRecord, SSH_PUBLIC_KEY_PATTERN, SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY, type TcpProbeResult, type TierSpec, VM_BOOTSTRAP_CONFIG_AGGREGATE_KEY, appendDeploymentTokenToSshPublicKey, broadcastAlephMessage, buildPaymentQuote, cleanupFailedDeployment, configureOrbitdbRelaySetup, configureUcGoPeer, createDeploymentIntent, createDeploymentToken, createInstanceContent, createPortForwardAggregateContent, createRelayBootstrapRegistrationId, createReleaseMetadata, createUnsignedAggregateMessage, createUnsignedForgetMessage, createUnsignedInstanceMessage, createVmBootstrapConfigAggregateContent, deleteVmBootstrapConfig, deployInstance, describeRejectedDeployment, describeRuntimeAvailability, enrichCrnsWithGeo, ensureInstancePortForwards, extractInsufficientBalanceMessage, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchMessageEnvelope, fetchPortForwardAggregate, fetchRelayMetadataForRuntime, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmBootstrapConfigAggregate, fetchVmRuntime, filterDeployableCrns, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isValidSshPublicKey, listGeocodedCrns, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, notifyCrnAllocationWithRetry, portForwardLabel, postBroadcastPayload, probeRootfsGateway, publishAggregateKey, publishRelayBootstrapRegistration, publishVmBootstrapConfig, quoteRequiredBudgetUnits, rankCandidateCrns, reconcileOwnerRelayBootstrapRegistrations, requestedPortFlags, requiredInstancePortForwards, resolveRootfsReference, retainSuccessfulDeployments, selectPreferredCrn, selectedTier, signAlephMessage, signaturePayload, tierSpec, validateRootfsManifest, verifyRootfsExists, verifyUcGoPeerReachability, waitForDeploymentResult, waitForSetupEndpoint, waitForVmRuntime };
|
|
865
|
+
export { type CrnCapacitySpec, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_CHANNEL, DEFAULT_COUNTRY_LOOKUP_BASE_URL, DEFAULT_CRN_LIST_URL, DEFAULT_DNS_RESOLVE_URL, DEFAULT_INSTANCE_PORT_FORWARDS, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_SCHEDULER_ALLOCATION_URL, DEFAULT_TWO_N_SIX_HASH_URL, type FetchLike, type FetchLikeResponse, type HttpProbeResult, ITEM_HASH_RE, type JsonFetchLike$1 as JsonFetchLike, type JsonFetchLikeResponse, type OwnerRelayBootstrapReconcileResult, type PaymentQuote, type RelayBootstrapPublicationResult, type RelayBootstrapVisibilityResult, type RelayMetadataShape, type RetentionRecord, SSH_PUBLIC_KEY_PATTERN, SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY, type TcpProbeResult, type TierSpec, VM_BOOTSTRAP_CONFIG_AGGREGATE_KEY, appendDeploymentTokenToSshPublicKey, broadcastAlephMessage, buildPaymentQuote, cleanupFailedDeployment, configureOrbitdbRelaySetup, configureUcGoPeer, createDeploymentIntent, createDeploymentToken, createInstanceContent, createPortForwardAggregateContent, createRelayBootstrapRegistrationId, createReleaseMetadata, createUnsignedAggregateMessage, createUnsignedForgetMessage, createUnsignedInstanceMessage, createVmBootstrapConfigAggregateContent, deleteVmBootstrapConfig, deployInstance, describeRejectedDeployment, describeRuntimeAvailability, enrichCrnsWithGeo, ensureInstancePortForwards, extractInsufficientBalanceMessage, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchMessageEnvelope, fetchPortForwardAggregate, fetchRelayMetadataForRuntime, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmBootstrapConfigAggregate, fetchVmRuntime, filterDeployableCrns, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isValidSshPublicKey, listGeocodedCrns, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, notifyCrnAllocationWithRetry, portForwardLabel, postBroadcastPayload, probeRootfsGateway, publishAggregateKey, publishRelayBootstrapRegistration, publishVmBootstrapConfig, quoteRequiredBudgetUnits, rankCandidateCrns, reconcileOwnerRelayBootstrapRegistrations, requestedPortFlags, requiredInstancePortForwards, resolveRootfsReference, retainSuccessfulDeployments, selectPreferredCrn, selectedTier, signAlephMessage, signaturePayload, tierSpec, validateRootfsManifest, verifyRootfsExists, verifyUcGoPeerReachability, waitForDeploymentResult, waitForRelayBootstrapRegistration, waitForSetupEndpoint, waitForVmRuntime };
|
package/index.js
CHANGED
|
@@ -679,14 +679,14 @@ async function inspectDeploymentResult(itemHash, options) {
|
|
|
679
679
|
async function waitForDeploymentResult(itemHash, options) {
|
|
680
680
|
const attempts = Math.max(1, Number(options.attempts ?? 15));
|
|
681
681
|
const delayMs = Math.max(0, Number(options.delayMs ?? 2e3));
|
|
682
|
-
const
|
|
682
|
+
const sleep2 = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
683
683
|
let lastResult = await inspectDeploymentResult(itemHash, options);
|
|
684
684
|
options.onAttempt?.(lastResult, 1, attempts);
|
|
685
685
|
for (let attempt = 1; attempt < attempts; attempt += 1) {
|
|
686
686
|
if (lastResult.status === "processed" || lastResult.status === "rejected") {
|
|
687
687
|
return lastResult;
|
|
688
688
|
}
|
|
689
|
-
await
|
|
689
|
+
await sleep2(delayMs);
|
|
690
690
|
lastResult = await inspectDeploymentResult(itemHash, options);
|
|
691
691
|
options.onAttempt?.(lastResult, attempt + 1, attempts);
|
|
692
692
|
}
|
|
@@ -1730,14 +1730,14 @@ async function fetchVmRuntime(args) {
|
|
|
1730
1730
|
async function waitForVmRuntime(args) {
|
|
1731
1731
|
const attempts = Math.max(1, Number(args.attempts ?? 20));
|
|
1732
1732
|
const delayMs = Math.max(0, Number(args.delayMs ?? 4e3));
|
|
1733
|
-
const
|
|
1733
|
+
const sleep2 = args.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
1734
1734
|
let lastRuntime = await fetchVmRuntime(args);
|
|
1735
1735
|
args.onAttempt?.(lastRuntime, 1, attempts);
|
|
1736
1736
|
for (let attempt = 0; attempt < attempts - 1; attempt += 1) {
|
|
1737
1737
|
if (lastRuntime.hostIpv4 && Object.keys(lastRuntime.mappedPorts ?? {}).length > 0) {
|
|
1738
1738
|
return lastRuntime;
|
|
1739
1739
|
}
|
|
1740
|
-
await
|
|
1740
|
+
await sleep2(delayMs);
|
|
1741
1741
|
lastRuntime = await fetchVmRuntime(args);
|
|
1742
1742
|
args.onAttempt?.(lastRuntime, attempt + 2, attempts);
|
|
1743
1743
|
}
|
|
@@ -1823,7 +1823,7 @@ function isRetryableAllocationNotifyReason(reason) {
|
|
|
1823
1823
|
async function notifyCrnAllocationWithRetry(args) {
|
|
1824
1824
|
const attempts = Math.max(1, Number(args.attempts ?? 6));
|
|
1825
1825
|
const delayMs = Math.max(0, Number(args.delayMs ?? 2e3));
|
|
1826
|
-
const
|
|
1826
|
+
const sleep2 = args.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
1827
1827
|
let lastResult = null;
|
|
1828
1828
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
1829
1829
|
args.onProgress?.({
|
|
@@ -1849,7 +1849,7 @@ async function notifyCrnAllocationWithRetry(args) {
|
|
|
1849
1849
|
return result;
|
|
1850
1850
|
}
|
|
1851
1851
|
if (attempt < attempts - 1) {
|
|
1852
|
-
await
|
|
1852
|
+
await sleep2(delayMs);
|
|
1853
1853
|
}
|
|
1854
1854
|
}
|
|
1855
1855
|
return lastResult ?? {
|
|
@@ -1860,7 +1860,7 @@ async function notifyCrnAllocationWithRetry(args) {
|
|
|
1860
1860
|
async function waitForSetupEndpoint(args) {
|
|
1861
1861
|
const attempts = Math.max(1, Number(args.attempts ?? 15));
|
|
1862
1862
|
const delayMs = Math.max(0, Number(args.delayMs ?? 4e3));
|
|
1863
|
-
const
|
|
1863
|
+
const sleep2 = args.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
1864
1864
|
const url = `http://${args.hostIpv4}:${args.setupPort}/health`;
|
|
1865
1865
|
let result = await defaultHttpProbe(
|
|
1866
1866
|
args.fetch,
|
|
@@ -1870,7 +1870,7 @@ async function waitForSetupEndpoint(args) {
|
|
|
1870
1870
|
args.onAttempt?.(result, 1, attempts);
|
|
1871
1871
|
for (let attempt = 1; attempt < attempts; attempt += 1) {
|
|
1872
1872
|
if (result.ok) return result;
|
|
1873
|
-
await
|
|
1873
|
+
await sleep2(delayMs);
|
|
1874
1874
|
result = await defaultHttpProbe(
|
|
1875
1875
|
args.fetch,
|
|
1876
1876
|
url,
|
|
@@ -1974,7 +1974,7 @@ async function configureOrbitdbRelaySetup(args) {
|
|
|
1974
1974
|
async function fetchUcGoPeerMetadata(args) {
|
|
1975
1975
|
const attempts = Math.max(1, Number(args.attempts ?? 60));
|
|
1976
1976
|
const delayMs = Math.max(0, Number(args.delayMs ?? 3e3));
|
|
1977
|
-
const
|
|
1977
|
+
const sleep2 = args.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
1978
1978
|
let lastPayload = null;
|
|
1979
1979
|
let lastError = null;
|
|
1980
1980
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
@@ -2034,7 +2034,7 @@ async function fetchUcGoPeerMetadata(args) {
|
|
|
2034
2034
|
clearTimeout(timeout);
|
|
2035
2035
|
}
|
|
2036
2036
|
if (attempt < attempts - 1) {
|
|
2037
|
-
await
|
|
2037
|
+
await sleep2(delayMs);
|
|
2038
2038
|
}
|
|
2039
2039
|
}
|
|
2040
2040
|
throw new Error(
|
|
@@ -2481,6 +2481,53 @@ function selectCurrentRelayBootstrapPosts(posts, options = {}) {
|
|
|
2481
2481
|
}
|
|
2482
2482
|
|
|
2483
2483
|
// src/bootstrap-registration.ts
|
|
2484
|
+
function sleep(ms) {
|
|
2485
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2486
|
+
}
|
|
2487
|
+
async function waitForRelayBootstrapRegistration(args) {
|
|
2488
|
+
const attempts = Math.max(1, Number(args.attempts ?? 10));
|
|
2489
|
+
const delayMs = Math.max(0, Number(args.delayMs ?? 2e3));
|
|
2490
|
+
const expectedSender = args.sender?.trim().toLowerCase() || null;
|
|
2491
|
+
const expectedRegistrationId = args.registrationId?.trim() || null;
|
|
2492
|
+
const expectedPeerId = args.peerId?.trim() || null;
|
|
2493
|
+
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
2494
|
+
const posts = await fetchAlephBootstrapPosts({
|
|
2495
|
+
apiHost: args.apiHost ?? DEFAULT_ALEPH_API_HOST2,
|
|
2496
|
+
channel: args.channel,
|
|
2497
|
+
ref: args.ref,
|
|
2498
|
+
postType: args.postType,
|
|
2499
|
+
fetch: args.fetch
|
|
2500
|
+
});
|
|
2501
|
+
const currentPosts = selectCurrentRelayBootstrapPosts(posts);
|
|
2502
|
+
const match = currentPosts.find((post) => {
|
|
2503
|
+
if (expectedSender && post.address?.toLowerCase() !== expectedSender) {
|
|
2504
|
+
return false;
|
|
2505
|
+
}
|
|
2506
|
+
if (expectedRegistrationId && post.content?.registrationId === expectedRegistrationId) {
|
|
2507
|
+
return true;
|
|
2508
|
+
}
|
|
2509
|
+
if (expectedPeerId && post.content?.peerId === expectedPeerId) {
|
|
2510
|
+
return true;
|
|
2511
|
+
}
|
|
2512
|
+
return false;
|
|
2513
|
+
});
|
|
2514
|
+
if (match?.content) {
|
|
2515
|
+
return {
|
|
2516
|
+
itemHash: match.itemHash ?? null,
|
|
2517
|
+
hash: match.hash ?? null,
|
|
2518
|
+
sender: typeof match.address === "string" ? match.address : null,
|
|
2519
|
+
registrationId: match.content.registrationId,
|
|
2520
|
+
peerId: match.content.peerId,
|
|
2521
|
+
multiaddrs: Array.isArray(match.content.multiaddrs) ? match.content.multiaddrs : [],
|
|
2522
|
+
browserMultiaddrs: Array.isArray(match.content.browserMultiaddrs) ? match.content.browserMultiaddrs : []
|
|
2523
|
+
};
|
|
2524
|
+
}
|
|
2525
|
+
if (attempt < attempts - 1) {
|
|
2526
|
+
await sleep(delayMs);
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
return null;
|
|
2530
|
+
}
|
|
2484
2531
|
async function publishRelayBootstrapRegistration(args) {
|
|
2485
2532
|
const publisherAddress = args.publisherAddress ?? args.sender;
|
|
2486
2533
|
const ownerAddress = args.ownerAddress;
|
|
@@ -2990,6 +3037,7 @@ export {
|
|
|
2990
3037
|
verifyRootfsExists,
|
|
2991
3038
|
verifyUcGoPeerReachability,
|
|
2992
3039
|
waitForDeploymentResult,
|
|
3040
|
+
waitForRelayBootstrapRegistration,
|
|
2993
3041
|
waitForSetupEndpoint,
|
|
2994
3042
|
waitForVmRuntime
|
|
2995
3043
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.19",
|
|
4
4
|
"description": "Reusable Aleph deployment, runtime, and guest lifecycle logic.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@le-space/aleph-bootstrap": "0.3.
|
|
20
|
-
"@le-space/shared-types": "0.3.
|
|
19
|
+
"@le-space/aleph-bootstrap": "0.3.19",
|
|
20
|
+
"@le-space/shared-types": "0.3.19"
|
|
21
21
|
}
|
|
22
22
|
}
|