@volr/react 0.1.135 → 0.2.0
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 +296 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -1
- package/dist/index.d.ts +70 -1
- package/dist/index.js +294 -88
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -18980,6 +18980,28 @@ function normalizeCall(call2) {
|
|
|
18980
18980
|
function normalizeCalls(calls) {
|
|
18981
18981
|
return calls.map(normalizeCall);
|
|
18982
18982
|
}
|
|
18983
|
+
|
|
18984
|
+
// src/errors/wallet-errors.ts
|
|
18985
|
+
var WalletRequiredError = class _WalletRequiredError extends Error {
|
|
18986
|
+
constructor(action, message) {
|
|
18987
|
+
super(
|
|
18988
|
+
message || "Wallet is required for this action. Please create a Volr account (passkey/MPC) or provide a wallet provider."
|
|
18989
|
+
);
|
|
18990
|
+
this.code = "WALLET_REQUIRED";
|
|
18991
|
+
this.name = "WalletRequiredError";
|
|
18992
|
+
this.action = action;
|
|
18993
|
+
Object.setPrototypeOf(this, _WalletRequiredError.prototype);
|
|
18994
|
+
}
|
|
18995
|
+
};
|
|
18996
|
+
function isWalletRequiredError(error) {
|
|
18997
|
+
if (error instanceof WalletRequiredError) return true;
|
|
18998
|
+
if (error && typeof error === "object" && error.code === "WALLET_REQUIRED") {
|
|
18999
|
+
return true;
|
|
19000
|
+
}
|
|
19001
|
+
return false;
|
|
19002
|
+
}
|
|
19003
|
+
|
|
19004
|
+
// src/wallet/signer.ts
|
|
18983
19005
|
async function resolveSigner(input) {
|
|
18984
19006
|
const { explicitSigner, provider, chainId, client, user, setProvider } = input;
|
|
18985
19007
|
if (explicitSigner) {
|
|
@@ -19038,8 +19060,9 @@ async function resolveSigner(input) {
|
|
|
19038
19060
|
const signer = await sdkCore.selectSigner(signerContext);
|
|
19039
19061
|
return { signer, activeProvider: restoredProvider };
|
|
19040
19062
|
}
|
|
19041
|
-
throw new
|
|
19042
|
-
"
|
|
19063
|
+
throw new WalletRequiredError(
|
|
19064
|
+
"send_transaction",
|
|
19065
|
+
"No wallet provider available. Please create a Volr wallet (passkey/MPC) first."
|
|
19043
19066
|
);
|
|
19044
19067
|
}
|
|
19045
19068
|
|
|
@@ -19205,11 +19228,6 @@ async function sendCalls(args) {
|
|
|
19205
19228
|
const normalizedFrom = normalizeHex(from14);
|
|
19206
19229
|
const normalizedCalls = normalizeCalls(calls);
|
|
19207
19230
|
validateCalls2(normalizedCalls);
|
|
19208
|
-
if (!deps.provider && deps.user?.keyStorageType !== "passkey") {
|
|
19209
|
-
throw new Error(
|
|
19210
|
-
"No wallet provider configured. Please set up a Passkey provider to sign transactions. SIWE is authentication-only."
|
|
19211
|
-
);
|
|
19212
|
-
}
|
|
19213
19231
|
let currentUser = deps.user;
|
|
19214
19232
|
if (deps.user?.keyStorageType === "passkey" && !deps.provider) {
|
|
19215
19233
|
try {
|
|
@@ -19281,15 +19299,52 @@ async function sendCalls(args) {
|
|
|
19281
19299
|
let signer;
|
|
19282
19300
|
let activeProvider = null;
|
|
19283
19301
|
try {
|
|
19284
|
-
|
|
19285
|
-
|
|
19286
|
-
|
|
19287
|
-
|
|
19288
|
-
|
|
19289
|
-
|
|
19290
|
-
|
|
19291
|
-
|
|
19292
|
-
|
|
19302
|
+
let resolved = null;
|
|
19303
|
+
try {
|
|
19304
|
+
resolved = await resolveSigner({
|
|
19305
|
+
explicitSigner: void 0,
|
|
19306
|
+
// Always resolve internally
|
|
19307
|
+
provider: deps.provider,
|
|
19308
|
+
chainId,
|
|
19309
|
+
client: deps.client,
|
|
19310
|
+
user: currentUser,
|
|
19311
|
+
setProvider: deps.setProvider
|
|
19312
|
+
});
|
|
19313
|
+
} catch (err) {
|
|
19314
|
+
if (isWalletRequiredError(err) && deps.onWalletRequired) {
|
|
19315
|
+
const maybeProvider = await deps.onWalletRequired({
|
|
19316
|
+
type: "transaction",
|
|
19317
|
+
chainId
|
|
19318
|
+
});
|
|
19319
|
+
if (!maybeProvider) {
|
|
19320
|
+
throw err;
|
|
19321
|
+
}
|
|
19322
|
+
await deps.setProvider(maybeProvider);
|
|
19323
|
+
try {
|
|
19324
|
+
const refreshedUser = await deps.client.refreshSession();
|
|
19325
|
+
if (refreshedUser) {
|
|
19326
|
+
currentUser = refreshedUser;
|
|
19327
|
+
}
|
|
19328
|
+
} catch {
|
|
19329
|
+
}
|
|
19330
|
+
resolved = await resolveSigner({
|
|
19331
|
+
explicitSigner: void 0,
|
|
19332
|
+
provider: maybeProvider,
|
|
19333
|
+
chainId,
|
|
19334
|
+
client: deps.client,
|
|
19335
|
+
user: currentUser,
|
|
19336
|
+
setProvider: deps.setProvider
|
|
19337
|
+
});
|
|
19338
|
+
} else {
|
|
19339
|
+
throw err;
|
|
19340
|
+
}
|
|
19341
|
+
}
|
|
19342
|
+
if (!resolved) {
|
|
19343
|
+
throw new WalletRequiredError(
|
|
19344
|
+
"send_transaction",
|
|
19345
|
+
"No wallet provider available. Please create a Volr wallet (passkey/MPC) first."
|
|
19346
|
+
);
|
|
19347
|
+
}
|
|
19293
19348
|
signer = resolved.signer;
|
|
19294
19349
|
activeProvider = resolved.activeProvider;
|
|
19295
19350
|
const result = await deps.relay(
|
|
@@ -19322,61 +19377,77 @@ function useVolr() {
|
|
|
19322
19377
|
const { relay } = useRelay();
|
|
19323
19378
|
const { client: apiClient } = useInternalAuth();
|
|
19324
19379
|
const restoringRef = react.useRef(null);
|
|
19380
|
+
const userRef = react.useRef(user);
|
|
19381
|
+
const providerRef = react.useRef(provider);
|
|
19382
|
+
react.useEffect(() => {
|
|
19383
|
+
userRef.current = user;
|
|
19384
|
+
}, [user]);
|
|
19385
|
+
react.useEffect(() => {
|
|
19386
|
+
providerRef.current = provider;
|
|
19387
|
+
}, [provider]);
|
|
19325
19388
|
const getRpcUrl = react.useCallback(
|
|
19326
19389
|
createGetRpcUrl({ client: apiClient, rpcOverrides: config.rpcOverrides }),
|
|
19327
19390
|
[apiClient, config.rpcOverrides]
|
|
19328
19391
|
);
|
|
19329
|
-
const ensureProvider = react.useCallback(
|
|
19330
|
-
|
|
19331
|
-
|
|
19332
|
-
|
|
19333
|
-
|
|
19334
|
-
|
|
19335
|
-
|
|
19336
|
-
|
|
19337
|
-
|
|
19338
|
-
|
|
19339
|
-
|
|
19340
|
-
|
|
19341
|
-
|
|
19342
|
-
|
|
19343
|
-
|
|
19344
|
-
|
|
19345
|
-
|
|
19346
|
-
|
|
19347
|
-
|
|
19348
|
-
|
|
19349
|
-
|
|
19350
|
-
|
|
19351
|
-
|
|
19352
|
-
|
|
19353
|
-
|
|
19354
|
-
|
|
19355
|
-
|
|
19356
|
-
|
|
19392
|
+
const ensureProvider = react.useCallback(
|
|
19393
|
+
async (args) => {
|
|
19394
|
+
if (providerRef.current) {
|
|
19395
|
+
return providerRef.current;
|
|
19396
|
+
}
|
|
19397
|
+
const currentUser = userRef.current;
|
|
19398
|
+
if (!currentUser?.keyStorageType || currentUser.keyStorageType !== "passkey") {
|
|
19399
|
+
if (config.onWalletRequired) {
|
|
19400
|
+
const maybeProvider = await config.onWalletRequired(args.request);
|
|
19401
|
+
if (maybeProvider) {
|
|
19402
|
+
await setProvider(maybeProvider);
|
|
19403
|
+
return maybeProvider;
|
|
19404
|
+
}
|
|
19405
|
+
}
|
|
19406
|
+
throw new WalletRequiredError(args.action);
|
|
19407
|
+
}
|
|
19408
|
+
if (!currentUser.id) {
|
|
19409
|
+
throw new Error("Missing user id. Please login again.");
|
|
19410
|
+
}
|
|
19411
|
+
const currentRpId = typeof window !== "undefined" ? window.location.hostname : "localhost";
|
|
19412
|
+
const domainPasskey = currentUser.registeredPasskeys?.find((p) => p.rpId === currentRpId) ?? null;
|
|
19413
|
+
const blobUrl = domainPasskey?.blobUrl ?? currentUser.blobUrl;
|
|
19414
|
+
const prfInput = domainPasskey?.prfInput ?? currentUser.prfInput;
|
|
19415
|
+
const credentialId = domainPasskey?.credentialId ?? currentUser.credentialId;
|
|
19416
|
+
if (currentUser.registeredPasskeys?.length && !domainPasskey) {
|
|
19417
|
+
throw new Error(
|
|
19418
|
+
`PASSKEY_DOMAIN_MISMATCH: No passkey registered for rpId=${currentRpId}`
|
|
19419
|
+
);
|
|
19420
|
+
}
|
|
19421
|
+
if (!blobUrl || !prfInput) {
|
|
19422
|
+
throw new Error("Missing passkey data. Please re-enroll your passkey.");
|
|
19423
|
+
}
|
|
19424
|
+
if (restoringRef.current) {
|
|
19425
|
+
return restoringRef.current;
|
|
19426
|
+
}
|
|
19427
|
+
restoringRef.current = restorePasskey({
|
|
19428
|
+
client: apiClient,
|
|
19429
|
+
userId: currentUser.id,
|
|
19430
|
+
blobUrl,
|
|
19431
|
+
prfInput,
|
|
19432
|
+
credentialId
|
|
19433
|
+
}).then(async ({ provider: restoredProvider }) => {
|
|
19434
|
+
await setProvider(restoredProvider);
|
|
19435
|
+
restoringRef.current = null;
|
|
19436
|
+
return restoredProvider;
|
|
19437
|
+
}).catch((err) => {
|
|
19438
|
+
restoringRef.current = null;
|
|
19439
|
+
throw err;
|
|
19440
|
+
});
|
|
19357
19441
|
return restoringRef.current;
|
|
19358
|
-
}
|
|
19359
|
-
|
|
19360
|
-
|
|
19361
|
-
client: apiClient,
|
|
19362
|
-
userId: user.id,
|
|
19363
|
-
blobUrl,
|
|
19364
|
-
prfInput,
|
|
19365
|
-
credentialId
|
|
19366
|
-
}).then(async ({ provider: restoredProvider }) => {
|
|
19367
|
-
await setProvider(restoredProvider);
|
|
19368
|
-
console.log("[useVolr] Passkey provider restored successfully");
|
|
19369
|
-
restoringRef.current = null;
|
|
19370
|
-
return restoredProvider;
|
|
19371
|
-
}).catch((err) => {
|
|
19372
|
-
restoringRef.current = null;
|
|
19373
|
-
throw err;
|
|
19374
|
-
});
|
|
19375
|
-
return restoringRef.current;
|
|
19376
|
-
}, [provider, user, apiClient, setProvider]);
|
|
19442
|
+
},
|
|
19443
|
+
[apiClient, config.onWalletRequired, setProvider]
|
|
19444
|
+
);
|
|
19377
19445
|
const signMessage = react.useCallback(
|
|
19378
19446
|
async (message) => {
|
|
19379
|
-
const activeProvider = await ensureProvider(
|
|
19447
|
+
const activeProvider = await ensureProvider({
|
|
19448
|
+
request: { type: "message" },
|
|
19449
|
+
action: "sign_message"
|
|
19450
|
+
});
|
|
19380
19451
|
if (config.onSignRequest) {
|
|
19381
19452
|
await config.onSignRequest({ type: "message", message });
|
|
19382
19453
|
}
|
|
@@ -19400,7 +19471,10 @@ function useVolr() {
|
|
|
19400
19471
|
);
|
|
19401
19472
|
const signTypedData = react.useCallback(
|
|
19402
19473
|
async (typedData) => {
|
|
19403
|
-
const activeProvider = await ensureProvider(
|
|
19474
|
+
const activeProvider = await ensureProvider({
|
|
19475
|
+
request: { type: "typedData" },
|
|
19476
|
+
action: "sign_typed_data"
|
|
19477
|
+
});
|
|
19404
19478
|
if (config.onSignRequest) {
|
|
19405
19479
|
await config.onSignRequest({ type: "typedData", typedData });
|
|
19406
19480
|
}
|
|
@@ -19437,10 +19511,30 @@ function useVolr() {
|
|
|
19437
19511
|
},
|
|
19438
19512
|
sendTransaction: async (tx, opts = {}) => {
|
|
19439
19513
|
const { publicClient: publicClient2, extendedRpcClient: rpcClient } = await ensureRpcClient();
|
|
19440
|
-
|
|
19514
|
+
let from14 = opts.from ?? userRef.current?.evmAddress;
|
|
19515
|
+
let providerForDeps = providerRef.current ?? null;
|
|
19516
|
+
if (!from14 && config.onWalletRequired) {
|
|
19517
|
+
const maybeProvider = await config.onWalletRequired({
|
|
19518
|
+
type: "transaction",
|
|
19519
|
+
chainId
|
|
19520
|
+
});
|
|
19521
|
+
if (maybeProvider) {
|
|
19522
|
+
providerForDeps = maybeProvider;
|
|
19523
|
+
await setProvider(maybeProvider);
|
|
19524
|
+
try {
|
|
19525
|
+
const refreshed = await apiClient.refreshSession();
|
|
19526
|
+
if (refreshed?.evmAddress) {
|
|
19527
|
+
from14 = refreshed.evmAddress;
|
|
19528
|
+
}
|
|
19529
|
+
} catch {
|
|
19530
|
+
}
|
|
19531
|
+
from14 = from14 ?? userRef.current?.evmAddress;
|
|
19532
|
+
}
|
|
19533
|
+
}
|
|
19441
19534
|
if (!from14) {
|
|
19442
|
-
throw new
|
|
19443
|
-
"
|
|
19535
|
+
throw new WalletRequiredError(
|
|
19536
|
+
"send_transaction",
|
|
19537
|
+
"Wallet address is required. Please create a Volr wallet (passkey/MPC) first."
|
|
19444
19538
|
);
|
|
19445
19539
|
}
|
|
19446
19540
|
const call2 = {
|
|
@@ -19460,18 +19554,39 @@ function useVolr() {
|
|
|
19460
19554
|
precheck,
|
|
19461
19555
|
relay,
|
|
19462
19556
|
client: apiClient,
|
|
19463
|
-
user:
|
|
19464
|
-
provider:
|
|
19465
|
-
setProvider
|
|
19557
|
+
user: userRef.current ?? null,
|
|
19558
|
+
provider: providerForDeps,
|
|
19559
|
+
setProvider,
|
|
19560
|
+
onWalletRequired: config.onWalletRequired
|
|
19466
19561
|
}
|
|
19467
19562
|
});
|
|
19468
19563
|
},
|
|
19469
19564
|
sendBatch: (async (calls, opts = {}) => {
|
|
19470
19565
|
const { publicClient: publicClient2, extendedRpcClient: rpcClient } = await ensureRpcClient();
|
|
19471
|
-
|
|
19566
|
+
let from14 = opts.from ?? userRef.current?.evmAddress;
|
|
19567
|
+
let providerForDeps = providerRef.current ?? null;
|
|
19568
|
+
if (!from14 && config.onWalletRequired) {
|
|
19569
|
+
const maybeProvider = await config.onWalletRequired({
|
|
19570
|
+
type: "transaction",
|
|
19571
|
+
chainId
|
|
19572
|
+
});
|
|
19573
|
+
if (maybeProvider) {
|
|
19574
|
+
providerForDeps = maybeProvider;
|
|
19575
|
+
await setProvider(maybeProvider);
|
|
19576
|
+
try {
|
|
19577
|
+
const refreshed = await apiClient.refreshSession();
|
|
19578
|
+
if (refreshed?.evmAddress) {
|
|
19579
|
+
from14 = refreshed.evmAddress;
|
|
19580
|
+
}
|
|
19581
|
+
} catch {
|
|
19582
|
+
}
|
|
19583
|
+
from14 = from14 ?? userRef.current?.evmAddress;
|
|
19584
|
+
}
|
|
19585
|
+
}
|
|
19472
19586
|
if (!from14) {
|
|
19473
|
-
throw new
|
|
19474
|
-
"
|
|
19587
|
+
throw new WalletRequiredError(
|
|
19588
|
+
"send_transaction",
|
|
19589
|
+
"Wallet address is required. Please create a Volr wallet (passkey/MPC) first."
|
|
19475
19590
|
);
|
|
19476
19591
|
}
|
|
19477
19592
|
const isCallArray = (calls2) => {
|
|
@@ -19494,15 +19609,16 @@ function useVolr() {
|
|
|
19494
19609
|
precheck,
|
|
19495
19610
|
relay,
|
|
19496
19611
|
client: apiClient,
|
|
19497
|
-
user:
|
|
19498
|
-
provider:
|
|
19499
|
-
setProvider
|
|
19612
|
+
user: userRef.current ?? null,
|
|
19613
|
+
provider: providerForDeps,
|
|
19614
|
+
setProvider,
|
|
19615
|
+
onWalletRequired: config.onWalletRequired
|
|
19500
19616
|
}
|
|
19501
19617
|
});
|
|
19502
19618
|
})
|
|
19503
19619
|
};
|
|
19504
19620
|
},
|
|
19505
|
-
[
|
|
19621
|
+
[precheck, relay, getRpcUrl, setProvider, apiClient, config.onWalletRequired]
|
|
19506
19622
|
);
|
|
19507
19623
|
const evm = react.useMemo(
|
|
19508
19624
|
() => ({
|
|
@@ -19520,11 +19636,101 @@ function useVolr() {
|
|
|
19520
19636
|
email: user?.email,
|
|
19521
19637
|
isLoggedIn: user !== null,
|
|
19522
19638
|
signerType: user?.signerType,
|
|
19639
|
+
hasWallet: Boolean(user?.evmAddress),
|
|
19523
19640
|
logout,
|
|
19524
19641
|
isLoading,
|
|
19525
19642
|
error
|
|
19526
19643
|
};
|
|
19527
19644
|
}
|
|
19645
|
+
|
|
19646
|
+
// src/utils/session-broadcast.ts
|
|
19647
|
+
function broadcastSessionEvent(event) {
|
|
19648
|
+
if (typeof window === "undefined") return;
|
|
19649
|
+
if (!("BroadcastChannel" in window)) return;
|
|
19650
|
+
const channel = new BroadcastChannel(STORAGE_CHANNELS.session);
|
|
19651
|
+
channel.postMessage(event);
|
|
19652
|
+
channel.close();
|
|
19653
|
+
}
|
|
19654
|
+
|
|
19655
|
+
// src/hooks/useVolrSession.ts
|
|
19656
|
+
function toVolrUser(u) {
|
|
19657
|
+
return {
|
|
19658
|
+
id: u.id,
|
|
19659
|
+
projectId: u.projectId,
|
|
19660
|
+
projectName: u.projectName,
|
|
19661
|
+
email: u.email,
|
|
19662
|
+
authWallet: u.authWallet ?? void 0,
|
|
19663
|
+
evmAddress: u.evmAddress,
|
|
19664
|
+
keyStorageType: u.keyStorageType ?? void 0,
|
|
19665
|
+
signerType: u.signerType ?? void 0,
|
|
19666
|
+
walletConnector: u.walletConnector ?? void 0,
|
|
19667
|
+
lastWalletChainId: u.lastWalletChainId ?? void 0,
|
|
19668
|
+
blobUrl: u.blobUrl ?? void 0,
|
|
19669
|
+
prfInput: u.prfInput ?? void 0,
|
|
19670
|
+
credentialId: u.credentialId ?? void 0,
|
|
19671
|
+
registeredPasskeys: u.registeredPasskeys ?? void 0
|
|
19672
|
+
};
|
|
19673
|
+
}
|
|
19674
|
+
function useVolrSession() {
|
|
19675
|
+
const { setUser, logout } = useVolrContext();
|
|
19676
|
+
const { client, setAccessToken, setRefreshToken } = useInternalAuth();
|
|
19677
|
+
const setSession = react.useCallback(
|
|
19678
|
+
async (session) => {
|
|
19679
|
+
setAccessToken(session.accessToken);
|
|
19680
|
+
setRefreshToken(session.refreshToken);
|
|
19681
|
+
const refreshedUser = await client.refreshSession();
|
|
19682
|
+
if (!refreshedUser) {
|
|
19683
|
+
throw new Error("Failed to refresh session. Please try logging in again.");
|
|
19684
|
+
}
|
|
19685
|
+
const nextUser = toVolrUser(refreshedUser);
|
|
19686
|
+
setUser(nextUser);
|
|
19687
|
+
const nextAccess = client.getAccessToken();
|
|
19688
|
+
const nextRefresh = client.getRefreshToken();
|
|
19689
|
+
if (nextAccess) setAccessToken(nextAccess);
|
|
19690
|
+
if (nextRefresh) setRefreshToken(nextRefresh);
|
|
19691
|
+
if (nextAccess && nextRefresh) {
|
|
19692
|
+
broadcastSessionEvent({
|
|
19693
|
+
type: "LOGIN",
|
|
19694
|
+
payload: { accessToken: nextAccess, refreshToken: nextRefresh, user: refreshedUser }
|
|
19695
|
+
});
|
|
19696
|
+
}
|
|
19697
|
+
return nextUser;
|
|
19698
|
+
},
|
|
19699
|
+
[client, setAccessToken, setRefreshToken, setUser]
|
|
19700
|
+
);
|
|
19701
|
+
const clearSession = react.useCallback(async () => {
|
|
19702
|
+
await logout();
|
|
19703
|
+
broadcastSessionEvent({ type: "LOGOUT" });
|
|
19704
|
+
}, [logout]);
|
|
19705
|
+
const exchangeOidc = react.useCallback(
|
|
19706
|
+
async (idToken) => {
|
|
19707
|
+
const response = await client.post("/auth/oidc/exchange", {
|
|
19708
|
+
idToken
|
|
19709
|
+
});
|
|
19710
|
+
setAccessToken(response.accessToken);
|
|
19711
|
+
setRefreshToken(response.refreshToken);
|
|
19712
|
+
const nextUser = toVolrUser(response.user);
|
|
19713
|
+
setUser(nextUser);
|
|
19714
|
+
broadcastSessionEvent({
|
|
19715
|
+
type: "LOGIN",
|
|
19716
|
+
payload: {
|
|
19717
|
+
accessToken: response.accessToken,
|
|
19718
|
+
refreshToken: response.refreshToken,
|
|
19719
|
+
user: response.user
|
|
19720
|
+
}
|
|
19721
|
+
});
|
|
19722
|
+
return {
|
|
19723
|
+
userId: response.user?.id || "",
|
|
19724
|
+
isNewUser: response.isNewUser,
|
|
19725
|
+
keyStorageType: response.user?.keyStorageType ?? null,
|
|
19726
|
+
signerType: response.user?.signerType ?? null,
|
|
19727
|
+
accessToken: response.accessToken
|
|
19728
|
+
};
|
|
19729
|
+
},
|
|
19730
|
+
[client, setAccessToken, setRefreshToken, setUser]
|
|
19731
|
+
);
|
|
19732
|
+
return { setSession, clearSession, exchangeOidc };
|
|
19733
|
+
}
|
|
19528
19734
|
init_sha3();
|
|
19529
19735
|
init_utils2();
|
|
19530
19736
|
function toChecksumAddress(address) {
|
|
@@ -19543,7 +19749,7 @@ function toChecksumAddress(address) {
|
|
|
19543
19749
|
function useVolrLogin() {
|
|
19544
19750
|
const { config, setUser } = useVolrContext();
|
|
19545
19751
|
const { setAccessToken, setRefreshToken, client } = useInternalAuth();
|
|
19546
|
-
const
|
|
19752
|
+
const toVolrUser2 = react.useCallback((u) => {
|
|
19547
19753
|
return {
|
|
19548
19754
|
id: u.id,
|
|
19549
19755
|
projectId: u.projectId,
|
|
@@ -19602,7 +19808,7 @@ function useVolrLogin() {
|
|
|
19602
19808
|
);
|
|
19603
19809
|
}
|
|
19604
19810
|
if (userFromServer) {
|
|
19605
|
-
setUser(
|
|
19811
|
+
setUser(toVolrUser2(userFromServer));
|
|
19606
19812
|
} else {
|
|
19607
19813
|
setUser({ id: "", email: normalizedEmail });
|
|
19608
19814
|
}
|
|
@@ -19614,7 +19820,7 @@ function useVolrLogin() {
|
|
|
19614
19820
|
accessToken
|
|
19615
19821
|
};
|
|
19616
19822
|
},
|
|
19617
|
-
[client, setAccessToken, setRefreshToken, setUser,
|
|
19823
|
+
[client, setAccessToken, setRefreshToken, setUser, toVolrUser2]
|
|
19618
19824
|
);
|
|
19619
19825
|
const handleSocialLogin = react.useCallback(
|
|
19620
19826
|
async (provider) => {
|
|
@@ -19652,7 +19858,7 @@ function useVolrLogin() {
|
|
|
19652
19858
|
setRefreshToken(refreshToken);
|
|
19653
19859
|
}
|
|
19654
19860
|
if (userFromServer) {
|
|
19655
|
-
setUser(
|
|
19861
|
+
setUser(toVolrUser2(userFromServer));
|
|
19656
19862
|
}
|
|
19657
19863
|
return {
|
|
19658
19864
|
userId: userFromServer?.id || "",
|
|
@@ -19670,7 +19876,7 @@ function useVolrLogin() {
|
|
|
19670
19876
|
throw error;
|
|
19671
19877
|
}
|
|
19672
19878
|
},
|
|
19673
|
-
[client, setAccessToken, setRefreshToken, setUser,
|
|
19879
|
+
[client, setAccessToken, setRefreshToken, setUser, toVolrUser2]
|
|
19674
19880
|
);
|
|
19675
19881
|
const signWithWallet = react.useCallback(
|
|
19676
19882
|
async (walletAddress, options) => {
|
|
@@ -19717,11 +19923,11 @@ Issued At: ${issuedAt}`;
|
|
|
19717
19923
|
if (response.status === "completed" && response.tokens && response.user) {
|
|
19718
19924
|
setAccessToken(response.tokens.accessToken);
|
|
19719
19925
|
setRefreshToken(response.tokens.refreshToken);
|
|
19720
|
-
setUser(
|
|
19926
|
+
setUser(toVolrUser2(response.user));
|
|
19721
19927
|
}
|
|
19722
19928
|
return response;
|
|
19723
19929
|
},
|
|
19724
|
-
[client, setAccessToken, setRefreshToken, setUser,
|
|
19930
|
+
[client, setAccessToken, setRefreshToken, setUser, toVolrUser2]
|
|
19725
19931
|
);
|
|
19726
19932
|
const getSiweSignUrl = react.useCallback(
|
|
19727
19933
|
(sessionId) => {
|
|
@@ -19761,7 +19967,7 @@ function useVolrAuthCallback(options = {}) {
|
|
|
19761
19967
|
const [isNewUser, setIsNewUser] = react.useState(false);
|
|
19762
19968
|
const [user, setLocalUser] = react.useState(null);
|
|
19763
19969
|
const hasProcessed = react.useRef(false);
|
|
19764
|
-
const
|
|
19970
|
+
const toVolrUser2 = react.useCallback((u) => {
|
|
19765
19971
|
return {
|
|
19766
19972
|
id: u.id,
|
|
19767
19973
|
projectId: u.projectId,
|
|
@@ -19821,7 +20027,7 @@ function useVolrAuthCallback(options = {}) {
|
|
|
19821
20027
|
if (refreshToken) {
|
|
19822
20028
|
setRefreshToken(refreshToken);
|
|
19823
20029
|
}
|
|
19824
|
-
const volrUser =
|
|
20030
|
+
const volrUser = toVolrUser2(userData);
|
|
19825
20031
|
setUser(volrUser);
|
|
19826
20032
|
setLocalUser(volrUser);
|
|
19827
20033
|
if (clearUrlParams && typeof window !== "undefined") {
|
|
@@ -21399,6 +21605,7 @@ exports.PasskeyNotFoundError = PasskeyNotFoundError;
|
|
|
21399
21605
|
exports.PrfNotSupportedError = PrfNotSupportedError;
|
|
21400
21606
|
exports.UserCancelledError = UserCancelledError;
|
|
21401
21607
|
exports.VolrProvider = VolrProvider;
|
|
21608
|
+
exports.WalletRequiredError = WalletRequiredError;
|
|
21402
21609
|
exports.WebAuthnBusyError = WebAuthnBusyError;
|
|
21403
21610
|
exports.analyzeContractForEIP7702 = analyzeContractForEIP7702;
|
|
21404
21611
|
exports.buildCall = buildCall;
|
|
@@ -21427,6 +21634,7 @@ exports.isEIP7702Delegated = isEIP7702Delegated;
|
|
|
21427
21634
|
exports.isInAppBrowser = isInAppBrowser;
|
|
21428
21635
|
exports.isInAppBrowserNotSupportedError = isInAppBrowserNotSupportedError;
|
|
21429
21636
|
exports.isUserCancelledError = isUserCancelledError;
|
|
21637
|
+
exports.isWalletRequiredError = isWalletRequiredError;
|
|
21430
21638
|
exports.isWebAuthnBusyError = isWebAuthnBusyError;
|
|
21431
21639
|
exports.listenForSeedRequests = listenForSeedRequests;
|
|
21432
21640
|
exports.normalizeHex = normalizeHex;
|
|
@@ -21449,6 +21657,7 @@ exports.useVolrAuthCallback = useVolrAuthCallback;
|
|
|
21449
21657
|
exports.useVolrContext = useVolrContext;
|
|
21450
21658
|
exports.useVolrLogin = useVolrLogin;
|
|
21451
21659
|
exports.useVolrPaymentApi = useVolrPaymentApi;
|
|
21660
|
+
exports.useVolrSession = useVolrSession;
|
|
21452
21661
|
exports.useWithdraw = useWithdraw;
|
|
21453
21662
|
//# sourceMappingURL=index.cjs.map
|
|
21454
21663
|
//# sourceMappingURL=index.cjs.map
|