@volr/react 0.1.113 → 0.1.115
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 +17 -161
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -161
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -19401,11 +19401,6 @@ function useDepositListener(input) {
|
|
|
19401
19401
|
}, [getRpcUrl, input.chainId, input.address, JSON.stringify(input.asset)]);
|
|
19402
19402
|
return status;
|
|
19403
19403
|
}
|
|
19404
|
-
function debugLog(step, data) {
|
|
19405
|
-
{
|
|
19406
|
-
console.log(`[PasskeyEnrollment] ${step}`, data !== void 0 ? data : "");
|
|
19407
|
-
}
|
|
19408
|
-
}
|
|
19409
19404
|
function blobToBase64(blob) {
|
|
19410
19405
|
return new Promise((resolve, reject) => {
|
|
19411
19406
|
const reader = new FileReader();
|
|
@@ -19453,14 +19448,6 @@ function buildDisplayName(userEmail, userEvmAddress, userId) {
|
|
|
19453
19448
|
return userId || "Volr Wallet";
|
|
19454
19449
|
}
|
|
19455
19450
|
async function enrollPasskey(params) {
|
|
19456
|
-
debugLog("Starting enrollment with params:", {
|
|
19457
|
-
userId: params.userId,
|
|
19458
|
-
projectId: params.projectId,
|
|
19459
|
-
rpId: params.rpId,
|
|
19460
|
-
rpName: params.rpName,
|
|
19461
|
-
userEmail: params.userEmail,
|
|
19462
|
-
userEvmAddress: params.userEvmAddress
|
|
19463
|
-
});
|
|
19464
19451
|
const {
|
|
19465
19452
|
client,
|
|
19466
19453
|
baseUrl,
|
|
@@ -19472,7 +19459,6 @@ async function enrollPasskey(params) {
|
|
|
19472
19459
|
rpId = typeof window !== "undefined" ? window.location.hostname : "localhost",
|
|
19473
19460
|
rpName
|
|
19474
19461
|
} = params;
|
|
19475
|
-
debugLog("Step 0: Validating parameters");
|
|
19476
19462
|
if (!userId) {
|
|
19477
19463
|
throw new Error("userId is required");
|
|
19478
19464
|
}
|
|
@@ -19488,27 +19474,19 @@ async function enrollPasskey(params) {
|
|
|
19488
19474
|
if (!apiKey) {
|
|
19489
19475
|
throw new Error("apiKey is required");
|
|
19490
19476
|
}
|
|
19491
|
-
debugLog("Step 0: Parameters validated", { rpId, rpName });
|
|
19492
|
-
debugLog("Step 1: Checking WebAuthn support");
|
|
19493
19477
|
if (!navigator.credentials || !navigator.credentials.create) {
|
|
19494
19478
|
throw new Error("WebAuthn API is not supported");
|
|
19495
19479
|
}
|
|
19496
|
-
debugLog("Step 1: WebAuthn API is supported");
|
|
19497
19480
|
const challenge2 = new Uint8Array(32);
|
|
19498
19481
|
crypto.getRandomValues(challenge2);
|
|
19499
|
-
debugLog("Step 1: Challenge generated", { challengeLength: challenge2.length });
|
|
19500
19482
|
const userHandle = new TextEncoder().encode(userId);
|
|
19501
|
-
debugLog("Step 1: User handle created", { userHandleLength: userHandle.length });
|
|
19502
19483
|
const tempCredentialId = "temp-" + Date.now();
|
|
19503
19484
|
const tempPrfInput = {
|
|
19504
19485
|
projectId,
|
|
19505
19486
|
credentialId: tempCredentialId
|
|
19506
19487
|
};
|
|
19507
|
-
debugLog("Step 1: Temp PRF input created", tempPrfInput);
|
|
19508
19488
|
const prfSalt = deriveWrapKey(tempPrfInput);
|
|
19509
|
-
debugLog("Step 1: PRF salt derived", { prfSaltLength: prfSalt.length });
|
|
19510
19489
|
const displayName = buildDisplayName(userEmail, userEvmAddress, userId);
|
|
19511
|
-
debugLog("Step 1: Display name built", { displayName });
|
|
19512
19490
|
const publicKeyCredentialCreationOptions = {
|
|
19513
19491
|
challenge: challenge2,
|
|
19514
19492
|
rp: {
|
|
@@ -19532,105 +19510,37 @@ async function enrollPasskey(params) {
|
|
|
19532
19510
|
}
|
|
19533
19511
|
}
|
|
19534
19512
|
};
|
|
19535
|
-
|
|
19536
|
-
|
|
19537
|
-
rpName: publicKeyCredentialCreationOptions.rp.name,
|
|
19538
|
-
timeout: publicKeyCredentialCreationOptions.timeout,
|
|
19539
|
-
attestation: publicKeyCredentialCreationOptions.attestation,
|
|
19540
|
-
authenticatorSelection: publicKeyCredentialCreationOptions.authenticatorSelection,
|
|
19541
|
-
pubKeyCredParams: publicKeyCredentialCreationOptions.pubKeyCredParams
|
|
19513
|
+
const credential = await navigator.credentials.create({
|
|
19514
|
+
publicKey: publicKeyCredentialCreationOptions
|
|
19542
19515
|
});
|
|
19543
|
-
debugLog("Step 1: Calling navigator.credentials.create()...");
|
|
19544
|
-
let credential;
|
|
19545
|
-
try {
|
|
19546
|
-
credential = await navigator.credentials.create({
|
|
19547
|
-
publicKey: publicKeyCredentialCreationOptions
|
|
19548
|
-
});
|
|
19549
|
-
debugLog("Step 1: Credential creation completed", {
|
|
19550
|
-
hasCredential: !!credential,
|
|
19551
|
-
credentialId: credential ? Array.from(new Uint8Array(credential.rawId)).slice(0, 8).join(",") + "..." : null
|
|
19552
|
-
});
|
|
19553
|
-
} catch (err) {
|
|
19554
|
-
debugLog("Step 1: Credential creation FAILED", {
|
|
19555
|
-
error: err,
|
|
19556
|
-
errorMessage: err instanceof Error ? err.message : String(err),
|
|
19557
|
-
errorName: err instanceof Error ? err.name : "Unknown"
|
|
19558
|
-
});
|
|
19559
|
-
throw err;
|
|
19560
|
-
}
|
|
19561
19516
|
if (!credential || !("response" in credential)) {
|
|
19562
|
-
debugLog("Step 1: Invalid credential response", { credential });
|
|
19563
19517
|
throw new Error("Failed to create passkey credential");
|
|
19564
19518
|
}
|
|
19565
19519
|
const credentialId = Array.from(new Uint8Array(credential.rawId)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
19566
|
-
debugLog("Step 2: Credential ID extracted", { credentialIdLength: credentialId.length, credentialIdPrefix: credentialId.slice(0, 16) });
|
|
19567
|
-
debugLog("Step 2: Extracting PRF output");
|
|
19568
19520
|
const extensionResults = credential.getClientExtensionResults();
|
|
19569
|
-
debugLog("Step 2: Extension results", {
|
|
19570
|
-
hasExtensionResults: !!extensionResults,
|
|
19571
|
-
hasPrf: !!extensionResults.prf,
|
|
19572
|
-
hasPrfResults: !!(extensionResults.prf && extensionResults.prf.results),
|
|
19573
|
-
hasPrfFirst: !!(extensionResults.prf && extensionResults.prf.results && extensionResults.prf.results.first),
|
|
19574
|
-
allKeys: Object.keys(extensionResults)
|
|
19575
|
-
});
|
|
19576
19521
|
if (!extensionResults.prf || !extensionResults.prf.results || !extensionResults.prf.results.first) {
|
|
19577
|
-
debugLog("Step 2: PRF extension not supported or missing", extensionResults);
|
|
19578
19522
|
throw new Error("PRF extension not supported or PRF output missing. Please use a browser that supports WebAuthn PRF extension.");
|
|
19579
19523
|
}
|
|
19580
19524
|
const prfOutputBuffer = extensionResults.prf.results.first;
|
|
19581
19525
|
const prfOutput = new Uint8Array(prfOutputBuffer);
|
|
19582
|
-
debugLog("Step 2: PRF output extracted", { prfOutputLength: prfOutput.length });
|
|
19583
19526
|
const prfInput = {
|
|
19584
19527
|
projectId,
|
|
19585
19528
|
credentialId
|
|
19586
19529
|
};
|
|
19587
|
-
debugLog("Step 3: PRF input built", prfInput);
|
|
19588
19530
|
const wrapKey = prfOutput;
|
|
19589
|
-
debugLog("Step 4: Wrap key created from PRF output", { wrapKeyLength: wrapKey.length });
|
|
19590
|
-
debugLog("Step 4: Generating master key...");
|
|
19591
19531
|
const masterKeyProvider = createMasterKeyProvider();
|
|
19592
|
-
|
|
19593
|
-
try {
|
|
19594
|
-
masterKeyHandle = await masterKeyProvider.generate();
|
|
19595
|
-
debugLog("Step 4: Master key generated", {
|
|
19596
|
-
hasEntropy: !!masterKeyHandle.entropy,
|
|
19597
|
-
entropyLength: masterKeyHandle.entropy?.length,
|
|
19598
|
-
hasSeed: !!masterKeyHandle.seed,
|
|
19599
|
-
seedLength: masterKeyHandle.seed?.length
|
|
19600
|
-
});
|
|
19601
|
-
} catch (err) {
|
|
19602
|
-
debugLog("Step 4: Master key generation FAILED", {
|
|
19603
|
-
error: err,
|
|
19604
|
-
errorMessage: err instanceof Error ? err.message : String(err)
|
|
19605
|
-
});
|
|
19606
|
-
throw err;
|
|
19607
|
-
}
|
|
19532
|
+
const masterKeyHandle = await masterKeyProvider.generate();
|
|
19608
19533
|
try {
|
|
19609
19534
|
const keyStorageType = "passkey";
|
|
19610
19535
|
const version5 = "v1";
|
|
19611
19536
|
const aadBytes = new TextEncoder().encode(
|
|
19612
19537
|
`volr/master-seed/v1|${userId}|${keyStorageType}|${version5}`
|
|
19613
19538
|
);
|
|
19614
|
-
|
|
19615
|
-
|
|
19616
|
-
|
|
19617
|
-
|
|
19618
|
-
|
|
19619
|
-
masterKeyHandle.entropy,
|
|
19620
|
-
wrapKey,
|
|
19621
|
-
aadBytes
|
|
19622
|
-
);
|
|
19623
|
-
debugLog("Step 4: Entropy encrypted", {
|
|
19624
|
-
cipherLength: encryptedBlob.cipher.length,
|
|
19625
|
-
nonceLength: encryptedBlob.nonce.length
|
|
19626
|
-
});
|
|
19627
|
-
} catch (err) {
|
|
19628
|
-
debugLog("Step 4: Encryption FAILED", {
|
|
19629
|
-
error: err,
|
|
19630
|
-
errorMessage: err instanceof Error ? err.message : String(err)
|
|
19631
|
-
});
|
|
19632
|
-
throw err;
|
|
19633
|
-
}
|
|
19539
|
+
const encryptedBlob = await sealMasterSeed(
|
|
19540
|
+
masterKeyHandle.entropy,
|
|
19541
|
+
wrapKey,
|
|
19542
|
+
aadBytes
|
|
19543
|
+
);
|
|
19634
19544
|
const blob = new Blob(
|
|
19635
19545
|
[
|
|
19636
19546
|
encryptedBlob.cipher,
|
|
@@ -19640,81 +19550,28 @@ async function enrollPasskey(params) {
|
|
|
19640
19550
|
type: "application/octet-stream"
|
|
19641
19551
|
}
|
|
19642
19552
|
);
|
|
19643
|
-
debugLog("Step 5: Blob prepared", { blobSize: blob.size });
|
|
19644
|
-
debugLog("Step 6: Converting blob to base64...");
|
|
19645
19553
|
const blobB64 = await blobToBase64(blob);
|
|
19646
|
-
|
|
19647
|
-
|
|
19648
|
-
|
|
19649
|
-
try {
|
|
19650
|
-
uploadResponse = await client.post("/blob/upload", {
|
|
19651
|
-
blobB64
|
|
19652
|
-
});
|
|
19653
|
-
debugLog("Step 6: Upload response", uploadResponse);
|
|
19654
|
-
} catch (err) {
|
|
19655
|
-
debugLog("Step 6: Blob upload FAILED", {
|
|
19656
|
-
error: err,
|
|
19657
|
-
errorMessage: err instanceof Error ? err.message : String(err)
|
|
19658
|
-
});
|
|
19659
|
-
throw err;
|
|
19660
|
-
}
|
|
19554
|
+
const uploadResponse = await client.post("/blob/upload", {
|
|
19555
|
+
blobB64
|
|
19556
|
+
});
|
|
19661
19557
|
const blobUrl = uploadResponse?.key;
|
|
19662
19558
|
if (!blobUrl) {
|
|
19663
|
-
debugLog("Step 6: Missing blob URL in response", uploadResponse);
|
|
19664
19559
|
throw new Error("Failed to upload blob: missing key");
|
|
19665
19560
|
}
|
|
19666
|
-
|
|
19667
|
-
debugLog("Step 7: Deriving address from seed...");
|
|
19668
|
-
let keypair;
|
|
19669
|
-
try {
|
|
19670
|
-
keypair = deriveEvmKey({ masterSeed: masterKeyHandle.seed });
|
|
19671
|
-
debugLog("Step 7: Keypair derived", { address: keypair.address });
|
|
19672
|
-
} catch (err) {
|
|
19673
|
-
debugLog("Step 7: Key derivation FAILED", {
|
|
19674
|
-
error: err,
|
|
19675
|
-
errorMessage: err instanceof Error ? err.message : String(err)
|
|
19676
|
-
});
|
|
19677
|
-
throw err;
|
|
19678
|
-
}
|
|
19561
|
+
const keypair = deriveEvmKey({ masterSeed: masterKeyHandle.seed });
|
|
19679
19562
|
const address = keypair.address;
|
|
19680
19563
|
const platform = detectPlatform();
|
|
19681
|
-
|
|
19564
|
+
const registerResponse = await client.post("/wallet/provider/register", {
|
|
19682
19565
|
keyStorageType: "passkey",
|
|
19683
19566
|
credentialId,
|
|
19684
19567
|
blobUrl,
|
|
19568
|
+
prfInput: {
|
|
19569
|
+
projectId,
|
|
19570
|
+
credentialId
|
|
19571
|
+
},
|
|
19685
19572
|
address,
|
|
19686
19573
|
platform
|
|
19687
19574
|
});
|
|
19688
|
-
let registerResponse;
|
|
19689
|
-
try {
|
|
19690
|
-
registerResponse = await client.post("/wallet/provider/register", {
|
|
19691
|
-
keyStorageType: "passkey",
|
|
19692
|
-
credentialId,
|
|
19693
|
-
blobUrl,
|
|
19694
|
-
prfInput: {
|
|
19695
|
-
projectId,
|
|
19696
|
-
credentialId
|
|
19697
|
-
},
|
|
19698
|
-
address,
|
|
19699
|
-
platform
|
|
19700
|
-
// For UX hints when authenticating on different devices
|
|
19701
|
-
});
|
|
19702
|
-
debugLog("Step 8: Provider registered", {
|
|
19703
|
-
providerId: registerResponse?.id,
|
|
19704
|
-
hasUser: !!registerResponse?.user
|
|
19705
|
-
});
|
|
19706
|
-
} catch (err) {
|
|
19707
|
-
debugLog("Step 8: Provider registration FAILED", {
|
|
19708
|
-
error: err,
|
|
19709
|
-
errorMessage: err instanceof Error ? err.message : String(err)
|
|
19710
|
-
});
|
|
19711
|
-
throw err;
|
|
19712
|
-
}
|
|
19713
|
-
debugLog("Enrollment completed successfully!", {
|
|
19714
|
-
credentialId,
|
|
19715
|
-
blobUrl,
|
|
19716
|
-
address
|
|
19717
|
-
});
|
|
19718
19575
|
return {
|
|
19719
19576
|
credentialId,
|
|
19720
19577
|
blobUrl,
|
|
@@ -19728,7 +19585,6 @@ async function enrollPasskey(params) {
|
|
|
19728
19585
|
user: registerResponse.user
|
|
19729
19586
|
};
|
|
19730
19587
|
} finally {
|
|
19731
|
-
debugLog("Cleanup: Destroying master key handle");
|
|
19732
19588
|
masterKeyHandle.destroy();
|
|
19733
19589
|
}
|
|
19734
19590
|
}
|