@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-rc.2",
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": "898b5acf0ecf16f2e988a9c01a06f681e0d5bf5e"
30
+ "gitHead": "50254faefff85fa3da57abfa1be1a0f71785ea30"
31
31
  }
@@ -12,7 +12,8 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@nebula.js/stardust": "<%= nebulaVersion %>",
15
- "@nebula.js/sn-bar-chart": "^0.8.24",
15
+ "@nebula.js/sn-bar-chart": "^1.x",
16
+ "@qlik/sdk": "^0.9.1",
16
17
  "enigma.js": "^2.6.3",
17
18
  "parcel": "^2.3.2"
18
19
  }
@@ -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 getQCSHeaders({ webIntegrationId, url }) {
5
- const response = await fetch(`${url}/api/v1/csrf-token`, {
6
- credentials: 'include',
7
- headers: { 'qlik-web-integration-id': webIntegrationId },
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
- const enigmaGlobal = await enigma
29
- .create({
30
- schema,
31
- url: `wss://${host}/app/${appId}?${params}`,
32
- })
33
- .open();
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
- async function connect({ url, webIntegrationId, appId }) {
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;
@@ -33,6 +33,6 @@
33
33
  "eslint-plugin-mocha": "9.0.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@nebula.js/stardust": "^3.0.0-alpha"
36
+ "@nebula.js/stardust": "^3.0.0"
37
37
  }
38
38
  }
@@ -35,6 +35,6 @@
35
35
  "picasso-plugin-q": "1.2.1"
36
36
  },
37
37
  "peerDependencies": {
38
- "@nebula.js/stardust": "^3.0.0-alpha"
38
+ "@nebula.js/stardust": "^3.0.0"
39
39
  }
40
40
  }