Skip to content

Commit

Permalink
feat: qlik api updates (#80)
Browse files Browse the repository at this point in the history
Co-authored-by: qlikossbuild <[email protected]>
  • Loading branch information
qlikossbuild and qlikossbuild authored Aug 22, 2024
1 parent e891f2b commit 5218f8f
Show file tree
Hide file tree
Showing 44 changed files with 150 additions and 130 deletions.
4 changes: 2 additions & 2 deletions api-keys.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/api-keys.ts
Expand Down
4 changes: 2 additions & 2 deletions apps.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/apps.ts
Expand Down
4 changes: 2 additions & 2 deletions audits.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/audits.ts
Expand Down
4 changes: 2 additions & 2 deletions auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
logout,
registerAuthModule,
setDefaultHostConfig
} from "./chunks/GPIKV6PO.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/HIDF7NRB.js";
import "./chunks/HILKFBG5.js";
export {
auth_default as default,
getAccessToken,
Expand Down
4 changes: 2 additions & 2 deletions automations.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/automations.ts
Expand Down
4 changes: 2 additions & 2 deletions brands.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/brands.ts
Expand Down
2 changes: 1 addition & 1 deletion chunks/PESPSFQN.js → chunks/6F5MEDU7.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
toValidEnigmaLocationUrl,
toValidLocationUrl,
toValidWebsocketLocationUrl
} from "./3XRP5N4L.js";
} from "./WZDZYILA.js";
import "./2ZQ3ZX7F.js";
export {
AuthorizationError,
Expand Down
2 changes: 1 addition & 1 deletion chunks/O3XVX7VQ.js → chunks/GZ2IPK4I.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getRestCallAuthParams,
getWebSocketAuthParams,
toValidWebsocketLocationUrl
} from "./3XRP5N4L.js";
} from "./WZDZYILA.js";
import {
isBrowser,
isNode
Expand Down
2 changes: 1 addition & 1 deletion chunks/GPIKV6PO.js → chunks/HIDF7NRB.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
getAuthRuntimeModule
} from "./AJZHO3JW.js";
} from "./HILKFBG5.js";

// src/public/auth.ts
function registerAuthModule(name, authModule) {
Expand Down
6 changes: 3 additions & 3 deletions chunks/AJZHO3JW.js → chunks/HILKFBG5.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// src/public/public-runtime-modules.ts
function getAuthRuntimeModule(hostConfig) {
const isNode = !!globalThis.process?.argv;
return isNode ? import("./PESPSFQN.js") : import("./TBHMVTOT.js").then(
return isNode ? import("./6F5MEDU7.js") : import("./PAGTF5II.js").then(
(mod) => mod.importRuntimeModule("auth@v1", hostConfig)
);
}
async function getQixRuntimeModule(hostConfig) {
await getAuthRuntimeModule(hostConfig);
const isNode = !!globalThis.process?.argv;
return isNode ? import("./JUVTHREC.js") : import("./TBHMVTOT.js").then(
return isNode ? import("./Y7V6Y33G.js") : import("./PAGTF5II.js").then(
(mod) => mod.importRuntimeModule("qix@v1", hostConfig)
);
}
async function getInvokeFetchRuntimeModule(hostConfig) {
await getAuthRuntimeModule(hostConfig);
const isNode = !!globalThis.process?.argv;
return isNode ? import("./ECWQX4IH.js") : import("./TBHMVTOT.js").then(
return isNode ? import("./KYUCJ7N4.js") : import("./PAGTF5II.js").then(
(mod) => mod.importRuntimeModule("invoke-fetch@v1", hostConfig)
);
}
Expand Down
2 changes: 1 addition & 1 deletion chunks/ECWQX4IH.js → chunks/KYUCJ7N4.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
invokeFetch,
invoke_fetch_default,
parseFetchResponse
} from "./3XRP5N4L.js";
} from "./WZDZYILA.js";
import "./2ZQ3ZX7F.js";
export {
EncodingError,
Expand Down
2 changes: 1 addition & 1 deletion chunks/3XUFIUKR.js → chunks/P3LY2SO7.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
getInvokeFetchRuntimeModule
} from "./AJZHO3JW.js";
} from "./HILKFBG5.js";
import {
isBrowser
} from "./2ZQ3ZX7F.js";
Expand Down
2 changes: 1 addition & 1 deletion chunks/TBHMVTOT.js → chunks/PAGTF5II.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// node_modules/.pnpm/@[email protected].8/node_modules/@qlik/runtime-module-loader/dist/index.js
// node_modules/.pnpm/@[email protected].9/node_modules/@qlik/runtime-module-loader/dist/index.js
window.__qlikMainPrivateResolvers = window.__qlikMainPrivateResolvers || {};
window.__qlikMainPrivateResolvers.mainUrlPromise = window.__qlikMainPrivateResolvers.mainUrlPromise || new Promise((resolve) => {
window.__qlikMainPrivateResolvers.resolveMainJsUrl = (value) => resolve(value);
Expand Down
2 changes: 1 addition & 1 deletion chunks/TXEL4LPW.js → chunks/Q7JLQHMM.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
getQixRuntimeModule
} from "./AJZHO3JW.js";
} from "./HILKFBG5.js";

// src/public/qix.ts
function openAppSession(appSessionProps) {
Expand Down
116 changes: 68 additions & 48 deletions chunks/3XRP5N4L.js → chunks/WZDZYILA.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,61 @@ async function refreshAccessToken(hostConfig) {
}
}

// src/auth/internal/default-auth-modules/oauth/temporary-token.ts
async function exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, purpose) {
const response = await fetch(`${toValidLocationUrl(hostConfig)}/oauth/token`, {
method: "POST",
credentials: "include",
mode: "cors",
headers: { "content-type": "application/json" },
redirect: "follow",
body: JSON.stringify({
subject_token: accessToken,
subject_token_type: "urn:ietf:params:oauth:token-type:access_token",
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
purpose,
redirect_uri: globalThis.location?.href,
client_id: hostConfig.clientId
})
});
if (response.status !== 200) {
throw await toError(response);
}
const data = await response.json();
return data.access_token;
}
async function toError(response) {
const body = await response.text();
try {
const data = JSON.parse(body);
return new AuthorizationError(data.errors);
} catch (err) {
return new AuthorizationError([
{
code: "unknown",
status: response.status,
detail: body,
title: "Unknown authentication error"
}
]);
}
}

// src/auth/internal/default-auth-modules/anonymous.ts
async function handlePotentialAuthenticationErrorAndRetry(hostConfig, fn) {
try {
return await fn();
} catch (err) {
const { retry } = await handleAuthenticationError2({
hostConfig,
canRetry: true
});
if (retry) {
return fn();
}
throw err;
}
}
async function getOrCreateTrackingCode(hostConfig) {
let trackingCode;
if (isBrowser()) {
Expand All @@ -809,7 +863,7 @@ async function getOrCreateTrackingCode(hostConfig) {
}
function createTrackingCode() {
const timeStamp = Math.floor(Date.now() / 1e3).toString(16);
const randomString = generateRandomHexString(20);
const randomString = generateRandomHexString(40 - timeStamp.length);
return `${timeStamp}${randomString}`;
}
async function getAnonymousAccessToken(hostConfig) {
Expand Down Expand Up @@ -849,20 +903,26 @@ async function getRestCallAuthParams2({
async function getWebSocketAuthParams2({
hostConfig
}) {
const accessToken = await getAnonymousAccessToken(hostConfig);
const websocketAccessToken = await handlePotentialAuthenticationErrorAndRetry(hostConfig, async () => {
const accessToken = await getAnonymousAccessToken(hostConfig);
return exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, "websocket");
});
return {
queryParams: {
accessToken
accessToken: websocketAccessToken
}
};
}
async function getWebResourceAuthParams2({
hostConfig
}) {
const accessToken = await getAnonymousAccessToken(hostConfig);
const websocketResourceAccessToken = await handlePotentialAuthenticationErrorAndRetry(hostConfig, async () => {
const accessToken = await getAnonymousAccessToken(hostConfig);
return exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, "websocket");
});
return {
queryParams: {
accessToken
accessToken: websocketResourceAccessToken
}
};
}
Expand Down Expand Up @@ -1059,51 +1119,11 @@ function handleOAuthCallback() {
}
}

// src/auth/internal/default-auth-modules/oauth/temporary-token.ts
async function exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, purpose) {
const response = await fetch(`${toValidLocationUrl(hostConfig)}/oauth/token`, {
method: "POST",
credentials: "include",
mode: "cors",
headers: { "content-type": "application/json" },
redirect: "follow",
body: JSON.stringify({
subject_token: accessToken,
subject_token_type: "urn:ietf:params:oauth:token-type:access_token",
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
purpose,
redirect_uri: globalThis.location?.href,
client_id: hostConfig.clientId
})
});
if (response.status !== 200) {
throw await toError(response);
}
const data = await response.json();
return data.access_token;
}
async function toError(response) {
const body = await response.text();
try {
const data = JSON.parse(body);
return new AuthorizationError(data.errors);
} catch (err) {
return new AuthorizationError([
{
code: "unknown",
status: response.status,
detail: body,
title: "Unknown authentication error"
}
]);
}
}

// src/auth/internal/default-auth-modules/oauth.ts
if (isBrowser()) {
handleOAuthCallback();
}
async function handlePotentialAuthenticationErrorAndRetry(hostConfig, fn) {
async function handlePotentialAuthenticationErrorAndRetry2(hostConfig, fn) {
try {
return await fn();
} catch (err) {
Expand Down Expand Up @@ -1131,7 +1151,7 @@ async function getRestCallAuthParams6({
async function getWebSocketAuthParams6({
hostConfig
}) {
const websocketAccessToken = await handlePotentialAuthenticationErrorAndRetry(hostConfig, async () => {
const websocketAccessToken = await handlePotentialAuthenticationErrorAndRetry2(hostConfig, async () => {
const accessToken = await getOAuthAccessToken(hostConfig);
return exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, "websocket");
});
Expand All @@ -1144,7 +1164,7 @@ async function getWebSocketAuthParams6({
async function getWebResourceAuthParams3({
hostConfig
}) {
const webResourceAccessToken = await handlePotentialAuthenticationErrorAndRetry(hostConfig, async () => {
const webResourceAccessToken = await handlePotentialAuthenticationErrorAndRetry2(hostConfig, async () => {
const accessToken = await getOAuthAccessToken(hostConfig);
return exchangeAccessTokenForTemporaryToken(hostConfig, accessToken, "webresource");
});
Expand Down
4 changes: 2 additions & 2 deletions chunks/JUVTHREC.js → chunks/Y7V6Y33G.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
invokeFetch,
isWindows,
toValidWebsocketLocationUrl
} from "./3XRP5N4L.js";
} from "./WZDZYILA.js";
import {
isBrowser
} from "./2ZQ3ZX7F.js";
Expand Down Expand Up @@ -101,7 +101,7 @@ function listenForWindowsAuthenticationInformation(session) {
return authSuggestedInWebsocket;
}
async function createAndSetupEnigmaSession(props, canRetry) {
const { createEnigmaSession } = await import("./O3XVX7VQ.js");
const { createEnigmaSession } = await import("./GZ2IPK4I.js");
const session = await createEnigmaSession(props);
setupSessionListeners(session, props);
let global;
Expand Down
4 changes: 2 additions & 2 deletions collections.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/collections.ts
Expand Down
4 changes: 2 additions & 2 deletions csp-origins.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/csp-origins.ts
Expand Down
4 changes: 2 additions & 2 deletions data-assets.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/data-assets.ts
Expand Down
4 changes: 2 additions & 2 deletions data-connections.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/data-connections.ts
Expand Down
4 changes: 2 additions & 2 deletions data-credentials.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
clearApiCache,
invokeFetch
} from "./chunks/3XUFIUKR.js";
import "./chunks/AJZHO3JW.js";
} from "./chunks/P3LY2SO7.js";
import "./chunks/HILKFBG5.js";
import "./chunks/2ZQ3ZX7F.js";

// src/public/rest/data-credentials.ts
Expand Down
Loading

0 comments on commit 5218f8f

Please sign in to comment.