@b3dotfun/sdk 0.1.70-alpha.4 → 0.1.70-alpha.6

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 (55) hide show
  1. package/constants/chains/b3Chain.js +3 -1
  2. package/dist/cjs/global-account/better-auth-client.d.ts +2 -2
  3. package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
  4. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
  5. package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
  6. package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +1 -3
  7. package/dist/cjs/global-account/react/components/index.d.ts +0 -1
  8. package/dist/cjs/global-account/react/components/index.js +3 -5
  9. package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
  10. package/dist/cjs/global-account/react/hooks/index.js +2 -4
  11. package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +1 -1
  12. package/dist/cjs/global-account/types/b3-api.types.d.ts +5 -0
  13. package/dist/cjs/global-account/types/chain-networks.d.ts +34 -34
  14. package/dist/cjs/global-account/types/feature-flags.d.ts +5 -5
  15. package/dist/esm/global-account/better-auth-client.d.ts +2 -2
  16. package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
  17. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
  18. package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
  19. package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +1 -3
  20. package/dist/esm/global-account/react/components/index.d.ts +0 -1
  21. package/dist/esm/global-account/react/components/index.js +0 -1
  22. package/dist/esm/global-account/react/hooks/index.d.ts +0 -1
  23. package/dist/esm/global-account/react/hooks/index.js +0 -1
  24. package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +1 -1
  25. package/dist/esm/global-account/types/b3-api.types.d.ts +5 -0
  26. package/dist/esm/global-account/types/chain-networks.d.ts +34 -34
  27. package/dist/esm/global-account/types/feature-flags.d.ts +5 -5
  28. package/dist/styles/index.css +1 -1
  29. package/dist/types/global-account/better-auth-client.d.ts +2 -2
  30. package/dist/types/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
  31. package/dist/types/global-account/react/components/index.d.ts +0 -1
  32. package/dist/types/global-account/react/hooks/index.d.ts +0 -1
  33. package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +1 -1
  34. package/dist/types/global-account/types/b3-api.types.d.ts +5 -0
  35. package/dist/types/global-account/types/chain-networks.d.ts +34 -34
  36. package/dist/types/global-account/types/feature-flags.d.ts +5 -5
  37. package/package.json +16 -7
  38. package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +1 -1
  39. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +1 -4
  40. package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +2 -4
  41. package/src/global-account/react/components/index.ts +0 -1
  42. package/src/global-account/react/hooks/index.ts +0 -1
  43. package/src/global-account/types/b3-api.types.ts +5 -1
  44. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
  45. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -46
  46. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
  47. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -70
  48. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
  49. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -43
  50. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
  51. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -67
  52. package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
  53. package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
  54. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +0 -63
  55. package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +0 -79
@@ -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
  }
@@ -1,44 +1,44 @@
1
1
  import { Static } from "@feathersjs/typebox";
2
- export declare const chainNetworksSchema: import("@feathersjs/typebox").TObject<{
3
- _id: import("@feathersjs/typebox").TUnion<[import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TObject<{}>]>;
4
- id: import("@feathersjs/typebox").TInteger;
5
- name: import("@feathersjs/typebox").TString<string>;
6
- rpcUrls: import("@feathersjs/typebox").TObject<{
7
- default: import("@feathersjs/typebox").TObject<{
8
- http: import("@feathersjs/typebox").TString<"uri">;
9
- ws: import("@feathersjs/typebox").TString<"uri">;
2
+ export declare const chainNetworksSchema: import("@sinclair/typebox").TObject<{
3
+ _id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{}>]>;
4
+ id: import("@sinclair/typebox").TInteger;
5
+ name: import("@sinclair/typebox").TString<string>;
6
+ rpcUrls: import("@sinclair/typebox").TObject<{
7
+ default: import("@sinclair/typebox").TObject<{
8
+ http: import("@sinclair/typebox").TString<"uri">;
9
+ ws: import("@sinclair/typebox").TString<"uri">;
10
10
  }>;
11
- backups: import("@feathersjs/typebox").TArray<import("@feathersjs/typebox").TObject<{
12
- type: import("@feathersjs/typebox").TUnion<[import("@feathersjs/typebox").TLiteral<"http">, import("@feathersjs/typebox").TLiteral<"ws">]>;
13
- uri: import("@feathersjs/typebox").TString<string>;
11
+ backups: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
12
+ type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"http">, import("@sinclair/typebox").TLiteral<"ws">]>;
13
+ uri: import("@sinclair/typebox").TString<string>;
14
14
  }>>;
15
15
  }>;
16
- icon: import("@feathersjs/typebox").TObject<{
17
- url: import("@feathersjs/typebox").TString<"uri">;
18
- width: import("@feathersjs/typebox").TInteger;
19
- height: import("@feathersjs/typebox").TInteger;
20
- format: import("@feathersjs/typebox").TString<string>;
16
+ icon: import("@sinclair/typebox").TObject<{
17
+ url: import("@sinclair/typebox").TString<"uri">;
18
+ width: import("@sinclair/typebox").TInteger;
19
+ height: import("@sinclair/typebox").TInteger;
20
+ format: import("@sinclair/typebox").TString<string>;
21
21
  }>;
22
- blockExplorers: import("@feathersjs/typebox").TObject<{
23
- explorerTitle: import("@feathersjs/typebox").TString<string>;
24
- default: import("@feathersjs/typebox").TString<"uri">;
22
+ blockExplorers: import("@sinclair/typebox").TObject<{
23
+ explorerTitle: import("@sinclair/typebox").TString<string>;
24
+ default: import("@sinclair/typebox").TString<"uri">;
25
25
  }>;
26
- nativeCurrency: import("@feathersjs/typebox").TObject<{
27
- name: import("@feathersjs/typebox").TString<string>;
28
- symbol: import("@feathersjs/typebox").TString<string>;
29
- decimals: import("@feathersjs/typebox").TInteger;
26
+ nativeCurrency: import("@sinclair/typebox").TObject<{
27
+ name: import("@sinclair/typebox").TString<string>;
28
+ symbol: import("@sinclair/typebox").TString<string>;
29
+ decimals: import("@sinclair/typebox").TInteger;
30
30
  }>;
31
- testnet: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TBoolean>;
32
- testnetConfigID: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TInteger>;
33
- sourceId: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TInteger>;
34
- contracts: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TRecord<import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TObject<{
35
- address: import("@feathersjs/typebox").TString<string>;
36
- blockCreated: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TInteger>;
31
+ testnet: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
32
+ testnetConfigID: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
33
+ sourceId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
34
+ contracts: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
35
+ address: import("@sinclair/typebox").TString<string>;
36
+ blockCreated: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
37
37
  }>>>;
38
- formatters: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TRecord<import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TAny>>;
39
- fees: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TRecord<import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TAny>>;
40
- badge: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TString<"uri">>;
41
- color: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TString<string>>;
42
- enabledFeatures: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TArray<import("@feathersjs/typebox").TString<string>>>;
38
+ formatters: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TAny>>;
39
+ fees: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TAny>>;
40
+ badge: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<"uri">>;
41
+ color: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
42
+ enabledFeatures: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString<string>>>;
43
43
  }>;
44
44
  export type ChainNetworks = Static<typeof chainNetworksSchema>;
@@ -1,8 +1,8 @@
1
1
  import { Static } from "@feathersjs/typebox";
2
- export declare const featureFlagsSchema: import("@feathersjs/typebox").TObject<{
3
- _id: import("@feathersjs/typebox").TUnion<[import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TObject<{}>]>;
4
- id: import("@feathersjs/typebox").TString<string>;
5
- enabled: import("@feathersjs/typebox").TBoolean;
6
- description: import("@feathersjs/typebox").TString<string>;
2
+ export declare const featureFlagsSchema: import("@sinclair/typebox").TObject<{
3
+ _id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{}>]>;
4
+ id: import("@sinclair/typebox").TString<string>;
5
+ enabled: import("@sinclair/typebox").TBoolean;
6
+ description: import("@sinclair/typebox").TString<string>;
7
7
  }>;
8
8
  export type FeatureFlags = Static<typeof featureFlagsSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.1.70-alpha.4",
3
+ "version": "0.1.70-alpha.6",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -12,11 +12,9 @@
12
12
  "exports": {
13
13
  "./index.css": "./dist/styles/index.css",
14
14
  ".": {
15
- "default": {
16
- "types": "./dist/types/index.d.ts",
17
- "import": "./dist/esm/index.js",
18
- "require": "./dist/cjs/index.js"
19
- }
15
+ "types": "./dist/types/index.d.ts",
16
+ "import": "./dist/esm/index.js",
17
+ "require": "./dist/cjs/index.js"
20
18
  },
21
19
  "./anyspend": {
22
20
  "types": "./dist/types/anyspend/index.d.ts",
@@ -55,6 +53,11 @@
55
53
  "import": "./dist/esm/anyspend/constants.js",
56
54
  "require": "./dist/cjs/anyspend/constants.js"
57
55
  },
56
+ "./anyspend/constants/*": {
57
+ "types": "./dist/types/anyspend/constants/*.d.ts",
58
+ "import": "./dist/esm/anyspend/constants/*.js",
59
+ "require": "./dist/cjs/anyspend/constants/*.js"
60
+ },
58
61
  "./anyspend/platform": {
59
62
  "types": "./dist/types/anyspend/platform/index.d.ts",
60
63
  "import": "./dist/esm/anyspend/platform/index.js",
@@ -291,6 +294,11 @@
291
294
  "import": "./dist/esm/global-account/react/hooks/useSiwe.js",
292
295
  "require": "./dist/cjs/global-account/react/hooks/useSiwe.js"
293
296
  }
297
+ },
298
+ "./global-account/react/hooks/*": {
299
+ "types": "./dist/types/global-account/react/hooks/*.d.ts",
300
+ "import": "./dist/esm/global-account/react/hooks/*.js",
301
+ "require": "./dist/cjs/global-account/react/hooks/*.js"
294
302
  }
295
303
  },
296
304
  "files": [
@@ -311,6 +319,7 @@
311
319
  "@feathersjs/socketio-client": "5.0.33",
312
320
  "@feathersjs/typebox": "5.0.33",
313
321
  "@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
322
+ "@headlessui/react": "^2.2.10",
314
323
  "@hey-api/client-fetch": "0.8.3",
315
324
  "@hey-api/openapi-ts": "0.64.13",
316
325
  "@lottiefiles/dotlottie-react": "0.7.2",
@@ -399,7 +408,6 @@
399
408
  },
400
409
  "peerDependencies": {
401
410
  "@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
402
- "@privy-io/react-auth": "^2.8.0",
403
411
  "@react-three/postprocessing": "2.16.6",
404
412
  "@tanstack/react-query": "5.55.0",
405
413
  "@wagmi/core": "2.20.3",
@@ -435,6 +443,7 @@
435
443
  "dev:esm": "tsc-watch -p tsconfig.esm.json --onSuccess \"tsc-alias -p tsconfig.esm.json --outDir dist/esm\"",
436
444
  "dev": "concurrently \"pnpm dev:cjs\" \"pnpm dev:esm\" \"pnpm dev:css\"",
437
445
  "dev:css": "postcss src/styles/index.css -o dist/styles/index.css --watch",
446
+ "preflight": "node scripts/preflight-publish.js",
438
447
  "release:test": "pnpm version prerelease --preid test && git push --follow-tags && pnpm publish --tag test --no-git-checks",
439
448
  "release:alpha": "pnpm version prerelease --preid alpha && git push --follow-tags && pnpm publish --tag alpha --no-git-checks",
440
449
  "typecheck": "tsc --noEmit",
@@ -84,7 +84,7 @@ const SettingsProfileCard = () => {
84
84
  // Better Auth: register username without wallet signing (DB-only, no ENS)
85
85
  // Skip ens_normalize — it rejects underscores/mixed-case that are valid non-ENS usernames
86
86
  const sanitizedUsername = editedUsername.trim().toLowerCase();
87
- // Type assertion needed: b3-mono now accepts message/hash as optional for Better Auth users
87
+ // Type assertion needed: API now accepts message/hash as optional for Better Auth users
88
88
  updatedUser = (await app
89
89
  .service("users")
90
90
  .registerUsername({ username: sanitizedUsername } as any, {} as any)) as unknown as Users;
@@ -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?.[0] === "privy") {
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
- type CustomStrategyType = "basement" | "privy";
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
- // Privy linked account interface
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
- };