@pear-protocol/hyperliquid-sdk 0.0.56 → 0.0.57

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.
@@ -1,25 +1,12 @@
1
1
  import React, { ReactNode } from 'react';
2
- import type { UserProfile } from './types';
3
- import { AuthStatus } from './types';
4
2
  export interface PearHyperliquidContextType {
3
+ clientId: string;
5
4
  apiBaseUrl: string;
6
5
  wsUrl: string;
7
- address: string | null;
8
- setAddress: (address: string | null) => void;
9
6
  isConnected: boolean;
10
7
  lastError: string | null;
11
8
  nativeIsConnected: boolean;
12
9
  nativeLastError: string | null;
13
- authStatus: AuthStatus;
14
- isAuthenticated: boolean;
15
- accessToken: string | null;
16
- user: UserProfile | null;
17
- authError: string | null;
18
- getEip712: (address: string) => Promise<any>;
19
- loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
20
- loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
21
- refreshTokens: () => Promise<any>;
22
- logout: () => Promise<void>;
23
10
  }
24
11
  export declare const PearHyperliquidContext: React.Context<PearHyperliquidContextType | undefined>;
25
12
  interface PearHyperliquidProviderProps {
@@ -37,19 +24,4 @@ export declare const PearHyperliquidProvider: React.FC<PearHyperliquidProviderPr
37
24
  * Prefer using the more specific hooks below when possible.
38
25
  */
39
26
  export declare function usePearHyperliquid(): PearHyperliquidContextType;
40
- /**
41
- * Provider-aware Auth hook. Uses auth state/actions provided by PearHyperliquidProvider.
42
- * Callers do not need to pass baseUrl/clientId.
43
- */
44
- export declare function usePearAuth(): {
45
- readonly status: AuthStatus;
46
- readonly isAuthenticated: boolean;
47
- readonly user: UserProfile | null;
48
- readonly error: string | null;
49
- readonly getEip712: (address: string) => Promise<any>;
50
- readonly loginWithSignedMessage: (address: string, signature: string, timestamp: number) => Promise<void>;
51
- readonly loginWithPrivyToken: (address: string, appId: string, accessToken: string) => Promise<void>;
52
- readonly refreshTokens: () => Promise<any>;
53
- readonly logout: () => Promise<void>;
54
- };
55
27
  export {};
package/dist/types.d.ts CHANGED
@@ -338,12 +338,6 @@ export interface AddressState {
338
338
  autoConnect: boolean;
339
339
  previousAddresses: string[];
340
340
  }
341
- export declare enum AuthStatus {
342
- Idle = "idle",
343
- Authenticating = "authenticating",
344
- Authenticated = "authenticated",
345
- Error = "error"
346
- }
347
341
  export interface UseAuthOptions {
348
342
  baseUrl: string;
349
343
  clientId: string;
@@ -359,7 +353,7 @@ export interface EIP712AuthDetails {
359
353
  name: string;
360
354
  version: string;
361
355
  chainId: number;
362
- verifyingContract: string;
356
+ verifyingContract: `0x${string}`;
363
357
  };
364
358
  types: Record<string, Array<{
365
359
  name: string;
@@ -1,3 +1,26 @@
1
+ import type { AxiosInstance } from 'axios';
1
2
  import { ApiErrorResponse } from '../types';
2
3
  export declare function toApiError(error: unknown): ApiErrorResponse;
3
4
  export declare function joinUrl(baseUrl: string, path: string): string;
5
+ /**
6
+ * Shared Axios instance with interceptors.
7
+ * - Request: inject Authorization headers from buildAuthHeaders when absent
8
+ * - Response: on 401, clear tokens and emit a logout event
9
+ */
10
+ export declare const apiClient: AxiosInstance;
11
+ /**
12
+ * Attach auth-aware Axios interceptors to `apiClient`.
13
+ * - Request: adds `Authorization: Bearer <accessToken>` for requests to `apiBaseUrl`.
14
+ * - Response: if a request returns 401, attempts token refresh and retries the request.
15
+ * If the 401 came from the refresh endpoint (or refresh fails/returns 401), calls `logout()`.
16
+ *
17
+ */
18
+ export declare function addAuthInterceptors(params: {
19
+ apiBaseUrl: string;
20
+ getAccessToken: () => string | null;
21
+ refreshTokens: () => Promise<{
22
+ accessToken: string;
23
+ refreshToken: string;
24
+ } | any>;
25
+ logout: () => Promise<void> | void;
26
+ }): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.56",
3
+ "version": "0.0.57",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",