@chipi-stack/core 0.6.1 → 0.6.2
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 +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -769,12 +769,24 @@ function generateNonce() {
|
|
|
769
769
|
}
|
|
770
770
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
771
771
|
}
|
|
772
|
+
function feltEquals(value, expected) {
|
|
773
|
+
try {
|
|
774
|
+
return BigInt(value) === expected;
|
|
775
|
+
} catch {
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
772
779
|
function normalizeX402Signature(signature) {
|
|
773
780
|
if (Array.isArray(signature)) {
|
|
774
|
-
if (signature.length
|
|
775
|
-
|
|
781
|
+
if (signature.length === 2) {
|
|
782
|
+
return { r: String(signature[0]), s: String(signature[1]) };
|
|
783
|
+
}
|
|
784
|
+
if (signature.length === 5 && feltEquals(signature[0], 1n) && feltEquals(signature[1], 0n)) {
|
|
785
|
+
return { r: String(signature[3]), s: String(signature[4]) };
|
|
776
786
|
}
|
|
777
|
-
|
|
787
|
+
throw new Error(
|
|
788
|
+
`Unsupported ${signature.length}-felt signature: x402 needs one Starknet key, signed as [r, s] (OpenZeppelin, Braavos) or [1, 0, pubkey, r, s] (Argent / Ready).`
|
|
789
|
+
);
|
|
778
790
|
}
|
|
779
791
|
if (signature && typeof signature === "object" && "r" in signature && "s" in signature) {
|
|
780
792
|
const sig = signature;
|