diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8e952a8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+qseow-dev.code-workspace
diff --git a/jwt-scratch/eng.js b/jwt-scratch/eng.js
deleted file mode 100644
index a8037e0..0000000
--- a/jwt-scratch/eng.js
+++ /dev/null
@@ -1,46 +0,0 @@
-require("amd-loader");
-
-define(function() {
- return function() {
- require(['qlik', 'enigma', 'autogenerated/qix/engine-api'], function(qlik, enigma, schema) {
- //The base config with all details filled in
- var config = {
- schema: schema,
- appId: "My Demo App.qvf",
- session: {
- host: "qseow.jprdonnelly.com",
- port: 443,
- prefix: "",
- unsecure: true,
- },
- }
- //Now that we have a config, use that to connect to the //QIX service.
- enigma.getService("qix", config).then(function(qlik) {
- qlik.global.openApp(config.appId)
- //Open App
- qlik.global.openApp(config.appId).then(function(app) {
- //Create SessionObject for FieldList
- app.createSessionObject({
- qFieldListDef: {
- qShowSystem: false,
- qShowHidden: false,
- qShowSrcTables: true,
- qShowSemantic: true,
- qShowDerivedFields: true
- },
- qInfo: {
- qId: "FieldList",
- qType: "FieldList"
- }
- }).then(function(list) {
- return list.getLayout();
- }).then(function(listLayout) {
- return listLayout.qFieldList.qItems;
- }).then(function(fieldItems) {
- console.log(fieldItems)
- });
- })
- })
- })
- }
- })
diff --git a/jwt-scratch/jwt.js b/jwt-scratch/jwt.js
deleted file mode 100644
index 5424b59..0000000
--- a/jwt-scratch/jwt.js
+++ /dev/null
@@ -1,59 +0,0 @@
-const fs = require('fs');
-const jwt = require('jsonwebtoken');
-const { http, https } = require('follow-redirects');
-
-// Your Sense Enterprise installation hostname:
-const senseHost = 'qseow.jprdonnelly.com';
-
-// Your configured virtual proxy prefix for JWT authentication:
-const proxyPrefix = 'jwt';
-
-// The Sense Enterprise-configured user directory for the user you want to identify
-// as:
-const userDirectory = 'INTERNAL';
-
-// The user to use when creating the session:
-const userId = 'sa_api';
-
-// The Sense Enterprise-configured JWT structure. Change the attributes to match
-// your configuration:
-const token = {
- directory: userDirectory,
- user: userId,
-};
-
-// Path to the private key used for JWT signing:
-const privateKeyPath = './fort_private.key';
-const key = fs.readFileSync(path.resolve(__dirname, privateKeyPath));
-
-// Sign the token using the RS256 algorithm:
-const signedToken = jwt.sign(token, key, { algorithm: 'RS256' });
-
-const options = {
- hostname: 'qseow.browntown.local',
- port: 443,
- path: '/qrs/about?xrfkey=abcdefghijklmnop',
- method: 'GET',
- // agent: 'Windows',
- // login: 'INTERNAL\SA_API',
- password: '',
- headers: {
- 'X-Qlik-Xrfkey' : 'abcdefghijklmnop',
- 'X-Qlik-User' : `UserDirectory=${encodeURIComponent('INTERNAL')}; UserId=${encodeURIComponent('sa_api')}`,
- 'Authorization' : 'Bearer ${signedToken}'}
- },
- // key: fs.readFileSync("client_key.pem"),
- // cert: fs.readFileSync("client.pem"),
- // ca: fs.readFileSync("root.pem"),
- // rejectUnauthorized: false
-};
-
-https.get(options, function(res) {
- console.log("Got response: " + res.statusCode);
- res.on("data", function(chunk) {
- console.log("BODY: " + chunk);
- });
- }).on('error', function(e) {
- con
- sole.log("Got error: " + e.message);
-});
diff --git a/jwt-scratch/client.pem b/jwt-scratch/keys/client.pem
similarity index 100%
rename from jwt-scratch/client.pem
rename to jwt-scratch/keys/client.pem
diff --git a/jwt-scratch/client_key.pem b/jwt-scratch/keys/client_key.pem
similarity index 100%
rename from jwt-scratch/client_key.pem
rename to jwt-scratch/keys/client_key.pem
diff --git a/jwt-scratch/fort_private.key b/jwt-scratch/keys/fort_private.key
similarity index 100%
rename from jwt-scratch/fort_private.key
rename to jwt-scratch/keys/fort_private.key
diff --git a/jwt-scratch/private.key b/jwt-scratch/keys/private.key
similarity index 100%
rename from jwt-scratch/private.key
rename to jwt-scratch/keys/private.key
diff --git a/jwt-scratch/public.key b/jwt-scratch/keys/public.key
similarity index 100%
rename from jwt-scratch/public.key
rename to jwt-scratch/keys/public.key
diff --git a/jwt-scratch/root.pem b/jwt-scratch/keys/root.pem
similarity index 100%
rename from jwt-scratch/root.pem
rename to jwt-scratch/keys/root.pem
diff --git a/jwt-scratch/server.pem b/jwt-scratch/keys/server.pem
similarity index 100%
rename from jwt-scratch/server.pem
rename to jwt-scratch/keys/server.pem
diff --git a/jwt-scratch/server_key.pem b/jwt-scratch/keys/server_key.pem
similarity index 100%
rename from jwt-scratch/server_key.pem
rename to jwt-scratch/keys/server_key.pem
diff --git a/jwt-scratch/az-token.js b/jwt-scratch/src/az/az-token.js
similarity index 100%
rename from jwt-scratch/az-token.js
rename to jwt-scratch/src/az/az-token.js
diff --git a/jwt-scratch/cfw-verifyjwt.js b/jwt-scratch/src/cf/cfw-verifyjwt.js
similarity index 100%
rename from jwt-scratch/cfw-verifyjwt.js
rename to jwt-scratch/src/cf/cfw-verifyjwt.js
diff --git a/jwt-scratch/src/js/.jwtE.js.swp b/jwt-scratch/src/js/.jwtE.js.swp
new file mode 100644
index 0000000..676a257
Binary files /dev/null and b/jwt-scratch/src/js/.jwtE.js.swp differ
diff --git a/jwt-scratch/jwtE.js b/jwt-scratch/src/js/jwtE.js
similarity index 77%
rename from jwt-scratch/jwtE.js
rename to jwt-scratch/src/js/jwtE.js
index 1f9feb7..e825798 100644
--- a/jwt-scratch/jwtE.js
+++ b/jwt-scratch/src/js/jwtE.js
@@ -27,7 +27,7 @@ const token = {
};
// Path to the private key used for JWT signing:
-const privateKeyPath = "./private.key";
+const privateKeyPath = "../../keys/private.key";
let key = fs.readFileSync(privateKeyPath, "utf8");
// Sign the token using the RS256 algorithm:
@@ -40,7 +40,7 @@ let signedToken = jwt.sign(token, key, { algorithm: "RS256" });
const config = {
schema,
// url: `wss://${senseHost}/${proxyPrefix}/app/engineData`,
- url: `https://${senseHost}/${proxyPrefix}/app/engineData`,
+ url: `wss://${senseHost}/${proxyPrefix}/app/engineData`,
// Notice how the signed JWT is passed in the 'Authorization' header using the
// 'Bearer' schema:
createSocket: (url) =>
@@ -56,17 +56,17 @@ session
.open()
.then((global) => {
console.log("Session was opened successfully");
- return global.getDocList().then((list) => {
- const apps = list
- .map((app) => `${app.qDocId} (${app.qTitle || "No title"})`)
- .join(", ");
- console.log(
- `Apps on this Engine that the configured user can open: ${apps}`
- );
- session.close();
- });
+ // return global.getDocList().then((list) => {
+ // const apps = list
+ // .map((app) => `${app.qDocId} (${app.qTitle || "No title"})`)
+ // .join(", ");
+ // console.log(
+ // `Apps on this Engine that the configured user can open: ${apps}`
+ // );
+ // session.close();
+ // });
})
.catch((error) => {
- console.log("Failed to open session and/or retrieve the app list:", error);
+ console.log("Failed to open session:", error);
process.exit(1);
});
diff --git a/jwt-scratch/src/js/node_modules/.bin/semver b/jwt-scratch/src/js/node_modules/.bin/semver
new file mode 120000
index 0000000..317eb29
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/.bin/semver
@@ -0,0 +1 @@
+../semver/bin/semver
\ No newline at end of file
diff --git a/jwt-scratch/src/js/node_modules/.yarn-integrity b/jwt-scratch/src/js/node_modules/.yarn-integrity
new file mode 100644
index 0000000..985daf8
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/.yarn-integrity
@@ -0,0 +1,16 @@
+{
+ "systemParams": "linux-arm64-83",
+ "modulesFolders": [
+ "node_modules"
+ ],
+ "flags": [],
+ "linkedModules": [],
+ "topLevelPatterns": [
+ "uWebSockets.js@uNetworking/uWebSockets.js"
+ ],
+ "lockfileEntries": {
+ "uWebSockets.js@uNetworking/uWebSockets.js": "https://codeload.github.com/uNetworking/uWebSockets.js/tar.gz/9af80e10cec000fe6cdbd4037b2154e2ffa08b2d"
+ },
+ "files": [],
+ "artifacts": {}
+}
\ No newline at end of file
diff --git a/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/.npmignore b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/.npmignore
new file mode 100644
index 0000000..34e4f5c
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/.npmignore
@@ -0,0 +1,2 @@
+.*.sw[mnop]
+node_modules/
diff --git a/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/.travis.yml b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/.travis.yml
new file mode 100644
index 0000000..78e1c01
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+- "0.11"
+- "0.10"
diff --git a/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/LICENSE.txt b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/LICENSE.txt
new file mode 100644
index 0000000..9a064f3
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/LICENSE.txt
@@ -0,0 +1,12 @@
+Copyright (c) 2013, GoInstant Inc., a salesforce.com company
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+* Neither the name of salesforce.com, nor GoInstant, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/README.md b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/README.md
new file mode 100644
index 0000000..4f227f5
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/README.md
@@ -0,0 +1,50 @@
+# buffer-equal-constant-time
+
+Constant-time `Buffer` comparison for node.js. Should work with browserify too.
+
+[](https://travis-ci.org/goinstant/buffer-equal-constant-time)
+
+```sh
+ npm install buffer-equal-constant-time
+```
+
+# Usage
+
+```js
+ var bufferEq = require('buffer-equal-constant-time');
+
+ var a = new Buffer('asdf');
+ var b = new Buffer('asdf');
+ if (bufferEq(a,b)) {
+ // the same!
+ } else {
+ // different in at least one byte!
+ }
+```
+
+If you'd like to install an `.equal()` method onto the node.js `Buffer` and
+`SlowBuffer` prototypes:
+
+```js
+ require('buffer-equal-constant-time').install();
+
+ var a = new Buffer('asdf');
+ var b = new Buffer('asdf');
+ if (a.equal(b)) {
+ // the same!
+ } else {
+ // different in at least one byte!
+ }
+```
+
+To get rid of the installed `.equal()` method, call `.restore()`:
+
+```js
+ require('buffer-equal-constant-time').restore();
+```
+
+# Legal
+
+© 2013 GoInstant Inc., a salesforce.com company
+
+Licensed under the BSD 3-clause license.
diff --git a/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/index.js b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/index.js
new file mode 100644
index 0000000..5462c1f
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/index.js
@@ -0,0 +1,41 @@
+/*jshint node:true */
+'use strict';
+var Buffer = require('buffer').Buffer; // browserify
+var SlowBuffer = require('buffer').SlowBuffer;
+
+module.exports = bufferEq;
+
+function bufferEq(a, b) {
+
+ // shortcutting on type is necessary for correctness
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
+ return false;
+ }
+
+ // buffer sizes should be well-known information, so despite this
+ // shortcutting, it doesn't leak any information about the *contents* of the
+ // buffers.
+ if (a.length !== b.length) {
+ return false;
+ }
+
+ var c = 0;
+ for (var i = 0; i < a.length; i++) {
+ /*jshint bitwise:false */
+ c |= a[i] ^ b[i]; // XOR
+ }
+ return c === 0;
+}
+
+bufferEq.install = function() {
+ Buffer.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
+ return bufferEq(this, that);
+ };
+};
+
+var origBufEqual = Buffer.prototype.equal;
+var origSlowBufEqual = SlowBuffer.prototype.equal;
+bufferEq.restore = function() {
+ Buffer.prototype.equal = origBufEqual;
+ SlowBuffer.prototype.equal = origSlowBufEqual;
+};
diff --git a/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/package.json b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/package.json
new file mode 100644
index 0000000..79d2aa3
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/package.json
@@ -0,0 +1,55 @@
+{
+ "_from": "buffer-equal-constant-time@1.0.1",
+ "_id": "buffer-equal-constant-time@1.0.1",
+ "_inBundle": false,
+ "_integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=",
+ "_location": "/buffer-equal-constant-time",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "buffer-equal-constant-time@1.0.1",
+ "name": "buffer-equal-constant-time",
+ "escapedName": "buffer-equal-constant-time",
+ "rawSpec": "1.0.1",
+ "saveSpec": null,
+ "fetchSpec": "1.0.1"
+ },
+ "_requiredBy": [
+ "/jwa"
+ ],
+ "_resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
+ "_shasum": "f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819",
+ "_spec": "buffer-equal-constant-time@1.0.1",
+ "_where": "/home/rock64/git/qseow-scripts/jwt-scratch/src/js/node_modules/jwa",
+ "author": {
+ "name": "GoInstant Inc., a salesforce.com company"
+ },
+ "bugs": {
+ "url": "https://github.com/goinstant/buffer-equal-constant-time/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "Constant-time comparison of Buffers",
+ "devDependencies": {
+ "mocha": "~1.15.1"
+ },
+ "homepage": "https://github.com/goinstant/buffer-equal-constant-time#readme",
+ "keywords": [
+ "buffer",
+ "equal",
+ "constant-time",
+ "crypto"
+ ],
+ "license": "BSD-3-Clause",
+ "main": "index.js",
+ "name": "buffer-equal-constant-time",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/goinstant/buffer-equal-constant-time.git"
+ },
+ "scripts": {
+ "test": "mocha test.js"
+ },
+ "version": "1.0.1"
+}
diff --git a/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/test.js b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/test.js
new file mode 100644
index 0000000..0bc972d
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/buffer-equal-constant-time/test.js
@@ -0,0 +1,42 @@
+/*jshint node:true */
+'use strict';
+
+var bufferEq = require('./index');
+var assert = require('assert');
+
+describe('buffer-equal-constant-time', function() {
+ var a = new Buffer('asdfasdf123456');
+ var b = new Buffer('asdfasdf123456');
+ var c = new Buffer('asdfasdf');
+
+ describe('bufferEq', function() {
+ it('says a == b', function() {
+ assert.strictEqual(bufferEq(a, b), true);
+ });
+
+ it('says a != c', function() {
+ assert.strictEqual(bufferEq(a, c), false);
+ });
+ });
+
+ describe('install/restore', function() {
+ before(function() {
+ bufferEq.install();
+ });
+ after(function() {
+ bufferEq.restore();
+ });
+
+ it('installed an .equal method', function() {
+ var SlowBuffer = require('buffer').SlowBuffer;
+ assert.ok(Buffer.prototype.equal);
+ assert.ok(SlowBuffer.prototype.equal);
+ });
+
+ it('infected existing Buffers', function() {
+ assert.strictEqual(a.equal(b), true);
+ assert.strictEqual(a.equal(c), false);
+ });
+ });
+
+});
diff --git a/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/CODEOWNERS b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/CODEOWNERS
new file mode 100644
index 0000000..4451d3d
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/CODEOWNERS
@@ -0,0 +1 @@
+* @omsmith
diff --git a/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/LICENSE b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/LICENSE
new file mode 100644
index 0000000..8754ed6
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/LICENSE
@@ -0,0 +1,201 @@
+Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2015 D2L Corporation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/README.md b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/README.md
new file mode 100644
index 0000000..daa95d6
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/README.md
@@ -0,0 +1,65 @@
+# ecdsa-sig-formatter
+
+[](https://travis-ci.org/Brightspace/node-ecdsa-sig-formatter) [](https://coveralls.io/r/Brightspace/node-ecdsa-sig-formatter)
+
+Translate between JOSE and ASN.1/DER encodings for ECDSA signatures
+
+## Install
+```sh
+npm install ecdsa-sig-formatter --save
+```
+
+## Usage
+```js
+var format = require('ecdsa-sig-formatter');
+
+var derSignature = '..'; // asn.1/DER encoded ecdsa signature
+
+var joseSignature = format.derToJose(derSignature);
+
+```
+
+### API
+
+---
+
+#### `.derToJose(Buffer|String signature, String alg)` -> `String`
+
+Convert the ASN.1/DER encoded signature to a JOSE-style concatenated signature.
+Returns a _base64 url_ encoded `String`.
+
+* If _signature_ is a `String`, it should be _base64_ encoded
+* _alg_ must be one of _ES256_, _ES384_ or _ES512_
+
+---
+
+#### `.joseToDer(Buffer|String signature, String alg)` -> `Buffer`
+
+Convert the JOSE-style concatenated signature to an ASN.1/DER encoded
+signature. Returns a `Buffer`
+
+* If _signature_ is a `String`, it should be _base64 url_ encoded
+* _alg_ must be one of _ES256_, _ES384_ or _ES512_
+
+## Contributing
+
+1. **Fork** the repository. Committing directly against this repository is
+ highly discouraged.
+
+2. Make your modifications in a branch, updating and writing new unit tests
+ as necessary in the `spec` directory.
+
+3. Ensure that all tests pass with `npm test`
+
+4. `rebase` your changes against master. *Do not merge*.
+
+5. Submit a pull request to this repository. Wait for tests to run and someone
+ to chime in.
+
+### Code Style
+
+This repository is configured with [EditorConfig][EditorConfig] and
+[ESLint][ESLint] rules.
+
+[EditorConfig]: http://editorconfig.org/
+[ESLint]: http://eslint.org
diff --git a/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/package.json b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/package.json
new file mode 100644
index 0000000..922a3ff
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/package.json
@@ -0,0 +1,73 @@
+{
+ "_from": "ecdsa-sig-formatter@1.0.11",
+ "_id": "ecdsa-sig-formatter@1.0.11",
+ "_inBundle": false,
+ "_integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
+ "_location": "/ecdsa-sig-formatter",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "ecdsa-sig-formatter@1.0.11",
+ "name": "ecdsa-sig-formatter",
+ "escapedName": "ecdsa-sig-formatter",
+ "rawSpec": "1.0.11",
+ "saveSpec": null,
+ "fetchSpec": "1.0.11"
+ },
+ "_requiredBy": [
+ "/jwa"
+ ],
+ "_resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
+ "_shasum": "ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf",
+ "_spec": "ecdsa-sig-formatter@1.0.11",
+ "_where": "/home/rock64/git/qseow-scripts/jwt-scratch/src/js/node_modules/jwa",
+ "author": {
+ "name": "D2L Corporation"
+ },
+ "bugs": {
+ "url": "https://github.com/Brightspace/node-ecdsa-sig-formatter/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "safe-buffer": "^5.0.1"
+ },
+ "deprecated": false,
+ "description": "Translate ECDSA signatures between ASN.1/DER and JOSE-style concatenation",
+ "devDependencies": {
+ "bench": "^0.3.6",
+ "chai": "^3.5.0",
+ "coveralls": "^2.11.9",
+ "eslint": "^2.12.0",
+ "eslint-config-brightspace": "^0.2.1",
+ "istanbul": "^0.4.3",
+ "jwk-to-pem": "^1.2.5",
+ "mocha": "^2.5.3",
+ "native-crypto": "^1.7.0"
+ },
+ "homepage": "https://github.com/Brightspace/node-ecdsa-sig-formatter#readme",
+ "keywords": [
+ "ecdsa",
+ "der",
+ "asn.1",
+ "jwt",
+ "jwa",
+ "jsonwebtoken",
+ "jose"
+ ],
+ "license": "Apache-2.0",
+ "main": "src/ecdsa-sig-formatter.js",
+ "name": "ecdsa-sig-formatter",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/Brightspace/node-ecdsa-sig-formatter.git"
+ },
+ "scripts": {
+ "check-style": "eslint .",
+ "pretest": "npm run check-style",
+ "report-cov": "cat ./coverage/lcov.info | coveralls",
+ "test": "istanbul cover --root src _mocha -- spec"
+ },
+ "typings": "./src/ecdsa-sig-formatter.d.ts",
+ "version": "1.0.11"
+}
diff --git a/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.d.ts b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.d.ts
new file mode 100644
index 0000000..9693aa0
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.d.ts
@@ -0,0 +1,17 @@
+///
+
+declare module "ecdsa-sig-formatter" {
+ /**
+ * Convert the ASN.1/DER encoded signature to a JOSE-style concatenated signature. Returns a base64 url encoded String.
+ * If signature is a String, it should be base64 encoded
+ * alg must be one of ES256, ES384 or ES512
+ */
+ export function derToJose(signature: Buffer | string, alg: string): string;
+
+ /**
+ * Convert the JOSE-style concatenated signature to an ASN.1/DER encoded signature. Returns a Buffer
+ * If signature is a String, it should be base64 url encoded
+ * alg must be one of ES256, ES384 or ES512
+ */
+ export function joseToDer(signature: Buffer | string, alg: string): Buffer
+}
diff --git a/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js
new file mode 100644
index 0000000..38eeb9b
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js
@@ -0,0 +1,187 @@
+'use strict';
+
+var Buffer = require('safe-buffer').Buffer;
+
+var getParamBytesForAlg = require('./param-bytes-for-alg');
+
+var MAX_OCTET = 0x80,
+ CLASS_UNIVERSAL = 0,
+ PRIMITIVE_BIT = 0x20,
+ TAG_SEQ = 0x10,
+ TAG_INT = 0x02,
+ ENCODED_TAG_SEQ = (TAG_SEQ | PRIMITIVE_BIT) | (CLASS_UNIVERSAL << 6),
+ ENCODED_TAG_INT = TAG_INT | (CLASS_UNIVERSAL << 6);
+
+function base64Url(base64) {
+ return base64
+ .replace(/=/g, '')
+ .replace(/\+/g, '-')
+ .replace(/\//g, '_');
+}
+
+function signatureAsBuffer(signature) {
+ if (Buffer.isBuffer(signature)) {
+ return signature;
+ } else if ('string' === typeof signature) {
+ return Buffer.from(signature, 'base64');
+ }
+
+ throw new TypeError('ECDSA signature must be a Base64 string or a Buffer');
+}
+
+function derToJose(signature, alg) {
+ signature = signatureAsBuffer(signature);
+ var paramBytes = getParamBytesForAlg(alg);
+
+ // the DER encoded param should at most be the param size, plus a padding
+ // zero, since due to being a signed integer
+ var maxEncodedParamLength = paramBytes + 1;
+
+ var inputLength = signature.length;
+
+ var offset = 0;
+ if (signature[offset++] !== ENCODED_TAG_SEQ) {
+ throw new Error('Could not find expected "seq"');
+ }
+
+ var seqLength = signature[offset++];
+ if (seqLength === (MAX_OCTET | 1)) {
+ seqLength = signature[offset++];
+ }
+
+ if (inputLength - offset < seqLength) {
+ throw new Error('"seq" specified length of "' + seqLength + '", only "' + (inputLength - offset) + '" remaining');
+ }
+
+ if (signature[offset++] !== ENCODED_TAG_INT) {
+ throw new Error('Could not find expected "int" for "r"');
+ }
+
+ var rLength = signature[offset++];
+
+ if (inputLength - offset - 2 < rLength) {
+ throw new Error('"r" specified length of "' + rLength + '", only "' + (inputLength - offset - 2) + '" available');
+ }
+
+ if (maxEncodedParamLength < rLength) {
+ throw new Error('"r" specified length of "' + rLength + '", max of "' + maxEncodedParamLength + '" is acceptable');
+ }
+
+ var rOffset = offset;
+ offset += rLength;
+
+ if (signature[offset++] !== ENCODED_TAG_INT) {
+ throw new Error('Could not find expected "int" for "s"');
+ }
+
+ var sLength = signature[offset++];
+
+ if (inputLength - offset !== sLength) {
+ throw new Error('"s" specified length of "' + sLength + '", expected "' + (inputLength - offset) + '"');
+ }
+
+ if (maxEncodedParamLength < sLength) {
+ throw new Error('"s" specified length of "' + sLength + '", max of "' + maxEncodedParamLength + '" is acceptable');
+ }
+
+ var sOffset = offset;
+ offset += sLength;
+
+ if (offset !== inputLength) {
+ throw new Error('Expected to consume entire buffer, but "' + (inputLength - offset) + '" bytes remain');
+ }
+
+ var rPadding = paramBytes - rLength,
+ sPadding = paramBytes - sLength;
+
+ var dst = Buffer.allocUnsafe(rPadding + rLength + sPadding + sLength);
+
+ for (offset = 0; offset < rPadding; ++offset) {
+ dst[offset] = 0;
+ }
+ signature.copy(dst, offset, rOffset + Math.max(-rPadding, 0), rOffset + rLength);
+
+ offset = paramBytes;
+
+ for (var o = offset; offset < o + sPadding; ++offset) {
+ dst[offset] = 0;
+ }
+ signature.copy(dst, offset, sOffset + Math.max(-sPadding, 0), sOffset + sLength);
+
+ dst = dst.toString('base64');
+ dst = base64Url(dst);
+
+ return dst;
+}
+
+function countPadding(buf, start, stop) {
+ var padding = 0;
+ while (start + padding < stop && buf[start + padding] === 0) {
+ ++padding;
+ }
+
+ var needsSign = buf[start + padding] >= MAX_OCTET;
+ if (needsSign) {
+ --padding;
+ }
+
+ return padding;
+}
+
+function joseToDer(signature, alg) {
+ signature = signatureAsBuffer(signature);
+ var paramBytes = getParamBytesForAlg(alg);
+
+ var signatureBytes = signature.length;
+ if (signatureBytes !== paramBytes * 2) {
+ throw new TypeError('"' + alg + '" signatures must be "' + paramBytes * 2 + '" bytes, saw "' + signatureBytes + '"');
+ }
+
+ var rPadding = countPadding(signature, 0, paramBytes);
+ var sPadding = countPadding(signature, paramBytes, signature.length);
+ var rLength = paramBytes - rPadding;
+ var sLength = paramBytes - sPadding;
+
+ var rsBytes = 1 + 1 + rLength + 1 + 1 + sLength;
+
+ var shortLength = rsBytes < MAX_OCTET;
+
+ var dst = Buffer.allocUnsafe((shortLength ? 2 : 3) + rsBytes);
+
+ var offset = 0;
+ dst[offset++] = ENCODED_TAG_SEQ;
+ if (shortLength) {
+ // Bit 8 has value "0"
+ // bits 7-1 give the length.
+ dst[offset++] = rsBytes;
+ } else {
+ // Bit 8 of first octet has value "1"
+ // bits 7-1 give the number of additional length octets.
+ dst[offset++] = MAX_OCTET | 1;
+ // length, base 256
+ dst[offset++] = rsBytes & 0xff;
+ }
+ dst[offset++] = ENCODED_TAG_INT;
+ dst[offset++] = rLength;
+ if (rPadding < 0) {
+ dst[offset++] = 0;
+ offset += signature.copy(dst, offset, 0, paramBytes);
+ } else {
+ offset += signature.copy(dst, offset, rPadding, paramBytes);
+ }
+ dst[offset++] = ENCODED_TAG_INT;
+ dst[offset++] = sLength;
+ if (sPadding < 0) {
+ dst[offset++] = 0;
+ signature.copy(dst, offset, paramBytes);
+ } else {
+ signature.copy(dst, offset, paramBytes + sPadding);
+ }
+
+ return dst;
+}
+
+module.exports = {
+ derToJose: derToJose,
+ joseToDer: joseToDer
+};
diff --git a/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js
new file mode 100644
index 0000000..9fe67ac
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js
@@ -0,0 +1,23 @@
+'use strict';
+
+function getParamSize(keySize) {
+ var result = ((keySize / 8) | 0) + (keySize % 8 === 0 ? 0 : 1);
+ return result;
+}
+
+var paramBytesForAlg = {
+ ES256: getParamSize(256),
+ ES384: getParamSize(384),
+ ES512: getParamSize(521)
+};
+
+function getParamBytesForAlg(alg) {
+ var paramBytes = paramBytesForAlg[alg];
+ if (paramBytes) {
+ return paramBytes;
+ }
+
+ throw new Error('Unknown algorithm "' + alg + '"');
+}
+
+module.exports = getParamBytesForAlg;
diff --git a/jwt-scratch/src/js/node_modules/enigma.js/CHANGELOG.md b/jwt-scratch/src/js/node_modules/enigma.js/CHANGELOG.md
new file mode 100644
index 0000000..d1e1c90
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/enigma.js/CHANGELOG.md
@@ -0,0 +1,166 @@
+# Changelog
+
+## 2.7.2
+
+- fix massive arrays breaking the json patch
+
+## 2.7.1
+
+- fix: corrected the "Socket closed" and "Socket error" to be true enigma errors (#739)
+
+## 2.7.0
+
+- feat: added new schema, 12.612.0
+- fix: malformed api specification
+
+## 2.6.2 / 2.6.3
+
+### Fixes
+
+- fix: no undefined error on closed resolver (#678)
+- chore(deps): pdate minor and patch (#679)
+- chore(deps): update qlikcore/engine docker tag to v12.515.0 (#680)
+
+## 2.6.1
+
+### Fixes
+
+- chore(deps): update dependency rollup to v1.27.0 (#676)
+- fix(session): no echo code on suspend in rpcClosed (#675)
+
+## 2.6.0
+
+### New features
+
+- feat: send code and reason through suspend chain (#673)
+
+### Fixes
+
+- chore(deps): update dependency rollup to v1.26.4 (#671)
+- chore(deps): update minor and patch (#670)
+- chore(deps): update dependency rollup to v1.26.3 (#668)
+- chore(deps): update minor and patch (#667)
+- chore: dont generate source maps for error-codes (#666)
+- fix(error-codes): wrong description (#664)
+
+## 2.5.0
+
+### New features
+
+- Thrown errors now contain an error code (#661)
+
+### Fixes
+
+- prefer sessionid in session app creation methods (#662)
+
+## 2.4.1
+
+- fix: allow code and reason on session close to pass through (#656)
+
+## 2.4.0
+
+### New features
+
+- Traffic events on generated APIs which allows a developer to listen to handle-specific traffic for e.g. debugging purposes or tracking raw responses. See [documentation](https://github.com/qlik-oss/enigma.js/blob/master/docs/api.md#event-trafficsent-1).
+
+## 2.3.2
+
+- Added `error.code` with value `-1` when requests are rejected due to closed socket.
+
+## 2.3.1
+
+- API specification published.
+
+## 2.3.0
+
+- New schema: 12.170.2
+
+## 2.2.1
+
+- Bugfix for single-parameter method calls when using arrays which would cause the named parameters logic to take over.
+
+## 2.2.0
+
+- Expose `session.config`. See [documentation](https://github.com/qlik-oss/enigma.js/blob/master/docs/api.md#sessionconfig).
+- Use `Promise.reject` instead of `throw` in the api and error response interceptors.
+- Removed `bluebird` dependency in tests.
+- Made `retry aborted` example more robust.
+
+## 2.1.1
+
+- Bugfix for response interceptor execution order
+- Bugfix for failed delta patching when falsy values are unchanged
+
+## 2.1.0
+
+### New features
+
+- Possibility to add request interceptors. See [documentation](https://github.com/qlik-oss/enigma.js/blob/master/docs/api.md#requests).
+
+- Bugfix for delta flag (was unable to turn it off, regression from 2.0 rewrite)
+
+- New schema: 12.34.11
+
+## 2.0.2
+
+- Bugfix for suspended state when network caused a socket disconnect.
+
+## 2.0.1
+
+- Bugfix for `suspendOnClose` configuration option when session is closed by network.
+
+## 2.0.0
+
+This is a new major version and introduces some breaking changes. Please check the migration guide
+and make sure you understand the impact on your application before upgrading.
+
+See [migration guide](https://github.com/qlik-oss/enigma.js/blob/master/docs/migrate-v1.md).
+
+### New features
+
+- Interceptor concept publicly available. See [documentation](https://github.com/qlik-oss/enigma.js/blob/master/docs/api.md#interceptors).
+- Support for named QIX method parameters. See [documentation](https://github.com/qlik-oss/enigma.js/blob/master/docs/concepts.md#schemas-the-qix-interface).
+- New optional module sense-utilities. See [documentation](https://github.com/qlik-oss/enigma.js/blob/master/docs/api.md#sense-utilities-api).
+
+### Notable changes
+
+- No more product-specific configuration, 23 settings down to 8. See [documentation](https://github.com/qlik-oss/enigma.js/blob/master/docs/api.md#configuration).
+- Dropped enigma.js REST service. See [documentation](https://github.com/qlik-oss/enigma.js/blob/master/docs/migrate-v1.md#service-concept-dropped).
+- File size is ~15 times smaller (around 7kb gzipped)
+- Full control of session life-cycles. See [documentation](https://github.com/qlik-oss/enigma.js/blob/master/docs/api.md#session-api).
+
+## 1.2.1
+
+- Bugfix related to suspend/resume, notification should be qSessionState (not qConnectedState).
+
+## 1.2.0
+
+### Features
+- Suspend/Resume: It is now possible to suspend an resume qix sessions. See [session.md](https://github.com/qlik-oss/enigma.js/blob/master/docs/qix/session.md#sessions).
+
+## 1.1.1
+
+### Features
+
+- Logging (QIX/REST): It is now possible to (optionally) log traffic (request/response), this may be expanded to log other things in the future. See configuration entry `handleLog` for [QIX](docs/qix/configuration.md#config-object) and [REST](docs/rest/configuration.md#configuration).
+- API types (QIX): All object APIs returned from enigma.js now exposes their generic type (e.g. `sheet`), and their "engine" type (e.g. `GenericObject`). They can be accessed using `api.genericType` and `api.type`.
+- URL Parameters (QIX): You can now specify additional querystring parameters that should be added to the websocket URL by using `session.urlParams` configuration option. See [configuration documentation](docs/qix/configuration.md#configuration).
+- New schema (QIX): A schema for version `3.2` has been added.
+- Documentation (QIX): Added [documentation of the object API `.session` property](docs/qix/session.md), which (among other things) allows you to close apps.
+
+### Deprecations
+
+- Configuration (QIX): `config.session.reloadUri` in favor of `config.session.urlParams`.
+- Configuration (QIX/REST): `config.unsecure` (default `false`) in favor of `config.secure` (default `true`).
+
+## 1.1.0
+
+Broken release. Do not use.
+
+## 1.0.1
+
+- Fix #5: Make / optional in prefix
+
+## 1.0.0
+
+Initial public release.
diff --git a/jwt-scratch/src/js/node_modules/enigma.js/LICENSE b/jwt-scratch/src/js/node_modules/enigma.js/LICENSE
new file mode 100644
index 0000000..58480f7
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/enigma.js/LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2016-present QlikTech International AB
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/jwt-scratch/src/js/node_modules/enigma.js/README.md b/jwt-scratch/src/js/node_modules/enigma.js/README.md
new file mode 100644
index 0000000..dd48113
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/enigma.js/README.md
@@ -0,0 +1,120 @@
+
+
+[](https://circleci.com/gh/qlik-oss/enigma.js)
+[](https://coveralls.io/github/qlik-oss/enigma.js)
+
+enigma.js is a library that helps you communicate with Qlik QIX Engine. Examples of use may be building your own browser-based analytics tools, back-end services, or command-line scripts.
+
+---
+
+- [Getting started](#getting-started)
+- [High-level concepts](./docs/concepts.md#high-level-concepts)
+- [API documentation](./docs/api.md#api-documentation)
+- [API documentation for v1.x](https://github.com/qlik-oss/enigma.js/tree/v1.x/docs#overview)
+- [Migrating from v1.x](./docs/migrate-v1.md#migrating-from-version-1x)
+- [Contributing](./.github/CONTRIBUTING.md#contributing-to-enigmajs)
+- [Releasing](./.github/CONTRIBUTING.md#releasing)
+- [Runnable examples](./examples/README.md#runnable-examples)
+
+---
+
+## Getting started
+
+### Prerequisites
+
+Before continuing, make sure that you have these tools installed:
+
+* Node.js >= 4.0
+* Git bash if on Windows
+
+And know of at least some of these web technologies:
+
+* JavaScript
+* Promises
+* Websockets
+
+### Schemas
+
+enigma.js use schemas as a source when generating the QIX Engine API. The exact
+version of the schema you need is based on the QIX Engine version you want to
+communicate with, as well as what you plan on using in the QIX Engine API.
+
+Keep in mind that before version `12.20.0` the schema version corresponds to the
+Qlik Sense Enterprise version, and from `12.20.0` and forward, the schema version
+is mapped to the QIX Engine API version.
+
+Read more:
+
+* [High-level concepts: Schemas](./docs/concepts.md#schemas-the-qix-interface) for more information about how they work.
+* [schemas/](/schemas) for the available schemas.
+* [API Insights on Qlik Sense Help](https://api-insights.qlik.com/#/manifest) to identify your QIX Engine API version.
+
+### Usage
+
+First off, install enigma.js and a WebSocket library:
+
+```sh
+npm i -S enigma.js ws
+```
+
+Next, create a new file called `my-file.js` and put the following code into it:
+
+```js
+const enigma = require('enigma.js');
+const WebSocket = require('ws');
+const schema = require('enigma.js/schemas/12.20.0.json');
+
+// create a new session:
+const session = enigma.create({
+ schema,
+ url: 'ws://localhost:9076/app/engineData',
+ createSocket: url => new WebSocket(url),
+});
+
+// bind traffic events to log what is sent and received on the socket:
+session.on('traffic:sent', data => console.log('sent:', data));
+session.on('traffic:received', data => console.log('received:', data));
+
+// open the socket and eventually receive the QIX global API, and then close
+// the session:
+session.open()
+ .then((/*global*/) => console.log('We are connected!'))
+ .then(() => session.close())
+ .then(() => console.log('Session closed'))
+ .catch(err => console.log('Something went wrong :(', err));
+```
+
+And then run it:
+
+```sh
+node my-file.js
+```
+
+You may need to adjust the code so the URL points towards your running QIX Engine.
+
+
+
+You may also use a service like [unpkg](https://unpkg.com/#/) to test enigma.js directly in your browser without using Node.js for development purposes.
+
+Create a HTML file `index.html` and insert the following example content:
+
+```html
+
+
+```
diff --git a/jwt-scratch/src/js/node_modules/enigma.js/enigma.js b/jwt-scratch/src/js/node_modules/enigma.js/enigma.js
new file mode 100644
index 0000000..7b9b575
--- /dev/null
+++ b/jwt-scratch/src/js/node_modules/enigma.js/enigma.js
@@ -0,0 +1,3263 @@
+/**
+ * enigma.js v2.7.2
+ * Copyright (c) 2020 QlikTech International AB
+ * This library is licensed under MIT - See the LICENSE file for full details
+ */
+
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.enigma = factory());
+}(this, (function () { 'use strict';
+
+ /**
+ * Utility functions
+ */
+
+ var util = {};
+
+ util.isObject = function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+ };
+
+ util.isNumber = function isNumber(arg) {
+ return typeof arg === 'number';
+ };
+
+ util.isUndefined = function isUndefined(arg) {
+ return arg === void 0;
+ };
+
+ util.isFunction = function isFunction(arg){
+ return typeof arg === 'function';
+ };
+
+
+ /**
+ * EventEmitter class
+ */
+
+ function EventEmitter() {
+ EventEmitter.init.call(this);
+ }
+ var nodeEventEmitter = EventEmitter;
+
+ // Backwards-compat with node 0.10.x
+ EventEmitter.EventEmitter = EventEmitter;
+
+ EventEmitter.prototype._events = undefined;
+ EventEmitter.prototype._maxListeners = undefined;
+
+ // By default EventEmitters will print a warning if more than 10 listeners are
+ // added to it. This is a useful default which helps finding memory leaks.
+ EventEmitter.defaultMaxListeners = 10;
+
+ EventEmitter.init = function() {
+ this._events = this._events || {};
+ this._maxListeners = this._maxListeners || undefined;
+ };
+
+ // Obviously not all Emitters should be limited to 10. This function allows
+ // that to be increased. Set to zero for unlimited.
+ EventEmitter.prototype.setMaxListeners = function(n) {
+ if (!util.isNumber(n) || n < 0 || isNaN(n))
+ throw TypeError('n must be a positive number');
+ this._maxListeners = n;
+ return this;
+ };
+
+ EventEmitter.prototype.emit = function(type) {
+ var er, handler, len, args, i, listeners;
+
+ if (!this._events)
+ this._events = {};
+
+ // If there is no 'error' event listener then throw.
+ if (type === 'error' && !this._events.error) {
+ er = arguments[1];
+ if (er instanceof Error) {
+ throw er; // Unhandled 'error' event
+ } else {
+ throw Error('Uncaught, unspecified "error" event.');
+ }
+ }
+
+ handler = this._events[type];
+
+ if (util.isUndefined(handler))
+ return false;
+
+ if (util.isFunction(handler)) {
+ switch (arguments.length) {
+ // fast cases
+ case 1:
+ handler.call(this);
+ break;
+ case 2:
+ handler.call(this, arguments[1]);
+ break;
+ case 3:
+ handler.call(this, arguments[1], arguments[2]);
+ break;
+ // slower
+ default:
+ len = arguments.length;
+ args = new Array(len - 1);
+ for (i = 1; i < len; i++)
+ args[i - 1] = arguments[i];
+ handler.apply(this, args);
+ }
+ } else if (util.isObject(handler)) {
+ len = arguments.length;
+ args = new Array(len - 1);
+ for (i = 1; i < len; i++)
+ args[i - 1] = arguments[i];
+
+ listeners = handler.slice();
+ len = listeners.length;
+ for (i = 0; i < len; i++)
+ listeners[i].apply(this, args);
+ }
+
+ return true;
+ };
+
+ EventEmitter.prototype.addListener = function(type, listener) {
+ var m;
+
+ if (!util.isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ if (!this._events)
+ this._events = {};
+
+ // To avoid recursion in the case that type === "newListener"! Before
+ // adding it to the listeners, first emit "newListener".
+ if (this._events.newListener)
+ this.emit('newListener', type,
+ util.isFunction(listener.listener) ?
+ listener.listener : listener);
+
+ if (!this._events[type])
+ // Optimize the case of one listener. Don't need the extra array object.
+ this._events[type] = listener;
+ else if (util.isObject(this._events[type]))
+ // If we've already got an array, just append.
+ this._events[type].push(listener);
+ else
+ // Adding the second element, need to change to array.
+ this._events[type] = [this._events[type], listener];
+
+ // Check for listener leak
+ if (util.isObject(this._events[type]) && !this._events[type].warned) {
+ var m;
+ if (!util.isUndefined(this._maxListeners)) {
+ m = this._maxListeners;
+ } else {
+ m = EventEmitter.defaultMaxListeners;
+ }
+
+ if (m && m > 0 && this._events[type].length > m) {
+ this._events[type].warned = true;
+
+ if (util.isFunction(console.error)) {
+ console.error('(node) warning: possible EventEmitter memory ' +
+ 'leak detected. %d listeners added. ' +
+ 'Use emitter.setMaxListeners() to increase limit.',
+ this._events[type].length);
+ }
+ if (util.isFunction(console.trace))
+ console.trace();
+ }
+ }
+
+ return this;
+ };
+
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+
+ EventEmitter.prototype.once = function(type, listener) {
+ if (!util.isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ var fired = false;
+
+ function g() {
+ this.removeListener(type, g);
+
+ if (!fired) {
+ fired = true;
+ listener.apply(this, arguments);
+ }
+ }
+
+ g.listener = listener;
+ this.on(type, g);
+
+ return this;
+ };
+
+ // emits a 'removeListener' event iff the listener was removed
+ EventEmitter.prototype.removeListener = function(type, listener) {
+ var list, position, length, i;
+
+ if (!util.isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ if (!this._events || !this._events[type])
+ return this;
+
+ list = this._events[type];
+ length = list.length;
+ position = -1;
+
+ if (list === listener ||
+ (util.isFunction(list.listener) && list.listener === listener)) {
+ delete this._events[type];
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
+
+ } else if (util.isObject(list)) {
+ for (i = length; i-- > 0;) {
+ if (list[i] === listener ||
+ (list[i].listener && list[i].listener === listener)) {
+ position = i;
+ break;
+ }
+ }
+
+ if (position < 0)
+ return this;
+
+ if (list.length === 1) {
+ list.length = 0;
+ delete this._events[type];
+ } else {
+ list.splice(position, 1);
+ }
+
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
+ }
+
+ return this;
+ };
+
+ EventEmitter.prototype.removeAllListeners = function(type) {
+ var key, listeners;
+
+ if (!this._events)
+ return this;
+
+ // not listening for removeListener, no need to emit
+ if (!this._events.removeListener) {
+ if (arguments.length === 0)
+ this._events = {};
+ else if (this._events[type])
+ delete this._events[type];
+ return this;
+ }
+
+ // emit removeListener for all listeners on all events
+ if (arguments.length === 0) {
+ for (key in this._events) {
+ if (key === 'removeListener') continue;
+ this.removeAllListeners(key);
+ }
+ this.removeAllListeners('removeListener');
+ this._events = {};
+ return this;
+ }
+
+ listeners = this._events[type];
+
+ if (util.isFunction(listeners)) {
+ this.removeListener(type, listeners);
+ } else if (Array.isArray(listeners)) {
+ // LIFO order
+ while (listeners.length)
+ this.removeListener(type, listeners[listeners.length - 1]);
+ }
+ delete this._events[type];
+
+ return this;
+ };
+
+ EventEmitter.prototype.listeners = function(type) {
+ var ret;
+ if (!this._events || !this._events[type])
+ ret = [];
+ else if (util.isFunction(this._events[type]))
+ ret = [this._events[type]];
+ else
+ ret = this._events[type].slice();
+ return ret;
+ };
+
+ EventEmitter.listenerCount = function(emitter, type) {
+ var ret;
+ if (!emitter._events || !emitter._events[type])
+ ret = 0;
+ else if (util.isFunction(emitter._events[type]))
+ ret = 1;
+ else
+ ret = emitter._events[type].length;
+ return ret;
+ };
+
+ /**
+ * @module EventEmitter
+ * @private
+ */
+
+ var Events = {
+ /**
+ * Function used to add event handling to objects passed in.
+ * @param {Object} obj Object instance that will get event handling.
+ */
+ mixin: function mixin(obj) {
+ Object.keys(nodeEventEmitter.prototype).forEach(function (key) {
+ obj[key] = nodeEventEmitter.prototype[key];
+ });
+ nodeEventEmitter.init(obj);
+ }
+ };
+
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
+
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
+
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
+
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
+
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
+
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
+
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
+
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
+
+ /**
+ * Error containing a custom error code.
+ * @extends Error
+ * @property {number} code The error code as defined by `errorCodes`
+ * @property {boolean} enigmaError=true
+ */
+ var EnigmaError = /*#__PURE__*/function (_Error) {
+ _inherits(EnigmaError, _Error);
+
+ var _super = _createSuper(EnigmaError);
+
+ function EnigmaError(name, code) {
+ var _this;
+
+ _classCallCheck(this, EnigmaError);
+
+ _this = _super.call(this, name);
+ _this.code = code;
+ _this.enigmaError = true;
+ return _this;
+ }
+
+ return EnigmaError;
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
+ /**
+ * Create an enigmaError
+ * @private
+ * @param {Number} code A proper error code from `errorCodes`
+ * @param {String} name A message/name of the enigmaError.
+ * @returns {EnigmaError}
+ */
+
+
+ function createEnigmaError(code, name) {
+ return new EnigmaError(name, code);
+ }
+
+ /**
+ * This is a list of error codes that can be thrown from enigma.js API calls.
+ * @entry
+ * @see EnigmaError
+ * @enum
+ * @example
Handling an enigma.js error
+ * const { NOT_CONNECTED } = require('enigma.js/error-codes');
+ * try {
+ * const layout = await model.getLayout();
+ * } catch (err) {
+ * if (err.code === NOT_CONNECTED) {
+ * console.log('Tried to communicate on a session that is closed');
+ * }
+ * }
+ */
+ var errorCodes = {
+ /**
+ * You're trying to send data on a socket that's not connected
+ * @type {number}
+ */
+ NOT_CONNECTED: -1,
+
+ /**
+ * The object you're trying to fetch does not exist
+ * @type {number}
+ */
+ OBJECT_NOT_FOUND: -2,
+
+ /**
+ * Unexpected RPC response, expected array of patches
+ * @type {number}
+ */
+ EXPECTED_ARRAY_OF_PATCHES: -3,
+
+ /**
+ * Patchee is not an object we can patch
+ * @type {number}
+ */
+ PATCH_HAS_NO_PARENT: -4,
+
+ /**
+ * This entry is already defined with another key
+ * @type {number}
+ */
+ ENTRY_ALREADY_DEFINED: -5,
+
+ /**
+ * You need to supply a configuration
+ * @type {number}
+ */
+ NO_CONFIG_SUPPLIED: -6,
+
+ /**
+ * There's no promise object available (polyfill required?)
+ * @type {number}
+ */
+ PROMISE_REQUIRED: -7,
+
+ /**
+ * The schema struct type you requested does not exist
+ * @type {number}
+ */
+ SCHEMA_STRUCT_TYPE_NOT_FOUND: -8,
+
+ /**
+ * Can't override this function
+ * @type {number}
+ */
+ SCHEMA_MIXIN_CANT_OVERRIDE_FUNCTION: -9,
+
+ /**
+ * Extend is not allowed for this mixin
+ * @type {number}
+ */
+ SCHEMA_MIXIN_EXTEND_NOT_ALLOWED: -10,
+
+ /**
+ * Session suspended - no interaction allowed
+ * @type {number}
+ */
+ SESSION_SUSPENDED: -11,
+
+ /**
+ * onlyIfAttached supplied, but you got SESSION_CREATED
+ * @type {number}
+ */
+ SESSION_NOT_ATTACHED: -12
+ };
+
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
+
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
+
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
+ var RPC_CLOSE_NORMAL = 1000;
+ var RPC_CLOSE_MANUAL_SUSPEND = 4000;
+ var cacheId = 0;
+ /**
+ * The QIX Engine session object
+ */
+
+ var Session = /*#__PURE__*/function () {
+ /**
+ * Handle all JSON-RPC notification event, 'notification:*. Or handle a specific JSON-RPC
+ * notification event, 'notification:OnConnected'. These events depend on the product you use QIX
+ * Engine from.
+ * @event Session#notification
+ * @type {Object}
+ * @example Bind the notification events
+ * // bind all notifications to console.log:
+ * session.on('notification:*', console.log);
+ * // bind a specific notification to console.log:
+ * session.on('notification:OnConnected', console.log);
+ */
+
+ /**
+ * Handle websocket messages. Generally used in debugging purposes. `traffic:*` will handle all
+ * websocket messages, `traffic:sent` will handle outgoing messages and `traffic:received` will
+ * handle incoming messages.
+ * @event Session#traffic
+ * @type {Object}
+ * @example Bind the traffic events
+ * // bind both in- and outbound traffic to console.log:
+ * session.on('traffic:*', console.log);
+ * // bind outbound traffic to console.log:
+ * session.on('traffic:sent', console.log);
+ * // bind inbound traffic to console.log:
+ * session.on('traffic:received', console.log);
+ */
+ function Session(options) {
+ _classCallCheck$1(this, Session);
+
+ var session = this;
+ Object.assign(session, options);
+ this.Promise = this.config.Promise;
+ this.definition = this.config.definition;
+ Events.mixin(session);
+ cacheId += 1;
+ session.id = cacheId;
+ session.rpc.on('socket-error', session.onRpcError.bind(session));
+ session.rpc.on('closed', session.onRpcClosed.bind(session));
+ session.rpc.on('message', session.onRpcMessage.bind(session));
+ session.rpc.on('notification', session.onRpcNotification.bind(session));
+ session.rpc.on('traffic', session.onRpcTraffic.bind(session));
+ session.on('closed', function () {
+ return session.onSessionClosed();
+ });
+ }
+ /**
+ * Event handler for re-triggering error events from RPC.
+ * @private
+ * @emits socket-error
+ * @param {Error} err Webocket error event.
+ */
+
+
+ _createClass(Session, [{
+ key: "onRpcError",
+ value: function onRpcError(err) {
+ if (this.suspendResume.isSuspended) {
+ return;
+ }
+
+ this.emit('socket-error', err);
+ }
+ /**
+ * Event handler for the RPC close event.
+ * @private
+ * @emits Session#suspended
+ * @emits Session#closed
+ * @param {Event} evt WebSocket close event.
+ */
+
+ }, {
+ key: "onRpcClosed",
+ value: function onRpcClosed(evt) {
+ var _this = this;
+
+ /**
+ * Handle suspended state. This event is triggered in two cases (listed below). It is useful
+ * in scenarios where you for example want to block interaction in your application until you
+ * are resumed again. If config.suspendOnClose is true and there was a network disconnect
+ * (socked closed) or if you ran session.suspend().
+ * @event Session#suspended
+ * @type {Object}
+ * @param {Object} evt Event object.
+ * @param {String} evt.initiator String indication what triggered the suspended state. Possible
+ * values network, manual.
+ * @example Handling session suspended
+ * session.on('suspended', () => {
+ * console.log('Session was suspended, retrying...');
+ * session.resume();
+ * });
+ */
+ if (this.suspendResume.isSuspended) {
+ return;
+ }
+
+ if (evt.code === RPC_CLOSE_NORMAL || evt.code === RPC_CLOSE_MANUAL_SUSPEND) {
+ return;
+ }
+
+ if (this.config.suspendOnClose) {
+ var code = evt.code,
+ reason = evt.reason;
+ this.suspendResume.suspend().then(function () {
+ return _this.emit('suspended', {
+ initiator: 'network',
+ code: code,
+ reason: reason
+ });
+ });
+ } else {
+ this.emit('closed', evt);
+ }
+ }
+ /**
+ * Event handler for the RPC message event.
+ * @private
+ * @param {Object} response JSONRPC response.
+ */
+
+ }, {
+ key: "onRpcMessage",
+ value: function onRpcMessage(response) {
+ var _this2 = this;
+
+ if (this.suspendResume.isSuspended) {
+ return;
+ }
+
+ if (response.change) {
+ response.change.forEach(function (handle) {
+ return _this2.emitHandleChanged(handle);
+ });
+ }
+
+ if (response.close) {
+ response.close.forEach(function (handle) {
+ return _this2.emitHandleClosed(handle);
+ });
+ }
+ }
+ /**
+ * Event handler for the RPC notification event.
+ * @private
+ * @emits Session#notification
+ * @param {Object} response The JSONRPC notification.
+ */
+
+ }, {
+ key: "onRpcNotification",
+ value: function onRpcNotification(response) {
+ this.emit('notification:*', response.method, response.params);
+ this.emit("notification:".concat(response.method), response.params);
+ }
+ /**
+ * Event handler for the RPC traffic event.
+ * @private
+ * @emits Session#traffic
+ * @param {String} dir The traffic direction, sent or received.
+ * @param {Object} data JSONRPC request/response/WebSocket message.
+ * @param {Number} handle The associated handle.
+ */
+
+ }, {
+ key: "onRpcTraffic",
+ value: function onRpcTraffic(dir, data, handle) {
+ this.emit('traffic:*', dir, data);
+ this.emit("traffic:".concat(dir), data);
+ var api = this.apis.getApi(handle);
+
+ if (api) {
+ api.emit('traffic:*', dir, data);
+ api.emit("traffic:".concat(dir), data);
+ }
+ }
+ /**
+ * Event handler for cleaning up API instances when a session has been closed.
+ * @private
+ * @emits API#closed
+ */
+
+ }, {
+ key: "onSessionClosed",
+ value: function onSessionClosed() {
+ this.apis.getApis().forEach(function (entry) {
+ entry.api.emit('closed');
+ entry.api.removeAllListeners();
+ });
+ this.apis.clear();
+ }
+ /**
+ * Function used to get an API for a backend object.
+ * @private
+ * @param {Object} args Arguments used to create object API.
+ * @param {Number} args.handle Handle of the backend object.
+ * @param {String} args.id ID of the backend object.
+ * @param {String} args.type QIX type of the backend object. Can for example
+ * be "Doc" or "GenericVariable".
+ * @param {String} args.genericType Custom type of the backend object, if defined in qInfo.
+ * @returns {Object} Returns the generated and possibly augmented API.
+ */
+
+ }, {
+ key: "getObjectApi",
+ value: function getObjectApi(args) {
+ var handle = args.handle,
+ id = args.id,
+ type = args.type,
+ genericType = args.genericType;
+ var api = this.apis.getApi(handle);
+
+ if (api) {
+ return api;
+ }
+
+ var factory = this.definition.generate(type);
+ api = factory(this, handle, id, genericType);
+ this.apis.add(handle, api);
+ return api;
+ }
+ /**
+ * Establishes the websocket against the configured URL and returns the Global instance.
+ * @emits Session#opened
+ * @returns {Promise