@swype-org/react-sdk 0.1.23 → 0.1.24
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 +24 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -622,6 +622,7 @@ function normalizeSignature(sig) {
|
|
|
622
622
|
);
|
|
623
623
|
return normalizeSignature(wrapper[1]);
|
|
624
624
|
} catch {
|
|
625
|
+
return `0x${hex}`;
|
|
625
626
|
}
|
|
626
627
|
}
|
|
627
628
|
}
|
|
@@ -1033,6 +1034,7 @@ async function executeSignPermit2(action, wagmiConfig2, apiBaseUrl, sessionId) {
|
|
|
1033
1034
|
}
|
|
1034
1035
|
let typedData = action.metadata?.typedData;
|
|
1035
1036
|
const tokenSymbol = action.metadata?.tokenSymbol;
|
|
1037
|
+
const ownerIsSCA = action.metadata?.ownerIsSCA === true;
|
|
1036
1038
|
if (!typedData && sessionId) {
|
|
1037
1039
|
for (let i = 0; i < SIGN_PERMIT2_MAX_POLLS; i++) {
|
|
1038
1040
|
await new Promise((r) => setTimeout(r, SIGN_PERMIT2_POLL_MS));
|
|
@@ -1060,23 +1062,29 @@ async function executeSignPermit2(action, wagmiConfig2, apiBaseUrl, sessionId) {
|
|
|
1060
1062
|
message: parsed.message
|
|
1061
1063
|
});
|
|
1062
1064
|
const signature = normalizeSignature(rawSignature);
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
`
|
|
1065
|
+
if (ownerIsSCA) {
|
|
1066
|
+
console.info(
|
|
1067
|
+
`[swype-sdk][sign-permit2] Owner is SCA \u2014 skipping client-side ecrecover verification. Server will validate via EIP-1271.`
|
|
1068
|
+
);
|
|
1069
|
+
} else {
|
|
1070
|
+
const recoverInput = {
|
|
1071
|
+
domain: parsed.domain,
|
|
1072
|
+
types: parsed.types,
|
|
1073
|
+
primaryType: parsed.primaryType,
|
|
1074
|
+
message: parsed.message,
|
|
1075
|
+
signature
|
|
1076
|
+
};
|
|
1077
|
+
const recoveredSigner = await viem.recoverTypedDataAddress(recoverInput);
|
|
1078
|
+
const expectedSigner = (expectedWallet ?? sender).toLowerCase();
|
|
1079
|
+
console.info(
|
|
1080
|
+
`[swype-sdk][sign-permit2] Signature recovered. recoveredSigner=${recoveredSigner}, expectedSigner=${expectedSigner}`
|
|
1079
1081
|
);
|
|
1082
|
+
if (recoveredSigner.toLowerCase() !== expectedSigner) {
|
|
1083
|
+
return actionError(
|
|
1084
|
+
action,
|
|
1085
|
+
`Wallet signed with ${recoveredSigner}, but source wallet is ${expectedWallet ?? sender}. Please switch to the source wallet in MetaMask and retry.`
|
|
1086
|
+
);
|
|
1087
|
+
}
|
|
1080
1088
|
}
|
|
1081
1089
|
console.info(
|
|
1082
1090
|
`[swype-sdk][sign-permit2] Permit2 EIP-712 signature obtained. token=${tokenSymbol ?? "unknown"}`
|