onairos 0.1.3 → 0.1.4
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/onairos.js +26 -7
- package/package.json +2 -2
- package/src/onairos.jsx +1 -71
package/dist/onairos.js
CHANGED
|
@@ -4,17 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _OnairosBlack = _interopRequireDefault(require("./OnairosBlack.png"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
12
|
function Onairos(_ref) {
|
|
11
13
|
let {
|
|
12
14
|
requestData,
|
|
13
|
-
onairosID,
|
|
14
|
-
access_token,
|
|
15
15
|
proofMode = false,
|
|
16
16
|
webpageName
|
|
17
17
|
} = _ref;
|
|
18
|
+
const [token, setToken] = (0, _react.useState)();
|
|
18
19
|
const OnairosAnime = async () => {
|
|
19
20
|
try {
|
|
20
21
|
console.log("Clicked Onairos Connect");
|
|
@@ -24,18 +25,36 @@ function Onairos(_ref) {
|
|
|
24
25
|
console.error("Error connecting to Onairos", error);
|
|
25
26
|
}
|
|
26
27
|
};
|
|
28
|
+
const requestToken = async () => {
|
|
29
|
+
const domain = window.location.hostname;
|
|
30
|
+
const response = await fetch('https://api2.onairos.uk/dev/request-token', {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/json'
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
domain
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
throw new Error('Token request failed: ' + response.statusText);
|
|
41
|
+
}
|
|
42
|
+
const data = await response.json();
|
|
43
|
+
setToken(data.token);
|
|
44
|
+
// this.token = data.token; // Store the token
|
|
45
|
+
};
|
|
46
|
+
|
|
27
47
|
const ConnectOnairos = async () => {
|
|
28
48
|
// Title here has to match a model in the Users : accountInfo.AccountInfo.models
|
|
29
49
|
// Prepare the data to be sent
|
|
30
50
|
// Send the data to the content script
|
|
51
|
+
|
|
52
|
+
await requestToken();
|
|
31
53
|
window.postMessage({
|
|
32
54
|
source: 'webpage',
|
|
33
55
|
type: 'GET_API_URL',
|
|
34
56
|
webpageName: webpageName,
|
|
35
|
-
|
|
36
|
-
access_token: access_token,
|
|
37
|
-
account: "ConnectedAccountRef.current",
|
|
38
|
-
//No Longer needed, REMOVE
|
|
57
|
+
access_token: token,
|
|
39
58
|
requestData: requestData,
|
|
40
59
|
proofMode: proofMode
|
|
41
60
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onairos",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@testing-library/jest-dom": "^5.17.0",
|
|
6
6
|
"@testing-library/react": "^13.4.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"main": "dist/onairos.js",
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
51
|
-
"url": "git+https://github.com/zd819/
|
|
51
|
+
"url": "git+https://github.com/zd819/onairos-npm"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"Onairos",
|
package/src/onairos.jsx
CHANGED
|
@@ -30,7 +30,7 @@ function Onairos( {requestData, proofMode=false,webpageName}) {
|
|
|
30
30
|
const data = await response.json();
|
|
31
31
|
setToken(data.token);
|
|
32
32
|
// this.token = data.token; // Store the token
|
|
33
|
-
}
|
|
33
|
+
}
|
|
34
34
|
|
|
35
35
|
const ConnectOnairos = async () => {
|
|
36
36
|
// Title here has to match a model in the Users : accountInfo.AccountInfo.models
|
|
@@ -43,9 +43,7 @@ function Onairos( {requestData, proofMode=false,webpageName}) {
|
|
|
43
43
|
source: 'webpage',
|
|
44
44
|
type: 'GET_API_URL',
|
|
45
45
|
webpageName: webpageName,
|
|
46
|
-
onairosID:'onairosID', // Remove
|
|
47
46
|
access_token:token,
|
|
48
|
-
account:"ConnectedAccountRef.current", //No Longer needed, REMOVE
|
|
49
47
|
requestData: requestData,
|
|
50
48
|
proofMode:proofMode
|
|
51
49
|
});
|
|
@@ -66,71 +64,3 @@ function Onairos( {requestData, proofMode=false,webpageName}) {
|
|
|
66
64
|
|
|
67
65
|
export default Onairos;
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
// import React from 'react';
|
|
71
|
-
// import onairosLogo from "./OnairosBlack.png";
|
|
72
|
-
|
|
73
|
-
// class Onairos {
|
|
74
|
-
// constructor({ requestData, onairosID, proofMode = false, webpageName }) {
|
|
75
|
-
// const OnairosAnime = async () => {
|
|
76
|
-
// try {
|
|
77
|
-
// console.log("Clicked Onairos Connect");
|
|
78
|
-
// await ConnectOnairos();
|
|
79
|
-
// } catch (error) {
|
|
80
|
-
// // Handle any errors here
|
|
81
|
-
// console.error("Error connecting to Onairos", error);
|
|
82
|
-
// }
|
|
83
|
-
// };
|
|
84
|
-
|
|
85
|
-
// const requestToken = async () => {
|
|
86
|
-
// const domain = window.location.hostname;
|
|
87
|
-
// // const response = await fetch('https://api2.onairos.uk/request-token', {
|
|
88
|
-
// const response = await fetch('http://localhost:8000/request-token', {
|
|
89
|
-
// method: 'POST',
|
|
90
|
-
// headers: {
|
|
91
|
-
// 'Content-Type': 'application/json',
|
|
92
|
-
// },
|
|
93
|
-
// body: JSON.stringify({ domain }),
|
|
94
|
-
// });
|
|
95
|
-
|
|
96
|
-
// if (!response.ok) {
|
|
97
|
-
// throw new Error('Token request failed: ' + response.statusText);
|
|
98
|
-
// }
|
|
99
|
-
|
|
100
|
-
// const data = await response.json();
|
|
101
|
-
// this.token = data.token; // Store the token
|
|
102
|
-
// };
|
|
103
|
-
|
|
104
|
-
// const ConnectOnairos = async () => {
|
|
105
|
-
// // Title here has to match a model in the Users : accountInfo.AccountInfo.models
|
|
106
|
-
// // Prepare the data to be sent
|
|
107
|
-
// // Send the data to the content script
|
|
108
|
-
// await requestToken();
|
|
109
|
-
|
|
110
|
-
// window.postMessage({
|
|
111
|
-
// source: 'webpage',
|
|
112
|
-
// type: 'GET_API_URL',
|
|
113
|
-
// webpageName: webpageName,
|
|
114
|
-
// onairosID: onairosID,
|
|
115
|
-
// access_token: "access_token",
|
|
116
|
-
// account: "ConnectedAccountRef.current",
|
|
117
|
-
// requestData: requestData,
|
|
118
|
-
// proofMode: proofMode
|
|
119
|
-
// });
|
|
120
|
-
// };
|
|
121
|
-
|
|
122
|
-
// return (
|
|
123
|
-
// <div>
|
|
124
|
-
// <button
|
|
125
|
-
// className="OnairosConnect w-20 h-20 flex flex-col items-center justify-center text-white font-bold py-2 px-4 rounded cursor-pointer"
|
|
126
|
-
// onClick={OnairosAnime}
|
|
127
|
-
// >
|
|
128
|
-
// <img src={onairosLogo} alt="Onairos Logo" className="w-16 h-16 object-contain mb-2" /> {/* Adjust size as needed */}
|
|
129
|
-
// <span className="whitespace-nowrap">Connect to Onairos</span> {/* Prevent text from wrapping */}
|
|
130
|
-
// </button>
|
|
131
|
-
// </div>
|
|
132
|
-
// );
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
|
|
136
|
-
// export default Onairos;
|