@opendatalabs/vana-sdk 3.23.0-pr.211.e98a9a2 → 3.23.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.
Files changed (42) hide show
  1. package/dist/crypto/envelope/job.cjs +5 -7
  2. package/dist/crypto/envelope/job.cjs.map +1 -1
  3. package/dist/crypto/envelope/job.d.ts +16 -16
  4. package/dist/crypto/envelope/job.js +5 -7
  5. package/dist/crypto/envelope/job.js.map +1 -1
  6. package/dist/direct/connect-flow.cjs +1 -43
  7. package/dist/direct/connect-flow.cjs.map +1 -1
  8. package/dist/direct/connect-flow.d.ts +0 -12
  9. package/dist/direct/connect-flow.js +1 -43
  10. package/dist/direct/connect-flow.js.map +1 -1
  11. package/dist/direct/use-direct-vana-connect.cjs +1 -2
  12. package/dist/direct/use-direct-vana-connect.cjs.map +1 -1
  13. package/dist/direct/use-direct-vana-connect.d.ts +1 -3
  14. package/dist/direct/use-direct-vana-connect.js +1 -2
  15. package/dist/direct/use-direct-vana-connect.js.map +1 -1
  16. package/dist/errors.cjs +0 -7
  17. package/dist/errors.cjs.map +1 -1
  18. package/dist/errors.d.ts +0 -10
  19. package/dist/errors.js +0 -6
  20. package/dist/errors.js.map +1 -1
  21. package/dist/index.browser.d.ts +1 -1
  22. package/dist/index.browser.js +7 -13
  23. package/dist/index.browser.js.map +2 -2
  24. package/dist/index.node.cjs +32 -79
  25. package/dist/index.node.cjs.map +3 -3
  26. package/dist/index.node.d.ts +1 -1
  27. package/dist/index.node.js +35 -83
  28. package/dist/index.node.js.map +3 -3
  29. package/dist/protocol/jobs-client.cjs +19 -60
  30. package/dist/protocol/jobs-client.cjs.map +1 -1
  31. package/dist/protocol/jobs-client.d.ts +5 -7
  32. package/dist/protocol/jobs-client.js +20 -62
  33. package/dist/protocol/jobs-client.js.map +1 -1
  34. package/dist/protocol/jobs.cjs +3 -0
  35. package/dist/protocol/jobs.cjs.map +1 -1
  36. package/dist/protocol/jobs.d.ts +12 -19
  37. package/dist/protocol/jobs.js +2 -0
  38. package/dist/protocol/jobs.js.map +1 -1
  39. package/dist/react.cjs.map +1 -1
  40. package/dist/react.d.ts +1 -1
  41. package/dist/react.js.map +1 -1
  42. package/package.json +1 -1
@@ -1242,7 +1242,6 @@ __export(index_node_exports, {
1242
1242
  JobNotFoundError: () => JobNotFoundError,
1243
1243
  JobRejectedError: () => JobRejectedError,
1244
1244
  JobRequestTooLargeError: () => JobRequestTooLargeError,
1245
- JobResultIntegrityError: () => JobResultIntegrityError,
1246
1245
  JobTimeoutError: () => JobTimeoutError,
1247
1246
  JobTransportError: () => JobTransportError,
1248
1247
  JobsClientError: () => JobsClientError,
@@ -1256,6 +1255,7 @@ __export(index_node_exports, {
1256
1255
  MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS: () => MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS,
1257
1256
  MASTER_SIGNATURE_DELIVERY_VERSION: () => MASTER_SIGNATURE_DELIVERY_VERSION,
1258
1257
  MAX_ATTEMPTS: () => MAX_ATTEMPTS,
1258
+ MAX_INLINE_RESULT_BYTES: () => MAX_INLINE_RESULT_BYTES,
1259
1259
  MAX_JOB_DEADLINE_SECONDS: () => MAX_JOB_DEADLINE_SECONDS,
1260
1260
  MAX_LEASE_SECONDS: () => MAX_LEASE_SECONDS,
1261
1261
  MAX_LINEAGE_SOURCES: () => MAX_LINEAGE_SOURCES,
@@ -1727,11 +1727,6 @@ var JobTimeoutError = class extends JobsClientError {
1727
1727
  super(message, "JOB_TIMEOUT", void 0, null, details);
1728
1728
  }
1729
1729
  };
1730
- var JobResultIntegrityError = class extends JobsClientError {
1731
- constructor(message, details) {
1732
- super(message, "JOB_RESULT_INTEGRITY", void 0, null, details);
1733
- }
1734
- };
1735
1730
  var JobRejectedError = class extends JobsClientError {
1736
1731
  constructor(message, status, errorCode = null, details) {
1737
1732
  super(message, "JOB_REJECTED", status, errorCode, details);
@@ -32922,12 +32917,12 @@ var MAX_LEASE_SECONDS = 300;
32922
32917
  var MAX_ATTEMPTS = 3;
32923
32918
  var MAX_WAIT_SECONDS = 25;
32924
32919
  var CLAIM_POLL_FLOOR_MS = 1e3;
32920
+ var MAX_INLINE_RESULT_BYTES = 1048576;
32925
32921
  var DEFAULT_JOB_DEADLINE_SECONDS = 600;
32926
32922
  var MAX_JOB_DEADLINE_SECONDS = 3600;
32927
32923
 
32928
32924
  // src/protocol/jobs-client.ts
32929
32925
  var import_node_crypto = require("node:crypto");
32930
- var import_sha26 = require("@noble/hashes/sha2");
32931
32926
  var import_viem16 = require("viem");
32932
32927
  var import_accounts2 = require("viem/accounts");
32933
32928
 
@@ -32983,9 +32978,6 @@ function resultPlaintext(result) {
32983
32978
  function encryptedBytesToBase64(encrypted) {
32984
32979
  return toBase64((0, import_viem15.fromHex)(`0x${serializeECIES(encrypted)}`, "bytes"));
32985
32980
  }
32986
- function encryptedToBytes(encrypted) {
32987
- return (0, import_viem15.fromHex)(`0x${serializeECIES(encrypted)}`, "bytes");
32988
- }
32989
32981
  function base64ToEncrypted(ciphertext) {
32990
32982
  return deserializeECIES((0, import_viem15.toHex)(fromBase64(ciphertext)));
32991
32983
  }
@@ -33131,13 +33123,14 @@ async function sealJobResult(result, builderPublicKey, ecies) {
33131
33123
  (0, import_viem15.fromHex)(builderPublicKey, "bytes"),
33132
33124
  resultPlaintext(result)
33133
33125
  );
33134
- const bytes = encryptedToBytes(encrypted);
33135
- return { bytes, hash: (0, import_viem15.bytesToHex)((0, import_sha25.sha256)(bytes)), size: bytes.length };
33126
+ const ciphertext = encryptedBytesToBase64(encrypted);
33127
+ const bytes = fromBase64(ciphertext);
33128
+ return { ciphertext, hash: (0, import_viem15.bytesToHex)((0, import_sha25.sha256)(bytes)), size: bytes.length };
33136
33129
  }
33137
- async function openJobResult(sealedBytes, builderPrivateKey, ecies, expect) {
33130
+ async function openJobResult(ciphertext, builderPrivateKey, ecies, expect) {
33138
33131
  const plaintext = await ecies.decrypt(
33139
33132
  (0, import_viem15.fromHex)(builderPrivateKey, "bytes"),
33140
- deserializeECIES((0, import_viem15.toHex)(sealedBytes))
33133
+ base64ToEncrypted(ciphertext)
33141
33134
  );
33142
33135
  const result = validateResult(parseObject(plaintext, "job result"));
33143
33136
  if (result.jobId !== expect.jobId) {
@@ -33617,51 +33610,31 @@ function createJobsClient(options) {
33617
33610
  await sleep2(Math.min(pollMs, remaining));
33618
33611
  }
33619
33612
  },
33620
- async openResult(handle, openOptions) {
33621
- if (!privateKey) {
33613
+ async openResult(job, openOptions) {
33614
+ if (!job.resultCiphertext) {
33622
33615
  throw new JobRejectedError(
33623
- "openResult requires createJobsClient({ builderPrivateKey })"
33624
- );
33625
- }
33626
- const response = await request(
33627
- handle.url,
33628
- { method: GET_METHOD },
33629
- "Job result fetch"
33630
- );
33631
- if (!response.ok) {
33632
- throw await rejectedResponse(response, "Job result fetch rejected");
33633
- }
33634
- let bytes;
33635
- try {
33636
- bytes = new Uint8Array(await response.arrayBuffer());
33637
- } catch (error) {
33638
- throw new JobTransportError(
33639
- `Job result fetch failed: ${error instanceof Error ? error.message : String(error)}`,
33640
- error
33641
- );
33642
- }
33643
- const actualHash = (0, import_viem16.bytesToHex)((0, import_sha26.sha256)(bytes));
33644
- if (actualHash.toLowerCase() !== handle.hash.toLowerCase()) {
33645
- throw new JobResultIntegrityError(
33646
- "Fetched job result hash does not match its handle",
33616
+ "Job status does not include inline resultCiphertext",
33617
+ void 0,
33618
+ null,
33647
33619
  {
33648
- objectKey: handle.objectKey,
33649
- expectedHash: handle.hash,
33650
- actualHash
33620
+ jobId: job.jobId,
33621
+ state: job.state,
33622
+ resultHandle: job.resultHandle,
33623
+ maxInlineResultBytes: MAX_INLINE_RESULT_BYTES
33651
33624
  }
33652
33625
  );
33653
33626
  }
33654
- if (bytes.length !== handle.size) {
33655
- throw new JobResultIntegrityError(
33656
- "Fetched job result size does not match its handle",
33657
- {
33658
- objectKey: handle.objectKey,
33659
- expectedSize: handle.size,
33660
- actualSize: bytes.length
33661
- }
33627
+ if (!privateKey) {
33628
+ throw new JobRejectedError(
33629
+ "openResult requires createJobsClient({ builderPrivateKey })"
33662
33630
  );
33663
33631
  }
33664
- return openJobResult(bytes, privateKey, ecies, openOptions.expect);
33632
+ return openJobResult(
33633
+ job.resultCiphertext,
33634
+ privateKey,
33635
+ ecies,
33636
+ openOptions.expect
33637
+ );
33665
33638
  },
33666
33639
  async readRaw(params) {
33667
33640
  const submitted = await client.submitRawRead(params);
@@ -33669,27 +33642,7 @@ function createJobsClient(options) {
33669
33642
  timeoutMs: params.timeoutMs,
33670
33643
  pollMs: params.pollMs
33671
33644
  });
33672
- if (job.state !== "completed") {
33673
- throw new JobRejectedError(
33674
- `Job ${job.jobId} ended in state ${job.state}${job.failureReason ? `: ${job.failureReason}` : ""}`,
33675
- void 0,
33676
- null,
33677
- {
33678
- jobId: job.jobId,
33679
- state: job.state,
33680
- ...job.failureReason ? { failureReason: job.failureReason } : {}
33681
- }
33682
- );
33683
- }
33684
- if (!job.result) {
33685
- throw new JobRejectedError(
33686
- "Completed job status does not include a result handle",
33687
- void 0,
33688
- null,
33689
- { jobId: job.jobId, state: job.state }
33690
- );
33691
- }
33692
- return client.openResult(job.result, {
33645
+ return client.openResult(job, {
33693
33646
  expect: {
33694
33647
  jobId: submitted.jobId,
33695
33648
  scope: params.scope,
@@ -35101,12 +35054,12 @@ function tryGrantPermissions(scopes) {
35101
35054
  }
35102
35055
 
35103
35056
  // src/protocol/personal-server-write.ts
35104
- var import_sha28 = require("@noble/hashes/sha2");
35057
+ var import_sha27 = require("@noble/hashes/sha2");
35105
35058
  var import_viem27 = require("viem");
35106
35059
  var import_zod4 = require("zod");
35107
35060
 
35108
35061
  // src/protocol/write-request.ts
35109
- var import_sha27 = require("@noble/hashes/sha2");
35062
+ var import_sha26 = require("@noble/hashes/sha2");
35110
35063
  var import_viem26 = require("viem");
35111
35064
  function normalizeBaseUrl2(url) {
35112
35065
  return url.replace(/\/+$/, "");
@@ -35182,14 +35135,14 @@ function freshProofNonce() {
35182
35135
  }
35183
35136
  function proofKeyFor(parts) {
35184
35137
  return (0, import_viem26.bytesToHex)(
35185
- (0, import_sha27.sha256)(
35138
+ (0, import_sha26.sha256)(
35186
35139
  new TextEncoder().encode(
35187
35140
  JSON.stringify([
35188
35141
  parts.aud,
35189
35142
  parts.method,
35190
35143
  parts.uri,
35191
35144
  parts.grantId,
35192
- parts.signedBytes ? (0, import_viem26.bytesToHex)((0, import_sha27.sha256)(parts.signedBytes)) : ""
35145
+ parts.signedBytes ? (0, import_viem26.bytesToHex)((0, import_sha26.sha256)(parts.signedBytes)) : ""
35193
35146
  ])
35194
35147
  )
35195
35148
  )
@@ -35376,7 +35329,7 @@ function binaryWriteSignedBytes(input) {
35376
35329
  mimeType: normalizeBinaryMimeType(input.contentType),
35377
35330
  ...input.filename ? { filename: input.filename } : {},
35378
35331
  sizeBytes: input.bytes.length,
35379
- contentHash: (0, import_viem27.bytesToHex)((0, import_sha28.sha256)(input.bytes)),
35332
+ contentHash: (0, import_viem27.bytesToHex)((0, import_sha27.sha256)(input.bytes)),
35380
35333
  encoding: "base64",
35381
35334
  content: toBase64(input.bytes),
35382
35335
  ...metadata !== void 0 ? { metadata } : {}
@@ -37434,7 +37387,6 @@ async function parsePSError(response) {
37434
37387
  JobNotFoundError,
37435
37388
  JobRejectedError,
37436
37389
  JobRequestTooLargeError,
37437
- JobResultIntegrityError,
37438
37390
  JobTimeoutError,
37439
37391
  JobTransportError,
37440
37392
  JobsClientError,
@@ -37448,6 +37400,7 @@ async function parsePSError(response) {
37448
37400
  MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS,
37449
37401
  MASTER_SIGNATURE_DELIVERY_VERSION,
37450
37402
  MAX_ATTEMPTS,
37403
+ MAX_INLINE_RESULT_BYTES,
37451
37404
  MAX_JOB_DEADLINE_SECONDS,
37452
37405
  MAX_LEASE_SECONDS,
37453
37406
  MAX_LINEAGE_SOURCES,