@getpara/react-common 2.0.0-dev.0 → 2.0.0-dev.2

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.
Files changed (51) hide show
  1. package/dist/chunk-GOCCUU3Z.js +42 -0
  2. package/dist/classes/ParaInternal.d.ts +23 -10
  3. package/dist/classes/ParaInternal.js +28 -0
  4. package/dist/classes/index.js +2 -0
  5. package/dist/components/HeroSpinner.d.ts +2 -2
  6. package/dist/components/HeroSpinner.js +63 -0
  7. package/dist/components/KnownDevices.js +59 -0
  8. package/dist/components/MoonPayEmbed.d.ts +2 -2
  9. package/dist/components/MoonPayEmbed.js +183 -0
  10. package/dist/components/NetworkSpeedBanner.d.ts +5 -0
  11. package/dist/components/NetworkSpeedBanner.js +80 -0
  12. package/dist/components/QRCode.js +80 -0
  13. package/dist/components/RampEmbed.d.ts +2 -2
  14. package/dist/components/RampEmbed.js +103 -0
  15. package/dist/components/UserIdentifier.d.ts +4 -2
  16. package/dist/components/UserIdentifier.js +65 -0
  17. package/dist/components/common.d.ts +5 -5
  18. package/dist/components/common.js +54 -0
  19. package/dist/components/index.d.ts +1 -1
  20. package/dist/components/index.js +9 -0
  21. package/dist/constants/aaguiMetadata.js +145 -0
  22. package/dist/constants/externalWalletDefaults.d.ts +41 -0
  23. package/dist/constants/externalWalletDefaults.js +47 -0
  24. package/dist/hooks/index.d.ts +1 -0
  25. package/dist/hooks/index.js +3 -0
  26. package/dist/hooks/useCopyToClipboard.js +36 -0
  27. package/dist/hooks/useUserAgent.d.ts +2 -0
  28. package/dist/hooks/useUserAgent.js +10 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +6 -1241
  31. package/dist/package.json +6 -0
  32. package/dist/types/externalWalletCommon.d.ts +69 -10
  33. package/dist/types/externalWalletCommon.js +1 -0
  34. package/dist/types/index.d.ts +1 -1
  35. package/dist/types/index.js +2 -0
  36. package/dist/utils/formatBiometricHints.d.ts +1 -1
  37. package/dist/utils/formatBiometricHints.js +51 -0
  38. package/dist/utils/getBrowserName.js +7 -0
  39. package/dist/utils/getDeviceLogo.js +36 -0
  40. package/dist/utils/getDeviceModelName.js +21 -0
  41. package/dist/utils/getExternalWalletDisplayName.d.ts +2 -0
  42. package/dist/utils/getExternalWalletDisplayName.js +22 -0
  43. package/dist/utils/index.d.ts +9 -2
  44. package/dist/utils/index.js +125 -0
  45. package/dist/utils/offRampSend.js +75 -0
  46. package/dist/utils/safeStyled.d.ts +2 -0
  47. package/dist/utils/safeStyled.js +25 -0
  48. package/package.json +22 -24
  49. package/dist/components/StripeEmbed.d.ts +0 -4
  50. package/dist/index.js.br +0 -0
  51. package/dist/index.js.gz +0 -0
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __spreadValues = (a, b) => {
8
+ for (var prop in b || (b = {}))
9
+ if (__hasOwnProp.call(b, prop))
10
+ __defNormalProp(a, prop, b[prop]);
11
+ if (__getOwnPropSymbols)
12
+ for (var prop of __getOwnPropSymbols(b)) {
13
+ if (__propIsEnum.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ }
16
+ return a;
17
+ };
18
+ var __async = (__this, __arguments, generator) => {
19
+ return new Promise((resolve, reject) => {
20
+ var fulfilled = (value) => {
21
+ try {
22
+ step(generator.next(value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ };
27
+ var rejected = (value) => {
28
+ try {
29
+ step(generator.throw(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ };
34
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
+ step((generator = generator.apply(__this, __arguments)).next());
36
+ });
37
+ };
38
+
39
+ export {
40
+ __spreadValues,
41
+ __async
42
+ };
@@ -1,6 +1,9 @@
1
- import ParaWeb from '@getpara/web-sdk';
2
- export declare class ParaInternal extends ParaWeb {
3
- getSupportedCreateAuthMethods: () => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
1
+ import ParaWeb, { InternalInterface } from '@getpara/web-sdk';
2
+ export declare class ParaInternal extends ParaWeb implements InternalInterface {
3
+ setupAfterLogin: ({ temporaryShares, skipSessionRefresh, }?: {
4
+ temporaryShares?: any[];
5
+ skipSessionRefresh?: boolean;
6
+ }) => Promise<void>;
4
7
  getTransmissionKeyShares: ({ isForNewDevice }?: {
5
8
  isForNewDevice?: boolean;
6
9
  }) => Promise<any>;
@@ -8,11 +11,21 @@ export declare class ParaInternal extends ParaWeb {
8
11
  setLoginEncryptionKeyPair: (keyPair?: import("node-forge").pki.rsa.KeyPair) => Promise<void>;
9
12
  getPortalURL: () => Promise<string>;
10
13
  isProviderModalDisabled: () => boolean;
11
- supportedAuthMethods: (auth: import("@getpara/user-management-client").Auth<import("@getpara/user-management-client").PrimaryAuthType | "userId">) => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
12
- getUserBiometricLocationHints: () => Promise<import("@getpara/user-management-client").BiometricLocationHint[]>;
13
- exitLoops: () => void;
14
- exitLogin: () => void;
15
- exitAccountCreation: () => void;
16
- exitOAuth: () => void;
17
- exitFarcaster: () => void;
14
+ setAuth: (auth: import("@getpara/user-management-client").PrimaryAuth, { extras, userId }?: {
15
+ extras?: import("@getpara/web-sdk").AuthExtras;
16
+ userId?: string;
17
+ }) => Promise<typeof this.authInfo>;
18
+ supportedAuthMethods: (auth: import("@getpara/web-sdk").Auth<import("@getpara/user-management-client").PrimaryAuthType | "userId">) => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
19
+ constructPortalUrl: (type: import("@getpara/core-sdk/dist/types/types").PortalUrlType, opts?: import("@getpara/core-sdk/dist/types/types").PortalUrlOptions) => Promise<string>;
20
+ getNewCredentialAndUrl: ({ authMethod, isForNewDevice, portalTheme, shorten, }?: import("@getpara/core-sdk/dist/types/types").NewCredentialUrlParams) => Promise<{
21
+ credentialId: string;
22
+ url?: string;
23
+ }>;
24
+ linkAccount: (opts: import("@getpara/web-sdk").InternalMethodParams<"linkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"linkAccount">;
25
+ unlinkAccount: ({ linkedAccountId, }: import("@getpara/web-sdk").InternalMethodParams<"unlinkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"unlinkAccount">;
26
+ verifyEmailOrPhoneLink: ({ verificationCode, }: import("@getpara/web-sdk").InternalMethodParams<"verifyEmailOrPhoneLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyEmailOrPhoneLink">;
27
+ verifyOAuthLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyOAuthLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyOAuthLink">;
28
+ verifyTelegramLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyTelegramLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyTelegramLink">;
29
+ verifyFarcasterLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyFarcasterLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyFarcasterLink">;
30
+ verifyExternalWalletLink: (opts: import("@getpara/web-sdk").InternalMethodParams<"verifyExternalWalletLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyExternalWalletLink">;
18
31
  }
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import "../chunk-GOCCUU3Z.js";
3
+ import ParaWeb from "@getpara/web-sdk";
4
+ class ParaInternal extends ParaWeb {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.setupAfterLogin = super.setupAfterLogin;
8
+ this.getTransmissionKeyShares = super.getTransmissionKeyShares;
9
+ this.userSetupAfterLogin = super.userSetupAfterLogin;
10
+ this.setLoginEncryptionKeyPair = super.setLoginEncryptionKeyPair;
11
+ this.getPortalURL = super.getPortalURL;
12
+ this.isProviderModalDisabled = super.isProviderModalDisabled;
13
+ this.setAuth = super.setAuth;
14
+ this.supportedAuthMethods = super.supportedAuthMethods;
15
+ this.constructPortalUrl = super.constructPortalUrl;
16
+ this.getNewCredentialAndUrl = super.getNewCredentialAndUrl;
17
+ this.linkAccount = super.linkAccount;
18
+ this.unlinkAccount = super.unlinkAccount;
19
+ this.verifyEmailOrPhoneLink = super.verifyEmailOrPhoneLink;
20
+ this.verifyOAuthLink = super.verifyOAuthLink;
21
+ this.verifyTelegramLink = super.verifyTelegramLink;
22
+ this.verifyFarcasterLink = super.verifyFarcasterLink;
23
+ this.verifyExternalWalletLink = super.verifyExternalWalletLink;
24
+ }
25
+ }
26
+ export {
27
+ ParaInternal
28
+ };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export * from "./ParaInternal.js";
@@ -1,8 +1,8 @@
1
1
  import { IconType } from '@getpara/react-components';
2
2
  import { PropsWithChildren, ReactNode } from 'react';
3
- type Status = 'loading' | 'error' | 'inactive';
3
+ type Status = 'pending' | 'error' | 'idle' | 'success';
4
4
  export declare function HeroSpinner({ icon, status, text, }: PropsWithChildren<{
5
- icon?: IconType;
5
+ icon?: IconType | ReactNode;
6
6
  status?: Status;
7
7
  text?: ReactNode;
8
8
  }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import "../chunk-GOCCUU3Z.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslIcon, CpslSpinner, CpslText } from "@getpara/react-components";
5
+ import { safeStyled } from "../utils/index.js";
6
+ function HeroSpinner({
7
+ icon,
8
+ status = "idle",
9
+ text
10
+ }) {
11
+ return /* @__PURE__ */ jsxs(Root, { children: [
12
+ /* @__PURE__ */ jsxs(Hero, { children: [
13
+ /* @__PURE__ */ jsx(Spinner, { size: 155, barWidth: 8, variant: status }),
14
+ typeof icon === "string" ? /* @__PURE__ */ jsx(CpslIcon, { icon, size: "80px" }) : icon
15
+ ] }),
16
+ /* @__PURE__ */ jsxs(Text, { status, children: [
17
+ status === "error" && /* @__PURE__ */ jsx(CpslIcon, { icon: "alertCircle", size: "16px", style: { stroke: "currentColor" } }),
18
+ status === "success" && /* @__PURE__ */ jsx(CpslIcon, { icon: "checkCircle", size: "16px", style: { stroke: "currentColor" } }),
19
+ /* @__PURE__ */ jsx(
20
+ CpslText,
21
+ {
22
+ variant: "bodyM",
23
+ weight: "semiBold",
24
+ color: status === "error" ? "error" : status === "success" ? "success" : "primary",
25
+ children: text
26
+ }
27
+ )
28
+ ] })
29
+ ] });
30
+ }
31
+ const Root = safeStyled.div`
32
+ display: flex;
33
+ flex-direction: column;
34
+ justify-content: center;
35
+ align-items: center;
36
+ `;
37
+ const Hero = safeStyled.div`
38
+ width: 150px;
39
+ height: 150px;
40
+ margin: 16px 0;
41
+ display: flex;
42
+ justify-content: center;
43
+ align-items: center;
44
+ position: relative;
45
+ `;
46
+ const Text = safeStyled.div`
47
+ display: flex;
48
+ gap: 4px;
49
+ align-items: center;
50
+ color: ${({ status }) => status === "error" ? "var(--cpsl-color-utility-red)" : status === "success" ? "var(--cpsl-color-utility-green)" : "auto"};
51
+ `;
52
+ const Spinner = safeStyled(CpslSpinner)`
53
+ position: absolute;
54
+ width: 150px;
55
+ height: 150px;
56
+ top: 0;
57
+ left: 0;
58
+ right: 0;
59
+ transition: 0.2s color;
60
+ `;
61
+ export {
62
+ HeroSpinner
63
+ };
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import "../chunk-GOCCUU3Z.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslButton, CpslIcon, CpslText } from "@getpara/react-components";
5
+ import { CenteredColumnContainer, FullWidthFilledDisabledInput, CenteredText } from "./common.js";
6
+ import { QRCode } from "./QRCode.js";
7
+ import { getDeviceLogo, getDeviceModelName, safeStyled } from "../utils/index.js";
8
+ import { useCopyToClipboard } from "../hooks/index.js";
9
+ const KnownDevices = ({ hints, link, showCurrentDevice }) => {
10
+ const [isCopied, copy] = useCopyToClipboard();
11
+ const handleCopy = () => {
12
+ copy(link);
13
+ };
14
+ return /* @__PURE__ */ jsxs(Container, { children: [
15
+ /* @__PURE__ */ jsx(CenteredText, { weight: "semiBold", children: "Continue with one of your other known devices" }),
16
+ !!hints.formattedHints.length && /* @__PURE__ */ jsx(DevicesContainer, { children: hints.formattedHints.map(
17
+ (hint) => {
18
+ var _a, _b, _c;
19
+ return (showCurrentDevice && hint.isKnownDevice || !hint.isKnownDevice) && /* @__PURE__ */ jsxs(DeviceListItem, { children: [
20
+ /* @__PURE__ */ jsx(DeviceLogo, { icon: getDeviceLogo(hint.device.vendor, hint.isMobile) }),
21
+ /* @__PURE__ */ jsx(CpslText, { weight: "medium", color: "contrast", children: (_b = (_a = getDeviceModelName(hint.device.model)) != null ? _a : hint.device.vendor) != null ? _b : hint.os.name }),
22
+ (hint.browser || hint.passwordManager) && /* @__PURE__ */ jsxs(Fragment, { children: [
23
+ /* @__PURE__ */ jsx(CpslText, { weight: "medium", color: "secondary", children: "using" }),
24
+ /* @__PURE__ */ jsx(CpslText, { weight: "medium", color: "contrast", children: (_c = hint.passwordManager) != null ? _c : hint.browser.name })
25
+ ] })
26
+ ] }, hint.key);
27
+ }
28
+ ) }),
29
+ hints.hasMobileDevice ? /* @__PURE__ */ jsx(QRCode, { link, icon: "paraIconQr" }) : /* @__PURE__ */ jsxs(CenteredColumnContainer, { children: [
30
+ /* @__PURE__ */ jsx(FullWidthFilledDisabledInput, { noAutoDisable: true, readonly: true, disabled: true, value: link, children: /* @__PURE__ */ jsx(CpslButton, { slot: "end", variant: "ghost", onClick: handleCopy, children: /* @__PURE__ */ jsx(CpslIcon, { icon: isCopied ? "check" : "copy" }) }) }),
31
+ /* @__PURE__ */ jsx(CenteredText, { color: "secondary", variant: "bodyS", weight: "medium", children: "Navigate to this link using your other device" })
32
+ ] })
33
+ ] });
34
+ };
35
+ const Container = safeStyled(CenteredColumnContainer)`
36
+ gap: 16px;
37
+ `;
38
+ const DevicesContainer = safeStyled.div`
39
+ display: flex;
40
+ flex-direction: column;
41
+ gap: 8px;
42
+ background: var(--cpsl-color-background-4);
43
+ padding: 16px;
44
+ width: 100%;
45
+ border-radius: 16px;
46
+ `;
47
+ const DeviceListItem = safeStyled.div`
48
+ display: flex;
49
+ gap: 4px;
50
+ align-items: center;
51
+ `;
52
+ const DeviceLogo = safeStyled(CpslIcon)`
53
+ --icon-color: var(--cpsl-color-text-contrast);
54
+ --height: 16px;
55
+ --width: 16px;
56
+ `;
57
+ export {
58
+ KnownDevices
59
+ };
@@ -1,3 +1,3 @@
1
- import { Props } from '../types/index.js';
2
- export declare const MoonPayEmbed: ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, setOnRampPurchase }: Props) => import("react/jsx-runtime").JSX.Element;
1
+ import { OnRampProps } from '../types/index.js';
2
+ export declare const MoonPayEmbed: ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, setOnRampPurchase }: OnRampProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default MoonPayEmbed;
@@ -0,0 +1,183 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../chunk-GOCCUU3Z.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { getNetworkPrefix, OnRampProvider, OnRampPurchaseStatus } from "@getpara/web-sdk";
7
+ import { lazy, useCallback, useEffect, useMemo, useState } from "react";
8
+ import { reverseCurrencyLookup, offRampSend, getCurrencyCode, safeStyled } from "../utils/index.js";
9
+ const MOONPAY_PUBLISHABLE_KEY = "pk_live_EQva4LydtNDE0Rwd9X7SG9w58wqOzbux";
10
+ const MOONPAY_PUBLISHABLE_KEY_TEST = "pk_test_HYobzemmTBXxcSStVA4dSED6jT";
11
+ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, setOnRampPurchase }) => {
12
+ const [LazyMoonPayBuyWidget, setLazyMoonPayBuyWidget] = useState(null);
13
+ const [LazyMoonPaySellWidget, setLazyMoonPaySellWidget] = useState(null);
14
+ const [LazyMoonPayProvider, setLazyMoonPayProvider] = useState(null);
15
+ useEffect(() => {
16
+ const _LazyMoonPayBuyWidget = lazy(
17
+ () => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPayBuyWidget }))
18
+ );
19
+ const _LazyMoonPaySellWidget = lazy(
20
+ () => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPaySellWidget }))
21
+ );
22
+ const _LazyMoonPayProvider = lazy(
23
+ () => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPayProvider }))
24
+ );
25
+ setLazyMoonPayBuyWidget(_LazyMoonPayBuyWidget);
26
+ setLazyMoonPaySellWidget(_LazyMoonPaySellWidget);
27
+ setLazyMoonPayProvider(_LazyMoonPayProvider);
28
+ }, []);
29
+ const apiKey = onRampPurchase.testMode ? MOONPAY_PUBLISHABLE_KEY_TEST : MOONPAY_PUBLISHABLE_KEY;
30
+ const onUrlSignatureRequested = useCallback(
31
+ (url) => __async(void 0, null, function* () {
32
+ if (!para.getUserId() || !onRampPurchase.walletType) {
33
+ throw new Error("missing required fields");
34
+ }
35
+ const res = yield para.ctx.client.signMoonPayUrl(para.getUserId(), {
36
+ url,
37
+ type: onRampPurchase.walletType,
38
+ cosmosPrefix: getNetworkPrefix(onRampPurchase.network),
39
+ testMode: onRampPurchase.testMode,
40
+ walletId: onRampPurchase.walletId || void 0,
41
+ externalWalletAddress: onRampPurchase.externalWalletAddress || void 0
42
+ });
43
+ return res.data.signature;
44
+ }),
45
+ [onRampPurchase.walletId, onRampPurchase.walletType, para.cosmosPrefix, onRampPurchase.testMode, para]
46
+ );
47
+ const onTransactionCompleted = useCallback(
48
+ (payload) => __async(void 0, null, function* () {
49
+ try {
50
+ const [network, asset] = reverseCurrencyLookup(
51
+ onRampConfig.assetInfo,
52
+ OnRampProvider.MOONPAY,
53
+ payload.quoteCurrency.code
54
+ );
55
+ const updated = yield para.ctx.client.updateOnRampPurchase({
56
+ userId: para.getUserId(),
57
+ walletId: onRampPurchase.walletId,
58
+ purchaseId: onRampPurchase.id,
59
+ externalWalletAddress: onRampPurchase.externalWalletAddress,
60
+ updates: {
61
+ fiatQuantity: payload.baseCurrencyAmount.toString(),
62
+ fiat: payload.baseCurrency.code,
63
+ network,
64
+ asset,
65
+ assetQuantity: payload.quoteCurrencyAmount.toString(),
66
+ status: OnRampPurchaseStatus.FINISHED
67
+ }
68
+ });
69
+ setOnRampPurchase(updated);
70
+ if (!isEmbedded) {
71
+ setTimeout(() => {
72
+ if (typeof window !== "undefined") {
73
+ window.close();
74
+ }
75
+ }, 5e3);
76
+ }
77
+ } catch (e) {
78
+ console.error(e);
79
+ }
80
+ }),
81
+ [onRampPurchase.walletId, onRampPurchase.id, onRampPurchase.externalWalletAddress, isEmbedded]
82
+ );
83
+ const onInitiateDeposit = useCallback(
84
+ (payload) => __async(void 0, null, function* () {
85
+ const txHash = yield offRampSend(para, onRampPurchase, setOnRampPurchase, {
86
+ assetQuantity: payload.cryptoCurrencyAmount,
87
+ fiatQuantity: payload.fiatCurrencyAmount || void 0,
88
+ fiat: payload.fiatCurrency.code.toUpperCase(),
89
+ destinationAddress: payload.depositWalletAddress,
90
+ contractAddress: payload.cryptoCurrency.contractAddress,
91
+ chainId: payload.cryptoCurrency.chainId
92
+ });
93
+ return { depositId: txHash, cancelTransactionOnError: false };
94
+ }),
95
+ [
96
+ para,
97
+ onRampPurchase.id,
98
+ onRampPurchase.testMode,
99
+ onRampPurchase.walletId,
100
+ onRampPurchase.walletType,
101
+ setOnRampPurchase
102
+ ]
103
+ );
104
+ const embed = useMemo(() => {
105
+ if (!LazyMoonPayBuyWidget || !LazyMoonPaySellWidget) {
106
+ return null;
107
+ }
108
+ const currencyCode = getCurrencyCode(onRampConfig, {
109
+ network: onRampPurchase.network,
110
+ asset: onRampPurchase.asset,
111
+ provider: OnRampProvider.MOONPAY
112
+ });
113
+ return onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
114
+ LazyMoonPayBuyWidget,
115
+ {
116
+ variant: "embedded",
117
+ baseCurrencyCode: onRampPurchase.fiat,
118
+ baseCurrencyAmount: onRampPurchase.fiatQuantity,
119
+ currencyCode,
120
+ walletAddress: onRampPurchase.address,
121
+ visible: true,
122
+ theme: isDark ? "dark" : "light",
123
+ style: {
124
+ height: "100%",
125
+ width: "100%",
126
+ border: "none",
127
+ borderRadius: 0,
128
+ margin: 0
129
+ },
130
+ onTransactionCompleted,
131
+ onUrlSignatureRequested
132
+ }
133
+ ) : /* @__PURE__ */ jsx(
134
+ LazyMoonPaySellWidget,
135
+ {
136
+ variant: "embedded",
137
+ visible: true,
138
+ theme: isDark ? "dark" : "light",
139
+ style: {
140
+ height: "100%",
141
+ width: "100%",
142
+ border: "none",
143
+ borderRadius: 0,
144
+ margin: 0
145
+ },
146
+ baseCurrencyCode: currencyCode,
147
+ refundWalletAddress: onRampPurchase.address,
148
+ onInitiateDeposit,
149
+ onTransactionCompleted,
150
+ onUrlSignatureRequested
151
+ }
152
+ );
153
+ }, [
154
+ onRampPurchase.type,
155
+ onRampPurchase.address,
156
+ onRampPurchase.walletId,
157
+ onRampPurchase.walletType,
158
+ onRampPurchase.asset,
159
+ onInitiateDeposit,
160
+ onTransactionCompleted,
161
+ onUrlSignatureRequested,
162
+ isDark,
163
+ LazyMoonPayBuyWidget,
164
+ LazyMoonPaySellWidget
165
+ ]);
166
+ if (!LazyMoonPayProvider) {
167
+ return null;
168
+ }
169
+ return /* @__PURE__ */ jsx(Container, { isEmbedded, children: /* @__PURE__ */ jsx(LazyMoonPayProvider, { apiKey, debug: onRampPurchase.testMode, children: embed }) });
170
+ };
171
+ var MoonPayEmbed_default = MoonPayEmbed;
172
+ const Container = safeStyled.div`
173
+ width: ${({ isEmbedded }) => isEmbedded ? "100%" : "100vw"};
174
+ height: ${({ isEmbedded }) => isEmbedded ? "640px" : "100vh"};
175
+
176
+ iframe {
177
+ border: 0 !important;
178
+ }
179
+ `;
180
+ export {
181
+ MoonPayEmbed,
182
+ MoonPayEmbed_default as default
183
+ };
@@ -0,0 +1,5 @@
1
+ export declare const NetworkSpeedBanner: ({ fontSize, iconSize, maxWidth, }: {
2
+ fontSize?: string;
3
+ iconSize?: string;
4
+ maxWidth?: string;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ import "../chunk-GOCCUU3Z.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { useEffect, useState } from "react";
5
+ import { CpslIcon } from "@getpara/react-components";
6
+ import { safeStyled } from "../utils/index.js";
7
+ const BannerContainerWrapper = safeStyled.div`
8
+ display: flex;
9
+ justify-content: center;
10
+ align-items: center;
11
+ width: 100%;
12
+ background-color: transparent;
13
+ `;
14
+ const BannerContainer = safeStyled.div`
15
+ display: flex;
16
+ justify-content: center;
17
+ align-items: center;
18
+ max-width: ${({ $maxWidth }) => $maxWidth || "100%"};
19
+ box-sizing: border-box;
20
+ padding: 6px;
21
+ border-radius: 12px;
22
+ background-color: transparent;
23
+ position: relative;
24
+ z-index: 10;
25
+ display: inline-flex;
26
+ white-space: nowrap;
27
+ text-overflow: ellipsis;
28
+ overflow: hidden;
29
+ `;
30
+ const WarningIcon = safeStyled(CpslIcon)`
31
+ --icon-color: #fbbc04;
32
+ --width: ${({ $size }) => $size || "24px"};
33
+ --height: ${({ $size }) => $size || "24px"};
34
+ margin-right: 6px;
35
+ flex-shrink: 0;
36
+ `;
37
+ const BannerText = safeStyled.span`
38
+ font-family: var(--cpsl-default-font);
39
+ font-weight: 500;
40
+ font-size: ${({ $fontSize }) => $fontSize || "14px"};
41
+ color: var(--cpsl-color-black);
42
+ flex: 1;
43
+ `;
44
+ const NetworkSpeedBanner = ({
45
+ fontSize,
46
+ iconSize,
47
+ maxWidth
48
+ }) => {
49
+ const [isSlowNetwork, setIsSlowNetwork] = useState(false);
50
+ useEffect(() => {
51
+ var _a;
52
+ const connection = navigator == null ? void 0 : navigator.connection;
53
+ const checkNetworkSpeed = () => {
54
+ if (connection) {
55
+ const isSlow = connection.effectiveType === "2g" || connection.effectiveType === "slow-2g" || connection.downlink && connection.downlink < 0.5;
56
+ setIsSlowNetwork(isSlow);
57
+ } else {
58
+ setIsSlowNetwork(false);
59
+ }
60
+ };
61
+ checkNetworkSpeed();
62
+ (_a = connection == null ? void 0 : connection.addEventListener) == null ? void 0 : _a.call(connection, "change", checkNetworkSpeed);
63
+ const intervalId = setInterval(checkNetworkSpeed, 15e3);
64
+ return () => {
65
+ var _a2;
66
+ clearInterval(intervalId);
67
+ (_a2 = connection == null ? void 0 : connection.removeEventListener) == null ? void 0 : _a2.call(connection, "change", checkNetworkSpeed);
68
+ };
69
+ }, []);
70
+ if (!isSlowNetwork) {
71
+ return null;
72
+ }
73
+ return /* @__PURE__ */ jsx(BannerContainerWrapper, { children: /* @__PURE__ */ jsxs(BannerContainer, { $maxWidth: maxWidth, children: [
74
+ /* @__PURE__ */ jsx(WarningIcon, { $size: iconSize, icon: "alertTriangle" }),
75
+ /* @__PURE__ */ jsx(BannerText, { $fontSize: fontSize, children: "Your network is slow. This may impact your experience." })
76
+ ] }) });
77
+ };
78
+ export {
79
+ NetworkSpeedBanner
80
+ };
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ import "../chunk-GOCCUU3Z.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
5
+ import { useCopyToClipboard } from "../hooks/index.js";
6
+ import { isMobile } from "@getpara/web-sdk";
7
+ import { safeStyled } from "../utils/index.js";
8
+ const QRCode = ({ link, imageSrc, icon, qrSize = 202, spinnerSize = 60 }) => {
9
+ const [isCopied, copy] = useCopyToClipboard();
10
+ const isMobileScreen = isMobile();
11
+ const handleCopy = () => {
12
+ copy(link);
13
+ };
14
+ return /* @__PURE__ */ jsxs(QRContainer, { $isMobile: isMobileScreen, children: [
15
+ isMobileScreen && /* @__PURE__ */ jsxs(MobileCopyButton, { fullWidth: true, onClick: handleCopy, children: [
16
+ /* @__PURE__ */ jsx(CopyIcon, { slot: "start", icon: isCopied ? "check" : "copy" }),
17
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyS", children: isCopied ? "Copied" : "Copy Link Instead" })
18
+ ] }),
19
+ !link ? /* @__PURE__ */ jsx(LoadingContainer, { $size: qrSize, children: /* @__PURE__ */ jsx(CpslSpinner, { size: spinnerSize }) }) : /* @__PURE__ */ jsx(StyledQRCode, { url: link, size: qrSize, icon, imageSrc }),
20
+ !isMobileScreen && /* @__PURE__ */ jsxs(CopyButton, { size: "small", onClick: handleCopy, children: [
21
+ /* @__PURE__ */ jsx(CopyIcon, { slot: "start", icon: isCopied ? "check" : "copy" }),
22
+ /* @__PURE__ */ jsx(CpslText, { variant: "body2XS", children: isCopied ? "Copied" : "Copy Link Instead" })
23
+ ] })
24
+ ] });
25
+ };
26
+ const QRContainer = safeStyled.div`
27
+ display: flex;
28
+ flex-direction: column;
29
+ justify-content: center;
30
+ align-items: center;
31
+ border: 1px solid;
32
+ border-color: var(--cpsl-color-background-16);
33
+ border-radius: 16px;
34
+ background-color: white;
35
+ overflow: hidden;
36
+ padding-bottom: ${({ $isMobile }) => $isMobile ? "0px" : "16px"};
37
+ padding-top: ${({ $isMobile }) => $isMobile ? "16px" : "0px"};
38
+ `;
39
+ const StyledQRCode = safeStyled(CpslQrCode)`
40
+ --qr-box-shadow: none;
41
+ --qr-border-radius: 0px;
42
+ `;
43
+ const CopyButton = safeStyled(CpslButton)`
44
+ --button-primary-color: var(--cpsl-color-text-contrast);
45
+ --button-primary-background-color: var(--cpsl-color-background-4);
46
+
47
+ --button-primary-hover-color: var(--cpsl-color-text-contrast);
48
+ --button-primary-hover-background-color: var(--cpsl-color-background-16);
49
+
50
+ --button-primary-active-color: var(--cpsl-color-text-contrast);
51
+ --button-primary-active-background-color: var(--cpsl-color-background-4);
52
+
53
+ --button-padding-start: 8px;
54
+ --button-padding-end: 8px;
55
+ --button-padding-top: 2px;
56
+ --button-padding-bottom: 2px;
57
+
58
+ --button-border-radius: 1000px;
59
+ `;
60
+ const MobileCopyButton = safeStyled(CopyButton)`
61
+ --button-padding-top: 4px;
62
+ --button-padding-bottom: 4px;
63
+
64
+ padding: 0px 12px;
65
+ `;
66
+ const CopyIcon = safeStyled(CpslIcon)`
67
+ --width: 16px;
68
+ --height: 16px;
69
+ --icon-color: var(--cpsl-color-text-contrast);
70
+ `;
71
+ const LoadingContainer = safeStyled.div`
72
+ display: flex;
73
+ justify-content: center;
74
+ align-items: center;
75
+ height: ${({ $size }) => `${$size}px`};
76
+ width: ${({ $size }) => `${$size}px`};
77
+ `;
78
+ export {
79
+ QRCode
80
+ };
@@ -1,4 +1,4 @@
1
- import { Props } from '../types/index.js';
2
- export declare const RampEmbed: ({ para, appName, onRampConfig, onRampPurchase, isEmbedded, apiKey, onClose, setOnRampPurchase, }: Props & {
1
+ import { OnRampProps } from '../types/index.js';
2
+ export declare const RampEmbed: ({ para, appName, onRampConfig, onRampPurchase, isEmbedded, apiKey, onClose, setOnRampPurchase, }: OnRampProps & {
3
3
  apiKey: string;
4
4
  }) => import("react/jsx-runtime").JSX.Element;