onairos 0.1.337 → 0.1.339

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.
@@ -4,52 +4,52 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = GoogleButton;
7
+ var _sdkReact = require("@telegram-apps/sdk-react");
7
8
  var _jsxRuntime = require("react/jsx-runtime");
8
9
  function GoogleButton(_ref) {
9
10
  let {
10
11
  onLoginSuccess
11
12
  } = _ref;
12
- const handleTelegramAuth = async () => {
13
+ const handleTelegramAuth = () => {
13
14
  try {
14
15
  // Get Telegram Mini App data
15
- const telegramAppUrl = window.Telegram.WebApp.initData;
16
+ const telegramAppUrl = WebApp.initDataUnsafe;
16
17
  const botUsername = 'OnairosMiniApp';
17
18
 
18
19
  // Construct URL to your Othent connect page
19
20
  const connectUrl = new URL('https://onairos.uk/othent-connect');
20
- connectUrl.searchParams.append('tgAppUrl', telegramAppUrl);
21
+ connectUrl.searchParams.append('tgAppUrl', encodeURIComponent(JSON.stringify(telegramAppUrl)));
21
22
  connectUrl.searchParams.append('botUsername', botUsername);
22
- connectUrl.searchParams.append('startApp', window.Telegram.WebApp.initDataUnsafe?.start_param || '');
23
+ connectUrl.searchParams.append('startApp', telegramAppUrl?.start_param || '');
23
24
 
24
- // Open in browser
25
- window.open(connectUrl.toString(), '_blank');
26
-
27
- // Listen for Telegram WebApp events
28
- window.Telegram.WebApp.onEvent('popupClosed', async params => {
29
- const startParam = window.Telegram.WebApp.initDataUnsafe?.start_param;
30
- if (startParam) {
31
- try {
32
- const authData = JSON.parse(decodeURIComponent(startParam));
33
- if (authData.sub && authData.token) {
34
- onLoginSuccess(authData);
35
- }
36
- } catch (error) {
37
- console.error('Error processing auth data:', error);
38
- }
39
- }
40
- });
25
+ // Open link using Telegram Mini App API
26
+ WebApp.openLink(connectUrl.toString());
41
27
  } catch (error) {
42
28
  console.error('Telegram auth flow failed:', error);
43
29
  }
44
30
  };
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
+ });
45
46
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
46
47
  className: "flex flex-col items-center",
47
48
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
48
49
  onClick: handleTelegramAuth,
49
50
  className: "flex items-center justify-center px-4 py-2 border border-gray-300 rounded-full shadow-sm bg-white hover:bg-gray-50",
50
51
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
51
- src: "https://imagepng.org/google-icone-icon/google-icon/" // Replace with actual Othent icon
52
- ,
52
+ src: "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
53
53
  alt: "Google",
54
54
  className: "w-5 h-5 mr-2"
55
55
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {