@volr/react 0.1.2 → 0.1.4
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.cjs +33 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -7
- package/dist/index.d.ts +0 -7
- package/dist/index.js +33 -21
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
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
|
-
//
|
|
72
|
+
// ../shared/src/constants/storage.ts
|
|
73
73
|
var STORAGE_KEYS = {
|
|
74
74
|
accessToken: "volr:accessToken",
|
|
75
75
|
user: "volr:user",
|
|
@@ -345,6 +345,21 @@ 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 devOverride = anyConfig.__devApiBaseUrl;
|
|
353
|
+
if (devOverride && typeof devOverride === "string") {
|
|
354
|
+
return devOverride.replace(/\/+$/, "");
|
|
355
|
+
}
|
|
356
|
+
const override = anyConfig.apiBaseUrl;
|
|
357
|
+
if (override && typeof override === "string") {
|
|
358
|
+
return override.replace(/\/+$/, "");
|
|
359
|
+
}
|
|
360
|
+
return DEFAULT_API_BASE_URL;
|
|
361
|
+
}
|
|
362
|
+
|
|
348
363
|
// src/config/webauthn.ts
|
|
349
364
|
var AUTHENTICATOR_SELECTION = {
|
|
350
365
|
authenticatorAttachment: "platform",
|
|
@@ -644,18 +659,18 @@ function VolrProvider({ config, children }) {
|
|
|
644
659
|
providerCountRef.current--;
|
|
645
660
|
};
|
|
646
661
|
}, []);
|
|
662
|
+
const apiBaseUrl = resolveApiBaseUrl(config);
|
|
647
663
|
const client = useMemo(() => {
|
|
648
664
|
if (!config.projectApiKey) {
|
|
649
665
|
throw new Error(
|
|
650
666
|
"VolrProvider requires config.projectApiKey. Please set VITE_PROJECT_API_KEY environment variable or provide projectApiKey in config."
|
|
651
667
|
);
|
|
652
668
|
}
|
|
653
|
-
const baseUrl = config.__devApiBaseUrl || config.apiBaseUrl;
|
|
654
669
|
return new APIClient({
|
|
655
|
-
baseUrl,
|
|
670
|
+
baseUrl: apiBaseUrl,
|
|
656
671
|
apiKey: config.projectApiKey
|
|
657
672
|
});
|
|
658
|
-
}, [
|
|
673
|
+
}, [apiBaseUrl, config.projectApiKey]);
|
|
659
674
|
const [user, setUser] = useState(() => {
|
|
660
675
|
if (typeof window === "undefined") return null;
|
|
661
676
|
const userStr = safeStorage.getItem(STORAGE_KEYS.user);
|
|
@@ -1860,9 +1875,10 @@ function useVolrLogin() {
|
|
|
1860
1875
|
credentialId: u.credentialId ?? void 0
|
|
1861
1876
|
};
|
|
1862
1877
|
}, []);
|
|
1878
|
+
const apiBaseUrl = resolveApiBaseUrl(config);
|
|
1863
1879
|
const api = useMemo(
|
|
1864
|
-
() => createAxiosInstance(
|
|
1865
|
-
[
|
|
1880
|
+
() => createAxiosInstance(apiBaseUrl, config.projectApiKey),
|
|
1881
|
+
[apiBaseUrl, config.projectApiKey]
|
|
1866
1882
|
);
|
|
1867
1883
|
const requestEmailCode = useCallback(
|
|
1868
1884
|
async (email) => {
|
|
@@ -1930,11 +1946,11 @@ function useVolrLogin() {
|
|
|
1930
1946
|
const handleSocialLogin = useCallback(
|
|
1931
1947
|
async (provider) => {
|
|
1932
1948
|
if (typeof window !== "undefined") {
|
|
1933
|
-
const baseUrl =
|
|
1949
|
+
const baseUrl = apiBaseUrl.replace(/\/+$/, "");
|
|
1934
1950
|
window.location.href = `${baseUrl}/auth/${provider}`;
|
|
1935
1951
|
}
|
|
1936
1952
|
},
|
|
1937
|
-
[
|
|
1953
|
+
[apiBaseUrl]
|
|
1938
1954
|
);
|
|
1939
1955
|
const requestSiweNonce = useCallback(async () => {
|
|
1940
1956
|
const response = await api.get("/auth/siwe/nonce");
|
|
@@ -2028,6 +2044,7 @@ function useVolrAuthCallback(options = {}) {
|
|
|
2028
2044
|
credentialId: u.credentialId ?? void 0
|
|
2029
2045
|
};
|
|
2030
2046
|
}, []);
|
|
2047
|
+
const apiBaseUrl = resolveApiBaseUrl(config);
|
|
2031
2048
|
useEffect(() => {
|
|
2032
2049
|
const handleCallback = async () => {
|
|
2033
2050
|
if (typeof window === "undefined") return;
|
|
@@ -2054,7 +2071,7 @@ function useVolrAuthCallback(options = {}) {
|
|
|
2054
2071
|
setIsNewUser(isNew);
|
|
2055
2072
|
await refreshAccessToken();
|
|
2056
2073
|
const api = createAxiosInstance(
|
|
2057
|
-
|
|
2074
|
+
apiBaseUrl,
|
|
2058
2075
|
config.projectApiKey
|
|
2059
2076
|
);
|
|
2060
2077
|
const userRes = await api.get(`/auth/onboarding/${userId}`);
|
|
@@ -2082,7 +2099,7 @@ function useVolrAuthCallback(options = {}) {
|
|
|
2082
2099
|
}
|
|
2083
2100
|
};
|
|
2084
2101
|
handleCallback();
|
|
2085
|
-
}, [
|
|
2102
|
+
}, [apiBaseUrl, config.projectApiKey, refreshAccessToken, setAccessToken, setUser, toVolrUser]);
|
|
2086
2103
|
return {
|
|
2087
2104
|
isLoading,
|
|
2088
2105
|
error,
|
|
@@ -2383,6 +2400,7 @@ function usePasskeyEnrollment() {
|
|
|
2383
2400
|
const [isEnrolling, setIsEnrolling] = useState(false);
|
|
2384
2401
|
const [error, setError] = useState(null);
|
|
2385
2402
|
const isEnrollingRef = useRef(false);
|
|
2403
|
+
const apiBaseUrl = resolveApiBaseUrl(config);
|
|
2386
2404
|
const enroll = useCallback(async () => {
|
|
2387
2405
|
if (isEnrollingRef.current || isEnrolling) return;
|
|
2388
2406
|
isEnrollingRef.current = true;
|
|
@@ -2398,13 +2416,15 @@ function usePasskeyEnrollment() {
|
|
|
2398
2416
|
}
|
|
2399
2417
|
const accessToken = client.getAccessToken();
|
|
2400
2418
|
if (!accessToken) {
|
|
2401
|
-
throw new Error(
|
|
2419
|
+
throw new Error(
|
|
2420
|
+
"Access token is required for passkey enrollment. Please login first."
|
|
2421
|
+
);
|
|
2402
2422
|
}
|
|
2403
2423
|
const projectId = user.id;
|
|
2404
2424
|
setStep("encrypting");
|
|
2405
2425
|
const result = await enrollPasskey({
|
|
2406
2426
|
client,
|
|
2407
|
-
baseUrl:
|
|
2427
|
+
baseUrl: apiBaseUrl,
|
|
2408
2428
|
apiKey: config.projectApiKey,
|
|
2409
2429
|
userId: user.id,
|
|
2410
2430
|
userEmail: user.email,
|
|
@@ -2449,15 +2469,7 @@ function usePasskeyEnrollment() {
|
|
|
2449
2469
|
setIsEnrolling(false);
|
|
2450
2470
|
isEnrollingRef.current = false;
|
|
2451
2471
|
}
|
|
2452
|
-
}, [
|
|
2453
|
-
client,
|
|
2454
|
-
config.apiBaseUrl,
|
|
2455
|
-
config.projectApiKey,
|
|
2456
|
-
user,
|
|
2457
|
-
setProvider,
|
|
2458
|
-
setUser,
|
|
2459
|
-
isEnrolling
|
|
2460
|
-
]);
|
|
2472
|
+
}, [apiBaseUrl, client, config.projectApiKey, user, setProvider, setUser, isEnrolling]);
|
|
2461
2473
|
return {
|
|
2462
2474
|
enroll,
|
|
2463
2475
|
step,
|