Comments (3)
Credential ID bytes are effectively random so I'm not at all surprised they're not encoding to readable UTF-8. I recommend using the isoBase64URL
helper instead, its isoBase64URL.fromBuffer()
and isoBase64URL.toBuffer()
are better at encoding these bytes into strings (though isoUint8Array.toHex()
and isoUint8Array.fromHex()
are fine too, though its seemingly unorthodox to me because so much of WebAuthn uses base64url encoding.)
can then trigger the windows hello prompt successfully but then on the verify part I get this error :
Error: No packed values available
Looking at your code sample I think I see the problem:
const backFromHexPublicKey = isoUint8Array.fromHex(previousAuthenticator.credentialID);
previousAuthenticator.credentialID
should probably be previousAuthenticator.credentialPublicKey
(or whatever it's called on your end)...
from simplewebauthn.
O.M.G
I can't believe this !
I've changed credentialID
to credentialPublicKey
and it works ... 💀
Too much copy / paste kills copy / paste 😢
Sorry to made you loose your time ! And a big thank you ! ♥
At least I've learned that I should probably use isoBase64URL.fromBuffer()
/ isoBase64URL.toBuffer()
😅
from simplewebauthn.
I've noticed that it's working with the isoUint8Array.toHex
helper :
// Saving :
const hexCredentialID = isoUint8Array.toHex(verification.registrationInfo.credentialID);
const hexCredentialPublicKey = isoUint8Array.toHex(verification.registrationInfo.credentialPublicKey);
// Authentification Option :
const previousAuthenticator = await Authenticator.findOne({ userId: user._id });
const credentialIDbackFromHex = isoUint8Array.fromHex(previousAuthenticator.credentialID);
console.log('credentialIDbackFromHex = ', credentialIDbackFromHex ); // The "restored" uInt8Array is the same !
const options = await generateAuthenticationOptions({
rpID,
allowCredentials: [
{
id: credentialIDbackFromHex ,
type: 'public-key',
transports: previousAuthenticator.transports,
},
],
userVerification: 'preferred',
});
I can then trigger the windows hello prompt successfully but then on the verify part I get this error :
Error: No packed values available
:
Verify part code :
const previousAuthenticator = await Authenticator.findOne({ userId: user?._id });
try {
const backFromHexCredentialID = isoUint8Array.fromHex(previousAuthenticator.credentialID);
const backFromHexPublicKey = isoUint8Array.fromHex(previousAuthenticator.credentialID);
verification = await verifyAuthenticationResponse({
response: challengeResponse,
expectedChallenge: user?.challenge,
expectedOrigin: origin,
expectedRPID: rpID,
authenticator: {
...previousAuthenticator,
credentialID: backFromHexCredentialID,
credentialPublicKey: backFromHexPublicKey,
},
requireUserVerification: true,
});
res.status(200).json({ ok: verification.verified });
} catch (error) {
console.error(error);
return res.status(400).send({ message: error.message });
}
from simplewebauthn.
Related Issues (20)
- VerifiedRegistrationResponse type missing transports attribute HOT 3
- failed test in packages/server HOT 4
- generateRegistrationOptions's `excludeCredentials` is returning empty string for each id HOT 1
- extractStrings is not a function HOT 3
- `pubKeyCredParams` field not properly functioning w/ non ES256 Algos on register HOT 2
- Unable to Register a Passkey Using a PIN Code HOT 2
- RFC: Rename @simplewebauthn/typescript-types to something shorter HOT 3
- Treat all custom string challenges as UTF-8 strings
- Cannot find module 'cbor-x/index-no-eval' or its corresponding type declarations. HOT 9
- ignore `node:crypto` import with webpack in `@simplewebauthn/server` HOT 8
- Update minimum Node support to v20+ HOT 3
- library reports lack of support to webauthn in mobile chrome but webauthn seems to work if using reference site HOT 8
- Using Android devices without non-Google Password managers fail to authenticate HOT 11
- Change signature of `decodeClientDataJSON` to accept `Base64URLString` as paramater HOT 2
- Improve ergonomics of `excludeCredentials` and `allowCredentials` HOT 3
- Remove footgun related to random user IDs HOT 16
- Update `getWebCrypto()` for Node 20 HOT 2
- cross-platform authenticator usage on android 14 HOT 1
- Default `userDisplayName` to empty string when not specified HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplewebauthn.