@swype-org/react-sdk 0.1.50 → 0.1.53
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 +27 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -77
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -674,33 +674,6 @@ function isInCrossOriginIframe() {
|
|
|
674
674
|
return true;
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
|
-
var delegationCounter = 0;
|
|
678
|
-
var DELEGATION_GET_TIMEOUT_MS = 3e4;
|
|
679
|
-
function delegatePasskeyGet(options) {
|
|
680
|
-
return new Promise((resolve, reject) => {
|
|
681
|
-
const id = `pg-${++delegationCounter}-${Date.now()}`;
|
|
682
|
-
const timer = setTimeout(() => {
|
|
683
|
-
window.removeEventListener("message", handler);
|
|
684
|
-
reject(new Error("Passkey verification timed out. Please try again."));
|
|
685
|
-
}, DELEGATION_GET_TIMEOUT_MS);
|
|
686
|
-
const handler = (event) => {
|
|
687
|
-
const data = event.data;
|
|
688
|
-
if (!data || typeof data !== "object") return;
|
|
689
|
-
if (data.type !== "swype:passkey-get-response" || data.id !== id) return;
|
|
690
|
-
clearTimeout(timer);
|
|
691
|
-
window.removeEventListener("message", handler);
|
|
692
|
-
if (data.error) {
|
|
693
|
-
reject(new Error(data.error));
|
|
694
|
-
} else if (data.result) {
|
|
695
|
-
resolve(data.result);
|
|
696
|
-
} else {
|
|
697
|
-
reject(new Error("Invalid passkey get response."));
|
|
698
|
-
}
|
|
699
|
-
};
|
|
700
|
-
window.addEventListener("message", handler);
|
|
701
|
-
window.parent.postMessage({ type: "swype:passkey-get-request", id, options }, "*");
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
677
|
var POPUP_RESULT_TIMEOUT_MS = 12e4;
|
|
705
678
|
var POPUP_CLOSED_POLL_MS = 500;
|
|
706
679
|
function createPasskeyViaPopup(options) {
|
|
@@ -950,16 +923,6 @@ async function findDevicePasskey(credentialIds) {
|
|
|
950
923
|
try {
|
|
951
924
|
const challenge = new Uint8Array(32);
|
|
952
925
|
crypto.getRandomValues(challenge);
|
|
953
|
-
if (isInCrossOriginIframe()) {
|
|
954
|
-
const result = await delegatePasskeyGet({
|
|
955
|
-
challenge: toBase64(challenge),
|
|
956
|
-
rpId: resolvePasskeyRpId(),
|
|
957
|
-
allowCredentials: credentialIds.map((id) => ({ type: "public-key", id })),
|
|
958
|
-
userVerification: "discouraged",
|
|
959
|
-
timeout: 3e4
|
|
960
|
-
});
|
|
961
|
-
return result.credentialId;
|
|
962
|
-
}
|
|
963
926
|
await waitForDocumentFocus();
|
|
964
927
|
const assertion = await navigator.credentials.get({
|
|
965
928
|
publicKey: {
|
|
@@ -1458,48 +1421,31 @@ function useTransferSigning(pollIntervalMs = 2e3, options) {
|
|
|
1458
1421
|
}
|
|
1459
1422
|
const hashBytes = hexToBytes(payload.userOpHash);
|
|
1460
1423
|
let signedUserOp;
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1424
|
+
const allowCredentials = payload.passkeyCredentialId ? [{
|
|
1425
|
+
type: "public-key",
|
|
1426
|
+
id: base64ToBytes(payload.passkeyCredentialId)
|
|
1427
|
+
}] : void 0;
|
|
1428
|
+
await waitForDocumentFocus();
|
|
1429
|
+
const assertion = await navigator.credentials.get({
|
|
1430
|
+
publicKey: {
|
|
1431
|
+
challenge: hashBytes,
|
|
1464
1432
|
rpId: resolvePasskeyRpId(),
|
|
1465
|
-
allowCredentials
|
|
1433
|
+
allowCredentials,
|
|
1466
1434
|
userVerification: "required",
|
|
1467
1435
|
timeout: 6e4
|
|
1468
|
-
});
|
|
1469
|
-
signedUserOp = {
|
|
1470
|
-
...payload.userOp,
|
|
1471
|
-
credentialId: delegatedResult.credentialId,
|
|
1472
|
-
signature: delegatedResult.signature,
|
|
1473
|
-
authenticatorData: delegatedResult.authenticatorData,
|
|
1474
|
-
clientDataJSON: delegatedResult.clientDataJSON
|
|
1475
|
-
};
|
|
1476
|
-
} else {
|
|
1477
|
-
const allowCredentials = payload.passkeyCredentialId ? [{
|
|
1478
|
-
type: "public-key",
|
|
1479
|
-
id: base64ToBytes(payload.passkeyCredentialId)
|
|
1480
|
-
}] : void 0;
|
|
1481
|
-
await waitForDocumentFocus();
|
|
1482
|
-
const assertion = await navigator.credentials.get({
|
|
1483
|
-
publicKey: {
|
|
1484
|
-
challenge: hashBytes,
|
|
1485
|
-
rpId: resolvePasskeyRpId(),
|
|
1486
|
-
allowCredentials,
|
|
1487
|
-
userVerification: "required",
|
|
1488
|
-
timeout: 6e4
|
|
1489
|
-
}
|
|
1490
|
-
});
|
|
1491
|
-
if (!assertion) {
|
|
1492
|
-
throw new Error("Passkey authentication was cancelled.");
|
|
1493
1436
|
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
credentialId: toBase64(assertion.rawId),
|
|
1498
|
-
signature: toBase64(response.signature),
|
|
1499
|
-
authenticatorData: toBase64(response.authenticatorData),
|
|
1500
|
-
clientDataJSON: toBase64(response.clientDataJSON)
|
|
1501
|
-
};
|
|
1437
|
+
});
|
|
1438
|
+
if (!assertion) {
|
|
1439
|
+
throw new Error("Passkey authentication was cancelled.");
|
|
1502
1440
|
}
|
|
1441
|
+
const response = assertion.response;
|
|
1442
|
+
signedUserOp = {
|
|
1443
|
+
...payload.userOp,
|
|
1444
|
+
credentialId: toBase64(assertion.rawId),
|
|
1445
|
+
signature: toBase64(response.signature),
|
|
1446
|
+
authenticatorData: toBase64(response.authenticatorData),
|
|
1447
|
+
clientDataJSON: toBase64(response.clientDataJSON)
|
|
1448
|
+
};
|
|
1503
1449
|
return await signTransfer(
|
|
1504
1450
|
apiBaseUrl,
|
|
1505
1451
|
token ?? "",
|
|
@@ -1962,8 +1908,7 @@ var inputStyle = (tokens, filled) => ({
|
|
|
1962
1908
|
textAlign: "center",
|
|
1963
1909
|
outline: "none",
|
|
1964
1910
|
caretColor: tokens.borderFocus,
|
|
1965
|
-
transition: "border-color 0.15s ease"
|
|
1966
|
-
flexShrink: 0
|
|
1911
|
+
transition: "border-color 0.15s ease"
|
|
1967
1912
|
});
|
|
1968
1913
|
function LimitSlider({
|
|
1969
1914
|
value,
|
|
@@ -3914,7 +3859,7 @@ function OpenWalletScreen({
|
|
|
3914
3859
|
const logoSrc = walletName ? KNOWN_LOGOS[walletName.toLowerCase()] : void 0;
|
|
3915
3860
|
const handleOpen = react.useCallback(() => {
|
|
3916
3861
|
const opened = window.open(deeplinkUri, "_blank");
|
|
3917
|
-
if (!opened) {
|
|
3862
|
+
if (!opened && window === window.parent) {
|
|
3918
3863
|
window.location.href = deeplinkUri;
|
|
3919
3864
|
}
|
|
3920
3865
|
}, [deeplinkUri]);
|
|
@@ -4284,6 +4229,11 @@ function SwypePaymentInner({
|
|
|
4284
4229
|
setError(err instanceof Error ? err.message : "Failed to verify code");
|
|
4285
4230
|
}
|
|
4286
4231
|
}, [verificationTarget, otpCode, loginWithEmailCode, loginWithSmsCode]);
|
|
4232
|
+
react.useEffect(() => {
|
|
4233
|
+
if (step === "otp-verify" && /^\d{6}$/.test(otpCode.trim()) && activeOtpStatus !== "submitting-code") {
|
|
4234
|
+
handleVerifyLoginCode();
|
|
4235
|
+
}
|
|
4236
|
+
}, [otpCode, step, activeOtpStatus, handleVerifyLoginCode]);
|
|
4287
4237
|
const handleResendLoginCode = react.useCallback(async () => {
|
|
4288
4238
|
if (!verificationTarget) return;
|
|
4289
4239
|
setError(null);
|