@opendatalabs/vana-sdk 3.22.0 → 3.23.0-pr.211.341f55d
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/envelope/job.cjs +355 -0
- package/dist/crypto/envelope/job.cjs.map +1 -0
- package/dist/crypto/envelope/job.d.ts +123 -0
- package/dist/crypto/envelope/job.js +333 -0
- package/dist/crypto/envelope/job.js.map +1 -0
- package/dist/direct/access-request-client.cjs +4 -0
- package/dist/direct/access-request-client.cjs.map +1 -1
- package/dist/direct/access-request-client.js +4 -0
- package/dist/direct/access-request-client.js.map +1 -1
- package/dist/direct/connect-flow.cjs +43 -1
- package/dist/direct/connect-flow.cjs.map +1 -1
- package/dist/direct/connect-flow.d.ts +12 -0
- package/dist/direct/connect-flow.js +43 -1
- package/dist/direct/connect-flow.js.map +1 -1
- package/dist/direct/types.cjs.map +1 -1
- package/dist/direct/types.d.ts +7 -0
- package/dist/direct/types.js.map +1 -1
- package/dist/direct/use-direct-vana-connect.cjs +2 -1
- package/dist/direct/use-direct-vana-connect.cjs.map +1 -1
- package/dist/direct/use-direct-vana-connect.d.ts +3 -1
- package/dist/direct/use-direct-vana-connect.js +2 -1
- package/dist/direct/use-direct-vana-connect.js.map +1 -1
- package/dist/errors.cjs +84 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +133 -0
- package/dist/errors.js +73 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.browser.js +631 -24
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +1259 -111
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +4 -0
- package/dist/index.node.js +1223 -101
- package/dist/index.node.js.map +4 -4
- package/dist/protocol/identity.cjs +219 -0
- package/dist/protocol/identity.cjs.map +1 -0
- package/dist/protocol/identity.d.ts +193 -0
- package/dist/protocol/identity.js +183 -0
- package/dist/protocol/identity.js.map +1 -0
- package/dist/protocol/identity.test.d.ts +1 -0
- package/dist/protocol/identity.vector.test.d.ts +1 -0
- package/dist/protocol/jobs-client.cjs +540 -0
- package/dist/protocol/jobs-client.cjs.map +1 -0
- package/dist/protocol/jobs-client.d.ts +169 -0
- package/dist/protocol/jobs-client.js +547 -0
- package/dist/protocol/jobs-client.js.map +1 -0
- package/dist/protocol/jobs-client.test.d.ts +1 -0
- package/dist/protocol/jobs.cjs +64 -0
- package/dist/protocol/jobs.cjs.map +1 -0
- package/dist/protocol/jobs.d.ts +193 -0
- package/dist/protocol/jobs.js +31 -0
- package/dist/protocol/jobs.js.map +1 -0
- package/dist/protocol/jobs.test.d.ts +1 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js.map +1 -1
- package/package.json +7 -1
package/dist/index.browser.js
CHANGED
|
@@ -1338,6 +1338,68 @@ var WriteRejectedError = class extends PersonalServerWriteError {
|
|
|
1338
1338
|
super(message, "WRITE_REJECTED", status, errorCode, details);
|
|
1339
1339
|
}
|
|
1340
1340
|
};
|
|
1341
|
+
var JobsClientError = class extends VanaError {
|
|
1342
|
+
constructor(message, code, status, errorCode = null, details) {
|
|
1343
|
+
super(message, code);
|
|
1344
|
+
this.status = status;
|
|
1345
|
+
this.errorCode = errorCode;
|
|
1346
|
+
this.details = details;
|
|
1347
|
+
}
|
|
1348
|
+
status;
|
|
1349
|
+
errorCode;
|
|
1350
|
+
details;
|
|
1351
|
+
};
|
|
1352
|
+
var BuilderUnknownError = class extends JobsClientError {
|
|
1353
|
+
constructor(message, details) {
|
|
1354
|
+
super(message, "JOB_BUILDER_UNKNOWN", 403, "BUILDER_UNKNOWN", details);
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
1357
|
+
var GrantInvalidError = class extends JobsClientError {
|
|
1358
|
+
constructor(message, details) {
|
|
1359
|
+
super(message, "JOB_GRANT_INVALID", 403, "GRANT_INVALID", details);
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
var OwnerNotReadyError = class extends JobsClientError {
|
|
1363
|
+
constructor(message, details) {
|
|
1364
|
+
super(message, "JOB_OWNER_NOT_READY", 403, "OWNER_NOT_READY", details);
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
var JobIdTakenError = class extends JobsClientError {
|
|
1368
|
+
constructor(message, details) {
|
|
1369
|
+
super(message, "JOB_ID_TAKEN", 409, "JOB_ID_TAKEN", details);
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
var JobNotFoundError = class extends JobsClientError {
|
|
1373
|
+
constructor(message, details) {
|
|
1374
|
+
super(message, "JOB_NOT_FOUND", 404, "JOB_NOT_FOUND", details);
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
var JobRequestTooLargeError = class extends JobsClientError {
|
|
1378
|
+
constructor(message, errorCode = "BODY_TOO_LARGE", details) {
|
|
1379
|
+
super(message, "JOB_REQUEST_TOO_LARGE", 413, errorCode, details);
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
var JobTimeoutError = class extends JobsClientError {
|
|
1383
|
+
constructor(message, details) {
|
|
1384
|
+
super(message, "JOB_TIMEOUT", void 0, null, details);
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
var JobResultIntegrityError = class extends JobsClientError {
|
|
1388
|
+
constructor(message, details) {
|
|
1389
|
+
super(message, "JOB_RESULT_INTEGRITY", void 0, null, details);
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
var JobRejectedError = class extends JobsClientError {
|
|
1393
|
+
constructor(message, status, errorCode = null, details) {
|
|
1394
|
+
super(message, "JOB_REJECTED", status, errorCode, details);
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
var JobTransportError = class extends JobsClientError {
|
|
1398
|
+
constructor(message, cause) {
|
|
1399
|
+
super(message, "JOB_TRANSPORT_ERROR");
|
|
1400
|
+
this.cause = cause;
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1341
1403
|
var LineageReadError = class extends VanaError {
|
|
1342
1404
|
constructor(message, status, errorCode = null, details) {
|
|
1343
1405
|
super(message, "LINEAGE_READ_ERROR");
|
|
@@ -31736,9 +31798,514 @@ var RECORD_DATA_ACCESS_TYPES = {
|
|
|
31736
31798
|
]
|
|
31737
31799
|
};
|
|
31738
31800
|
|
|
31801
|
+
// src/protocol/identity.ts
|
|
31802
|
+
init_interface();
|
|
31803
|
+
import * as secp256k13 from "@noble/secp256k1";
|
|
31804
|
+
import {
|
|
31805
|
+
concat as concat4,
|
|
31806
|
+
encodePacked,
|
|
31807
|
+
fromHex as fromHex5,
|
|
31808
|
+
getAddress,
|
|
31809
|
+
isAddressEqual,
|
|
31810
|
+
keccak256,
|
|
31811
|
+
recoverPublicKey,
|
|
31812
|
+
toBytes,
|
|
31813
|
+
toHex as toHex6
|
|
31814
|
+
} from "viem";
|
|
31815
|
+
import { publicKeyToAddress } from "viem/accounts";
|
|
31816
|
+
var ENCLAVE_IDENTITY_EVIDENCE_VERSION = 1;
|
|
31817
|
+
var USER_PS_ID_DOMAIN = "vana.ps-enclave.v1";
|
|
31818
|
+
var ENCLAVE_WALLET_PURPOSE = "vana.ps-enclave.wallet.v1";
|
|
31819
|
+
var MASTER_SIGNATURE_DELIVERY_VERSION = "vana.ps-enclave.delivery.v1";
|
|
31820
|
+
var MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS = 600;
|
|
31821
|
+
var SEALED_ENVELOPE_VERSION = 1;
|
|
31822
|
+
var VANA_MAINNET_CHAIN_ID = 1480;
|
|
31823
|
+
var MOKSHA_CHAIN_ID = 14800;
|
|
31824
|
+
var KMS_ISSUED_PREFIX = "dstack-kms-issued";
|
|
31825
|
+
var PREIMAGE_SEPARATOR = ":";
|
|
31826
|
+
var UNCOMPRESSED_PUBLIC_KEY_BYTES = 65;
|
|
31827
|
+
var UNCOMPRESSED_PUBLIC_KEY_PREFIX = "04";
|
|
31828
|
+
var EMPTY_HEX = "0x";
|
|
31829
|
+
function emptyAnchor() {
|
|
31830
|
+
return Object.freeze({
|
|
31831
|
+
kmsRootPubkey: EMPTY_HEX,
|
|
31832
|
+
appIds: Object.freeze([])
|
|
31833
|
+
});
|
|
31834
|
+
}
|
|
31835
|
+
var ENCLAVE_TRUST_ANCHORS = Object.freeze({
|
|
31836
|
+
// filled at fleet provisioning; verify fails closed while empty
|
|
31837
|
+
[VANA_MAINNET_CHAIN_ID]: emptyAnchor(),
|
|
31838
|
+
// filled at fleet provisioning; verify fails closed while empty
|
|
31839
|
+
[MOKSHA_CHAIN_ID]: emptyAnchor()
|
|
31840
|
+
});
|
|
31841
|
+
function userPsId(chainId, ownerAddress) {
|
|
31842
|
+
const packed = encodePacked(
|
|
31843
|
+
["string", "uint256", "address"],
|
|
31844
|
+
[USER_PS_ID_DOMAIN, BigInt(chainId), getAddress(ownerAddress)]
|
|
31845
|
+
);
|
|
31846
|
+
return keccak256(packed);
|
|
31847
|
+
}
|
|
31848
|
+
function compressPublicKey(publicKey) {
|
|
31849
|
+
return secp256k13.ProjectivePoint.fromHex(
|
|
31850
|
+
fromHex5(publicKey, "bytes")
|
|
31851
|
+
).toRawBytes(true);
|
|
31852
|
+
}
|
|
31853
|
+
function sameKey(a, b) {
|
|
31854
|
+
return toHex6(compressPublicKey(a)) === toHex6(compressPublicKey(b));
|
|
31855
|
+
}
|
|
31856
|
+
function assertUncompressedKey(publicKey) {
|
|
31857
|
+
const hex = publicKey.slice(2);
|
|
31858
|
+
if (hex.length !== UNCOMPRESSED_PUBLIC_KEY_BYTES * 2 || !hex.startsWith(UNCOMPRESSED_PUBLIC_KEY_PREFIX) || !/^[0-9a-fA-F]+$/.test(hex)) {
|
|
31859
|
+
throw new Error("Public key must be a 65-byte uncompressed secp256k1 key");
|
|
31860
|
+
}
|
|
31861
|
+
}
|
|
31862
|
+
function appRootPreimage(purpose, publicKey) {
|
|
31863
|
+
const keyHex = toHex6(compressPublicKey(publicKey)).slice(2);
|
|
31864
|
+
return keccak256(toBytes(`${purpose}${PREIMAGE_SEPARATOR}${keyHex}`));
|
|
31865
|
+
}
|
|
31866
|
+
function kmsIssuedPreimage(appId, appRootPublicKey) {
|
|
31867
|
+
const prefix = concat4([
|
|
31868
|
+
toBytes(`${KMS_ISSUED_PREFIX}${PREIMAGE_SEPARATOR}`),
|
|
31869
|
+
fromHex5(appId, "bytes")
|
|
31870
|
+
]);
|
|
31871
|
+
const compressed = compressPublicKey(appRootPublicKey);
|
|
31872
|
+
return keccak256(concat4([prefix, compressed]));
|
|
31873
|
+
}
|
|
31874
|
+
async function recoverChainKey(hash, signature, link) {
|
|
31875
|
+
try {
|
|
31876
|
+
return (await recoverPublicKey({ hash, signature })).toLowerCase();
|
|
31877
|
+
} catch {
|
|
31878
|
+
throw new Error(`Invalid enclave signature chain link ${link}`);
|
|
31879
|
+
}
|
|
31880
|
+
}
|
|
31881
|
+
async function verifyEnclaveIdentityEvidence(evidence, anchors, expected) {
|
|
31882
|
+
if (evidence.v !== ENCLAVE_IDENTITY_EVIDENCE_VERSION) {
|
|
31883
|
+
throw new Error("Unsupported enclave identity evidence version");
|
|
31884
|
+
}
|
|
31885
|
+
if (!Number.isInteger(evidence.epoch) || evidence.epoch < 1) {
|
|
31886
|
+
throw new Error("Invalid enclave identity epoch");
|
|
31887
|
+
}
|
|
31888
|
+
if (evidence.chainId !== expected.chainId) {
|
|
31889
|
+
throw new Error(
|
|
31890
|
+
"Enclave identity chain ID does not match expected chain ID"
|
|
31891
|
+
);
|
|
31892
|
+
}
|
|
31893
|
+
if (!isAddressEqual(evidence.ownerAddress, expected.ownerAddress)) {
|
|
31894
|
+
throw new Error("Enclave identity owner does not match expected owner");
|
|
31895
|
+
}
|
|
31896
|
+
if (evidence.epoch !== expected.epoch) {
|
|
31897
|
+
throw new Error("Enclave identity epoch does not match expected epoch");
|
|
31898
|
+
}
|
|
31899
|
+
const expectedUserPsId = userPsId(expected.chainId, expected.ownerAddress);
|
|
31900
|
+
if (evidence.userPsId.toLowerCase() !== expectedUserPsId.toLowerCase()) {
|
|
31901
|
+
throw new Error("Enclave userPsId does not match expected identity");
|
|
31902
|
+
}
|
|
31903
|
+
if (evidence.purpose !== ENCLAVE_WALLET_PURPOSE) {
|
|
31904
|
+
throw new Error("Unexpected enclave wallet purpose");
|
|
31905
|
+
}
|
|
31906
|
+
if (anchors.kmsRootPubkey === EMPTY_HEX) {
|
|
31907
|
+
throw new Error("KMS root trust anchor is not provisioned");
|
|
31908
|
+
}
|
|
31909
|
+
assertUncompressedKey(evidence.publicKey);
|
|
31910
|
+
const derivedAddress = publicKeyToAddress(evidence.publicKey);
|
|
31911
|
+
if (getAddress(derivedAddress) !== getAddress(evidence.address)) {
|
|
31912
|
+
throw new Error("Enclave public key does not match its address");
|
|
31913
|
+
}
|
|
31914
|
+
const appRootPublicKey = await recoverChainKey(
|
|
31915
|
+
appRootPreimage(evidence.purpose, evidence.publicKey),
|
|
31916
|
+
evidence.signatureChain[0],
|
|
31917
|
+
0
|
|
31918
|
+
);
|
|
31919
|
+
const kmsRootPublicKey = await recoverChainKey(
|
|
31920
|
+
kmsIssuedPreimage(evidence.appId, appRootPublicKey),
|
|
31921
|
+
evidence.signatureChain[1],
|
|
31922
|
+
1
|
|
31923
|
+
);
|
|
31924
|
+
let matchesAnchor;
|
|
31925
|
+
try {
|
|
31926
|
+
matchesAnchor = sameKey(kmsRootPublicKey, anchors.kmsRootPubkey);
|
|
31927
|
+
} catch {
|
|
31928
|
+
throw new Error("KMS root trust anchor is malformed");
|
|
31929
|
+
}
|
|
31930
|
+
if (!matchesAnchor) {
|
|
31931
|
+
throw new Error("KMS root public key does not match the trust anchor");
|
|
31932
|
+
}
|
|
31933
|
+
if (keccak256(kmsRootPublicKey) !== evidence.kmsRootFingerprint.toLowerCase()) {
|
|
31934
|
+
throw new Error("KMS root fingerprint does not match the evidence");
|
|
31935
|
+
}
|
|
31936
|
+
const appId = evidence.appId.toLowerCase();
|
|
31937
|
+
if (!anchors.appIds.some((allowedAppId) => allowedAppId.toLowerCase() === appId)) {
|
|
31938
|
+
throw new Error("Enclave app ID is not trusted");
|
|
31939
|
+
}
|
|
31940
|
+
}
|
|
31941
|
+
async function buildMasterSignatureDelivery(evidence, masterSignature, now = Math.floor(Date.now() / 1e3)) {
|
|
31942
|
+
deriveMasterKey(masterSignature);
|
|
31943
|
+
const signerAddress = await recoverServerOwner(masterSignature);
|
|
31944
|
+
if (!isAddressEqual(signerAddress, evidence.ownerAddress)) {
|
|
31945
|
+
throw new Error("Master signature signer does not match evidence owner");
|
|
31946
|
+
}
|
|
31947
|
+
return {
|
|
31948
|
+
v: MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
31949
|
+
userPsId: evidence.userPsId,
|
|
31950
|
+
epoch: evidence.epoch,
|
|
31951
|
+
enclaveAddress: evidence.address,
|
|
31952
|
+
ownerAddress: evidence.ownerAddress,
|
|
31953
|
+
masterSignature,
|
|
31954
|
+
issuedAt: now
|
|
31955
|
+
};
|
|
31956
|
+
}
|
|
31957
|
+
async function encryptMasterSignatureDelivery(delivery, publicKey, ecies) {
|
|
31958
|
+
assertUncompressedKey(publicKey);
|
|
31959
|
+
if (!isAddressEqual(publicKeyToAddress(publicKey), delivery.enclaveAddress)) {
|
|
31960
|
+
throw new Error(
|
|
31961
|
+
"Public key does not belong to the delivery's enclave address"
|
|
31962
|
+
);
|
|
31963
|
+
}
|
|
31964
|
+
const plaintext = toBytes(JSON.stringify(delivery));
|
|
31965
|
+
const encrypted = await ecies.encrypt(fromHex5(publicKey, "bytes"), plaintext);
|
|
31966
|
+
return `0x${serializeECIES(encrypted)}`;
|
|
31967
|
+
}
|
|
31968
|
+
|
|
31969
|
+
// src/protocol/jobs.ts
|
|
31970
|
+
var JOB_PROTOCOL_VERSION = 1;
|
|
31971
|
+
var JOB_OPERATIONS = ["raw_read", "inference"];
|
|
31972
|
+
var JOB_STATES = [
|
|
31973
|
+
"queued",
|
|
31974
|
+
"claimed",
|
|
31975
|
+
"running",
|
|
31976
|
+
"completed",
|
|
31977
|
+
"failed",
|
|
31978
|
+
"expired",
|
|
31979
|
+
"cancelled"
|
|
31980
|
+
];
|
|
31981
|
+
var DEFAULT_LEASE_SECONDS = 30;
|
|
31982
|
+
var MAX_LEASE_SECONDS = 300;
|
|
31983
|
+
var MAX_ATTEMPTS = 3;
|
|
31984
|
+
var MAX_WAIT_SECONDS = 25;
|
|
31985
|
+
var CLAIM_POLL_FLOOR_MS = 1e3;
|
|
31986
|
+
var DEFAULT_JOB_DEADLINE_SECONDS = 600;
|
|
31987
|
+
var MAX_JOB_DEADLINE_SECONDS = 3600;
|
|
31988
|
+
|
|
31989
|
+
// src/crypto/envelope/job.ts
|
|
31990
|
+
init_constants();
|
|
31991
|
+
init_interface();
|
|
31992
|
+
import { sha256 as sha2565 } from "@noble/hashes/sha2";
|
|
31993
|
+
import { bytesToHex as bytesToHex2, fromHex as fromHex6, isAddress, isHex, toHex as toHex7 } from "viem";
|
|
31994
|
+
var textDecoder = new TextDecoder();
|
|
31995
|
+
var textEncoder = new TextEncoder();
|
|
31996
|
+
var MAX_JOB_RESULT_HEADER_BYTES = 4096;
|
|
31997
|
+
var JOB_RESULT_LENGTH_PREFIX_BYTES = 4;
|
|
31998
|
+
var JobEnvelopeError = class extends Error {
|
|
31999
|
+
constructor(message) {
|
|
32000
|
+
super(message);
|
|
32001
|
+
this.name = "JobEnvelopeError";
|
|
32002
|
+
}
|
|
32003
|
+
};
|
|
32004
|
+
function sortJsonKeys(value) {
|
|
32005
|
+
if (Array.isArray(value)) {
|
|
32006
|
+
return value.map(sortJsonKeys);
|
|
32007
|
+
}
|
|
32008
|
+
if (value !== null && typeof value === "object") {
|
|
32009
|
+
return Object.fromEntries(
|
|
32010
|
+
Object.keys(value).sort().map((key) => [
|
|
32011
|
+
key,
|
|
32012
|
+
sortJsonKeys(value[key])
|
|
32013
|
+
])
|
|
32014
|
+
);
|
|
32015
|
+
}
|
|
32016
|
+
return value;
|
|
32017
|
+
}
|
|
32018
|
+
function canonicalJsonBytes(value) {
|
|
32019
|
+
return textEncoder.encode(JSON.stringify(sortJsonKeys(value)));
|
|
32020
|
+
}
|
|
32021
|
+
function canonicalJobRequestBytes(request) {
|
|
32022
|
+
validateJobRequest(request);
|
|
32023
|
+
return canonicalJsonBytes(request);
|
|
32024
|
+
}
|
|
32025
|
+
function requestPlaintext(envelope) {
|
|
32026
|
+
validateRequestEnvelope(envelope);
|
|
32027
|
+
return canonicalJsonBytes(envelope);
|
|
32028
|
+
}
|
|
32029
|
+
function resultPlaintext(result) {
|
|
32030
|
+
const header = textEncoder.encode(
|
|
32031
|
+
JSON.stringify({
|
|
32032
|
+
v: result.v,
|
|
32033
|
+
jobId: result.jobId,
|
|
32034
|
+
scope: result.scope,
|
|
32035
|
+
version: result.version,
|
|
32036
|
+
contentType: result.contentType
|
|
32037
|
+
})
|
|
32038
|
+
);
|
|
32039
|
+
if (header.length > MAX_JOB_RESULT_HEADER_BYTES) {
|
|
32040
|
+
throw new JobEnvelopeError(
|
|
32041
|
+
`Invalid job result: header exceeds ${MAX_JOB_RESULT_HEADER_BYTES} bytes`
|
|
32042
|
+
);
|
|
32043
|
+
}
|
|
32044
|
+
const plaintext = new Uint8Array(
|
|
32045
|
+
JOB_RESULT_LENGTH_PREFIX_BYTES + header.length + result.body.length
|
|
32046
|
+
);
|
|
32047
|
+
new DataView(plaintext.buffer).setUint32(0, header.length);
|
|
32048
|
+
plaintext.set(header, JOB_RESULT_LENGTH_PREFIX_BYTES);
|
|
32049
|
+
plaintext.set(result.body, JOB_RESULT_LENGTH_PREFIX_BYTES + header.length);
|
|
32050
|
+
return plaintext;
|
|
32051
|
+
}
|
|
32052
|
+
function parseResultPlaintext(plaintext) {
|
|
32053
|
+
if (plaintext.length < JOB_RESULT_LENGTH_PREFIX_BYTES) {
|
|
32054
|
+
throw new JobEnvelopeError(
|
|
32055
|
+
"Invalid job result: missing header length prefix"
|
|
32056
|
+
);
|
|
32057
|
+
}
|
|
32058
|
+
const headerLength = new DataView(
|
|
32059
|
+
plaintext.buffer,
|
|
32060
|
+
plaintext.byteOffset,
|
|
32061
|
+
JOB_RESULT_LENGTH_PREFIX_BYTES
|
|
32062
|
+
).getUint32(0);
|
|
32063
|
+
if (headerLength > MAX_JOB_RESULT_HEADER_BYTES) {
|
|
32064
|
+
throw new JobEnvelopeError(
|
|
32065
|
+
`Invalid job result: header exceeds ${MAX_JOB_RESULT_HEADER_BYTES} bytes`
|
|
32066
|
+
);
|
|
32067
|
+
}
|
|
32068
|
+
const remainingLength = plaintext.length - JOB_RESULT_LENGTH_PREFIX_BYTES;
|
|
32069
|
+
if (headerLength > remainingLength) {
|
|
32070
|
+
throw new JobEnvelopeError(
|
|
32071
|
+
"Invalid job result: header length exceeds payload"
|
|
32072
|
+
);
|
|
32073
|
+
}
|
|
32074
|
+
const headerEnd = JOB_RESULT_LENGTH_PREFIX_BYTES + headerLength;
|
|
32075
|
+
const header = parseObject(
|
|
32076
|
+
plaintext.subarray(JOB_RESULT_LENGTH_PREFIX_BYTES, headerEnd),
|
|
32077
|
+
"job result header"
|
|
32078
|
+
);
|
|
32079
|
+
return validateResult({ ...header, body: plaintext.subarray(headerEnd) });
|
|
32080
|
+
}
|
|
32081
|
+
function encryptedBytesToBase64(encrypted) {
|
|
32082
|
+
return toBase64(fromHex6(`0x${serializeECIES(encrypted)}`, "bytes"));
|
|
32083
|
+
}
|
|
32084
|
+
function encryptedToBytes(encrypted) {
|
|
32085
|
+
const bytes = new Uint8Array(
|
|
32086
|
+
encrypted.iv.length + encrypted.ephemPublicKey.length + encrypted.ciphertext.length + encrypted.mac.length
|
|
32087
|
+
);
|
|
32088
|
+
let offset = 0;
|
|
32089
|
+
bytes.set(encrypted.iv, offset);
|
|
32090
|
+
offset += encrypted.iv.length;
|
|
32091
|
+
bytes.set(encrypted.ephemPublicKey, offset);
|
|
32092
|
+
offset += encrypted.ephemPublicKey.length;
|
|
32093
|
+
bytes.set(encrypted.ciphertext, offset);
|
|
32094
|
+
offset += encrypted.ciphertext.length;
|
|
32095
|
+
bytes.set(encrypted.mac, offset);
|
|
32096
|
+
return bytes;
|
|
32097
|
+
}
|
|
32098
|
+
function bytesToEncrypted(bytes) {
|
|
32099
|
+
const absoluteMinLength = FORMAT.IV_LENGTH + 1 + MAC.LENGTH + 1;
|
|
32100
|
+
if (bytes.length < absoluteMinLength) {
|
|
32101
|
+
throw new ECIESError(
|
|
32102
|
+
`Invalid ECIES data: too short (${bytes.length} bytes, minimum ${absoluteMinLength} bytes required)`,
|
|
32103
|
+
"DECRYPTION_FAILED"
|
|
32104
|
+
);
|
|
32105
|
+
}
|
|
32106
|
+
const prefix = bytes[FORMAT.EPHEMERAL_KEY_OFFSET];
|
|
32107
|
+
if (prefix !== CURVE.PREFIX.UNCOMPRESSED) {
|
|
32108
|
+
throw new ECIESError(
|
|
32109
|
+
`Invalid ephemeral public key: must be uncompressed format (0x04 prefix), got 0x${prefix.toString(16).padStart(2, "0")}`,
|
|
32110
|
+
"DECRYPTION_FAILED"
|
|
32111
|
+
);
|
|
32112
|
+
}
|
|
32113
|
+
const ephemKeySize = CURVE.UNCOMPRESSED_PUBLIC_KEY_LENGTH;
|
|
32114
|
+
const minLength = FORMAT.IV_LENGTH + ephemKeySize + MAC.LENGTH + 1;
|
|
32115
|
+
if (bytes.length < minLength) {
|
|
32116
|
+
throw new ECIESError(
|
|
32117
|
+
`Invalid ECIES data: too short (${bytes.length} bytes, minimum ${minLength} bytes required)`,
|
|
32118
|
+
"DECRYPTION_FAILED"
|
|
32119
|
+
);
|
|
32120
|
+
}
|
|
32121
|
+
return {
|
|
32122
|
+
iv: bytes.subarray(FORMAT.IV_OFFSET, FORMAT.IV_OFFSET + FORMAT.IV_LENGTH),
|
|
32123
|
+
ephemPublicKey: bytes.subarray(
|
|
32124
|
+
FORMAT.EPHEMERAL_KEY_OFFSET,
|
|
32125
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize
|
|
32126
|
+
),
|
|
32127
|
+
ciphertext: bytes.subarray(
|
|
32128
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize,
|
|
32129
|
+
bytes.length - MAC.LENGTH
|
|
32130
|
+
),
|
|
32131
|
+
mac: bytes.subarray(bytes.length - MAC.LENGTH)
|
|
32132
|
+
};
|
|
32133
|
+
}
|
|
32134
|
+
function base64ToEncrypted(ciphertext) {
|
|
32135
|
+
return deserializeECIES(toHex7(fromBase64(ciphertext)));
|
|
32136
|
+
}
|
|
32137
|
+
function parseObject(plaintext, kind) {
|
|
32138
|
+
try {
|
|
32139
|
+
const value = JSON.parse(textDecoder.decode(plaintext));
|
|
32140
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
32141
|
+
throw new JobEnvelopeError(`Invalid ${kind}: expected an object`);
|
|
32142
|
+
}
|
|
32143
|
+
return value;
|
|
32144
|
+
} catch (error) {
|
|
32145
|
+
if (error instanceof JobEnvelopeError) throw error;
|
|
32146
|
+
throw new JobEnvelopeError(`Invalid ${kind}: malformed JSON`);
|
|
32147
|
+
}
|
|
32148
|
+
}
|
|
32149
|
+
function isPlainObject2(value) {
|
|
32150
|
+
if (value === null || typeof value !== "object") return false;
|
|
32151
|
+
const prototype = Object.getPrototypeOf(value);
|
|
32152
|
+
return prototype === Object.prototype || prototype === null;
|
|
32153
|
+
}
|
|
32154
|
+
function requirePlainObject(value, field, kind) {
|
|
32155
|
+
if (!isPlainObject2(value)) {
|
|
32156
|
+
throw new JobEnvelopeError(`Invalid ${kind}: invalid ${field}`);
|
|
32157
|
+
}
|
|
32158
|
+
}
|
|
32159
|
+
function requireExactKeys(value, expectedKeys, kind) {
|
|
32160
|
+
for (const key of expectedKeys) {
|
|
32161
|
+
if (!Object.hasOwn(value, key) || value[key] === void 0) {
|
|
32162
|
+
throw new JobEnvelopeError(`Invalid ${kind}: missing ${key}`);
|
|
32163
|
+
}
|
|
32164
|
+
}
|
|
32165
|
+
const expected = new Set(expectedKeys);
|
|
32166
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
32167
|
+
if (!expected.has(key)) {
|
|
32168
|
+
throw new JobEnvelopeError(
|
|
32169
|
+
`Invalid ${kind}: unknown field ${String(key)}`
|
|
32170
|
+
);
|
|
32171
|
+
}
|
|
32172
|
+
}
|
|
32173
|
+
}
|
|
32174
|
+
function requireString(value, field, kind) {
|
|
32175
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
32176
|
+
throw new JobEnvelopeError(`Invalid ${kind}: missing ${field}`);
|
|
32177
|
+
}
|
|
32178
|
+
}
|
|
32179
|
+
function validateJobRequest(value) {
|
|
32180
|
+
requirePlainObject(value, "request", "job request");
|
|
32181
|
+
requireExactKeys(
|
|
32182
|
+
value,
|
|
32183
|
+
[
|
|
32184
|
+
"v",
|
|
32185
|
+
"jobId",
|
|
32186
|
+
"owner",
|
|
32187
|
+
"builder",
|
|
32188
|
+
"builderPublicKey",
|
|
32189
|
+
"grantId",
|
|
32190
|
+
"scope",
|
|
32191
|
+
"operation",
|
|
32192
|
+
"pinnedVersion",
|
|
32193
|
+
"deadline"
|
|
32194
|
+
],
|
|
32195
|
+
"job request"
|
|
32196
|
+
);
|
|
32197
|
+
if (value.v !== JOB_PROTOCOL_VERSION) {
|
|
32198
|
+
throw new JobEnvelopeError(
|
|
32199
|
+
`Unsupported job request version: ${String(value.v)}`
|
|
32200
|
+
);
|
|
32201
|
+
}
|
|
32202
|
+
requireString(value.jobId, "jobId", "job request");
|
|
32203
|
+
if (typeof value.owner !== "string" || !isAddress(value.owner)) {
|
|
32204
|
+
throw new JobEnvelopeError("Invalid job request: invalid owner");
|
|
32205
|
+
}
|
|
32206
|
+
if (typeof value.builder !== "string" || !isAddress(value.builder)) {
|
|
32207
|
+
throw new JobEnvelopeError("Invalid job request: invalid builder");
|
|
32208
|
+
}
|
|
32209
|
+
if (typeof value.builderPublicKey !== "string" || !isHex(value.builderPublicKey)) {
|
|
32210
|
+
throw new JobEnvelopeError("Invalid job request: invalid builderPublicKey");
|
|
32211
|
+
}
|
|
32212
|
+
if (typeof value.grantId !== "string" || !isHex(value.grantId)) {
|
|
32213
|
+
throw new JobEnvelopeError("Invalid job request: invalid grantId");
|
|
32214
|
+
}
|
|
32215
|
+
requireString(value.scope, "scope", "job request");
|
|
32216
|
+
if (!JOB_OPERATIONS.includes(value.operation)) {
|
|
32217
|
+
throw new JobEnvelopeError("Invalid job request: invalid operation");
|
|
32218
|
+
}
|
|
32219
|
+
if (value.pinnedVersion !== null && typeof value.pinnedVersion !== "string") {
|
|
32220
|
+
throw new JobEnvelopeError("Invalid job request: missing pinnedVersion");
|
|
32221
|
+
}
|
|
32222
|
+
if (typeof value.deadline !== "string" || !Number.isFinite(Date.parse(value.deadline))) {
|
|
32223
|
+
throw new JobEnvelopeError("Invalid job request: invalid deadline");
|
|
32224
|
+
}
|
|
32225
|
+
return value;
|
|
32226
|
+
}
|
|
32227
|
+
function validateRequestEnvelope(value) {
|
|
32228
|
+
requirePlainObject(value, "envelope", "job request envelope");
|
|
32229
|
+
requireExactKeys(value, ["request", "auth"], "job request envelope");
|
|
32230
|
+
validateJobRequest(value.request);
|
|
32231
|
+
requireString(value.auth, "auth", "job request envelope");
|
|
32232
|
+
return value;
|
|
32233
|
+
}
|
|
32234
|
+
function validateResult(value) {
|
|
32235
|
+
requirePlainObject(value, "result", "job result");
|
|
32236
|
+
requireExactKeys(
|
|
32237
|
+
value,
|
|
32238
|
+
["v", "jobId", "scope", "version", "contentType", "body"],
|
|
32239
|
+
"job result"
|
|
32240
|
+
);
|
|
32241
|
+
if (value.v !== JOB_PROTOCOL_VERSION) {
|
|
32242
|
+
throw new JobEnvelopeError(
|
|
32243
|
+
`Unsupported job result version: ${String(value.v)}`
|
|
32244
|
+
);
|
|
32245
|
+
}
|
|
32246
|
+
for (const field of ["jobId", "scope", "contentType"]) {
|
|
32247
|
+
requireString(value[field], field, "job result");
|
|
32248
|
+
}
|
|
32249
|
+
if (!(value.body instanceof Uint8Array)) {
|
|
32250
|
+
throw new JobEnvelopeError("Invalid job result: missing body");
|
|
32251
|
+
}
|
|
32252
|
+
if (value.version !== null && typeof value.version !== "string") {
|
|
32253
|
+
throw new JobEnvelopeError("Invalid job result: missing version");
|
|
32254
|
+
}
|
|
32255
|
+
return value;
|
|
32256
|
+
}
|
|
32257
|
+
async function sealJobRequest(envelope, enclavePublicKey, ecies) {
|
|
32258
|
+
const encrypted = await ecies.encrypt(
|
|
32259
|
+
fromHex6(enclavePublicKey, "bytes"),
|
|
32260
|
+
requestPlaintext(envelope)
|
|
32261
|
+
);
|
|
32262
|
+
return encryptedBytesToBase64(encrypted);
|
|
32263
|
+
}
|
|
32264
|
+
async function openJobRequest(ciphertext, privateKey, ecies) {
|
|
32265
|
+
const plaintext = await ecies.decrypt(
|
|
32266
|
+
privateKey,
|
|
32267
|
+
base64ToEncrypted(ciphertext)
|
|
32268
|
+
);
|
|
32269
|
+
return validateRequestEnvelope(
|
|
32270
|
+
parseObject(plaintext, "job request envelope")
|
|
32271
|
+
);
|
|
32272
|
+
}
|
|
32273
|
+
async function sealJobResult(result, builderPublicKey, ecies) {
|
|
32274
|
+
validateResult(result);
|
|
32275
|
+
const encrypted = await ecies.encrypt(
|
|
32276
|
+
fromHex6(builderPublicKey, "bytes"),
|
|
32277
|
+
resultPlaintext(result)
|
|
32278
|
+
);
|
|
32279
|
+
const bytes = encryptedToBytes(encrypted);
|
|
32280
|
+
return { bytes, hash: bytesToHex2(sha2565(bytes)), size: bytes.length };
|
|
32281
|
+
}
|
|
32282
|
+
async function openJobResult(sealedBytes, builderPrivateKey, ecies, expect) {
|
|
32283
|
+
const plaintext = await ecies.decrypt(
|
|
32284
|
+
fromHex6(builderPrivateKey, "bytes"),
|
|
32285
|
+
bytesToEncrypted(sealedBytes)
|
|
32286
|
+
);
|
|
32287
|
+
const result = parseResultPlaintext(plaintext);
|
|
32288
|
+
if (result.jobId !== expect.jobId) {
|
|
32289
|
+
throw new JobEnvelopeError(
|
|
32290
|
+
`Job result ID ${result.jobId} does not match expected job ID ${expect.jobId}`
|
|
32291
|
+
);
|
|
32292
|
+
}
|
|
32293
|
+
if (expect.scope !== void 0 && result.scope !== expect.scope) {
|
|
32294
|
+
throw new JobEnvelopeError(
|
|
32295
|
+
`Job result scope ${result.scope} does not match expected scope ${expect.scope}`
|
|
32296
|
+
);
|
|
32297
|
+
}
|
|
32298
|
+
if (expect.version !== void 0 && result.version !== expect.version) {
|
|
32299
|
+
throw new JobEnvelopeError(
|
|
32300
|
+
`Job result version ${String(result.version)} does not match expected version ${String(expect.version)}`
|
|
32301
|
+
);
|
|
32302
|
+
}
|
|
32303
|
+
return result;
|
|
32304
|
+
}
|
|
32305
|
+
|
|
31739
32306
|
// src/protocol/personal-server-registration.ts
|
|
31740
32307
|
import {
|
|
31741
|
-
isAddress
|
|
32308
|
+
isAddress as isAddress2
|
|
31742
32309
|
} from "viem";
|
|
31743
32310
|
var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet2.id;
|
|
31744
32311
|
var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
|
|
@@ -31746,7 +32313,7 @@ var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress
|
|
|
31746
32313
|
"DataPortabilityServers"
|
|
31747
32314
|
);
|
|
31748
32315
|
function assertAddress(value, name) {
|
|
31749
|
-
if (!
|
|
32316
|
+
if (!isAddress2(value)) {
|
|
31750
32317
|
throw new Error(`${name} must be a valid EVM address`);
|
|
31751
32318
|
}
|
|
31752
32319
|
}
|
|
@@ -31833,13 +32400,13 @@ var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
|
|
|
31833
32400
|
|
|
31834
32401
|
// src/personal-server-lite/owner-binding.ts
|
|
31835
32402
|
import {
|
|
31836
|
-
isAddress as
|
|
32403
|
+
isAddress as isAddress3
|
|
31837
32404
|
} from "viem";
|
|
31838
32405
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
|
|
31839
32406
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
31840
32407
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
31841
32408
|
function assertAddress2(value, name) {
|
|
31842
|
-
if (!
|
|
32409
|
+
if (!isAddress3(value)) {
|
|
31843
32410
|
throw new Error(`${name} must be a valid EVM address`);
|
|
31844
32411
|
}
|
|
31845
32412
|
}
|
|
@@ -31889,7 +32456,7 @@ async function buildPersonalServerLiteOwnerBindingSignature(input) {
|
|
|
31889
32456
|
var signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
|
|
31890
32457
|
|
|
31891
32458
|
// src/account/personal-server-registration.ts
|
|
31892
|
-
import { isAddress as
|
|
32459
|
+
import { isAddress as isAddress4 } from "viem";
|
|
31893
32460
|
var ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT = "personal_server.server_registration.v1";
|
|
31894
32461
|
var AccountPersonalServerRegistrationError = class extends Error {
|
|
31895
32462
|
status;
|
|
@@ -31908,7 +32475,7 @@ function trimTrailingSlash(value) {
|
|
|
31908
32475
|
return value.replace(/\/+$/, "");
|
|
31909
32476
|
}
|
|
31910
32477
|
function assertAddress3(value, name) {
|
|
31911
|
-
if (!
|
|
32478
|
+
if (!isAddress4(value)) {
|
|
31912
32479
|
throw new Error(`${name} must be a valid EVM address`);
|
|
31913
32480
|
}
|
|
31914
32481
|
}
|
|
@@ -32434,8 +33001,8 @@ function buildMarkDataPointUnavailableRequest(config, input) {
|
|
|
32434
33001
|
|
|
32435
33002
|
// src/protocol/data-point-deletion.ts
|
|
32436
33003
|
import {
|
|
32437
|
-
isAddress as
|
|
32438
|
-
keccak256 as
|
|
33004
|
+
isAddress as isAddress6,
|
|
33005
|
+
keccak256 as keccak2563,
|
|
32439
33006
|
maxUint256,
|
|
32440
33007
|
stringToBytes as stringToBytes3
|
|
32441
33008
|
} from "viem";
|
|
@@ -32443,8 +33010,8 @@ import {
|
|
|
32443
33010
|
// src/protocol/lineage.ts
|
|
32444
33011
|
import {
|
|
32445
33012
|
encodeAbiParameters,
|
|
32446
|
-
isAddress as
|
|
32447
|
-
keccak256
|
|
33013
|
+
isAddress as isAddress5,
|
|
33014
|
+
keccak256 as keccak2562
|
|
32448
33015
|
} from "viem";
|
|
32449
33016
|
import { z } from "zod";
|
|
32450
33017
|
|
|
@@ -32523,12 +33090,12 @@ function isDataPointId(value) {
|
|
|
32523
33090
|
return typeof value === "string" && DATA_POINT_ID_PATTERN.test(value);
|
|
32524
33091
|
}
|
|
32525
33092
|
function deriveDataPointId(ownerAddress, scope) {
|
|
32526
|
-
if (!
|
|
33093
|
+
if (!isAddress5(ownerAddress, { strict: false })) {
|
|
32527
33094
|
throw new Error(
|
|
32528
33095
|
`ownerAddress is not an EVM address: ${String(ownerAddress)}`
|
|
32529
33096
|
);
|
|
32530
33097
|
}
|
|
32531
|
-
return
|
|
33098
|
+
return keccak2562(
|
|
32532
33099
|
encodeAbiParameters(
|
|
32533
33100
|
[
|
|
32534
33101
|
{ name: "ownerAddress", type: "address" },
|
|
@@ -32755,7 +33322,7 @@ var TOMBSTONE_METADATA_HASH_PREIMAGE = "vana.data-point.tombstone.metadata.v1";
|
|
|
32755
33322
|
var TOMBSTONE_DATA_HASH = "0x30c45ee72fe56d1927701316925ab7ceacd3b6f9267061735d59396f075c6222";
|
|
32756
33323
|
var TOMBSTONE_METADATA_HASH = "0xc5255a141acd6a2ae55971b62c0a85977c2511989dc114ad2abc2b7644f57d90";
|
|
32757
33324
|
function computeTombstoneHash(preimage) {
|
|
32758
|
-
return
|
|
33325
|
+
return keccak2563(stringToBytes3(preimage));
|
|
32759
33326
|
}
|
|
32760
33327
|
function isTombstoneHashes(dataHash, metadataHash) {
|
|
32761
33328
|
return typeof dataHash === "string" && typeof metadataHash === "string" && dataHash.toLowerCase() === TOMBSTONE_DATA_HASH && metadataHash.toLowerCase() === TOMBSTONE_METADATA_HASH;
|
|
@@ -32774,7 +33341,7 @@ function tombstoneDeletedAt(value) {
|
|
|
32774
33341
|
return typeof deletedAt === "string" ? deletedAt : null;
|
|
32775
33342
|
}
|
|
32776
33343
|
function assertAddress4(value, name) {
|
|
32777
|
-
if (!
|
|
33344
|
+
if (!isAddress6(value)) {
|
|
32778
33345
|
throw new Error(`${name} must be a valid EVM address`);
|
|
32779
33346
|
}
|
|
32780
33347
|
}
|
|
@@ -33189,13 +33756,13 @@ function tryGrantPermissions(scopes) {
|
|
|
33189
33756
|
}
|
|
33190
33757
|
|
|
33191
33758
|
// src/protocol/personal-server-write.ts
|
|
33192
|
-
import { sha256 as
|
|
33193
|
-
import { bytesToHex as
|
|
33759
|
+
import { sha256 as sha2567 } from "@noble/hashes/sha2";
|
|
33760
|
+
import { bytesToHex as bytesToHex4, isAddress as isAddress7 } from "viem";
|
|
33194
33761
|
import { z as z4 } from "zod";
|
|
33195
33762
|
|
|
33196
33763
|
// src/protocol/write-request.ts
|
|
33197
|
-
import { sha256 as
|
|
33198
|
-
import { bytesToHex as
|
|
33764
|
+
import { sha256 as sha2566 } from "@noble/hashes/sha2";
|
|
33765
|
+
import { bytesToHex as bytesToHex3 } from "viem";
|
|
33199
33766
|
function normalizeBaseUrl2(url) {
|
|
33200
33767
|
return url.replace(/\/+$/, "");
|
|
33201
33768
|
}
|
|
@@ -33262,22 +33829,22 @@ function freshProofNonce() {
|
|
|
33262
33829
|
return webCrypto.randomUUID();
|
|
33263
33830
|
}
|
|
33264
33831
|
if (typeof webCrypto?.getRandomValues === "function") {
|
|
33265
|
-
return
|
|
33832
|
+
return bytesToHex3(webCrypto.getRandomValues(new Uint8Array(16)));
|
|
33266
33833
|
}
|
|
33267
33834
|
throw new WriteRequestError(
|
|
33268
33835
|
"No secure random source available to build a proof nonce; provide a crypto global"
|
|
33269
33836
|
);
|
|
33270
33837
|
}
|
|
33271
33838
|
function proofKeyFor(parts) {
|
|
33272
|
-
return
|
|
33273
|
-
|
|
33839
|
+
return bytesToHex3(
|
|
33840
|
+
sha2566(
|
|
33274
33841
|
new TextEncoder().encode(
|
|
33275
33842
|
JSON.stringify([
|
|
33276
33843
|
parts.aud,
|
|
33277
33844
|
parts.method,
|
|
33278
33845
|
parts.uri,
|
|
33279
33846
|
parts.grantId,
|
|
33280
|
-
parts.signedBytes ?
|
|
33847
|
+
parts.signedBytes ? bytesToHex3(sha2566(parts.signedBytes)) : ""
|
|
33281
33848
|
])
|
|
33282
33849
|
)
|
|
33283
33850
|
)
|
|
@@ -33464,7 +34031,7 @@ function binaryWriteSignedBytes(input) {
|
|
|
33464
34031
|
mimeType: normalizeBinaryMimeType(input.contentType),
|
|
33465
34032
|
...input.filename ? { filename: input.filename } : {},
|
|
33466
34033
|
sizeBytes: input.bytes.length,
|
|
33467
|
-
contentHash:
|
|
34034
|
+
contentHash: bytesToHex4(sha2567(input.bytes)),
|
|
33468
34035
|
encoding: "base64",
|
|
33469
34036
|
content: toBase64(input.bytes),
|
|
33470
34037
|
...metadata !== void 0 ? { metadata } : {}
|
|
@@ -33512,7 +34079,7 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
33512
34079
|
for (const entry of lineage) {
|
|
33513
34080
|
let id;
|
|
33514
34081
|
if (isLineagePair(entry)) {
|
|
33515
|
-
if (!
|
|
34082
|
+
if (!isAddress7(entry.ownerAddress, { strict: false })) {
|
|
33516
34083
|
throw new WriteRequestError(
|
|
33517
34084
|
"lineage source ownerAddress must be an EVM address",
|
|
33518
34085
|
{ ownerAddress: entry.ownerAddress }
|
|
@@ -34992,6 +35559,8 @@ export {
|
|
|
34992
35559
|
BlockchainError,
|
|
34993
35560
|
BrowserECIESUint8Provider as BrowserECIESProvider,
|
|
34994
35561
|
BrowserPlatformAdapter,
|
|
35562
|
+
BuilderUnknownError,
|
|
35563
|
+
CLAIM_POLL_FLOOR_MS,
|
|
34995
35564
|
CONTRACTS,
|
|
34996
35565
|
CallbackStorage,
|
|
34997
35566
|
ContractFactory,
|
|
@@ -34999,6 +35568,8 @@ export {
|
|
|
34999
35568
|
DATA_REGISTRY_STATUS_ABI,
|
|
35000
35569
|
DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS,
|
|
35001
35570
|
DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS,
|
|
35571
|
+
DEFAULT_JOB_DEADLINE_SECONDS,
|
|
35572
|
+
DEFAULT_LEASE_SECONDS,
|
|
35002
35573
|
DEFAULT_QUESTION_POLL_INTERVAL_MS,
|
|
35003
35574
|
DEFAULT_QUESTION_TIMEOUT_MS,
|
|
35004
35575
|
DERIVATIVE_ERROR_CODES,
|
|
@@ -35023,6 +35594,9 @@ export {
|
|
|
35023
35594
|
DerivativeStatusSchema,
|
|
35024
35595
|
DropboxStorage,
|
|
35025
35596
|
ECIESError,
|
|
35597
|
+
ENCLAVE_IDENTITY_EVIDENCE_VERSION,
|
|
35598
|
+
ENCLAVE_TRUST_ANCHORS,
|
|
35599
|
+
ENCLAVE_WALLET_PURPOSE,
|
|
35026
35600
|
ESCROW_DEPOSIT_ABI2 as ESCROW_DEPOSIT_ABI,
|
|
35027
35601
|
ExpiredTokenError,
|
|
35028
35602
|
FEE_REGISTRY_ABI,
|
|
@@ -35030,12 +35604,25 @@ export {
|
|
|
35030
35604
|
GRANT_REGISTRATION_TYPES,
|
|
35031
35605
|
GRANT_REVOCATION_TYPES,
|
|
35032
35606
|
GoogleDriveStorage,
|
|
35607
|
+
GrantInvalidError,
|
|
35033
35608
|
InMemoryTokenStore,
|
|
35034
35609
|
IngestResponseSchema,
|
|
35035
35610
|
InvalidConfigurationError,
|
|
35036
35611
|
InvalidScopeEntryError,
|
|
35037
35612
|
InvalidSignatureError,
|
|
35038
35613
|
IpfsStorage,
|
|
35614
|
+
JOB_OPERATIONS,
|
|
35615
|
+
JOB_PROTOCOL_VERSION,
|
|
35616
|
+
JOB_STATES,
|
|
35617
|
+
JobEnvelopeError,
|
|
35618
|
+
JobIdTakenError,
|
|
35619
|
+
JobNotFoundError,
|
|
35620
|
+
JobRejectedError,
|
|
35621
|
+
JobRequestTooLargeError,
|
|
35622
|
+
JobResultIntegrityError,
|
|
35623
|
+
JobTimeoutError,
|
|
35624
|
+
JobTransportError,
|
|
35625
|
+
JobsClientError,
|
|
35039
35626
|
LINEAGE_FIELD,
|
|
35040
35627
|
LINEAGE_KEY,
|
|
35041
35628
|
LineageEntrySchema,
|
|
@@ -35043,16 +35630,23 @@ export {
|
|
|
35043
35630
|
LineageNodeSchema,
|
|
35044
35631
|
LineageReadError,
|
|
35045
35632
|
MASTER_KEY_MESSAGE,
|
|
35633
|
+
MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS,
|
|
35634
|
+
MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
35635
|
+
MAX_ATTEMPTS,
|
|
35636
|
+
MAX_JOB_DEADLINE_SECONDS,
|
|
35637
|
+
MAX_LEASE_SECONDS,
|
|
35046
35638
|
MAX_LINEAGE_SOURCES,
|
|
35047
35639
|
MAX_QUESTION_CHARS,
|
|
35048
35640
|
MAX_QUESTION_MODEL_CHARS,
|
|
35049
35641
|
MAX_QUESTION_SOURCE_SCOPES,
|
|
35642
|
+
MAX_WAIT_SECONDS,
|
|
35050
35643
|
MissingAuthError,
|
|
35051
35644
|
NATIVE_ASSET_ADDRESS,
|
|
35052
35645
|
NATIVE_VANA_ASSET,
|
|
35053
35646
|
NetworkError,
|
|
35054
35647
|
NonceError,
|
|
35055
35648
|
OAuthClient,
|
|
35649
|
+
OwnerNotReadyError,
|
|
35056
35650
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
35057
35651
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
35058
35652
|
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
@@ -35078,6 +35672,7 @@ export {
|
|
|
35078
35672
|
RedactedLineageNodeSchema,
|
|
35079
35673
|
RelayerError,
|
|
35080
35674
|
SCOPE_ACTIONS,
|
|
35675
|
+
SEALED_ENVELOPE_VERSION,
|
|
35081
35676
|
SERVER_REGISTRATION_TYPES,
|
|
35082
35677
|
ScopeSchema,
|
|
35083
35678
|
SerializationError,
|
|
@@ -35090,6 +35685,7 @@ export {
|
|
|
35090
35685
|
TOMBSTONE_METADATA_HASH,
|
|
35091
35686
|
TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
35092
35687
|
TransactionPendingError,
|
|
35688
|
+
USER_PS_ID_DOMAIN,
|
|
35093
35689
|
UserRejectedRequestError,
|
|
35094
35690
|
VanaError,
|
|
35095
35691
|
VanaStorage,
|
|
@@ -35108,6 +35704,7 @@ export {
|
|
|
35108
35704
|
WriteSessionExpiredError,
|
|
35109
35705
|
WriteTransportError,
|
|
35110
35706
|
WriteUnauthorizedError,
|
|
35707
|
+
appRootPreimage,
|
|
35111
35708
|
askPersonalServer,
|
|
35112
35709
|
assertDerivedScopeNaming,
|
|
35113
35710
|
assertValidPkceVerifier,
|
|
@@ -35117,6 +35714,7 @@ export {
|
|
|
35117
35714
|
buildDepositNativeRequest,
|
|
35118
35715
|
buildDepositTokenRequest,
|
|
35119
35716
|
buildMarkDataPointUnavailableRequest,
|
|
35717
|
+
buildMasterSignatureDelivery,
|
|
35120
35718
|
buildPersonalServerDataReadRequest,
|
|
35121
35719
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
35122
35720
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
@@ -35125,6 +35723,7 @@ export {
|
|
|
35125
35723
|
buildSetDataPointStatusRequest,
|
|
35126
35724
|
buildWeb3SignedHeader,
|
|
35127
35725
|
builderRegistrationDomain,
|
|
35726
|
+
canonicalJobRequestBytes,
|
|
35128
35727
|
chains,
|
|
35129
35728
|
clearContractCache,
|
|
35130
35729
|
computeBodyHash,
|
|
@@ -35156,6 +35755,7 @@ export {
|
|
|
35156
35755
|
encodeDepositTokenData,
|
|
35157
35756
|
encodeSetDataPointStatusData,
|
|
35158
35757
|
encodeWriteMetadataHeader,
|
|
35758
|
+
encryptMasterSignatureDelivery,
|
|
35159
35759
|
encryptWithPassword,
|
|
35160
35760
|
escrowContractAddress,
|
|
35161
35761
|
escrowPaymentDomain,
|
|
@@ -35190,12 +35790,15 @@ export {
|
|
|
35190
35790
|
isPlatformSupported,
|
|
35191
35791
|
isRedactedLineageNode,
|
|
35192
35792
|
isTombstoneHashes,
|
|
35793
|
+
kmsIssuedPreimage,
|
|
35193
35794
|
listQuestions,
|
|
35194
35795
|
mainnetServices,
|
|
35195
35796
|
moksha,
|
|
35196
35797
|
mokshaServices,
|
|
35197
35798
|
mokshaTestnet2 as mokshaTestnet,
|
|
35198
35799
|
normalizeBinaryMimeType,
|
|
35800
|
+
openJobRequest,
|
|
35801
|
+
openJobResult,
|
|
35199
35802
|
openWriteSession,
|
|
35200
35803
|
parsePSError,
|
|
35201
35804
|
parseScope,
|
|
@@ -35216,6 +35819,8 @@ export {
|
|
|
35216
35819
|
scopeMatchesPattern,
|
|
35217
35820
|
scopeNamespace,
|
|
35218
35821
|
scopeToPathSegments,
|
|
35822
|
+
sealJobRequest,
|
|
35823
|
+
sealJobResult,
|
|
35219
35824
|
serializeECIES,
|
|
35220
35825
|
serverRegistrationDomain,
|
|
35221
35826
|
sessionCoversScope,
|
|
@@ -35224,7 +35829,9 @@ export {
|
|
|
35224
35829
|
signPersonalServerRegistrationWithAccount,
|
|
35225
35830
|
tombstoneDeletedAt,
|
|
35226
35831
|
tryGrantPermissions,
|
|
35832
|
+
userPsId,
|
|
35227
35833
|
vanaMainnet2 as vanaMainnet,
|
|
35834
|
+
verifyEnclaveIdentityEvidence,
|
|
35228
35835
|
verifyGrantRegistration,
|
|
35229
35836
|
verifyPkceChallenge,
|
|
35230
35837
|
verifyWeb3Signed,
|