webauthnScript top-level property
Implementation
final webauthnScript = '''
const webauthnRequests = {};
$webauthnRegistrationFunction = ({ optionsJSON }) => {
return new Promise((resolve, reject) => {
webauthnRequests.create = { resolve, reject };
$webauthnInterface.postMessage(JSON.stringify({
type: 'create',
request: optionsJSON
}));
});
};
$webauthnAuthenticationFunction = ({ optionsJSON }) => {
return new Promise((resolve, reject) => {
webauthnRequests.get = { resolve, reject };
$webauthnInterface.postMessage(JSON.stringify({
type: 'get',
request: optionsJSON
}));
});
};
$webauthnReplyFunction = ([status, data, type]) => {
if (status === 'success') {
webauthnRequests[type].resolve(data);
} else {
webauthnRequests[type].reject(new DOMException(data, 'NotAllowedError'));
}
delete webauthnRequests[type];
};
''';