onairos 0.1.334 → 0.1.336
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/AuthButtons.js +1 -2
- package/dist/components/GoogleButton.js +41 -30
- package/dist/onairos.bundle.js +1 -1
- package/dist/onairos.bundle.js.map +1 -1
- package/dist/onairos.js +24 -0
- package/package.json +1 -1
- package/src/components/AuthButtons.jsx +2 -1
- package/src/components/GoogleButton.js +51 -0
- package/src/onairos.jsx +25 -0
|
@@ -38,8 +38,7 @@ function AuthButtons(_ref) {
|
|
|
38
38
|
};
|
|
39
39
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
40
40
|
className: "flex flex-row justify-center items-center space-x-4",
|
|
41
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
42
|
-
onSuccess: handleOthentSuccess,
|
|
41
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(GoogleButton, {
|
|
43
42
|
onLoginSuccess: othentLogin
|
|
44
43
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_OnairosAppButton.default, {
|
|
45
44
|
hasSavedCredentials: hasSavedCredentials,
|
|
@@ -4,46 +4,57 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = GoogleButton;
|
|
7
|
-
var _google = require("@react-oauth/google");
|
|
8
|
-
var _jwtDecode = require("jwt-decode");
|
|
9
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
8
|
function GoogleButton(_ref) {
|
|
11
9
|
let {
|
|
12
10
|
onLoginSuccess
|
|
13
11
|
} = _ref;
|
|
14
|
-
const
|
|
12
|
+
const handleTelegramAuth = async () => {
|
|
15
13
|
try {
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
// Get Telegram Mini App data
|
|
15
|
+
const telegramAppUrl = window.Telegram.WebApp.initData;
|
|
16
|
+
const botUsername = 'OnairosMiniApp';
|
|
17
|
+
|
|
18
|
+
// Construct URL to your Othent connect page
|
|
19
|
+
const connectUrl = new URL('https://onairos.uk/othent-connect');
|
|
20
|
+
connectUrl.searchParams.append('tgAppUrl', telegramAppUrl);
|
|
21
|
+
connectUrl.searchParams.append('botUsername', botUsername);
|
|
22
|
+
connectUrl.searchParams.append('startApp', window.Telegram.WebApp.initDataUnsafe?.start_param || '');
|
|
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
|
+
}
|
|
26
40
|
});
|
|
27
|
-
if (!response.ok) {
|
|
28
|
-
throw new Error('Google authentication failed');
|
|
29
|
-
}
|
|
30
|
-
const data = await response.json();
|
|
31
|
-
localStorage.setItem('onairosToken', data.token);
|
|
32
|
-
await onLoginSuccess(decoded.email);
|
|
33
41
|
} catch (error) {
|
|
34
|
-
console.error('
|
|
42
|
+
console.error('Telegram auth flow failed:', error);
|
|
35
43
|
}
|
|
36
44
|
};
|
|
37
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
38
46
|
className: "flex flex-col items-center",
|
|
39
|
-
children:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
|
48
|
+
onClick: handleTelegramAuth,
|
|
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
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
51
|
+
src: "https://imagepng.org/google-icone-icon/google-icon/" // Replace with actual Othent icon
|
|
52
|
+
,
|
|
53
|
+
alt: "Google",
|
|
54
|
+
className: "w-5 h-5 mr-2"
|
|
55
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
56
|
+
children: "Continue with Google"
|
|
57
|
+
})]
|
|
58
|
+
})
|
|
48
59
|
});
|
|
49
60
|
}
|