cidaas-javascript-sdk 2.2.0 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/package.json +13 -1
- package/src/main/web-auth/webauth.js +96 -9
- package/types/.DS_Store +0 -0
- package/types/main/web-auth/webauth.d.ts +1 -0
- package/.gitlab-ci.yml +0 -17
- package/.prettierrc +0 -6
- package/tsconfig.json +0 -21
- package/webpack.common.js +0 -32
- package/webpack.dev.js +0 -15
- package/webpack.prod.js +0 -11
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## [2.2.4](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v2.2.3...v2.2.4) (2023-01-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **[gitlab-240](https://gitlab.widas.de/cidaas-v2/auth/issues/-/issues/240):** added getDevices & deleteDevices ([1dade9a](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/1dade9a3502d69ca4569ad72e456b3cf879afc34))
|
|
7
|
+
* **[gitlab-240](https://gitlab.widas.de/cidaas-v2/auth/issues/-/issues/240):** removed user-agent ([6061c4b](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/6061c4bc174150a5afdf84560627211558dddeb0))
|
|
8
|
+
* added unique deviceID instead of crypto ([bb9870b](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/bb9870be86a7a2292d658ba4a5f9209e8bc17e53))
|
|
9
|
+
* added unique deviceID instead of crypto ([80e5acc](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/80e5acc33e693a7bcbb7602bf147c416f7e26f2d))
|
|
10
|
+
* remove nexus refs ([f4f1cc4](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/f4f1cc4b1090fc3f333684cf2e428c0f731d3bc9))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cidaas-javascript-sdk",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"author": "cidaas by Widas ID GmbH",
|
|
5
5
|
"description": "Cidaas native javascript sdk",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,8 +16,20 @@
|
|
|
16
16
|
"test:coverage": "jest --coverage",
|
|
17
17
|
"build-types": "npx -p typescript tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir types"
|
|
18
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"src",
|
|
21
|
+
"types",
|
|
22
|
+
"README.md",
|
|
23
|
+
"license.MD",
|
|
24
|
+
"Changelogs.md"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"registry": "https://registry.npmjs.org/"
|
|
28
|
+
},
|
|
19
29
|
"dependencies": {
|
|
30
|
+
"@types/node": "^18.11.18",
|
|
20
31
|
"crypto-js": "^4.1.1",
|
|
32
|
+
"device-uuid": "^1.0.4",
|
|
21
33
|
"oidc-client": "^1.11.5"
|
|
22
34
|
},
|
|
23
35
|
"devDependencies": {
|
|
@@ -2,6 +2,7 @@ var Authentication = require('../authentication');
|
|
|
2
2
|
var CustomException = require('./exception');
|
|
3
3
|
var Oidc = require('oidc-client');
|
|
4
4
|
var CryptoJS = require("crypto-js");
|
|
5
|
+
var deviceID = require("device-uuid")
|
|
5
6
|
|
|
6
7
|
var code_verifier;
|
|
7
8
|
|
|
@@ -134,7 +135,7 @@ WebAuth.prototype.getUserProfile = function (options) {
|
|
|
134
135
|
};
|
|
135
136
|
http.open("GET", _serviceURL, true);
|
|
136
137
|
http.setRequestHeader("Content-type", "application/json");
|
|
137
|
-
http.setRequestHeader("
|
|
138
|
+
http.setRequestHeader("Authorization", `Bearer ${options.access_token}`);
|
|
138
139
|
if (window.localeSettings) {
|
|
139
140
|
http.setRequestHeader("accept-language", window.localeSettings);
|
|
140
141
|
}
|
|
@@ -161,7 +162,7 @@ WebAuth.prototype.getProfileInfo = function (access_token) {
|
|
|
161
162
|
};
|
|
162
163
|
http.open("GET", _serviceURL, true);
|
|
163
164
|
http.setRequestHeader("Content-type", "application/json");
|
|
164
|
-
http.setRequestHeader("
|
|
165
|
+
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
165
166
|
if (window.localeSettings) {
|
|
166
167
|
http.setRequestHeader("accept-language", window.localeSettings);
|
|
167
168
|
}
|
|
@@ -242,7 +243,7 @@ function createPostPromise(options, serviceurl, errorResolver, access_token) {
|
|
|
242
243
|
http.open("POST", serviceurl, true);
|
|
243
244
|
http.setRequestHeader("Content-type", "application/json");
|
|
244
245
|
if (access_token) {
|
|
245
|
-
http.setRequestHeader("
|
|
246
|
+
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
246
247
|
}
|
|
247
248
|
if (window.localeSettings) {
|
|
248
249
|
http.setRequestHeader("accept-language", window.localeSettings);
|
|
@@ -594,6 +595,66 @@ WebAuth.prototype.getClientInfo = function (options) {
|
|
|
594
595
|
});
|
|
595
596
|
};
|
|
596
597
|
|
|
598
|
+
// get all devices associated to the client
|
|
599
|
+
WebAuth.prototype.getDevicesInfo = function (options) {
|
|
600
|
+
return new Promise(function (resolve, reject) {
|
|
601
|
+
try {
|
|
602
|
+
var http = new XMLHttpRequest();
|
|
603
|
+
var _serviceURL = window.webAuthSettings.authority + "/device-srv/devices";
|
|
604
|
+
http.onreadystatechange = function () {
|
|
605
|
+
if (http.readyState == 4) {
|
|
606
|
+
if (http.responseText) {
|
|
607
|
+
resolve(JSON.parse(http.responseText));
|
|
608
|
+
} else {
|
|
609
|
+
resolve(false);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
http.open("GET", _serviceURL, true);
|
|
614
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
615
|
+
if (window.localeSettings) {
|
|
616
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
617
|
+
}
|
|
618
|
+
if(window.navigator.userAgent) {
|
|
619
|
+
http.setRequestBody("userAgent", window.navigator.userAgent)
|
|
620
|
+
}
|
|
621
|
+
http.send();
|
|
622
|
+
} catch (ex) {
|
|
623
|
+
reject(ex);
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
// delete a device
|
|
629
|
+
WebAuth.prototype.deleteDevice = function (options) {
|
|
630
|
+
return new Promise(function (resolve, reject) {
|
|
631
|
+
try {
|
|
632
|
+
var http = new XMLHttpRequest();
|
|
633
|
+
var _serviceURL = window.webAuthSettings.authority + "/device-srv/device/" + options.device_id;
|
|
634
|
+
http.onreadystatechange = function () {
|
|
635
|
+
if (http.readyState == 4) {
|
|
636
|
+
if (http.responseText) {
|
|
637
|
+
resolve(JSON.parse(http.responseText));
|
|
638
|
+
} else {
|
|
639
|
+
resolve(false);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
http.open("DELETE", _serviceURL, true);
|
|
644
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
645
|
+
if (window.localeSettings) {
|
|
646
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
647
|
+
}
|
|
648
|
+
if(window.navigator.userAgent) {
|
|
649
|
+
http.setRequestBody("userAgent", window.navigator.userAgent)
|
|
650
|
+
}
|
|
651
|
+
http.send();
|
|
652
|
+
} catch (ex) {
|
|
653
|
+
reject(ex);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
};
|
|
657
|
+
|
|
597
658
|
// get Registration setup
|
|
598
659
|
WebAuth.prototype.getRegistrationSetup = function (options) {
|
|
599
660
|
return new Promise(function (resolve, reject) {
|
|
@@ -1199,7 +1260,7 @@ WebAuth.prototype.getScopeConsentVersionDetailsV2 = function (options) {
|
|
|
1199
1260
|
};
|
|
1200
1261
|
http.open("GET", _serviceURL, true);
|
|
1201
1262
|
http.setRequestHeader("Content-type", "application/json");
|
|
1202
|
-
http.setRequestHeader("Authorization",
|
|
1263
|
+
http.setRequestHeader("Authorization", `Bearer ${options.access_token}`);
|
|
1203
1264
|
if (window.localeSettings) {
|
|
1204
1265
|
http.setRequestHeader("accept-language", window.localeSettings);
|
|
1205
1266
|
}
|
|
@@ -1412,7 +1473,7 @@ WebAuth.prototype.updateProfile = function (options, access_token, sub) {
|
|
|
1412
1473
|
};
|
|
1413
1474
|
http.open("PUT", _serviceURL, true);
|
|
1414
1475
|
http.setRequestHeader("Content-type", "application/json");
|
|
1415
|
-
http.setRequestHeader("
|
|
1476
|
+
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1416
1477
|
if (window.localeSettings) {
|
|
1417
1478
|
http.setRequestHeader("accept-language", window.localeSettings);
|
|
1418
1479
|
}
|
|
@@ -1446,7 +1507,7 @@ WebAuth.prototype.getUnreviewedDevices = function (access_token, sub) {
|
|
|
1446
1507
|
};
|
|
1447
1508
|
http.open("GET", _serviceURL, true);
|
|
1448
1509
|
http.setRequestHeader("Content-type", "application/json");
|
|
1449
|
-
http.setRequestHeader("
|
|
1510
|
+
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1450
1511
|
if (window.localeSettings) {
|
|
1451
1512
|
http.setRequestHeader("accept-language", window.localeSettings);
|
|
1452
1513
|
}
|
|
@@ -1474,7 +1535,7 @@ WebAuth.prototype.getReviewedDevices = function (access_token, sub) {
|
|
|
1474
1535
|
};
|
|
1475
1536
|
http.open("GET", _serviceURL, true);
|
|
1476
1537
|
http.setRequestHeader("Content-type", "application/json");
|
|
1477
|
-
http.setRequestHeader("
|
|
1538
|
+
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1478
1539
|
if (window.localeSettings) {
|
|
1479
1540
|
http.setRequestHeader("accept-language", window.localeSettings);
|
|
1480
1541
|
}
|
|
@@ -1502,7 +1563,7 @@ WebAuth.prototype.reviewDevice = function (options, access_token, sub) {
|
|
|
1502
1563
|
};
|
|
1503
1564
|
http.open("PUT", _serviceURL, true);
|
|
1504
1565
|
http.setRequestHeader("Content-type", "application/json");
|
|
1505
|
-
http.setRequestHeader("
|
|
1566
|
+
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1506
1567
|
if (window.localeSettings) {
|
|
1507
1568
|
http.setRequestHeader("accept-language", window.localeSettings);
|
|
1508
1569
|
}
|
|
@@ -1536,7 +1597,7 @@ WebAuth.prototype.viewAcceptedConsent = function (options, access_token) {
|
|
|
1536
1597
|
};
|
|
1537
1598
|
http.open("GET", _serviceURL, true);
|
|
1538
1599
|
http.setRequestHeader("Content-type", "application/json");
|
|
1539
|
-
http.setRequestHeader("
|
|
1600
|
+
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1540
1601
|
if (window.localeSettings) {
|
|
1541
1602
|
http.setRequestHeader("accept-language", window.localeSettings);
|
|
1542
1603
|
}
|
|
@@ -1876,4 +1937,30 @@ WebAuth.prototype.setAcceptLanguageHeader = function (acceptLanguage) {
|
|
|
1876
1937
|
window.localeSettings = acceptLanguage;
|
|
1877
1938
|
}
|
|
1878
1939
|
|
|
1940
|
+
// get device info
|
|
1941
|
+
WebAuth.prototype.getDeviceInfo = function (options) {
|
|
1942
|
+
return new Promise(function (resolve, reject) {
|
|
1943
|
+
try {
|
|
1944
|
+
if(!options.deviceFingerprint) {
|
|
1945
|
+
options.deviceFingerprint = new DeviceUUID().get();
|
|
1946
|
+
}
|
|
1947
|
+
var http = new XMLHttpRequest();
|
|
1948
|
+
var _serviceURL = window.webAuthSettings.authority + "/device-srv/deviceinfo";
|
|
1949
|
+
http.onreadystatechange = function () {
|
|
1950
|
+
if (http.readyState == 4) {
|
|
1951
|
+
resolve(JSON.parse(http.responseText));
|
|
1952
|
+
}
|
|
1953
|
+
};
|
|
1954
|
+
http.open("POST", _serviceURL, true);
|
|
1955
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
1956
|
+
if (window.localeSettings) {
|
|
1957
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
1958
|
+
}
|
|
1959
|
+
http.send(JSON.stringify(options));
|
|
1960
|
+
} catch (ex) {
|
|
1961
|
+
reject(ex);
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1964
|
+
};
|
|
1965
|
+
|
|
1879
1966
|
module.exports = WebAuth;
|
package/types/.DS_Store
ADDED
|
Binary file
|
package/.gitlab-ci.yml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
include:
|
|
2
|
-
- project: "widas/codequality"
|
|
3
|
-
ref: fix/yml-file-failure
|
|
4
|
-
file: "ci_templates/js.gitlab-ci.yml"
|
|
5
|
-
|
|
6
|
-
stages:
|
|
7
|
-
- test
|
|
8
|
-
- build
|
|
9
|
-
- badges
|
|
10
|
-
- deploy
|
|
11
|
-
|
|
12
|
-
npm-build:
|
|
13
|
-
image: nexus.widas.de:18443/cidaas-node-typescript:10.10.0-latest
|
|
14
|
-
stage: build
|
|
15
|
-
script:
|
|
16
|
-
- npm install
|
|
17
|
-
- npm run build
|
package/.prettierrc
DELETED
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Change this to match your project
|
|
3
|
-
"include": ["src/**/*"],
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
// Tells TypeScript to read JS files, as
|
|
6
|
-
// normally they are ignored as source files
|
|
7
|
-
"allowJs": true,
|
|
8
|
-
// Generate d.ts files
|
|
9
|
-
"declaration": true,
|
|
10
|
-
// This compiler run should
|
|
11
|
-
// only output d.ts files
|
|
12
|
-
"emitDeclarationOnly": true,
|
|
13
|
-
// Types should go into this directory.
|
|
14
|
-
// Removing this would place the .d.ts files
|
|
15
|
-
// next to the .js files
|
|
16
|
-
"outDir": "dist",
|
|
17
|
-
// go to js file when using IDE functions like
|
|
18
|
-
// "Go to Definition" in VSCode
|
|
19
|
-
"declarationMap": true
|
|
20
|
-
}
|
|
21
|
-
}
|
package/webpack.common.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const pjson = require('./package.json');
|
|
3
|
-
var webpack = require('webpack');
|
|
4
|
-
|
|
5
|
-
var entryPoints = {
|
|
6
|
-
'cidaas-javascript-sdk': './src/main/index.js'
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
entry: entryPoints,
|
|
11
|
-
plugins: [
|
|
12
|
-
new webpack.BannerPlugin({
|
|
13
|
-
banner: `${pjson.name} v${pjson.version}\n\nAuthor: ${pjson.author}\nDate: ${new Date().toLocaleString()}\nLicense: MIT\n`, // eslint-disable-line
|
|
14
|
-
raw: false,
|
|
15
|
-
entryOnly: true
|
|
16
|
-
}
|
|
17
|
-
)
|
|
18
|
-
],
|
|
19
|
-
output: {
|
|
20
|
-
path: path.resolve(__dirname, './build'),
|
|
21
|
-
filename: '[name].min.js',
|
|
22
|
-
library: '[name]',
|
|
23
|
-
libraryTarget: 'umd',
|
|
24
|
-
umdNamedDefine: true,
|
|
25
|
-
clean: true,
|
|
26
|
-
},
|
|
27
|
-
stats: {
|
|
28
|
-
colors: true,
|
|
29
|
-
modules: true,
|
|
30
|
-
reasons: true
|
|
31
|
-
},
|
|
32
|
-
};
|
package/webpack.dev.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { merge } = require('webpack-merge');
|
|
2
|
-
const common = require('./webpack.common.js');
|
|
3
|
-
|
|
4
|
-
module.exports = merge(common, {
|
|
5
|
-
mode: 'development',
|
|
6
|
-
devtool: 'inline-source-map',
|
|
7
|
-
devServer: {
|
|
8
|
-
contentBase: './build',
|
|
9
|
-
},
|
|
10
|
-
watch: true,
|
|
11
|
-
watchOptions: {
|
|
12
|
-
aggregateTimeout: 500,
|
|
13
|
-
poll: true
|
|
14
|
-
},
|
|
15
|
-
});
|
package/webpack.prod.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const { merge } = require('webpack-merge');
|
|
2
|
-
var webpack = require('webpack');
|
|
3
|
-
const common = require('./webpack.common.js');
|
|
4
|
-
const CompressionPlugin = require("compression-webpack-plugin");
|
|
5
|
-
module.exports = merge(common, {
|
|
6
|
-
mode: 'production',
|
|
7
|
-
plugins: [
|
|
8
|
-
new webpack.optimize.AggressiveMergingPlugin(),
|
|
9
|
-
new CompressionPlugin()
|
|
10
|
-
]
|
|
11
|
-
});
|