@le-space/browser 0.1.29 → 0.1.30

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/README.md CHANGED
@@ -27,6 +27,7 @@ That client should remain small and stable. It currently owns:
27
27
  - message envelope lookup
28
28
  - scheduler allocation lookup
29
29
  - CRN allocation notify
30
+ - relay setup-server configure request
30
31
  - deployment result inspection and polling
31
32
  - Aleph message broadcast helpers
32
33
 
package/index.d.ts CHANGED
@@ -164,6 +164,21 @@ interface InstanceAllocation {
164
164
  interface AllocationNotifyResult {
165
165
  status: 'confirmed' | 'unconfirmed';
166
166
  }
167
+ interface RelaySetupRequest {
168
+ hostIpv4: string;
169
+ publicIpv6?: string | null;
170
+ setupPort: number;
171
+ tcpPort: number;
172
+ wsPort: number;
173
+ proxyUrl?: string | null;
174
+ metricsPort?: number | null;
175
+ metricsHttpsPort?: number | null;
176
+ webrtcPort?: number | null;
177
+ quicPort?: number | null;
178
+ }
179
+ interface RelaySetupResult {
180
+ status: 'configured' | 'unconfirmed';
181
+ }
167
182
  interface AlephBroadcastMessage {
168
183
  sender: string;
169
184
  chain: AlephSenderChain;
@@ -197,6 +212,7 @@ interface AlephBrowserClient {
197
212
  fetchMessageEnvelope(itemHash: string): Promise<AlephMessageEnvelope | null>;
198
213
  fetchSchedulerAllocation(itemHash: string): Promise<InstanceAllocation | null>;
199
214
  notifyCrnAllocation(crnUrl: string, itemHash: string): Promise<AllocationNotifyResult>;
215
+ configureOrbitdbRelaySetup(args: RelaySetupRequest): Promise<RelaySetupResult>;
200
216
  inspectDeploymentResult(itemHash: string, rootfsRef?: string): Promise<DeploymentInspectionResult>;
201
217
  waitForDeploymentResult(itemHash: string, rootfsRef?: string, attempts?: number, delayMs?: number): Promise<DeploymentInspectionResult>;
202
218
  broadcastInstanceMessage(message: AlephBroadcastMessage, sync?: boolean): Promise<BroadcastResult>;
@@ -251,6 +267,7 @@ declare function fetchCrns(url?: string): Promise<Crn[]>;
251
267
  declare function fetchInstances(address: string, apiHost?: string): Promise<InstanceMessage[]>;
252
268
  declare function fetchSchedulerAllocation(itemHash: string, schedulerApiHost?: string): Promise<InstanceAllocation | null>;
253
269
  declare function notifyCrnAllocation(crnUrl: string, itemHash: string): Promise<AllocationNotifyResult>;
270
+ declare function configureOrbitdbRelaySetup(args: RelaySetupRequest): Promise<RelaySetupResult>;
254
271
  declare function fetchMessageEnvelope(itemHash: string, apiHost?: string): Promise<AlephMessageEnvelope | null>;
255
272
  declare function inspectDeploymentResult(itemHash: string, rootfsRef?: string, apiHost?: string): Promise<DeploymentInspectionResult>;
256
273
  declare function waitForDeploymentResult(itemHash: string, rootfsRef?: string, apiHost?: string, attempts?: number, delayMs?: number): Promise<DeploymentInspectionResult>;
@@ -279,4 +296,4 @@ declare const DEFAULT_ALEPH_AGGREGATE_ADDRESS = "0xFba561a84A537fCaa567bb7A2257e
279
296
  declare function parseInstancePricing(payload: unknown): InstancePricing;
280
297
  declare function fetchInstancePricing(apiHost?: string, aggregateAddress?: string): Promise<PricingState>;
281
298
 
282
- export { type AlephBroadcastMessage, type AlephBroadcastResponse, type AlephBrowserClient, type AlephMessageEnvelope, type AlephMessageType, type AlephSenderChain, type AllocationNotifyResult, BROWSER_PACKAGE_PLAN, type BalanceResponse, type BroadcastResult, type BrowserExtractionPhase, type BrowserPackagePlan, type ComputeUnit, type CreateAlephBrowserClientOptions, type Crn, type CrnListResponse, type CrnLocation, type CrnUsage, DEFAULT_ALEPH_AGGREGATE_ADDRESS, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_SCHEDULER_API_HOST, DEFAULT_CRN_LIST_URL, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_ROOTFS_MANIFEST_URL, type DeploymentInspectionResult, type GatewayProbeStatus, ITEM_HASH_RE, type InstanceAllocation, type InstanceAllocationNode, type InstanceAllocationPeriod, type InstanceMessage, type InstancePricing, type LoadRootfsManifestOptions, type MessageReference, type MessageStatus, type PaymentMode, type Price, type PricingState, type ReferenceStatus, type RootfsManifest, type RootfsManifestState, type RootfsRequiredPortForward, type RootfsResolution, type Tier, broadcastAlephMessage, broadcastInstanceMessage, createAlephBrowserClient, fetchBalance, fetchCrns, fetchInstancePricing, fetchInstances, fetchMessageEnvelope, fetchSchedulerAllocation, fetchWithTimeout, inspectDeploymentResult, loadRootfsManifest, normalizeMessageStatus, notifyCrnAllocation, parseInstancePricing, resolveRootfsReference, validateRootfsManifest, verifyRootfsExists, waitForDeploymentResult };
299
+ export { type AlephBroadcastMessage, type AlephBroadcastResponse, type AlephBrowserClient, type AlephMessageEnvelope, type AlephMessageType, type AlephSenderChain, type AllocationNotifyResult, BROWSER_PACKAGE_PLAN, type BalanceResponse, type BroadcastResult, type BrowserExtractionPhase, type BrowserPackagePlan, type ComputeUnit, type CreateAlephBrowserClientOptions, type Crn, type CrnListResponse, type CrnLocation, type CrnUsage, DEFAULT_ALEPH_AGGREGATE_ADDRESS, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_SCHEDULER_API_HOST, DEFAULT_CRN_LIST_URL, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_ROOTFS_MANIFEST_URL, type DeploymentInspectionResult, type GatewayProbeStatus, ITEM_HASH_RE, type InstanceAllocation, type InstanceAllocationNode, type InstanceAllocationPeriod, type InstanceMessage, type InstancePricing, type LoadRootfsManifestOptions, type MessageReference, type MessageStatus, type PaymentMode, type Price, type PricingState, type ReferenceStatus, type RelaySetupRequest, type RelaySetupResult, type RootfsManifest, type RootfsManifestState, type RootfsRequiredPortForward, type RootfsResolution, type Tier, broadcastAlephMessage, broadcastInstanceMessage, configureOrbitdbRelaySetup, createAlephBrowserClient, fetchBalance, fetchCrns, fetchInstancePricing, fetchInstances, fetchMessageEnvelope, fetchSchedulerAllocation, fetchWithTimeout, inspectDeploymentResult, loadRootfsManifest, normalizeMessageStatus, notifyCrnAllocation, parseInstancePricing, resolveRootfsReference, validateRootfsManifest, verifyRootfsExists, waitForDeploymentResult };
package/index.js CHANGED
@@ -147,6 +147,43 @@ async function notifyCrnAllocation(crnUrl, itemHash) {
147
147
  throw error;
148
148
  }
149
149
  }
150
+ async function configureOrbitdbRelaySetup(args) {
151
+ const targetUrl = `http://${args.hostIpv4}:${args.setupPort}/configure`;
152
+ try {
153
+ const response = await fetchWithTimeout(
154
+ targetUrl,
155
+ {
156
+ method: "POST",
157
+ headers: {
158
+ "content-type": "text/plain;charset=UTF-8"
159
+ },
160
+ body: JSON.stringify({
161
+ public_ipv4: args.hostIpv4,
162
+ public_ipv6: args.publicIpv6 ?? void 0,
163
+ tcp_port: args.tcpPort,
164
+ ws_port: args.wsPort,
165
+ proxy_url: args.proxyUrl ?? void 0,
166
+ metrics_port: args.metricsPort ?? void 0,
167
+ metrics_https_port: args.metricsHttpsPort ?? void 0,
168
+ webrtc_port: args.webrtcPort ?? void 0,
169
+ quic_port: args.quicPort ?? void 0
170
+ }),
171
+ mode: "cors"
172
+ },
173
+ 3e4
174
+ );
175
+ if (!response.ok) {
176
+ const responseText = await response.text().catch(() => "");
177
+ throw new Error(`Relay setup request failed: ${response.status}${responseText ? ` ${responseText}` : ""}`);
178
+ }
179
+ return { status: "configured" };
180
+ } catch (error) {
181
+ if (isUnconfirmedNetworkError(error)) {
182
+ return { status: "unconfirmed" };
183
+ }
184
+ throw error;
185
+ }
186
+ }
150
187
  function messageTypeFromEnvelope(payload) {
151
188
  if (!payload) return null;
152
189
  const type = payload.type ?? payload.message?.type ?? (Array.isArray(payload.messages) ? payload.messages[0]?.type : void 0);
@@ -310,6 +347,9 @@ function createAlephBrowserClient(options = {}) {
310
347
  notifyCrnAllocation(crnUrl, itemHash) {
311
348
  return notifyCrnAllocation(crnUrl, itemHash);
312
349
  },
350
+ configureOrbitdbRelaySetup(args) {
351
+ return configureOrbitdbRelaySetup(args);
352
+ },
313
353
  inspectDeploymentResult(itemHash, rootfsRef) {
314
354
  return inspectDeploymentResult(itemHash, rootfsRef, apiHost);
315
355
  },
@@ -545,6 +585,7 @@ export {
545
585
  ITEM_HASH_RE,
546
586
  broadcastAlephMessage,
547
587
  broadcastInstanceMessage,
588
+ configureOrbitdbRelaySetup,
548
589
  createAlephBrowserClient,
549
590
  fetchBalance,
550
591
  fetchCrns,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/browser",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "description": "Shared browser-safe Aleph deployment and polling helpers.",
5
5
  "license": "MIT",
6
6
  "type": "module",