onairos 0.1.243 → 0.1.246

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.
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = SecuritySetup;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _framerMotion = require("framer-motion");
9
+ var _jsxRuntime = require("react/jsx-runtime");
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; }
12
+ function SecuritySetup(_ref) {
13
+ let {
14
+ onComplete
15
+ } = _ref;
16
+ const [pin, setPin] = (0, _react.useState)('');
17
+ const [securityMethod, setSecurityMethod] = (0, _react.useState)(null);
18
+ const [pinRequirements, setPinRequirements] = (0, _react.useState)({
19
+ length: false,
20
+ capital: false,
21
+ number: false,
22
+ symbol: false
23
+ });
24
+ (0, _react.useEffect)(() => {
25
+ // Check PIN requirements
26
+ setPinRequirements({
27
+ length: pin.length >= 8,
28
+ capital: /[A-Z]/.test(pin),
29
+ number: /[0-9]/.test(pin),
30
+ symbol: /[!@#$%^&*(),.?":{}|<>]/.test(pin)
31
+ });
32
+ }, [pin]);
33
+ const allRequirementsMet = Object.values(pinRequirements).every(req => req);
34
+ const handlePinSubmit = async () => {
35
+ if (allRequirementsMet) {
36
+ // Here you would typically hash the PIN and store it
37
+ onComplete({
38
+ method: 'pin',
39
+ value: pin
40
+ });
41
+ }
42
+ };
43
+ const handleOthentSetup = () => {
44
+ onComplete({
45
+ method: 'othent'
46
+ });
47
+ };
48
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_framerMotion.motion.div, {
49
+ initial: {
50
+ opacity: 0,
51
+ y: 20
52
+ },
53
+ animate: {
54
+ opacity: 1,
55
+ y: 0
56
+ },
57
+ className: "flex flex-col items-center space-y-6 p-6",
58
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
59
+ className: "text-xl font-semibold text-gray-900",
60
+ children: "Secure Your Account"
61
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
62
+ className: "text-gray-600 text-center",
63
+ children: "Choose how you want to secure your data"
64
+ }), !securityMethod ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
65
+ className: "grid grid-cols-1 gap-4 w-full max-w-md",
66
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_framerMotion.motion.button, {
67
+ whileHover: {
68
+ scale: 1.02
69
+ },
70
+ whileTap: {
71
+ scale: 0.98
72
+ },
73
+ onClick: () => setSecurityMethod('othent'),
74
+ className: "flex items-center justify-center p-6 rounded-lg border border-gray-300 hover:border-blue-500 bg-white",
75
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
76
+ src: "https://onairos.sirv.com/Images/othent-icon.png",
77
+ alt: "Othent",
78
+ className: "w-8 h-8 mr-3"
79
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
80
+ className: "text-gray-700",
81
+ children: "Secure with Google (Othent)"
82
+ })]
83
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_framerMotion.motion.button, {
84
+ whileHover: {
85
+ scale: 1.02
86
+ },
87
+ whileTap: {
88
+ scale: 0.98
89
+ },
90
+ onClick: () => setSecurityMethod('pin'),
91
+ className: "flex items-center justify-center p-6 rounded-lg border border-gray-300 hover:border-blue-500 bg-white",
92
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
93
+ className: "material-icons mr-3",
94
+ children: "lock"
95
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
96
+ className: "text-gray-700",
97
+ children: "Set up PIN"
98
+ })]
99
+ })]
100
+ }) : securityMethod === 'pin' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_framerMotion.motion.div, {
101
+ initial: {
102
+ opacity: 0
103
+ },
104
+ animate: {
105
+ opacity: 1
106
+ },
107
+ className: "w-full max-w-md space-y-4",
108
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
109
+ type: "password",
110
+ value: pin,
111
+ onChange: e => setPin(e.target.value),
112
+ placeholder: "Enter your PIN",
113
+ className: "w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
114
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
115
+ className: "space-y-2",
116
+ children: Object.entries(pinRequirements).map(_ref2 => {
117
+ let [req, met] = _ref2;
118
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
119
+ className: "flex items-center",
120
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
121
+ className: `material-icons text-sm ${met ? 'text-green-500' : 'text-gray-400'}`,
122
+ children: met ? 'check_circle' : 'radio_button_unchecked'
123
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
124
+ className: `ml-2 text-sm ${met ? 'text-green-600' : 'text-gray-600'}`,
125
+ children: req === 'length' ? 'At least 8 characters' : req === 'capital' ? 'One capital letter' : req === 'number' ? 'One number' : 'One special character'
126
+ })]
127
+ }, req);
128
+ })
129
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
130
+ onClick: handlePinSubmit,
131
+ disabled: !allRequirementsMet,
132
+ className: `w-full py-3 px-4 rounded-lg font-semibold ${allRequirementsMet ? 'bg-blue-500 text-white hover:bg-blue-600' : 'bg-gray-300 text-gray-500 cursor-not-allowed'}`,
133
+ children: "Set PIN"
134
+ })]
135
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_framerMotion.motion.div, {
136
+ initial: {
137
+ opacity: 0
138
+ },
139
+ animate: {
140
+ opacity: 1
141
+ },
142
+ className: "w-full max-w-md",
143
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
144
+ onClick: handleOthentSetup,
145
+ className: "w-full py-3 px-4 rounded-lg font-semibold bg-blue-500 text-white hover:bg-blue-600",
146
+ children: "Continue with Othent"
147
+ })
148
+ })]
149
+ });
150
+ }
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = SignUp;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _google = require("@react-oauth/google");
10
+ var _AuthButtons = _interopRequireDefault(require("./AuthButtons"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ 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); }
13
+ 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; }
14
+ function SignUp(_ref) {
15
+ let {
16
+ onSignUpSuccess,
17
+ setOthent,
18
+ setHashedOthentSub,
19
+ setEncryptedPin
20
+ } = _ref;
21
+ const [formData, setFormData] = (0, _react.useState)({
22
+ email: '',
23
+ username: '',
24
+ password: '',
25
+ confirmPassword: ''
26
+ });
27
+ const [error, setError] = (0, _react.useState)(null);
28
+ const handleInputChange = e => {
29
+ setFormData({
30
+ ...formData,
31
+ [e.target.name]: e.target.value
32
+ });
33
+ };
34
+ const handleSubmit = async e => {
35
+ e.preventDefault();
36
+ if (formData.password !== formData.confirmPassword) {
37
+ setError("Passwords don't match");
38
+ return;
39
+ }
40
+ try {
41
+ const response = await fetch('https://api2.onairos.uk/signup', {
42
+ method: 'POST',
43
+ headers: {
44
+ 'Content-Type': 'application/json'
45
+ },
46
+ body: JSON.stringify({
47
+ email: formData.email,
48
+ username: formData.username,
49
+ password: formData.password
50
+ })
51
+ });
52
+ const data = await response.json();
53
+ if (response.ok) {
54
+ localStorage.setItem('onairosToken', data.token);
55
+ localStorage.setItem('username', formData.username);
56
+ onSignUpSuccess(formData.username);
57
+ } else {
58
+ setError(data.message || 'Sign up failed');
59
+ }
60
+ } catch (error) {
61
+ setError('Sign up failed. Please try again.');
62
+ }
63
+ };
64
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
65
+ className: "flex flex-col items-center justify-start max-w-sm mx-auto space-y-6 pt-4",
66
+ children: [error && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
67
+ className: "w-full bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg",
68
+ children: error
69
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AuthButtons.default, {
70
+ onLoginSuccess: onSignUpSuccess,
71
+ setOthent: setOthent,
72
+ setHashedOthentSub: setHashedOthentSub,
73
+ setEncryptedPin: setEncryptedPin
74
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
75
+ className: "w-full flex items-center justify-center space-x-4",
76
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("hr", {
77
+ className: "flex-grow border-gray-300"
78
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
79
+ className: "text-gray-500",
80
+ children: "or"
81
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("hr", {
82
+ className: "flex-grow border-gray-300"
83
+ })]
84
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
85
+ onSubmit: handleSubmit,
86
+ className: "w-full space-y-4",
87
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
88
+ type: "email",
89
+ name: "email",
90
+ value: formData.email,
91
+ onChange: handleInputChange,
92
+ placeholder: "Email",
93
+ className: "w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",
94
+ required: true
95
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
96
+ type: "text",
97
+ name: "username",
98
+ value: formData.username,
99
+ onChange: handleInputChange,
100
+ placeholder: "Username",
101
+ className: "w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",
102
+ required: true
103
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
104
+ type: "password",
105
+ name: "password",
106
+ value: formData.password,
107
+ onChange: handleInputChange,
108
+ placeholder: "Password",
109
+ className: "w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",
110
+ required: true
111
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
112
+ type: "password",
113
+ name: "confirmPassword",
114
+ value: formData.confirmPassword,
115
+ onChange: handleInputChange,
116
+ placeholder: "Confirm Password",
117
+ className: "w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",
118
+ required: true
119
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
120
+ type: "submit",
121
+ className: "w-full bg-blue-500 text-white font-semibold py-3 px-4 rounded-lg hover:bg-blue-600 transition-colors",
122
+ children: "Sign Up"
123
+ })]
124
+ })]
125
+ });
126
+ }
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = UniversalOnboarding;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _framerMotion = require("framer-motion");
9
+ var _jsxRuntime = require("react/jsx-runtime");
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; }
12
+ const socialPlatforms = [{
13
+ name: 'YouTube',
14
+ icon: 'https://onairos.sirv.com/Images/youtube-icon.png',
15
+ connected: false
16
+ }, {
17
+ name: 'Reddit',
18
+ icon: 'https://onairos.sirv.com/Images/reddit-icon.png',
19
+ connected: false
20
+ }, {
21
+ name: 'Instagram',
22
+ icon: 'https://onairos.sirv.com/Images/instagram-icon.png',
23
+ connected: false
24
+ }, {
25
+ name: 'Pinterest',
26
+ icon: 'https://onairos.sirv.com/Images/pinterest-icon.png',
27
+ connected: false
28
+ }];
29
+ function UniversalOnboarding(_ref) {
30
+ let {
31
+ onComplete
32
+ } = _ref;
33
+ const [platforms, setPlatforms] = (0, _react.useState)(socialPlatforms);
34
+ const [isUnifying, setIsUnifying] = (0, _react.useState)(false);
35
+ const [unifyProgress, setUnifyProgress] = (0, _react.useState)(0);
36
+ (0, _react.useEffect)(() => {
37
+ if (isUnifying) {
38
+ const interval = setInterval(() => {
39
+ setUnifyProgress(prev => {
40
+ if (prev >= 100) {
41
+ clearInterval(interval);
42
+ setIsUnifying(false);
43
+ onComplete();
44
+ return 100;
45
+ }
46
+ return prev + 2;
47
+ });
48
+ }, 100);
49
+ return () => clearInterval(interval);
50
+ }
51
+ }, [isUnifying, onComplete]);
52
+ const handleConnect = async platformName => {
53
+ // Implement OAuth flow for each platform
54
+ try {
55
+ const response = await fetch(`https://api2.onairos.uk/connect/${platformName.toLowerCase()}`, {
56
+ method: 'POST',
57
+ headers: {
58
+ 'Authorization': `Bearer ${localStorage.getItem('onairosToken')}`,
59
+ 'Content-Type': 'application/json'
60
+ }
61
+ });
62
+ if (response.ok) {
63
+ setPlatforms(platforms.map(p => p.name === platformName ? {
64
+ ...p,
65
+ connected: true
66
+ } : p));
67
+ }
68
+ } catch (error) {
69
+ console.error(`Failed to connect to ${platformName}:`, error);
70
+ }
71
+ };
72
+ const handleUnify = async () => {
73
+ if (platforms.some(p => p.connected)) {
74
+ setIsUnifying(true);
75
+ try {
76
+ const response = await fetch('https://api2.onairos.uk/unify', {
77
+ method: 'POST',
78
+ headers: {
79
+ 'Authorization': `Bearer ${localStorage.getItem('onairosToken')}`,
80
+ 'Content-Type': 'application/json'
81
+ }
82
+ });
83
+ if (response.ok) {
84
+ onComplete();
85
+ }
86
+ } catch (error) {
87
+ console.error('Failed to unify data:', error);
88
+ }
89
+ }
90
+ };
91
+ if (isUnifying) {
92
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_framerMotion.motion.div, {
93
+ initial: {
94
+ opacity: 0
95
+ },
96
+ animate: {
97
+ opacity: 1
98
+ },
99
+ className: "flex flex-col items-center justify-center space-y-6 p-6",
100
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
101
+ className: "text-xl font-semibold text-gray-900",
102
+ children: "Unifying Your Data"
103
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
104
+ className: "text-gray-600 text-center",
105
+ children: "Please wait while we process your information"
106
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
107
+ className: "w-full max-w-md",
108
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
109
+ className: "relative pt-1",
110
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
111
+ className: "flex mb-2 items-center justify-between",
112
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
113
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
114
+ className: "text-xs font-semibold inline-block py-1 px-2 uppercase rounded-full text-blue-600 bg-blue-200",
115
+ children: "Progress"
116
+ })
117
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
118
+ className: "text-right",
119
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
120
+ className: "text-xs font-semibold inline-block text-blue-600",
121
+ children: [unifyProgress, "%"]
122
+ })
123
+ })]
124
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_framerMotion.motion.div, {
125
+ className: "overflow-hidden h-2 mb-4 text-xs flex rounded bg-blue-200",
126
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_framerMotion.motion.div, {
127
+ initial: {
128
+ width: 0
129
+ },
130
+ animate: {
131
+ width: `${unifyProgress}%`
132
+ },
133
+ transition: {
134
+ duration: 0.5
135
+ },
136
+ className: "shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500"
137
+ })
138
+ })]
139
+ })
140
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_framerMotion.motion.div, {
141
+ animate: {
142
+ rotate: 360
143
+ },
144
+ transition: {
145
+ duration: 2,
146
+ repeat: Infinity,
147
+ ease: "linear"
148
+ },
149
+ className: "w-12 h-12",
150
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
151
+ className: "w-full h-full text-blue-500",
152
+ viewBox: "0 0 24 24",
153
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
154
+ fill: "currentColor",
155
+ d: "M12,4V2A10,10 0 0,0 2,12H4A8,8 0 0,1 12,4Z"
156
+ })
157
+ })
158
+ })]
159
+ });
160
+ }
161
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
162
+ className: "flex flex-col items-center space-y-6 p-6",
163
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
164
+ className: "text-xl font-semibold text-gray-900",
165
+ children: "Connect Your Accounts"
166
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
167
+ className: "text-gray-600 text-center",
168
+ children: "Connect at least one account to create your personality model"
169
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
170
+ className: "grid grid-cols-2 gap-4 w-full max-w-md",
171
+ children: platforms.map(platform => /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
172
+ onClick: () => handleConnect(platform.name),
173
+ className: `flex items-center justify-center p-4 rounded-lg border ${platform.connected ? 'bg-green-50 border-green-500' : 'border-gray-300 hover:border-blue-500'}`,
174
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
175
+ src: platform.icon,
176
+ alt: platform.name,
177
+ className: "w-8 h-8 mr-2"
178
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
179
+ className: platform.connected ? 'text-green-600' : 'text-gray-700',
180
+ children: platform.connected ? 'Connected' : `Connect ${platform.name}`
181
+ })]
182
+ }, platform.name))
183
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
184
+ onClick: handleUnify,
185
+ disabled: !platforms.some(p => p.connected),
186
+ className: `w-full max-w-md py-3 px-4 rounded-lg font-semibold ${platforms.some(p => p.connected) ? 'bg-blue-500 text-white hover:bg-blue-600' : 'bg-gray-300 text-gray-500 cursor-not-allowed'}`,
187
+ children: "Unify and Create Model"
188
+ })]
189
+ });
190
+ }