@getpara/react-common 1.7.1 → 2.0.0-alpha.3

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.
@@ -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: (partnerId?: string) => Promise<string>;
13
+ getPortalURL: () => Promise<string>;
17
14
  isProviderModalDisabled: () => boolean;
18
- supportedAuthMethods: (auth: import("@getpara/user-management-client").Auth) => Promise<Set<import("@getpara/web-sdk").AuthMethod>>;
19
- getUserBiometricLocationHints: () => Promise<import("@getpara/user-management-client").BiometricLocationHint[]>;
20
- exitLoops: () => void;
21
- exitLogin: () => void;
22
- exitAccountCreation: () => void;
23
- exitOAuth: () => void;
24
- exitFarcaster: () => void;
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
  }
@@ -1,2 +1,4 @@
1
- import { ModalAuthInfo } from '../types/index.js';
2
- export declare const UserIdentifier: ({ identifier, authType, displayName, pfpUrl }: ModalAuthInfo) => import("react/jsx-runtime").JSX.Element;
1
+ import { CoreAuthInfo } from '@getpara/web-sdk';
2
+ export declare const UserIdentifier: ({ authInfo }: {
3
+ authInfo?: CoreAuthInfo;
4
+ }) => import("react/jsx-runtime").JSX.Element;
package/dist/index.js CHANGED
@@ -44,20 +44,17 @@ import ParaWeb from "@getpara/web-sdk";
44
44
  var ParaInternal = class extends ParaWeb {
45
45
  constructor() {
46
46
  super(...arguments);
47
+ this.setupAfterLogin = super.setupAfterLogin;
47
48
  this.getSupportedCreateAuthMethods = super.getSupportedCreateAuthMethods;
48
- this.isUsingExternalWallet = super.isUsingExternalWallet;
49
49
  this.getTransmissionKeyShares = super.getTransmissionKeyShares;
50
50
  this.userSetupAfterLogin = super.userSetupAfterLogin;
51
51
  this.setLoginEncryptionKeyPair = super.setLoginEncryptionKeyPair;
52
52
  this.getPortalURL = super.getPortalURL;
53
53
  this.isProviderModalDisabled = super.isProviderModalDisabled;
54
+ this.setAuth = super.setAuth;
54
55
  this.supportedAuthMethods = super.supportedAuthMethods;
55
- this.getUserBiometricLocationHints = super.getUserBiometricLocationHints;
56
- this.exitLoops = super.exitLoops;
57
- this.exitLogin = super.exitLogin;
58
- this.exitAccountCreation = super.exitAccountCreation;
59
- this.exitOAuth = super.exitOAuth;
60
- this.exitFarcaster = super.exitFarcaster;
56
+ this.constructPortalUrl = super.constructPortalUrl;
57
+ this.getNewCredentialAndUrl = super.getNewCredentialAndUrl;
61
58
  }
62
59
  };
63
60
 
@@ -384,28 +381,6 @@ var formatBiometricHints = (hints) => {
384
381
  };
385
382
  };
386
383
 
387
- // src/utils/formatPhoneNumber.ts
388
- import parsePhoneNumberFromString from "libphonenumber-js";
389
- var formatPhoneNumber = (phone, countryCode) => {
390
- phone = phone.toString();
391
- countryCode = countryCode == null ? void 0 : countryCode.toString();
392
- let sanitizedNumber, parsedNumber;
393
- if (!!countryCode) {
394
- sanitizedNumber = phone.replace(/\D/g, "");
395
- if (/^\+\d+$/.test(countryCode)) {
396
- countryCode = countryCode.slice(1);
397
- }
398
- parsedNumber = parsePhoneNumberFromString(sanitizedNumber, { defaultCallingCode: countryCode });
399
- } else {
400
- sanitizedNumber = `${phone.startsWith("+") ? "" : "+"}${phone.replace(/[^\d+]/g, "")}`;
401
- parsedNumber = parsePhoneNumberFromString(sanitizedNumber);
402
- }
403
- if (parsedNumber == null ? void 0 : parsedNumber.isValid()) {
404
- return parsedNumber.formatInternational();
405
- }
406
- return null;
407
- };
408
-
409
384
  // src/utils/getExternalWalletDisplayName.ts
410
385
  import { truncateAddress, WalletType as WalletType2 } from "@getpara/web-sdk";
411
386
  var getExternalWalletDisplayName = ({ address, type }) => {
@@ -1182,41 +1157,34 @@ var DeviceLogo = styled6(CpslIcon3)`
1182
1157
  // src/components/UserIdentifier.tsx
1183
1158
  import { CpslAvatar, CpslIcon as CpslIcon4, CpslText as CpslText5 } from "@getpara/react-components";
1184
1159
  import styled7 from "styled-components";
1160
+ import { displayPhoneNumber } from "@getpara/web-sdk";
1185
1161
  import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1186
- function defaultDisplayName({ authType, identifier }) {
1162
+ function defaultDisplay(authInfo) {
1163
+ const { authType, identifier, externalWallet } = authInfo;
1187
1164
  switch (authType) {
1188
1165
  case "email":
1189
- return identifier.toLowerCase();
1166
+ return [identifier.toLowerCase(), "mail"];
1190
1167
  case "phone":
1191
- return formatPhoneNumber(identifier);
1168
+ return [displayPhoneNumber(identifier), "phone"];
1192
1169
  case "farcaster":
1193
- return `@${identifier}`;
1170
+ return [`@${identifier}`, "farcasterBrand"];
1194
1171
  case "telegram":
1195
- return `Telegram User @${identifier}`;
1172
+ return [`Telegram User @${identifier}`, "telegramBrand"];
1173
+ case "externalWallet":
1174
+ return [getExternalWalletDisplayName(externalWallet), "wallet"];
1196
1175
  default:
1197
- return null;
1176
+ return [null, null];
1198
1177
  }
1199
1178
  }
1200
- var UserIdentifier = ({ identifier, authType, displayName, pfpUrl }) => {
1201
- const shouldHideAvatar = authType === "externalWallet";
1202
- let icon;
1203
- switch (authType) {
1204
- case "email":
1205
- icon = "mail";
1206
- break;
1207
- case "phone":
1208
- icon = "phone";
1209
- break;
1210
- case "farcaster":
1211
- icon = "farcasterBrand";
1212
- break;
1213
- case "telegram":
1214
- icon = "telegramBrand";
1215
- break;
1179
+ var UserIdentifier = ({ authInfo }) => {
1180
+ if (!authInfo) {
1181
+ return null;
1216
1182
  }
1183
+ const { authType, displayName, pfpUrl } = authInfo;
1184
+ const [defaultName, defaultIcon] = defaultDisplay(authInfo);
1217
1185
  return /* @__PURE__ */ jsxs5(Container4, { children: [
1218
- !shouldHideAvatar && /* @__PURE__ */ jsx7(IconContainer, { children: pfpUrl ? /* @__PURE__ */ jsx7(Avatar, { src: pfpUrl, size: "20px" }) : /* @__PURE__ */ jsx7(Icon, { icon, size: authType === "telegram" ? "20px" : "13px" }) }),
1219
- /* @__PURE__ */ jsx7(IdentifierText, { variant: "bodyS", weight: "medium", children: displayName || defaultDisplayName({ authType, identifier }) })
1186
+ /* @__PURE__ */ jsx7(IconContainer, { children: pfpUrl ? /* @__PURE__ */ jsx7(Avatar, { src: pfpUrl, size: "20px", variant: "round" }) : /* @__PURE__ */ jsx7(Icon, { icon: defaultIcon, size: authType === "telegram" ? "20px" : "13px" }) }),
1187
+ /* @__PURE__ */ jsx7(IdentifierText, { variant: "bodyS", weight: "medium", children: displayName || defaultName })
1220
1188
  ] });
1221
1189
  };
1222
1190
  var Container4 = styled7.div`
@@ -1247,9 +1215,35 @@ var Avatar = styled7(CpslAvatar)`
1247
1215
  --container-border-width: 0;
1248
1216
  --container-padding: 0;
1249
1217
  `;
1218
+
1219
+ // src/types/externalWalletCommon.ts
1220
+ var EvmWallet = /* @__PURE__ */ ((EvmWallet2) => {
1221
+ EvmWallet2["METAMASK"] = "METAMASK";
1222
+ EvmWallet2["RAINBOW"] = "RAINBOW";
1223
+ EvmWallet2["COINBASE"] = "COINBASE";
1224
+ EvmWallet2["WALLETCONNECT"] = "WALLETCONNECT";
1225
+ EvmWallet2["ZERION"] = "ZERION";
1226
+ EvmWallet2["RABBY"] = "RABBY";
1227
+ return EvmWallet2;
1228
+ })(EvmWallet || {});
1229
+ var SolanaWallet = /* @__PURE__ */ ((SolanaWallet2) => {
1230
+ SolanaWallet2["PHANTOM"] = "PHANTOM";
1231
+ SolanaWallet2["GLOW"] = "GLOW";
1232
+ SolanaWallet2["BACKPACK"] = "BACKPACK";
1233
+ return SolanaWallet2;
1234
+ })(SolanaWallet || {});
1235
+ var CosmosWallet = /* @__PURE__ */ ((CosmosWallet2) => {
1236
+ CosmosWallet2["KEPLR"] = "KEPLR";
1237
+ CosmosWallet2["LEAP"] = "LEAP";
1238
+ return CosmosWallet2;
1239
+ })(CosmosWallet || {});
1240
+ var ExternalWallet = __spreadValues(__spreadValues(__spreadValues({}, EvmWallet), SolanaWallet), CosmosWallet);
1250
1241
  export {
1251
1242
  CenteredColumnContainer,
1252
1243
  CenteredText,
1244
+ CosmosWallet,
1245
+ EvmWallet,
1246
+ ExternalWallet,
1253
1247
  FilledDisabledInput,
1254
1248
  FullWidthFilledDisabledInput,
1255
1249
  HeaderButton,
@@ -1263,12 +1257,12 @@ export {
1263
1257
  RampEmbed,
1264
1258
  STRIPE_PUBLISHABLE_KEY,
1265
1259
  STRIPE_PUBLISHABLE_KEY_TEST,
1260
+ SolanaWallet,
1266
1261
  SpinnerContainer,
1267
1262
  StripeEmbed,
1268
1263
  TestNetworks,
1269
1264
  UserIdentifier,
1270
1265
  formatBiometricHints,
1271
- formatPhoneNumber,
1272
1266
  getAssetFromContractAddress,
1273
1267
  getBrowserName,
1274
1268
  getChainId,
package/dist/index.js.br CHANGED
Binary file
package/dist/index.js.gz CHANGED
Binary file
@@ -0,0 +1,79 @@
1
+ import { AuthStateLogin, AuthStateVerify, WalletType } 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: WalletType;
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
+ RABBY = "RABBY"
56
+ }
57
+ export declare enum SolanaWallet {
58
+ PHANTOM = "PHANTOM",
59
+ GLOW = "GLOW",
60
+ BACKPACK = "BACKPACK"
61
+ }
62
+ export declare enum CosmosWallet {
63
+ KEPLR = "KEPLR",
64
+ LEAP = "LEAP"
65
+ }
66
+ export declare const ExternalWallet: {
67
+ KEPLR: CosmosWallet.KEPLR;
68
+ LEAP: CosmosWallet.LEAP;
69
+ PHANTOM: SolanaWallet.PHANTOM;
70
+ GLOW: SolanaWallet.GLOW;
71
+ BACKPACK: SolanaWallet.BACKPACK;
72
+ METAMASK: EvmWallet.METAMASK;
73
+ RAINBOW: EvmWallet.RAINBOW;
74
+ COINBASE: EvmWallet.COINBASE;
75
+ WALLETCONNECT: EvmWallet.WALLETCONNECT;
76
+ ZERION: EvmWallet.ZERION;
77
+ RABBY: EvmWallet.RABBY;
78
+ };
79
+ export type TExternalWallet = keyof typeof ExternalWallet;
@@ -1,5 +1,6 @@
1
- import { ExtractAuth } from '@getpara/user-management-client';
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 = ExtractAuth & Partial<{
14
+ export type ModalAuthInfo = AuthInfo & Partial<{
14
15
  pfpUrl: string | null;
15
16
  displayName: string | null;
16
17
  }>;
@@ -32,5 +32,4 @@ export * from './getDeviceLogo.js';
32
32
  export * from './getDeviceModelName.js';
33
33
  export * from './getBrowserName.js';
34
34
  export * from './formatBiometricHints.js';
35
- export * from './formatPhoneNumber.js';
36
35
  export * from './getExternalWalletDisplayName.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-common",
3
- "version": "1.7.1",
3
+ "version": "2.0.0-alpha.3",
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": "1.7.1",
15
- "@getpara/web-sdk": "1.7.1",
14
+ "@getpara/react-components": "2.0.0-alpha.3",
15
+ "@getpara/web-sdk": "2.0.0-alpha.3",
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": "767395af96d4a724946a092de760e9137a73369a"
45
+ "gitHead": "77a1e04b06258842ca9c81e3db2a2b0092517659"
47
46
  }
package/dist/package.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "type": "module",
3
- "sideEffects": false
4
- }
@@ -1 +0,0 @@
1
- export declare const formatPhoneNumber: (phone: string, countryCode?: string) => string | null;