@le-space/core 0.6.2 → 0.6.4

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 +9 -1
  2. package/index.js +36 -9
  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
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";
@@ -219,6 +219,9 @@ declare function broadcastAlephMessage(message: AlephBroadcastMessage, options:
219
219
  apiHost?: string;
220
220
  sync?: boolean;
221
221
  fetch: JsonFetchLike$1;
222
+ attempts?: number;
223
+ retryDelayMs?: number;
224
+ sleep?: (ms: number) => Promise<void>;
222
225
  }): Promise<{
223
226
  response: AlephBroadcastResponse;
224
227
  httpStatus: number;
@@ -522,6 +525,9 @@ declare function deployInstance(args: {
522
525
  channel?: string;
523
526
  sync?: boolean;
524
527
  now?: number;
528
+ broadcastAttempts?: number;
529
+ broadcastRetryDelayMs?: number;
530
+ broadcastSleep?: (ms: number) => Promise<void>;
525
531
  onProgress?: DeploymentProgressListener;
526
532
  }): Promise<DeploymentResult>;
527
533
 
@@ -665,6 +671,8 @@ declare function configureUcanStore(args: {
665
671
  setupPort: number;
666
672
  publicIpv6?: string | null;
667
673
  proxyUrl?: string | null;
674
+ serviceDid?: string | null;
675
+ serviceOrigin?: string | null;
668
676
  webauthnOrigin?: string | null;
669
677
  webauthnOriginFallbacks?: string | null;
670
678
  adminDid?: string | null;
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
  }
@@ -747,7 +764,9 @@ async function postBroadcastPayload(body, options) {
747
764
  }
748
765
  async function broadcastAlephMessage(message, options) {
749
766
  const requestBody = { sync: options.sync ?? false, message };
750
- const maxAttempts = 3;
767
+ const maxAttempts = Math.max(1, Number(options.attempts ?? 3));
768
+ const retryDelayMs = Math.max(0, Number(options.retryDelayMs ?? 0));
769
+ const sleep2 = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
751
770
  for (let index = 0; index < maxAttempts; index += 1) {
752
771
  const result = await postBroadcastPayload(requestBody, {
753
772
  apiHost: options.apiHost,
@@ -760,6 +779,9 @@ async function broadcastAlephMessage(message, options) {
760
779
  if (!canRetry) {
761
780
  throw new Error(`Broadcast failed: ${result.httpStatus} ${JSON.stringify(result.response ?? {})}`);
762
781
  }
782
+ if (retryDelayMs > 0) {
783
+ await sleep2(retryDelayMs);
784
+ }
763
785
  }
764
786
  throw new Error("Broadcast failed: retry budget exhausted");
765
787
  }
@@ -1967,7 +1989,10 @@ async function deployInstance(args) {
1967
1989
  const { response, httpStatus } = await broadcastAlephMessage(message, {
1968
1990
  apiHost: args.apiHost,
1969
1991
  sync: args.sync,
1970
- fetch: args.fetch
1992
+ fetch: args.fetch,
1993
+ attempts: args.broadcastAttempts,
1994
+ retryDelayMs: args.broadcastRetryDelayMs,
1995
+ sleep: args.broadcastSleep
1971
1996
  });
1972
1997
  const status = httpStatus === 202 ? "pending" : typeof response.message_status === "string" ? response.message_status : "unknown";
1973
1998
  args.onProgress?.({
@@ -2224,6 +2249,8 @@ async function configureUcanStore(args) {
2224
2249
  public_ipv4: args.hostIpv4,
2225
2250
  public_ipv6: args.publicIpv6 ?? void 0,
2226
2251
  proxy_url: args.proxyUrl ?? void 0,
2252
+ service_did: args.serviceDid ?? void 0,
2253
+ service_origin: args.serviceOrigin ?? void 0,
2227
2254
  webauthn_origin: args.webauthnOrigin ?? void 0,
2228
2255
  webauthn_origin_fallbacks: args.webauthnOriginFallbacks ?? void 0,
2229
2256
  admin_did: args.adminDid ?? void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/core",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
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.2",
28
- "@le-space/shared-types": "0.6.2"
27
+ "@le-space/aleph-bootstrap": "0.6.4",
28
+ "@le-space/shared-types": "0.6.4"
29
29
  }
30
30
  }