onairos 1.0.10 → 1.0.13

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.
@@ -3,45 +3,40 @@
3
3
  */
4
4
 
5
5
  /**
6
- * Get API access based on user selections and authentication data
7
- * @param {Object} options - Request options
8
- * @param {boolean} options.proofMode - Whether to use proof mode
9
- * @param {string} options.Web3Type - The web3 authentication type (e.g., "Othent")
10
- * @param {Array} options.Confirmations - The data confirmations selected by the user
6
+ * Get API access for data requests
7
+ * @param {Object} options - The request options
8
+ * @param {boolean} options.proofMode - Whether proof mode is enabled
9
+ * @param {string} options.Web3Type - The web3 authentication type
10
+ * @param {Array} options.Confirmations - Array of confirmations
11
11
  * @param {string} options.EncryptedUserPin - The encrypted user PIN
12
- * @param {string} options.Domain - The domain making the request
13
- * @param {string} options.OthentSub - The hashed Othent subject
14
- * @returns {Promise<Object>} - Promise resolving to the API access data
12
+ * @param {string} options.Domain - The requesting domain
13
+ * @param {string} options.UserSub - The user subject identifier
15
14
  */
16
- export async function getAPIAccess({ proofMode, Web3Type, Confirmations, EncryptedUserPin, Domain, OthentSub }) {
15
+ export async function getAPIAccess({ proofMode, Web3Type, Confirmations, EncryptedUserPin, Domain, UserSub }) {
17
16
  try {
18
- console.log('Getting API access with:', { proofMode, Web3Type, Domain });
19
-
20
- // Construct request body
21
- const requestBody = {
22
- proofMode,
23
- web3Type: Web3Type,
24
- confirmations: Confirmations,
25
- encryptedUserPin: EncryptedUserPin,
26
- domain: Domain,
27
- othentSub: OthentSub
28
- };
29
-
30
- // In a real implementation, this would make an actual API call
31
- // For now, simulate a network request with a timeout
32
- return new Promise((resolve) => {
33
- setTimeout(() => {
34
- resolve({
35
- success: true,
36
- body: {
37
- apiUrl: 'https://api.onairos.ai/access/' + Math.random().toString(36).substring(2, 15),
38
- token: 'token_' + Math.random().toString(36).substring(2, 15),
39
- }
40
- });
41
- }, 1000);
17
+ const response = await fetch('https://api2.onairos.uk/getAPIAccess', {
18
+ method: 'POST',
19
+ headers: {
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ body: JSON.stringify({
23
+ proofMode,
24
+ web3Type: Web3Type,
25
+ confirmations: Confirmations,
26
+ encryptedUserPin: EncryptedUserPin,
27
+ domain: Domain,
28
+ userSub: UserSub
29
+ })
42
30
  });
31
+
32
+ if (!response.ok) {
33
+ throw new Error(`HTTP error! status: ${response.status}`);
34
+ }
35
+
36
+ const data = await response.json();
37
+ return data;
43
38
  } catch (error) {
44
- console.error('Error in getAPIAccess:', error);
39
+ console.error('Error getting API access:', error);
45
40
  throw error;
46
41
  }
47
42
  }
@@ -0,0 +1,48 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Clean Onairos Build Test</title>
7
+ <script src="https://unpkg.com/react@18/umd/react.development.js"></script>
8
+ <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
9
+ <script src="https://cdn.tailwindcss.com"></script>
10
+ </head>
11
+ <body>
12
+ <div id="root" class="p-8">
13
+ <h1 class="text-2xl font-bold mb-4">Clean Onairos Build Test</h1>
14
+ <p class="mb-4 text-gray-600">✅ No Othent dependencies</p>
15
+ <p class="mb-4 text-gray-600">✅ No crypto-key-composer issues</p>
16
+ <p class="mb-4 text-gray-600">✅ No node-forge import errors</p>
17
+ <div id="button-container"></div>
18
+ </div>
19
+
20
+ <script src="./dist/main.bundle.js"></script>
21
+ <script>
22
+ console.log('🔥 Testing clean Onairos build...');
23
+
24
+ // Test the Onairos button
25
+ const { OnairosButton } = window.Onairos;
26
+
27
+ function handleComplete(result) {
28
+ console.log('✅ Onboarding completed successfully:', result);
29
+ alert('✅ Success! Onboarding completed without errors.');
30
+ }
31
+
32
+ // Create the button element
33
+ const buttonElement = React.createElement(OnairosButton, {
34
+ requestData: ['email', 'profile', 'social'],
35
+ webpageName: 'Clean Test App',
36
+ onComplete: handleComplete,
37
+ buttonType: 'pill',
38
+ visualType: 'full',
39
+ textColor: 'black'
40
+ });
41
+
42
+ // Render the button
43
+ ReactDOM.render(buttonElement, document.getElementById('button-container'));
44
+
45
+ console.log('✅ Onairos button rendered successfully!');
46
+ </script>
47
+ </body>
48
+ </html>
package/webpack.config.js CHANGED
@@ -2,19 +2,7 @@ const path = require('path');
2
2
  const TerserPlugin = require('terser-webpack-plugin');
3
3
  const HtmlWebpackPlugin = require('html-webpack-plugin');
4
4
 
5
- module.exports = {
6
- entry: {
7
- main: path.resolve(__dirname, 'src', 'onairos.jsx'),
8
- iframe: path.resolve(__dirname, 'src', 'iframe', 'data_request_page.js')
9
- },
10
- output: {
11
- path: path.resolve(__dirname, 'dist'),
12
- filename: '[name].bundle.js',
13
- libraryTarget: 'umd',
14
- globalObject: 'this',
15
- umdNamedDefine: true,
16
- publicPath: 'auto',
17
- },
5
+ const baseConfig = {
18
6
  externals: {
19
7
  react: {
20
8
  commonjs: 'react',
@@ -73,13 +61,57 @@ module.exports = {
73
61
  alias: {
74
62
  '@': path.resolve(__dirname, 'src'),
75
63
  },
64
+ }
65
+ };
66
+
67
+ module.exports = [
68
+ // UMD build for browsers
69
+ {
70
+ ...baseConfig,
71
+ entry: {
72
+ onairos: path.resolve(__dirname, 'src', 'onairos.jsx'),
73
+ iframe: path.resolve(__dirname, 'src', 'iframe', 'data_request_page.js')
74
+ },
75
+ output: {
76
+ path: path.resolve(__dirname, 'dist'),
77
+ filename: (pathData) => {
78
+ return pathData.chunk.name === 'onairos' ? 'onairos.bundle.js' : '[name].bundle.js';
79
+ },
80
+ libraryTarget: 'umd',
81
+ library: 'Onairos',
82
+ globalObject: 'this',
83
+ umdNamedDefine: true,
84
+ publicPath: 'auto',
85
+ },
86
+ plugins: [
87
+ new HtmlWebpackPlugin({
88
+ template: path.resolve(__dirname, 'src', 'iframe', 'data_request_iframe.html'),
89
+ filename: 'data_request_iframe.html',
90
+ chunks: ['iframe'],
91
+ inject: true
92
+ })
93
+ ]
76
94
  },
77
- plugins: [
78
- new HtmlWebpackPlugin({
79
- template: path.resolve(__dirname, 'src', 'iframe', 'data_request_iframe.html'),
80
- filename: 'data_request_iframe.html',
81
- chunks: ['iframe'],
82
- inject: true
83
- })
84
- ]
85
- };
95
+ // ESM build
96
+ {
97
+ ...baseConfig,
98
+ entry: path.resolve(__dirname, 'src', 'onairos.jsx'),
99
+ experiments: {
100
+ outputModule: true
101
+ },
102
+ output: {
103
+ path: path.resolve(__dirname, 'dist'),
104
+ filename: 'onairos.esm.js',
105
+ library: {
106
+ type: 'module'
107
+ },
108
+ environment: {
109
+ module: true
110
+ }
111
+ },
112
+ externals: {
113
+ react: 'react',
114
+ 'react-dom': 'react-dom'
115
+ }
116
+ }
117
+ ];