@hfunlabs/hypurr-connect 0.1.21 → 0.1.22
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/README.md +6 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/HypurrConnectProvider.tsx +10 -0
- package/src/grpc.ts +5 -1
- package/src/types.ts +2 -0
package/package.json
CHANGED
|
@@ -263,6 +263,14 @@ function normalizeScopes(scope?: string | string[]): string {
|
|
|
263
263
|
return scope?.trim() || DEFAULT_TELEGRAM_SCOPES.join(" ");
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
+
function normalizeClientId(clientId: unknown): string {
|
|
267
|
+
const normalized = typeof clientId === "string" ? clientId.trim() : "";
|
|
268
|
+
if (!normalized) {
|
|
269
|
+
throw new Error("[HypurrConnect] config.client_id is required.");
|
|
270
|
+
}
|
|
271
|
+
return normalized;
|
|
272
|
+
}
|
|
273
|
+
|
|
266
274
|
function isTelegramAuthMessage(data: unknown): data is {
|
|
267
275
|
type: typeof TELEGRAM_AUTH_MESSAGE;
|
|
268
276
|
token: string;
|
|
@@ -1364,6 +1372,7 @@ export function HypurrConnectProvider({
|
|
|
1364
1372
|
const authUrl = new URL(
|
|
1365
1373
|
config.telegram?.authHubUrl || DEFAULT_AUTH_HUB_URL,
|
|
1366
1374
|
);
|
|
1375
|
+
authUrl.searchParams.set("client_id", normalizeClientId(config.client_id));
|
|
1367
1376
|
authUrl.searchParams.set("return_to", returnTo);
|
|
1368
1377
|
authUrl.searchParams.set("state", state);
|
|
1369
1378
|
authUrl.searchParams.set("scope", normalizeScopes(config.telegram?.scope));
|
|
@@ -1392,6 +1401,7 @@ export function HypurrConnectProvider({
|
|
|
1392
1401
|
|
|
1393
1402
|
window.location.assign(authUrl.toString());
|
|
1394
1403
|
}, [
|
|
1404
|
+
config.client_id,
|
|
1395
1405
|
config.telegram?.authHubUrl,
|
|
1396
1406
|
config.telegram?.returnTo,
|
|
1397
1407
|
config.telegram?.scope,
|
package/src/grpc.ts
CHANGED
|
@@ -5,9 +5,13 @@ import type { HypurrConnectConfig } from "./types";
|
|
|
5
5
|
|
|
6
6
|
const DEFAULT_GRPC_URL = "https://grpc.hypurr.fun";
|
|
7
7
|
|
|
8
|
+
function resolveGrpcUrl(config: HypurrConnectConfig): string {
|
|
9
|
+
return config.grpcUrl?.trim() || DEFAULT_GRPC_URL;
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
function createTransport(config: HypurrConnectConfig) {
|
|
9
13
|
return new GrpcWebFetchTransport({
|
|
10
|
-
baseUrl: config
|
|
14
|
+
baseUrl: resolveGrpcUrl(config),
|
|
11
15
|
timeout: config.grpcTimeout ?? 15_000,
|
|
12
16
|
});
|
|
13
17
|
}
|
package/src/types.ts
CHANGED
|
@@ -20,6 +20,8 @@ import type { HyperliquidWallet } from "hypurr-grpc/ts/hypurr/wallet";
|
|
|
20
20
|
// ─── Config ──────────────────────────────────────────────────────
|
|
21
21
|
|
|
22
22
|
export interface HypurrConnectConfig {
|
|
23
|
+
/** Auth hub client identifier. Sent as `client_id` during Telegram login. */
|
|
24
|
+
client_id: string;
|
|
23
25
|
/** gRPC-web base URL. Defaults to https://grpc.hypurr.fun. */
|
|
24
26
|
grpcUrl?: string;
|
|
25
27
|
/** Media base URL for user-uploaded assets. Defaults to https://media.hypurr.fun. */
|