@nebula.js/cli-create
Advanced tools
Comparing version 3.0.0-rc.2 to 3.0.0-rc.3
{ | ||
"name": "@nebula.js/cli-create", | ||
"version": "3.0.0-rc.2", | ||
"version": "3.0.0-rc.3", | ||
"description": "", | ||
@@ -30,3 +30,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "898b5acf0ecf16f2e988a9c01a06f681e0d5bf5e" | ||
"gitHead": "6ffc4105c1f52e785a67e1c87bd64ff2f0351b52" | ||
} |
@@ -16,2 +16,3 @@ { | ||
"@nebula.js/sn-bar-chart": "^0.8.24", | ||
"@qlik/sdk": "^0.9.1", | ||
"enigma.js": "^2.6.3", | ||
@@ -18,0 +19,0 @@ "parcel": "^2.3.2" |
import enigma from 'enigma.js'; | ||
import schema from 'enigma.js/schemas/12.936.0.json'; | ||
import { Auth, AuthType } from '@qlik/sdk'; | ||
async function getQCSHeaders({ webIntegrationId, url }) { | ||
const response = await fetch(`${url}/api/v1/csrf-token`, { | ||
credentials: 'include', | ||
headers: { 'qlik-web-integration-id': webIntegrationId }, | ||
async function connect({ url, webIntegrationId, appId }) { | ||
const authInstance = new Auth({ | ||
webIntegrationId, | ||
autoRedirect: true, | ||
authType: AuthType.WebIntegration, | ||
host: url.replace(/^https?:\/\//, '').replace(/\/?/, ''), | ||
}); | ||
if (response.status === 401) { | ||
const loginUrl = new URL(`${url}/login`); | ||
loginUrl.searchParams.append('returnto', window.location.href); | ||
loginUrl.searchParams.append('qlik-web-integration-id', webIntegrationId); | ||
window.location.href = loginUrl; | ||
return undefined; | ||
if (!authInstance.isAuthenticated()) { | ||
authInstance.authenticate(); | ||
} else { | ||
const wssUrl = await authInstance.generateWebsocketUrl(appId); | ||
const enigmaGlobal = await enigma.create({ schema, url: wssUrl }).open(); | ||
return enigmaGlobal.openDoc(appId); | ||
} | ||
const csrfToken = new Map(response.headers).get('qlik-csrf-token'); | ||
return { | ||
'qlik-web-integration-id': webIntegrationId, | ||
'qlik-csrf-token': csrfToken, | ||
}; | ||
} | ||
async function getEnigmaApp({ host, appId, headers }) { | ||
const params = Object.keys(headers) | ||
.map((key) => `${key}=${headers[key]}`) | ||
.join('&'); | ||
const enigmaGlobal = await enigma | ||
.create({ | ||
schema, | ||
url: `wss://${host}/app/${appId}?${params}`, | ||
}) | ||
.open(); | ||
return enigmaGlobal.openDoc(appId); | ||
return null; | ||
} | ||
async function connect({ url, webIntegrationId, appId }) { | ||
const host = url.replace(/^https?:\/\//, '').replace(/\/?/, ''); | ||
const headers = await getQCSHeaders({ url, webIntegrationId }); | ||
return getEnigmaApp({ host, headers, appId }); | ||
} | ||
export default connect; |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
1
43527
1270