@volr/react 0.1.71 → 0.1.72
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/index.cjs +41 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -18540,7 +18540,37 @@ function useVolr() {
|
|
|
18540
18540
|
setProvider
|
|
18541
18541
|
}
|
|
18542
18542
|
});
|
|
18543
|
-
})
|
|
18543
|
+
}),
|
|
18544
|
+
signMessage: async (message) => {
|
|
18545
|
+
if (!provider) {
|
|
18546
|
+
throw new Error(
|
|
18547
|
+
"No wallet provider available. Please log in with a Passkey or MPC wallet to sign messages."
|
|
18548
|
+
);
|
|
18549
|
+
}
|
|
18550
|
+
await provider.ensureSession({ interactive: true });
|
|
18551
|
+
const messageHash = hashMessage(
|
|
18552
|
+
typeof message === "string" ? message : { raw: message }
|
|
18553
|
+
);
|
|
18554
|
+
const hashBytes = new Uint8Array(32);
|
|
18555
|
+
const hex = messageHash.slice(2);
|
|
18556
|
+
for (let i = 0; i < 32; i++) {
|
|
18557
|
+
hashBytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
18558
|
+
}
|
|
18559
|
+
const sig = await provider.signMessage(hashBytes);
|
|
18560
|
+
const v = sig.yParity + 27;
|
|
18561
|
+
const rHex = Array.from(sig.r).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
18562
|
+
const sHex = Array.from(sig.s).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
18563
|
+
const vHex = v.toString(16).padStart(2, "0");
|
|
18564
|
+
return `0x${rHex}${sHex}${vHex}`;
|
|
18565
|
+
},
|
|
18566
|
+
signTypedData: async (typedData) => {
|
|
18567
|
+
if (!provider) {
|
|
18568
|
+
throw new Error(
|
|
18569
|
+
"No wallet provider available. Please log in with a Passkey or MPC wallet to sign typed data."
|
|
18570
|
+
);
|
|
18571
|
+
}
|
|
18572
|
+
return provider.signTypedData(typedData);
|
|
18573
|
+
}
|
|
18544
18574
|
};
|
|
18545
18575
|
},
|
|
18546
18576
|
[user, config, provider, precheck, relay, getRpcUrl, setProvider, client]
|
|
@@ -18633,7 +18663,12 @@ function useVolrLogin() {
|
|
|
18633
18663
|
async (provider) => {
|
|
18634
18664
|
if (typeof window !== "undefined") {
|
|
18635
18665
|
const baseUrl = apiBaseUrl.replace(/\/+$/, "");
|
|
18636
|
-
|
|
18666
|
+
const params = new URLSearchParams({
|
|
18667
|
+
projectApiKey: config.projectApiKey,
|
|
18668
|
+
callbackUrl: window.location.href
|
|
18669
|
+
// Return to current page after login
|
|
18670
|
+
});
|
|
18671
|
+
window.location.href = `${baseUrl}/auth/${provider}?${params.toString()}`;
|
|
18637
18672
|
}
|
|
18638
18673
|
},
|
|
18639
18674
|
[apiBaseUrl, config.projectApiKey]
|
|
@@ -18724,6 +18759,10 @@ function useVolrAuthCallback(options = {}) {
|
|
|
18724
18759
|
const authCode = searchParams.get("code");
|
|
18725
18760
|
const errorParam = searchParams.get("error");
|
|
18726
18761
|
const isNew = searchParams.get("isNewUser") === "true";
|
|
18762
|
+
const warning = searchParams.get("warning");
|
|
18763
|
+
if (warning) {
|
|
18764
|
+
console.warn(`[Volr] ${warning}`);
|
|
18765
|
+
}
|
|
18727
18766
|
if (errorParam) {
|
|
18728
18767
|
const errorMsg = `Authentication failed: ${errorParam.replace(/_/g, " ")}`;
|
|
18729
18768
|
setError(errorMsg);
|