mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2025-03-15 13:22:43 +01:00
Update content of files
This commit is contained in:
parent
32fd29a592
commit
eeba9f19bd
4 changed files with 78 additions and 22 deletions
|
@ -1224,6 +1224,14 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
function checkInit() {
|
||||
if (!isInited) {
|
||||
console.error('[Telegram.WebApp] BiometricManager should be inited before using.');
|
||||
throw Error('WebAppBiometricManagerNotInited');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
biometricManager.init = function(callback) {
|
||||
if (!checkVersion()) {
|
||||
return biometricManager;
|
||||
|
@ -1237,14 +1245,11 @@
|
|||
WebView.postEvent('web_app_biometry_get_info', false);
|
||||
return biometricManager;
|
||||
};
|
||||
biometricManager.requestAccess = function(callback) {
|
||||
biometricManager.requestAccess = function(params, callback) {
|
||||
if (!checkVersion()) {
|
||||
return biometricManager;
|
||||
}
|
||||
if (!isInited) {
|
||||
console.error('[Telegram.WebApp] BiometricManager should be inited before using.');
|
||||
throw Error('WebAppBiometricManagerNotInited');
|
||||
}
|
||||
checkInit();
|
||||
if (!isBiometricAvailable) {
|
||||
console.error('[Telegram.WebApp] Biometrics is not available on this device.');
|
||||
throw Error('WebAppBiometricManagerBiometricsNotAvailable');
|
||||
|
@ -1253,20 +1258,29 @@
|
|||
console.error('[Telegram.WebApp] Access is already requested');
|
||||
throw Error('WebAppBiometricManagerAccessRequested');
|
||||
}
|
||||
var popup_params = {};
|
||||
if (typeof params.reason !== 'undefined') {
|
||||
var reason = strTrim(params.reason);
|
||||
if (reason.length > 128) {
|
||||
console.error('[Telegram.WebApp] Biometric reason is too long', reason);
|
||||
throw Error('WebAppBiometricRequestAccessParamInvalid');
|
||||
}
|
||||
if (reason.length > 0) {
|
||||
popup_params.reason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
accessRequestState = {
|
||||
callback: callback
|
||||
};
|
||||
WebView.postEvent('web_app_biometry_request_access', false);
|
||||
WebView.postEvent('web_app_biometry_request_access', false, popup_params);
|
||||
return biometricManager;
|
||||
};
|
||||
biometricManager.authenticate = function(callback) {
|
||||
biometricManager.authenticate = function(params, callback) {
|
||||
if (!checkVersion()) {
|
||||
return biometricManager;
|
||||
}
|
||||
if (!isInited) {
|
||||
console.error('[Telegram.WebApp] BiometricManager should be inited before using.');
|
||||
throw Error('WebAppBiometricManagerNotInited');
|
||||
}
|
||||
checkInit();
|
||||
if (!isBiometricAvailable) {
|
||||
console.error('[Telegram.WebApp] Biometrics is not available on this device.');
|
||||
throw Error('WebAppBiometricManagerBiometricsNotAvailable');
|
||||
|
@ -1279,10 +1293,22 @@
|
|||
console.error('[Telegram.WebApp] Authentication request is already in progress.');
|
||||
throw Error('WebAppBiometricManagerAuthenticationRequested');
|
||||
}
|
||||
var popup_params = {};
|
||||
if (typeof params.reason !== 'undefined') {
|
||||
var reason = strTrim(params.reason);
|
||||
if (reason.length > 128) {
|
||||
console.error('[Telegram.WebApp] Biometric reason is too long', reason);
|
||||
throw Error('WebAppBiometricRequestAccessParamInvalid');
|
||||
}
|
||||
if (reason.length > 0) {
|
||||
popup_params.reason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
authRequestState = {
|
||||
callback: callback
|
||||
};
|
||||
WebView.postEvent('web_app_biometry_request_auth', false);
|
||||
WebView.postEvent('web_app_biometry_request_auth', false, popup_params);
|
||||
return biometricManager;
|
||||
};
|
||||
biometricManager.updateBiometricToken = function(token, callback) {
|
||||
|
@ -1294,10 +1320,7 @@
|
|||
console.error('[Telegram.WebApp] Token is too long', token);
|
||||
throw Error('WebAppBiometricManagerTokenInvalid');
|
||||
}
|
||||
if (!isInited) {
|
||||
console.error('[Telegram.WebApp] BiometricManager should be inited before using.');
|
||||
throw Error('WebAppBiometricManagerNotInited');
|
||||
}
|
||||
checkInit();
|
||||
if (!isBiometricAvailable) {
|
||||
console.error('[Telegram.WebApp] Biometrics is not available on this device.');
|
||||
throw Error('WebAppBiometricManagerBiometricsNotAvailable');
|
||||
|
@ -1316,6 +1339,26 @@
|
|||
WebView.postEvent('web_app_biometry_update_token', false, {token: token});
|
||||
return biometricManager;
|
||||
};
|
||||
biometricManager.openSettings = function() {
|
||||
if (!checkVersion()) {
|
||||
return biometricManager;
|
||||
}
|
||||
checkInit();
|
||||
if (!isBiometricAvailable) {
|
||||
console.error('[Telegram.WebApp] Biometrics is not available on this device.');
|
||||
throw Error('WebAppBiometricManagerBiometricsNotAvailable');
|
||||
}
|
||||
if (!isAccessRequested) {
|
||||
console.error('[Telegram.WebApp] Biometric access was not requested yet.');
|
||||
throw Error('WebAppBiometricManagerBiometricsAccessNotRequested');
|
||||
}
|
||||
if (isAccessGranted) {
|
||||
console.warn('[Telegram.WebApp] Biometric access was granted by the user, no need to go to settings.');
|
||||
return biometricManager;
|
||||
}
|
||||
WebView.postEvent('web_app_biometry_open_settings', false);
|
||||
return biometricManager;
|
||||
};
|
||||
return biometricManager;
|
||||
})();
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="MobileOptimized" content="176" />
|
||||
<meta name="HandheldFriendly" content="True" />
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<script src="https://tg.dev/js/telegram-web-app.js?43"></script>
|
||||
<script src="https://tg.dev/js/telegram-web-app.js?44"></script>
|
||||
<script>
|
||||
function setThemeClass() {
|
||||
document.documentElement.className = Telegram.WebApp.colorScheme;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<meta name="MobileOptimized" content="176" />
|
||||
<meta name="HandheldFriendly" content="True" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<script src="https://tg.dev/js/telegram-web-app.js?43"></script>
|
||||
<script src="https://tg.dev/js/telegram-web-app.js?44"></script>
|
||||
<script>
|
||||
function setThemeClass() {
|
||||
document.documentElement.className = Telegram.WebApp.colorScheme;
|
||||
|
@ -128,7 +128,7 @@
|
|||
<li>available: <span class="txt" id="bm_available">false</span></li>
|
||||
<li>type: <span class="txt" id="bm_type"></span></li>
|
||||
<li>access_requested: <span class="txt" id="bm_access_requested">false</span> (<a href="javascript:;" onclick="return DemoApp.biometricRequestAccess(this);">Request access</a>) <span></span></li>
|
||||
<li>access_granted: <span class="txt" id="bm_access_granted">false</span></li>
|
||||
<li>access_granted: <span class="txt" id="bm_access_granted">false</span> <span id="bm_settings" style="display:none;">(<a href="javascript:;" onclick="return DemoApp.biometricOpenSettings(this);">Open settings</a>)</span></li>
|
||||
<li>token_saved: <span class="txt" id="bm_token_saved">false</span> (<a href="javascript:;" onclick="return DemoApp.biometricSetToken(this);">Set token</a>, <a href="javascript:;" onclick="return DemoApp.biometricRemoveToken(this);">Remove token</a>) <span></span></li>
|
||||
<li><a href="javascript:;" onclick="return DemoApp.biometricRequestAuth(this);">Request auth</a> <span></span></li>
|
||||
</ul>
|
||||
|
@ -151,7 +151,7 @@
|
|||
<div class="viewport-stable_border"></div>
|
||||
<script src="/js/jquery.min.js"></script>
|
||||
<script src="https://tg.dev/js/bootstrap.min.js"></script>
|
||||
<script src="/js/webappdemo.js?25"></script>
|
||||
<script src="/js/webappdemo.js?26"></script>
|
||||
<script>DemoApp.apiUrl = "/demo/api";
|
||||
|
||||
Telegram.WebApp.onEvent('themeChanged', function() {
|
||||
|
|
|
@ -299,6 +299,7 @@ var DemoApp = {
|
|||
$('#bm_access_requested').text(biometricManager.isAccessRequested ? 'true' : 'false');
|
||||
$('#bm_access_granted').text(biometricManager.isAccessGranted ? 'true' : 'false');
|
||||
$('#bm_token_saved').text(biometricManager.isBiometricTokenSaved ? 'true' : 'false');
|
||||
$('#bm_settings').toggle(!!(biometricManager.isAvailable && biometricManager.isAccessRequested && !biometricManager.isAccessGranted));
|
||||
});
|
||||
}
|
||||
biometricManager.init();
|
||||
|
@ -308,7 +309,7 @@ var DemoApp = {
|
|||
if (!biometricManager.isInited) {
|
||||
return DemoApp.showAlert('Biometric not inited yet!');
|
||||
}
|
||||
biometricManager.requestAccess(function(access_granted) {
|
||||
biometricManager.requestAccess({reason: 'The bot uses biometrics for testing purposes.'}, function(access_granted) {
|
||||
if (access_granted) {
|
||||
$(el).next('span').text('(Access granted)').attr('class', 'ok');
|
||||
} else {
|
||||
|
@ -322,7 +323,7 @@ var DemoApp = {
|
|||
return DemoApp.showAlert('Biometric not inited yet!');
|
||||
}
|
||||
$(el).next('span').text('').attr('class', '');
|
||||
biometricManager.authenticate(function(success, token) {
|
||||
biometricManager.authenticate({reason: 'The bot requests biometrics for testing purposes.'}, function(success, token) {
|
||||
if (success) {
|
||||
$(el).next('span').text('(Success, token: ' + token + ')').attr('class', 'ok');
|
||||
} else {
|
||||
|
@ -330,6 +331,18 @@ var DemoApp = {
|
|||
}
|
||||
});
|
||||
},
|
||||
biometricOpenSettings: function(el) {
|
||||
var biometricManager = Telegram.WebApp.BiometricManager;
|
||||
if (!biometricManager.isInited) {
|
||||
return DemoApp.showAlert('Biometric not inited yet!');
|
||||
}
|
||||
if (!biometricManager.isAvailable ||
|
||||
!biometricManager.isAccessRequested ||
|
||||
biometricManager.isAccessGranted) {
|
||||
return false;
|
||||
}
|
||||
biometricManager.openSettings();
|
||||
},
|
||||
biometricSetToken: function(el) {
|
||||
var biometricManager = Telegram.WebApp.BiometricManager;
|
||||
if (!biometricManager.isInited) {
|
||||
|
|
Loading…
Add table
Reference in a new issue