@le-space/core 0.6.1 → 0.6.3

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 +16 -3
  2. package/index.js +65 -8
  3. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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, VmBootstrapConfigSignalRecord, VmBootstrapConfigSignalType } 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, UcanStoreBootstrapPackage, PortMapping, VmBootstrapConfigRecord, VmBootstrapConfigAggregate, VmBootstrapConfigSignalRecord, VmBootstrapConfigSignalType } from '@le-space/shared-types';
3
3
 
4
- declare const DEFAULT_ALEPH_CHANNEL = "TEST";
4
+ declare const DEFAULT_ALEPH_CHANNEL = "ALEPH-CLOUDSOLUTIONS";
5
5
 
6
6
  declare const ITEM_HASH_RE: RegExp;
7
7
  declare const DEFAULT_ALEPH_API_HOST = "https://api.aleph.im";
@@ -660,6 +660,19 @@ declare function configureOrbitdbRelaySetup(args: {
660
660
  fetch: FetchLike;
661
661
  timeoutMs?: number;
662
662
  }): Promise<unknown>;
663
+ declare function configureUcanStore(args: {
664
+ hostIpv4: string;
665
+ setupPort: number;
666
+ publicIpv6?: string | null;
667
+ proxyUrl?: string | null;
668
+ webauthnOrigin?: string | null;
669
+ webauthnOriginFallbacks?: string | null;
670
+ adminDid?: string | null;
671
+ bootstrapPackage?: UcanStoreBootstrapPackage | null;
672
+ noStart?: boolean;
673
+ fetch: FetchLike;
674
+ timeoutMs?: number;
675
+ }): Promise<unknown>;
663
676
  declare function fetchUcGoPeerMetadata(args: {
664
677
  hostIpv4: string;
665
678
  setupPort: number;
@@ -943,4 +956,4 @@ declare function reconcileOwnerRelayBootstrapRegistrations(args: {
943
956
  } | null;
944
957
  }): Promise<OwnerRelayBootstrapReconcileResult>;
945
958
 
946
- export { type CrnCapacitySpec, type CrnEraseResult, type CrnResolutionResult, 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_HISTORY_RETENTION_MS, 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, eraseInstanceOnCrn, extractInsufficientBalanceMessage, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchMessageEnvelope, fetchPortForwardAggregate, fetchRelayMetadataForRuntime, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmBootstrapConfigAggregate, fetchVmBootstrapConfigSignals, fetchVmRuntime, filterDeployableCrns, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isTransientMessageLookupError, isValidSshPublicKey, listGeocodedCrns, listStaleVmBootstrapConfigAggregateMessageHashes, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, notifyCrnAllocationWithRetry, portForwardLabel, postBroadcastPayload, probeRootfsGateway, publishAggregateKey, publishRelayBootstrapRegistration, publishVmBootstrapConfig, quoteRequiredBudgetUnits, rankCandidateCrns, reconcileOwnerRelayBootstrapRegistrations, requestedPortFlags, requiredInstancePortForwards, resolveInstanceCrn, resolveRootfsReference, retainSuccessfulDeployments, selectPreferredCrn, selectedTier, signAlephMessage, signaturePayload, tierSpec, validateRootfsManifest, verifyRootfsExists, verifyUcGoPeerReachability, waitForDeploymentResult, waitForRelayBootstrapRegistration, waitForSetupEndpoint, waitForVmBootstrapConfigSignal, waitForVmRuntime };
959
+ export { type CrnCapacitySpec, type CrnEraseResult, type CrnResolutionResult, 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_HISTORY_RETENTION_MS, VM_BOOTSTRAP_CONFIG_SIGNAL_POST_TYPE, VM_BOOTSTRAP_CONFIG_SIGNAL_REF, appendDeploymentTokenToSshPublicKey, broadcastAlephMessage, buildPaymentQuote, cleanupFailedDeployment, configureOrbitdbRelaySetup, configureUcGoPeer, configureUcanStore, createDeploymentIntent, createDeploymentToken, createInstanceContent, createPortForwardAggregateContent, createRelayBootstrapRegistrationId, createReleaseMetadata, createUnsignedAggregateMessage, createUnsignedForgetMessage, createUnsignedInstanceMessage, createVmBootstrapConfigAggregateContent, deleteVmBootstrapConfig, deployInstance, describeRejectedDeployment, describeRuntimeAvailability, enrichCrnsWithGeo, ensureInstancePortForwards, eraseInstanceOnCrn, extractInsufficientBalanceMessage, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchMessageEnvelope, fetchPortForwardAggregate, fetchRelayMetadataForRuntime, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmBootstrapConfigAggregate, fetchVmBootstrapConfigSignals, fetchVmRuntime, filterDeployableCrns, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isTransientMessageLookupError, isValidSshPublicKey, listGeocodedCrns, listStaleVmBootstrapConfigAggregateMessageHashes, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, notifyCrnAllocationWithRetry, portForwardLabel, postBroadcastPayload, probeRootfsGateway, publishAggregateKey, publishRelayBootstrapRegistration, publishVmBootstrapConfig, quoteRequiredBudgetUnits, rankCandidateCrns, reconcileOwnerRelayBootstrapRegistrations, requestedPortFlags, requiredInstancePortForwards, resolveInstanceCrn, resolveRootfsReference, retainSuccessfulDeployments, selectPreferredCrn, selectedTier, signAlephMessage, signaturePayload, tierSpec, validateRootfsManifest, verifyRootfsExists, verifyUcGoPeerReachability, waitForDeploymentResult, waitForRelayBootstrapRegistration, waitForSetupEndpoint, waitForVmBootstrapConfigSignal, waitForVmRuntime };
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./chunk-4VNS5WPM.js";
2
2
 
3
3
  // src/constants.ts
4
- var DEFAULT_ALEPH_CHANNEL = "TEST";
4
+ var DEFAULT_ALEPH_CHANNEL = "ALEPH-CLOUDSOLUTIONS";
5
5
 
6
6
  // src/manifests.ts
7
7
  var ITEM_HASH_RE = /^[a-fA-F0-9]{64}$/;
@@ -687,15 +687,32 @@ async function waitForDeploymentResult(itemHash, options) {
687
687
  const attempts = Math.max(1, Number(options.attempts ?? 15));
688
688
  const delayMs = Math.max(0, Number(options.delayMs ?? 2e3));
689
689
  const sleep2 = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
690
- let lastResult = await inspectDeploymentResult(itemHash, options);
691
- options.onAttempt?.(lastResult, 1, attempts);
692
- for (let attempt = 1; attempt < attempts; attempt += 1) {
690
+ let lastResult = {
691
+ status: "unknown",
692
+ errorCode: null,
693
+ details: null,
694
+ rejectionReason: null,
695
+ references: []
696
+ };
697
+ for (let attempt = 1; attempt <= attempts; attempt += 1) {
698
+ try {
699
+ lastResult = await inspectDeploymentResult(itemHash, options);
700
+ } catch (error) {
701
+ if (!isTransientMessageLookupError(error)) {
702
+ throw error;
703
+ }
704
+ lastResult = {
705
+ ...lastResult,
706
+ rejectionReason: error instanceof Error ? error.message : String(error)
707
+ };
708
+ }
709
+ options.onAttempt?.(lastResult, attempt, attempts);
693
710
  if (lastResult.status === "processed" || lastResult.status === "rejected") {
694
711
  return lastResult;
695
712
  }
696
- await sleep2(delayMs);
697
- lastResult = await inspectDeploymentResult(itemHash, options);
698
- options.onAttempt?.(lastResult, attempt + 1, attempts);
713
+ if (attempt < attempts) {
714
+ await sleep2(delayMs);
715
+ }
699
716
  }
700
717
  return lastResult;
701
718
  }
@@ -2214,6 +2231,45 @@ async function configureOrbitdbRelaySetup(args) {
2214
2231
  clearTimeout(timeout);
2215
2232
  }
2216
2233
  }
2234
+ async function configureUcanStore(args) {
2235
+ const controller = new AbortController();
2236
+ const timeout = setTimeout(
2237
+ () => controller.abort(),
2238
+ Number(args.timeoutMs ?? 18e4)
2239
+ );
2240
+ const payload = {
2241
+ public_ipv4: args.hostIpv4,
2242
+ public_ipv6: args.publicIpv6 ?? void 0,
2243
+ proxy_url: args.proxyUrl ?? void 0,
2244
+ webauthn_origin: args.webauthnOrigin ?? void 0,
2245
+ webauthn_origin_fallbacks: args.webauthnOriginFallbacks ?? void 0,
2246
+ admin_did: args.adminDid ?? void 0,
2247
+ bootstrap_package: args.bootstrapPackage ?? void 0,
2248
+ no_start: args.noStart === true ? true : void 0
2249
+ };
2250
+ try {
2251
+ const response = await args.fetch(
2252
+ `http://${args.hostIpv4}:${args.setupPort}/configure`,
2253
+ {
2254
+ method: "POST",
2255
+ headers: {
2256
+ "content-type": "application/json"
2257
+ },
2258
+ body: JSON.stringify(payload),
2259
+ signal: controller.signal
2260
+ }
2261
+ );
2262
+ const responsePayload = await response.json().catch(() => null);
2263
+ if (!response.ok) {
2264
+ throw new Error(
2265
+ `Service setup request failed: ${response.status} ${typeof responsePayload === "string" ? responsePayload : JSON.stringify(responsePayload ?? {})}`
2266
+ );
2267
+ }
2268
+ return responsePayload;
2269
+ } finally {
2270
+ clearTimeout(timeout);
2271
+ }
2272
+ }
2217
2273
  async function fetchUcGoPeerMetadata(args) {
2218
2274
  const attempts = Math.max(1, Number(args.attempts ?? 60));
2219
2275
  const delayMs = Math.max(0, Number(args.delayMs ?? 3e3));
@@ -2281,7 +2337,7 @@ async function fetchUcGoPeerMetadata(args) {
2281
2337
  }
2282
2338
  }
2283
2339
  throw new Error(
2284
- `Relay metadata did not become ready after ${attempts} attempts: ${lastError ? lastError : typeof lastPayload === "string" ? lastPayload : JSON.stringify(lastPayload ?? {})}`
2340
+ `Guest metadata did not become ready after ${attempts} attempts: ${lastError ? lastError : typeof lastPayload === "string" ? lastPayload : JSON.stringify(lastPayload ?? {})}`
2285
2341
  );
2286
2342
  }
2287
2343
  async function verifyUcGoPeerReachability(args) {
@@ -3403,6 +3459,7 @@ export {
3403
3459
  cleanupFailedDeployment,
3404
3460
  configureOrbitdbRelaySetup,
3405
3461
  configureUcGoPeer,
3462
+ configureUcanStore,
3406
3463
  createDeploymentIntent,
3407
3464
  createDeploymentToken,
3408
3465
  createInstanceContent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/core",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
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.1",
28
- "@le-space/shared-types": "0.6.1"
27
+ "@le-space/aleph-bootstrap": "0.6.3",
28
+ "@le-space/shared-types": "0.6.3"
29
29
  }
30
30
  }