@getpara/react-common 1.12.0 → 2.0.0-alpha.10
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/classes/ParaInternal.d.ts +16 -16
- package/dist/classes/ParaInternal.js +4 -7
- package/dist/components/UserIdentifier.d.ts +4 -2
- package/dist/components/UserIdentifier.js +18 -25
- package/dist/types/externalWalletCommon.d.ts +81 -0
- package/dist/types/externalWalletCommon.js +32 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.js +1 -0
- package/dist/utils/getExternalWalletDisplayName.d.ts +2 -5
- package/dist/utils/getExternalWalletDisplayName.js +6 -6
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/index.js +0 -1
- package/dist/utils/offRampSend.js +3 -3
- package/package.json +5 -6
- package/dist/utils/formatPhoneNumber.d.ts +0 -1
- package/dist/utils/formatPhoneNumber.js +0 -25
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import ParaWeb from '@getpara/web-sdk';
|
|
2
2
|
export declare class ParaInternal extends ParaWeb {
|
|
3
|
+
setupAfterLogin: ({ temporaryShares, skipSessionRefresh, }?: {
|
|
4
|
+
temporaryShares?: any[];
|
|
5
|
+
skipSessionRefresh?: boolean;
|
|
6
|
+
}) => Promise<void>;
|
|
3
7
|
getSupportedCreateAuthMethods: () => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
|
|
4
|
-
isUsingExternalWallet: () => boolean;
|
|
5
8
|
getTransmissionKeyShares: ({ isForNewDevice }?: {
|
|
6
9
|
isForNewDevice?: boolean;
|
|
7
10
|
}) => Promise<any>;
|
|
8
|
-
userSetupAfterLogin: () => Promise<
|
|
9
|
-
data: {
|
|
10
|
-
partnerId?: string;
|
|
11
|
-
needsWallet?: boolean;
|
|
12
|
-
sessionLookupId: string;
|
|
13
|
-
};
|
|
14
|
-
}>;
|
|
11
|
+
userSetupAfterLogin: () => Promise<import("@getpara/user-management-client").SessionInfo>;
|
|
15
12
|
setLoginEncryptionKeyPair: (keyPair?: import("node-forge").pki.rsa.KeyPair) => Promise<void>;
|
|
16
|
-
getPortalURL: (
|
|
13
|
+
getPortalURL: () => Promise<string>;
|
|
17
14
|
isProviderModalDisabled: () => boolean;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
setAuth: (auth: import("@getpara/user-management-client").PrimaryAuth, { extras, userId }?: {
|
|
16
|
+
extras?: import("@getpara/web-sdk").AuthExtras;
|
|
17
|
+
userId?: string;
|
|
18
|
+
}) => Promise<typeof this.authInfo>;
|
|
19
|
+
supportedAuthMethods: (auth: import("@getpara/user-management-client").Auth<import("@getpara/user-management-client").PrimaryAuthType | "userId">) => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
|
|
20
|
+
constructPortalUrl: (type: import("@getpara/core-sdk/dist/types/types").PortalUrlType, opts?: import("@getpara/core-sdk/dist/types/types").PortalUrlOptions) => Promise<string>;
|
|
21
|
+
getNewCredentialAndUrl: ({ authMethod, isForNewDevice, portalTheme, shorten, }?: import("@getpara/core-sdk/dist/types/types").NewCredentialUrlParams) => Promise<{
|
|
22
|
+
credentialId: string;
|
|
23
|
+
url?: string;
|
|
24
|
+
}>;
|
|
25
25
|
}
|
|
@@ -4,20 +4,17 @@ import ParaWeb from "@getpara/web-sdk";
|
|
|
4
4
|
class ParaInternal extends ParaWeb {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
7
|
+
this.setupAfterLogin = super.setupAfterLogin;
|
|
7
8
|
this.getSupportedCreateAuthMethods = super.getSupportedCreateAuthMethods;
|
|
8
|
-
this.isUsingExternalWallet = super.isUsingExternalWallet;
|
|
9
9
|
this.getTransmissionKeyShares = super.getTransmissionKeyShares;
|
|
10
10
|
this.userSetupAfterLogin = super.userSetupAfterLogin;
|
|
11
11
|
this.setLoginEncryptionKeyPair = super.setLoginEncryptionKeyPair;
|
|
12
12
|
this.getPortalURL = super.getPortalURL;
|
|
13
13
|
this.isProviderModalDisabled = super.isProviderModalDisabled;
|
|
14
|
+
this.setAuth = super.setAuth;
|
|
14
15
|
this.supportedAuthMethods = super.supportedAuthMethods;
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.exitLogin = super.exitLogin;
|
|
18
|
-
this.exitAccountCreation = super.exitAccountCreation;
|
|
19
|
-
this.exitOAuth = super.exitOAuth;
|
|
20
|
-
this.exitFarcaster = super.exitFarcaster;
|
|
16
|
+
this.constructPortalUrl = super.constructPortalUrl;
|
|
17
|
+
this.getNewCredentialAndUrl = super.getNewCredentialAndUrl;
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
20
|
export {
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const UserIdentifier: ({
|
|
1
|
+
import { CoreAuthInfo } from '@getpara/web-sdk';
|
|
2
|
+
export declare const UserIdentifier: ({ authInfo }: {
|
|
3
|
+
authInfo?: CoreAuthInfo;
|
|
4
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,41 +3,34 @@ import "../chunk-GOCCUU3Z.js";
|
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { CpslAvatar, CpslIcon, CpslText } from "@getpara/react-components";
|
|
5
5
|
import styled from "styled-components";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { displayPhoneNumber } from "@getpara/web-sdk";
|
|
7
|
+
import { getExternalWalletDisplayName } from "../utils/index.js";
|
|
8
|
+
function defaultDisplay(authInfo) {
|
|
9
|
+
const { authType, identifier, externalWallet } = authInfo;
|
|
8
10
|
switch (authType) {
|
|
9
11
|
case "email":
|
|
10
|
-
return identifier.toLowerCase();
|
|
12
|
+
return { defaultName: identifier.toLowerCase(), defaultIcon: "mail" };
|
|
11
13
|
case "phone":
|
|
12
|
-
return
|
|
14
|
+
return { defaultName: displayPhoneNumber(identifier), defaultIcon: "phone" };
|
|
13
15
|
case "farcaster":
|
|
14
|
-
return `@${identifier}
|
|
16
|
+
return { defaultName: `@${identifier}`, defaultIcon: "farcasterBrand" };
|
|
15
17
|
case "telegram":
|
|
16
|
-
return `Telegram User @${identifier}
|
|
18
|
+
return { defaultName: `Telegram User @${identifier}`, defaultIcon: "telegramBrand" };
|
|
19
|
+
case "externalWallet":
|
|
20
|
+
return { defaultName: getExternalWalletDisplayName(externalWallet), defaultIcon: "wallet" };
|
|
17
21
|
default:
|
|
18
|
-
return null;
|
|
22
|
+
return { defaultName: null, defaultIcon: null };
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
|
-
const UserIdentifier = ({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
switch (authType) {
|
|
25
|
-
case "email":
|
|
26
|
-
icon = "mail";
|
|
27
|
-
break;
|
|
28
|
-
case "phone":
|
|
29
|
-
icon = "phone";
|
|
30
|
-
break;
|
|
31
|
-
case "farcaster":
|
|
32
|
-
icon = "farcasterBrand";
|
|
33
|
-
break;
|
|
34
|
-
case "telegram":
|
|
35
|
-
icon = "telegramBrand";
|
|
36
|
-
break;
|
|
25
|
+
const UserIdentifier = ({ authInfo }) => {
|
|
26
|
+
if (!authInfo) {
|
|
27
|
+
return null;
|
|
37
28
|
}
|
|
29
|
+
const { authType, displayName, pfpUrl } = authInfo;
|
|
30
|
+
const { defaultName, defaultIcon } = defaultDisplay(authInfo);
|
|
38
31
|
return /* @__PURE__ */ jsxs(Container, { children: [
|
|
39
|
-
|
|
40
|
-
/* @__PURE__ */ jsx(IdentifierText, { variant: "bodyS", weight: "medium", children: displayName ||
|
|
32
|
+
/* @__PURE__ */ jsx(IconContainer, { children: pfpUrl ? /* @__PURE__ */ jsx(Avatar, { src: pfpUrl, size: "20px", variant: "round" }) : /* @__PURE__ */ jsx(Icon, { icon: defaultIcon, size: authType === "telegram" ? "20px" : "13px" }) }),
|
|
33
|
+
/* @__PURE__ */ jsx(IdentifierText, { variant: "bodyS", weight: "medium", children: displayName || defaultName })
|
|
41
34
|
] });
|
|
42
35
|
};
|
|
43
36
|
const Container = styled.div`
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AuthStateLogin, AuthStateVerify, TWalletType } from '@getpara/web-sdk';
|
|
2
|
+
export type WalletMetadata = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
iconUrl: string;
|
|
6
|
+
rdns?: string;
|
|
7
|
+
installed?: boolean;
|
|
8
|
+
isExtension?: boolean;
|
|
9
|
+
isMobile?: boolean;
|
|
10
|
+
isWeb?: boolean;
|
|
11
|
+
downloadUrl?: string;
|
|
12
|
+
getQrUri?: () => Promise<string>;
|
|
13
|
+
downloadUrls?: {
|
|
14
|
+
android?: string;
|
|
15
|
+
ios?: string;
|
|
16
|
+
mobile?: string;
|
|
17
|
+
qrCode?: string;
|
|
18
|
+
chrome?: string;
|
|
19
|
+
edge?: string;
|
|
20
|
+
firefox?: string;
|
|
21
|
+
opera?: string;
|
|
22
|
+
safari?: string;
|
|
23
|
+
browserExtension?: string;
|
|
24
|
+
macos?: string;
|
|
25
|
+
windows?: string;
|
|
26
|
+
linux?: string;
|
|
27
|
+
desktop?: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type CommonWallet = {
|
|
31
|
+
connect: () => Promise<{
|
|
32
|
+
address?: string;
|
|
33
|
+
bufferAddress?: string;
|
|
34
|
+
error?: string;
|
|
35
|
+
authState?: AuthStateLogin | AuthStateVerify;
|
|
36
|
+
}>;
|
|
37
|
+
connectMobile: (isManualWalletConnect?: boolean) => Promise<{
|
|
38
|
+
address?: string;
|
|
39
|
+
bufferAddress?: string;
|
|
40
|
+
error?: string;
|
|
41
|
+
authState?: AuthStateLogin | AuthStateVerify;
|
|
42
|
+
}>;
|
|
43
|
+
type: TWalletType;
|
|
44
|
+
} & WalletMetadata;
|
|
45
|
+
export type CommonChain = {
|
|
46
|
+
id: string | number;
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
export declare enum EvmWallet {
|
|
50
|
+
METAMASK = "METAMASK",
|
|
51
|
+
RAINBOW = "RAINBOW",
|
|
52
|
+
COINBASE = "COINBASE",
|
|
53
|
+
WALLETCONNECT = "WALLETCONNECT",
|
|
54
|
+
ZERION = "ZERION",
|
|
55
|
+
SAFE = "SAFE",
|
|
56
|
+
RABBY = "RABBY"
|
|
57
|
+
}
|
|
58
|
+
export declare enum SolanaWallet {
|
|
59
|
+
PHANTOM = "PHANTOM",
|
|
60
|
+
GLOW = "GLOW",
|
|
61
|
+
BACKPACK = "BACKPACK"
|
|
62
|
+
}
|
|
63
|
+
export declare enum CosmosWallet {
|
|
64
|
+
KEPLR = "KEPLR",
|
|
65
|
+
LEAP = "LEAP"
|
|
66
|
+
}
|
|
67
|
+
export declare const ExternalWallet: {
|
|
68
|
+
KEPLR: CosmosWallet.KEPLR;
|
|
69
|
+
LEAP: CosmosWallet.LEAP;
|
|
70
|
+
PHANTOM: SolanaWallet.PHANTOM;
|
|
71
|
+
GLOW: SolanaWallet.GLOW;
|
|
72
|
+
BACKPACK: SolanaWallet.BACKPACK;
|
|
73
|
+
METAMASK: EvmWallet.METAMASK;
|
|
74
|
+
RAINBOW: EvmWallet.RAINBOW;
|
|
75
|
+
COINBASE: EvmWallet.COINBASE;
|
|
76
|
+
WALLETCONNECT: EvmWallet.WALLETCONNECT;
|
|
77
|
+
ZERION: EvmWallet.ZERION;
|
|
78
|
+
SAFE: EvmWallet.SAFE;
|
|
79
|
+
RABBY: EvmWallet.RABBY;
|
|
80
|
+
};
|
|
81
|
+
export type TExternalWallet = keyof typeof ExternalWallet;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../chunk-GOCCUU3Z.js";
|
|
5
|
+
var EvmWallet = /* @__PURE__ */ ((EvmWallet2) => {
|
|
6
|
+
EvmWallet2["METAMASK"] = "METAMASK";
|
|
7
|
+
EvmWallet2["RAINBOW"] = "RAINBOW";
|
|
8
|
+
EvmWallet2["COINBASE"] = "COINBASE";
|
|
9
|
+
EvmWallet2["WALLETCONNECT"] = "WALLETCONNECT";
|
|
10
|
+
EvmWallet2["ZERION"] = "ZERION";
|
|
11
|
+
EvmWallet2["SAFE"] = "SAFE";
|
|
12
|
+
EvmWallet2["RABBY"] = "RABBY";
|
|
13
|
+
return EvmWallet2;
|
|
14
|
+
})(EvmWallet || {});
|
|
15
|
+
var SolanaWallet = /* @__PURE__ */ ((SolanaWallet2) => {
|
|
16
|
+
SolanaWallet2["PHANTOM"] = "PHANTOM";
|
|
17
|
+
SolanaWallet2["GLOW"] = "GLOW";
|
|
18
|
+
SolanaWallet2["BACKPACK"] = "BACKPACK";
|
|
19
|
+
return SolanaWallet2;
|
|
20
|
+
})(SolanaWallet || {});
|
|
21
|
+
var CosmosWallet = /* @__PURE__ */ ((CosmosWallet2) => {
|
|
22
|
+
CosmosWallet2["KEPLR"] = "KEPLR";
|
|
23
|
+
CosmosWallet2["LEAP"] = "LEAP";
|
|
24
|
+
return CosmosWallet2;
|
|
25
|
+
})(CosmosWallet || {});
|
|
26
|
+
const ExternalWallet = __spreadValues(__spreadValues(__spreadValues({}, EvmWallet), SolanaWallet), CosmosWallet);
|
|
27
|
+
export {
|
|
28
|
+
CosmosWallet,
|
|
29
|
+
EvmWallet,
|
|
30
|
+
ExternalWallet,
|
|
31
|
+
SolanaWallet
|
|
32
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthInfo } from '@getpara/user-management-client';
|
|
2
2
|
import ParaWeb, { type OnRampConfig, type OnRampPurchase } from '@getpara/web-sdk';
|
|
3
|
+
export * from './externalWalletCommon.js';
|
|
3
4
|
export type Props = {
|
|
4
5
|
appName?: string;
|
|
5
6
|
para: ParaWeb;
|
|
@@ -10,7 +11,7 @@ export type Props = {
|
|
|
10
11
|
onRampPurchase: OnRampPurchase;
|
|
11
12
|
setOnRampPurchase?: (_: OnRampPurchase) => void;
|
|
12
13
|
};
|
|
13
|
-
export type ModalAuthInfo =
|
|
14
|
+
export type ModalAuthInfo = AuthInfo & Partial<{
|
|
14
15
|
pfpUrl: string | null;
|
|
15
16
|
displayName: string | null;
|
|
16
17
|
}>;
|
package/dist/types/index.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const getExternalWalletDisplayName: ({ address, type }:
|
|
3
|
-
address: string;
|
|
4
|
-
type: WalletType;
|
|
5
|
-
}) => string;
|
|
1
|
+
import { ExternalWalletInfo } from '@getpara/user-management-client';
|
|
2
|
+
export declare const getExternalWalletDisplayName: ({ address, type, addressBech32 }: ExternalWalletInfo) => string;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../chunk-GOCCUU3Z.js";
|
|
3
|
-
import { truncateAddress
|
|
4
|
-
const getExternalWalletDisplayName = ({ address, type }) => {
|
|
3
|
+
import { truncateAddress } from "@getpara/web-sdk";
|
|
4
|
+
const getExternalWalletDisplayName = ({ address, type, addressBech32 }) => {
|
|
5
5
|
const walletType = type;
|
|
6
6
|
let walletTypeDisplay;
|
|
7
7
|
switch (walletType) {
|
|
8
|
-
case
|
|
8
|
+
case "EVM":
|
|
9
9
|
walletTypeDisplay = "EVM";
|
|
10
10
|
break;
|
|
11
|
-
case
|
|
11
|
+
case "SOLANA":
|
|
12
12
|
walletTypeDisplay = "Solana";
|
|
13
13
|
break;
|
|
14
|
-
case
|
|
14
|
+
case "COSMOS":
|
|
15
15
|
walletTypeDisplay = "Cosmos";
|
|
16
16
|
break;
|
|
17
17
|
}
|
|
18
|
-
return `${walletTypeDisplay} ${truncateAddress(address, walletType)}`;
|
|
18
|
+
return `${walletTypeDisplay} ${truncateAddress(addressBech32 != null ? addressBech32 : address, walletType)}`;
|
|
19
19
|
};
|
|
20
20
|
export {
|
|
21
21
|
getExternalWalletDisplayName
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OnRampAsset, OnRampAssetInfo, OnRampProvider, Network, OnRampPurchaseType, OnRampConfig,
|
|
1
|
+
import { OnRampAsset, OnRampAssetInfo, OnRampProvider, Network, OnRampPurchaseType, OnRampConfig, TWalletType } from '@getpara/web-sdk';
|
|
2
2
|
export declare function getCurrencyCode({ assetInfo }: OnRampConfig, { network, asset, provider }: {
|
|
3
3
|
network: Network;
|
|
4
4
|
asset: OnRampAsset;
|
|
@@ -7,7 +7,7 @@ export declare function getCurrencyCode({ assetInfo }: OnRampConfig, { network,
|
|
|
7
7
|
export declare function getCurrencyCodes({ assetInfo, allowedAssets, defaultOnRampNetwork, defaultOnRampAsset }: OnRampConfig, { provider, purchaseType, walletType, }: {
|
|
8
8
|
provider: OnRampProvider;
|
|
9
9
|
purchaseType: OnRampPurchaseType;
|
|
10
|
-
walletType:
|
|
10
|
+
walletType: TWalletType;
|
|
11
11
|
}): {
|
|
12
12
|
currencyCodes: string[];
|
|
13
13
|
defaultCurrencyCode?: string;
|
|
@@ -37,5 +37,4 @@ export * from './getDeviceLogo.js';
|
|
|
37
37
|
export * from './getDeviceModelName.js';
|
|
38
38
|
export * from './getBrowserName.js';
|
|
39
39
|
export * from './formatBiometricHints.js';
|
|
40
|
-
export * from './formatPhoneNumber.js';
|
|
41
40
|
export * from './getExternalWalletDisplayName.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -107,7 +107,6 @@ export * from "./getDeviceLogo.js";
|
|
|
107
107
|
export * from "./getDeviceModelName.js";
|
|
108
108
|
export * from "./getBrowserName.js";
|
|
109
109
|
export * from "./formatBiometricHints.js";
|
|
110
|
-
export * from "./formatPhoneNumber.js";
|
|
111
110
|
export * from "./getExternalWalletDisplayName.js";
|
|
112
111
|
export {
|
|
113
112
|
NetworkAssetAddresses,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
__async
|
|
4
4
|
} from "../chunk-GOCCUU3Z.js";
|
|
5
|
-
import { hexStringToBase64
|
|
5
|
+
import { hexStringToBase64 } from "@getpara/web-sdk";
|
|
6
6
|
function offRampSend(_0, _1, _2, _3) {
|
|
7
7
|
return __async(this, arguments, function* (para, { id: purchaseId, provider, walletId, walletType, address, testMode = false }, setOnRampPurchase, {
|
|
8
8
|
assetQuantity,
|
|
@@ -30,14 +30,14 @@ function offRampSend(_0, _1, _2, _3) {
|
|
|
30
30
|
});
|
|
31
31
|
let signature;
|
|
32
32
|
switch (walletType) {
|
|
33
|
-
case
|
|
33
|
+
case "EVM":
|
|
34
34
|
signature = (_a = yield para.signTransaction({
|
|
35
35
|
walletId,
|
|
36
36
|
rlpEncodedTxBase64: hexStringToBase64(tx),
|
|
37
37
|
chainId
|
|
38
38
|
})) == null ? void 0 : _a.signature;
|
|
39
39
|
break;
|
|
40
|
-
case
|
|
40
|
+
case "SOLANA":
|
|
41
41
|
signature = (_b = yield para.signMessage({ walletId, messageBase64: message })) == null ? void 0 : _b.signature;
|
|
42
42
|
break;
|
|
43
43
|
default:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"*.css"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@getpara/react-components": "
|
|
15
|
-
"@getpara/web-sdk": "
|
|
14
|
+
"@getpara/react-components": "2.0.0-alpha.10",
|
|
15
|
+
"@getpara/web-sdk": "2.0.0-alpha.10",
|
|
16
16
|
"@moonpay/moonpay-react": "^1.8.3",
|
|
17
17
|
"@ramp-network/ramp-instant-sdk": "^4.0.5",
|
|
18
18
|
"@stripe/crypto": "^0.0.4",
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs",
|
|
26
|
-
"typegen": "tsc --emitDeclarationOnly"
|
|
27
|
-
"test": "vitest run --coverage"
|
|
26
|
+
"typegen": "tsc --emitDeclarationOnly"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
29
|
"@types/react": "^18.0.31",
|
|
@@ -43,5 +42,5 @@
|
|
|
43
42
|
"resolutions": {
|
|
44
43
|
"styled-components": "^6"
|
|
45
44
|
},
|
|
46
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "92904c321f1dd8101046d8d2d70aa341bac99842"
|
|
47
46
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const formatPhoneNumber: (phone: string, countryCode?: string) => string | null;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../chunk-GOCCUU3Z.js";
|
|
3
|
-
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
4
|
-
const formatPhoneNumber = (phone, countryCode) => {
|
|
5
|
-
phone = phone.toString();
|
|
6
|
-
countryCode = countryCode == null ? void 0 : countryCode.toString();
|
|
7
|
-
let sanitizedNumber, parsedNumber;
|
|
8
|
-
if (!!countryCode) {
|
|
9
|
-
sanitizedNumber = phone.replace(/\D/g, "");
|
|
10
|
-
if (/^\+\d+$/.test(countryCode)) {
|
|
11
|
-
countryCode = countryCode.slice(1);
|
|
12
|
-
}
|
|
13
|
-
parsedNumber = parsePhoneNumberFromString(sanitizedNumber, { defaultCallingCode: countryCode });
|
|
14
|
-
} else {
|
|
15
|
-
sanitizedNumber = `${phone.startsWith("+") ? "" : "+"}${phone.replace(/[^\d+]/g, "")}`;
|
|
16
|
-
parsedNumber = parsePhoneNumberFromString(sanitizedNumber);
|
|
17
|
-
}
|
|
18
|
-
if (parsedNumber == null ? void 0 : parsedNumber.isValid()) {
|
|
19
|
-
return parsedNumber.formatInternational();
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
formatPhoneNumber
|
|
25
|
-
};
|