lightnode-sdk 0.4.6 → 0.4.7

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/dist/crypto.js CHANGED
@@ -27,29 +27,43 @@ async function getCrypto() {
27
27
  if (resolvingCrypto)
28
28
  return resolvingCrypto;
29
29
  resolvingCrypto = (async () => {
30
+ const diag = [];
30
31
  const g = globalThis.crypto;
32
+ diag.push(`globalThis.crypto=${g ? "present" : "missing"}`);
33
+ if (g)
34
+ diag.push(`globalThis.crypto.subtle=${g.subtle ? "present" : "missing"}`);
35
+ if (g)
36
+ diag.push(`globalThis.crypto.getRandomValues=${typeof g.getRandomValues}`);
31
37
  if (g?.subtle && typeof g.getRandomValues === "function") {
32
38
  const provider = { subtle: g.subtle, getRandomValues: g.getRandomValues.bind(g) };
33
39
  resolvedCrypto = provider;
34
40
  return provider;
35
41
  }
36
- // Node 18 + StackBlitz WebContainer: globalThis.crypto is missing, but
42
+ // Node 18 + StackBlitz WebContainer: globalThis.crypto may be missing, but
37
43
  // `node:crypto` exposes the same Web Crypto API via `webcrypto`.
44
+ let nodeCryptoError = null;
38
45
  try {
39
46
  const mod = (await import("node:crypto"));
47
+ diag.push(`node:crypto=imported`);
40
48
  const wc = mod.webcrypto;
49
+ diag.push(`node:crypto.webcrypto=${wc ? "present" : "missing"}`);
50
+ if (wc)
51
+ diag.push(`node:crypto.webcrypto.subtle=${wc.subtle ? "present" : "missing"}`);
52
+ if (wc)
53
+ diag.push(`node:crypto.webcrypto.getRandomValues=${typeof wc.getRandomValues}`);
41
54
  if (wc?.subtle && typeof wc.getRandomValues === "function") {
42
55
  const provider = { subtle: wc.subtle, getRandomValues: wc.getRandomValues.bind(wc) };
43
56
  resolvedCrypto = provider;
44
57
  return provider;
45
58
  }
46
59
  }
47
- catch {
48
- // node:crypto not importable - we're in a browser bundle without a
49
- // global crypto. The fall-through error below explains the fix.
60
+ catch (err) {
61
+ nodeCryptoError = err.message;
62
+ diag.push(`node:crypto=import threw: ${nodeCryptoError}`);
50
63
  }
51
- throw new Error("Web Crypto unavailable: globalThis.crypto is missing and node:crypto could not be loaded. " +
52
- "The SDK requires Node 18+ or a modern browser.");
64
+ throw new Error("Web Crypto unavailable. The SDK requires either globalThis.crypto (Node 19+ or any modern browser) " +
65
+ "or node:crypto.webcrypto (Node 18, StackBlitz WebContainer). Diagnostic: " +
66
+ diag.join("; "));
53
67
  })();
54
68
  try {
55
69
  return await resolvingCrypto;
package/dist/index.d.ts CHANGED
@@ -60,6 +60,13 @@ export declare class LightNode {
60
60
  baseUrl?: string;
61
61
  }): GatewayClient;
62
62
  }
63
+ /**
64
+ * Build-time SDK version. Useful for diagnostic prints in examples and apps so
65
+ * the operator can confirm which version of the SDK is loaded at runtime
66
+ * (especially in registry-proxy environments like StackBlitz where lockfiles
67
+ * may pin an older minor than the local install command suggests).
68
+ */
69
+ export declare const SDK_VERSION = "0.4.7";
63
70
  export { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS, aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv, fromWei, computeModelId as modelId, estimateJobFee, JOB_REGISTRY_CONSUMER_ABI, consumerGatewayUrl, consumerGatewayHost, GatewayClient, GatewayHttpError, prepareSession, submitPrompt, decryptResponse, generateEcdhKeyPair, crypto, runInference, runInferenceWithKey, StalledWorkerError, OnChainRevertError, RelayTokenTimeoutError, GatewayAuthError, isStalledWorker, };
64
71
  export type { BearerSource, GatewayClientOptions, SelectSessionResult, PrepareSessionResult, UploadBlobResult, SessionTokenResult } from "./gateway.js";
65
72
  export type { SessionPreparation, RunInferenceArgs, RunInferenceResult, RunInferenceWithKeyArgs } from "./inference.js";
package/dist/index.js CHANGED
@@ -90,6 +90,13 @@ export class LightNode {
90
90
  return new GatewayClient({ network: this.network, ...opts });
91
91
  }
92
92
  }
93
+ /**
94
+ * Build-time SDK version. Useful for diagnostic prints in examples and apps so
95
+ * the operator can confirm which version of the SDK is loaded at runtime
96
+ * (especially in registry-proxy environments like StackBlitz where lockfiles
97
+ * may pin an older minor than the local install command suggests).
98
+ */
99
+ export const SDK_VERSION = "0.4.7";
93
100
  export { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS, aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv, fromWei, computeModelId as modelId, estimateJobFee, JOB_REGISTRY_CONSUMER_ABI, consumerGatewayUrl, consumerGatewayHost,
94
101
  // v0.3 inference-submit surface (BETA - see README "Submitting inference").
95
102
  GatewayClient, GatewayHttpError, prepareSession, submitPrompt, decryptResponse, generateEcdhKeyPair, crypto,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lightnode-sdk",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Read-only TypeScript client for LightChain AI: workers, jobs, models, on-chain registration, and per-model network analytics. Independent, community-built (not an official LightChain package).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",