@opendatalabs/vana-sdk 3.13.4-pr.186.afb5a4f → 3.14.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/config/contracts.config.cjs +1 -1
- package/dist/config/contracts.config.cjs.map +1 -1
- package/dist/config/contracts.config.js +1 -1
- package/dist/config/contracts.config.js.map +1 -1
- package/dist/direct/access-request-client.cjs +3 -1
- package/dist/direct/access-request-client.cjs.map +1 -1
- package/dist/direct/access-request-client.js +3 -1
- package/dist/direct/access-request-client.js.map +1 -1
- package/dist/direct/controller.cjs +72 -32
- package/dist/direct/controller.cjs.map +1 -1
- package/dist/direct/controller.d.ts +41 -3
- package/dist/direct/controller.js +77 -33
- package/dist/direct/controller.js.map +1 -1
- package/dist/direct/errors.cjs +11 -2
- package/dist/direct/errors.cjs.map +1 -1
- package/dist/direct/errors.d.ts +13 -0
- package/dist/direct/errors.js +9 -1
- package/dist/direct/errors.js.map +1 -1
- 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/direct/types.cjs.map +1 -1
- package/dist/direct/types.d.ts +33 -1
- package/dist/direct/types.js.map +1 -1
- package/dist/generated/addresses.cjs +6 -6
- package/dist/generated/addresses.cjs.map +1 -1
- package/dist/generated/addresses.d.ts +6 -6
- package/dist/generated/addresses.js +6 -6
- package/dist/generated/addresses.js.map +1 -1
- package/dist/index.browser.d.ts +2 -2
- package/dist/index.browser.js +7 -136
- package/dist/index.browser.js.map +2 -2
- package/dist/index.node.cjs +18 -151
- package/dist/index.node.cjs.map +3 -3
- package/dist/index.node.d.ts +2 -2
- package/dist/index.node.js +17 -146
- package/dist/index.node.js.map +3 -3
- package/dist/protocol/eip712.cjs +2 -28
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +0 -70
- package/dist/protocol/eip712.js +1 -24
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow.cjs +2 -118
- package/dist/protocol/escrow.cjs.map +1 -1
- package/dist/protocol/escrow.d.ts +2 -108
- package/dist/protocol/escrow.js +1 -116
- package/dist/protocol/escrow.js.map +1 -1
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +38 -8
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/server.cjs +2 -0
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/index.node.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export { MissingAuthError, InvalidSignatureError, ExpiredTokenError, } from "./a
|
|
|
36
36
|
export { generatePkceVerifier, computePkceChallenge, verifyPkceChallenge, assertValidPkceVerifier, PKCE_VERIFIER_PATTERN, PKCE_CHALLENGE_PATTERN, } from "./auth/pkce.js";
|
|
37
37
|
export { InMemoryTokenStore, type TokenStore, type TokenRecord, } from "./auth/token-store.js";
|
|
38
38
|
export { OAuthClient, type OAuthClientConfig, type AuthorizationUrlResult, } from "./auth/oauth-client.js";
|
|
39
|
-
export { NATIVE_VANA_ASSET, dataRegistryDomain, grantRegistrationDomain, grantRevocationDomain, serverRegistrationDomain, builderRegistrationDomain, escrowPaymentDomain,
|
|
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 { 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";
|
|
41
41
|
export { PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION, PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE, PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX, buildPersonalServerLiteOwnerBindingMessage, createViemPersonalServerLiteOwnerBindingSigner, buildPersonalServerLiteOwnerBindingSignature, signPersonalServerLiteOwnerBinding, type PersonalServerLiteOwnerBindingPurpose, type PersonalServerLiteOwnerBindingMessage, type PersonalServerLiteOwnerBindingSigner, type ViemPersonalServerLiteOwnerBindingWalletClient, type ViemPersonalServerLiteOwnerBindingSignerSource, type BuildPersonalServerLiteOwnerBindingSignatureInput, type PersonalServerLiteOwnerBindingSignature, } from "./personal-server-lite/owner-binding.js";
|
|
42
42
|
export { ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT, AccountPersonalServerRegistrationError, signPersonalServerRegistrationWithAccount, type AccountPersonalServerRegistrationIntent, type AccountPersonalServerRegistrationSignature, type AccountPersonalServerRegistrationStatus, type AccountPersonalServerRegistrationRequest, type AccountPersonalServerRegistrationConfig, type AccountSignedPersonalServerRegistration, type AccountConfirmationRequiredPersonalServerRegistration, type AccountFallbackSignedPersonalServerRegistration, type AccountPersonalServerRegistrationResult, } from "./account/personal-server-registration.js";
|
|
@@ -49,7 +49,7 @@ export { personalServerDataReadPath, buildPersonalServerDataReadRequest, readPer
|
|
|
49
49
|
export { ScopeSchema, parseScope, scopeToPathSegments, scopeMatchesPattern, scopeCoveredByGrant, type Scope, type ParsedScope, } from "./protocol/scopes.js";
|
|
50
50
|
export { DataFileEnvelopeSchema, createDataFileEnvelope, IngestResponseSchema, type DataFileEnvelope, type IngestResponse, } from "./protocol/data-file.js";
|
|
51
51
|
export { createGatewayClient, type GatewayEnvelope, type GatewayProof, type Builder, type Schema, type ServerInfo, type OwnerServerRecord, type OwnerServersResult, type GatewayGrantFee, type GatewayGrantStatus, type GatewayGrantResponse, type GrantListItem, type DataPointRecord, type DataPointListResult, type ListDataPointsOptions, type RegisterServerParams, type RegisterServerResult, type RegisterBuilderParams, type RegisterBuilderResult, type RegisterDataPointParams, type RegisterDataPointResult, type CreateGrantParams, type RevokeGrantParams, type AccessRecord, type PayForOperationParams, type PayForOperationResult, type SettleOpType, type SettleItem, type SettlePromoteResult, type SettleReconcileItem, type SettleParams, type SettleResult, type GatewayClient, } from "./protocol/gateway.js";
|
|
52
|
-
export { createEscrowGatewayClient, genericPaymentDomain, GENERIC_PAYMENT_TYPES, ESCROW_DEPOSIT_ABI, NATIVE_ASSET_ADDRESS, type GenericPaymentMessage, type EscrowBalanceEntry, type EscrowBalanceResult, type EscrowBalanceSyncResult, type DepositSubmissionResult, type PaymentBreakdown, type EscrowPayResult,
|
|
52
|
+
export { createEscrowGatewayClient, genericPaymentDomain, GENERIC_PAYMENT_TYPES, ESCROW_DEPOSIT_ABI, NATIVE_ASSET_ADDRESS, type GenericPaymentMessage, type EscrowBalanceEntry, type EscrowBalanceResult, type EscrowBalanceSyncResult, type DepositSubmissionResult, type PaymentBreakdown, type EscrowPayResult, type SubmitDepositParams, type PayForOpParams, type EscrowGatewayClient, type SubmittedDepositEntry, type FinalizedDepositEntry, type FailedDepositEntry, } from "./protocol/escrow.js";
|
|
53
53
|
export { authorizeEscrowPayment, authorizeGrantPayment, buildEscrowPaymentHeader, buildGrantPaymentHeader, createDefaultNonceSource, DATA_ACCESS_OP_TYPE, GRANT_OP_TYPE, paymentReceiptFromHeader, paymentResponseMetadataFromHeader, toDirectFeeBreakdown, toDirectPaymentReceipt, type EscrowPaymentConfig, type EscrowPaymentHeaderConfig, type PaymentNonceSource, type SignTypedDataFn, } from "./direct/escrow-payment.js";
|
|
54
54
|
export { parsePersonalServerPaymentRequired, type FetchResponseLike, } from "./direct/personal-server-read.js";
|
|
55
55
|
export type { DirectPaymentResponseMetadata, PersonalServerDataAccessPaymentOperation, PersonalServerGrantPaymentOperation, PersonalServerPaymentOperation, PersonalServerPaymentRequired, } from "./direct/types.js";
|
package/dist/index.node.js
CHANGED
|
@@ -28463,7 +28463,7 @@ var CONTRACTS = {
|
|
|
28463
28463
|
},
|
|
28464
28464
|
DataPortabilityServers: {
|
|
28465
28465
|
addresses: {
|
|
28466
|
-
14800: "
|
|
28466
|
+
14800: "0xCae2CE0e9caa6643ed28186cF57bd40Bd9E17Eab",
|
|
28467
28467
|
1480: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c"
|
|
28468
28468
|
}
|
|
28469
28469
|
},
|
|
@@ -28621,7 +28621,7 @@ var CONTRACTS = {
|
|
|
28621
28621
|
},
|
|
28622
28622
|
_meta: {
|
|
28623
28623
|
discoveredFrom: "ComputeEngine",
|
|
28624
|
-
lastUpdated: "2026-
|
|
28624
|
+
lastUpdated: "2026-08-18"
|
|
28625
28625
|
}
|
|
28626
28626
|
},
|
|
28627
28627
|
VanaTreasury: {
|
|
@@ -28631,7 +28631,7 @@ var CONTRACTS = {
|
|
|
28631
28631
|
},
|
|
28632
28632
|
_meta: {
|
|
28633
28633
|
discoveredFrom: "QueryEngine",
|
|
28634
|
-
lastUpdated: "2026-
|
|
28634
|
+
lastUpdated: "2026-08-18"
|
|
28635
28635
|
}
|
|
28636
28636
|
},
|
|
28637
28637
|
DLPRegistryTreasury: {
|
|
@@ -28641,7 +28641,7 @@ var CONTRACTS = {
|
|
|
28641
28641
|
},
|
|
28642
28642
|
_meta: {
|
|
28643
28643
|
discoveredFrom: "DLPRegistry",
|
|
28644
|
-
lastUpdated: "2026-
|
|
28644
|
+
lastUpdated: "2026-08-18"
|
|
28645
28645
|
}
|
|
28646
28646
|
},
|
|
28647
28647
|
VanaPoolTreasury: {
|
|
@@ -28651,7 +28651,7 @@ var CONTRACTS = {
|
|
|
28651
28651
|
},
|
|
28652
28652
|
_meta: {
|
|
28653
28653
|
discoveredFrom: "VanaPoolStaking",
|
|
28654
|
-
lastUpdated: "2026-
|
|
28654
|
+
lastUpdated: "2026-08-18"
|
|
28655
28655
|
}
|
|
28656
28656
|
},
|
|
28657
28657
|
VanaPoolEntity: {
|
|
@@ -28661,7 +28661,7 @@ var CONTRACTS = {
|
|
|
28661
28661
|
},
|
|
28662
28662
|
_meta: {
|
|
28663
28663
|
discoveredFrom: "VanaPoolStaking",
|
|
28664
|
-
lastUpdated: "2026-
|
|
28664
|
+
lastUpdated: "2026-08-18"
|
|
28665
28665
|
}
|
|
28666
28666
|
}
|
|
28667
28667
|
};
|
|
@@ -32715,9 +32715,6 @@ function escrowPaymentDomain(config) {
|
|
|
32715
32715
|
config.contracts.dataPortabilityEscrow
|
|
32716
32716
|
);
|
|
32717
32717
|
}
|
|
32718
|
-
function withdrawAuthorizationDomain(config) {
|
|
32719
|
-
return escrowPaymentDomain(config);
|
|
32720
|
-
}
|
|
32721
32718
|
var GRANT_REGISTRATION_TYPES = {
|
|
32722
32719
|
GrantRegistration: [
|
|
32723
32720
|
{ name: "grantorAddress", type: "address" },
|
|
@@ -32750,15 +32747,6 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32750
32747
|
{ name: "appUrl", type: "string" }
|
|
32751
32748
|
]
|
|
32752
32749
|
};
|
|
32753
|
-
var WITHDRAW_AUTHORIZATION_TYPES = {
|
|
32754
|
-
WithdrawAuthorization: [
|
|
32755
|
-
{ name: "account", type: "address" },
|
|
32756
|
-
{ name: "asset", type: "address" },
|
|
32757
|
-
{ name: "amount", type: "uint256" },
|
|
32758
|
-
{ name: "withdrawNonce", type: "uint256" },
|
|
32759
|
-
{ name: "deadline", type: "uint256" }
|
|
32760
|
-
]
|
|
32761
|
-
};
|
|
32762
32750
|
var ADD_DATA_TYPES = {
|
|
32763
32751
|
AddData: [
|
|
32764
32752
|
{ name: "ownerAddress", type: "address" },
|
|
@@ -32777,14 +32765,6 @@ var RECORD_DATA_ACCESS_TYPES = {
|
|
|
32777
32765
|
{ name: "recordId", type: "bytes32" }
|
|
32778
32766
|
]
|
|
32779
32767
|
};
|
|
32780
|
-
function buildWithdrawAuthorizationTypedData(config, message) {
|
|
32781
|
-
return {
|
|
32782
|
-
domain: withdrawAuthorizationDomain(config),
|
|
32783
|
-
types: WITHDRAW_AUTHORIZATION_TYPES,
|
|
32784
|
-
primaryType: "WithdrawAuthorization",
|
|
32785
|
-
message
|
|
32786
|
-
};
|
|
32787
|
-
}
|
|
32788
32768
|
|
|
32789
32769
|
// src/protocol/personal-server-registration.ts
|
|
32790
32770
|
import {
|
|
@@ -33895,7 +33875,6 @@ function createGatewayClient(baseUrl) {
|
|
|
33895
33875
|
}
|
|
33896
33876
|
|
|
33897
33877
|
// src/protocol/escrow.ts
|
|
33898
|
-
import { isHex } from "viem";
|
|
33899
33878
|
var GENERIC_PAYMENT_TYPES = {
|
|
33900
33879
|
GenericPayment: [
|
|
33901
33880
|
{ name: "payerAddress", type: "address" },
|
|
@@ -33935,26 +33914,6 @@ var ESCROW_DEPOSIT_ABI2 = [
|
|
|
33935
33914
|
}
|
|
33936
33915
|
];
|
|
33937
33916
|
var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
33938
|
-
var EscrowWithdrawalLifecycleError = class extends Error {
|
|
33939
|
-
constructor(httpStatus, result) {
|
|
33940
|
-
super(result.error);
|
|
33941
|
-
this.httpStatus = httpStatus;
|
|
33942
|
-
this.result = result;
|
|
33943
|
-
}
|
|
33944
|
-
httpStatus;
|
|
33945
|
-
result;
|
|
33946
|
-
name = "EscrowWithdrawalLifecycleError";
|
|
33947
|
-
};
|
|
33948
|
-
var EscrowWithdrawalRejectionError = class extends Error {
|
|
33949
|
-
constructor(httpStatus, result) {
|
|
33950
|
-
super(result.error);
|
|
33951
|
-
this.httpStatus = httpStatus;
|
|
33952
|
-
this.result = result;
|
|
33953
|
-
}
|
|
33954
|
-
httpStatus;
|
|
33955
|
-
result;
|
|
33956
|
-
name = "EscrowWithdrawalRejectionError";
|
|
33957
|
-
};
|
|
33958
33917
|
function createEscrowGatewayClient(baseUrl) {
|
|
33959
33918
|
const base = baseUrl.replace(/\/+$/, "");
|
|
33960
33919
|
async function throwOnError(res, context) {
|
|
@@ -33970,27 +33929,6 @@ function createEscrowGatewayClient(baseUrl) {
|
|
|
33970
33929
|
);
|
|
33971
33930
|
}
|
|
33972
33931
|
}
|
|
33973
|
-
async function throwOnWithdrawError(res) {
|
|
33974
|
-
if (res.ok) return;
|
|
33975
|
-
let body;
|
|
33976
|
-
try {
|
|
33977
|
-
body = await res.json();
|
|
33978
|
-
} catch {
|
|
33979
|
-
throw new Error(
|
|
33980
|
-
`Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}`
|
|
33981
|
-
);
|
|
33982
|
-
}
|
|
33983
|
-
if (isEscrowWithdrawalFailureResult(body)) {
|
|
33984
|
-
throw new EscrowWithdrawalLifecycleError(res.status, body);
|
|
33985
|
-
}
|
|
33986
|
-
if (isEscrowWithdrawalRejectedResult(body)) {
|
|
33987
|
-
throw new EscrowWithdrawalRejectionError(res.status, body);
|
|
33988
|
-
}
|
|
33989
|
-
const error = getGatewayErrorMessage(body);
|
|
33990
|
-
throw new Error(
|
|
33991
|
-
`Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}${error ? `: ${error}` : ""}`
|
|
33992
|
-
);
|
|
33993
|
-
}
|
|
33994
33932
|
return {
|
|
33995
33933
|
async submitDeposit({ txHash }) {
|
|
33996
33934
|
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
@@ -34046,72 +33984,9 @@ function createEscrowGatewayClient(baseUrl) {
|
|
|
34046
33984
|
});
|
|
34047
33985
|
await throwOnError(res, "POST /v1/escrow/pay");
|
|
34048
33986
|
return res.json();
|
|
34049
|
-
},
|
|
34050
|
-
async withdraw({
|
|
34051
|
-
account,
|
|
34052
|
-
asset,
|
|
34053
|
-
amount,
|
|
34054
|
-
withdrawNonce,
|
|
34055
|
-
deadline,
|
|
34056
|
-
signature
|
|
34057
|
-
}) {
|
|
34058
|
-
const res = await fetch(`${base}/v1/escrow/withdraw`, {
|
|
34059
|
-
method: "POST",
|
|
34060
|
-
headers: {
|
|
34061
|
-
"Content-Type": "application/json",
|
|
34062
|
-
Authorization: `Web3Signed ${signature}`
|
|
34063
|
-
},
|
|
34064
|
-
body: JSON.stringify({
|
|
34065
|
-
account,
|
|
34066
|
-
asset,
|
|
34067
|
-
amount,
|
|
34068
|
-
withdrawNonce,
|
|
34069
|
-
deadline
|
|
34070
|
-
})
|
|
34071
|
-
});
|
|
34072
|
-
await throwOnWithdrawError(res);
|
|
34073
|
-
return res.json();
|
|
34074
33987
|
}
|
|
34075
33988
|
};
|
|
34076
33989
|
}
|
|
34077
|
-
function getGatewayErrorMessage(body) {
|
|
34078
|
-
if (typeof body === "object" && body !== null && "error" in body && typeof body.error === "string") {
|
|
34079
|
-
return body.error;
|
|
34080
|
-
}
|
|
34081
|
-
return void 0;
|
|
34082
|
-
}
|
|
34083
|
-
function isEscrowWithdrawalFailureResult(body) {
|
|
34084
|
-
if (typeof body !== "object" || body === null) return false;
|
|
34085
|
-
const value = body;
|
|
34086
|
-
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));
|
|
34087
|
-
}
|
|
34088
|
-
function isEscrowWithdrawalRejectedResult(body) {
|
|
34089
|
-
if (typeof body !== "object" || body === null) return false;
|
|
34090
|
-
const value = body;
|
|
34091
|
-
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);
|
|
34092
|
-
}
|
|
34093
|
-
function isWithdrawalRejectionCode(value) {
|
|
34094
|
-
return value === "below_minimum" || value === "deadline_too_far" || value === "expired" || value === "insufficient_available" || value === "stale_nonce";
|
|
34095
|
-
}
|
|
34096
|
-
function optionalUint256Decimal(value) {
|
|
34097
|
-
return value === void 0 || isUint256Decimal(value);
|
|
34098
|
-
}
|
|
34099
|
-
function isAddressHex(value) {
|
|
34100
|
-
return typeof value === "string" && isHex(value, { strict: true }) && value.length === 42;
|
|
34101
|
-
}
|
|
34102
|
-
function isHash(value) {
|
|
34103
|
-
return typeof value === "string" && isHex(value, { strict: true }) && value.length === 66;
|
|
34104
|
-
}
|
|
34105
|
-
function isUint256Decimal(value) {
|
|
34106
|
-
if (typeof value !== "string" || value.length === 0 || value.length > 78) {
|
|
34107
|
-
return false;
|
|
34108
|
-
}
|
|
34109
|
-
if (!/^(0|[1-9]\d*)$/.test(value)) return false;
|
|
34110
|
-
return BigInt(value) <= 2n ** 256n - 1n;
|
|
34111
|
-
}
|
|
34112
|
-
function isBlockNumber(value) {
|
|
34113
|
-
return value === null || isUint256Decimal(value);
|
|
34114
|
-
}
|
|
34115
33990
|
|
|
34116
33991
|
// src/direct/escrow-payment.ts
|
|
34117
33992
|
var GRANT_OP_TYPE = "grant";
|
|
@@ -34148,12 +34023,12 @@ var UINT256_MAX = (1n << 256n) - 1n;
|
|
|
34148
34023
|
var ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
34149
34024
|
var BYTES32_RE = /^0x[0-9a-fA-F]{64}$/;
|
|
34150
34025
|
var SIGNATURE_RE = /^0x[0-9a-fA-F]{130}$/;
|
|
34151
|
-
function
|
|
34026
|
+
function isUint256Decimal(value, allowZero) {
|
|
34152
34027
|
const pattern = allowZero ? /^(0|[1-9]\d*)$/ : /^[1-9]\d*$/;
|
|
34153
34028
|
return value.length <= UINT256_MAX.toString().length && pattern.test(value) && BigInt(value) <= UINT256_MAX;
|
|
34154
34029
|
}
|
|
34155
34030
|
function isValidAccessRecord(record) {
|
|
34156
|
-
return BYTES32_RE.test(record.dataPointId) &&
|
|
34031
|
+
return BYTES32_RE.test(record.dataPointId) && isUint256Decimal(record.version, false) && ADDRESS_RE.test(record.accessor) && BYTES32_RE.test(record.recordId) && SIGNATURE_RE.test(record.signature);
|
|
34157
34032
|
}
|
|
34158
34033
|
function validateSigningOperation(payerAddress, required) {
|
|
34159
34034
|
if (!ADDRESS_RE.test(payerAddress)) {
|
|
@@ -34165,10 +34040,10 @@ function validateSigningOperation(payerAddress, required) {
|
|
|
34165
34040
|
if (!ADDRESS_RE.test(required.asset || NATIVE_ASSET_ADDRESS)) {
|
|
34166
34041
|
throw new Error("Payment asset must be a 20-byte EVM address");
|
|
34167
34042
|
}
|
|
34168
|
-
if (!
|
|
34043
|
+
if (!isUint256Decimal(required.amount, true)) {
|
|
34169
34044
|
throw new Error("Payment amount must be a canonical uint256 decimal");
|
|
34170
34045
|
}
|
|
34171
|
-
if (required.paymentNonce !== void 0 && !
|
|
34046
|
+
if (required.paymentNonce !== void 0 && !isUint256Decimal(required.paymentNonce, false)) {
|
|
34172
34047
|
throw new Error("Payment nonce must be a positive uint256 decimal");
|
|
34173
34048
|
}
|
|
34174
34049
|
const accessRecord = required.accessRecord;
|
|
@@ -34299,7 +34174,7 @@ function paymentResponseMetadataFromHeader(header) {
|
|
|
34299
34174
|
const registrationFee = stringField(breakdown, "registrationFee");
|
|
34300
34175
|
const dataAccessFee = stringField(breakdown, "dataAccessFee");
|
|
34301
34176
|
const paidAt = stringField(result, "paidAt");
|
|
34302
|
-
if (result?.success !== true || !opType || !opId || !BYTES32_RE.test(opId) || !payerAddress || !ADDRESS_RE.test(payerAddress) || !asset || !ADDRESS_RE.test(asset) || !amount || !
|
|
34177
|
+
if (result?.success !== true || !opType || !opId || !BYTES32_RE.test(opId) || !payerAddress || !ADDRESS_RE.test(payerAddress) || !asset || !ADDRESS_RE.test(asset) || !amount || !isUint256Decimal(amount, true) || !paymentNonce || !isUint256Decimal(paymentNonce, false) || !registrationFee || !isUint256Decimal(registrationFee, true) || !dataAccessFee || !isUint256Decimal(dataAccessFee, true) || typeof breakdown?.registrationPaid !== "boolean" || !paidAt || !isCanonicalIsoTimestamp(paidAt)) {
|
|
34303
34178
|
return void 0;
|
|
34304
34179
|
}
|
|
34305
34180
|
return {
|
|
@@ -34389,15 +34264,15 @@ function isBytes32Hex(value) {
|
|
|
34389
34264
|
return /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
34390
34265
|
}
|
|
34391
34266
|
var UINT256_MAX2 = (1n << 256n) - 1n;
|
|
34392
|
-
function
|
|
34267
|
+
function isAddressHex(value) {
|
|
34393
34268
|
return /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
34394
34269
|
}
|
|
34395
|
-
function
|
|
34270
|
+
function isUint256Decimal2(value, allowZero) {
|
|
34396
34271
|
const pattern = allowZero ? /^(0|[1-9]\d*)$/ : /^[1-9]\d*$/;
|
|
34397
34272
|
return value.length <= UINT256_MAX2.toString().length && pattern.test(value) && BigInt(value) <= UINT256_MAX2;
|
|
34398
34273
|
}
|
|
34399
34274
|
function isValidDataAccessRecord(record) {
|
|
34400
|
-
return isBytes32Hex(record.dataPointId) &&
|
|
34275
|
+
return isBytes32Hex(record.dataPointId) && isUint256Decimal2(record.version, false) && isAddressHex(record.accessor) && isBytes32Hex(record.recordId) && /^0x[0-9a-fA-F]{130}$/.test(record.signature);
|
|
34401
34276
|
}
|
|
34402
34277
|
function parseLegacyGrantOperation(params) {
|
|
34403
34278
|
const { challengeGrantId, challengeOpId, challengeOpType, grantId } = params;
|
|
@@ -34448,7 +34323,7 @@ function parseCanonicalDataAccessAccept(value) {
|
|
|
34448
34323
|
const accessRecord = parseAccessRecord(accept?.accessRecord);
|
|
34449
34324
|
const acceptAsset = stringField2(accept, "asset");
|
|
34450
34325
|
const acceptAmount = stringField2(accept, "amount");
|
|
34451
|
-
if (!network || !payerAddress || !
|
|
34326
|
+
if (!network || !payerAddress || !isAddressHex(payerAddress) || !opId || !isBytes32Hex(opId) || !asset || !isAddressHex(asset) || !amount || !isUint256Decimal2(amount, true) || !paymentNonce || !isUint256Decimal2(paymentNonce, false) || !accessRecord || !isValidDataAccessRecord(accessRecord) || payerAddress.toLowerCase() !== accessRecord.accessor.toLowerCase() || opId.toLowerCase() !== accessRecord.recordId.toLowerCase() || !acceptAsset || acceptAsset.toLowerCase() !== asset.toLowerCase() || acceptAmount !== amount) {
|
|
34452
34327
|
return null;
|
|
34453
34328
|
}
|
|
34454
34329
|
return {
|
|
@@ -34533,7 +34408,7 @@ async function parsePersonalServerPaymentRequired(res, grantId) {
|
|
|
34533
34408
|
const acceptAmount = stringField2(accept, "amount");
|
|
34534
34409
|
const accessRecord2 = parseAccessRecord(accept.accessRecord);
|
|
34535
34410
|
const hasAccessRecord = accept.accessRecord !== void 0;
|
|
34536
|
-
if (!network || !payerAddress || !
|
|
34411
|
+
if (!network || !payerAddress || !isAddressHex(payerAddress) || !opId || !isBytes32Hex(opId) || !asset || !isAddressHex(asset) || !amount || !isUint256Decimal2(amount, true) || !paymentNonce || !isUint256Decimal2(paymentNonce, false) || !acceptAsset || acceptAsset.toLowerCase() !== asset.toLowerCase() || acceptAmount !== amount || hasAccessRecord && (!accessRecord2 || !isValidDataAccessRecord(accessRecord2) || accessRecord2.accessor.toLowerCase() !== payerAddress.toLowerCase()) || amount === "0" && !accessRecord2) {
|
|
34537
34412
|
throw new PersonalServerReadError(
|
|
34538
34413
|
"Personal Server grant payment challenge was untrusted or incomplete",
|
|
34539
34414
|
402
|
|
@@ -34662,7 +34537,6 @@ export {
|
|
|
34662
34537
|
DropboxStorage,
|
|
34663
34538
|
ECIESError,
|
|
34664
34539
|
ESCROW_DEPOSIT_ABI2 as ESCROW_DEPOSIT_ABI,
|
|
34665
|
-
EscrowWithdrawalLifecycleError,
|
|
34666
34540
|
ExpiredTokenError,
|
|
34667
34541
|
FEE_REGISTRY_ABI,
|
|
34668
34542
|
GENERIC_PAYMENT_TYPES,
|
|
@@ -34711,7 +34585,6 @@ export {
|
|
|
34711
34585
|
UserRejectedRequestError,
|
|
34712
34586
|
VanaError,
|
|
34713
34587
|
VanaStorage,
|
|
34714
|
-
WITHDRAW_AUTHORIZATION_TYPES,
|
|
34715
34588
|
assertValidPkceVerifier,
|
|
34716
34589
|
authorizeEscrowPayment,
|
|
34717
34590
|
authorizeGrantPayment,
|
|
@@ -34727,7 +34600,6 @@ export {
|
|
|
34727
34600
|
buildPersonalServerRegistrationTypedData,
|
|
34728
34601
|
buildSetDataPointStatusRequest,
|
|
34729
34602
|
buildWeb3SignedHeader,
|
|
34730
|
-
buildWithdrawAuthorizationTypedData,
|
|
34731
34603
|
builderRegistrationDomain,
|
|
34732
34604
|
chains,
|
|
34733
34605
|
clearContractCache,
|
|
@@ -34804,7 +34676,6 @@ export {
|
|
|
34804
34676
|
vanaMainnet2 as vanaMainnet,
|
|
34805
34677
|
verifyGrantRegistration,
|
|
34806
34678
|
verifyPkceChallenge,
|
|
34807
|
-
verifyWeb3Signed
|
|
34808
|
-
withdrawAuthorizationDomain
|
|
34679
|
+
verifyWeb3Signed
|
|
34809
34680
|
};
|
|
34810
34681
|
//# sourceMappingURL=index.node.js.map
|