onairos 2.3.0 → 2.3.1

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.
Files changed (3) hide show
  1. package/llm.txt +78 -7
  2. package/package.json +3 -1
  3. package/webpack.config.js +196 -196
package/llm.txt CHANGED
@@ -13,6 +13,7 @@
13
13
  4. **API Integration**: Supports both test/live modes with automatic endpoint switching
14
14
  5. **PIN-based Encryption**: All models encrypted with user PIN + server key
15
15
  6. **Responsive Design**: Tailwind CSS with mobile-first approach
16
+ 7. **API Key Initialization**: Developer API key setup for authentication and environment configuration
16
17
 
17
18
  ## Mobile Browser Compatibility ✅
18
19
  **WORKS PERFECTLY**: React components, API calls, touch interactions, responsive design, state management
@@ -42,7 +43,7 @@
42
43
  - **Training Routes**: `api2.onairos.uk/mobile-training/clean` (regular) or `/enoch` (advanced)
43
44
 
44
45
  ## Data Flow
45
- 1. **Email Authentication** → 2. **OAuth Connections** → 3. **PIN Setup** → 4. **Data Request**
46
+ 1. **API Key Initialization** → 2. **Email Authentication** → 3. **OAuth Connections** → 4. **PIN Setup** → 5. **Data Request**
46
47
 
47
48
  **Backend Format**:
48
49
  ```json
@@ -57,7 +58,27 @@
57
58
  }
58
59
  ```
59
60
 
61
+ ## API Key Setup ✅
62
+ **CRITICAL**: Must initialize API key before using any Onairos components
63
+
64
+ ```javascript
65
+ import { initializeApiKey } from '@onairos/react-native';
66
+
67
+ // Initialize with developer key
68
+ await initializeApiKey({
69
+ apiKey: 'dev_your_32_char_key_here',
70
+ environment: 'production', // or 'development'
71
+ enableLogging: true
72
+ });
73
+ ```
74
+
75
+ **Configuration Options**:
76
+ - `apiKey`: Your 32-character developer key (format: `dev_your_32_char_key_here`)
77
+ - `environment`: `'production'` or `'development'` mode
78
+ - `enableLogging`: Boolean for debug logging
79
+
60
80
  ## Key Components
81
+ - **initializeApiKey**: API key setup function (must be called first)
61
82
  - **OnairosButton**: Main entry point with props (testMode, autoFetch, requestData)
62
83
  - **UniversalOnboarding**: OAuth connector management with mobile detection
63
84
  - **DataRequest**: Data type selection with visual checkmarks
@@ -81,8 +102,25 @@
81
102
  ✅ Enhanced OAuth URL parsing for all 9 platforms
82
103
  ✅ Added mobile browser compatibility documentation
83
104
  ✅ Fixed OAuth popup blocking on mobile devices
105
+ ✅ Added API key initialization system for developer authentication
106
+ ✅ Implemented environment-specific configuration (production/development)
107
+ ✅ Added comprehensive logging system for debugging
108
+ ✅ Fixed TypeScript declaration file resolution issue in package.json exports
84
109
 
85
110
  ## Usage Pattern
111
+ **Step 1: Initialize API Key (Required)**
112
+ ```javascript
113
+ import { initializeApiKey } from '@onairos/react-native';
114
+
115
+ // Must be called before using any components
116
+ await initializeApiKey({
117
+ apiKey: 'dev_your_32_char_key_here',
118
+ environment: 'production',
119
+ enableLogging: true
120
+ });
121
+ ```
122
+
123
+ **Step 2: Use Onairos Components**
86
124
  ```javascript
87
125
  import { OnairosButton } from 'onairos';
88
126
 
@@ -100,14 +138,47 @@ import { OnairosButton } from 'onairos';
100
138
  ```
101
139
 
102
140
  ## Critical Success Factors
103
- 1. **Cross-Platform**: Same React code works in desktop browsers, mobile browsers, and React Native
104
- 2. **OAuth Reliability**: Auto-detects environment and uses appropriate OAuth flow
105
- 3. **API Consistency**: All endpoints use `api2.onairos.uk` with proper authentication
106
- 4. **Mobile UX**: Touch-friendly UI with proper viewport handling
107
- 5. **Error Handling**: Comprehensive error states and user guidance
141
+ 1. **API Key Setup**: Must call `initializeApiKey()` before using any components
142
+ 2. **Cross-Platform**: Same React code works in desktop browsers, mobile browsers, and React Native
143
+ 3. **OAuth Reliability**: Auto-detects environment and uses appropriate OAuth flow
144
+ 4. **API Consistency**: All endpoints use `api2.onairos.uk` with proper authentication
145
+ 5. **Mobile UX**: Touch-friendly UI with proper viewport handling
146
+ 6. **Error Handling**: Comprehensive error states and user guidance
147
+
148
+ ## TypeScript Support ✅
149
+ **Full TypeScript Support**: Complete type definitions provided in `onairos.d.ts`
150
+
151
+ **Usage with TypeScript**:
152
+ ```typescript
153
+ import { OnairosButton } from 'onairos';
154
+ import type { OnairosProps } from 'onairos';
155
+
156
+ // Component usage with full type safety
157
+ const MyComponent: React.FC = () => {
158
+ return (
159
+ <OnairosButton
160
+ requestData={{
161
+ basic: { type: "basic", reward: "10 tokens" },
162
+ personality: { type: "personality", reward: "25 tokens" },
163
+ preferences: { type: "preferences", reward: "15 tokens" }
164
+ }}
165
+ webpageName="MyApp"
166
+ testMode={false}
167
+ autoFetch={true}
168
+ onComplete={(result) => console.log(result)}
169
+ />
170
+ );
171
+ };
172
+ ```
173
+
174
+ **Common TypeScript Issues & Solutions**:
175
+ - **"Could not find declaration file"**: Fixed in v2.1.5 by adding `types` field to package.json exports
176
+ - **Import errors**: Always import from `'onairos'` (not specific paths)
177
+ - **Type inference**: All components have full TypeScript support with IntelliSense
108
178
 
109
179
  ## Build & Development
110
180
  - **Build**: `npm run build` (creates dist/ folder)
111
181
  - **Test Files**: Multiple test HTML files for different scenarios
112
182
  - **Entry Points**: `src/index.js` (main), `src/onairos.native.jsx` (React Native)
113
- - **Responsive**: Tailwind CSS with `sm:`, `md:`, `lg:` breakpoints throughout
183
+ - **Responsive**: Tailwind CSS with `sm:`, `md:`, `lg:` breakpoints throughout
184
+ - **TypeScript**: Full type definitions with proper package.json exports configuration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onairos",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "dependencies": {
5
5
  "@react-oauth/google": "^0.12.1",
6
6
  "@telegram-apps/sdk-react": "^2.0.25",
@@ -108,11 +108,13 @@
108
108
  "laravel": "dist/onairos.laravel.js",
109
109
  "exports": {
110
110
  ".": {
111
+ "types": "./onairos.d.ts",
111
112
  "import": "./dist/onairos.esm.js",
112
113
  "require": "./dist/onairos.bundle.js",
113
114
  "browser": "./dist/onairos.bundle.js"
114
115
  },
115
116
  "./laravel": {
117
+ "types": "./onairos.d.ts",
116
118
  "import": "./dist/onairos.laravel.js",
117
119
  "require": "./dist/onairos.laravel.js"
118
120
  },
package/webpack.config.js CHANGED
@@ -1,197 +1,197 @@
1
- const path = require('path');
2
- const TerserPlugin = require('terser-webpack-plugin');
3
- const HtmlWebpackPlugin = require('html-webpack-plugin');
4
- const CopyWebpackPlugin = require('copy-webpack-plugin');
5
-
6
- const baseConfig = {
7
- externals: {
8
- react: {
9
- commonjs: 'react',
10
- commonjs2: 'react',
11
- amd: 'React',
12
- root: 'React'
13
- },
14
- 'react-dom': {
15
- commonjs: 'react-dom',
16
- commonjs2: 'react-dom',
17
- amd: 'ReactDOM',
18
- root: 'ReactDOM'
19
- },
20
- 'ajv': 'ajv',
21
- 'ajv/dist/runtime/validation_error': 'ajv/dist/runtime/validation_error',
22
- 'ajv/dist/runtime/equal': 'ajv/dist/runtime/equal',
23
- 'ajv/dist/runtime/ucs2length': 'ajv/dist/runtime/ucs2length',
24
- 'ajv/dist/runtime/uri': 'ajv/dist/runtime/uri',
25
- '@anthropic-ai/sdk': '@anthropic-ai/sdk',
26
- '@google/generative-ai': '@google/generative-ai',
27
- '@pinecone-database/pinecone': '@pinecone-database/pinecone',
28
- 'openai': 'openai'
29
- },
30
- optimization: {
31
- minimize: true,
32
- minimizer: [
33
- new TerserPlugin({
34
- terserOptions: {
35
- compress: {
36
- dead_code: true,
37
- },
38
- mangle: true,
39
- output: {
40
- comments: false,
41
- },
42
- },
43
- extractComments: false,
44
- }),
45
- ],
46
- },
47
- devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
48
- module: {
49
- rules: [
50
- {
51
- test: /\.jsx?$/,
52
- exclude: /node_modules/,
53
- use: {
54
- loader: 'babel-loader',
55
- options: {
56
- presets: ['@babel/preset-env', '@babel/preset-react']
57
- }
58
- }
59
- },
60
- {
61
- test: /\.(png|jpg|gif|svg)$/i,
62
- type: 'asset/resource',
63
- generator: {
64
- filename: 'static/[hash][ext][query]'
65
- }
66
- }
67
- ]
68
- },
69
- resolve: {
70
- extensions: ['.js', '.jsx', '.mjs'],
71
- alias: {
72
- '@': path.resolve(__dirname, 'src'),
73
- },
74
- fallback: {
75
- "crypto": require.resolve("crypto-browserify"),
76
- "stream": require.resolve("stream-browserify"),
77
- "assert": require.resolve("assert"),
78
- "http": require.resolve("stream-http"),
79
- "https": require.resolve("https-browserify"),
80
- "os": require.resolve("os-browserify/browser"),
81
- "url": require.resolve("url"),
82
- "zlib": require.resolve("browserify-zlib"),
83
- "path": require.resolve("path-browserify"),
84
- "vm": require.resolve("vm-browserify"),
85
- "fs": false,
86
- "net": false,
87
- "tls": false,
88
- "child_process": false
89
- }
90
- }
91
- };
92
-
93
- // ES Module specific externals configuration
94
- const esmExternals = {
95
- react: 'react',
96
- 'react-dom': 'react-dom',
97
- 'ajv': 'ajv',
98
- 'ajv/dist/runtime/validation_error': 'ajv/dist/runtime/validation_error',
99
- 'ajv/dist/runtime/equal': 'ajv/dist/runtime/equal',
100
- 'ajv/dist/runtime/ucs2length': 'ajv/dist/runtime/ucs2length',
101
- 'ajv/dist/runtime/uri': 'ajv/dist/runtime/uri',
102
- '@anthropic-ai/sdk': '@anthropic-ai/sdk',
103
- '@google/generative-ai': '@google/generative-ai',
104
- '@pinecone-database/pinecone': '@pinecone-database/pinecone',
105
- 'openai': 'openai'
106
- };
107
-
108
- module.exports = [
109
- // UMD build for browsers
110
- {
111
- ...baseConfig,
112
- entry: {
113
- onairos: path.resolve(__dirname, 'src', 'onairos.jsx'),
114
- iframe: path.resolve(__dirname, 'src', 'iframe', 'data_request_page.js')
115
- },
116
- output: {
117
- path: path.resolve(__dirname, 'dist'),
118
- filename: (pathData) => {
119
- return pathData.chunk.name === 'onairos' ? 'onairos.bundle.js' : '[name].bundle.js';
120
- },
121
- libraryTarget: 'umd',
122
- library: 'Onairos',
123
- globalObject: 'this',
124
- umdNamedDefine: true,
125
- publicPath: 'auto',
126
- },
127
- plugins: [
128
- new HtmlWebpackPlugin({
129
- template: path.resolve(__dirname, 'src', 'iframe', 'data_request_iframe.html'),
130
- filename: 'data_request_iframe.html',
131
- chunks: ['iframe'],
132
- inject: true
133
- }),
134
- new CopyWebpackPlugin({
135
- patterns: [
136
- {
137
- from: path.resolve(__dirname, 'public', 'data_request_popup.html'),
138
- to: path.resolve(__dirname, 'dist', 'data_request_popup.html')
139
- },
140
- {
141
- from: path.resolve(__dirname, 'public', 'oauth-callback.html'),
142
- to: path.resolve(__dirname, 'dist', 'oauth-callback.html')
143
- }
144
- ]
145
- })
146
- ]
147
- },
148
-
149
- // Laravel-specific build
150
- {
151
- ...baseConfig,
152
- entry: {
153
- 'onairos-laravel': path.resolve(__dirname, 'src', 'laravel', 'blade-helpers.js')
154
- },
155
- output: {
156
- path: path.resolve(__dirname, 'dist'),
157
- filename: '[name].js',
158
- libraryTarget: 'umd',
159
- library: 'OnairosLaravel',
160
- globalObject: 'this',
161
- umdNamedDefine: true,
162
- },
163
- externals: {
164
- // Laravel build shouldn't externalize React since blade-helpers.js doesn't use React
165
- 'ajv': 'ajv',
166
- 'ajv/dist/runtime/validation_error': 'ajv/dist/runtime/validation_error',
167
- 'ajv/dist/runtime/equal': 'ajv/dist/runtime/equal',
168
- 'ajv/dist/runtime/ucs2length': 'ajv/dist/runtime/ucs2length',
169
- 'ajv/dist/runtime/uri': 'ajv/dist/runtime/uri',
170
- '@anthropic-ai/sdk': '@anthropic-ai/sdk',
171
- '@google/generative-ai': '@google/generative-ai',
172
- '@pinecone-database/pinecone': '@pinecone-database/pinecone',
173
- 'openai': 'openai'
174
- }
175
- },
176
-
177
- // ES Module build
178
- {
179
- ...baseConfig,
180
- entry: path.resolve(__dirname, 'src', 'onairos.jsx'),
181
- externals: esmExternals,
182
- experiments: {
183
- outputModule: true,
184
- },
185
- output: {
186
- path: path.resolve(__dirname, 'dist'),
187
- filename: 'onairos.esm.js',
188
- library: {
189
- type: 'module'
190
- },
191
- environment: {
192
- module: true
193
- }
194
- },
195
- target: 'es2020'
196
- }
1
+ const path = require('path');
2
+ const TerserPlugin = require('terser-webpack-plugin');
3
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
4
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
5
+
6
+ const baseConfig = {
7
+ externals: {
8
+ react: {
9
+ commonjs: 'react',
10
+ commonjs2: 'react',
11
+ amd: 'React',
12
+ root: 'React'
13
+ },
14
+ 'react-dom': {
15
+ commonjs: 'react-dom',
16
+ commonjs2: 'react-dom',
17
+ amd: 'ReactDOM',
18
+ root: 'ReactDOM'
19
+ },
20
+ 'ajv': 'ajv',
21
+ 'ajv/dist/runtime/validation_error': 'ajv/dist/runtime/validation_error',
22
+ 'ajv/dist/runtime/equal': 'ajv/dist/runtime/equal',
23
+ 'ajv/dist/runtime/ucs2length': 'ajv/dist/runtime/ucs2length',
24
+ 'ajv/dist/runtime/uri': 'ajv/dist/runtime/uri',
25
+ '@anthropic-ai/sdk': '@anthropic-ai/sdk',
26
+ '@google/generative-ai': '@google/generative-ai',
27
+ '@pinecone-database/pinecone': '@pinecone-database/pinecone',
28
+ 'openai': 'openai'
29
+ },
30
+ optimization: {
31
+ minimize: true,
32
+ minimizer: [
33
+ new TerserPlugin({
34
+ terserOptions: {
35
+ compress: {
36
+ dead_code: true,
37
+ },
38
+ mangle: true,
39
+ output: {
40
+ comments: false,
41
+ },
42
+ },
43
+ extractComments: false,
44
+ }),
45
+ ],
46
+ },
47
+ devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
48
+ module: {
49
+ rules: [
50
+ {
51
+ test: /\.jsx?$/,
52
+ exclude: /node_modules/,
53
+ use: {
54
+ loader: 'babel-loader',
55
+ options: {
56
+ presets: ['@babel/preset-env', '@babel/preset-react']
57
+ }
58
+ }
59
+ },
60
+ {
61
+ test: /\.(png|jpg|gif|svg)$/i,
62
+ type: 'asset/resource',
63
+ generator: {
64
+ filename: 'static/[hash][ext][query]'
65
+ }
66
+ }
67
+ ]
68
+ },
69
+ resolve: {
70
+ extensions: ['.js', '.jsx', '.mjs'],
71
+ alias: {
72
+ '@': path.resolve(__dirname, 'src'),
73
+ },
74
+ fallback: {
75
+ "crypto": require.resolve("crypto-browserify"),
76
+ "stream": require.resolve("stream-browserify"),
77
+ "assert": require.resolve("assert"),
78
+ "http": require.resolve("stream-http"),
79
+ "https": require.resolve("https-browserify"),
80
+ "os": require.resolve("os-browserify/browser"),
81
+ "url": require.resolve("url"),
82
+ "zlib": require.resolve("browserify-zlib"),
83
+ "path": require.resolve("path-browserify"),
84
+ "vm": require.resolve("vm-browserify"),
85
+ "fs": false,
86
+ "net": false,
87
+ "tls": false,
88
+ "child_process": false
89
+ }
90
+ }
91
+ };
92
+
93
+ // ES Module specific externals configuration
94
+ const esmExternals = {
95
+ react: 'react',
96
+ 'react-dom': 'react-dom',
97
+ 'ajv': 'ajv',
98
+ 'ajv/dist/runtime/validation_error': 'ajv/dist/runtime/validation_error',
99
+ 'ajv/dist/runtime/equal': 'ajv/dist/runtime/equal',
100
+ 'ajv/dist/runtime/ucs2length': 'ajv/dist/runtime/ucs2length',
101
+ 'ajv/dist/runtime/uri': 'ajv/dist/runtime/uri',
102
+ '@anthropic-ai/sdk': '@anthropic-ai/sdk',
103
+ '@google/generative-ai': '@google/generative-ai',
104
+ '@pinecone-database/pinecone': '@pinecone-database/pinecone',
105
+ 'openai': 'openai'
106
+ };
107
+
108
+ module.exports = [
109
+ // UMD build for browsers
110
+ {
111
+ ...baseConfig,
112
+ entry: {
113
+ onairos: path.resolve(__dirname, 'src', 'onairos.jsx'),
114
+ iframe: path.resolve(__dirname, 'src', 'iframe', 'data_request_page.js')
115
+ },
116
+ output: {
117
+ path: path.resolve(__dirname, 'dist'),
118
+ filename: (pathData) => {
119
+ return pathData.chunk.name === 'onairos' ? 'onairos.bundle.js' : '[name].bundle.js';
120
+ },
121
+ libraryTarget: 'umd',
122
+ library: 'Onairos',
123
+ globalObject: 'this',
124
+ umdNamedDefine: true,
125
+ publicPath: 'auto',
126
+ },
127
+ plugins: [
128
+ new HtmlWebpackPlugin({
129
+ template: path.resolve(__dirname, 'src', 'iframe', 'data_request_iframe.html'),
130
+ filename: 'data_request_iframe.html',
131
+ chunks: ['iframe'],
132
+ inject: true
133
+ }),
134
+ new CopyWebpackPlugin({
135
+ patterns: [
136
+ {
137
+ from: path.resolve(__dirname, 'public', 'data_request_popup.html'),
138
+ to: path.resolve(__dirname, 'dist', 'data_request_popup.html')
139
+ },
140
+ {
141
+ from: path.resolve(__dirname, 'public', 'oauth-callback.html'),
142
+ to: path.resolve(__dirname, 'dist', 'oauth-callback.html')
143
+ }
144
+ ]
145
+ })
146
+ ]
147
+ },
148
+
149
+ // Laravel-specific build
150
+ {
151
+ ...baseConfig,
152
+ entry: {
153
+ 'onairos-laravel': path.resolve(__dirname, 'src', 'laravel', 'blade-helpers.js')
154
+ },
155
+ output: {
156
+ path: path.resolve(__dirname, 'dist'),
157
+ filename: '[name].js',
158
+ libraryTarget: 'umd',
159
+ library: 'OnairosLaravel',
160
+ globalObject: 'this',
161
+ umdNamedDefine: true,
162
+ },
163
+ externals: {
164
+ // Laravel build shouldn't externalize React since blade-helpers.js doesn't use React
165
+ 'ajv': 'ajv',
166
+ 'ajv/dist/runtime/validation_error': 'ajv/dist/runtime/validation_error',
167
+ 'ajv/dist/runtime/equal': 'ajv/dist/runtime/equal',
168
+ 'ajv/dist/runtime/ucs2length': 'ajv/dist/runtime/ucs2length',
169
+ 'ajv/dist/runtime/uri': 'ajv/dist/runtime/uri',
170
+ '@anthropic-ai/sdk': '@anthropic-ai/sdk',
171
+ '@google/generative-ai': '@google/generative-ai',
172
+ '@pinecone-database/pinecone': '@pinecone-database/pinecone',
173
+ 'openai': 'openai'
174
+ }
175
+ },
176
+
177
+ // ES Module build
178
+ {
179
+ ...baseConfig,
180
+ entry: path.resolve(__dirname, 'src', 'onairos.jsx'),
181
+ externals: esmExternals,
182
+ experiments: {
183
+ outputModule: true,
184
+ },
185
+ output: {
186
+ path: path.resolve(__dirname, 'dist'),
187
+ filename: 'onairos.esm.js',
188
+ library: {
189
+ type: 'module'
190
+ },
191
+ environment: {
192
+ module: true
193
+ }
194
+ },
195
+ target: 'es2020'
196
+ }
197
197
  ];