@swype-org/react-sdk 0.1.23 → 0.1.25

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.js CHANGED
@@ -619,6 +619,7 @@ function normalizeSignature(sig) {
619
619
  );
620
620
  return normalizeSignature(wrapper[1]);
621
621
  } catch {
622
+ return `0x${hex}`;
622
623
  }
623
624
  }
624
625
  }
@@ -1030,6 +1031,7 @@ async function executeSignPermit2(action, wagmiConfig2, apiBaseUrl, sessionId) {
1030
1031
  }
1031
1032
  let typedData = action.metadata?.typedData;
1032
1033
  const tokenSymbol = action.metadata?.tokenSymbol;
1034
+ const ownerIsSCA = action.metadata?.ownerIsSCA === true;
1033
1035
  if (!typedData && sessionId) {
1034
1036
  for (let i = 0; i < SIGN_PERMIT2_MAX_POLLS; i++) {
1035
1037
  await new Promise((r) => setTimeout(r, SIGN_PERMIT2_POLL_MS));
@@ -1056,24 +1058,30 @@ async function executeSignPermit2(action, wagmiConfig2, apiBaseUrl, sessionId) {
1056
1058
  primaryType: parsed.primaryType,
1057
1059
  message: parsed.message
1058
1060
  });
1059
- const signature = normalizeSignature(rawSignature);
1060
- const recoverInput = {
1061
- domain: parsed.domain,
1062
- types: parsed.types,
1063
- primaryType: parsed.primaryType,
1064
- message: parsed.message,
1065
- signature
1066
- };
1067
- const recoveredSigner = await recoverTypedDataAddress(recoverInput);
1068
- const expectedSigner = (expectedWallet ?? sender).toLowerCase();
1069
- console.info(
1070
- `[swype-sdk][sign-permit2] Signature recovered. recoveredSigner=${recoveredSigner}, expectedSigner=${expectedSigner}`
1071
- );
1072
- if (recoveredSigner.toLowerCase() !== expectedSigner) {
1073
- return actionError(
1074
- action,
1075
- `Wallet signed with ${recoveredSigner}, but source wallet is ${expectedWallet ?? sender}. Please switch to the source wallet in MetaMask and retry.`
1061
+ const signature = ownerIsSCA ? rawSignature.startsWith("0x") ? rawSignature : `0x${rawSignature}` : normalizeSignature(rawSignature);
1062
+ if (ownerIsSCA) {
1063
+ console.info(
1064
+ `[swype-sdk][sign-permit2] Owner is SCA \u2014 preserving raw signature (${rawSignature.length / 2 - 1}B). 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}`
1076
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
+ }
1077
1085
  }
1078
1086
  console.info(
1079
1087
  `[swype-sdk][sign-permit2] Permit2 EIP-712 signature obtained. token=${tokenSymbol ?? "unknown"}`