@opendatalabs/vana-sdk 3.1.0 → 3.2.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/README.md +2 -1
- package/dist/account/personal-server-lite-owner-binding.cjs +81 -0
- package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -0
- package/dist/account/personal-server-lite-owner-binding.d.ts +30 -0
- package/dist/account/personal-server-lite-owner-binding.js +59 -0
- package/dist/account/personal-server-lite-owner-binding.js.map +1 -0
- package/dist/account/personal-server-lite-owner-binding.test.d.ts +1 -0
- package/dist/account/personal-server-registration.cjs +263 -0
- package/dist/account/personal-server-registration.cjs.map +1 -0
- package/dist/account/personal-server-registration.d.ts +66 -0
- package/dist/account/personal-server-registration.js +240 -0
- package/dist/account/personal-server-registration.js.map +1 -0
- package/dist/account/personal-server-registration.test.d.ts +1 -0
- package/dist/auth/errors.js +1 -1
- package/dist/auth/oauth-client.js +2 -2
- package/dist/auth/web3-signed-builder.js +1 -1
- package/dist/auth/web3-signed.js +3 -3
- package/dist/browser.js +1 -1
- package/dist/chains/definitions.js +1 -1
- package/dist/chains/index.js +1 -1
- package/dist/chains.browser.js +1 -1
- package/dist/chains.js +1 -1
- package/dist/chains.node.js +1 -1
- package/dist/contracts/contractController.js +4 -4
- package/dist/core/client.js +1 -1
- package/dist/crypto/ecies/base.js +3 -3
- package/dist/crypto/ecies/browser.js +1 -1
- package/dist/crypto/ecies/index.js +1 -1
- package/dist/crypto/ecies/interface.js +1 -1
- package/dist/crypto/ecies/node.js +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.js +1 -1
- package/dist/generated/abi/index.js +26 -26
- package/dist/index.browser.d.ts +4 -0
- package/dist/index.browser.js +447 -3
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +464 -5
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +4 -0
- package/dist/index.node.js +447 -3
- package/dist/index.node.js.map +4 -4
- package/dist/node.js +1 -1
- package/dist/platform/browser-only.js +1 -1
- package/dist/platform/browser-safe.js +1 -1
- package/dist/platform/browser.js +6 -6
- package/dist/platform/index.js +4 -4
- package/dist/platform/node.js +8 -8
- package/dist/platform/utils.js +2 -2
- package/dist/platform.browser.js +3 -3
- package/dist/platform.js +4 -4
- package/dist/platform.node.js +4 -4
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +1 -1
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/grants.js +1 -1
- package/dist/protocol/personal-server-lite-owner-binding.cjs +93 -0
- package/dist/protocol/personal-server-lite-owner-binding.cjs.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.d.ts +44 -0
- package/dist/protocol/personal-server-lite-owner-binding.js +65 -0
- package/dist/protocol/personal-server-lite-owner-binding.js.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +1 -0
- package/dist/protocol/personal-server-registration.cjs +122 -0
- package/dist/protocol/personal-server-registration.cjs.map +1 -0
- package/dist/protocol/personal-server-registration.d.ts +62 -0
- package/dist/protocol/personal-server-registration.js +97 -0
- package/dist/protocol/personal-server-registration.js.map +1 -0
- package/dist/protocol/personal-server-registration.test.d.ts +1 -0
- package/dist/storage/default.js +1 -1
- package/dist/storage/index.js +10 -10
- package/dist/storage/manager.js +1 -1
- package/dist/storage/providers/callback-storage.js +1 -1
- package/dist/storage/providers/dropbox.js +1 -1
- package/dist/storage/providers/google-drive.js +1 -1
- package/dist/storage/providers/ipfs.js +2 -2
- package/dist/storage/providers/pinata.js +1 -1
- package/dist/storage/providers/r2.js +1 -1
- package/dist/storage/providers/vana-storage.js +2 -2
- package/dist/types/index.js +2 -2
- package/dist/types.js +1 -1
- package/package.json +4 -2
package/dist/index.browser.js
CHANGED
|
@@ -31958,6 +31958,431 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
31958
31958
|
]
|
|
31959
31959
|
};
|
|
31960
31960
|
|
|
31961
|
+
// src/protocol/personal-server-registration.ts
|
|
31962
|
+
import {
|
|
31963
|
+
isAddress
|
|
31964
|
+
} from "viem";
|
|
31965
|
+
var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;
|
|
31966
|
+
var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c";
|
|
31967
|
+
function assertAddress(value, name) {
|
|
31968
|
+
if (!isAddress(value)) {
|
|
31969
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
31970
|
+
}
|
|
31971
|
+
}
|
|
31972
|
+
function getAccountAddress(account) {
|
|
31973
|
+
if (!account) {
|
|
31974
|
+
return void 0;
|
|
31975
|
+
}
|
|
31976
|
+
return typeof account === "string" ? account : account.address;
|
|
31977
|
+
}
|
|
31978
|
+
function isPersonalServerRegistrationSigner(source) {
|
|
31979
|
+
return "address" in source && typeof source.signTypedData === "function";
|
|
31980
|
+
}
|
|
31981
|
+
function createViemPersonalServerRegistrationSigner(source, options = {}) {
|
|
31982
|
+
if (isPersonalServerRegistrationSigner(source)) {
|
|
31983
|
+
return source;
|
|
31984
|
+
}
|
|
31985
|
+
const accountAddress = getAccountAddress(options.account) ?? getAccountAddress(source.account);
|
|
31986
|
+
if (accountAddress) {
|
|
31987
|
+
return {
|
|
31988
|
+
address: accountAddress,
|
|
31989
|
+
signTypedData: (typedData) => source.signTypedData({
|
|
31990
|
+
...typedData,
|
|
31991
|
+
account: options.account ?? source.account ?? accountAddress
|
|
31992
|
+
})
|
|
31993
|
+
};
|
|
31994
|
+
}
|
|
31995
|
+
throw new Error(
|
|
31996
|
+
"Viem wallet client requires an account option or account property"
|
|
31997
|
+
);
|
|
31998
|
+
}
|
|
31999
|
+
function personalServerRegistrationDomain(input = {}) {
|
|
32000
|
+
if (input.config) {
|
|
32001
|
+
return serverRegistrationDomain(input.config);
|
|
32002
|
+
}
|
|
32003
|
+
const verifyingContract = input.verifyingContract ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;
|
|
32004
|
+
assertAddress(verifyingContract, "verifyingContract");
|
|
32005
|
+
return {
|
|
32006
|
+
name: "Vana Data Portability",
|
|
32007
|
+
version: "1",
|
|
32008
|
+
chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
32009
|
+
verifyingContract
|
|
32010
|
+
};
|
|
32011
|
+
}
|
|
32012
|
+
function buildPersonalServerRegistrationTypedData(input) {
|
|
32013
|
+
assertAddress(input.ownerAddress, "ownerAddress");
|
|
32014
|
+
assertAddress(input.serverAddress, "serverAddress");
|
|
32015
|
+
return {
|
|
32016
|
+
domain: personalServerRegistrationDomain(input),
|
|
32017
|
+
types: SERVER_REGISTRATION_TYPES,
|
|
32018
|
+
primaryType: "ServerRegistration",
|
|
32019
|
+
message: {
|
|
32020
|
+
ownerAddress: input.ownerAddress,
|
|
32021
|
+
serverAddress: input.serverAddress,
|
|
32022
|
+
publicKey: input.serverPublicKey,
|
|
32023
|
+
serverUrl: input.serverUrl
|
|
32024
|
+
}
|
|
32025
|
+
};
|
|
32026
|
+
}
|
|
32027
|
+
async function buildPersonalServerRegistrationSignature(input) {
|
|
32028
|
+
const typedData = buildPersonalServerRegistrationTypedData({
|
|
32029
|
+
ownerAddress: input.signer.address,
|
|
32030
|
+
serverAddress: input.serverAddress,
|
|
32031
|
+
serverPublicKey: input.serverPublicKey,
|
|
32032
|
+
serverUrl: input.serverUrl,
|
|
32033
|
+
config: input.config,
|
|
32034
|
+
chainId: input.chainId,
|
|
32035
|
+
verifyingContract: input.verifyingContract
|
|
32036
|
+
});
|
|
32037
|
+
const signature = await input.signer.signTypedData(typedData);
|
|
32038
|
+
return {
|
|
32039
|
+
signature,
|
|
32040
|
+
signerAddress: input.signer.address,
|
|
32041
|
+
typedData
|
|
32042
|
+
};
|
|
32043
|
+
}
|
|
32044
|
+
var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
|
|
32045
|
+
|
|
32046
|
+
// src/protocol/personal-server-lite-owner-binding.ts
|
|
32047
|
+
import {
|
|
32048
|
+
isAddress as isAddress2
|
|
32049
|
+
} from "viem";
|
|
32050
|
+
var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.account.v1";
|
|
32051
|
+
var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
32052
|
+
var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
32053
|
+
function assertAddress2(value, name) {
|
|
32054
|
+
if (!isAddress2(value)) {
|
|
32055
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
32056
|
+
}
|
|
32057
|
+
}
|
|
32058
|
+
function getAccountAddress2(account) {
|
|
32059
|
+
if (!account) {
|
|
32060
|
+
return void 0;
|
|
32061
|
+
}
|
|
32062
|
+
return typeof account === "string" ? account : account.address;
|
|
32063
|
+
}
|
|
32064
|
+
function isPersonalServerLiteOwnerBindingSigner(source) {
|
|
32065
|
+
return "address" in source && typeof source.signMessage === "function";
|
|
32066
|
+
}
|
|
32067
|
+
function buildPersonalServerLiteOwnerBindingMessage(ownerAddress) {
|
|
32068
|
+
assertAddress2(ownerAddress, "ownerAddress");
|
|
32069
|
+
return `${PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${ownerAddress.toLowerCase()}`;
|
|
32070
|
+
}
|
|
32071
|
+
function createViemPersonalServerLiteOwnerBindingSigner(source, options = {}) {
|
|
32072
|
+
if (isPersonalServerLiteOwnerBindingSigner(source)) {
|
|
32073
|
+
return source;
|
|
32074
|
+
}
|
|
32075
|
+
const accountAddress = getAccountAddress2(options.account) ?? getAccountAddress2(source.account);
|
|
32076
|
+
if (accountAddress) {
|
|
32077
|
+
return {
|
|
32078
|
+
address: accountAddress,
|
|
32079
|
+
signMessage: ({ message }) => source.signMessage({
|
|
32080
|
+
account: options.account ?? source.account ?? accountAddress,
|
|
32081
|
+
message
|
|
32082
|
+
})
|
|
32083
|
+
};
|
|
32084
|
+
}
|
|
32085
|
+
throw new Error(
|
|
32086
|
+
"Viem wallet client requires an account option or account property"
|
|
32087
|
+
);
|
|
32088
|
+
}
|
|
32089
|
+
async function buildPersonalServerLiteOwnerBindingSignature(input) {
|
|
32090
|
+
const message = buildPersonalServerLiteOwnerBindingMessage(
|
|
32091
|
+
input.signer.address
|
|
32092
|
+
);
|
|
32093
|
+
const signature = await input.signer.signMessage({ message });
|
|
32094
|
+
return {
|
|
32095
|
+
signature,
|
|
32096
|
+
signerAddress: input.signer.address,
|
|
32097
|
+
message,
|
|
32098
|
+
purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE
|
|
32099
|
+
};
|
|
32100
|
+
}
|
|
32101
|
+
var signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
|
|
32102
|
+
|
|
32103
|
+
// src/account/personal-server-registration.ts
|
|
32104
|
+
import { isAddress as isAddress3 } from "viem";
|
|
32105
|
+
var ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT = "personal_server.server_registration.v1";
|
|
32106
|
+
var AccountPersonalServerRegistrationError = class extends Error {
|
|
32107
|
+
status;
|
|
32108
|
+
code;
|
|
32109
|
+
details;
|
|
32110
|
+
constructor(input) {
|
|
32111
|
+
super(input.message);
|
|
32112
|
+
this.name = "AccountPersonalServerRegistrationError";
|
|
32113
|
+
this.status = input.status;
|
|
32114
|
+
this.code = input.code;
|
|
32115
|
+
this.details = input.details;
|
|
32116
|
+
}
|
|
32117
|
+
};
|
|
32118
|
+
var DEFAULT_ACCOUNT_PS_REGISTRATION_PATH = "/api/v1/intents/personal-server-registration/sign";
|
|
32119
|
+
function trimTrailingSlash(value) {
|
|
32120
|
+
return value.replace(/\/+$/, "");
|
|
32121
|
+
}
|
|
32122
|
+
function assertAddress3(value, name) {
|
|
32123
|
+
if (!isAddress3(value)) {
|
|
32124
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
32125
|
+
}
|
|
32126
|
+
}
|
|
32127
|
+
async function parseAccountResponse(response) {
|
|
32128
|
+
const body = await response.json().catch(() => void 0);
|
|
32129
|
+
if (!response.ok) {
|
|
32130
|
+
throw new AccountPersonalServerRegistrationError({
|
|
32131
|
+
status: response.status,
|
|
32132
|
+
code: accountErrorCode(body),
|
|
32133
|
+
message: accountErrorMessage(response.status, body),
|
|
32134
|
+
details: body
|
|
32135
|
+
});
|
|
32136
|
+
}
|
|
32137
|
+
return body;
|
|
32138
|
+
}
|
|
32139
|
+
function accountErrorMessage(status, body) {
|
|
32140
|
+
const nestedMessage = nestedAccountErrorField(body, "message");
|
|
32141
|
+
if (nestedMessage) {
|
|
32142
|
+
return nestedMessage;
|
|
32143
|
+
}
|
|
32144
|
+
if (isRecord(body) && typeof body.message === "string") {
|
|
32145
|
+
return body.message;
|
|
32146
|
+
}
|
|
32147
|
+
const code = accountErrorCode(body);
|
|
32148
|
+
if (code) {
|
|
32149
|
+
return `Account PS registration signing failed: ${code}`;
|
|
32150
|
+
}
|
|
32151
|
+
return `Account PS registration signing failed: ${status}`;
|
|
32152
|
+
}
|
|
32153
|
+
function accountErrorCode(body) {
|
|
32154
|
+
const nestedCode = nestedAccountErrorField(body, "code");
|
|
32155
|
+
if (nestedCode) {
|
|
32156
|
+
return nestedCode;
|
|
32157
|
+
}
|
|
32158
|
+
if (isRecord(body)) {
|
|
32159
|
+
if (typeof body.code === "string") {
|
|
32160
|
+
return body.code;
|
|
32161
|
+
}
|
|
32162
|
+
if (typeof body.error === "string") {
|
|
32163
|
+
return body.error;
|
|
32164
|
+
}
|
|
32165
|
+
}
|
|
32166
|
+
return void 0;
|
|
32167
|
+
}
|
|
32168
|
+
function nestedAccountErrorField(body, field) {
|
|
32169
|
+
if (!isRecord(body) || !isRecord(body.error)) {
|
|
32170
|
+
return void 0;
|
|
32171
|
+
}
|
|
32172
|
+
const value = body.error[field];
|
|
32173
|
+
return typeof value === "string" ? value : void 0;
|
|
32174
|
+
}
|
|
32175
|
+
function isRecord(value) {
|
|
32176
|
+
return typeof value === "object" && value !== null;
|
|
32177
|
+
}
|
|
32178
|
+
function normalizeAccountResponse(response) {
|
|
32179
|
+
return {
|
|
32180
|
+
...response,
|
|
32181
|
+
status: response.status === "fallback_required" ? "confirmation_required" : response.status,
|
|
32182
|
+
signerAddress: response.signerAddress ?? response.signer?.address,
|
|
32183
|
+
typedData: response.typedData ?? response.typed_data
|
|
32184
|
+
};
|
|
32185
|
+
}
|
|
32186
|
+
function buildSignedResult(response, request) {
|
|
32187
|
+
assertAddress3(response.signerAddress, "signerAddress");
|
|
32188
|
+
if (response.typedData) {
|
|
32189
|
+
assertTypedDataMatchesRequest(
|
|
32190
|
+
response.typedData,
|
|
32191
|
+
request,
|
|
32192
|
+
response.signerAddress
|
|
32193
|
+
);
|
|
32194
|
+
}
|
|
32195
|
+
return {
|
|
32196
|
+
signature: response.signature,
|
|
32197
|
+
signerAddress: response.signerAddress,
|
|
32198
|
+
typedData: response.typedData ?? buildPersonalServerRegistrationTypedData({
|
|
32199
|
+
ownerAddress: response.signerAddress,
|
|
32200
|
+
...request
|
|
32201
|
+
}),
|
|
32202
|
+
intent: ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT
|
|
32203
|
+
};
|
|
32204
|
+
}
|
|
32205
|
+
function assertTypedDataMatchesRequest(typedData, request, expectedSignerAddress) {
|
|
32206
|
+
assertAddress3(
|
|
32207
|
+
typedData.message.ownerAddress,
|
|
32208
|
+
"typedData.message.ownerAddress"
|
|
32209
|
+
);
|
|
32210
|
+
assertAddress3(
|
|
32211
|
+
typedData.message.serverAddress,
|
|
32212
|
+
"typedData.message.serverAddress"
|
|
32213
|
+
);
|
|
32214
|
+
if (expectedSignerAddress && !sameAddress(typedData.message.ownerAddress, expectedSignerAddress)) {
|
|
32215
|
+
throw new Error(
|
|
32216
|
+
"Account typedData ownerAddress must match the expected signer address"
|
|
32217
|
+
);
|
|
32218
|
+
}
|
|
32219
|
+
if (!sameAddress(typedData.message.serverAddress, request.serverAddress)) {
|
|
32220
|
+
throw new Error(
|
|
32221
|
+
"Account typedData serverAddress must match the requested serverAddress"
|
|
32222
|
+
);
|
|
32223
|
+
}
|
|
32224
|
+
if (typedData.message.publicKey !== request.serverPublicKey) {
|
|
32225
|
+
throw new Error(
|
|
32226
|
+
"Account typedData publicKey must match the requested serverPublicKey"
|
|
32227
|
+
);
|
|
32228
|
+
}
|
|
32229
|
+
if (typedData.message.serverUrl !== request.serverUrl) {
|
|
32230
|
+
throw new Error(
|
|
32231
|
+
"Account typedData serverUrl must match the requested serverUrl"
|
|
32232
|
+
);
|
|
32233
|
+
}
|
|
32234
|
+
if (typedData.primaryType !== "ServerRegistration") {
|
|
32235
|
+
throw new Error("Account typedData primaryType must be ServerRegistration");
|
|
32236
|
+
}
|
|
32237
|
+
if (JSON.stringify(typedData.types) !== JSON.stringify(SERVER_REGISTRATION_TYPES)) {
|
|
32238
|
+
throw new Error("Account typedData types must be ServerRegistration types");
|
|
32239
|
+
}
|
|
32240
|
+
const expectedDomain = personalServerRegistrationDomain({
|
|
32241
|
+
config: request.config,
|
|
32242
|
+
chainId: request.chainId,
|
|
32243
|
+
verifyingContract: request.verifyingContract
|
|
32244
|
+
});
|
|
32245
|
+
if (!domainsEqual(typedData.domain, expectedDomain)) {
|
|
32246
|
+
throw new Error("Account typedData domain must match the requested domain");
|
|
32247
|
+
}
|
|
32248
|
+
}
|
|
32249
|
+
function sameAddress(a, b) {
|
|
32250
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
32251
|
+
}
|
|
32252
|
+
function domainsEqual(a, b) {
|
|
32253
|
+
if (!a || !b) {
|
|
32254
|
+
return false;
|
|
32255
|
+
}
|
|
32256
|
+
return a.name === b.name && a.version === b.version && Number(a.chainId) === Number(b.chainId) && String(a.verifyingContract ?? "").toLowerCase() === String(b.verifyingContract ?? "").toLowerCase() && a.salt === b.salt;
|
|
32257
|
+
}
|
|
32258
|
+
async function signPersonalServerRegistrationWithAccount(config, request) {
|
|
32259
|
+
assertAddress3(request.serverAddress, "serverAddress");
|
|
32260
|
+
const fetchImpl = config.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
32261
|
+
const endpoint = new URL(
|
|
32262
|
+
config.endpointPath ?? DEFAULT_ACCOUNT_PS_REGISTRATION_PATH,
|
|
32263
|
+
`${trimTrailingSlash(config.accountOrigin)}/`
|
|
32264
|
+
);
|
|
32265
|
+
const response = await fetchImpl(endpoint, {
|
|
32266
|
+
method: "POST",
|
|
32267
|
+
headers: { "content-type": "application/json" },
|
|
32268
|
+
credentials: "include",
|
|
32269
|
+
body: JSON.stringify({
|
|
32270
|
+
intent: ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
32271
|
+
serverAddress: request.serverAddress,
|
|
32272
|
+
serverPublicKey: request.serverPublicKey,
|
|
32273
|
+
serverUrl: request.serverUrl,
|
|
32274
|
+
config: request.config,
|
|
32275
|
+
chainId: request.chainId,
|
|
32276
|
+
verifyingContract: request.verifyingContract
|
|
32277
|
+
})
|
|
32278
|
+
});
|
|
32279
|
+
const body = normalizeAccountResponse(await parseAccountResponse(response));
|
|
32280
|
+
if (body.status === "signed") {
|
|
32281
|
+
if (!body.signature || !body.signerAddress) {
|
|
32282
|
+
throw new Error(
|
|
32283
|
+
"Account signed response must include signature and signerAddress"
|
|
32284
|
+
);
|
|
32285
|
+
}
|
|
32286
|
+
return {
|
|
32287
|
+
status: "signed",
|
|
32288
|
+
result: buildSignedResult(
|
|
32289
|
+
{
|
|
32290
|
+
signature: body.signature,
|
|
32291
|
+
signerAddress: body.signerAddress,
|
|
32292
|
+
typedData: body.typedData
|
|
32293
|
+
},
|
|
32294
|
+
request
|
|
32295
|
+
)
|
|
32296
|
+
};
|
|
32297
|
+
}
|
|
32298
|
+
if (body.status === "confirmation_required") {
|
|
32299
|
+
if (!body.typedData) {
|
|
32300
|
+
throw new Error(
|
|
32301
|
+
"Account confirmation_required response must include typedData"
|
|
32302
|
+
);
|
|
32303
|
+
}
|
|
32304
|
+
assertTypedDataMatchesRequest(body.typedData, request, body.signerAddress);
|
|
32305
|
+
if (!config.fallbackSigner) {
|
|
32306
|
+
return {
|
|
32307
|
+
status: "confirmation_required",
|
|
32308
|
+
typedData: body.typedData,
|
|
32309
|
+
signerAddress: body.signerAddress
|
|
32310
|
+
};
|
|
32311
|
+
}
|
|
32312
|
+
assertTypedDataMatchesRequest(
|
|
32313
|
+
body.typedData,
|
|
32314
|
+
request,
|
|
32315
|
+
config.fallbackSigner.address
|
|
32316
|
+
);
|
|
32317
|
+
const signature = await config.fallbackSigner.signTypedData(body.typedData);
|
|
32318
|
+
return {
|
|
32319
|
+
status: "fallback_signed",
|
|
32320
|
+
accountStatus: "confirmation_required",
|
|
32321
|
+
result: {
|
|
32322
|
+
signature,
|
|
32323
|
+
signerAddress: config.fallbackSigner.address,
|
|
32324
|
+
typedData: body.typedData,
|
|
32325
|
+
intent: ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT
|
|
32326
|
+
}
|
|
32327
|
+
};
|
|
32328
|
+
}
|
|
32329
|
+
throw new Error(
|
|
32330
|
+
`Unsupported Account PS registration signing status: ${String(body.status)}`
|
|
32331
|
+
);
|
|
32332
|
+
}
|
|
32333
|
+
|
|
32334
|
+
// src/account/personal-server-lite-owner-binding.ts
|
|
32335
|
+
var AccountPersonalServerLiteOwnerBindingError = class extends Error {
|
|
32336
|
+
code;
|
|
32337
|
+
details;
|
|
32338
|
+
constructor(input) {
|
|
32339
|
+
super(input.message);
|
|
32340
|
+
this.name = "AccountPersonalServerLiteOwnerBindingError";
|
|
32341
|
+
this.code = input.code;
|
|
32342
|
+
this.details = input.details;
|
|
32343
|
+
}
|
|
32344
|
+
};
|
|
32345
|
+
async function signPersonalServerLiteOwnerBindingWithAccountClient(config) {
|
|
32346
|
+
let address;
|
|
32347
|
+
try {
|
|
32348
|
+
address = await config.client.getAddress();
|
|
32349
|
+
} catch (error) {
|
|
32350
|
+
throw accountOwnerBindingError(error);
|
|
32351
|
+
}
|
|
32352
|
+
if (!address) {
|
|
32353
|
+
throw new AccountPersonalServerLiteOwnerBindingError({
|
|
32354
|
+
message: "Account did not return a wallet address",
|
|
32355
|
+
code: "account_address_required"
|
|
32356
|
+
});
|
|
32357
|
+
}
|
|
32358
|
+
const message = buildPersonalServerLiteOwnerBindingMessage(address);
|
|
32359
|
+
let signature;
|
|
32360
|
+
try {
|
|
32361
|
+
signature = await config.client.signMessage({ message });
|
|
32362
|
+
} catch (error) {
|
|
32363
|
+
throw accountOwnerBindingError(error);
|
|
32364
|
+
}
|
|
32365
|
+
return {
|
|
32366
|
+
signature,
|
|
32367
|
+
signerAddress: address,
|
|
32368
|
+
message,
|
|
32369
|
+
purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE
|
|
32370
|
+
};
|
|
32371
|
+
}
|
|
32372
|
+
function accountOwnerBindingError(error) {
|
|
32373
|
+
if (error instanceof AccountPersonalServerLiteOwnerBindingError) {
|
|
32374
|
+
return error;
|
|
32375
|
+
}
|
|
32376
|
+
const rpcError = error;
|
|
32377
|
+
const code = rpcError?.code;
|
|
32378
|
+
const message = typeof rpcError?.message === "string" && rpcError.message.length > 0 ? rpcError.message : "Account PS Lite owner-binding signature failed";
|
|
32379
|
+
return new AccountPersonalServerLiteOwnerBindingError({
|
|
32380
|
+
message,
|
|
32381
|
+
code,
|
|
32382
|
+
details: error
|
|
32383
|
+
});
|
|
32384
|
+
}
|
|
32385
|
+
|
|
31961
32386
|
// src/protocol/grants.ts
|
|
31962
32387
|
import { verifyTypedData } from "viem";
|
|
31963
32388
|
function isHexString(value) {
|
|
@@ -32368,7 +32793,7 @@ var KNOWN_CODES = /* @__PURE__ */ new Set([
|
|
|
32368
32793
|
"server_not_configured",
|
|
32369
32794
|
"content_too_large"
|
|
32370
32795
|
]);
|
|
32371
|
-
function
|
|
32796
|
+
function isRecord2(value) {
|
|
32372
32797
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
32373
32798
|
}
|
|
32374
32799
|
function normalizeCode(value) {
|
|
@@ -32379,10 +32804,10 @@ function normalizeCode(value) {
|
|
|
32379
32804
|
return KNOWN_CODES.has(code) ? code : null;
|
|
32380
32805
|
}
|
|
32381
32806
|
function extractPSErrorBody(body) {
|
|
32382
|
-
if (!
|
|
32807
|
+
if (!isRecord2(body)) {
|
|
32383
32808
|
return null;
|
|
32384
32809
|
}
|
|
32385
|
-
const nested =
|
|
32810
|
+
const nested = isRecord2(body.error) ? body.error : null;
|
|
32386
32811
|
const code = normalizeCode(
|
|
32387
32812
|
nested?.errorCode ?? nested?.code ?? body.errorCode ?? body.code
|
|
32388
32813
|
);
|
|
@@ -32406,6 +32831,9 @@ async function parsePSError(response) {
|
|
|
32406
32831
|
return errorBody ? new PSError(errorBody.code, errorBody.message) : null;
|
|
32407
32832
|
}
|
|
32408
32833
|
export {
|
|
32834
|
+
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
32835
|
+
AccountPersonalServerLiteOwnerBindingError,
|
|
32836
|
+
AccountPersonalServerRegistrationError,
|
|
32409
32837
|
BUILDER_REGISTRATION_TYPES,
|
|
32410
32838
|
BlockchainError,
|
|
32411
32839
|
BrowserECIESUint8Provider as BrowserECIESProvider,
|
|
@@ -32432,6 +32860,11 @@ export {
|
|
|
32432
32860
|
NetworkError,
|
|
32433
32861
|
NonceError,
|
|
32434
32862
|
OAuthClient,
|
|
32863
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
32864
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
32865
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
32866
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
32867
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT,
|
|
32435
32868
|
PKCE_CHALLENGE_PATTERN,
|
|
32436
32869
|
PKCE_VERIFIER_PATTERN,
|
|
32437
32870
|
PSError,
|
|
@@ -32453,6 +32886,10 @@ export {
|
|
|
32453
32886
|
VanaError,
|
|
32454
32887
|
VanaStorage,
|
|
32455
32888
|
assertValidPkceVerifier,
|
|
32889
|
+
buildPersonalServerLiteOwnerBindingMessage,
|
|
32890
|
+
buildPersonalServerLiteOwnerBindingSignature,
|
|
32891
|
+
buildPersonalServerRegistrationSignature,
|
|
32892
|
+
buildPersonalServerRegistrationTypedData,
|
|
32456
32893
|
buildWeb3SignedHeader,
|
|
32457
32894
|
builderRegistrationDomain,
|
|
32458
32895
|
chains,
|
|
@@ -32465,6 +32902,8 @@ export {
|
|
|
32465
32902
|
createGatewayClient,
|
|
32466
32903
|
createPlatformAdapterSafe,
|
|
32467
32904
|
createVanaStorageProvider,
|
|
32905
|
+
createViemPersonalServerLiteOwnerBindingSigner,
|
|
32906
|
+
createViemPersonalServerRegistrationSigner,
|
|
32468
32907
|
decryptWithPassword,
|
|
32469
32908
|
deriveMasterKey,
|
|
32470
32909
|
deriveScopeKey,
|
|
@@ -32494,12 +32933,17 @@ export {
|
|
|
32494
32933
|
parsePSError,
|
|
32495
32934
|
parseScope,
|
|
32496
32935
|
parseWeb3SignedHeader,
|
|
32936
|
+
personalServerRegistrationDomain,
|
|
32497
32937
|
recoverServerOwner,
|
|
32938
|
+
registerPersonalServerSignature,
|
|
32498
32939
|
scopeCoveredByGrant,
|
|
32499
32940
|
scopeMatchesPattern,
|
|
32500
32941
|
scopeToPathSegments,
|
|
32501
32942
|
serializeECIES,
|
|
32502
32943
|
serverRegistrationDomain,
|
|
32944
|
+
signPersonalServerLiteOwnerBinding,
|
|
32945
|
+
signPersonalServerLiteOwnerBindingWithAccountClient,
|
|
32946
|
+
signPersonalServerRegistrationWithAccount,
|
|
32503
32947
|
vanaMainnet2 as vanaMainnet,
|
|
32504
32948
|
verifyGrantRegistration,
|
|
32505
32949
|
verifyPkceChallenge,
|