@swype-org/react-sdk 0.1.80 → 0.1.82
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 +47 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +47 -8
- package/dist/index.js.map +1 -1
- package/package.json +10 -3
package/dist/index.cjs
CHANGED
|
@@ -331,6 +331,22 @@ async function reportActionCompletion(apiBaseUrl, actionId, result) {
|
|
|
331
331
|
return await res.json();
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
+
// src/sentry.ts
|
|
335
|
+
var _mod;
|
|
336
|
+
function captureException(error) {
|
|
337
|
+
if (_mod === null) return;
|
|
338
|
+
if (_mod) {
|
|
339
|
+
_mod.captureException(error);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
import('@sentry/react').then((m) => {
|
|
343
|
+
_mod = m;
|
|
344
|
+
m.captureException(error);
|
|
345
|
+
}).catch(() => {
|
|
346
|
+
_mod = null;
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
334
350
|
// node_modules/@wagmi/core/dist/esm/version.js
|
|
335
351
|
var version = "2.22.1";
|
|
336
352
|
|
|
@@ -701,13 +717,17 @@ var POPUP_RESULT_TIMEOUT_MS = 12e4;
|
|
|
701
717
|
var POPUP_CLOSED_POLL_MS = 500;
|
|
702
718
|
function createPasskeyViaPopup(options) {
|
|
703
719
|
return new Promise((resolve, reject) => {
|
|
704
|
-
const
|
|
720
|
+
const channelId = `swype-pk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
721
|
+
const payload = { ...options, channelId };
|
|
722
|
+
const encoded = btoa(JSON.stringify(payload));
|
|
705
723
|
const popupUrl = `${window.location.origin}/passkey-register#${encoded}`;
|
|
706
724
|
const popup = window.open(popupUrl, "swype-passkey");
|
|
707
725
|
if (!popup) {
|
|
708
726
|
reject(new Error("Pop-up blocked. Please allow pop-ups for this site and try again."));
|
|
709
727
|
return;
|
|
710
728
|
}
|
|
729
|
+
let settled = false;
|
|
730
|
+
const channel = typeof BroadcastChannel !== "undefined" ? new BroadcastChannel(channelId) : null;
|
|
711
731
|
const timer = setTimeout(() => {
|
|
712
732
|
cleanup();
|
|
713
733
|
reject(new Error("Passkey creation timed out. Please try again."));
|
|
@@ -718,11 +738,11 @@ function createPasskeyViaPopup(options) {
|
|
|
718
738
|
reject(new Error("Passkey setup window was closed before completing."));
|
|
719
739
|
}
|
|
720
740
|
}, POPUP_CLOSED_POLL_MS);
|
|
721
|
-
|
|
722
|
-
if (
|
|
723
|
-
const data = event.data;
|
|
741
|
+
function handleResult(data) {
|
|
742
|
+
if (settled) return;
|
|
724
743
|
if (!data || typeof data !== "object") return;
|
|
725
744
|
if (data.type !== "swype:passkey-popup-result") return;
|
|
745
|
+
settled = true;
|
|
726
746
|
cleanup();
|
|
727
747
|
if (data.error) {
|
|
728
748
|
reject(new Error(data.error));
|
|
@@ -731,13 +751,21 @@ function createPasskeyViaPopup(options) {
|
|
|
731
751
|
} else {
|
|
732
752
|
reject(new Error("Invalid passkey popup response."));
|
|
733
753
|
}
|
|
754
|
+
}
|
|
755
|
+
if (channel) {
|
|
756
|
+
channel.onmessage = (event) => handleResult(event.data);
|
|
757
|
+
}
|
|
758
|
+
const postMessageHandler = (event) => {
|
|
759
|
+
if (event.source !== popup) return;
|
|
760
|
+
handleResult(event.data);
|
|
734
761
|
};
|
|
762
|
+
window.addEventListener("message", postMessageHandler);
|
|
735
763
|
function cleanup() {
|
|
736
764
|
clearTimeout(timer);
|
|
737
765
|
clearInterval(closedPoll);
|
|
738
|
-
window.removeEventListener("message",
|
|
766
|
+
window.removeEventListener("message", postMessageHandler);
|
|
767
|
+
channel?.close();
|
|
739
768
|
}
|
|
740
|
-
window.addEventListener("message", handler);
|
|
741
769
|
});
|
|
742
770
|
}
|
|
743
771
|
|
|
@@ -4346,8 +4374,8 @@ var PaymentErrorBoundary = class extends react.Component {
|
|
|
4346
4374
|
static getDerivedStateFromError() {
|
|
4347
4375
|
return { hasError: true };
|
|
4348
4376
|
}
|
|
4349
|
-
componentDidCatch(error,
|
|
4350
|
-
|
|
4377
|
+
componentDidCatch(error, _info) {
|
|
4378
|
+
captureException(error);
|
|
4351
4379
|
}
|
|
4352
4380
|
handleReset = () => {
|
|
4353
4381
|
this.setState({ hasError: false });
|
|
@@ -4665,6 +4693,7 @@ function SwypePaymentInner({
|
|
|
4665
4693
|
try {
|
|
4666
4694
|
await initOAuth({ provider });
|
|
4667
4695
|
} catch (err) {
|
|
4696
|
+
captureException(err);
|
|
4668
4697
|
setError(err instanceof Error ? err.message : "Social login failed");
|
|
4669
4698
|
}
|
|
4670
4699
|
}, [initOAuth]);
|
|
@@ -4691,6 +4720,7 @@ function SwypePaymentInner({
|
|
|
4691
4720
|
setVerificationTarget(normalizedIdentifier);
|
|
4692
4721
|
setStep("otp-verify");
|
|
4693
4722
|
} catch (err) {
|
|
4723
|
+
captureException(err);
|
|
4694
4724
|
setError(err instanceof Error ? err.message : "Failed to send verification code");
|
|
4695
4725
|
}
|
|
4696
4726
|
}, [authInput, sendEmailCode, sendSmsCode]);
|
|
@@ -4709,6 +4739,7 @@ function SwypePaymentInner({
|
|
|
4709
4739
|
await loginWithSmsCode({ code: trimmedCode });
|
|
4710
4740
|
}
|
|
4711
4741
|
} catch (err) {
|
|
4742
|
+
captureException(err);
|
|
4712
4743
|
setError(err instanceof Error ? err.message : "Failed to verify code");
|
|
4713
4744
|
}
|
|
4714
4745
|
}, [verificationTarget, otpCode, loginWithEmailCode, loginWithSmsCode]);
|
|
@@ -4727,6 +4758,7 @@ function SwypePaymentInner({
|
|
|
4727
4758
|
await sendSmsCode({ phoneNumber: verificationTarget.value });
|
|
4728
4759
|
}
|
|
4729
4760
|
} catch (err) {
|
|
4761
|
+
captureException(err);
|
|
4730
4762
|
setError(err instanceof Error ? err.message : "Failed to resend code");
|
|
4731
4763
|
}
|
|
4732
4764
|
}, [verificationTarget, sendEmailCode, sendSmsCode]);
|
|
@@ -4941,6 +4973,7 @@ function SwypePaymentInner({
|
|
|
4941
4973
|
}
|
|
4942
4974
|
} catch (err) {
|
|
4943
4975
|
if (!cancelled) {
|
|
4976
|
+
captureException(err);
|
|
4944
4977
|
setError(err instanceof Error ? err.message : "Failed to load data");
|
|
4945
4978
|
}
|
|
4946
4979
|
} finally {
|
|
@@ -4983,6 +5016,7 @@ function SwypePaymentInner({
|
|
|
4983
5016
|
if (!hasProcessingTimedOut(processingStartedAtRef.current, Date.now())) return;
|
|
4984
5017
|
const status = getTransferStatus(polling.transfer, transfer);
|
|
4985
5018
|
const msg = buildProcessingTimeoutMessage(status);
|
|
5019
|
+
captureException(new Error(msg));
|
|
4986
5020
|
polling.stopPolling();
|
|
4987
5021
|
setStep("deposit");
|
|
4988
5022
|
setError(msg);
|
|
@@ -5207,6 +5241,7 @@ function SwypePaymentInner({
|
|
|
5207
5241
|
setTransfer(signedTransfer);
|
|
5208
5242
|
polling.startPolling(t.id);
|
|
5209
5243
|
} catch (err) {
|
|
5244
|
+
captureException(err);
|
|
5210
5245
|
const msg = err instanceof Error ? err.message : "Transfer failed";
|
|
5211
5246
|
setError(msg);
|
|
5212
5247
|
onError?.(msg);
|
|
@@ -5285,6 +5320,7 @@ function SwypePaymentInner({
|
|
|
5285
5320
|
triggerDeeplink(uri);
|
|
5286
5321
|
}
|
|
5287
5322
|
} catch (err) {
|
|
5323
|
+
captureException(err);
|
|
5288
5324
|
const msg = err instanceof Error ? err.message : "Failed to increase limit";
|
|
5289
5325
|
setError(msg);
|
|
5290
5326
|
onError?.(msg);
|
|
@@ -5339,6 +5375,7 @@ function SwypePaymentInner({
|
|
|
5339
5375
|
if (err instanceof PasskeyIframeBlockedError) {
|
|
5340
5376
|
setPasskeyPopupNeeded(true);
|
|
5341
5377
|
} else {
|
|
5378
|
+
captureException(err);
|
|
5342
5379
|
setError(err instanceof Error ? err.message : "Failed to register passkey");
|
|
5343
5380
|
}
|
|
5344
5381
|
} finally {
|
|
@@ -5357,6 +5394,7 @@ function SwypePaymentInner({
|
|
|
5357
5394
|
const { credentialId, publicKey } = await createPasskeyViaPopup(popupOptions);
|
|
5358
5395
|
await completePasskeyRegistration(credentialId, publicKey);
|
|
5359
5396
|
} catch (err) {
|
|
5397
|
+
captureException(err);
|
|
5360
5398
|
setError(err instanceof Error ? err.message : "Failed to register passkey");
|
|
5361
5399
|
} finally {
|
|
5362
5400
|
setRegisteringPasskey(false);
|
|
@@ -5444,6 +5482,7 @@ function SwypePaymentInner({
|
|
|
5444
5482
|
setStep("processing");
|
|
5445
5483
|
polling.startPolling(t.id);
|
|
5446
5484
|
} catch (err) {
|
|
5485
|
+
captureException(err);
|
|
5447
5486
|
const msg = err instanceof Error ? err.message : "Failed to sign transfer";
|
|
5448
5487
|
setError(msg);
|
|
5449
5488
|
onError?.(msg);
|