onairos 0.1.337 → 0.1.338

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.
@@ -9,47 +9,46 @@ function GoogleButton(_ref) {
9
9
  let {
10
10
  onLoginSuccess
11
11
  } = _ref;
12
- const handleTelegramAuth = async () => {
12
+ const handleTelegramAuth = () => {
13
13
  try {
14
14
  // Get Telegram Mini App data
15
- const telegramAppUrl = window.Telegram.WebApp.initData;
15
+ const telegramAppUrl = window.Telegram.WebApp.initDataUnsafe;
16
16
  const botUsername = 'OnairosMiniApp';
17
17
 
18
18
  // Construct URL to your Othent connect page
19
19
  const connectUrl = new URL('https://onairos.uk/othent-connect');
20
- connectUrl.searchParams.append('tgAppUrl', telegramAppUrl);
20
+ connectUrl.searchParams.append('tgAppUrl', encodeURIComponent(JSON.stringify(telegramAppUrl)));
21
21
  connectUrl.searchParams.append('botUsername', botUsername);
22
- connectUrl.searchParams.append('startApp', window.Telegram.WebApp.initDataUnsafe?.start_param || '');
22
+ connectUrl.searchParams.append('startApp', telegramAppUrl?.start_param || '');
23
23
 
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
- });
24
+ // Open link using Telegram Mini App API
25
+ window.Telegram.WebApp.openLink(connectUrl.toString());
41
26
  } catch (error) {
42
27
  console.error('Telegram auth flow failed:', error);
43
28
  }
44
29
  };
30
+
31
+ // Event listener for when the Mini App is closed
32
+ window.Telegram.WebApp.onEvent('viewportChanged', () => {
33
+ const startParam = window.Telegram.WebApp.initDataUnsafe?.start_param;
34
+ if (startParam) {
35
+ try {
36
+ const authData = JSON.parse(decodeURIComponent(startParam));
37
+ if (authData.sub && authData.token) {
38
+ onLoginSuccess(authData);
39
+ }
40
+ } catch (error) {
41
+ console.error('Error processing auth data:', error);
42
+ }
43
+ }
44
+ });
45
45
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
46
46
  className: "flex flex-col items-center",
47
47
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
48
48
  onClick: handleTelegramAuth,
49
49
  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
50
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
51
- src: "https://imagepng.org/google-icone-icon/google-icon/" // Replace with actual Othent icon
52
- ,
51
+ src: "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png",
53
52
  alt: "Google",
54
53
  className: "w-5 h-5 mr-2"
55
54
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {