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