@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
@@ -38,7 +38,7 @@ export { InMemoryTokenStore, type TokenStore, type TokenRecord, } from "./auth/t
38
38
  export { OAuthClient, type OAuthClientConfig, type AuthorizationUrlResult, } from "./auth/oauth-client.js";
39
39
  export { NATIVE_VANA_ASSET, dataRegistryDomain, grantRegistrationDomain, grantRevocationDomain, serverRegistrationDomain, builderRegistrationDomain, escrowPaymentDomain, GRANT_REGISTRATION_TYPES, GRANT_REVOCATION_TYPES, SERVER_REGISTRATION_TYPES, BUILDER_REGISTRATION_TYPES, ADD_DATA_TYPES, RECORD_DATA_ACCESS_TYPES, type DataPortabilityContracts, type DataPortabilityGatewayConfig, type GrantRegistrationMessage, type GrantRevocationMessage, type ServerRegistrationMessage, type BuilderRegistrationMessage, type AddDataMessage, type RecordDataAccessMessage, } from "./protocol/eip712.js";
40
40
  export { ENCLAVE_IDENTITY_EVIDENCE_VERSION, USER_PS_ID_DOMAIN, ENCLAVE_WALLET_PURPOSE, MASTER_SIGNATURE_DELIVERY_VERSION, MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS, SEALED_ENVELOPE_VERSION, ENCLAVE_TRUST_ANCHORS, userPsId, appRootPreimage, kmsIssuedPreimage, verifyEnclaveIdentityEvidence, buildMasterSignatureDelivery, encryptMasterSignatureDelivery, type UserPsId, type EnclaveIdentityEvidence, type ExpectedIdentity, type IdentityRequest, type IdentityState, type IdentityResponse, type IdentityRegistrationRequest, type IdentityRegistrationResponse, type MasterSignatureDelivery, type SealedSecretSubmission, type SealedSecretResponse, type AesGcmBox, type SealedEnvelope, type EnclaveTrustAnchors, } from "./protocol/identity.js";
41
- export { JOB_PROTOCOL_VERSION, JOB_OPERATIONS, JOB_STATES, DEFAULT_LEASE_SECONDS, MAX_LEASE_SECONDS, MAX_ATTEMPTS, MAX_WAIT_SECONDS, CLAIM_POLL_FLOOR_MS, DEFAULT_JOB_DEADLINE_SECONDS, MAX_JOB_DEADLINE_SECONDS, type JobOperation, type JobState, type PaymentState, type JobRequest, type JobRequestEnvelope, type JobSubmission, type ResultHandle, type JobStatus, type ClaimRequest, type ClaimResponse, type HeartbeatRequest, type CompleteRequest, type FailRequest, type FencedResponse, type JobResult, type TeeNodeState, type TeeNodeRegistration, type TeeNodeHeartbeat, type TeeNode, } from "./protocol/jobs.js";
41
+ export { JOB_PROTOCOL_VERSION, JOB_OPERATIONS, JOB_STATES, DEFAULT_LEASE_SECONDS, MAX_LEASE_SECONDS, MAX_ATTEMPTS, MAX_WAIT_SECONDS, CLAIM_POLL_FLOOR_MS, MAX_INLINE_RESULT_BYTES, DEFAULT_JOB_DEADLINE_SECONDS, MAX_JOB_DEADLINE_SECONDS, type JobOperation, type JobState, type PaymentState, type JobRequest, type JobRequestEnvelope, type JobSubmission, type JobStatus, type ClaimRequest, type ClaimResponse, type HeartbeatRequest, type CompleteRequest, type FailRequest, type FencedResponse, type JobResult, type TeeNodeState, type TeeNodeRegistration, type TeeNodeHeartbeat, type TeeNode, } from "./protocol/jobs.js";
42
42
  export { createJobsClient, type JobsBuilderAccount, type JobsClientOptions, type SubmitRawReadParams, type SubmitRawReadResult, type WaitForJobOptions, type OpenJobResultOptions, type ReadRawParams, type JobsClient, } from "./protocol/jobs-client.js";
43
43
  export { JobEnvelopeError, canonicalJobRequestBytes, sealJobRequest, openJobRequest, sealJobResult, openJobResult, } from "./crypto/envelope/job.js";
44
44
  export { PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID, PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT, personalServerRegistrationDomain, createViemPersonalServerRegistrationSigner, buildPersonalServerRegistrationTypedData, buildPersonalServerRegistrationSignature, registerPersonalServerSignature, type PersonalServerRegistrationTypedData, type PersonalServerRegistrationSigner, type PersonalServerRegistrationDomainInput, type ViemPersonalServerRegistrationWalletClient, type ViemPersonalServerRegistrationSignerSource, type BuildPersonalServerRegistrationTypedDataInput, type BuildPersonalServerRegistrationSignatureInput, type PersonalServerRegistrationSignature, } from "./protocol/personal-server-registration.js";
@@ -1393,11 +1393,6 @@ var JobTimeoutError = class extends JobsClientError {
1393
1393
  super(message, "JOB_TIMEOUT", void 0, null, details);
1394
1394
  }
1395
1395
  };
1396
- var JobResultIntegrityError = class extends JobsClientError {
1397
- constructor(message, details) {
1398
- super(message, "JOB_RESULT_INTEGRITY", void 0, null, details);
1399
- }
1400
- };
1401
1396
  var JobRejectedError = class extends JobsClientError {
1402
1397
  constructor(message, status, errorCode = null, details) {
1403
1398
  super(message, "JOB_REJECTED", status, errorCode, details);
@@ -32610,14 +32605,13 @@ var MAX_LEASE_SECONDS = 300;
32610
32605
  var MAX_ATTEMPTS = 3;
32611
32606
  var MAX_WAIT_SECONDS = 25;
32612
32607
  var CLAIM_POLL_FLOOR_MS = 1e3;
32608
+ var MAX_INLINE_RESULT_BYTES = 1048576;
32613
32609
  var DEFAULT_JOB_DEADLINE_SECONDS = 600;
32614
32610
  var MAX_JOB_DEADLINE_SECONDS = 3600;
32615
32611
 
32616
32612
  // src/protocol/jobs-client.ts
32617
32613
  import { randomUUID } from "node:crypto";
32618
- import { sha256 as sha2566 } from "@noble/hashes/sha2";
32619
32614
  import {
32620
- bytesToHex as bytesToHex3,
32621
32615
  isAddress as isAddress2,
32622
32616
  isAddressEqual as isAddressEqual2,
32623
32617
  isHex as isHex2
@@ -32676,9 +32670,6 @@ function resultPlaintext(result) {
32676
32670
  function encryptedBytesToBase64(encrypted) {
32677
32671
  return toBase64(fromHex6(`0x${serializeECIES(encrypted)}`, "bytes"));
32678
32672
  }
32679
- function encryptedToBytes(encrypted) {
32680
- return fromHex6(`0x${serializeECIES(encrypted)}`, "bytes");
32681
- }
32682
32673
  function base64ToEncrypted(ciphertext) {
32683
32674
  return deserializeECIES(toHex8(fromBase64(ciphertext)));
32684
32675
  }
@@ -32824,13 +32815,14 @@ async function sealJobResult(result, builderPublicKey, ecies) {
32824
32815
  fromHex6(builderPublicKey, "bytes"),
32825
32816
  resultPlaintext(result)
32826
32817
  );
32827
- const bytes = encryptedToBytes(encrypted);
32828
- return { bytes, hash: bytesToHex2(sha2565(bytes)), size: bytes.length };
32818
+ const ciphertext = encryptedBytesToBase64(encrypted);
32819
+ const bytes = fromBase64(ciphertext);
32820
+ return { ciphertext, hash: bytesToHex2(sha2565(bytes)), size: bytes.length };
32829
32821
  }
32830
- async function openJobResult(sealedBytes, builderPrivateKey, ecies, expect) {
32822
+ async function openJobResult(ciphertext, builderPrivateKey, ecies, expect) {
32831
32823
  const plaintext = await ecies.decrypt(
32832
32824
  fromHex6(builderPrivateKey, "bytes"),
32833
- deserializeECIES(toHex8(sealedBytes))
32825
+ base64ToEncrypted(ciphertext)
32834
32826
  );
32835
32827
  const result = validateResult(parseObject(plaintext, "job result"));
32836
32828
  if (result.jobId !== expect.jobId) {
@@ -33310,51 +33302,31 @@ function createJobsClient(options) {
33310
33302
  await sleep2(Math.min(pollMs, remaining));
33311
33303
  }
33312
33304
  },
33313
- async openResult(handle, openOptions) {
33314
- if (!privateKey) {
33305
+ async openResult(job, openOptions) {
33306
+ if (!job.resultCiphertext) {
33315
33307
  throw new JobRejectedError(
33316
- "openResult requires createJobsClient({ builderPrivateKey })"
33317
- );
33318
- }
33319
- const response = await request(
33320
- handle.url,
33321
- { method: GET_METHOD },
33322
- "Job result fetch"
33323
- );
33324
- if (!response.ok) {
33325
- throw await rejectedResponse(response, "Job result fetch rejected");
33326
- }
33327
- let bytes;
33328
- try {
33329
- bytes = new Uint8Array(await response.arrayBuffer());
33330
- } catch (error) {
33331
- throw new JobTransportError(
33332
- `Job result fetch failed: ${error instanceof Error ? error.message : String(error)}`,
33333
- error
33334
- );
33335
- }
33336
- const actualHash = bytesToHex3(sha2566(bytes));
33337
- if (actualHash.toLowerCase() !== handle.hash.toLowerCase()) {
33338
- throw new JobResultIntegrityError(
33339
- "Fetched job result hash does not match its handle",
33308
+ "Job status does not include inline resultCiphertext",
33309
+ void 0,
33310
+ null,
33340
33311
  {
33341
- objectKey: handle.objectKey,
33342
- expectedHash: handle.hash,
33343
- actualHash
33312
+ jobId: job.jobId,
33313
+ state: job.state,
33314
+ resultHandle: job.resultHandle,
33315
+ maxInlineResultBytes: MAX_INLINE_RESULT_BYTES
33344
33316
  }
33345
33317
  );
33346
33318
  }
33347
- if (bytes.length !== handle.size) {
33348
- throw new JobResultIntegrityError(
33349
- "Fetched job result size does not match its handle",
33350
- {
33351
- objectKey: handle.objectKey,
33352
- expectedSize: handle.size,
33353
- actualSize: bytes.length
33354
- }
33319
+ if (!privateKey) {
33320
+ throw new JobRejectedError(
33321
+ "openResult requires createJobsClient({ builderPrivateKey })"
33355
33322
  );
33356
33323
  }
33357
- return openJobResult(bytes, privateKey, ecies, openOptions.expect);
33324
+ return openJobResult(
33325
+ job.resultCiphertext,
33326
+ privateKey,
33327
+ ecies,
33328
+ openOptions.expect
33329
+ );
33358
33330
  },
33359
33331
  async readRaw(params) {
33360
33332
  const submitted = await client.submitRawRead(params);
@@ -33362,27 +33334,7 @@ function createJobsClient(options) {
33362
33334
  timeoutMs: params.timeoutMs,
33363
33335
  pollMs: params.pollMs
33364
33336
  });
33365
- if (job.state !== "completed") {
33366
- throw new JobRejectedError(
33367
- `Job ${job.jobId} ended in state ${job.state}${job.failureReason ? `: ${job.failureReason}` : ""}`,
33368
- void 0,
33369
- null,
33370
- {
33371
- jobId: job.jobId,
33372
- state: job.state,
33373
- ...job.failureReason ? { failureReason: job.failureReason } : {}
33374
- }
33375
- );
33376
- }
33377
- if (!job.result) {
33378
- throw new JobRejectedError(
33379
- "Completed job status does not include a result handle",
33380
- void 0,
33381
- null,
33382
- { jobId: job.jobId, state: job.state }
33383
- );
33384
- }
33385
- return client.openResult(job.result, {
33337
+ return client.openResult(job, {
33386
33338
  expect: {
33387
33339
  jobId: submitted.jobId,
33388
33340
  scope: params.scope,
@@ -34807,13 +34759,13 @@ function tryGrantPermissions(scopes) {
34807
34759
  }
34808
34760
 
34809
34761
  // src/protocol/personal-server-write.ts
34810
- import { sha256 as sha2568 } from "@noble/hashes/sha2";
34811
- import { bytesToHex as bytesToHex5, isAddress as isAddress8 } from "viem";
34762
+ import { sha256 as sha2567 } from "@noble/hashes/sha2";
34763
+ import { bytesToHex as bytesToHex4, isAddress as isAddress8 } from "viem";
34812
34764
  import { z as z4 } from "zod";
34813
34765
 
34814
34766
  // src/protocol/write-request.ts
34815
- import { sha256 as sha2567 } from "@noble/hashes/sha2";
34816
- import { bytesToHex as bytesToHex4 } from "viem";
34767
+ import { sha256 as sha2566 } from "@noble/hashes/sha2";
34768
+ import { bytesToHex as bytesToHex3 } from "viem";
34817
34769
  function normalizeBaseUrl2(url) {
34818
34770
  return url.replace(/\/+$/, "");
34819
34771
  }
@@ -34880,22 +34832,22 @@ function freshProofNonce() {
34880
34832
  return webCrypto.randomUUID();
34881
34833
  }
34882
34834
  if (typeof webCrypto?.getRandomValues === "function") {
34883
- return bytesToHex4(webCrypto.getRandomValues(new Uint8Array(16)));
34835
+ return bytesToHex3(webCrypto.getRandomValues(new Uint8Array(16)));
34884
34836
  }
34885
34837
  throw new WriteRequestError(
34886
34838
  "No secure random source available to build a proof nonce; provide a crypto global"
34887
34839
  );
34888
34840
  }
34889
34841
  function proofKeyFor(parts) {
34890
- return bytesToHex4(
34891
- sha2567(
34842
+ return bytesToHex3(
34843
+ sha2566(
34892
34844
  new TextEncoder().encode(
34893
34845
  JSON.stringify([
34894
34846
  parts.aud,
34895
34847
  parts.method,
34896
34848
  parts.uri,
34897
34849
  parts.grantId,
34898
- parts.signedBytes ? bytesToHex4(sha2567(parts.signedBytes)) : ""
34850
+ parts.signedBytes ? bytesToHex3(sha2566(parts.signedBytes)) : ""
34899
34851
  ])
34900
34852
  )
34901
34853
  )
@@ -35082,7 +35034,7 @@ function binaryWriteSignedBytes(input) {
35082
35034
  mimeType: normalizeBinaryMimeType(input.contentType),
35083
35035
  ...input.filename ? { filename: input.filename } : {},
35084
35036
  sizeBytes: input.bytes.length,
35085
- contentHash: bytesToHex5(sha2568(input.bytes)),
35037
+ contentHash: bytesToHex4(sha2567(input.bytes)),
35086
35038
  encoding: "base64",
35087
35039
  content: toBase64(input.bytes),
35088
35040
  ...metadata !== void 0 ? { metadata } : {}
@@ -37139,7 +37091,6 @@ export {
37139
37091
  JobNotFoundError,
37140
37092
  JobRejectedError,
37141
37093
  JobRequestTooLargeError,
37142
- JobResultIntegrityError,
37143
37094
  JobTimeoutError,
37144
37095
  JobTransportError,
37145
37096
  JobsClientError,
@@ -37153,6 +37104,7 @@ export {
37153
37104
  MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS,
37154
37105
  MASTER_SIGNATURE_DELIVERY_VERSION,
37155
37106
  MAX_ATTEMPTS,
37107
+ MAX_INLINE_RESULT_BYTES,
37156
37108
  MAX_JOB_DEADLINE_SECONDS,
37157
37109
  MAX_LEASE_SECONDS,
37158
37110
  MAX_LINEAGE_SOURCES,