@opendatalabs/vana-sdk 3.23.0-pr.211.fa01520 → 4.0.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.
- package/dist/direct/escrow-payment.cjs.map +1 -1
- package/dist/direct/escrow-payment.d.ts +2 -2
- package/dist/direct/escrow-payment.js.map +1 -1
- package/dist/index.browser.d.ts +2 -2
- package/dist/index.browser.js +173 -2
- package/dist/index.browser.js.map +3 -3
- package/dist/index.node.cjs +188 -12
- package/dist/index.node.cjs.map +3 -3
- package/dist/index.node.d.ts +2 -2
- package/dist/index.node.js +183 -12
- package/dist/index.node.js.map +3 -3
- package/dist/protocol/eip712.cjs +28 -2
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +70 -0
- package/dist/protocol/eip712.js +24 -1
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow.cjs +154 -2
- package/dist/protocol/escrow.cjs.map +1 -1
- package/dist/protocol/escrow.d.ts +145 -2
- package/dist/protocol/escrow.js +152 -1
- package/dist/protocol/escrow.js.map +1 -1
- package/dist/protocol/fixtures/moksha-identity.json +20 -0
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +8 -38
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/identity.cjs +7 -2
- package/dist/protocol/identity.cjs.map +1 -1
- package/dist/protocol/identity.js +7 -2
- package/dist/protocol/identity.js.map +1 -1
- package/package.json +1 -1
package/dist/index.node.cjs
CHANGED
|
@@ -1206,6 +1206,8 @@ __export(index_node_exports, {
|
|
|
1206
1206
|
ENCLAVE_TRUST_ANCHORS: () => ENCLAVE_TRUST_ANCHORS,
|
|
1207
1207
|
ENCLAVE_WALLET_PURPOSE: () => ENCLAVE_WALLET_PURPOSE,
|
|
1208
1208
|
ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI2,
|
|
1209
|
+
EscrowWithdrawalLifecycleError: () => EscrowWithdrawalLifecycleError,
|
|
1210
|
+
EscrowWithdrawalRejectionError: () => EscrowWithdrawalRejectionError,
|
|
1209
1211
|
ExpiredTokenError: () => import_errors14.ExpiredTokenError,
|
|
1210
1212
|
FEE_REGISTRY_ABI: () => FEE_REGISTRY_ABI,
|
|
1211
1213
|
GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
|
|
@@ -1277,6 +1279,7 @@ __export(index_node_exports, {
|
|
|
1277
1279
|
TOMBSTONE_METADATA_HASH_PREIMAGE: () => TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
1278
1280
|
USER_PS_ID_DOMAIN: () => USER_PS_ID_DOMAIN,
|
|
1279
1281
|
VanaStorage: () => VanaStorage,
|
|
1282
|
+
WITHDRAW_AUTHORIZATION_TYPES: () => WITHDRAW_AUTHORIZATION_TYPES,
|
|
1280
1283
|
WRITER_ATTRIBUTION_KEY: () => WRITER_ATTRIBUTION_KEY,
|
|
1281
1284
|
WRITE_CONTENT_DISPOSITION_HEADER: () => WRITE_CONTENT_DISPOSITION_HEADER,
|
|
1282
1285
|
WRITE_FILENAME_HEADER: () => WRITE_FILENAME_HEADER,
|
|
@@ -1305,6 +1308,7 @@ __export(index_node_exports, {
|
|
|
1305
1308
|
buildPersonalServerRegistrationTypedData: () => buildPersonalServerRegistrationTypedData,
|
|
1306
1309
|
buildSetDataPointStatusRequest: () => buildSetDataPointStatusRequest,
|
|
1307
1310
|
buildWeb3SignedHeader: () => buildWeb3SignedHeader,
|
|
1311
|
+
buildWithdrawAuthorizationTypedData: () => buildWithdrawAuthorizationTypedData,
|
|
1308
1312
|
builderRegistrationDomain: () => builderRegistrationDomain,
|
|
1309
1313
|
canonicalJobRequestBytes: () => canonicalJobRequestBytes,
|
|
1310
1314
|
chains: () => chains,
|
|
@@ -1432,6 +1436,7 @@ __export(index_node_exports, {
|
|
|
1432
1436
|
verifyWeb3Signed: () => verifyWeb3Signed,
|
|
1433
1437
|
waitForDerivativeStatus: () => waitForDerivativeStatus,
|
|
1434
1438
|
waitForQuestion: () => waitForQuestion,
|
|
1439
|
+
withdrawAuthorizationDomain: () => withdrawAuthorizationDomain,
|
|
1435
1440
|
writeData: () => writeData,
|
|
1436
1441
|
writePersonalServerData: () => writePersonalServerData
|
|
1437
1442
|
});
|
|
@@ -32286,6 +32291,9 @@ function escrowPaymentDomain(config) {
|
|
|
32286
32291
|
config.contracts.dataPortabilityEscrow
|
|
32287
32292
|
);
|
|
32288
32293
|
}
|
|
32294
|
+
function withdrawAuthorizationDomain(config) {
|
|
32295
|
+
return escrowPaymentDomain(config);
|
|
32296
|
+
}
|
|
32289
32297
|
var GRANT_REGISTRATION_TYPES = {
|
|
32290
32298
|
GrantRegistration: [
|
|
32291
32299
|
{ name: "grantorAddress", type: "address" },
|
|
@@ -32318,6 +32326,15 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32318
32326
|
{ name: "appUrl", type: "string" }
|
|
32319
32327
|
]
|
|
32320
32328
|
};
|
|
32329
|
+
var WITHDRAW_AUTHORIZATION_TYPES = {
|
|
32330
|
+
WithdrawAuthorization: [
|
|
32331
|
+
{ name: "account", type: "address" },
|
|
32332
|
+
{ name: "asset", type: "address" },
|
|
32333
|
+
{ name: "amount", type: "uint256" },
|
|
32334
|
+
{ name: "withdrawNonce", type: "uint256" },
|
|
32335
|
+
{ name: "deadline", type: "uint256" }
|
|
32336
|
+
]
|
|
32337
|
+
};
|
|
32321
32338
|
var ADD_DATA_TYPES = {
|
|
32322
32339
|
AddData: [
|
|
32323
32340
|
{ name: "ownerAddress", type: "address" },
|
|
@@ -32336,6 +32353,14 @@ var RECORD_DATA_ACCESS_TYPES = {
|
|
|
32336
32353
|
{ name: "recordId", type: "bytes32" }
|
|
32337
32354
|
]
|
|
32338
32355
|
};
|
|
32356
|
+
function buildWithdrawAuthorizationTypedData(config, message) {
|
|
32357
|
+
return {
|
|
32358
|
+
domain: withdrawAuthorizationDomain(config),
|
|
32359
|
+
types: WITHDRAW_AUTHORIZATION_TYPES,
|
|
32360
|
+
primaryType: "WithdrawAuthorization",
|
|
32361
|
+
message
|
|
32362
|
+
};
|
|
32363
|
+
}
|
|
32339
32364
|
|
|
32340
32365
|
// src/protocol/identity.ts
|
|
32341
32366
|
var secp256k14 = __toESM(require("@noble/secp256k1"), 1);
|
|
@@ -32364,8 +32389,13 @@ function emptyAnchor() {
|
|
|
32364
32389
|
var ENCLAVE_TRUST_ANCHORS = Object.freeze({
|
|
32365
32390
|
// filled at fleet provisioning; verify fails closed while empty
|
|
32366
32391
|
[VANA_MAINNET_CHAIN_ID]: emptyAnchor(),
|
|
32367
|
-
//
|
|
32368
|
-
[MOKSHA_CHAIN_ID]:
|
|
32392
|
+
// Moksha workers share this dstack app and KMS root; the controller does not derive owner keys.
|
|
32393
|
+
[MOKSHA_CHAIN_ID]: Object.freeze({
|
|
32394
|
+
kmsRootPubkey: "0x0434c76e0c3f52ec64cbf9bbf5c910c272330166fd656c0a86bb330963e46910e1a0e6fa51bec74be2f9129342707636060d85856d102cee8290185409ecf7422f",
|
|
32395
|
+
appIds: Object.freeze([
|
|
32396
|
+
"0xec9a39de98c760e1ded9f1e97016dc5f0e357cf2"
|
|
32397
|
+
])
|
|
32398
|
+
})
|
|
32369
32399
|
});
|
|
32370
32400
|
function userPsId(chainId, ownerAddress) {
|
|
32371
32401
|
const packed = (0, import_viem14.encodePacked)(
|
|
@@ -36880,6 +36910,7 @@ function createGatewayClient(baseUrl) {
|
|
|
36880
36910
|
}
|
|
36881
36911
|
|
|
36882
36912
|
// src/protocol/escrow.ts
|
|
36913
|
+
var import_viem28 = require("viem");
|
|
36883
36914
|
var GENERIC_PAYMENT_TYPES = {
|
|
36884
36915
|
GenericPayment: [
|
|
36885
36916
|
{ name: "payerAddress", type: "address" },
|
|
@@ -36919,6 +36950,26 @@ var ESCROW_DEPOSIT_ABI2 = [
|
|
|
36919
36950
|
}
|
|
36920
36951
|
];
|
|
36921
36952
|
var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
36953
|
+
var EscrowWithdrawalLifecycleError = class extends Error {
|
|
36954
|
+
constructor(httpStatus, result) {
|
|
36955
|
+
super(result.error);
|
|
36956
|
+
this.httpStatus = httpStatus;
|
|
36957
|
+
this.result = result;
|
|
36958
|
+
}
|
|
36959
|
+
httpStatus;
|
|
36960
|
+
result;
|
|
36961
|
+
name = "EscrowWithdrawalLifecycleError";
|
|
36962
|
+
};
|
|
36963
|
+
var EscrowWithdrawalRejectionError = class extends Error {
|
|
36964
|
+
constructor(httpStatus, result) {
|
|
36965
|
+
super(result.error);
|
|
36966
|
+
this.httpStatus = httpStatus;
|
|
36967
|
+
this.result = result;
|
|
36968
|
+
}
|
|
36969
|
+
httpStatus;
|
|
36970
|
+
result;
|
|
36971
|
+
name = "EscrowWithdrawalRejectionError";
|
|
36972
|
+
};
|
|
36922
36973
|
function createEscrowGatewayClient(baseUrl) {
|
|
36923
36974
|
const base = baseUrl.replace(/\/+$/, "");
|
|
36924
36975
|
async function throwOnError(res, context) {
|
|
@@ -36934,6 +36985,27 @@ function createEscrowGatewayClient(baseUrl) {
|
|
|
36934
36985
|
);
|
|
36935
36986
|
}
|
|
36936
36987
|
}
|
|
36988
|
+
async function throwOnWithdrawError(res) {
|
|
36989
|
+
if (res.ok) return;
|
|
36990
|
+
let body;
|
|
36991
|
+
try {
|
|
36992
|
+
body = await res.json();
|
|
36993
|
+
} catch {
|
|
36994
|
+
throw new Error(
|
|
36995
|
+
`Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}`
|
|
36996
|
+
);
|
|
36997
|
+
}
|
|
36998
|
+
if (isEscrowWithdrawalFailureResult(body)) {
|
|
36999
|
+
throw new EscrowWithdrawalLifecycleError(res.status, body);
|
|
37000
|
+
}
|
|
37001
|
+
if (isEscrowWithdrawalRejectedResult(body)) {
|
|
37002
|
+
throw new EscrowWithdrawalRejectionError(res.status, body);
|
|
37003
|
+
}
|
|
37004
|
+
const error = getGatewayErrorMessage(body);
|
|
37005
|
+
throw new Error(
|
|
37006
|
+
`Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}${error ? `: ${error}` : ""}`
|
|
37007
|
+
);
|
|
37008
|
+
}
|
|
36937
37009
|
return {
|
|
36938
37010
|
async submitDeposit({ txHash }) {
|
|
36939
37011
|
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
@@ -36989,9 +37061,108 @@ function createEscrowGatewayClient(baseUrl) {
|
|
|
36989
37061
|
});
|
|
36990
37062
|
await throwOnError(res, "POST /v1/escrow/pay");
|
|
36991
37063
|
return res.json();
|
|
37064
|
+
},
|
|
37065
|
+
async withdraw({
|
|
37066
|
+
account,
|
|
37067
|
+
asset,
|
|
37068
|
+
amount,
|
|
37069
|
+
withdrawNonce,
|
|
37070
|
+
deadline,
|
|
37071
|
+
signature
|
|
37072
|
+
}) {
|
|
37073
|
+
const res = await fetch(`${base}/v1/escrow/withdraw`, {
|
|
37074
|
+
method: "POST",
|
|
37075
|
+
headers: {
|
|
37076
|
+
"Content-Type": "application/json",
|
|
37077
|
+
Authorization: `Web3Signed ${signature}`
|
|
37078
|
+
},
|
|
37079
|
+
body: JSON.stringify({
|
|
37080
|
+
account,
|
|
37081
|
+
asset,
|
|
37082
|
+
amount,
|
|
37083
|
+
withdrawNonce,
|
|
37084
|
+
deadline
|
|
37085
|
+
})
|
|
37086
|
+
});
|
|
37087
|
+
await throwOnWithdrawError(res);
|
|
37088
|
+
return res.json();
|
|
37089
|
+
},
|
|
37090
|
+
async getWithdrawNonce(account) {
|
|
37091
|
+
const res = await fetch(
|
|
37092
|
+
`${base}/v1/escrow/withdraw/nonce?account=${encodeURIComponent(account)}`,
|
|
37093
|
+
{ cache: "no-store" }
|
|
37094
|
+
);
|
|
37095
|
+
await throwOnError(res, "GET /v1/escrow/withdraw/nonce");
|
|
37096
|
+
const body = await res.json();
|
|
37097
|
+
if (!isWithdrawNonceResponse(body, account)) {
|
|
37098
|
+
throw new Error(
|
|
37099
|
+
"GET /v1/escrow/withdraw/nonce: invalid response structure"
|
|
37100
|
+
);
|
|
37101
|
+
}
|
|
37102
|
+
return body;
|
|
36992
37103
|
}
|
|
36993
37104
|
};
|
|
36994
37105
|
}
|
|
37106
|
+
function getGatewayErrorMessage(body) {
|
|
37107
|
+
if (typeof body === "object" && body !== null && "error" in body && typeof body.error === "string") {
|
|
37108
|
+
return body.error;
|
|
37109
|
+
}
|
|
37110
|
+
return void 0;
|
|
37111
|
+
}
|
|
37112
|
+
function isEscrowWithdrawalFailureResult(body) {
|
|
37113
|
+
if (typeof body !== "object" || body === null) return false;
|
|
37114
|
+
const value = body;
|
|
37115
|
+
return value.success === false && (value.status === "retryable" || value.status === "reorged" || value.status === "failed") && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && (isHash(value.txHash) || value.txHash === null) && (!("blockNumber" in value) || isBlockNumber(value.blockNumber));
|
|
37116
|
+
}
|
|
37117
|
+
function isEscrowWithdrawalRejectedResult(body) {
|
|
37118
|
+
if (typeof body !== "object" || body === null) return false;
|
|
37119
|
+
const value = body;
|
|
37120
|
+
return value.success === false && value.status === "rejected" && isWithdrawalRejectionCode(value.code) && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && optionalUint256Decimal(value.balance) && optionalUint256Decimal(value.authorizedAmount) && optionalUint256Decimal(value.withdrawingAmount) && optionalUint256Decimal(value.availableAmount) && optionalUint256Decimal(value.requestedAmount) && optionalUint256Decimal(value.minimumAmount);
|
|
37121
|
+
}
|
|
37122
|
+
function isWithdrawalRejectionCode(value) {
|
|
37123
|
+
return value === "below_minimum" || value === "deadline_too_far" || value === "expired" || value === "insufficient_available" || value === "stale_nonce";
|
|
37124
|
+
}
|
|
37125
|
+
function optionalUint256Decimal(value) {
|
|
37126
|
+
return value === void 0 || isUint256Decimal(value);
|
|
37127
|
+
}
|
|
37128
|
+
function isAddressHex(value) {
|
|
37129
|
+
return typeof value === "string" && (0, import_viem28.isHex)(value, { strict: true }) && value.length === 42;
|
|
37130
|
+
}
|
|
37131
|
+
function isHash(value) {
|
|
37132
|
+
return typeof value === "string" && (0, import_viem28.isHex)(value, { strict: true }) && value.length === 66;
|
|
37133
|
+
}
|
|
37134
|
+
function isUint256Decimal(value) {
|
|
37135
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 78) {
|
|
37136
|
+
return false;
|
|
37137
|
+
}
|
|
37138
|
+
if (!/^(0|[1-9]\d*)$/.test(value)) return false;
|
|
37139
|
+
return BigInt(value) <= 2n ** 256n - 1n;
|
|
37140
|
+
}
|
|
37141
|
+
function isBlockNumber(value) {
|
|
37142
|
+
return value === null || isUint256Decimal(value);
|
|
37143
|
+
}
|
|
37144
|
+
function isWithdrawNonceResponse(body, requestedAccount) {
|
|
37145
|
+
if (typeof body !== "object" || body === null) return false;
|
|
37146
|
+
const value = body;
|
|
37147
|
+
if (value.success !== true) return false;
|
|
37148
|
+
if (!isAddressHex(value.account)) return false;
|
|
37149
|
+
if (value.account.toLowerCase() !== requestedAccount.toLowerCase())
|
|
37150
|
+
return false;
|
|
37151
|
+
if (typeof value.chainId !== "string") return false;
|
|
37152
|
+
if (!/^(0|[1-9]\d*)$/.test(value.chainId)) return false;
|
|
37153
|
+
const isLastNull = value.lastWithdrawNonce === null;
|
|
37154
|
+
const lastNonceValid = isLastNull || isUint256Decimal(value.lastWithdrawNonce);
|
|
37155
|
+
if (!lastNonceValid) return false;
|
|
37156
|
+
if (!isUint256Decimal(value.nextWithdrawNonce)) return false;
|
|
37157
|
+
if (isLastNull) {
|
|
37158
|
+
return value.nextWithdrawNonce === "1";
|
|
37159
|
+
}
|
|
37160
|
+
const lastNonce = BigInt(value.lastWithdrawNonce);
|
|
37161
|
+
const nextNonce = BigInt(value.nextWithdrawNonce);
|
|
37162
|
+
const expectedNextNonce = lastNonce + 1n;
|
|
37163
|
+
if (expectedNextNonce > 2n ** 256n - 1n) return false;
|
|
37164
|
+
return nextNonce === expectedNextNonce;
|
|
37165
|
+
}
|
|
36995
37166
|
|
|
36996
37167
|
// src/direct/escrow-payment.ts
|
|
36997
37168
|
var GRANT_OP_TYPE = "grant";
|
|
@@ -37028,12 +37199,12 @@ var UINT256_MAX = (1n << 256n) - 1n;
|
|
|
37028
37199
|
var ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
37029
37200
|
var BYTES32_RE = /^0x[0-9a-fA-F]{64}$/;
|
|
37030
37201
|
var SIGNATURE_RE = /^0x[0-9a-fA-F]{130}$/;
|
|
37031
|
-
function
|
|
37202
|
+
function isUint256Decimal2(value, allowZero) {
|
|
37032
37203
|
const pattern = allowZero ? /^(0|[1-9]\d*)$/ : /^[1-9]\d*$/;
|
|
37033
37204
|
return value.length <= UINT256_MAX.toString().length && pattern.test(value) && BigInt(value) <= UINT256_MAX;
|
|
37034
37205
|
}
|
|
37035
37206
|
function isValidAccessRecord(record) {
|
|
37036
|
-
return BYTES32_RE.test(record.dataPointId) &&
|
|
37207
|
+
return BYTES32_RE.test(record.dataPointId) && isUint256Decimal2(record.version, false) && ADDRESS_RE.test(record.accessor) && BYTES32_RE.test(record.recordId) && SIGNATURE_RE.test(record.signature);
|
|
37037
37208
|
}
|
|
37038
37209
|
function validateSigningOperation(payerAddress, required) {
|
|
37039
37210
|
if (!ADDRESS_RE.test(payerAddress)) {
|
|
@@ -37045,10 +37216,10 @@ function validateSigningOperation(payerAddress, required) {
|
|
|
37045
37216
|
if (!ADDRESS_RE.test(required.asset || NATIVE_ASSET_ADDRESS)) {
|
|
37046
37217
|
throw new Error("Payment asset must be a 20-byte EVM address");
|
|
37047
37218
|
}
|
|
37048
|
-
if (!
|
|
37219
|
+
if (!isUint256Decimal2(required.amount, true)) {
|
|
37049
37220
|
throw new Error("Payment amount must be a canonical uint256 decimal");
|
|
37050
37221
|
}
|
|
37051
|
-
if (required.paymentNonce !== void 0 && !
|
|
37222
|
+
if (required.paymentNonce !== void 0 && !isUint256Decimal2(required.paymentNonce, false)) {
|
|
37052
37223
|
throw new Error("Payment nonce must be a positive uint256 decimal");
|
|
37053
37224
|
}
|
|
37054
37225
|
const accessRecord = required.accessRecord;
|
|
@@ -37179,7 +37350,7 @@ function paymentResponseMetadataFromHeader(header) {
|
|
|
37179
37350
|
const registrationFee = stringField(breakdown, "registrationFee");
|
|
37180
37351
|
const dataAccessFee = stringField(breakdown, "dataAccessFee");
|
|
37181
37352
|
const paidAt = stringField(result, "paidAt");
|
|
37182
|
-
if (result?.success !== true || !opType || !opId || !BYTES32_RE.test(opId) || !payerAddress || !ADDRESS_RE.test(payerAddress) || !asset || !ADDRESS_RE.test(asset) || !amount || !
|
|
37353
|
+
if (result?.success !== true || !opType || !opId || !BYTES32_RE.test(opId) || !payerAddress || !ADDRESS_RE.test(payerAddress) || !asset || !ADDRESS_RE.test(asset) || !amount || !isUint256Decimal2(amount, true) || !paymentNonce || !isUint256Decimal2(paymentNonce, false) || !registrationFee || !isUint256Decimal2(registrationFee, true) || !dataAccessFee || !isUint256Decimal2(dataAccessFee, true) || typeof breakdown?.registrationPaid !== "boolean" || !paidAt || !isCanonicalIsoTimestamp(paidAt)) {
|
|
37183
37354
|
return void 0;
|
|
37184
37355
|
}
|
|
37185
37356
|
return {
|
|
@@ -37260,15 +37431,15 @@ function isBytes32Hex(value) {
|
|
|
37260
37431
|
return /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
37261
37432
|
}
|
|
37262
37433
|
var UINT256_MAX2 = (1n << 256n) - 1n;
|
|
37263
|
-
function
|
|
37434
|
+
function isAddressHex2(value) {
|
|
37264
37435
|
return /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
37265
37436
|
}
|
|
37266
|
-
function
|
|
37437
|
+
function isUint256Decimal3(value, allowZero) {
|
|
37267
37438
|
const pattern = allowZero ? /^(0|[1-9]\d*)$/ : /^[1-9]\d*$/;
|
|
37268
37439
|
return value.length <= UINT256_MAX2.toString().length && pattern.test(value) && BigInt(value) <= UINT256_MAX2;
|
|
37269
37440
|
}
|
|
37270
37441
|
function isValidDataAccessRecord(record) {
|
|
37271
|
-
return isBytes32Hex(record.dataPointId) &&
|
|
37442
|
+
return isBytes32Hex(record.dataPointId) && isUint256Decimal3(record.version, false) && isAddressHex2(record.accessor) && isBytes32Hex(record.recordId) && /^0x[0-9a-fA-F]{130}$/.test(record.signature);
|
|
37272
37443
|
}
|
|
37273
37444
|
function parseLegacyGrantOperation(params) {
|
|
37274
37445
|
const { challengeGrantId, challengeOpId, challengeOpType, grantId } = params;
|
|
@@ -37319,7 +37490,7 @@ function parseCanonicalDataAccessAccept(value) {
|
|
|
37319
37490
|
const accessRecord = parseAccessRecord(accept?.accessRecord);
|
|
37320
37491
|
const acceptAsset = stringField2(accept, "asset");
|
|
37321
37492
|
const acceptAmount = stringField2(accept, "amount");
|
|
37322
|
-
if (!network || !payerAddress || !
|
|
37493
|
+
if (!network || !payerAddress || !isAddressHex2(payerAddress) || !opId || !isBytes32Hex(opId) || !asset || !isAddressHex2(asset) || !amount || !isUint256Decimal3(amount, true) || !paymentNonce || !isUint256Decimal3(paymentNonce, false) || !accessRecord || !isValidDataAccessRecord(accessRecord) || payerAddress.toLowerCase() !== accessRecord.accessor.toLowerCase() || opId.toLowerCase() !== accessRecord.recordId.toLowerCase() || !acceptAsset || acceptAsset.toLowerCase() !== asset.toLowerCase() || acceptAmount !== amount) {
|
|
37323
37494
|
return null;
|
|
37324
37495
|
}
|
|
37325
37496
|
return {
|
|
@@ -37404,7 +37575,7 @@ async function parsePersonalServerPaymentRequired(res, grantId) {
|
|
|
37404
37575
|
const acceptAmount = stringField2(accept, "amount");
|
|
37405
37576
|
const accessRecord2 = parseAccessRecord(accept.accessRecord);
|
|
37406
37577
|
const hasAccessRecord = accept.accessRecord !== void 0;
|
|
37407
|
-
if (!network || !payerAddress || !
|
|
37578
|
+
if (!network || !payerAddress || !isAddressHex2(payerAddress) || !opId || !isBytes32Hex(opId) || !asset || !isAddressHex2(asset) || !amount || !isUint256Decimal3(amount, true) || !paymentNonce || !isUint256Decimal3(paymentNonce, false) || !acceptAsset || acceptAsset.toLowerCase() !== asset.toLowerCase() || acceptAmount !== amount || hasAccessRecord && (!accessRecord2 || !isValidDataAccessRecord(accessRecord2) || accessRecord2.accessor.toLowerCase() !== payerAddress.toLowerCase()) || amount === "0" && !accessRecord2) {
|
|
37408
37579
|
throw new import_errors12.PersonalServerReadError(
|
|
37409
37580
|
"Personal Server grant payment challenge was untrusted or incomplete",
|
|
37410
37581
|
402
|
|
@@ -37548,6 +37719,8 @@ async function parsePSError(response) {
|
|
|
37548
37719
|
ENCLAVE_TRUST_ANCHORS,
|
|
37549
37720
|
ENCLAVE_WALLET_PURPOSE,
|
|
37550
37721
|
ESCROW_DEPOSIT_ABI,
|
|
37722
|
+
EscrowWithdrawalLifecycleError,
|
|
37723
|
+
EscrowWithdrawalRejectionError,
|
|
37551
37724
|
ExpiredTokenError,
|
|
37552
37725
|
FEE_REGISTRY_ABI,
|
|
37553
37726
|
GENERIC_PAYMENT_TYPES,
|
|
@@ -37619,6 +37792,7 @@ async function parsePSError(response) {
|
|
|
37619
37792
|
TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
37620
37793
|
USER_PS_ID_DOMAIN,
|
|
37621
37794
|
VanaStorage,
|
|
37795
|
+
WITHDRAW_AUTHORIZATION_TYPES,
|
|
37622
37796
|
WRITER_ATTRIBUTION_KEY,
|
|
37623
37797
|
WRITE_CONTENT_DISPOSITION_HEADER,
|
|
37624
37798
|
WRITE_FILENAME_HEADER,
|
|
@@ -37647,6 +37821,7 @@ async function parsePSError(response) {
|
|
|
37647
37821
|
buildPersonalServerRegistrationTypedData,
|
|
37648
37822
|
buildSetDataPointStatusRequest,
|
|
37649
37823
|
buildWeb3SignedHeader,
|
|
37824
|
+
buildWithdrawAuthorizationTypedData,
|
|
37650
37825
|
builderRegistrationDomain,
|
|
37651
37826
|
canonicalJobRequestBytes,
|
|
37652
37827
|
chains,
|
|
@@ -37774,6 +37949,7 @@ async function parsePSError(response) {
|
|
|
37774
37949
|
verifyWeb3Signed,
|
|
37775
37950
|
waitForDerivativeStatus,
|
|
37776
37951
|
waitForQuestion,
|
|
37952
|
+
withdrawAuthorizationDomain,
|
|
37777
37953
|
writeData,
|
|
37778
37954
|
writePersonalServerData,
|
|
37779
37955
|
...require("./errors.cjs")
|