@nebula.js/cli-create
Advanced tools
Comparing version 3.0.3 to 3.0.4
{ | ||
"name": "@nebula.js/cli-create", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "", | ||
@@ -30,3 +30,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "2beefab5a936527fe5cdd20b98784d72199327fb" | ||
"gitHead": "419f994f8f5e15235fa20057bc9085b03a9a904b" | ||
} |
@@ -16,3 +16,3 @@ { | ||
"@nebula.js/sn-bar-chart": "^1.x", | ||
"@qlik/sdk": "^0.9.1", | ||
"@qlik/sdk": "^0.10.2", | ||
"enigma.js": "^2.6.3", | ||
@@ -19,0 +19,0 @@ "parcel": "^2.3.2" |
@@ -1,24 +0,26 @@ | ||
import enigma from 'enigma.js'; | ||
import schema from 'enigma.js/schemas/12.936.0.json'; | ||
import { Auth, AuthType } from '@qlik/sdk'; | ||
import { AuthType } from '@qlik/sdk'; | ||
import Authenticator from './Authenticator'; | ||
async function connect({ url, webIntegrationId, appId }) { | ||
const authInstance = new Auth({ | ||
webIntegrationId, | ||
autoRedirect: true, | ||
authType: AuthType.WebIntegration, | ||
host: url.replace(/^https?:\/\//, '').replace(/\/?/, ''), | ||
async function connect({ connectionType, url, appId, ...rest }) { | ||
const AuthenticatorInstance = new Authenticator({ | ||
url, | ||
appId, | ||
}); | ||
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); | ||
switch (connectionType) { | ||
case AuthType.WebIntegration: { | ||
return AuthenticatorInstance.AuthenticateWithWebIntegrationId({ | ||
...rest, | ||
}); | ||
} | ||
case AuthType.OAuth2: { | ||
return AuthenticatorInstance.AuthenticateWithOAuth({ ...rest }); | ||
} | ||
default: | ||
throw new Error('Please Provide a `connectionType` to proceed!'); | ||
} | ||
return null; | ||
} | ||
export default connect; |
/* eslint-disable */ | ||
import { AuthType } from '@qlik/sdk'; | ||
import embed from './configure'; | ||
@@ -7,5 +8,10 @@ import connect from './connect'; | ||
const app = await connect({ | ||
connectionType: '<AuthType.SOME_CONNECTION_TYPE>', | ||
url: '<URL>', | ||
appId: '<App id>', | ||
// you should use only one of below keys | ||
// based on your `connectionType` | ||
clientId: '<Qlik OAuth client id>', | ||
webIntegrationId: '<Qlik web integration id>', | ||
appId: '<App id>', | ||
}); | ||
@@ -12,0 +18,0 @@ |
46378
41
1352