Using passwordless-id/webauthn on the react native, however facing some problems.
Fist was TextDecoder which I have fixed, but still there is one issue idk why:
import client from '@passwordless-id/webauthn';
const CreateCredentials = () => {
const {loggedInUser} = useContext(UserLoggedInData);
const isClientAvailable = client.isAvailable();
//fetch data
const credential = AsyncStorage.getItem('credential_');
const challengeS = AsyncStorage.getItem('challenge_');
// Registration
const [isRegistered, setIsRegistered] = useState(false);
const challenge =
AsyncStorage.getItem('challenge_' + loggedInUser.username) || uuidv4();
const checkIsRegistered = useCallback(async () => {
setIsRegistered(
!!AsyncStorage.getItem('credential_' + loggedInUser.username),
);
}, []);
useEffect(() => {
if (loggedInUser.username) {
checkIsRegistered();
}
}, []);
const register = useCallback(async () => {
const res = await client.register(loggedInUser.username, challenge, {
authenticatorType: 'auto',
userVerification: 'required',
timeout: 60000,
attestation: false,
debug: false,
});
console.log('====================================');
console.log(res);
console.log('====================================');
AsyncStorage.setItem('username', loggedInUser.username);
AsyncStorage.setItem(
'credential_' + loggedInUser.username,
parsed.credential.id,
);
AsyncStorage.setItem('challenge_' + loggedInUser.username, challenge);
checkIsRegistered();
}, []);
ERROR TypeError: undefined is not a function
This error is located at:
in CreateCredentials