@hfunlabs/hypurr-connect 0.1.9 → 0.1.11

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.
@@ -6,7 +6,6 @@ import {
6
6
  } from "framer-motion";
7
7
  import {
8
8
  useCallback,
9
- useEffect,
10
9
  useSyncExternalStore,
11
10
  type CSSProperties,
12
11
  type ReactNode,
@@ -14,8 +13,6 @@ import {
14
13
  import { useHypurrConnectInternal } from "./HypurrConnectProvider";
15
14
  import { MetaMaskColorIcon } from "./icons/MetaMaskColorIcon";
16
15
  import { TelegramColorIcon } from "./icons/TelegramColorIcon";
17
- import { TelegramLoginWidget } from "./TelegramLoginWidget";
18
- import type { TelegramLoginData } from "./types";
19
16
 
20
17
  export interface LoginModalProps {
21
18
  onConnectWallet: () => void;
@@ -131,62 +128,13 @@ function HoverButton({
131
128
  }
132
129
 
133
130
  export function LoginModal({ onConnectWallet, walletIcon }: LoginModalProps) {
134
- const {
135
- loginTelegram,
136
- loginModalOpen,
137
- closeLoginModal,
138
- botId,
139
- botUsername,
140
- useWidget,
141
- } = useHypurrConnectInternal();
142
-
143
- const handleTelegramAuth = useCallback(
144
- (user: TelegramLoginData) => {
145
- loginTelegram(user);
146
- closeLoginModal();
147
- },
148
- [loginTelegram, closeLoginModal],
149
- );
131
+ const { loginTelegram, loginModalOpen, closeLoginModal } =
132
+ useHypurrConnectInternal();
150
133
 
151
- useEffect(() => {
152
- if (!loginModalOpen) return;
153
- function onMessage(e: MessageEvent) {
154
- if (e.origin !== "https://oauth.telegram.org") return;
155
- try {
156
- const data = typeof e.data === "string" ? JSON.parse(e.data) : e.data;
157
- if (data?.event === "auth_result" && data.result) {
158
- const r = data.result;
159
- handleTelegramAuth({
160
- id: r.id,
161
- first_name: r.first_name ?? "",
162
- last_name: r.last_name ?? undefined,
163
- username: r.username ?? undefined,
164
- photo_url: r.photo_url ?? undefined,
165
- auth_date: r.auth_date,
166
- hash: r.hash,
167
- });
168
- }
169
- } catch {
170
- /* ignore non-JSON */
171
- }
172
- }
173
- window.addEventListener("message", onMessage);
174
- return () => window.removeEventListener("message", onMessage);
175
- }, [loginModalOpen, handleTelegramAuth]);
176
-
177
- const openTelegramOAuth = useCallback(() => {
178
- const origin = encodeURIComponent(window.location.origin);
179
- const url = `https://oauth.telegram.org/auth?bot_id=${botId}&origin=${origin}&request_access=write`;
180
- const w = 550;
181
- const h = 470;
182
- const left = window.screenX + (window.outerWidth - w) / 2;
183
- const top = window.screenY + (window.outerHeight - h) / 2;
184
- window.open(
185
- url,
186
- "telegram_auth",
187
- `width=${w},height=${h},left=${left},top=${top}`,
188
- );
189
- }, [botId]);
134
+ const handleTelegramAuth = useCallback(() => {
135
+ closeLoginModal();
136
+ loginTelegram();
137
+ }, [loginTelegram, closeLoginModal]);
190
138
 
191
139
  const isMobile = useIsMobile();
192
140
 
@@ -202,17 +150,10 @@ export function LoginModal({ onConnectWallet, walletIcon }: LoginModalProps) {
202
150
  overflow: "hidden",
203
151
  }}
204
152
  >
205
- {useWidget && botUsername ? (
206
- <TelegramLoginWidget
207
- botUsername={botUsername}
208
- onAuth={handleTelegramAuth}
209
- />
210
- ) : (
211
- <HoverButton onClick={openTelegramOAuth}>
212
- <TelegramColorIcon style={iconSize} />
213
- Telegram
214
- </HoverButton>
215
- )}
153
+ <HoverButton onClick={handleTelegramAuth}>
154
+ <TelegramColorIcon style={iconSize} />
155
+ Telegram
156
+ </HoverButton>
216
157
  </div>
217
158
 
218
159
  <div style={dividerStyle} />
@@ -258,13 +199,13 @@ export function LoginModal({ onConnectWallet, walletIcon }: LoginModalProps) {
258
199
  >
259
200
  <motion.div
260
201
  style={modalBoxStyle}
261
- initial={{ opacity: 0, scale: 0.95, y: 10 }}
262
- animate={{ opacity: 1, scale: 1, y: 0 }}
263
- exit={{ opacity: 0, scale: 0.95, y: 10 }}
264
- transition={{ duration: 0.2, ease: "easeOut" }}
202
+ initial={{ scale: 0.96, opacity: 0, y: 8 }}
203
+ animate={{ scale: 1, opacity: 1, y: 0 }}
204
+ exit={{ scale: 0.96, opacity: 0, y: 8 }}
205
+ transition={{ duration: 0.12 }}
265
206
  onClick={(e) => e.stopPropagation()}
266
207
  >
267
- <p style={headingStyle}>Connect</p>
208
+ <h2 style={headingStyle}>Connect</h2>
268
209
  {modalContent}
269
210
  </motion.div>
270
211
  </motion.div>
package/src/grpc.ts CHANGED
@@ -3,11 +3,11 @@ import { StaticClient } from "hypurr-grpc/ts/hypurr/static/static_service.client
3
3
  import { TelegramClient } from "hypurr-grpc/ts/hypurr/telegram/telegram_service.client";
4
4
  import type { HypurrConnectConfig } from "./types";
5
5
 
6
- const GRPC_URL = "https://grpc.hypurr.fun";
6
+ const DEFAULT_GRPC_URL = "https://grpc.hypurr.fun";
7
7
 
8
8
  function createTransport(config: HypurrConnectConfig) {
9
9
  return new GrpcWebFetchTransport({
10
- baseUrl: GRPC_URL,
10
+ baseUrl: config.grpcUrl ?? DEFAULT_GRPC_URL,
11
11
  timeout: config.grpcTimeout ?? 15_000,
12
12
  });
13
13
  }
package/src/index.ts CHANGED
@@ -4,8 +4,6 @@ export {
4
4
  } from "./HypurrConnectProvider";
5
5
  export { LoginModal } from "./LoginModal";
6
6
  export type { LoginModalProps } from "./LoginModal";
7
- export { TelegramLoginWidget } from "./TelegramLoginWidget";
8
- export type { TelegramLoginWidgetProps } from "./TelegramLoginWidget";
9
7
  export { GrpcExchangeTransport } from "./GrpcExchangeTransport";
10
8
  export type { GrpcExchangeTransportConfig } from "./GrpcExchangeTransport";
11
9
  export { createTelegramClient, createStaticClient } from "./grpc";
package/src/types.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { ExchangeClient } from "@hfunlabs/hyperliquid";
2
+ import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
2
3
  import type { StaticClient } from "hypurr-grpc/ts/hypurr/static/static_service.client";
3
4
  import type {
4
5
  HyperliquidScaleCreateRequest,
@@ -16,19 +17,33 @@ import type { HyperliquidWallet } from "hypurr-grpc/ts/hypurr/wallet";
16
17
  // ─── Config ──────────────────────────────────────────────────────
17
18
 
18
19
  export interface HypurrConnectConfig {
20
+ /** gRPC-web base URL. Defaults to https://grpc.hypurr.fun. */
21
+ grpcUrl?: string;
22
+ /** Media base URL for user-uploaded assets. Defaults to https://media.hypurr.fun. */
23
+ mediaUrl?: string;
19
24
  grpcTimeout?: number;
20
25
  isTestnet?: boolean;
21
26
  /** Polling interval in ms for TWAP/Scale session updates. Default 5000. Set 0 to disable. */
22
27
  sessionPollInterval?: number;
23
28
  telegram: {
24
- botUsername: string;
29
+ /** Deprecated for the hub flow; retained for older consumers. */
30
+ botUsername?: string;
31
+ /** Deprecated for the hub flow; retained for older consumers. */
25
32
  botId?: string;
26
- useWidget: boolean;
33
+ /** Deprecated: Telegram login is now handled by the auth hub. */
34
+ useWidget?: boolean;
35
+ /** Auth hub login URL. Defaults to https://auth.hypurr.fun/login. */
36
+ authHubUrl?: string;
37
+ /** Optional callback URL. Defaults to the current page without auth query params. */
38
+ returnTo?: string | (() => string);
39
+ /** Requested hub scopes. Defaults to the scopes required by this SDK. */
40
+ scope?: string | string[];
27
41
  };
28
42
  }
29
43
 
30
44
  // ─── Telegram login ──────────────────────────────────────────────
31
45
 
46
+ /** @deprecated Telegram login is handled by the auth hub; raw Telegram data is no longer used by the provider. */
32
47
  export interface TelegramLoginData {
33
48
  id: number;
34
49
  first_name: string;
@@ -180,12 +195,18 @@ export interface HypurrConnectState {
180
195
  }) => Promise<void>;
181
196
 
182
197
  // TWAP sessions (Telegram only)
183
- createTwap: (params: TwapCreateParams) => Promise<HyperliquidWalletTwapSession>;
184
- modifyTwap: (params: TwapModifyParams) => Promise<HyperliquidWalletTwapSession>;
198
+ createTwap: (
199
+ params: TwapCreateParams,
200
+ ) => Promise<HyperliquidWalletTwapSession>;
201
+ modifyTwap: (
202
+ params: TwapModifyParams,
203
+ ) => Promise<HyperliquidWalletTwapSession>;
185
204
  cancelTwap: (sessionId: number) => Promise<void>;
186
205
 
187
206
  // Scale sessions (Telegram only)
188
- createScale: (params: ScaleCreateParams) => Promise<HyperliquidWalletScaleSession>;
207
+ createScale: (
208
+ params: ScaleCreateParams,
209
+ ) => Promise<HyperliquidWalletScaleSession>;
189
210
  cancelScale: (sessionId: number) => Promise<void>;
190
211
 
191
212
  // Login modal
@@ -210,7 +231,10 @@ export interface HypurrConnectState {
210
231
  botId: string;
211
232
 
212
233
  // Low-level access
234
+ /** Deprecated: JWT auth leaves authData empty; use `telegramRpcOptions` for low-level calls. */
213
235
  authDataMap: Record<string, string>;
236
+ authToken: string | null;
237
+ telegramRpcOptions?: RpcOptions;
214
238
  telegramClient: TelegramClient;
215
239
  staticClient: StaticClient;
216
240
  }