@b3dotfun/sdk 0.0.37 → 0.0.38

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/dist/cjs/app.shared.d.ts +17 -0
  2. package/dist/cjs/app.shared.js +54 -0
  3. package/dist/cjs/global-account/app.d.ts +4 -3
  4. package/dist/cjs/global-account/app.js +17 -60
  5. package/dist/cjs/global-account/app.rest.d.ts +2 -0
  6. package/dist/cjs/global-account/app.rest.js +11 -0
  7. package/dist/cjs/global-account/client-manager.d.ts +44 -0
  8. package/dist/cjs/global-account/client-manager.js +136 -0
  9. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +5 -2
  10. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +9 -3
  11. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -2
  12. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +4 -3
  13. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +2 -0
  14. package/dist/cjs/global-account/react/components/B3Provider/types.js +1 -0
  15. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
  16. package/dist/cjs/global-account/react/hooks/index.js +3 -1
  17. package/dist/cjs/global-account/react/hooks/useClient.d.ts +16 -0
  18. package/dist/cjs/global-account/react/hooks/useClient.js +38 -0
  19. package/dist/esm/app.shared.d.ts +17 -0
  20. package/dist/esm/app.shared.js +46 -0
  21. package/dist/esm/global-account/app.d.ts +4 -3
  22. package/dist/esm/global-account/app.js +14 -54
  23. package/dist/esm/global-account/app.rest.d.ts +2 -0
  24. package/dist/esm/global-account/app.rest.js +3 -0
  25. package/dist/esm/global-account/client-manager.d.ts +44 -0
  26. package/dist/esm/global-account/client-manager.js +121 -0
  27. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +5 -2
  28. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +9 -3
  29. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -2
  30. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +4 -3
  31. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +2 -0
  32. package/dist/esm/global-account/react/components/B3Provider/types.js +1 -0
  33. package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
  34. package/dist/esm/global-account/react/hooks/index.js +1 -0
  35. package/dist/esm/global-account/react/hooks/useClient.d.ts +16 -0
  36. package/dist/esm/global-account/react/hooks/useClient.js +35 -0
  37. package/dist/types/app.shared.d.ts +17 -0
  38. package/dist/types/global-account/app.d.ts +4 -3
  39. package/dist/types/global-account/app.rest.d.ts +2 -0
  40. package/dist/types/global-account/client-manager.d.ts +44 -0
  41. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +5 -2
  42. package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -2
  43. package/dist/types/global-account/react/components/B3Provider/types.d.ts +2 -0
  44. package/dist/types/global-account/react/hooks/index.d.ts +1 -0
  45. package/dist/types/global-account/react/hooks/useClient.d.ts +16 -0
  46. package/package.json +2 -1
  47. package/src/app.shared.ts +61 -0
  48. package/src/global-account/app.rest.ts +4 -0
  49. package/src/global-account/app.ts +17 -63
  50. package/src/global-account/client-manager.ts +141 -0
  51. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +13 -1
  52. package/src/global-account/react/components/B3Provider/B3Provider.tsx +12 -0
  53. package/src/global-account/react/components/B3Provider/types.ts +3 -0
  54. package/src/global-account/react/hooks/index.ts +1 -0
  55. package/src/global-account/react/hooks/useClient.ts +57 -0
@@ -0,0 +1,17 @@
1
+ import { ClientApplication } from "@b3dotfun/b3-api";
2
+ import { AuthenticationClient } from "@feathersjs/authentication-client";
3
+ export declare const B3_API_URL: string;
4
+ export declare const authenticate: (app: ClientApplication, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
5
+ export declare class MyAuthenticationClient extends AuthenticationClient {
6
+ getFromLocation(location: any): Promise<any>;
7
+ }
8
+ export declare const clientOptions: {
9
+ Authentication: typeof MyAuthenticationClient;
10
+ jwtStrategy: string;
11
+ storage: {
12
+ getItem: (key: string) => string | undefined;
13
+ setItem: (key: string, value: string) => void;
14
+ removeItem: (key: string) => void;
15
+ };
16
+ storageKey: string;
17
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.clientOptions = exports.MyAuthenticationClient = exports.authenticate = exports.B3_API_URL = void 0;
7
+ const authentication_client_1 = require("@feathersjs/authentication-client");
8
+ const js_cookie_1 = __importDefault(require("js-cookie"));
9
+ const constants_1 = require("./shared/constants");
10
+ exports.B3_API_URL = process.env.EXPO_PUBLIC_B3_API || process.env.NEXT_PUBLIC_B3_API || process.env.PUBLIC_B3_API || "https://api.b3.fun";
11
+ const authenticate = async (app, accessToken, identityToken, params) => {
12
+ const fullToken = `${accessToken}+${identityToken}`;
13
+ // Do not authenticate if there is no token
14
+ if (!fullToken) {
15
+ console.log("No token found, not authenticating");
16
+ return null;
17
+ }
18
+ try {
19
+ const response = await app.authenticate({
20
+ strategy: "jwt",
21
+ accessToken: fullToken,
22
+ }, {
23
+ query: params || {},
24
+ });
25
+ return response;
26
+ }
27
+ catch (error) {
28
+ return null;
29
+ }
30
+ };
31
+ exports.authenticate = authenticate;
32
+ class MyAuthenticationClient extends authentication_client_1.AuthenticationClient {
33
+ getFromLocation(location) {
34
+ // Do custom location things here
35
+ return super.getFromLocation(location);
36
+ }
37
+ }
38
+ exports.MyAuthenticationClient = MyAuthenticationClient;
39
+ exports.clientOptions = {
40
+ Authentication: MyAuthenticationClient,
41
+ jwtStrategy: "jwt",
42
+ storage: {
43
+ getItem: (key) => {
44
+ return js_cookie_1.default.get(key);
45
+ },
46
+ setItem: (key, value) => {
47
+ js_cookie_1.default.set(key, value);
48
+ },
49
+ removeItem: (key) => {
50
+ js_cookie_1.default.remove(key);
51
+ },
52
+ },
53
+ storageKey: constants_1.B3_AUTH_COOKIE_NAME,
54
+ };
@@ -1,4 +1,5 @@
1
- declare const app: import("@b3dotfun/b3-api").ClientApplication;
2
- export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
3
- export declare const resetSocket: () => void;
1
+ import type { ClientApplication } from "@b3dotfun/b3-api";
2
+ import { authenticate, getClient, getClientByType, setClientType } from "./client-manager";
3
+ declare const app: ClientApplication;
4
4
  export default app;
5
+ export { authenticate, getClient, getClientByType, setClientType };
@@ -1,65 +1,22 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resetSocket = exports.authenticate = void 0;
7
- const b3_api_1 = require("@b3dotfun/b3-api");
8
- const authentication_client_1 = require("@feathersjs/authentication-client");
9
- const socketio_client_1 = __importDefault(require("@feathersjs/socketio-client"));
10
- const js_cookie_1 = __importDefault(require("js-cookie"));
11
- const socket_io_client_1 = __importDefault(require("socket.io-client"));
12
- const constants_1 = require("../shared/constants");
13
- const B3_API_URL = process.env.EXPO_PUBLIC_B3_API || process.env.NEXT_PUBLIC_B3_API || process.env.PUBLIC_B3_API || "https://api.b3.fun";
14
- const socket = (0, socket_io_client_1.default)(B3_API_URL, { transports: ["websocket"] });
15
- class MyAuthenticationClient extends authentication_client_1.AuthenticationClient {
16
- getFromLocation(location) {
17
- // Do custom location things here
18
- return super.getFromLocation(location);
19
- }
20
- }
21
- const app = (0, b3_api_1.createClient)((0, socketio_client_1.default)(socket), {
22
- Authentication: MyAuthenticationClient,
23
- jwtStrategy: "jwt",
24
- storage: {
25
- getItem: (key) => {
26
- return js_cookie_1.default.get(key);
27
- },
28
- setItem: (key, value) => {
29
- js_cookie_1.default.set(key, value);
30
- },
31
- removeItem: (key) => {
32
- js_cookie_1.default.remove(key);
33
- },
3
+ exports.setClientType = exports.getClientByType = exports.getClient = exports.authenticate = void 0;
4
+ const client_manager_1 = require("./client-manager");
5
+ Object.defineProperty(exports, "authenticate", { enumerable: true, get: function () { return client_manager_1.authenticate; } });
6
+ Object.defineProperty(exports, "getClient", { enumerable: true, get: function () { return client_manager_1.getClient; } });
7
+ Object.defineProperty(exports, "getClientByType", { enumerable: true, get: function () { return client_manager_1.getClientByType; } });
8
+ Object.defineProperty(exports, "setClientType", { enumerable: true, get: function () { return client_manager_1.setClientType; } });
9
+ // Default to rest
10
+ (0, client_manager_1.setClientType)("rest");
11
+ // Default export that *looks like* a Feathers app and auto-forwards
12
+ const app = new Proxy({}, {
13
+ get(_t, prop, receiver) {
14
+ const target = (0, client_manager_1.getClient)();
15
+ return Reflect.get(target, prop, receiver);
16
+ },
17
+ set(_t, prop, value) {
18
+ const target = (0, client_manager_1.getClient)();
19
+ return Reflect.set(target, prop, value);
34
20
  },
35
- storageKey: constants_1.B3_AUTH_COOKIE_NAME,
36
21
  });
37
- const authenticate = async (accessToken, identityToken, params) => {
38
- const fullToken = `${accessToken}+${identityToken}`;
39
- // Do not authenticate if there is no token
40
- if (!fullToken) {
41
- console.log("No token found, not authenticating");
42
- return null;
43
- }
44
- try {
45
- const response = await app.authenticate({
46
- strategy: "jwt",
47
- accessToken: fullToken,
48
- }, {
49
- query: params || {},
50
- });
51
- return response;
52
- }
53
- catch (error) {
54
- return null;
55
- }
56
- };
57
- exports.authenticate = authenticate;
58
- const resetSocket = () => {
59
- if (socket.connected)
60
- socket.disconnect();
61
- socket.connect();
62
- // reset the socket connection
63
- };
64
- exports.resetSocket = resetSocket;
65
22
  exports.default = app;
@@ -0,0 +1,2 @@
1
+ export { authenticateWithClient, getClientByType, getClientType, setClientType } from "./client-manager";
2
+ export declare const getRestClient: () => import("@b3dotfun/b3-api").ClientApplication;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRestClient = exports.setClientType = exports.getClientType = exports.getClientByType = exports.authenticateWithClient = void 0;
4
+ const client_manager_1 = require("./client-manager");
5
+ var client_manager_2 = require("./client-manager");
6
+ Object.defineProperty(exports, "authenticateWithClient", { enumerable: true, get: function () { return client_manager_2.authenticateWithClient; } });
7
+ Object.defineProperty(exports, "getClientByType", { enumerable: true, get: function () { return client_manager_2.getClientByType; } });
8
+ Object.defineProperty(exports, "getClientType", { enumerable: true, get: function () { return client_manager_2.getClientType; } });
9
+ Object.defineProperty(exports, "setClientType", { enumerable: true, get: function () { return client_manager_2.setClientType; } });
10
+ const getRestClient = () => (0, client_manager_1.getClientByType)("rest");
11
+ exports.getRestClient = getRestClient;
@@ -0,0 +1,44 @@
1
+ import { ClientApplication } from "@b3dotfun/b3-api";
2
+ export type ClientType = "socket" | "rest";
3
+ /**
4
+ * Sets the active client type and creates the appropriate client
5
+ *
6
+ * Note: When using, be sure to avoid race conditions between different clients
7
+ */
8
+ export declare function setClientType(t: ClientType): void;
9
+ /**
10
+ * Gets the current active client
11
+ */
12
+ export declare function getClient(): ClientApplication;
13
+ /**
14
+ * Gets the current client type
15
+ */
16
+ export declare function getClientType(): ClientType;
17
+ /**
18
+ * Gets a specific client type (useful for parallel operations)
19
+ */
20
+ export declare function getClientByType(clientType: ClientType): ClientApplication;
21
+ /**
22
+ * Resets the socket connection (only applicable for socket client)
23
+ */
24
+ export declare function resetSocket(): void;
25
+ /**
26
+ * Authenticates with the current active client
27
+ */
28
+ export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
29
+ /**
30
+ * Authenticates with a specific client type
31
+ */
32
+ export declare const authenticateWithClient: (clientType: ClientType, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
33
+ /**
34
+ * Authenticates with both clients in parallel (useful for migration scenarios)
35
+ */
36
+ export declare const authenticateBoth: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<{
37
+ socket: import("@feathersjs/authentication").AuthenticationResult | null;
38
+ rest: import("@feathersjs/authentication").AuthenticationResult | null;
39
+ success: boolean;
40
+ }>;
41
+ /**
42
+ * Switches the client type and authenticates
43
+ */
44
+ export declare function switchClientAndAuth(type: ClientType, access: string, id: string, params?: any): Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.authenticateBoth = exports.authenticateWithClient = exports.authenticate = void 0;
7
+ exports.setClientType = setClientType;
8
+ exports.getClient = getClient;
9
+ exports.getClientType = getClientType;
10
+ exports.getClientByType = getClientByType;
11
+ exports.resetSocket = resetSocket;
12
+ exports.switchClientAndAuth = switchClientAndAuth;
13
+ const b3_api_1 = require("@b3dotfun/b3-api");
14
+ const rest_client_1 = __importDefault(require("@feathersjs/rest-client"));
15
+ const socketio_client_1 = __importDefault(require("@feathersjs/socketio-client"));
16
+ const socket_io_client_1 = __importDefault(require("socket.io-client"));
17
+ const app_shared_1 = require("../app.shared");
18
+ // Global state to track which client type is active
19
+ let currentClientType = "rest";
20
+ let currentClient = null;
21
+ // Socket client instance
22
+ let socketClient = null;
23
+ let socketInstance = null;
24
+ // REST client instance
25
+ let restClient = null;
26
+ /**
27
+ * Creates a socket client
28
+ */
29
+ function createSocketClient() {
30
+ if (!socketClient) {
31
+ socketInstance = (0, socket_io_client_1.default)(app_shared_1.B3_API_URL, { transports: ["websocket"] });
32
+ socketClient = (0, b3_api_1.createClient)((0, socketio_client_1.default)(socketInstance), app_shared_1.clientOptions);
33
+ }
34
+ return socketClient;
35
+ }
36
+ /**
37
+ * Creates a REST client
38
+ */
39
+ function resolveFetch() {
40
+ const f = globalThis.fetch;
41
+ if (typeof f === "function")
42
+ return f.bind(globalThis);
43
+ // lazy-require for Node environments
44
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
45
+ return require("cross-fetch").fetch;
46
+ }
47
+ function createRestClient() {
48
+ if (!restClient) {
49
+ const connection = (0, rest_client_1.default)(app_shared_1.B3_API_URL).fetch(resolveFetch());
50
+ restClient = (0, b3_api_1.createClient)(connection, app_shared_1.clientOptions);
51
+ }
52
+ return restClient;
53
+ }
54
+ /**
55
+ * Sets the active client type and creates the appropriate client
56
+ *
57
+ * Note: When using, be sure to avoid race conditions between different clients
58
+ */
59
+ function setClientType(t) {
60
+ if (currentClientType === t && currentClient)
61
+ return;
62
+ currentClientType = t;
63
+ currentClient = t === "socket" ? createSocketClient() : createRestClient();
64
+ }
65
+ /**
66
+ * Gets the current active client
67
+ */
68
+ function getClient() {
69
+ if (!currentClient) {
70
+ currentClient = currentClientType === "socket" ? createSocketClient() : createRestClient();
71
+ }
72
+ return currentClient;
73
+ }
74
+ /**
75
+ * Gets the current client type
76
+ */
77
+ function getClientType() {
78
+ return currentClientType;
79
+ }
80
+ /**
81
+ * Gets a specific client type (useful for parallel operations)
82
+ */
83
+ function getClientByType(clientType) {
84
+ if (clientType === "socket") {
85
+ return createSocketClient();
86
+ }
87
+ else {
88
+ return createRestClient();
89
+ }
90
+ }
91
+ /**
92
+ * Resets the socket connection (only applicable for socket client)
93
+ */
94
+ function resetSocket() {
95
+ if (socketInstance && socketInstance.connected) {
96
+ socketInstance.disconnect();
97
+ socketInstance.connect();
98
+ }
99
+ }
100
+ /**
101
+ * Authenticates with the current active client
102
+ */
103
+ const authenticate = async (accessToken, identityToken, params) => {
104
+ return (0, app_shared_1.authenticate)(getClient(), accessToken, identityToken, params);
105
+ };
106
+ exports.authenticate = authenticate;
107
+ /**
108
+ * Authenticates with a specific client type
109
+ */
110
+ const authenticateWithClient = async (clientType, accessToken, identityToken, params) => {
111
+ const client = getClientByType(clientType);
112
+ return (0, app_shared_1.authenticate)(client, accessToken, identityToken, params);
113
+ };
114
+ exports.authenticateWithClient = authenticateWithClient;
115
+ /**
116
+ * Authenticates with both clients in parallel (useful for migration scenarios)
117
+ */
118
+ const authenticateBoth = async (accessToken, identityToken, params) => {
119
+ const [socketResult, restResult] = await Promise.allSettled([
120
+ (0, exports.authenticateWithClient)("socket", accessToken, identityToken, params),
121
+ (0, exports.authenticateWithClient)("rest", accessToken, identityToken, params),
122
+ ]);
123
+ return {
124
+ socket: socketResult.status === "fulfilled" ? socketResult.value : null,
125
+ rest: restResult.status === "fulfilled" ? restResult.value : null,
126
+ success: socketResult.status === "fulfilled" || restResult.status === "fulfilled",
127
+ };
128
+ };
129
+ exports.authenticateBoth = authenticateBoth;
130
+ /**
131
+ * Switches the client type and authenticates
132
+ */
133
+ async function switchClientAndAuth(type, access, id, params) {
134
+ setClientType(type);
135
+ return (0, exports.authenticateWithClient)(type, access, id, params);
136
+ }
@@ -1,12 +1,13 @@
1
1
  import { PermissionsConfig } from "../../../../global-account/types/permissions";
2
2
  import { Account } from "thirdweb/wallets";
3
+ import { ClientType } from "../../../client-manager";
3
4
  import { B3ContextType } from "./types";
4
5
  import "@reservoir0x/relay-kit-ui/styles.css";
5
6
  export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], any, readonly import("wagmi").CreateConnectorFn[]>;
6
7
  /**
7
8
  * Main B3Provider component
8
9
  */
9
- export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, }: {
10
+ export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, }: {
10
11
  theme: "light" | "dark";
11
12
  children: React.ReactNode;
12
13
  accountOverride?: Account;
@@ -17,15 +18,17 @@ export declare function B3Provider({ theme, children, accountOverride, environme
17
18
  position?: "top-center" | "top-right" | "bottom-center" | "bottom-right";
18
19
  style?: React.CSSProperties;
19
20
  };
21
+ clientType?: ClientType;
20
22
  }): import("react/jsx-runtime").JSX.Element;
21
23
  /**
22
24
  * Inner provider component that provides the actual B3Context
23
25
  */
24
- export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, }: {
26
+ export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, }: {
25
27
  children: React.ReactNode;
26
28
  accountOverride?: Account;
27
29
  environment: B3ContextType["environment"];
28
30
  defaultPermissions?: PermissionsConfig;
29
31
  automaticallySetFirstEoa: boolean;
30
32
  theme: "light" | "dark";
33
+ clientType?: ClientType;
31
34
  }): import("react/jsx-runtime").JSX.Element;
@@ -12,6 +12,7 @@ const react_2 = require("react");
12
12
  const sonner_1 = require("sonner");
13
13
  const react_3 = require("thirdweb/react");
14
14
  const wagmi_1 = require("wagmi");
15
+ const client_manager_1 = require("../../../client-manager");
15
16
  const StyleRoot_1 = require("../StyleRoot");
16
17
  const types_1 = require("./types");
17
18
  require("@reservoir0x/relay-kit-ui/styles.css");
@@ -33,17 +34,21 @@ const queryClient = new react_query_1.QueryClient();
33
34
  /**
34
35
  * Main B3Provider component
35
36
  */
36
- function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, }) {
37
+ function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", }) {
37
38
  // Initialize Google Analytics on mount
38
39
  (0, react_2.useEffect)(() => {
39
40
  (0, analytics_1.loadGA4Script)();
40
41
  }, []);
41
- return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: exports.wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
42
+ // Set the client type when provider mounts
43
+ (0, react_2.useEffect)(() => {
44
+ (0, client_manager_1.setClientType)(clientType);
45
+ }, [clientType]);
46
+ return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: exports.wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
42
47
  }
43
48
  /**
44
49
  * Inner provider component that provides the actual B3Context
45
50
  */
46
- function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", }) {
51
+ function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", }) {
47
52
  const activeAccount = (0, react_3.useActiveAccount)();
48
53
  const [manuallySelectedWallet, setManuallySelectedWallet] = (0, react_2.useState)(undefined);
49
54
  const wallets = (0, react_3.useConnectedWallets)();
@@ -114,5 +119,6 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
114
119
  environment,
115
120
  defaultPermissions,
116
121
  theme,
122
+ clientType,
117
123
  }, children: children }));
118
124
  }
@@ -1,22 +1,25 @@
1
1
  import { PermissionsConfig } from "../../../../global-account/types/permissions";
2
2
  import { Account } from "thirdweb/wallets";
3
+ import { ClientType } from "../../../client-manager";
3
4
  import { B3ContextType } from "./types";
4
5
  /**
5
6
  * Main B3Provider component
6
7
  */
7
- export declare function B3Provider({ theme, children, accountOverride, environment, }: {
8
+ export declare function B3Provider({ theme, children, accountOverride, environment, clientType, }: {
8
9
  theme: "light" | "dark";
9
10
  children: React.ReactNode;
10
11
  accountOverride?: Account;
11
12
  environment: B3ContextType["environment"];
13
+ clientType?: ClientType;
12
14
  }): import("react/jsx-runtime").JSX.Element;
13
15
  /**
14
16
  * Inner provider component that provides the actual B3Context
15
17
  */
16
- export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, }: {
18
+ export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, }: {
17
19
  children: React.ReactNode;
18
20
  accountOverride?: Account;
19
21
  environment: B3ContextType["environment"];
20
22
  defaultPermissions?: PermissionsConfig;
21
23
  theme: "light" | "dark";
24
+ clientType?: ClientType;
22
25
  }): import("react/jsx-runtime").JSX.Element;
@@ -21,13 +21,13 @@ const queryClient = new react_query_1.QueryClient();
21
21
  /**
22
22
  * Main B3Provider component
23
23
  */
24
- function B3Provider({ theme = "light", children, accountOverride, environment, }) {
25
- return ((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_2.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, children: children }) }) }));
24
+ function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", }) {
25
+ return ((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_2.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, clientType: clientType, children: children }) }) }));
26
26
  }
27
27
  /**
28
28
  * Inner provider component that provides the actual B3Context
29
29
  */
30
- function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, theme = "light", }) {
30
+ function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, theme = "light", clientType = "socket", }) {
31
31
  const activeAccount = (0, react_2.useActiveAccount)();
32
32
  const [user, setUser] = (0, react_1.useState)(undefined);
33
33
  // Use given accountOverride or activeAccount from thirdweb
@@ -44,5 +44,6 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
44
44
  environment,
45
45
  defaultPermissions,
46
46
  theme,
47
+ clientType,
47
48
  }, children: children }));
48
49
  }
@@ -1,6 +1,7 @@
1
1
  import { Users } from "@b3dotfun/b3-api";
2
2
  import { PermissionsConfig } from "../../../../global-account/types/permissions";
3
3
  import { Account, Wallet } from "thirdweb/wallets";
4
+ import { ClientType } from "../../../client-manager";
4
5
  /**
5
6
  * Context type for B3Provider
6
7
  */
@@ -16,6 +17,7 @@ export interface B3ContextType {
16
17
  environment?: "development" | "production";
17
18
  defaultPermissions?: PermissionsConfig;
18
19
  theme: "light" | "dark";
20
+ clientType: ClientType;
19
21
  }
20
22
  /**
21
23
  * Context for B3 provider
@@ -16,4 +16,5 @@ exports.B3Context = (0, react_1.createContext)({
16
16
  ready: false,
17
17
  environment: "development",
18
18
  theme: "light",
19
+ clientType: "rest",
19
20
  });
@@ -8,6 +8,7 @@ export { useB3EnsName } from "./useB3EnsName";
8
8
  export { useBestTransactionPath } from "./useBestTransactionPath";
9
9
  export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
10
10
  export * from "./useClaim";
11
+ export { useClient } from "./useClient";
11
12
  export { useConnect } from "./useConnect";
12
13
  export { useExchangeRate } from "./useExchangeRate";
13
14
  export { useFirstEOA } from "./useFirstEOA";
@@ -14,7 +14,7 @@ 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.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
17
+ exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
18
18
  var useAccountAssets_1 = require("./useAccountAssets");
19
19
  Object.defineProperty(exports, "useAccountAssets", { enumerable: true, get: function () { return useAccountAssets_1.useAccountAssets; } });
20
20
  var useAccountWallet_1 = require("./useAccountWallet");
@@ -34,6 +34,8 @@ Object.defineProperty(exports, "useBestTransactionPath", { enumerable: true, get
34
34
  var useChainSwitchWithAction_1 = require("./useChainSwitchWithAction");
35
35
  Object.defineProperty(exports, "useChainSwitchWithAction", { enumerable: true, get: function () { return useChainSwitchWithAction_1.useChainSwitchWithAction; } });
36
36
  __exportStar(require("./useClaim"), exports);
37
+ var useClient_1 = require("./useClient");
38
+ Object.defineProperty(exports, "useClient", { enumerable: true, get: function () { return useClient_1.useClient; } });
37
39
  var useConnect_1 = require("./useConnect");
38
40
  Object.defineProperty(exports, "useConnect", { enumerable: true, get: function () { return useConnect_1.useConnect; } });
39
41
  var useExchangeRate_1 = require("./useExchangeRate");
@@ -0,0 +1,16 @@
1
+ import { ClientType } from "../../client-manager";
2
+ /**
3
+ * Hook to access the current FeathersJS client and client management utilities
4
+ */
5
+ export declare function useClient(): {
6
+ clientType: ClientType;
7
+ getCurrentClient: () => import("@b3dotfun/b3-api").ClientApplication;
8
+ getClientByType: (type: ClientType) => import("@b3dotfun/b3-api").ClientApplication;
9
+ switchClientType: (type: ClientType) => void;
10
+ authenticateWithType: (type: ClientType, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
11
+ authenticateWithBoth: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<{
12
+ socket: import("@feathersjs/authentication").AuthenticationResult | null;
13
+ rest: import("@feathersjs/authentication").AuthenticationResult | null;
14
+ success: boolean;
15
+ }>;
16
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useClient = useClient;
4
+ const react_1 = require("../../../global-account/react");
5
+ const react_2 = require("react");
6
+ const client_manager_1 = require("../../client-manager");
7
+ /**
8
+ * Hook to access the current FeathersJS client and client management utilities
9
+ */
10
+ function useClient() {
11
+ const { clientType } = (0, react_1.useB3)();
12
+ const getCurrentClient = (0, react_2.useCallback)(() => {
13
+ return (0, client_manager_1.getClient)();
14
+ }, []);
15
+ const getClientByTypeCallback = (0, react_2.useCallback)((type) => {
16
+ return (0, client_manager_1.getClientByType)(type);
17
+ }, []);
18
+ const switchClientType = (0, react_2.useCallback)((type) => {
19
+ (0, client_manager_1.setClientType)(type);
20
+ }, []);
21
+ const authenticateWithType = (0, react_2.useCallback)(async (type, accessToken, identityToken, params) => {
22
+ return (0, client_manager_1.authenticateWithClient)(type, accessToken, identityToken, params);
23
+ }, []);
24
+ const authenticateWithBoth = (0, react_2.useCallback)(async (accessToken, identityToken, params) => {
25
+ return (0, client_manager_1.authenticateBoth)(accessToken, identityToken, params);
26
+ }, []);
27
+ return {
28
+ // Current client info
29
+ clientType,
30
+ getCurrentClient,
31
+ // Client management
32
+ getClientByType: getClientByTypeCallback,
33
+ switchClientType,
34
+ // Authentication utilities
35
+ authenticateWithType,
36
+ authenticateWithBoth,
37
+ };
38
+ }
@@ -0,0 +1,17 @@
1
+ import { ClientApplication } from "@b3dotfun/b3-api";
2
+ import { AuthenticationClient } from "@feathersjs/authentication-client";
3
+ export declare const B3_API_URL: string;
4
+ export declare const authenticate: (app: ClientApplication, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<import("@feathersjs/authentication").AuthenticationResult | null>;
5
+ export declare class MyAuthenticationClient extends AuthenticationClient {
6
+ getFromLocation(location: any): Promise<any>;
7
+ }
8
+ export declare const clientOptions: {
9
+ Authentication: typeof MyAuthenticationClient;
10
+ jwtStrategy: string;
11
+ storage: {
12
+ getItem: (key: string) => string | undefined;
13
+ setItem: (key: string, value: string) => void;
14
+ removeItem: (key: string) => void;
15
+ };
16
+ storageKey: string;
17
+ };