@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.cjs
CHANGED
|
@@ -612,6 +612,18 @@ function normalizeSignature(sig) {
|
|
|
612
612
|
);
|
|
613
613
|
return normalizeSignature(innerBytes);
|
|
614
614
|
} catch {
|
|
615
|
+
try {
|
|
616
|
+
const [wrapper] = viem.decodeAbiParameters(
|
|
617
|
+
[{
|
|
618
|
+
type: "tuple",
|
|
619
|
+
components: [{ type: "uint8" }, { type: "bytes" }]
|
|
620
|
+
}],
|
|
621
|
+
`0x${hex}`
|
|
622
|
+
);
|
|
623
|
+
return normalizeSignature(wrapper[1]);
|
|
624
|
+
} catch {
|
|
625
|
+
return `0x${hex}`;
|
|
626
|
+
}
|
|
615
627
|
}
|
|
616
628
|
}
|
|
617
629
|
throw new Error(
|
|
@@ -1022,6 +1034,7 @@ async function executeSignPermit2(action, wagmiConfig2, apiBaseUrl, sessionId) {
|
|
|
1022
1034
|
}
|
|
1023
1035
|
let typedData = action.metadata?.typedData;
|
|
1024
1036
|
const tokenSymbol = action.metadata?.tokenSymbol;
|
|
1037
|
+
const ownerIsSCA = action.metadata?.ownerIsSCA === true;
|
|
1025
1038
|
if (!typedData && sessionId) {
|
|
1026
1039
|
for (let i = 0; i < SIGN_PERMIT2_MAX_POLLS; i++) {
|
|
1027
1040
|
await new Promise((r) => setTimeout(r, SIGN_PERMIT2_POLL_MS));
|
|
@@ -1049,23 +1062,29 @@ async function executeSignPermit2(action, wagmiConfig2, apiBaseUrl, sessionId) {
|
|
|
1049
1062
|
message: parsed.message
|
|
1050
1063
|
});
|
|
1051
1064
|
const signature = normalizeSignature(rawSignature);
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
`
|
|
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}`
|
|
1068
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
|
+
}
|
|
1069
1088
|
}
|
|
1070
1089
|
console.info(
|
|
1071
1090
|
`[swype-sdk][sign-permit2] Permit2 EIP-712 signature obtained. token=${tokenSymbol ?? "unknown"}`
|