@le-space/core 0.9.9 → 0.10.0

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.
@@ -5,9 +5,9 @@ import {
5
5
  __toESM
6
6
  } from "./chunk-7DQDWJI5.js";
7
7
 
8
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/constants.js
8
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/constants.js
9
9
  var require_constants = __commonJS({
10
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/constants.js"(exports, module) {
10
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/constants.js"(exports, module) {
11
11
  "use strict";
12
12
  var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
13
13
  var hasBlob = typeof Blob !== "undefined";
@@ -28,9 +28,9 @@ var require_constants = __commonJS({
28
28
  }
29
29
  });
30
30
 
31
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/buffer-util.js
31
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/buffer-util.js
32
32
  var require_buffer_util = __commonJS({
33
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/buffer-util.js"(exports, module) {
33
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/buffer-util.js"(exports, module) {
34
34
  "use strict";
35
35
  var { EMPTY_BUFFER } = require_constants();
36
36
  var FastBuffer = Buffer[Symbol.species];
@@ -103,9 +103,9 @@ var require_buffer_util = __commonJS({
103
103
  }
104
104
  });
105
105
 
106
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/limiter.js
106
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/limiter.js
107
107
  var require_limiter = __commonJS({
108
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/limiter.js"(exports, module) {
108
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/limiter.js"(exports, module) {
109
109
  "use strict";
110
110
  var kDone = /* @__PURE__ */ Symbol("kDone");
111
111
  var kRun = /* @__PURE__ */ Symbol("kRun");
@@ -153,9 +153,9 @@ var require_limiter = __commonJS({
153
153
  }
154
154
  });
155
155
 
156
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/permessage-deflate.js
156
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/permessage-deflate.js
157
157
  var require_permessage_deflate = __commonJS({
158
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
158
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
159
159
  "use strict";
160
160
  var zlib = __require("zlib");
161
161
  var bufferUtil = require_buffer_util();
@@ -282,7 +282,7 @@ var require_permessage_deflate = __commonJS({
282
282
  acceptAsServer(offers) {
283
283
  const opts = this._options;
284
284
  const accepted = offers.find((params) => {
285
- if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && !params.client_max_window_bits) {
285
+ if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && (typeof params.client_max_window_bits === "number" ? opts.clientMaxWindowBits > params.client_max_window_bits : !params.client_max_window_bits)) {
286
286
  return false;
287
287
  }
288
288
  return true;
@@ -536,9 +536,9 @@ var require_permessage_deflate = __commonJS({
536
536
  }
537
537
  });
538
538
 
539
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/validation.js
539
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/validation.js
540
540
  var require_validation = __commonJS({
541
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/validation.js"(exports, module) {
541
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/validation.js"(exports, module) {
542
542
  "use strict";
543
543
  var { isUtf8 } = __require("buffer");
544
544
  var { hasBlob } = require_constants();
@@ -737,9 +737,9 @@ var require_validation = __commonJS({
737
737
  }
738
738
  });
739
739
 
740
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/receiver.js
740
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/receiver.js
741
741
  var require_receiver = __commonJS({
742
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/receiver.js"(exports, module) {
742
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/receiver.js"(exports, module) {
743
743
  "use strict";
744
744
  var { Writable } = __require("stream");
745
745
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -1360,9 +1360,9 @@ var require_receiver = __commonJS({
1360
1360
  }
1361
1361
  });
1362
1362
 
1363
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/sender.js
1363
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/sender.js
1364
1364
  var require_sender = __commonJS({
1365
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/sender.js"(exports, module) {
1365
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/sender.js"(exports, module) {
1366
1366
  "use strict";
1367
1367
  var { Duplex } = __require("stream");
1368
1368
  var { randomFillSync } = __require("crypto");
@@ -1853,9 +1853,9 @@ var require_sender = __commonJS({
1853
1853
  }
1854
1854
  });
1855
1855
 
1856
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/event-target.js
1856
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/event-target.js
1857
1857
  var require_event_target = __commonJS({
1858
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/event-target.js"(exports, module) {
1858
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/event-target.js"(exports, module) {
1859
1859
  "use strict";
1860
1860
  var { kForOnEventAttribute, kListener } = require_constants();
1861
1861
  var kCode = /* @__PURE__ */ Symbol("kCode");
@@ -2082,9 +2082,9 @@ var require_event_target = __commonJS({
2082
2082
  }
2083
2083
  });
2084
2084
 
2085
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/extension.js
2085
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/extension.js
2086
2086
  var require_extension = __commonJS({
2087
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/extension.js"(exports, module) {
2087
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/extension.js"(exports, module) {
2088
2088
  "use strict";
2089
2089
  var { tokenChars } = require_validation();
2090
2090
  function push(dest, name, elem) {
@@ -2235,9 +2235,9 @@ var require_extension = __commonJS({
2235
2235
  }
2236
2236
  });
2237
2237
 
2238
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/websocket.js
2238
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/websocket.js
2239
2239
  var require_websocket = __commonJS({
2240
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/websocket.js"(exports, module) {
2240
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/websocket.js"(exports, module) {
2241
2241
  "use strict";
2242
2242
  var EventEmitter = __require("events");
2243
2243
  var https = __require("https");
@@ -2300,11 +2300,23 @@ var require_websocket = __commonJS({
2300
2300
  this._isServer = false;
2301
2301
  this._redirects = 0;
2302
2302
  if (protocols === void 0) {
2303
- protocols = [];
2303
+ if (!options || options.protocols === void 0) {
2304
+ protocols = [];
2305
+ } else if (Array.isArray(options.protocols)) {
2306
+ protocols = options.protocols;
2307
+ } else {
2308
+ protocols = [options.protocols];
2309
+ }
2304
2310
  } else if (!Array.isArray(protocols)) {
2305
2311
  if (typeof protocols === "object" && protocols !== null) {
2306
2312
  options = protocols;
2307
- protocols = [];
2313
+ if (options.protocols === void 0) {
2314
+ protocols = [];
2315
+ } else if (Array.isArray(options.protocols)) {
2316
+ protocols = options.protocols;
2317
+ } else {
2318
+ protocols = [options.protocols];
2319
+ }
2308
2320
  } else {
2309
2321
  protocols = [protocols];
2310
2322
  }
@@ -2501,7 +2513,6 @@ var require_websocket = __commonJS({
2501
2513
  }
2502
2514
  return;
2503
2515
  }
2504
- this._readyState = _WebSocket.CLOSING;
2505
2516
  this._sender.close(code, data, !this._isServer, (err) => {
2506
2517
  if (err) return;
2507
2518
  this._closeFrameSent = true;
@@ -2509,6 +2520,7 @@ var require_websocket = __commonJS({
2509
2520
  this._socket.end();
2510
2521
  }
2511
2522
  });
2523
+ this._readyState = _WebSocket.CLOSING;
2512
2524
  setCloseTimer(this);
2513
2525
  }
2514
2526
  /**
@@ -2733,6 +2745,7 @@ var require_websocket = __commonJS({
2733
2745
  socketPath: void 0,
2734
2746
  hostname: void 0,
2735
2747
  protocol: void 0,
2748
+ protocols: void 0,
2736
2749
  timeout: void 0,
2737
2750
  method: "GET",
2738
2751
  host: void 0,
@@ -3131,9 +3144,9 @@ var require_websocket = __commonJS({
3131
3144
  }
3132
3145
  });
3133
3146
 
3134
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/stream.js
3147
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/stream.js
3135
3148
  var require_stream = __commonJS({
3136
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/stream.js"(exports, module) {
3149
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/stream.js"(exports, module) {
3137
3150
  "use strict";
3138
3151
  var WebSocket4 = require_websocket();
3139
3152
  var { Duplex } = __require("stream");
@@ -3229,9 +3242,9 @@ var require_stream = __commonJS({
3229
3242
  }
3230
3243
  });
3231
3244
 
3232
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/subprotocol.js
3245
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/subprotocol.js
3233
3246
  var require_subprotocol = __commonJS({
3234
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/subprotocol.js"(exports, module) {
3247
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/subprotocol.js"(exports, module) {
3235
3248
  "use strict";
3236
3249
  var { tokenChars } = require_validation();
3237
3250
  function parse(header) {
@@ -3274,9 +3287,9 @@ var require_subprotocol = __commonJS({
3274
3287
  }
3275
3288
  });
3276
3289
 
3277
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/websocket-server.js
3290
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/websocket-server.js
3278
3291
  var require_websocket_server = __commonJS({
3279
- "../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/lib/websocket-server.js"(exports, module) {
3292
+ "../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/websocket-server.js"(exports, module) {
3280
3293
  "use strict";
3281
3294
  var EventEmitter = __require("events");
3282
3295
  var http = __require("http");
@@ -3675,7 +3688,7 @@ var require_websocket_server = __commonJS({
3675
3688
  }
3676
3689
  });
3677
3690
 
3678
- // ../../node_modules/.pnpm/ws@8.21.2/node_modules/ws/wrapper.mjs
3691
+ // ../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/wrapper.mjs
3679
3692
  var wrapper_exports = {};
3680
3693
  __export(wrapper_exports, {
3681
3694
  PerMessageDeflate: () => import_permessage_deflate.default,
@@ -3698,7 +3711,7 @@ var import_websocket = __toESM(require_websocket(), 1);
3698
3711
  var import_websocket_server = __toESM(require_websocket_server(), 1);
3699
3712
  var wrapper_default = import_websocket.default;
3700
3713
 
3701
- // ../../node_modules/.pnpm/isows@1.0.7_ws@8.21.2/node_modules/isows/_esm/utils.js
3714
+ // ../../node_modules/.pnpm/isows@1.0.7_ws@8.22.0/node_modules/isows/_esm/utils.js
3702
3715
  function getNativeWebSocket() {
3703
3716
  if (typeof WebSocket !== "undefined")
3704
3717
  return WebSocket;
@@ -3711,7 +3724,7 @@ function getNativeWebSocket() {
3711
3724
  throw new Error("`WebSocket` is not supported in this environment");
3712
3725
  }
3713
3726
 
3714
- // ../../node_modules/.pnpm/isows@1.0.7_ws@8.21.2/node_modules/isows/_esm/index.js
3727
+ // ../../node_modules/.pnpm/isows@1.0.7_ws@8.22.0/node_modules/isows/_esm/index.js
3715
3728
  var WebSocket3 = (() => {
3716
3729
  try {
3717
3730
  return getNativeWebSocket();
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, UcanStoreBootstrapPackage, PortMapping, VmBootstrapConfigRecord, VmBootstrapConfigAggregate, VmBootstrapConfigSignalRecord, VmBootstrapConfigSignalType } from '@le-space/shared-types';
2
+ import { RootfsResolution, RootfsManifest, RootfsManifestState, TeeMode, TrustedExecution, 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
4
  declare const DEFAULT_ALEPH_CHANNEL = "ALEPH-CLOUDSOLUTIONS";
5
5
 
@@ -28,6 +28,56 @@ declare function resolveRootfsReference(itemHash: string, options: {
28
28
  fetch: FetchLike;
29
29
  }): Promise<RootfsResolution | null>;
30
30
 
31
+ /**
32
+ * The oldest aleph-vm a confidential instance may land on. The SEV-SNP launch
33
+ * measurement covers kernel, initrd, cmdline and owner key but not the disk;
34
+ * 2.1.2 is where a host-supplied LUKS2 header with a null cipher stopped being
35
+ * accepted (aleph-im/aleph-vm#1280).
36
+ */
37
+ declare const MIN_CONFIDENTIAL_ALEPH_VM_VERSION = "2.1.2";
38
+ /**
39
+ * SEV-SNP 64-bit guest policy aleph-rs uses by default (aleph-types
40
+ * DEFAULT_SNP_POLICY): bit 17 is reserved and must be 1, bit 16 allows SMT.
41
+ */
42
+ declare const DEFAULT_SEV_SNP_POLICY = 196608;
43
+ interface ConfidentialRequirement {
44
+ /** Defaults to sev_snp; "sev" also accepts SEV / SEV-ES-only nodes. */
45
+ mode?: Extract<TeeMode, 'sev' | 'sev_snp'>;
46
+ /** Defaults to MIN_CONFIDENTIAL_ALEPH_VM_VERSION. */
47
+ minVersion?: string;
48
+ }
49
+ /** Compares two aleph-vm versions; null when either does not parse. */
50
+ declare function compareAlephVmVersions(left: string, right: string): number | null;
51
+ /**
52
+ * Whether a node may take a confidential instance. Strict on purpose: a node
53
+ * whose TEE support or version is unknown is refused, because landing a
54
+ * confidential workload on a node that cannot protect it is worse than not
55
+ * deploying. Enrich aggregate-sourced records with `enrichCrnsWithTee` first.
56
+ */
57
+ declare function isConfidentialCrn(crn: CrnRecord, requirement?: ConfidentialRequirement): boolean;
58
+ /**
59
+ * Reads a node's CPU features, TEE properties and aleph-vm version from the
60
+ * node itself and returns an enriched copy. Fields the node does not answer
61
+ * for are left as they were.
62
+ */
63
+ declare function probeCrnTee<TCrn extends CrnRecord>(crn: TCrn, options: {
64
+ fetch: FetchLike;
65
+ }): Promise<TCrn>;
66
+ /**
67
+ * Probes the nodes whose TEE support or version is not known yet (the core
68
+ * channel aggregate carries neither), a few at a time, keeping the order.
69
+ */
70
+ declare function enrichCrnsWithTee<TCrn extends CrnRecord>(crns: ReadonlyArray<TCrn>, options: {
71
+ fetch: FetchLike;
72
+ concurrency?: number;
73
+ }): Promise<TCrn[]>;
74
+ /**
75
+ * Refuses a trusted_execution block Aleph would reject or, worse, accept in a
76
+ * weaker form: measured modes need the runtime bundle and the expected
77
+ * measurements, legacy SEV needs a firmware hash.
78
+ */
79
+ declare function assertValidTrustedExecution(value: TrustedExecution): void;
80
+
31
81
  declare const DEFAULT_CRN_LIST_URL = "https://crns-list.aleph.sh/crns.json";
32
82
  declare const DEFAULT_COUNTRY_LOOKUP_BASE_URL = "https://api.country.is";
33
83
  declare const DEFAULT_DNS_RESOLVE_URL = "https://dns.google/resolve";
@@ -43,6 +93,8 @@ interface CrnCapacitySpec {
43
93
  declare function filterDeployableCrns<TCrn extends CrnRecord>(crns: ReadonlyArray<TCrn>, options?: {
44
94
  excludedHashes?: ReadonlyArray<string>;
45
95
  spec?: CrnCapacitySpec | null;
96
+ /** Keep only nodes that can take a confidential instance (see isConfidentialCrn). */
97
+ confidential?: ConfidentialRequirement | null;
46
98
  }): TCrn[];
47
99
  declare function fetchCrnsFromList(options: {
48
100
  url?: string;
@@ -543,6 +595,8 @@ declare function createInstanceContent(args: {
543
595
  crnHash?: string;
544
596
  deployer?: string;
545
597
  now?: number;
598
+ /** Makes the instance confidential; validated before anything is built. */
599
+ trustedExecution?: TrustedExecution;
546
600
  }): AlephInstanceContent;
547
601
  declare function createUnsignedInstanceMessage(args: {
548
602
  sender: string;
@@ -1026,4 +1080,4 @@ declare function reconcileOwnerRelayBootstrapRegistrations(args: {
1026
1080
  } | null;
1027
1081
  }): Promise<OwnerRelayBootstrapReconcileResult>;
1028
1082
 
1029
- export { type CrnCapacitySpec, type CrnEraseResult, type CrnResolutionResult, type CrnSource, type CrnSourceOptions, type CrnSourceResult, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_CHANNEL, DEFAULT_COUNTRY_LOOKUP_BASE_URL, DEFAULT_CRN_AGGREGATE_ADDRESS, DEFAULT_CRN_AGGREGATE_API_HOSTS, DEFAULT_CRN_AGGREGATE_KEY, 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, crnExecutionAbsent, deleteVmBootstrapConfig, deployInstance, describeRejectedDeployment, describeRuntimeAvailability, enrichCrnsWithGeo, ensureInstancePortForwards, eraseInstanceOnCrn, extractInsufficientBalanceMessage, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchCrnsFromAggregate, fetchCrnsFromList, fetchCrnsWithSource, fetchMessageEnvelope, fetchPortForwardAggregate, fetchRelayMetadataForRuntime, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmBootstrapConfigAggregate, fetchVmBootstrapConfigSignals, fetchVmRuntime, filterDeployableCrns, filterReachableCrns, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isTransientMessageLookupError, isValidSshPublicKey, listGeocodedCrns, listStaleVmBootstrapConfigAggregateMessageHashes, mapResourceNodesToCrns, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, notifyCrnAllocationWithRetry, portForwardLabel, postBroadcastPayload, probeCrnAvailability, 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 };
1083
+ export { type ConfidentialRequirement, type CrnCapacitySpec, type CrnEraseResult, type CrnResolutionResult, type CrnSource, type CrnSourceOptions, type CrnSourceResult, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_CHANNEL, DEFAULT_COUNTRY_LOOKUP_BASE_URL, DEFAULT_CRN_AGGREGATE_ADDRESS, DEFAULT_CRN_AGGREGATE_API_HOSTS, DEFAULT_CRN_AGGREGATE_KEY, DEFAULT_CRN_LIST_URL, DEFAULT_DNS_RESOLVE_URL, DEFAULT_INSTANCE_PORT_FORWARDS, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_SCHEDULER_ALLOCATION_URL, DEFAULT_SEV_SNP_POLICY, DEFAULT_TWO_N_SIX_HASH_URL, type FetchLike, type FetchLikeResponse, type HttpProbeResult, ITEM_HASH_RE, type JsonFetchLike$1 as JsonFetchLike, type JsonFetchLikeResponse, MIN_CONFIDENTIAL_ALEPH_VM_VERSION, 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, assertValidTrustedExecution, broadcastAlephMessage, buildPaymentQuote, cleanupFailedDeployment, compareAlephVmVersions, configureOrbitdbRelaySetup, configureUcGoPeer, configureUcanStore, createDeploymentIntent, createDeploymentToken, createInstanceContent, createPortForwardAggregateContent, createRelayBootstrapRegistrationId, createReleaseMetadata, createUnsignedAggregateMessage, createUnsignedForgetMessage, createUnsignedInstanceMessage, createVmBootstrapConfigAggregateContent, crnExecutionAbsent, deleteVmBootstrapConfig, deployInstance, describeRejectedDeployment, describeRuntimeAvailability, enrichCrnsWithGeo, enrichCrnsWithTee, ensureInstancePortForwards, eraseInstanceOnCrn, extractInsufficientBalanceMessage, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchCrnsFromAggregate, fetchCrnsFromList, fetchCrnsWithSource, fetchMessageEnvelope, fetchPortForwardAggregate, fetchRelayMetadataForRuntime, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmBootstrapConfigAggregate, fetchVmBootstrapConfigSignals, fetchVmRuntime, filterDeployableCrns, filterReachableCrns, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isConfidentialCrn, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isTransientMessageLookupError, isValidSshPublicKey, listGeocodedCrns, listStaleVmBootstrapConfigAggregateMessageHashes, mapResourceNodesToCrns, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, notifyCrnAllocationWithRetry, portForwardLabel, postBroadcastPayload, probeCrnAvailability, probeCrnTee, 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
@@ -198,6 +198,114 @@ async function resolveRootfsReference(itemHash, options) {
198
198
  };
199
199
  }
200
200
 
201
+ // src/confidential.ts
202
+ var MIN_CONFIDENTIAL_ALEPH_VM_VERSION = "2.1.2";
203
+ var DEFAULT_SEV_SNP_POLICY = 196608;
204
+ var SNP_POLICY_RESERVED_BIT_17 = 131072;
205
+ function versionParts(value) {
206
+ const match = /^v?(\d+)\.(\d+)(?:\.(\d+))?/.exec(value.trim());
207
+ if (!match) return null;
208
+ return [Number(match[1]), Number(match[2]), Number(match[3] ?? 0)];
209
+ }
210
+ function compareAlephVmVersions(left, right) {
211
+ const a = versionParts(left);
212
+ const b = versionParts(right);
213
+ if (!a || !b) return null;
214
+ for (let i = 0; i < 3; i++) {
215
+ if (a[i] !== b[i]) return a[i] - b[i];
216
+ }
217
+ return 0;
218
+ }
219
+ function supportsSevSnp(crn) {
220
+ return Boolean(crn.tee?.sev_snp) || (crn.cpu_features ?? []).includes("sev_snp");
221
+ }
222
+ function supportsSev(crn) {
223
+ if (supportsSevSnp(crn)) return true;
224
+ if ((crn.cpu_features ?? []).includes("sev")) return true;
225
+ return crn.confidential_support === true;
226
+ }
227
+ function isConfidentialCrn(crn, requirement = {}) {
228
+ const mode = requirement.mode ?? "sev_snp";
229
+ if (mode === "sev_snp" ? !supportsSevSnp(crn) : !supportsSev(crn)) return false;
230
+ if (!crn.version) return false;
231
+ const comparison = compareAlephVmVersions(crn.version, requirement.minVersion ?? MIN_CONFIDENTIAL_ALEPH_VM_VERSION);
232
+ return comparison !== null && comparison >= 0;
233
+ }
234
+ function asStringArray(value) {
235
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : null;
236
+ }
237
+ async function fetchJson(fetch, url) {
238
+ try {
239
+ const response = await fetch(url, { cache: "no-cache" });
240
+ return response.ok ? await response.json() : null;
241
+ } catch {
242
+ return null;
243
+ }
244
+ }
245
+ async function probeCrnTee(crn, options) {
246
+ const address = crn.address ? String(crn.address).replace(/\/+$/, "") : "";
247
+ if (!address) return crn;
248
+ const [usage, config] = await Promise.all([
249
+ fetchJson(options.fetch, `${address}/about/usage/system`),
250
+ fetchJson(options.fetch, `${address}/status/config`)
251
+ ]);
252
+ const enriched = { ...crn };
253
+ const properties = usage?.properties;
254
+ const features = asStringArray(properties?.cpu?.features);
255
+ if (features) enriched.cpu_features = features;
256
+ if (properties && "tee" in properties) {
257
+ enriched.tee = properties.tee && typeof properties.tee === "object" ? properties.tee : null;
258
+ }
259
+ const version = config?.version;
260
+ if (typeof version === "string" && version) enriched.version = version;
261
+ return enriched;
262
+ }
263
+ async function enrichCrnsWithTee(crns, options) {
264
+ const result = [...crns];
265
+ const pending = result.map((crn, index) => ({ crn, index })).filter(({ crn }) => !crn.version || crn.cpu_features == null && crn.tee == null);
266
+ const concurrency = Math.max(1, Number(options.concurrency) || 8);
267
+ for (let start = 0; start < pending.length; start += concurrency) {
268
+ const batch = pending.slice(start, start + concurrency);
269
+ const probed = await Promise.all(batch.map(({ crn }) => probeCrnTee(crn, { fetch: options.fetch })));
270
+ batch.forEach(({ index }, i) => {
271
+ result[index] = probed[i];
272
+ });
273
+ }
274
+ return result;
275
+ }
276
+ var HEX_HASH = /^[a-fA-F0-9]{64}$/;
277
+ function assertValidTrustedExecution(value) {
278
+ const mode = value.mode ?? "sev";
279
+ if (mode === "sev") {
280
+ if (!value.firmware || !HEX_HASH.test(value.firmware)) {
281
+ throw new Error("trusted_execution: legacy SEV needs a 64-character firmware item hash.");
282
+ }
283
+ if (value.runtime || value.measurements) {
284
+ throw new Error("trusted_execution: runtime and measurements belong to measured modes, not legacy SEV.");
285
+ }
286
+ return;
287
+ }
288
+ if (value.firmware) {
289
+ throw new Error(`trusted_execution: firmware is for legacy SEV only, not ${mode}.`);
290
+ }
291
+ if (!value.runtime || !HEX_HASH.test(value.runtime)) {
292
+ throw new Error(`trusted_execution: ${mode} needs the runtime bundle's 64-character item hash.`);
293
+ }
294
+ const measurements = value.measurements ?? [];
295
+ if (measurements.length === 0 || measurements.some((m) => m.platform !== mode || Object.keys(m.registers ?? {}).length === 0)) {
296
+ throw new Error(`trusted_execution: ${mode} needs expected measurements for platform ${mode}.`);
297
+ }
298
+ if (mode === "sev_snp" && value.policy !== void 0 && (value.policy & SNP_POLICY_RESERVED_BIT_17) === 0) {
299
+ throw new Error("trusted_execution: an SEV-SNP policy must set the reserved bit 17 (e.g. 0x30000).");
300
+ }
301
+ if (mode === "tdx" && value.policy !== void 0) {
302
+ throw new Error("trusted_execution: tdx has no host-chosen policy; leave it unset.");
303
+ }
304
+ if (value.attestation_port !== void 0 && !(Number.isInteger(value.attestation_port) && value.attestation_port > 0 && value.attestation_port < 65536)) {
305
+ throw new Error("trusted_execution: attestation_port must be a TCP port.");
306
+ }
307
+ }
308
+
201
309
  // src/crns.ts
202
310
  var DEFAULT_CRN_LIST_URL = "https://crns-list.aleph.sh/crns.json";
203
311
  var DEFAULT_COUNTRY_LOOKUP_BASE_URL = "https://api.country.is";
@@ -272,8 +380,9 @@ function shuffleTopPool(sorted, poolSize = TOP_CRN_POOL_SIZE) {
272
380
  return [...pool, ...sorted.slice(poolSize)];
273
381
  }
274
382
  function filterDeployableCrns(crns, options = {}) {
383
+ const confidential = options.confidential;
275
384
  return scoreSortedCrns(
276
- compatibleCrns(crns, options.excludedHashes).filter((crn) => hasCrnCapacity(crn, options.spec))
385
+ compatibleCrns(crns, options.excludedHashes).filter((crn) => hasCrnCapacity(crn, options.spec)).filter((crn) => !confidential || isConfidentialCrn(crn, confidential))
277
386
  );
278
387
  }
279
388
  async function resolveHostIp(host, options) {
@@ -375,6 +484,8 @@ function mapResourceNodesToCrns(resourceNodes) {
375
484
  if (name) record.name = name;
376
485
  const score = aggregateScore(node);
377
486
  if (score != null) record.score = score;
487
+ const owner = asString(node.owner);
488
+ if (owner) record.owner = owner;
378
489
  return record;
379
490
  });
380
491
  }
@@ -2038,6 +2149,9 @@ function createInstanceContent(args) {
2038
2149
  if (!args.rootfsItemHash || !/^[a-fA-F0-9]{64}$/.test(args.rootfsItemHash)) {
2039
2150
  throw new Error("rootfsItemHash must be a 64-character Aleph item hash.");
2040
2151
  }
2152
+ if (args.trustedExecution) {
2153
+ assertValidTrustedExecution(args.trustedExecution);
2154
+ }
2041
2155
  return {
2042
2156
  address: args.address,
2043
2157
  time: args.now ?? Date.now() / 1e3,
@@ -2049,7 +2163,8 @@ function createInstanceContent(args) {
2049
2163
  aleph_api: true,
2050
2164
  hypervisor: "qemu",
2051
2165
  reproducible: false,
2052
- shared_cache: false
2166
+ shared_cache: false,
2167
+ ...args.trustedExecution ? { trusted_execution: args.trustedExecution } : {}
2053
2168
  },
2054
2169
  resources: {
2055
2170
  vcpus: Number(args.vcpus),
@@ -3756,8 +3871,10 @@ export {
3756
3871
  DEFAULT_INSTANCE_PORT_FORWARDS,
3757
3872
  DEFAULT_IPFS_GATEWAY_BASE_URL,
3758
3873
  DEFAULT_SCHEDULER_ALLOCATION_URL,
3874
+ DEFAULT_SEV_SNP_POLICY,
3759
3875
  DEFAULT_TWO_N_SIX_HASH_URL,
3760
3876
  ITEM_HASH_RE,
3877
+ MIN_CONFIDENTIAL_ALEPH_VM_VERSION,
3761
3878
  SSH_PUBLIC_KEY_PATTERN,
3762
3879
  SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY,
3763
3880
  VM_BOOTSTRAP_CONFIG_AGGREGATE_KEY,
@@ -3765,9 +3882,11 @@ export {
3765
3882
  VM_BOOTSTRAP_CONFIG_SIGNAL_POST_TYPE,
3766
3883
  VM_BOOTSTRAP_CONFIG_SIGNAL_REF,
3767
3884
  appendDeploymentTokenToSshPublicKey,
3885
+ assertValidTrustedExecution,
3768
3886
  broadcastAlephMessage,
3769
3887
  buildPaymentQuote,
3770
3888
  cleanupFailedDeployment,
3889
+ compareAlephVmVersions,
3771
3890
  configureOrbitdbRelaySetup,
3772
3891
  configureUcGoPeer,
3773
3892
  configureUcanStore,
@@ -3787,6 +3906,7 @@ export {
3787
3906
  describeRejectedDeployment,
3788
3907
  describeRuntimeAvailability,
3789
3908
  enrichCrnsWithGeo,
3909
+ enrichCrnsWithTee,
3790
3910
  ensureInstancePortForwards,
3791
3911
  eraseInstanceOnCrn,
3792
3912
  extractInsufficientBalanceMessage,
@@ -3813,6 +3933,7 @@ export {
3813
3933
  forgetAlephMessages,
3814
3934
  inspectDeploymentResult,
3815
3935
  inspectMessageResult,
3936
+ isConfidentialCrn,
3816
3937
  isInvalidMessageFormatResponse,
3817
3938
  isRetryableBroadcastFailure,
3818
3939
  isTransientMessageLookupError,
@@ -3834,6 +3955,7 @@ export {
3834
3955
  portForwardLabel,
3835
3956
  postBroadcastPayload,
3836
3957
  probeCrnAvailability,
3958
+ probeCrnTee,
3837
3959
  probeRootfsGateway,
3838
3960
  publishAggregateKey,
3839
3961
  publishRelayBootstrapRegistration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/core",
3
- "version": "0.9.9",
3
+ "version": "0.10.0",
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.9.9",
28
- "@le-space/shared-types": "0.9.9"
27
+ "@le-space/aleph-bootstrap": "0.10.0",
28
+ "@le-space/shared-types": "0.10.0"
29
29
  }
30
30
  }