@le-space/core 0.3.24 → 0.3.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 +28 -2
  2. package/index.js +90 -0
  3. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _le_space_shared_types from '@le-space/shared-types';
2
- import { RootfsResolution, RootfsManifest, RootfsManifestState, CrnRecord, RootfsRequiredPortForward, PortForwardAggregate, PortForwardFlags, PortForwardAggregateEntry, MessageReference, InstanceExecution, MessageStatus, DeploymentInspectionResult, MessageInspectionResult, AlephBroadcastMessage, AlephBroadcastResponse, MessageSigner, MessageHasher, DeploymentProgressListener, AlephAggregateContent, AlephInstanceContent, DeploymentIntentEnvelope, DeploymentResult, InstanceAllocation, InstanceRuntimeDetails, InstanceWebAccess, RuntimeDiagnostics, PortMapping, VmBootstrapConfigRecord, VmBootstrapConfigAggregate } from '@le-space/shared-types';
2
+ import { RootfsResolution, RootfsManifest, RootfsManifestState, CrnRecord, RootfsRequiredPortForward, PortForwardAggregate, PortForwardFlags, PortForwardAggregateEntry, MessageReference, InstanceExecution, MessageStatus, DeploymentInspectionResult, MessageInspectionResult, AlephBroadcastMessage, AlephBroadcastResponse, MessageSigner, MessageHasher, DeploymentProgressListener, AlephAggregateContent, AlephInstanceContent, DeploymentIntentEnvelope, DeploymentResult, InstanceAllocation, InstanceRuntimeDetails, InstanceWebAccess, RuntimeDiagnostics, PortMapping, VmBootstrapConfigRecord, VmBootstrapConfigAggregate, VmBootstrapConfigSignalRecord, VmBootstrapConfigSignalType } from '@le-space/shared-types';
3
3
 
4
4
  declare const DEFAULT_ALEPH_CHANNEL = "TEST";
5
5
 
@@ -756,6 +756,8 @@ declare function publishRelayBootstrapRegistration(args: {
756
756
  }): Promise<RelayBootstrapPublicationResult>;
757
757
 
758
758
  declare const VM_BOOTSTRAP_CONFIG_AGGREGATE_KEY = "vm-bootstrap-config";
759
+ declare const VM_BOOTSTRAP_CONFIG_SIGNAL_REF = "vm-bootstrap-config";
760
+ declare const VM_BOOTSTRAP_CONFIG_SIGNAL_POST_TYPE = "vm-bootstrap-config-status";
759
761
  declare function fetchVmBootstrapConfigAggregate(address: string, options: {
760
762
  apiHost?: string;
761
763
  fetch: JsonFetchLike$1;
@@ -794,6 +796,30 @@ declare function deleteVmBootstrapConfig(args: {
794
796
  aggregateStatus: MessageStatus;
795
797
  aggregate: VmBootstrapConfigAggregate;
796
798
  }>;
799
+ declare function fetchVmBootstrapConfigSignals(args: {
800
+ deploymentToken?: string;
801
+ ownerAddress?: string;
802
+ instanceItemHash?: string;
803
+ fetch: JsonFetchLike$1;
804
+ apiHost?: string;
805
+ ref?: string;
806
+ postType?: string;
807
+ page?: number;
808
+ pagination?: number;
809
+ }): Promise<VmBootstrapConfigSignalRecord[]>;
810
+ declare function waitForVmBootstrapConfigSignal(args: {
811
+ deploymentToken: string;
812
+ ownerAddress: string;
813
+ instanceItemHash: string;
814
+ expectedStatus?: VmBootstrapConfigSignalType;
815
+ fetch: JsonFetchLike$1;
816
+ apiHost?: string;
817
+ ref?: string;
818
+ postType?: string;
819
+ attempts?: number;
820
+ delayMs?: number;
821
+ sleep?: (ms: number) => Promise<void>;
822
+ }): Promise<VmBootstrapConfigSignalRecord | null>;
797
823
 
798
824
  type JsonFetchLike = FetchLike;
799
825
  type RelayMetadataShape = {
@@ -862,4 +888,4 @@ declare function reconcileOwnerRelayBootstrapRegistrations(args: {
862
888
  } | null;
863
889
  }): Promise<OwnerRelayBootstrapReconcileResult>;
864
890
 
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 };
891
+ 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, VM_BOOTSTRAP_CONFIG_SIGNAL_POST_TYPE, VM_BOOTSTRAP_CONFIG_SIGNAL_REF, 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, fetchVmBootstrapConfigSignals, 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, waitForVmBootstrapConfigSignal, waitForVmRuntime };
package/index.js CHANGED
@@ -2634,6 +2634,16 @@ async function publishRelayBootstrapRegistration(args) {
2634
2634
 
2635
2635
  // src/bootstrap-config.ts
2636
2636
  var VM_BOOTSTRAP_CONFIG_AGGREGATE_KEY = "vm-bootstrap-config";
2637
+ var VM_BOOTSTRAP_CONFIG_SIGNAL_REF = "vm-bootstrap-config";
2638
+ var VM_BOOTSTRAP_CONFIG_SIGNAL_POST_TYPE = "vm-bootstrap-config-status";
2639
+ function parseJsonObject(value) {
2640
+ try {
2641
+ const parsed = JSON.parse(value);
2642
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
2643
+ } catch {
2644
+ return null;
2645
+ }
2646
+ }
2637
2647
  async function fetchVmBootstrapConfigAggregate(address, options) {
2638
2648
  const requestUrl = new URL(`/api/v0/aggregates/${address}.json`, options.apiHost ?? DEFAULT_ALEPH_API_HOST);
2639
2649
  requestUrl.searchParams.set("keys", VM_BOOTSTRAP_CONFIG_AGGREGATE_KEY);
@@ -2753,6 +2763,82 @@ async function deleteVmBootstrapConfig(args) {
2753
2763
  aggregate: content
2754
2764
  };
2755
2765
  }
2766
+ function normalizeVmBootstrapConfigSignalRecord(value) {
2767
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
2768
+ const candidate = value;
2769
+ const deploymentToken = typeof candidate.deploymentToken === "string" ? candidate.deploymentToken.trim() : "";
2770
+ const status = typeof candidate.status === "string" ? candidate.status.trim() : "";
2771
+ const profile = typeof candidate.profile === "string" ? candidate.profile.trim() : "";
2772
+ const ownerAddress = typeof candidate.ownerAddress === "string" ? candidate.ownerAddress.trim() : "";
2773
+ const instanceItemHash = typeof candidate.instanceItemHash === "string" ? candidate.instanceItemHash.trim() : "";
2774
+ const updatedAt = typeof candidate.updatedAt === "string" ? candidate.updatedAt.trim() : "";
2775
+ if (!deploymentToken || !status || !profile || !ownerAddress || !instanceItemHash || !updatedAt) {
2776
+ return null;
2777
+ }
2778
+ return {
2779
+ deploymentToken,
2780
+ status,
2781
+ profile,
2782
+ ownerAddress,
2783
+ instanceItemHash,
2784
+ updatedAt,
2785
+ publisherAddress: typeof candidate.publisherAddress === "string" && candidate.publisherAddress.trim() ? candidate.publisherAddress.trim() : null,
2786
+ authorization: candidate.authorization
2787
+ };
2788
+ }
2789
+ async function fetchVmBootstrapConfigSignals(args) {
2790
+ const requestUrl = new URL("/api/v0/posts.json", args.apiHost ?? DEFAULT_ALEPH_API_HOST);
2791
+ requestUrl.searchParams.set("refs", args.ref ?? VM_BOOTSTRAP_CONFIG_SIGNAL_REF);
2792
+ requestUrl.searchParams.set("types", args.postType ?? VM_BOOTSTRAP_CONFIG_SIGNAL_POST_TYPE);
2793
+ requestUrl.searchParams.set("pagination", String(Math.max(1, Number(args.pagination ?? 100))));
2794
+ requestUrl.searchParams.set("page", String(Math.max(1, Number(args.page ?? 1))));
2795
+ requestUrl.searchParams.set("sortOrder", "-1");
2796
+ const response = await args.fetch(requestUrl.toString(), { cache: "no-cache" });
2797
+ if (!response.ok) {
2798
+ throw new Error(`VM bootstrap config signal request failed: ${response.status}`);
2799
+ }
2800
+ const payload = await response.json();
2801
+ const expectedDeploymentToken = args.deploymentToken?.trim() ?? "";
2802
+ const expectedOwnerAddress = args.ownerAddress?.trim().toLowerCase() ?? "";
2803
+ const expectedInstanceItemHash = args.instanceItemHash?.trim() ?? "";
2804
+ return (payload.posts ?? []).map((entry) => {
2805
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) return null;
2806
+ const parsed = "content" in entry && entry.content && typeof entry.content === "object" && !Array.isArray(entry.content) ? entry.content : "item_content" in entry && typeof entry.item_content === "string" ? parseJsonObject(entry.item_content) : null;
2807
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
2808
+ const content = "deploymentToken" in parsed ? parsed : "content" in parsed && parsed.content && typeof parsed.content === "object" && !Array.isArray(parsed.content) ? parsed.content : null;
2809
+ if (!content || typeof content !== "object" || Array.isArray(content)) return null;
2810
+ return normalizeVmBootstrapConfigSignalRecord(content);
2811
+ }).filter((entry) => {
2812
+ if (!entry) return false;
2813
+ if (expectedDeploymentToken && entry.deploymentToken !== expectedDeploymentToken) return false;
2814
+ if (expectedOwnerAddress && entry.ownerAddress.toLowerCase() !== expectedOwnerAddress) return false;
2815
+ if (expectedInstanceItemHash && entry.instanceItemHash !== expectedInstanceItemHash) return false;
2816
+ return true;
2817
+ });
2818
+ }
2819
+ async function waitForVmBootstrapConfigSignal(args) {
2820
+ const attempts = Math.max(1, Number(args.attempts ?? 24));
2821
+ const delayMs = Math.max(0, Number(args.delayMs ?? 2500));
2822
+ const sleep2 = args.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
2823
+ const expectedStatus = args.expectedStatus ?? "applied";
2824
+ for (let attempt = 0; attempt < attempts; attempt += 1) {
2825
+ const signals = await fetchVmBootstrapConfigSignals({
2826
+ deploymentToken: args.deploymentToken,
2827
+ ownerAddress: args.ownerAddress,
2828
+ instanceItemHash: args.instanceItemHash,
2829
+ fetch: args.fetch,
2830
+ apiHost: args.apiHost,
2831
+ ref: args.ref,
2832
+ postType: args.postType
2833
+ }).catch(() => []);
2834
+ const match = signals.find((entry) => entry.status === expectedStatus) ?? null;
2835
+ if (match) return match;
2836
+ if (attempt < attempts - 1) {
2837
+ await sleep2(delayMs);
2838
+ }
2839
+ }
2840
+ return null;
2841
+ }
2756
2842
 
2757
2843
  // src/bootstrap-reconcile.ts
2758
2844
  function createRelayBootstrapRegistrationId(profile, instanceName, itemHash) {
@@ -2959,6 +3045,8 @@ export {
2959
3045
  SSH_PUBLIC_KEY_PATTERN,
2960
3046
  SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY,
2961
3047
  VM_BOOTSTRAP_CONFIG_AGGREGATE_KEY,
3048
+ VM_BOOTSTRAP_CONFIG_SIGNAL_POST_TYPE,
3049
+ VM_BOOTSTRAP_CONFIG_SIGNAL_REF,
2962
3050
  appendDeploymentTokenToSshPublicKey,
2963
3051
  broadcastAlephMessage,
2964
3052
  buildPaymentQuote,
@@ -2994,6 +3082,7 @@ export {
2994
3082
  fetchSchedulerAllocation,
2995
3083
  fetchUcGoPeerMetadata,
2996
3084
  fetchVmBootstrapConfigAggregate,
3085
+ fetchVmBootstrapConfigSignals,
2997
3086
  fetchVmRuntime,
2998
3087
  filterDeployableCrns,
2999
3088
  findCrnByHash,
@@ -3039,5 +3128,6 @@ export {
3039
3128
  waitForDeploymentResult,
3040
3129
  waitForRelayBootstrapRegistration,
3041
3130
  waitForSetupEndpoint,
3131
+ waitForVmBootstrapConfigSignal,
3042
3132
  waitForVmRuntime
3043
3133
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/core",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
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.24",
20
- "@le-space/shared-types": "0.3.24"
19
+ "@le-space/aleph-bootstrap": "0.3.26",
20
+ "@le-space/shared-types": "0.3.26"
21
21
  }
22
22
  }