@volr/react 0.1.2 → 0.1.3

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/dist/index.d.cts CHANGED
@@ -189,7 +189,6 @@ interface VolrUser {
189
189
  * Volr configuration
190
190
  */
191
191
  type VolrConfig = {
192
- apiBaseUrl: string;
193
192
  defaultChainId: number;
194
193
  projectApiKey: string;
195
194
  rpcOverrides?: Record<string, string>;
@@ -201,12 +200,6 @@ type VolrConfig = {
201
200
  * Deposit/Topup configuration for multi-chain, multi-token support
202
201
  */
203
202
  deposit?: DepositConfig;
204
- /**
205
- * @internal 개발용: API Base URL 오버라이드
206
- * 일반 사용자는 타입 체크로 접근 불가
207
- * 개발 시에는 @ts-expect-error 주석 필요
208
- */
209
- __devApiBaseUrl?: string;
210
203
  };
211
204
  /**
212
205
  * Public context value
package/dist/index.d.ts CHANGED
@@ -189,7 +189,6 @@ interface VolrUser {
189
189
  * Volr configuration
190
190
  */
191
191
  type VolrConfig = {
192
- apiBaseUrl: string;
193
192
  defaultChainId: number;
194
193
  projectApiKey: string;
195
194
  rpcOverrides?: Record<string, string>;
@@ -201,12 +200,6 @@ type VolrConfig = {
201
200
  * Deposit/Topup configuration for multi-chain, multi-token support
202
201
  */
203
202
  deposit?: DepositConfig;
204
- /**
205
- * @internal 개발용: API Base URL 오버라이드
206
- * 일반 사용자는 타입 체크로 접근 불가
207
- * 개발 시에는 @ts-expect-error 주석 필요
208
- */
209
- __devApiBaseUrl?: string;
210
203
  };
211
204
  /**
212
205
  * Public context value
package/dist/index.js CHANGED
@@ -69,7 +69,7 @@ var safeStorage = {
69
69
  }
70
70
  };
71
71
 
72
- // node_modules/@volr/shared/src/constants/storage.ts
72
+ // ../shared/src/constants/storage.ts
73
73
  var STORAGE_KEYS = {
74
74
  accessToken: "volr:accessToken",
75
75
  user: "volr:user",
@@ -345,6 +345,17 @@ var SessionSync = class {
345
345
  }
346
346
  };
347
347
 
348
+ // src/config/backend.ts
349
+ var DEFAULT_API_BASE_URL = "https://api.volr.io";
350
+ function resolveApiBaseUrl(config) {
351
+ const anyConfig = config;
352
+ const override = anyConfig.apiBaseUrl;
353
+ if (override && typeof override === "string") {
354
+ return override.replace(/\/+$/, "");
355
+ }
356
+ return DEFAULT_API_BASE_URL;
357
+ }
358
+
348
359
  // src/config/webauthn.ts
349
360
  var AUTHENTICATOR_SELECTION = {
350
361
  authenticatorAttachment: "platform",
@@ -644,18 +655,18 @@ function VolrProvider({ config, children }) {
644
655
  providerCountRef.current--;
645
656
  };
646
657
  }, []);
658
+ const apiBaseUrl = resolveApiBaseUrl(config);
647
659
  const client = useMemo(() => {
648
660
  if (!config.projectApiKey) {
649
661
  throw new Error(
650
662
  "VolrProvider requires config.projectApiKey. Please set VITE_PROJECT_API_KEY environment variable or provide projectApiKey in config."
651
663
  );
652
664
  }
653
- const baseUrl = config.__devApiBaseUrl || config.apiBaseUrl;
654
665
  return new APIClient({
655
- baseUrl,
666
+ baseUrl: apiBaseUrl,
656
667
  apiKey: config.projectApiKey
657
668
  });
658
- }, [config.apiBaseUrl, config.projectApiKey]);
669
+ }, [apiBaseUrl, config.projectApiKey]);
659
670
  const [user, setUser] = useState(() => {
660
671
  if (typeof window === "undefined") return null;
661
672
  const userStr = safeStorage.getItem(STORAGE_KEYS.user);
@@ -1860,9 +1871,10 @@ function useVolrLogin() {
1860
1871
  credentialId: u.credentialId ?? void 0
1861
1872
  };
1862
1873
  }, []);
1874
+ const apiBaseUrl = resolveApiBaseUrl(config);
1863
1875
  const api = useMemo(
1864
- () => createAxiosInstance(config.apiBaseUrl, config.projectApiKey),
1865
- [config.apiBaseUrl, config.projectApiKey]
1876
+ () => createAxiosInstance(apiBaseUrl, config.projectApiKey),
1877
+ [apiBaseUrl, config.projectApiKey]
1866
1878
  );
1867
1879
  const requestEmailCode = useCallback(
1868
1880
  async (email) => {
@@ -1930,11 +1942,11 @@ function useVolrLogin() {
1930
1942
  const handleSocialLogin = useCallback(
1931
1943
  async (provider) => {
1932
1944
  if (typeof window !== "undefined") {
1933
- const baseUrl = config.apiBaseUrl.replace(/\/+$/, "");
1945
+ const baseUrl = apiBaseUrl.replace(/\/+$/, "");
1934
1946
  window.location.href = `${baseUrl}/auth/${provider}`;
1935
1947
  }
1936
1948
  },
1937
- [config.apiBaseUrl]
1949
+ [apiBaseUrl]
1938
1950
  );
1939
1951
  const requestSiweNonce = useCallback(async () => {
1940
1952
  const response = await api.get("/auth/siwe/nonce");
@@ -2028,6 +2040,7 @@ function useVolrAuthCallback(options = {}) {
2028
2040
  credentialId: u.credentialId ?? void 0
2029
2041
  };
2030
2042
  }, []);
2043
+ const apiBaseUrl = resolveApiBaseUrl(config);
2031
2044
  useEffect(() => {
2032
2045
  const handleCallback = async () => {
2033
2046
  if (typeof window === "undefined") return;
@@ -2054,7 +2067,7 @@ function useVolrAuthCallback(options = {}) {
2054
2067
  setIsNewUser(isNew);
2055
2068
  await refreshAccessToken();
2056
2069
  const api = createAxiosInstance(
2057
- config.apiBaseUrl,
2070
+ apiBaseUrl,
2058
2071
  config.projectApiKey
2059
2072
  );
2060
2073
  const userRes = await api.get(`/auth/onboarding/${userId}`);
@@ -2082,7 +2095,7 @@ function useVolrAuthCallback(options = {}) {
2082
2095
  }
2083
2096
  };
2084
2097
  handleCallback();
2085
- }, [config.apiBaseUrl, config.projectApiKey, refreshAccessToken, setAccessToken, setUser, toVolrUser]);
2098
+ }, [apiBaseUrl, config.projectApiKey, refreshAccessToken, setAccessToken, setUser, toVolrUser]);
2086
2099
  return {
2087
2100
  isLoading,
2088
2101
  error,
@@ -2383,6 +2396,7 @@ function usePasskeyEnrollment() {
2383
2396
  const [isEnrolling, setIsEnrolling] = useState(false);
2384
2397
  const [error, setError] = useState(null);
2385
2398
  const isEnrollingRef = useRef(false);
2399
+ const apiBaseUrl = resolveApiBaseUrl(config);
2386
2400
  const enroll = useCallback(async () => {
2387
2401
  if (isEnrollingRef.current || isEnrolling) return;
2388
2402
  isEnrollingRef.current = true;
@@ -2398,13 +2412,15 @@ function usePasskeyEnrollment() {
2398
2412
  }
2399
2413
  const accessToken = client.getAccessToken();
2400
2414
  if (!accessToken) {
2401
- throw new Error("Access token is required for passkey enrollment. Please login first.");
2415
+ throw new Error(
2416
+ "Access token is required for passkey enrollment. Please login first."
2417
+ );
2402
2418
  }
2403
2419
  const projectId = user.id;
2404
2420
  setStep("encrypting");
2405
2421
  const result = await enrollPasskey({
2406
2422
  client,
2407
- baseUrl: config.apiBaseUrl,
2423
+ baseUrl: apiBaseUrl,
2408
2424
  apiKey: config.projectApiKey,
2409
2425
  userId: user.id,
2410
2426
  userEmail: user.email,
@@ -2449,15 +2465,7 @@ function usePasskeyEnrollment() {
2449
2465
  setIsEnrolling(false);
2450
2466
  isEnrollingRef.current = false;
2451
2467
  }
2452
- }, [
2453
- client,
2454
- config.apiBaseUrl,
2455
- config.projectApiKey,
2456
- user,
2457
- setProvider,
2458
- setUser,
2459
- isEnrolling
2460
- ]);
2468
+ }, [apiBaseUrl, client, config.projectApiKey, user, setProvider, setUser, isEnrolling]);
2461
2469
  return {
2462
2470
  enroll,
2463
2471
  step,