onairos 0.1.339 → 0.1.341
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/components/GoogleButton.js +27 -21
- package/dist/onairos.bundle.js +1 -1
- package/dist/onairos.bundle.js.map +1 -1
- package/dist/onairos.js +8 -5
- package/dist/onairosButton.js +21 -11
- package/package.json +1 -1
- package/src/components/GoogleButton.js +58 -54
- package/src/onairos.jsx +10 -5
- package/src/onairosButton.jsx +26 -14
|
@@ -4,45 +4,51 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = GoogleButton;
|
|
7
|
-
var
|
|
7
|
+
var _sdk = require("@telegram-apps/sdk");
|
|
8
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
9
|
function GoogleButton(_ref) {
|
|
10
10
|
let {
|
|
11
11
|
onLoginSuccess
|
|
12
12
|
} = _ref;
|
|
13
|
-
const handleTelegramAuth = () => {
|
|
13
|
+
const handleTelegramAuth = async () => {
|
|
14
|
+
if (!_sdk.miniApp.mount.isAvailable()) {
|
|
15
|
+
console.error('Telegram Mini App not available');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
14
18
|
try {
|
|
19
|
+
// Mount the Mini App
|
|
20
|
+
_sdk.miniApp.mount();
|
|
21
|
+
|
|
15
22
|
// Get Telegram Mini App data
|
|
16
|
-
const telegramAppUrl =
|
|
23
|
+
const telegramAppUrl = _sdk.miniApp.initData;
|
|
17
24
|
const botUsername = 'OnairosMiniApp';
|
|
18
25
|
|
|
19
26
|
// Construct URL to your Othent connect page
|
|
20
27
|
const connectUrl = new URL('https://onairos.uk/othent-connect');
|
|
21
28
|
connectUrl.searchParams.append('tgAppUrl', encodeURIComponent(JSON.stringify(telegramAppUrl)));
|
|
22
29
|
connectUrl.searchParams.append('botUsername', botUsername);
|
|
23
|
-
connectUrl.searchParams.append('startApp', telegramAppUrl?.start_param || '');
|
|
24
30
|
|
|
25
|
-
// Open
|
|
26
|
-
|
|
31
|
+
// Open in browser
|
|
32
|
+
_sdk.miniApp.openLink(connectUrl.toString());
|
|
33
|
+
|
|
34
|
+
// Listen for viewport changes
|
|
35
|
+
// miniApp.onEvent('viewportChanged', () => {
|
|
36
|
+
// const startParam = miniApp.initDataUnsafe?.start_param;
|
|
37
|
+
// if (startParam) {
|
|
38
|
+
// try {
|
|
39
|
+
// const authData = JSON.parse(decodeURIComponent(startParam));
|
|
40
|
+
// if (authData) {
|
|
41
|
+
// onLoginSuccess(authData);
|
|
42
|
+
// }
|
|
43
|
+
// } catch (error) {
|
|
44
|
+
// console.error('Error processing auth data:', error);
|
|
45
|
+
// }
|
|
46
|
+
// }
|
|
47
|
+
// });
|
|
27
48
|
} catch (error) {
|
|
28
49
|
console.error('Telegram auth flow failed:', error);
|
|
29
50
|
}
|
|
30
51
|
};
|
|
31
|
-
|
|
32
|
-
// Event listener for when the Mini App is closed
|
|
33
|
-
WebApp.onEvent('viewportChanged', () => {
|
|
34
|
-
const startParam = WebApp.initDataUnsafe?.start_param;
|
|
35
|
-
if (startParam) {
|
|
36
|
-
try {
|
|
37
|
-
const authData = JSON.parse(decodeURIComponent(startParam));
|
|
38
|
-
if (authData.sub && authData.token) {
|
|
39
|
-
onLoginSuccess(authData);
|
|
40
|
-
}
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error('Error processing auth data:', error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
52
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
47
53
|
className: "flex flex-col items-center",
|
|
48
54
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|