@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/dist/index.js
CHANGED
|
@@ -10761,7 +10761,6 @@ function VolrProvider({ config, children }) {
|
|
|
10761
10761
|
);
|
|
10762
10762
|
const [isLoading, setIsLoading] = useState(true);
|
|
10763
10763
|
const [error, setError] = useState(null);
|
|
10764
|
-
const [chainId] = useState(config.defaultChainId);
|
|
10765
10764
|
const userRef = useRef(null);
|
|
10766
10765
|
useEffect(() => {
|
|
10767
10766
|
userRef.current = user;
|
|
@@ -10878,7 +10877,6 @@ function VolrProvider({ config, children }) {
|
|
|
10878
10877
|
safeStorage.removeItem(STORAGE_KEYS.user);
|
|
10879
10878
|
}
|
|
10880
10879
|
},
|
|
10881
|
-
chainId,
|
|
10882
10880
|
precheck,
|
|
10883
10881
|
relay,
|
|
10884
10882
|
logout,
|
|
@@ -10890,7 +10888,6 @@ function VolrProvider({ config, children }) {
|
|
|
10890
10888
|
user,
|
|
10891
10889
|
provider,
|
|
10892
10890
|
setProvider,
|
|
10893
|
-
chainId,
|
|
10894
10891
|
precheck,
|
|
10895
10892
|
relay,
|
|
10896
10893
|
logout,
|
|
@@ -18956,6 +18953,28 @@ function normalizeCall(call2) {
|
|
|
18956
18953
|
function normalizeCalls(calls) {
|
|
18957
18954
|
return calls.map(normalizeCall);
|
|
18958
18955
|
}
|
|
18956
|
+
|
|
18957
|
+
// src/errors/wallet-errors.ts
|
|
18958
|
+
var WalletRequiredError = class _WalletRequiredError extends Error {
|
|
18959
|
+
constructor(action, message) {
|
|
18960
|
+
super(
|
|
18961
|
+
message || "Wallet is required for this action. Please create a Volr account (passkey/MPC) or provide a wallet provider."
|
|
18962
|
+
);
|
|
18963
|
+
this.code = "WALLET_REQUIRED";
|
|
18964
|
+
this.name = "WalletRequiredError";
|
|
18965
|
+
this.action = action;
|
|
18966
|
+
Object.setPrototypeOf(this, _WalletRequiredError.prototype);
|
|
18967
|
+
}
|
|
18968
|
+
};
|
|
18969
|
+
function isWalletRequiredError(error) {
|
|
18970
|
+
if (error instanceof WalletRequiredError) return true;
|
|
18971
|
+
if (error && typeof error === "object" && error.code === "WALLET_REQUIRED") {
|
|
18972
|
+
return true;
|
|
18973
|
+
}
|
|
18974
|
+
return false;
|
|
18975
|
+
}
|
|
18976
|
+
|
|
18977
|
+
// src/wallet/signer.ts
|
|
18959
18978
|
async function resolveSigner(input) {
|
|
18960
18979
|
const { explicitSigner, provider, chainId, client, user, setProvider } = input;
|
|
18961
18980
|
if (explicitSigner) {
|
|
@@ -19014,8 +19033,9 @@ async function resolveSigner(input) {
|
|
|
19014
19033
|
const signer = await selectSigner(signerContext);
|
|
19015
19034
|
return { signer, activeProvider: restoredProvider };
|
|
19016
19035
|
}
|
|
19017
|
-
throw new
|
|
19018
|
-
"
|
|
19036
|
+
throw new WalletRequiredError(
|
|
19037
|
+
"send_transaction",
|
|
19038
|
+
"No wallet provider available. Please create a Volr wallet (passkey/MPC) first."
|
|
19019
19039
|
);
|
|
19020
19040
|
}
|
|
19021
19041
|
|
|
@@ -19181,11 +19201,6 @@ async function sendCalls(args) {
|
|
|
19181
19201
|
const normalizedFrom = normalizeHex(from14);
|
|
19182
19202
|
const normalizedCalls = normalizeCalls(calls);
|
|
19183
19203
|
validateCalls2(normalizedCalls);
|
|
19184
|
-
if (!deps.provider && deps.user?.keyStorageType !== "passkey") {
|
|
19185
|
-
throw new Error(
|
|
19186
|
-
"No wallet provider configured. Please set up a Passkey provider to sign transactions. SIWE is authentication-only."
|
|
19187
|
-
);
|
|
19188
|
-
}
|
|
19189
19204
|
let currentUser = deps.user;
|
|
19190
19205
|
if (deps.user?.keyStorageType === "passkey" && !deps.provider) {
|
|
19191
19206
|
try {
|
|
@@ -19257,15 +19272,52 @@ async function sendCalls(args) {
|
|
|
19257
19272
|
let signer;
|
|
19258
19273
|
let activeProvider = null;
|
|
19259
19274
|
try {
|
|
19260
|
-
|
|
19261
|
-
|
|
19262
|
-
|
|
19263
|
-
|
|
19264
|
-
|
|
19265
|
-
|
|
19266
|
-
|
|
19267
|
-
|
|
19268
|
-
|
|
19275
|
+
let resolved = null;
|
|
19276
|
+
try {
|
|
19277
|
+
resolved = await resolveSigner({
|
|
19278
|
+
explicitSigner: void 0,
|
|
19279
|
+
// Always resolve internally
|
|
19280
|
+
provider: deps.provider,
|
|
19281
|
+
chainId,
|
|
19282
|
+
client: deps.client,
|
|
19283
|
+
user: currentUser,
|
|
19284
|
+
setProvider: deps.setProvider
|
|
19285
|
+
});
|
|
19286
|
+
} catch (err) {
|
|
19287
|
+
if (isWalletRequiredError(err) && deps.onWalletRequired) {
|
|
19288
|
+
const maybeProvider = await deps.onWalletRequired({
|
|
19289
|
+
type: "transaction",
|
|
19290
|
+
chainId
|
|
19291
|
+
});
|
|
19292
|
+
if (!maybeProvider) {
|
|
19293
|
+
throw err;
|
|
19294
|
+
}
|
|
19295
|
+
await deps.setProvider(maybeProvider);
|
|
19296
|
+
try {
|
|
19297
|
+
const refreshedUser = await deps.client.refreshSession();
|
|
19298
|
+
if (refreshedUser) {
|
|
19299
|
+
currentUser = refreshedUser;
|
|
19300
|
+
}
|
|
19301
|
+
} catch {
|
|
19302
|
+
}
|
|
19303
|
+
resolved = await resolveSigner({
|
|
19304
|
+
explicitSigner: void 0,
|
|
19305
|
+
provider: maybeProvider,
|
|
19306
|
+
chainId,
|
|
19307
|
+
client: deps.client,
|
|
19308
|
+
user: currentUser,
|
|
19309
|
+
setProvider: deps.setProvider
|
|
19310
|
+
});
|
|
19311
|
+
} else {
|
|
19312
|
+
throw err;
|
|
19313
|
+
}
|
|
19314
|
+
}
|
|
19315
|
+
if (!resolved) {
|
|
19316
|
+
throw new WalletRequiredError(
|
|
19317
|
+
"send_transaction",
|
|
19318
|
+
"No wallet provider available. Please create a Volr wallet (passkey/MPC) first."
|
|
19319
|
+
);
|
|
19320
|
+
}
|
|
19269
19321
|
signer = resolved.signer;
|
|
19270
19322
|
activeProvider = resolved.activeProvider;
|
|
19271
19323
|
const result = await deps.relay(
|
|
@@ -19298,61 +19350,77 @@ function useVolr() {
|
|
|
19298
19350
|
const { relay } = useRelay();
|
|
19299
19351
|
const { client: apiClient } = useInternalAuth();
|
|
19300
19352
|
const restoringRef = useRef(null);
|
|
19353
|
+
const userRef = useRef(user);
|
|
19354
|
+
const providerRef = useRef(provider);
|
|
19355
|
+
useEffect(() => {
|
|
19356
|
+
userRef.current = user;
|
|
19357
|
+
}, [user]);
|
|
19358
|
+
useEffect(() => {
|
|
19359
|
+
providerRef.current = provider;
|
|
19360
|
+
}, [provider]);
|
|
19301
19361
|
const getRpcUrl = useCallback(
|
|
19302
19362
|
createGetRpcUrl({ client: apiClient, rpcOverrides: config.rpcOverrides }),
|
|
19303
19363
|
[apiClient, config.rpcOverrides]
|
|
19304
19364
|
);
|
|
19305
|
-
const ensureProvider = useCallback(
|
|
19306
|
-
|
|
19307
|
-
|
|
19308
|
-
|
|
19309
|
-
|
|
19310
|
-
|
|
19311
|
-
|
|
19312
|
-
|
|
19313
|
-
|
|
19314
|
-
|
|
19315
|
-
|
|
19316
|
-
|
|
19317
|
-
|
|
19318
|
-
|
|
19319
|
-
|
|
19320
|
-
|
|
19321
|
-
|
|
19322
|
-
|
|
19323
|
-
|
|
19324
|
-
|
|
19325
|
-
|
|
19326
|
-
|
|
19327
|
-
|
|
19328
|
-
|
|
19329
|
-
|
|
19330
|
-
|
|
19331
|
-
|
|
19332
|
-
|
|
19365
|
+
const ensureProvider = useCallback(
|
|
19366
|
+
async (args) => {
|
|
19367
|
+
if (providerRef.current) {
|
|
19368
|
+
return providerRef.current;
|
|
19369
|
+
}
|
|
19370
|
+
const currentUser = userRef.current;
|
|
19371
|
+
if (!currentUser?.keyStorageType || currentUser.keyStorageType !== "passkey") {
|
|
19372
|
+
if (config.onWalletRequired) {
|
|
19373
|
+
const maybeProvider = await config.onWalletRequired(args.request);
|
|
19374
|
+
if (maybeProvider) {
|
|
19375
|
+
await setProvider(maybeProvider);
|
|
19376
|
+
return maybeProvider;
|
|
19377
|
+
}
|
|
19378
|
+
}
|
|
19379
|
+
throw new WalletRequiredError(args.action);
|
|
19380
|
+
}
|
|
19381
|
+
if (!currentUser.id) {
|
|
19382
|
+
throw new Error("Missing user id. Please login again.");
|
|
19383
|
+
}
|
|
19384
|
+
const currentRpId = typeof window !== "undefined" ? window.location.hostname : "localhost";
|
|
19385
|
+
const domainPasskey = currentUser.registeredPasskeys?.find((p) => p.rpId === currentRpId) ?? null;
|
|
19386
|
+
const blobUrl = domainPasskey?.blobUrl ?? currentUser.blobUrl;
|
|
19387
|
+
const prfInput = domainPasskey?.prfInput ?? currentUser.prfInput;
|
|
19388
|
+
const credentialId = domainPasskey?.credentialId ?? currentUser.credentialId;
|
|
19389
|
+
if (currentUser.registeredPasskeys?.length && !domainPasskey) {
|
|
19390
|
+
throw new Error(
|
|
19391
|
+
`PASSKEY_DOMAIN_MISMATCH: No passkey registered for rpId=${currentRpId}`
|
|
19392
|
+
);
|
|
19393
|
+
}
|
|
19394
|
+
if (!blobUrl || !prfInput) {
|
|
19395
|
+
throw new Error("Missing passkey data. Please re-enroll your passkey.");
|
|
19396
|
+
}
|
|
19397
|
+
if (restoringRef.current) {
|
|
19398
|
+
return restoringRef.current;
|
|
19399
|
+
}
|
|
19400
|
+
restoringRef.current = restorePasskey({
|
|
19401
|
+
client: apiClient,
|
|
19402
|
+
userId: currentUser.id,
|
|
19403
|
+
blobUrl,
|
|
19404
|
+
prfInput,
|
|
19405
|
+
credentialId
|
|
19406
|
+
}).then(async ({ provider: restoredProvider }) => {
|
|
19407
|
+
await setProvider(restoredProvider);
|
|
19408
|
+
restoringRef.current = null;
|
|
19409
|
+
return restoredProvider;
|
|
19410
|
+
}).catch((err) => {
|
|
19411
|
+
restoringRef.current = null;
|
|
19412
|
+
throw err;
|
|
19413
|
+
});
|
|
19333
19414
|
return restoringRef.current;
|
|
19334
|
-
}
|
|
19335
|
-
|
|
19336
|
-
|
|
19337
|
-
client: apiClient,
|
|
19338
|
-
userId: user.id,
|
|
19339
|
-
blobUrl,
|
|
19340
|
-
prfInput,
|
|
19341
|
-
credentialId
|
|
19342
|
-
}).then(async ({ provider: restoredProvider }) => {
|
|
19343
|
-
await setProvider(restoredProvider);
|
|
19344
|
-
console.log("[useVolr] Passkey provider restored successfully");
|
|
19345
|
-
restoringRef.current = null;
|
|
19346
|
-
return restoredProvider;
|
|
19347
|
-
}).catch((err) => {
|
|
19348
|
-
restoringRef.current = null;
|
|
19349
|
-
throw err;
|
|
19350
|
-
});
|
|
19351
|
-
return restoringRef.current;
|
|
19352
|
-
}, [provider, user, apiClient, setProvider]);
|
|
19415
|
+
},
|
|
19416
|
+
[apiClient, config.onWalletRequired, setProvider]
|
|
19417
|
+
);
|
|
19353
19418
|
const signMessage = useCallback(
|
|
19354
19419
|
async (message) => {
|
|
19355
|
-
const activeProvider = await ensureProvider(
|
|
19420
|
+
const activeProvider = await ensureProvider({
|
|
19421
|
+
request: { type: "message" },
|
|
19422
|
+
action: "sign_message"
|
|
19423
|
+
});
|
|
19356
19424
|
if (config.onSignRequest) {
|
|
19357
19425
|
await config.onSignRequest({ type: "message", message });
|
|
19358
19426
|
}
|
|
@@ -19376,7 +19444,10 @@ function useVolr() {
|
|
|
19376
19444
|
);
|
|
19377
19445
|
const signTypedData = useCallback(
|
|
19378
19446
|
async (typedData) => {
|
|
19379
|
-
const activeProvider = await ensureProvider(
|
|
19447
|
+
const activeProvider = await ensureProvider({
|
|
19448
|
+
request: { type: "typedData" },
|
|
19449
|
+
action: "sign_typed_data"
|
|
19450
|
+
});
|
|
19380
19451
|
if (config.onSignRequest) {
|
|
19381
19452
|
await config.onSignRequest({ type: "typedData", typedData });
|
|
19382
19453
|
}
|
|
@@ -19413,10 +19484,30 @@ function useVolr() {
|
|
|
19413
19484
|
},
|
|
19414
19485
|
sendTransaction: async (tx, opts = {}) => {
|
|
19415
19486
|
const { publicClient: publicClient2, extendedRpcClient: rpcClient } = await ensureRpcClient();
|
|
19416
|
-
|
|
19487
|
+
let from14 = opts.from ?? userRef.current?.evmAddress;
|
|
19488
|
+
let providerForDeps = providerRef.current ?? null;
|
|
19489
|
+
if (!from14 && config.onWalletRequired) {
|
|
19490
|
+
const maybeProvider = await config.onWalletRequired({
|
|
19491
|
+
type: "transaction",
|
|
19492
|
+
chainId
|
|
19493
|
+
});
|
|
19494
|
+
if (maybeProvider) {
|
|
19495
|
+
providerForDeps = maybeProvider;
|
|
19496
|
+
await setProvider(maybeProvider);
|
|
19497
|
+
try {
|
|
19498
|
+
const refreshed = await apiClient.refreshSession();
|
|
19499
|
+
if (refreshed?.evmAddress) {
|
|
19500
|
+
from14 = refreshed.evmAddress;
|
|
19501
|
+
}
|
|
19502
|
+
} catch {
|
|
19503
|
+
}
|
|
19504
|
+
from14 = from14 ?? userRef.current?.evmAddress;
|
|
19505
|
+
}
|
|
19506
|
+
}
|
|
19417
19507
|
if (!from14) {
|
|
19418
|
-
throw new
|
|
19419
|
-
"
|
|
19508
|
+
throw new WalletRequiredError(
|
|
19509
|
+
"send_transaction",
|
|
19510
|
+
"Wallet address is required. Please create a Volr wallet (passkey/MPC) first."
|
|
19420
19511
|
);
|
|
19421
19512
|
}
|
|
19422
19513
|
const call2 = {
|
|
@@ -19436,18 +19527,39 @@ function useVolr() {
|
|
|
19436
19527
|
precheck,
|
|
19437
19528
|
relay,
|
|
19438
19529
|
client: apiClient,
|
|
19439
|
-
user:
|
|
19440
|
-
provider:
|
|
19441
|
-
setProvider
|
|
19530
|
+
user: userRef.current ?? null,
|
|
19531
|
+
provider: providerForDeps,
|
|
19532
|
+
setProvider,
|
|
19533
|
+
onWalletRequired: config.onWalletRequired
|
|
19442
19534
|
}
|
|
19443
19535
|
});
|
|
19444
19536
|
},
|
|
19445
19537
|
sendBatch: (async (calls, opts = {}) => {
|
|
19446
19538
|
const { publicClient: publicClient2, extendedRpcClient: rpcClient } = await ensureRpcClient();
|
|
19447
|
-
|
|
19539
|
+
let from14 = opts.from ?? userRef.current?.evmAddress;
|
|
19540
|
+
let providerForDeps = providerRef.current ?? null;
|
|
19541
|
+
if (!from14 && config.onWalletRequired) {
|
|
19542
|
+
const maybeProvider = await config.onWalletRequired({
|
|
19543
|
+
type: "transaction",
|
|
19544
|
+
chainId
|
|
19545
|
+
});
|
|
19546
|
+
if (maybeProvider) {
|
|
19547
|
+
providerForDeps = maybeProvider;
|
|
19548
|
+
await setProvider(maybeProvider);
|
|
19549
|
+
try {
|
|
19550
|
+
const refreshed = await apiClient.refreshSession();
|
|
19551
|
+
if (refreshed?.evmAddress) {
|
|
19552
|
+
from14 = refreshed.evmAddress;
|
|
19553
|
+
}
|
|
19554
|
+
} catch {
|
|
19555
|
+
}
|
|
19556
|
+
from14 = from14 ?? userRef.current?.evmAddress;
|
|
19557
|
+
}
|
|
19558
|
+
}
|
|
19448
19559
|
if (!from14) {
|
|
19449
|
-
throw new
|
|
19450
|
-
"
|
|
19560
|
+
throw new WalletRequiredError(
|
|
19561
|
+
"send_transaction",
|
|
19562
|
+
"Wallet address is required. Please create a Volr wallet (passkey/MPC) first."
|
|
19451
19563
|
);
|
|
19452
19564
|
}
|
|
19453
19565
|
const isCallArray = (calls2) => {
|
|
@@ -19470,15 +19582,16 @@ function useVolr() {
|
|
|
19470
19582
|
precheck,
|
|
19471
19583
|
relay,
|
|
19472
19584
|
client: apiClient,
|
|
19473
|
-
user:
|
|
19474
|
-
provider:
|
|
19475
|
-
setProvider
|
|
19585
|
+
user: userRef.current ?? null,
|
|
19586
|
+
provider: providerForDeps,
|
|
19587
|
+
setProvider,
|
|
19588
|
+
onWalletRequired: config.onWalletRequired
|
|
19476
19589
|
}
|
|
19477
19590
|
});
|
|
19478
19591
|
})
|
|
19479
19592
|
};
|
|
19480
19593
|
},
|
|
19481
|
-
[
|
|
19594
|
+
[precheck, relay, getRpcUrl, setProvider, apiClient, config.onWalletRequired]
|
|
19482
19595
|
);
|
|
19483
19596
|
const evm = useMemo(
|
|
19484
19597
|
() => ({
|
|
@@ -19496,11 +19609,101 @@ function useVolr() {
|
|
|
19496
19609
|
email: user?.email,
|
|
19497
19610
|
isLoggedIn: user !== null,
|
|
19498
19611
|
signerType: user?.signerType,
|
|
19612
|
+
hasWallet: Boolean(user?.evmAddress),
|
|
19499
19613
|
logout,
|
|
19500
19614
|
isLoading,
|
|
19501
19615
|
error
|
|
19502
19616
|
};
|
|
19503
19617
|
}
|
|
19618
|
+
|
|
19619
|
+
// src/utils/session-broadcast.ts
|
|
19620
|
+
function broadcastSessionEvent(event) {
|
|
19621
|
+
if (typeof window === "undefined") return;
|
|
19622
|
+
if (!("BroadcastChannel" in window)) return;
|
|
19623
|
+
const channel = new BroadcastChannel(STORAGE_CHANNELS.session);
|
|
19624
|
+
channel.postMessage(event);
|
|
19625
|
+
channel.close();
|
|
19626
|
+
}
|
|
19627
|
+
|
|
19628
|
+
// src/hooks/useVolrSession.ts
|
|
19629
|
+
function toVolrUser(u) {
|
|
19630
|
+
return {
|
|
19631
|
+
id: u.id,
|
|
19632
|
+
projectId: u.projectId,
|
|
19633
|
+
projectName: u.projectName,
|
|
19634
|
+
email: u.email,
|
|
19635
|
+
authWallet: u.authWallet ?? void 0,
|
|
19636
|
+
evmAddress: u.evmAddress,
|
|
19637
|
+
keyStorageType: u.keyStorageType ?? void 0,
|
|
19638
|
+
signerType: u.signerType ?? void 0,
|
|
19639
|
+
walletConnector: u.walletConnector ?? void 0,
|
|
19640
|
+
lastWalletChainId: u.lastWalletChainId ?? void 0,
|
|
19641
|
+
blobUrl: u.blobUrl ?? void 0,
|
|
19642
|
+
prfInput: u.prfInput ?? void 0,
|
|
19643
|
+
credentialId: u.credentialId ?? void 0,
|
|
19644
|
+
registeredPasskeys: u.registeredPasskeys ?? void 0
|
|
19645
|
+
};
|
|
19646
|
+
}
|
|
19647
|
+
function useVolrSession() {
|
|
19648
|
+
const { setUser, logout } = useVolrContext();
|
|
19649
|
+
const { client, setAccessToken, setRefreshToken } = useInternalAuth();
|
|
19650
|
+
const setSession = useCallback(
|
|
19651
|
+
async (session) => {
|
|
19652
|
+
setAccessToken(session.accessToken);
|
|
19653
|
+
setRefreshToken(session.refreshToken);
|
|
19654
|
+
const refreshedUser = await client.refreshSession();
|
|
19655
|
+
if (!refreshedUser) {
|
|
19656
|
+
throw new Error("Failed to refresh session. Please try logging in again.");
|
|
19657
|
+
}
|
|
19658
|
+
const nextUser = toVolrUser(refreshedUser);
|
|
19659
|
+
setUser(nextUser);
|
|
19660
|
+
const nextAccess = client.getAccessToken();
|
|
19661
|
+
const nextRefresh = client.getRefreshToken();
|
|
19662
|
+
if (nextAccess) setAccessToken(nextAccess);
|
|
19663
|
+
if (nextRefresh) setRefreshToken(nextRefresh);
|
|
19664
|
+
if (nextAccess && nextRefresh) {
|
|
19665
|
+
broadcastSessionEvent({
|
|
19666
|
+
type: "LOGIN",
|
|
19667
|
+
payload: { accessToken: nextAccess, refreshToken: nextRefresh, user: refreshedUser }
|
|
19668
|
+
});
|
|
19669
|
+
}
|
|
19670
|
+
return nextUser;
|
|
19671
|
+
},
|
|
19672
|
+
[client, setAccessToken, setRefreshToken, setUser]
|
|
19673
|
+
);
|
|
19674
|
+
const clearSession = useCallback(async () => {
|
|
19675
|
+
await logout();
|
|
19676
|
+
broadcastSessionEvent({ type: "LOGOUT" });
|
|
19677
|
+
}, [logout]);
|
|
19678
|
+
const exchangeOidc = useCallback(
|
|
19679
|
+
async (idToken) => {
|
|
19680
|
+
const response = await client.post("/auth/oidc/exchange", {
|
|
19681
|
+
idToken
|
|
19682
|
+
});
|
|
19683
|
+
setAccessToken(response.accessToken);
|
|
19684
|
+
setRefreshToken(response.refreshToken);
|
|
19685
|
+
const nextUser = toVolrUser(response.user);
|
|
19686
|
+
setUser(nextUser);
|
|
19687
|
+
broadcastSessionEvent({
|
|
19688
|
+
type: "LOGIN",
|
|
19689
|
+
payload: {
|
|
19690
|
+
accessToken: response.accessToken,
|
|
19691
|
+
refreshToken: response.refreshToken,
|
|
19692
|
+
user: response.user
|
|
19693
|
+
}
|
|
19694
|
+
});
|
|
19695
|
+
return {
|
|
19696
|
+
userId: response.user?.id || "",
|
|
19697
|
+
isNewUser: response.isNewUser,
|
|
19698
|
+
keyStorageType: response.user?.keyStorageType ?? null,
|
|
19699
|
+
signerType: response.user?.signerType ?? null,
|
|
19700
|
+
accessToken: response.accessToken
|
|
19701
|
+
};
|
|
19702
|
+
},
|
|
19703
|
+
[client, setAccessToken, setRefreshToken, setUser]
|
|
19704
|
+
);
|
|
19705
|
+
return { setSession, clearSession, exchangeOidc };
|
|
19706
|
+
}
|
|
19504
19707
|
init_sha3();
|
|
19505
19708
|
init_utils2();
|
|
19506
19709
|
function toChecksumAddress(address) {
|
|
@@ -19519,7 +19722,7 @@ function toChecksumAddress(address) {
|
|
|
19519
19722
|
function useVolrLogin() {
|
|
19520
19723
|
const { config, setUser } = useVolrContext();
|
|
19521
19724
|
const { setAccessToken, setRefreshToken, client } = useInternalAuth();
|
|
19522
|
-
const
|
|
19725
|
+
const toVolrUser2 = useCallback((u) => {
|
|
19523
19726
|
return {
|
|
19524
19727
|
id: u.id,
|
|
19525
19728
|
projectId: u.projectId,
|
|
@@ -19578,7 +19781,7 @@ function useVolrLogin() {
|
|
|
19578
19781
|
);
|
|
19579
19782
|
}
|
|
19580
19783
|
if (userFromServer) {
|
|
19581
|
-
setUser(
|
|
19784
|
+
setUser(toVolrUser2(userFromServer));
|
|
19582
19785
|
} else {
|
|
19583
19786
|
setUser({ id: "", email: normalizedEmail });
|
|
19584
19787
|
}
|
|
@@ -19590,7 +19793,7 @@ function useVolrLogin() {
|
|
|
19590
19793
|
accessToken
|
|
19591
19794
|
};
|
|
19592
19795
|
},
|
|
19593
|
-
[client, setAccessToken, setRefreshToken, setUser,
|
|
19796
|
+
[client, setAccessToken, setRefreshToken, setUser, toVolrUser2]
|
|
19594
19797
|
);
|
|
19595
19798
|
const handleSocialLogin = useCallback(
|
|
19596
19799
|
async (provider) => {
|
|
@@ -19628,7 +19831,7 @@ function useVolrLogin() {
|
|
|
19628
19831
|
setRefreshToken(refreshToken);
|
|
19629
19832
|
}
|
|
19630
19833
|
if (userFromServer) {
|
|
19631
|
-
setUser(
|
|
19834
|
+
setUser(toVolrUser2(userFromServer));
|
|
19632
19835
|
}
|
|
19633
19836
|
return {
|
|
19634
19837
|
userId: userFromServer?.id || "",
|
|
@@ -19646,7 +19849,7 @@ function useVolrLogin() {
|
|
|
19646
19849
|
throw error;
|
|
19647
19850
|
}
|
|
19648
19851
|
},
|
|
19649
|
-
[client, setAccessToken, setRefreshToken, setUser,
|
|
19852
|
+
[client, setAccessToken, setRefreshToken, setUser, toVolrUser2]
|
|
19650
19853
|
);
|
|
19651
19854
|
const signWithWallet = useCallback(
|
|
19652
19855
|
async (walletAddress, options) => {
|
|
@@ -19693,11 +19896,11 @@ Issued At: ${issuedAt}`;
|
|
|
19693
19896
|
if (response.status === "completed" && response.tokens && response.user) {
|
|
19694
19897
|
setAccessToken(response.tokens.accessToken);
|
|
19695
19898
|
setRefreshToken(response.tokens.refreshToken);
|
|
19696
|
-
setUser(
|
|
19899
|
+
setUser(toVolrUser2(response.user));
|
|
19697
19900
|
}
|
|
19698
19901
|
return response;
|
|
19699
19902
|
},
|
|
19700
|
-
[client, setAccessToken, setRefreshToken, setUser,
|
|
19903
|
+
[client, setAccessToken, setRefreshToken, setUser, toVolrUser2]
|
|
19701
19904
|
);
|
|
19702
19905
|
const getSiweSignUrl = useCallback(
|
|
19703
19906
|
(sessionId) => {
|
|
@@ -19737,7 +19940,7 @@ function useVolrAuthCallback(options = {}) {
|
|
|
19737
19940
|
const [isNewUser, setIsNewUser] = useState(false);
|
|
19738
19941
|
const [user, setLocalUser] = useState(null);
|
|
19739
19942
|
const hasProcessed = useRef(false);
|
|
19740
|
-
const
|
|
19943
|
+
const toVolrUser2 = useCallback((u) => {
|
|
19741
19944
|
return {
|
|
19742
19945
|
id: u.id,
|
|
19743
19946
|
projectId: u.projectId,
|
|
@@ -19797,7 +20000,7 @@ function useVolrAuthCallback(options = {}) {
|
|
|
19797
20000
|
if (refreshToken) {
|
|
19798
20001
|
setRefreshToken(refreshToken);
|
|
19799
20002
|
}
|
|
19800
|
-
const volrUser =
|
|
20003
|
+
const volrUser = toVolrUser2(userData);
|
|
19801
20004
|
setUser(volrUser);
|
|
19802
20005
|
setLocalUser(volrUser);
|
|
19803
20006
|
if (clearUrlParams && typeof window !== "undefined") {
|
|
@@ -21340,6 +21543,6 @@ function detectWalletConnector(provider, providerInfo) {
|
|
|
21340
21543
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
21341
21544
|
*/
|
|
21342
21545
|
|
|
21343
|
-
export { DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, InAppBrowserNotSupportedError, PasskeyNotFoundError, PrfNotSupportedError, UserCancelledError, VolrProvider, WebAuthnBusyError, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfCompatibility, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, decryptEntropyForMigration, defaultIdempotencyKey, detectWalletConnector, diagnoseTransactionFailure, getBrowserVersion, getERC20Balance, getIOSVersion, getPasskeyAuthGuidance, getPlatformHint, getUserCredentials, getWalletState, isEIP7702Delegated, isInAppBrowser, isInAppBrowserNotSupportedError, isUserCancelledError, isWebAuthnBusyError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useEIP6963, useInternalAuth, useMpcConnection, usePasskeyEnrollment, usePrecheck, useRelay, useUserBalances, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi, useWithdraw };
|
|
21546
|
+
export { DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, InAppBrowserNotSupportedError, PasskeyNotFoundError, PrfNotSupportedError, UserCancelledError, VolrProvider, WalletRequiredError, WebAuthnBusyError, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfCompatibility, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, decryptEntropyForMigration, defaultIdempotencyKey, detectWalletConnector, diagnoseTransactionFailure, getBrowserVersion, getERC20Balance, getIOSVersion, getPasskeyAuthGuidance, getPlatformHint, getUserCredentials, getWalletState, isEIP7702Delegated, isInAppBrowser, isInAppBrowserNotSupportedError, isUserCancelledError, isWalletRequiredError, isWebAuthnBusyError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useEIP6963, useInternalAuth, useMpcConnection, usePasskeyEnrollment, usePrecheck, useRelay, useUserBalances, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi, useVolrSession, useWithdraw };
|
|
21344
21547
|
//# sourceMappingURL=index.js.map
|
|
21345
21548
|
//# sourceMappingURL=index.js.map
|