@nebula.js/cli-create 3.0.0-rc.2 → 3.0.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebula.js/cli-create",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "QlikTech International AB",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"fs-extra": "10.1.0",
|
|
28
28
|
"inquirer": "8.2.4"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "50254faefff85fa3da57abfa1be1a0f71785ea30"
|
|
31
31
|
}
|
|
@@ -1,44 +1,24 @@
|
|
|
1
1
|
import enigma from 'enigma.js';
|
|
2
2
|
import schema from 'enigma.js/schemas/12.936.0.json';
|
|
3
|
+
import { Auth, AuthType } from '@qlik/sdk';
|
|
3
4
|
|
|
4
|
-
async function
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
async function connect({ url, webIntegrationId, appId }) {
|
|
6
|
+
const authInstance = new Auth({
|
|
7
|
+
webIntegrationId,
|
|
8
|
+
autoRedirect: true,
|
|
9
|
+
authType: AuthType.WebIntegration,
|
|
10
|
+
host: url.replace(/^https?:\/\//, '').replace(/\/?/, ''),
|
|
8
11
|
});
|
|
9
|
-
if (response.status === 401) {
|
|
10
|
-
const loginUrl = new URL(`${url}/login`);
|
|
11
|
-
loginUrl.searchParams.append('returnto', window.location.href);
|
|
12
|
-
loginUrl.searchParams.append('qlik-web-integration-id', webIntegrationId);
|
|
13
|
-
window.location.href = loginUrl;
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
const csrfToken = new Map(response.headers).get('qlik-csrf-token');
|
|
17
|
-
return {
|
|
18
|
-
'qlik-web-integration-id': webIntegrationId,
|
|
19
|
-
'qlik-csrf-token': csrfToken,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function getEnigmaApp({ host, appId, headers }) {
|
|
24
|
-
const params = Object.keys(headers)
|
|
25
|
-
.map((key) => `${key}=${headers[key]}`)
|
|
26
|
-
.join('&');
|
|
27
12
|
|
|
28
|
-
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
return enigmaGlobal.openDoc(appId);
|
|
36
|
-
}
|
|
13
|
+
if (!authInstance.isAuthenticated()) {
|
|
14
|
+
authInstance.authenticate();
|
|
15
|
+
} else {
|
|
16
|
+
const wssUrl = await authInstance.generateWebsocketUrl(appId);
|
|
17
|
+
const enigmaGlobal = await enigma.create({ schema, url: wssUrl }).open();
|
|
18
|
+
return enigmaGlobal.openDoc(appId);
|
|
19
|
+
}
|
|
37
20
|
|
|
38
|
-
|
|
39
|
-
const host = url.replace(/^https?:\/\//, '').replace(/\/?/, '');
|
|
40
|
-
const headers = await getQCSHeaders({ url, webIntegrationId });
|
|
41
|
-
return getEnigmaApp({ host, headers, appId });
|
|
21
|
+
return null;
|
|
42
22
|
}
|
|
43
23
|
|
|
44
24
|
export default connect;
|