@swype-org/react-sdk 0.1.22 → 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 +35 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -609,6 +609,18 @@ function normalizeSignature(sig) {
|
|
|
609
609
|
);
|
|
610
610
|
return normalizeSignature(innerBytes);
|
|
611
611
|
} catch {
|
|
612
|
+
try {
|
|
613
|
+
const [wrapper] = decodeAbiParameters(
|
|
614
|
+
[{
|
|
615
|
+
type: "tuple",
|
|
616
|
+
components: [{ type: "uint8" }, { type: "bytes" }]
|
|
617
|
+
}],
|
|
618
|
+
`0x${hex}`
|
|
619
|
+
);
|
|
620
|
+
return normalizeSignature(wrapper[1]);
|
|
621
|
+
} catch {
|
|
622
|
+
return `0x${hex}`;
|
|
623
|
+
}
|
|
612
624
|
}
|
|
613
625
|
}
|
|
614
626
|
throw new Error(
|
|
@@ -1019,6 +1031,7 @@ async function executeSignPermit2(action, wagmiConfig2, apiBaseUrl, sessionId) {
|
|
|
1019
1031
|
}
|
|
1020
1032
|
let typedData = action.metadata?.typedData;
|
|
1021
1033
|
const tokenSymbol = action.metadata?.tokenSymbol;
|
|
1034
|
+
const ownerIsSCA = action.metadata?.ownerIsSCA === true;
|
|
1022
1035
|
if (!typedData && sessionId) {
|
|
1023
1036
|
for (let i = 0; i < SIGN_PERMIT2_MAX_POLLS; i++) {
|
|
1024
1037
|
await new Promise((r) => setTimeout(r, SIGN_PERMIT2_POLL_MS));
|
|
@@ -1046,23 +1059,29 @@ async function executeSignPermit2(action, wagmiConfig2, apiBaseUrl, sessionId) {
|
|
|
1046
1059
|
message: parsed.message
|
|
1047
1060
|
});
|
|
1048
1061
|
const signature = normalizeSignature(rawSignature);
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
`
|
|
1062
|
+
if (ownerIsSCA) {
|
|
1063
|
+
console.info(
|
|
1064
|
+
`[swype-sdk][sign-permit2] Owner is SCA \u2014 skipping client-side ecrecover verification. Server will validate via EIP-1271.`
|
|
1065
|
+
);
|
|
1066
|
+
} else {
|
|
1067
|
+
const recoverInput = {
|
|
1068
|
+
domain: parsed.domain,
|
|
1069
|
+
types: parsed.types,
|
|
1070
|
+
primaryType: parsed.primaryType,
|
|
1071
|
+
message: parsed.message,
|
|
1072
|
+
signature
|
|
1073
|
+
};
|
|
1074
|
+
const recoveredSigner = await recoverTypedDataAddress(recoverInput);
|
|
1075
|
+
const expectedSigner = (expectedWallet ?? sender).toLowerCase();
|
|
1076
|
+
console.info(
|
|
1077
|
+
`[swype-sdk][sign-permit2] Signature recovered. recoveredSigner=${recoveredSigner}, expectedSigner=${expectedSigner}`
|
|
1065
1078
|
);
|
|
1079
|
+
if (recoveredSigner.toLowerCase() !== expectedSigner) {
|
|
1080
|
+
return actionError(
|
|
1081
|
+
action,
|
|
1082
|
+
`Wallet signed with ${recoveredSigner}, but source wallet is ${expectedWallet ?? sender}. Please switch to the source wallet in MetaMask and retry.`
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1066
1085
|
}
|
|
1067
1086
|
console.info(
|
|
1068
1087
|
`[swype-sdk][sign-permit2] Permit2 EIP-712 signature obtained. token=${tokenSymbol ?? "unknown"}`
|