@b3dotfun/sdk 0.1.70-alpha.4 → 0.1.70-alpha.5
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/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +1 -3
- package/dist/cjs/global-account/react/components/index.d.ts +0 -1
- package/dist/cjs/global-account/react/components/index.js +3 -5
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
- package/dist/cjs/global-account/react/hooks/index.js +2 -4
- package/dist/cjs/global-account/types/b3-api.types.d.ts +5 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +1 -3
- package/dist/esm/global-account/react/components/index.d.ts +0 -1
- package/dist/esm/global-account/react/components/index.js +0 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -1
- package/dist/esm/global-account/react/hooks/index.js +0 -1
- package/dist/esm/global-account/types/b3-api.types.d.ts +5 -0
- package/dist/types/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
- package/dist/types/global-account/react/components/index.d.ts +0 -1
- package/dist/types/global-account/react/hooks/index.d.ts +0 -1
- package/dist/types/global-account/types/b3-api.types.d.ts +5 -0
- package/package.json +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +1 -4
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +2 -4
- package/src/global-account/react/components/index.ts +0 -1
- package/src/global-account/react/hooks/index.ts +0 -1
- package/src/global-account/types/b3-api.types.ts +5 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -46
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -70
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -43
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -67
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
- package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +0 -63
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +0 -79
|
@@ -7,7 +7,6 @@ const LoginStepBetterAuth_1 = require("./steps/LoginStepBetterAuth");
|
|
|
7
7
|
const debug_1 = require("../../../../shared/utils/debug");
|
|
8
8
|
const react_2 = require("react");
|
|
9
9
|
const react_3 = require("thirdweb/react");
|
|
10
|
-
const SignInWithB3Privy_1 = require("./SignInWithB3Privy");
|
|
11
10
|
const LoginStep_1 = require("./steps/LoginStep");
|
|
12
11
|
const LoginStepCustom_1 = require("./steps/LoginStepCustom");
|
|
13
12
|
const debug = (0, debug_1.debugB3React)("SignInWithB3Flow");
|
|
@@ -254,10 +253,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
254
253
|
}
|
|
255
254
|
else {
|
|
256
255
|
// Custom strategy
|
|
257
|
-
if (strategies
|
|
258
|
-
content = (0, jsx_runtime_1.jsx)(SignInWithB3Privy_1.SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
259
|
-
}
|
|
260
|
-
else if (strategies) {
|
|
256
|
+
if (strategies) {
|
|
261
257
|
// Strategies are explicitly provided
|
|
262
258
|
content = ((0, jsx_runtime_1.jsx)(LoginStepCustom_1.LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
263
259
|
}
|
|
@@ -2,10 +2,11 @@ import { Chain } from "thirdweb";
|
|
|
2
2
|
import { SingleStepAuthArgsType, Wallet } from "thirdweb/wallets";
|
|
3
3
|
type WalletType = Wallet["id"];
|
|
4
4
|
type StrategyType = SingleStepAuthArgsType["strategy"];
|
|
5
|
-
|
|
5
|
+
declare const customStrategies: readonly ["basement"];
|
|
6
|
+
type CustomStrategyType = (typeof customStrategies)[number];
|
|
6
7
|
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType | "email";
|
|
7
8
|
type NonWalletStrategyType = Exclude<AllowedStrategies, WalletType>;
|
|
8
|
-
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement"
|
|
9
|
+
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement"];
|
|
9
10
|
export type AllowedStrategy = (typeof allowedStrategies)[number];
|
|
10
11
|
export declare function isWalletType(strategy: AllowedStrategies): strategy is WalletType;
|
|
11
12
|
export declare function isStrategyType(strategy: AllowedStrategies): strategy is NonWalletStrategyType;
|
|
@@ -5,8 +5,7 @@ exports.isWalletType = isWalletType;
|
|
|
5
5
|
exports.isStrategyType = isStrategyType;
|
|
6
6
|
exports.getConnectOptionsFromStrategy = getConnectOptionsFromStrategy;
|
|
7
7
|
const wallets_1 = require("thirdweb/wallets");
|
|
8
|
-
const customStrategies = ["basement"
|
|
9
|
-
// type CustomStrategy = (typeof customStrategies)[number];
|
|
8
|
+
const customStrategies = ["basement"];
|
|
10
9
|
exports.allowedStrategies = [
|
|
11
10
|
// Auth strategies
|
|
12
11
|
"apple",
|
|
@@ -21,7 +20,6 @@ exports.allowedStrategies = [
|
|
|
21
20
|
"io.metamask",
|
|
22
21
|
"com.coinbase.wallet",
|
|
23
22
|
// Custom strategies
|
|
24
|
-
// TODO: Audit we don't use "privy" directly anymore
|
|
25
23
|
...customStrategies,
|
|
26
24
|
];
|
|
27
25
|
function isWalletType(strategy) {
|
|
@@ -14,7 +14,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
|
14
14
|
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
15
15
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
|
|
16
16
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
17
|
-
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
18
17
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
19
18
|
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
20
19
|
export { ManageAccount } from "./ManageAccount/ManageAccount";
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CommandShortcut = exports.CommandSeparator = exports.CommandList = exports.CommandItem = exports.CommandInput = exports.CommandGroup = exports.CommandEmpty = exports.CommandDialog = exports.Command = exports.buttonVariants = exports.Button = exports.badgeVariants = exports.Badge = exports.WalletConnectorIcon = exports.StaggeredFadeLoader = exports.CopyToClipboard = exports.ClientOnly = exports.customButtonVariants = exports.CustomButton = exports.SingleUserSearchSelector = exports.SendERC20Button = exports.SendETHButton = exports.MintButton = exports.AccountAssets = exports.RequestPermissionsButton = exports.RequestPermissions = exports.IPFSMediaRenderer = exports.Send = exports.Deposit = exports.UserAvatar = exports.ManageAccount = exports.isWalletType = exports.getConnectOptionsFromStrategy = exports.LoginStepContainer = exports.
|
|
7
|
-
exports.TooltipProvider = exports.TooltipContent = exports.Tooltip = exports.TextShimmer = exports.TextLoop = exports.TabTrigger = exports.TabsTransitionWrapper = exports.TabsList = exports.TabsContent = exports.Tabs = exports.TabTriggerPrimitive = exports.TabsPrimitive = exports.TabsListPrimitive = exports.TabsContentPrimitive = exports.Skeleton = exports.ShinyButton = exports.ScrollBar = exports.ScrollArea = exports.PopoverTrigger = exports.PopoverContent = exports.Popover = exports.Loading = exports.Input = exports.GlareCardRounded = exports.GlareCard = exports.DropdownMenuTrigger = exports.DropdownMenuSeparator = exports.DropdownMenuItem = exports.DropdownMenuContent = exports.DropdownMenu = exports.DrawerTrigger = exports.DrawerTitle = exports.DrawerPortal = exports.DrawerOverlay = exports.DrawerHeader = exports.DrawerFooter = exports.DrawerDescription = exports.DrawerContent = exports.DrawerClose = exports.Drawer = exports.DialogTrigger = exports.DialogTitle = exports.DialogPortal = exports.DialogOverlay = exports.DialogHeader = exports.DialogFooter = exports.DialogDescription = exports.DialogContent = exports.DialogClose =
|
|
8
|
-
exports.WalletImage = exports.useToastContext = exports.ToastProvider = exports.ToastContainer = exports.Toast = exports.toast = exports.AnimatedLottie = exports.TransitionPanel =
|
|
6
|
+
exports.Dialog = exports.CommandShortcut = exports.CommandSeparator = exports.CommandList = exports.CommandItem = exports.CommandInput = exports.CommandGroup = exports.CommandEmpty = exports.CommandDialog = exports.Command = exports.buttonVariants = exports.Button = exports.badgeVariants = exports.Badge = exports.WalletConnectorIcon = exports.StaggeredFadeLoader = exports.CopyToClipboard = exports.ClientOnly = exports.customButtonVariants = exports.CustomButton = exports.SingleUserSearchSelector = exports.SendERC20Button = exports.SendETHButton = exports.MintButton = exports.AccountAssets = exports.RequestPermissionsButton = exports.RequestPermissions = exports.IPFSMediaRenderer = exports.Send = exports.Deposit = exports.UserAvatar = exports.ManageAccount = exports.isWalletType = exports.getConnectOptionsFromStrategy = exports.LoginStepContainer = exports.SignInWithB3Flow = exports.SignInWithB3 = exports.WalletRow = exports.PermissionItem = exports.AuthButton = exports.BetterAuthVerifyEmail = exports.BetterAuthSignIn = exports.BetterAuthResetPassword = exports.StyleRoot = exports.useB3Config = exports.useB3Account = exports.useB3 = exports.RelayKitProviderWrapper = exports.B3Provider = exports.B3DynamicModal = void 0;
|
|
7
|
+
exports.TooltipTrigger = exports.TooltipProvider = exports.TooltipContent = exports.Tooltip = exports.TextShimmer = exports.TextLoop = exports.TabTrigger = exports.TabsTransitionWrapper = exports.TabsList = exports.TabsContent = exports.Tabs = exports.TabTriggerPrimitive = exports.TabsPrimitive = exports.TabsListPrimitive = exports.TabsContentPrimitive = exports.Skeleton = exports.ShinyButton = exports.ScrollBar = exports.ScrollArea = exports.PopoverTrigger = exports.PopoverContent = exports.Popover = exports.Loading = exports.Input = exports.GlareCardRounded = exports.GlareCard = exports.DropdownMenuTrigger = exports.DropdownMenuSeparator = exports.DropdownMenuItem = exports.DropdownMenuContent = exports.DropdownMenu = exports.DrawerTrigger = exports.DrawerTitle = exports.DrawerPortal = exports.DrawerOverlay = exports.DrawerHeader = exports.DrawerFooter = exports.DrawerDescription = exports.DrawerContent = exports.DrawerClose = exports.Drawer = exports.DialogTrigger = exports.DialogTitle = exports.DialogPortal = exports.DialogOverlay = exports.DialogHeader = exports.DialogFooter = exports.DialogDescription = exports.DialogContent = exports.DialogClose = void 0;
|
|
8
|
+
exports.WalletImage = exports.useToastContext = exports.ToastProvider = exports.ToastContainer = exports.Toast = exports.toast = exports.AnimatedLottie = exports.TransitionPanel = void 0;
|
|
9
9
|
// TODO woj: Barrel file for all components, this might be reason of bundle size issues
|
|
10
10
|
// Core Components
|
|
11
11
|
var B3DynamicModal_1 = require("./B3DynamicModal");
|
|
@@ -39,8 +39,6 @@ var SignInWithB3_1 = require("./SignInWithB3/SignInWithB3");
|
|
|
39
39
|
Object.defineProperty(exports, "SignInWithB3", { enumerable: true, get: function () { return SignInWithB3_1.SignInWithB3; } });
|
|
40
40
|
var SignInWithB3Flow_1 = require("./SignInWithB3/SignInWithB3Flow");
|
|
41
41
|
Object.defineProperty(exports, "SignInWithB3Flow", { enumerable: true, get: function () { return SignInWithB3Flow_1.SignInWithB3Flow; } });
|
|
42
|
-
var SignInWithB3Privy_1 = require("./SignInWithB3/SignInWithB3Privy");
|
|
43
|
-
Object.defineProperty(exports, "SignInWithB3Privy", { enumerable: true, get: function () { return SignInWithB3Privy_1.SignInWithB3Privy; } });
|
|
44
42
|
var LoginStep_1 = require("./SignInWithB3/steps/LoginStep");
|
|
45
43
|
Object.defineProperty(exports, "LoginStepContainer", { enumerable: true, get: function () { return LoginStep_1.LoginStepContainer; } });
|
|
46
44
|
var signInUtils_1 = require("./SignInWithB3/utils/signInUtils");
|
|
@@ -17,7 +17,6 @@ export { useFirstEOA } from "./useFirstEOA";
|
|
|
17
17
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
18
18
|
export { useGetGeo } from "./useGetGeo";
|
|
19
19
|
export { useGlobalAccount } from "./useGlobalAccount";
|
|
20
|
-
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
21
20
|
export { useHasMounted } from "./useHasMounted";
|
|
22
21
|
export { useIsMobile } from "./useIsMobile";
|
|
23
22
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimCollectibles = exports.useSimTokenBalance = exports.useSimSvmBalance = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfileSettings = exports.useProfilePreference = exports.useProfile = exports.useDisplayName = exports.useOneBalance = exports.useNotifications = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.
|
|
18
|
-
exports.useUser = exports.useURLParams =
|
|
17
|
+
exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimCollectibles = exports.useSimTokenBalance = exports.useSimSvmBalance = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfileSettings = exports.useProfilePreference = exports.useProfile = exports.useDisplayName = exports.useOneBalance = exports.useNotifications = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.EmailVerificationRequiredError = exports.useBetterAuth = exports.useAuthentication = exports.useAuth = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = exports.createWagmiConfig = void 0;
|
|
18
|
+
exports.useUser = exports.useURLParams = void 0;
|
|
19
19
|
var createWagmiConfig_1 = require("../utils/createWagmiConfig");
|
|
20
20
|
Object.defineProperty(exports, "createWagmiConfig", { enumerable: true, get: function () { return createWagmiConfig_1.createWagmiConfig; } });
|
|
21
21
|
var useAccountAssets_1 = require("./useAccountAssets");
|
|
@@ -54,8 +54,6 @@ var useGetGeo_1 = require("./useGetGeo");
|
|
|
54
54
|
Object.defineProperty(exports, "useGetGeo", { enumerable: true, get: function () { return useGetGeo_1.useGetGeo; } });
|
|
55
55
|
var useGlobalAccount_1 = require("./useGlobalAccount");
|
|
56
56
|
Object.defineProperty(exports, "useGlobalAccount", { enumerable: true, get: function () { return useGlobalAccount_1.useGlobalAccount; } });
|
|
57
|
-
var useHandleConnectWithPrivy_1 = require("./useHandleConnectWithPrivy");
|
|
58
|
-
Object.defineProperty(exports, "useHandleConnectWithPrivy", { enumerable: true, get: function () { return useHandleConnectWithPrivy_1.useHandleConnectWithPrivy; } });
|
|
59
57
|
var useHasMounted_1 = require("./useHasMounted");
|
|
60
58
|
Object.defineProperty(exports, "useHasMounted", { enumerable: true, get: function () { return useHasMounted_1.useHasMounted; } });
|
|
61
59
|
var useIsMobile_1 = require("./useIsMobile");
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
type ObjectId = string;
|
|
5
5
|
interface PartnerIds {
|
|
6
|
+
/** @deprecated Privy is no longer used for authentication. This field exists for legacy data compatibility only. */
|
|
6
7
|
privyId?: string;
|
|
7
8
|
thirdwebId?: string;
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Privy is no longer used for authentication. This type exists for legacy data compatibility only.
|
|
12
|
+
*/
|
|
9
13
|
interface PrivyLinkedAccount {
|
|
10
14
|
type: string;
|
|
11
15
|
address?: string;
|
|
@@ -45,6 +49,7 @@ interface User {
|
|
|
45
49
|
createdAt: number;
|
|
46
50
|
updatedAt: number;
|
|
47
51
|
partnerIds: PartnerIds;
|
|
52
|
+
/** @deprecated Privy is no longer used for authentication. This field exists for legacy data compatibility only. */
|
|
48
53
|
privyLinkedAccounts?: PrivyLinkedAccount[];
|
|
49
54
|
twProfiles?: TWProfile[];
|
|
50
55
|
}
|
|
@@ -4,7 +4,6 @@ import { LoginStepBetterAuth } from "./steps/LoginStepBetterAuth.js";
|
|
|
4
4
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
5
5
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
6
6
|
import { useActiveAccount } from "thirdweb/react";
|
|
7
|
-
import { SignInWithB3Privy } from "./SignInWithB3Privy.js";
|
|
8
7
|
import { LoginStep, LoginStepContainer } from "./steps/LoginStep.js";
|
|
9
8
|
import { LoginStepCustom } from "./steps/LoginStepCustom.js";
|
|
10
9
|
const debug = debugB3React("SignInWithB3Flow");
|
|
@@ -251,10 +250,7 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
251
250
|
}
|
|
252
251
|
else {
|
|
253
252
|
// Custom strategy
|
|
254
|
-
if (strategies
|
|
255
|
-
content = _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
256
|
-
}
|
|
257
|
-
else if (strategies) {
|
|
253
|
+
if (strategies) {
|
|
258
254
|
// Strategies are explicitly provided
|
|
259
255
|
content = (_jsx(LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
260
256
|
}
|
|
@@ -2,10 +2,11 @@ import { Chain } from "thirdweb";
|
|
|
2
2
|
import { SingleStepAuthArgsType, Wallet } from "thirdweb/wallets";
|
|
3
3
|
type WalletType = Wallet["id"];
|
|
4
4
|
type StrategyType = SingleStepAuthArgsType["strategy"];
|
|
5
|
-
|
|
5
|
+
declare const customStrategies: readonly ["basement"];
|
|
6
|
+
type CustomStrategyType = (typeof customStrategies)[number];
|
|
6
7
|
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType | "email";
|
|
7
8
|
type NonWalletStrategyType = Exclude<AllowedStrategies, WalletType>;
|
|
8
|
-
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement"
|
|
9
|
+
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement"];
|
|
9
10
|
export type AllowedStrategy = (typeof allowedStrategies)[number];
|
|
10
11
|
export declare function isWalletType(strategy: AllowedStrategies): strategy is WalletType;
|
|
11
12
|
export declare function isStrategyType(strategy: AllowedStrategies): strategy is NonWalletStrategyType;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createWallet } from "thirdweb/wallets";
|
|
2
|
-
const customStrategies = ["basement"
|
|
3
|
-
// type CustomStrategy = (typeof customStrategies)[number];
|
|
2
|
+
const customStrategies = ["basement"];
|
|
4
3
|
export const allowedStrategies = [
|
|
5
4
|
// Auth strategies
|
|
6
5
|
"apple",
|
|
@@ -15,7 +14,6 @@ export const allowedStrategies = [
|
|
|
15
14
|
"io.metamask",
|
|
16
15
|
"com.coinbase.wallet",
|
|
17
16
|
// Custom strategies
|
|
18
|
-
// TODO: Audit we don't use "privy" directly anymore
|
|
19
17
|
...customStrategies,
|
|
20
18
|
];
|
|
21
19
|
export function isWalletType(strategy) {
|
|
@@ -14,7 +14,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
|
14
14
|
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
15
15
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
|
|
16
16
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
17
|
-
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
18
17
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
19
18
|
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
20
19
|
export { ManageAccount } from "./ManageAccount/ManageAccount";
|
|
@@ -16,7 +16,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem.js";
|
|
|
16
16
|
export { WalletRow } from "./SignInWithB3/components/WalletRow.js";
|
|
17
17
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3.js";
|
|
18
18
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow.js";
|
|
19
|
-
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy.js";
|
|
20
19
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep.js";
|
|
21
20
|
export { getConnectOptionsFromStrategy, isWalletType } from "./SignInWithB3/utils/signInUtils.js";
|
|
22
21
|
// ManageAccount Components
|
|
@@ -17,7 +17,6 @@ export { useFirstEOA } from "./useFirstEOA";
|
|
|
17
17
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
18
18
|
export { useGetGeo } from "./useGetGeo";
|
|
19
19
|
export { useGlobalAccount } from "./useGlobalAccount";
|
|
20
|
-
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
21
20
|
export { useHasMounted } from "./useHasMounted";
|
|
22
21
|
export { useIsMobile } from "./useIsMobile";
|
|
23
22
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
@@ -17,7 +17,6 @@ export { useFirstEOA } from "./useFirstEOA.js";
|
|
|
17
17
|
export { useGetAllTWSigners } from "./useGetAllTWSigners.js";
|
|
18
18
|
export { useGetGeo } from "./useGetGeo.js";
|
|
19
19
|
export { useGlobalAccount } from "./useGlobalAccount.js";
|
|
20
|
-
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy.js";
|
|
21
20
|
export { useHasMounted } from "./useHasMounted.js";
|
|
22
21
|
export { useIsMobile } from "./useIsMobile.js";
|
|
23
22
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
type ObjectId = string;
|
|
5
5
|
interface PartnerIds {
|
|
6
|
+
/** @deprecated Privy is no longer used for authentication. This field exists for legacy data compatibility only. */
|
|
6
7
|
privyId?: string;
|
|
7
8
|
thirdwebId?: string;
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Privy is no longer used for authentication. This type exists for legacy data compatibility only.
|
|
12
|
+
*/
|
|
9
13
|
interface PrivyLinkedAccount {
|
|
10
14
|
type: string;
|
|
11
15
|
address?: string;
|
|
@@ -45,6 +49,7 @@ interface User {
|
|
|
45
49
|
createdAt: number;
|
|
46
50
|
updatedAt: number;
|
|
47
51
|
partnerIds: PartnerIds;
|
|
52
|
+
/** @deprecated Privy is no longer used for authentication. This field exists for legacy data compatibility only. */
|
|
48
53
|
privyLinkedAccounts?: PrivyLinkedAccount[];
|
|
49
54
|
twProfiles?: TWProfile[];
|
|
50
55
|
}
|
|
@@ -2,10 +2,11 @@ import { Chain } from "thirdweb";
|
|
|
2
2
|
import { SingleStepAuthArgsType, Wallet } from "thirdweb/wallets";
|
|
3
3
|
type WalletType = Wallet["id"];
|
|
4
4
|
type StrategyType = SingleStepAuthArgsType["strategy"];
|
|
5
|
-
|
|
5
|
+
declare const customStrategies: readonly ["basement"];
|
|
6
|
+
type CustomStrategyType = (typeof customStrategies)[number];
|
|
6
7
|
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType | "email";
|
|
7
8
|
type NonWalletStrategyType = Exclude<AllowedStrategies, WalletType>;
|
|
8
|
-
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement"
|
|
9
|
+
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement"];
|
|
9
10
|
export type AllowedStrategy = (typeof allowedStrategies)[number];
|
|
10
11
|
export declare function isWalletType(strategy: AllowedStrategies): strategy is WalletType;
|
|
11
12
|
export declare function isStrategyType(strategy: AllowedStrategies): strategy is NonWalletStrategyType;
|
|
@@ -14,7 +14,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
|
14
14
|
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
15
15
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
|
|
16
16
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
17
|
-
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
18
17
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
19
18
|
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
20
19
|
export { ManageAccount } from "./ManageAccount/ManageAccount";
|
|
@@ -17,7 +17,6 @@ export { useFirstEOA } from "./useFirstEOA";
|
|
|
17
17
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
18
18
|
export { useGetGeo } from "./useGetGeo";
|
|
19
19
|
export { useGlobalAccount } from "./useGlobalAccount";
|
|
20
|
-
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
21
20
|
export { useHasMounted } from "./useHasMounted";
|
|
22
21
|
export { useIsMobile } from "./useIsMobile";
|
|
23
22
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
type ObjectId = string;
|
|
5
5
|
interface PartnerIds {
|
|
6
|
+
/** @deprecated Privy is no longer used for authentication. This field exists for legacy data compatibility only. */
|
|
6
7
|
privyId?: string;
|
|
7
8
|
thirdwebId?: string;
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Privy is no longer used for authentication. This type exists for legacy data compatibility only.
|
|
12
|
+
*/
|
|
9
13
|
interface PrivyLinkedAccount {
|
|
10
14
|
type: string;
|
|
11
15
|
address?: string;
|
|
@@ -45,6 +49,7 @@ interface User {
|
|
|
45
49
|
createdAt: number;
|
|
46
50
|
updatedAt: number;
|
|
47
51
|
partnerIds: PartnerIds;
|
|
52
|
+
/** @deprecated Privy is no longer used for authentication. This field exists for legacy data compatibility only. */
|
|
48
53
|
privyLinkedAccounts?: PrivyLinkedAccount[];
|
|
49
54
|
twProfiles?: TWProfile[];
|
|
50
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.1.70-alpha.
|
|
3
|
+
"version": "0.1.70-alpha.5",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -311,6 +311,7 @@
|
|
|
311
311
|
"@feathersjs/socketio-client": "5.0.33",
|
|
312
312
|
"@feathersjs/typebox": "5.0.33",
|
|
313
313
|
"@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
|
|
314
|
+
"@headlessui/react": "^2.2.10",
|
|
314
315
|
"@hey-api/client-fetch": "0.8.3",
|
|
315
316
|
"@hey-api/openapi-ts": "0.64.13",
|
|
316
317
|
"@lottiefiles/dotlottie-react": "0.7.2",
|
|
@@ -399,7 +400,6 @@
|
|
|
399
400
|
},
|
|
400
401
|
"peerDependencies": {
|
|
401
402
|
"@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
|
|
402
|
-
"@privy-io/react-auth": "^2.8.0",
|
|
403
403
|
"@react-three/postprocessing": "2.16.6",
|
|
404
404
|
"@tanstack/react-query": "5.55.0",
|
|
405
405
|
"@wagmi/core": "2.20.3",
|
|
@@ -12,7 +12,6 @@ import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
|
12
12
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
13
13
|
import { useActiveAccount } from "thirdweb/react";
|
|
14
14
|
import { Account } from "thirdweb/wallets";
|
|
15
|
-
import { SignInWithB3Privy } from "./SignInWithB3Privy";
|
|
16
15
|
import { LoginStep, LoginStepContainer } from "./steps/LoginStep";
|
|
17
16
|
import { LoginStepCustom } from "./steps/LoginStepCustom";
|
|
18
17
|
|
|
@@ -310,9 +309,7 @@ export function SignInWithB3Flow({
|
|
|
310
309
|
);
|
|
311
310
|
} else {
|
|
312
311
|
// Custom strategy
|
|
313
|
-
if (strategies
|
|
314
|
-
content = <SignInWithB3Privy onSuccess={handleLoginSuccess} chain={chain} />;
|
|
315
|
-
} else if (strategies) {
|
|
312
|
+
if (strategies) {
|
|
316
313
|
// Strategies are explicitly provided
|
|
317
314
|
content = (
|
|
318
315
|
<LoginStepCustom
|
|
@@ -3,12 +3,11 @@ import { createWallet, SingleStepAuthArgsType, Wallet } from "thirdweb/wallets";
|
|
|
3
3
|
|
|
4
4
|
type WalletType = Wallet["id"];
|
|
5
5
|
type StrategyType = SingleStepAuthArgsType["strategy"];
|
|
6
|
-
|
|
6
|
+
const customStrategies = ["basement"] as const;
|
|
7
|
+
type CustomStrategyType = (typeof customStrategies)[number];
|
|
7
8
|
|
|
8
9
|
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType | "email";
|
|
9
10
|
type NonWalletStrategyType = Exclude<AllowedStrategies, WalletType>;
|
|
10
|
-
const customStrategies = ["basement", "privy"] as const;
|
|
11
|
-
// type CustomStrategy = (typeof customStrategies)[number];
|
|
12
11
|
|
|
13
12
|
export const allowedStrategies = [
|
|
14
13
|
// Auth strategies
|
|
@@ -26,7 +25,6 @@ export const allowedStrategies = [
|
|
|
26
25
|
"com.coinbase.wallet",
|
|
27
26
|
|
|
28
27
|
// Custom strategies
|
|
29
|
-
// TODO: Audit we don't use "privy" directly anymore
|
|
30
28
|
...customStrategies,
|
|
31
29
|
] as const;
|
|
32
30
|
|
|
@@ -22,7 +22,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
|
22
22
|
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
23
23
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
|
|
24
24
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
25
|
-
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
26
25
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
27
26
|
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
28
27
|
|
|
@@ -17,7 +17,6 @@ export { useFirstEOA } from "./useFirstEOA";
|
|
|
17
17
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
18
18
|
export { useGetGeo } from "./useGetGeo";
|
|
19
19
|
export { useGlobalAccount } from "./useGlobalAccount";
|
|
20
|
-
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
21
20
|
export { useHasMounted } from "./useHasMounted";
|
|
22
21
|
export { useIsMobile } from "./useIsMobile";
|
|
23
22
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
@@ -10,11 +10,14 @@ type ObjectId = string;
|
|
|
10
10
|
|
|
11
11
|
// Partner IDs interface
|
|
12
12
|
interface PartnerIds {
|
|
13
|
+
/** @deprecated Privy is no longer used for authentication. This field exists for legacy data compatibility only. */
|
|
13
14
|
privyId?: string;
|
|
14
15
|
thirdwebId?: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Privy is no longer used for authentication. This type exists for legacy data compatibility only.
|
|
20
|
+
*/
|
|
18
21
|
interface PrivyLinkedAccount {
|
|
19
22
|
type: string; // "wallet" | "smart_wallet" | "google_oauth"
|
|
20
23
|
address?: string;
|
|
@@ -76,6 +79,7 @@ interface User {
|
|
|
76
79
|
|
|
77
80
|
// Partner integrations
|
|
78
81
|
partnerIds: PartnerIds;
|
|
82
|
+
/** @deprecated Privy is no longer used for authentication. This field exists for legacy data compatibility only. */
|
|
79
83
|
privyLinkedAccounts?: PrivyLinkedAccount[];
|
|
80
84
|
twProfiles?: TWProfile[];
|
|
81
85
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Chain } from "thirdweb";
|
|
2
|
-
import { Account } from "thirdweb/wallets";
|
|
3
|
-
interface SignInWithB3PrivyProps {
|
|
4
|
-
onError?: (error: Error) => Promise<void>;
|
|
5
|
-
onSuccess: (account: Account) => Promise<void>;
|
|
6
|
-
accessToken?: string;
|
|
7
|
-
chain: Chain;
|
|
8
|
-
}
|
|
9
|
-
export declare function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignInWithB3Privy = SignInWithB3Privy;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("../../../../global-account/react");
|
|
6
|
-
const debug_1 = require("../../../../shared/utils/debug");
|
|
7
|
-
const react_2 = require("react");
|
|
8
|
-
const debug = (0, debug_1.debugB3React)("SignInWithB3Privy");
|
|
9
|
-
function SignInWithB3Privy({ onSuccess, onError, chain }) {
|
|
10
|
-
const { partnerId } = (0, react_1.useB3Config)();
|
|
11
|
-
const { isLoading, connectTw, fullToken } = (0, react_1.useHandleConnectWithPrivy)(chain, onSuccess);
|
|
12
|
-
const setIsAuthenticating = (0, react_1.useAuthStore)(state => state.setIsAuthenticating);
|
|
13
|
-
const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
|
|
14
|
-
const { logout } = (0, react_1.useAuthentication)(partnerId, { skipAutoConnect: true });
|
|
15
|
-
debug("@@SignInWithB3Privy", {
|
|
16
|
-
isLoading,
|
|
17
|
-
fullToken,
|
|
18
|
-
});
|
|
19
|
-
(0, react_2.useEffect)(() => {
|
|
20
|
-
async function autoConnect() {
|
|
21
|
-
try {
|
|
22
|
-
const connectResult = await connectTw();
|
|
23
|
-
const account = connectResult?.getAccount();
|
|
24
|
-
if (!account) {
|
|
25
|
-
setIsAuthenticated(false);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
await onSuccess(account);
|
|
29
|
-
setIsAuthenticated(true);
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error("Failed to connect:", error);
|
|
33
|
-
await onError?.(error);
|
|
34
|
-
await logout();
|
|
35
|
-
setIsAuthenticated(false);
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
debug("setIsAuthenticating:false:7");
|
|
39
|
-
setIsAuthenticating(false);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
autoConnect();
|
|
43
|
-
}, [connectTw, onSuccess, onError, setIsAuthenticated, logout, setIsAuthenticating]);
|
|
44
|
-
// Currently we auto login, so we can show loading immediately and the onSuccess will proceed to the next modal
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "flex aspect-square items-center justify-center p-6", children: (0, jsx_runtime_1.jsx)(react_1.Loading, { variant: "white", size: "lg" }) }));
|
|
46
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Chain } from "thirdweb";
|
|
2
|
-
import { Account } from "thirdweb/wallets";
|
|
3
|
-
/**
|
|
4
|
-
* This essentially wraps our useConnect hook to handle the Privy auth flow.
|
|
5
|
-
* Currently, this is for the basement-privy strategy
|
|
6
|
-
*/
|
|
7
|
-
export declare function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void): {
|
|
8
|
-
connectTw: () => Promise<import("thirdweb/wallets").Wallet | null | undefined>;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
fullToken: string | null;
|
|
11
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useHandleConnectWithPrivy = useHandleConnectWithPrivy;
|
|
4
|
-
const react_1 = require("../../../global-account/react");
|
|
5
|
-
const debug_1 = require("../../../shared/utils/debug");
|
|
6
|
-
const react_auth_1 = require("@privy-io/react-auth");
|
|
7
|
-
const react_2 = require("react");
|
|
8
|
-
const debug = (0, debug_1.debugB3React)("@@b3:useHandleConnectWithPrivy");
|
|
9
|
-
/**
|
|
10
|
-
* This essentially wraps our useConnect hook to handle the Privy auth flow.
|
|
11
|
-
* Currently, this is for the basement-privy strategy
|
|
12
|
-
*/
|
|
13
|
-
function useHandleConnectWithPrivy(chain, onSuccess) {
|
|
14
|
-
const { partnerId } = (0, react_1.useB3Config)();
|
|
15
|
-
if (!chain) {
|
|
16
|
-
throw new Error("Chain is required");
|
|
17
|
-
}
|
|
18
|
-
const { connect } = (0, react_1.useConnect)(partnerId, chain);
|
|
19
|
-
const [isLoading, setIsLoading] = (0, react_2.useState)(true);
|
|
20
|
-
const isConnecting = (0, react_2.useRef)(false);
|
|
21
|
-
const { identityToken } = (0, react_auth_1.useIdentityToken)();
|
|
22
|
-
const { getAccessToken } = (0, react_auth_1.usePrivy)();
|
|
23
|
-
const [fullToken, setFullToken] = (0, react_2.useState)(null);
|
|
24
|
-
const connectTw = (0, react_2.useCallback)(async () => {
|
|
25
|
-
if (isConnecting.current) {
|
|
26
|
-
debug("@@connectTw:skipping:isConnecting", isConnecting.current);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
setIsLoading(true);
|
|
30
|
-
isConnecting.current = true;
|
|
31
|
-
// Form token
|
|
32
|
-
const accessToken = await getAccessToken();
|
|
33
|
-
const fullToken = `${accessToken}+${identityToken}`;
|
|
34
|
-
setFullToken(fullToken);
|
|
35
|
-
debug("@@connectTw:fullToken", fullToken);
|
|
36
|
-
if (!fullToken)
|
|
37
|
-
throw new Error("Token is not set");
|
|
38
|
-
// Connect to TW via privy
|
|
39
|
-
const wallet = await connect({
|
|
40
|
-
strategy: "auth_endpoint",
|
|
41
|
-
payload: JSON.stringify({
|
|
42
|
-
strategy: "basement",
|
|
43
|
-
accessToken: fullToken,
|
|
44
|
-
}),
|
|
45
|
-
});
|
|
46
|
-
debug("@@useHandleConnectWithPrivy:connect:return", wallet);
|
|
47
|
-
setIsLoading(false);
|
|
48
|
-
// Handle onsuccess & more
|
|
49
|
-
try {
|
|
50
|
-
debug("@@autoLogin:starting", fullToken);
|
|
51
|
-
const account = wallet?.getAccount();
|
|
52
|
-
if (!account) {
|
|
53
|
-
throw new Error("Failed to connect");
|
|
54
|
-
}
|
|
55
|
-
onSuccess?.(account);
|
|
56
|
-
if (!account) {
|
|
57
|
-
throw new Error("Failed to connect");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
console.error("@@Error signing in with Privy", error);
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
isConnecting.current = false;
|
|
65
|
-
setIsLoading(false);
|
|
66
|
-
}
|
|
67
|
-
return wallet;
|
|
68
|
-
}, [connect, getAccessToken, identityToken, onSuccess]);
|
|
69
|
-
return { connectTw, isLoading, fullToken };
|
|
70
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Chain } from "thirdweb";
|
|
2
|
-
import { Account } from "thirdweb/wallets";
|
|
3
|
-
interface SignInWithB3PrivyProps {
|
|
4
|
-
onError?: (error: Error) => Promise<void>;
|
|
5
|
-
onSuccess: (account: Account) => Promise<void>;
|
|
6
|
-
accessToken?: string;
|
|
7
|
-
chain: Chain;
|
|
8
|
-
}
|
|
9
|
-
export declare function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Loading, useAuthentication, useAuthStore, useB3Config, useHandleConnectWithPrivy, } from "../../../../global-account/react/index.js";
|
|
3
|
-
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
const debug = debugB3React("SignInWithB3Privy");
|
|
6
|
-
export function SignInWithB3Privy({ onSuccess, onError, chain }) {
|
|
7
|
-
const { partnerId } = useB3Config();
|
|
8
|
-
const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(chain, onSuccess);
|
|
9
|
-
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
10
|
-
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
11
|
-
const { logout } = useAuthentication(partnerId, { skipAutoConnect: true });
|
|
12
|
-
debug("@@SignInWithB3Privy", {
|
|
13
|
-
isLoading,
|
|
14
|
-
fullToken,
|
|
15
|
-
});
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
async function autoConnect() {
|
|
18
|
-
try {
|
|
19
|
-
const connectResult = await connectTw();
|
|
20
|
-
const account = connectResult?.getAccount();
|
|
21
|
-
if (!account) {
|
|
22
|
-
setIsAuthenticated(false);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
await onSuccess(account);
|
|
26
|
-
setIsAuthenticated(true);
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
console.error("Failed to connect:", error);
|
|
30
|
-
await onError?.(error);
|
|
31
|
-
await logout();
|
|
32
|
-
setIsAuthenticated(false);
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
debug("setIsAuthenticating:false:7");
|
|
36
|
-
setIsAuthenticating(false);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
autoConnect();
|
|
40
|
-
}, [connectTw, onSuccess, onError, setIsAuthenticated, logout, setIsAuthenticating]);
|
|
41
|
-
// Currently we auto login, so we can show loading immediately and the onSuccess will proceed to the next modal
|
|
42
|
-
return (_jsx("div", { className: "flex aspect-square items-center justify-center p-6", children: _jsx(Loading, { variant: "white", size: "lg" }) }));
|
|
43
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Chain } from "thirdweb";
|
|
2
|
-
import { Account } from "thirdweb/wallets";
|
|
3
|
-
/**
|
|
4
|
-
* This essentially wraps our useConnect hook to handle the Privy auth flow.
|
|
5
|
-
* Currently, this is for the basement-privy strategy
|
|
6
|
-
*/
|
|
7
|
-
export declare function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void): {
|
|
8
|
-
connectTw: () => Promise<import("thirdweb/wallets").Wallet | null | undefined>;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
fullToken: string | null;
|
|
11
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { useB3Config, useConnect } from "../../../global-account/react/index.js";
|
|
2
|
-
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
3
|
-
import { useIdentityToken, usePrivy } from "@privy-io/react-auth";
|
|
4
|
-
import { useCallback, useRef, useState } from "react";
|
|
5
|
-
const debug = debugB3React("@@b3:useHandleConnectWithPrivy");
|
|
6
|
-
/**
|
|
7
|
-
* This essentially wraps our useConnect hook to handle the Privy auth flow.
|
|
8
|
-
* Currently, this is for the basement-privy strategy
|
|
9
|
-
*/
|
|
10
|
-
export function useHandleConnectWithPrivy(chain, onSuccess) {
|
|
11
|
-
const { partnerId } = useB3Config();
|
|
12
|
-
if (!chain) {
|
|
13
|
-
throw new Error("Chain is required");
|
|
14
|
-
}
|
|
15
|
-
const { connect } = useConnect(partnerId, chain);
|
|
16
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
17
|
-
const isConnecting = useRef(false);
|
|
18
|
-
const { identityToken } = useIdentityToken();
|
|
19
|
-
const { getAccessToken } = usePrivy();
|
|
20
|
-
const [fullToken, setFullToken] = useState(null);
|
|
21
|
-
const connectTw = useCallback(async () => {
|
|
22
|
-
if (isConnecting.current) {
|
|
23
|
-
debug("@@connectTw:skipping:isConnecting", isConnecting.current);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
setIsLoading(true);
|
|
27
|
-
isConnecting.current = true;
|
|
28
|
-
// Form token
|
|
29
|
-
const accessToken = await getAccessToken();
|
|
30
|
-
const fullToken = `${accessToken}+${identityToken}`;
|
|
31
|
-
setFullToken(fullToken);
|
|
32
|
-
debug("@@connectTw:fullToken", fullToken);
|
|
33
|
-
if (!fullToken)
|
|
34
|
-
throw new Error("Token is not set");
|
|
35
|
-
// Connect to TW via privy
|
|
36
|
-
const wallet = await connect({
|
|
37
|
-
strategy: "auth_endpoint",
|
|
38
|
-
payload: JSON.stringify({
|
|
39
|
-
strategy: "basement",
|
|
40
|
-
accessToken: fullToken,
|
|
41
|
-
}),
|
|
42
|
-
});
|
|
43
|
-
debug("@@useHandleConnectWithPrivy:connect:return", wallet);
|
|
44
|
-
setIsLoading(false);
|
|
45
|
-
// Handle onsuccess & more
|
|
46
|
-
try {
|
|
47
|
-
debug("@@autoLogin:starting", fullToken);
|
|
48
|
-
const account = wallet?.getAccount();
|
|
49
|
-
if (!account) {
|
|
50
|
-
throw new Error("Failed to connect");
|
|
51
|
-
}
|
|
52
|
-
onSuccess?.(account);
|
|
53
|
-
if (!account) {
|
|
54
|
-
throw new Error("Failed to connect");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.error("@@Error signing in with Privy", error);
|
|
59
|
-
}
|
|
60
|
-
finally {
|
|
61
|
-
isConnecting.current = false;
|
|
62
|
-
setIsLoading(false);
|
|
63
|
-
}
|
|
64
|
-
return wallet;
|
|
65
|
-
}, [connect, getAccessToken, identityToken, onSuccess]);
|
|
66
|
-
return { connectTw, isLoading, fullToken };
|
|
67
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Chain } from "thirdweb";
|
|
2
|
-
import { Account } from "thirdweb/wallets";
|
|
3
|
-
interface SignInWithB3PrivyProps {
|
|
4
|
-
onError?: (error: Error) => Promise<void>;
|
|
5
|
-
onSuccess: (account: Account) => Promise<void>;
|
|
6
|
-
accessToken?: string;
|
|
7
|
-
chain: Chain;
|
|
8
|
-
}
|
|
9
|
-
export declare function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Chain } from "thirdweb";
|
|
2
|
-
import { Account } from "thirdweb/wallets";
|
|
3
|
-
/**
|
|
4
|
-
* This essentially wraps our useConnect hook to handle the Privy auth flow.
|
|
5
|
-
* Currently, this is for the basement-privy strategy
|
|
6
|
-
*/
|
|
7
|
-
export declare function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void): {
|
|
8
|
-
connectTw: () => Promise<import("thirdweb/wallets").Wallet | null | undefined>;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
fullToken: string | null;
|
|
11
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Loading,
|
|
3
|
-
useAuthentication,
|
|
4
|
-
useAuthStore,
|
|
5
|
-
useB3Config,
|
|
6
|
-
useHandleConnectWithPrivy,
|
|
7
|
-
} from "@b3dotfun/sdk/global-account/react";
|
|
8
|
-
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
9
|
-
import { useEffect } from "react";
|
|
10
|
-
import type { Chain } from "thirdweb";
|
|
11
|
-
import { Account } from "thirdweb/wallets";
|
|
12
|
-
|
|
13
|
-
const debug = debugB3React("SignInWithB3Privy");
|
|
14
|
-
interface SignInWithB3PrivyProps {
|
|
15
|
-
onError?: (error: Error) => Promise<void>;
|
|
16
|
-
onSuccess: (account: Account) => Promise<void>;
|
|
17
|
-
accessToken?: string;
|
|
18
|
-
chain: Chain;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps) {
|
|
22
|
-
const { partnerId } = useB3Config();
|
|
23
|
-
const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(chain, onSuccess);
|
|
24
|
-
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
25
|
-
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
26
|
-
const { logout } = useAuthentication(partnerId, { skipAutoConnect: true });
|
|
27
|
-
|
|
28
|
-
debug("@@SignInWithB3Privy", {
|
|
29
|
-
isLoading,
|
|
30
|
-
fullToken,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
async function autoConnect() {
|
|
35
|
-
try {
|
|
36
|
-
const connectResult = await connectTw();
|
|
37
|
-
const account = connectResult?.getAccount();
|
|
38
|
-
if (!account) {
|
|
39
|
-
setIsAuthenticated(false);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
await onSuccess(account);
|
|
43
|
-
setIsAuthenticated(true);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error("Failed to connect:", error);
|
|
46
|
-
await onError?.(error as Error);
|
|
47
|
-
await logout();
|
|
48
|
-
setIsAuthenticated(false);
|
|
49
|
-
} finally {
|
|
50
|
-
debug("setIsAuthenticating:false:7");
|
|
51
|
-
setIsAuthenticating(false);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
autoConnect();
|
|
55
|
-
}, [connectTw, onSuccess, onError, setIsAuthenticated, logout, setIsAuthenticating]);
|
|
56
|
-
|
|
57
|
-
// Currently we auto login, so we can show loading immediately and the onSuccess will proceed to the next modal
|
|
58
|
-
return (
|
|
59
|
-
<div className="flex aspect-square items-center justify-center p-6">
|
|
60
|
-
<Loading variant="white" size="lg" />
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { useB3Config, useConnect } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
-
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
-
import { useIdentityToken, usePrivy } from "@privy-io/react-auth";
|
|
4
|
-
import { useCallback, useRef, useState } from "react";
|
|
5
|
-
import { Chain } from "thirdweb";
|
|
6
|
-
import { Account } from "thirdweb/wallets";
|
|
7
|
-
const debug = debugB3React("@@b3:useHandleConnectWithPrivy");
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This essentially wraps our useConnect hook to handle the Privy auth flow.
|
|
11
|
-
* Currently, this is for the basement-privy strategy
|
|
12
|
-
*/
|
|
13
|
-
export function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void) {
|
|
14
|
-
const { partnerId } = useB3Config();
|
|
15
|
-
if (!chain) {
|
|
16
|
-
throw new Error("Chain is required");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const { connect } = useConnect(partnerId, chain);
|
|
20
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
21
|
-
const isConnecting = useRef(false);
|
|
22
|
-
const { identityToken } = useIdentityToken();
|
|
23
|
-
const { getAccessToken } = usePrivy();
|
|
24
|
-
const [fullToken, setFullToken] = useState<string | null>(null);
|
|
25
|
-
|
|
26
|
-
const connectTw = useCallback(async () => {
|
|
27
|
-
if (isConnecting.current) {
|
|
28
|
-
debug("@@connectTw:skipping:isConnecting", isConnecting.current);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
setIsLoading(true);
|
|
32
|
-
isConnecting.current = true;
|
|
33
|
-
|
|
34
|
-
// Form token
|
|
35
|
-
const accessToken = await getAccessToken();
|
|
36
|
-
const fullToken = `${accessToken}+${identityToken}`;
|
|
37
|
-
setFullToken(fullToken);
|
|
38
|
-
debug("@@connectTw:fullToken", fullToken);
|
|
39
|
-
if (!fullToken) throw new Error("Token is not set");
|
|
40
|
-
|
|
41
|
-
// Connect to TW via privy
|
|
42
|
-
const wallet = await connect({
|
|
43
|
-
strategy: "auth_endpoint",
|
|
44
|
-
payload: JSON.stringify({
|
|
45
|
-
strategy: "basement",
|
|
46
|
-
accessToken: fullToken,
|
|
47
|
-
}),
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
debug("@@useHandleConnectWithPrivy:connect:return", wallet);
|
|
51
|
-
setIsLoading(false);
|
|
52
|
-
|
|
53
|
-
// Handle onsuccess & more
|
|
54
|
-
try {
|
|
55
|
-
debug("@@autoLogin:starting", fullToken);
|
|
56
|
-
|
|
57
|
-
const account = wallet?.getAccount();
|
|
58
|
-
|
|
59
|
-
if (!account) {
|
|
60
|
-
throw new Error("Failed to connect");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
onSuccess?.(account);
|
|
64
|
-
|
|
65
|
-
if (!account) {
|
|
66
|
-
throw new Error("Failed to connect");
|
|
67
|
-
}
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error("@@Error signing in with Privy", error);
|
|
70
|
-
} finally {
|
|
71
|
-
isConnecting.current = false;
|
|
72
|
-
setIsLoading(false);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return wallet;
|
|
76
|
-
}, [connect, getAccessToken, identityToken, onSuccess]);
|
|
77
|
-
|
|
78
|
-
return { connectTw, isLoading, fullToken };
|
|
79
|
-
}
|