Skip to content

Commit 9b43f27

Browse files
taneltmmrts
authored andcommitted
feat: language option support
* Language selection options for web-eid.js and hwcrypto.js mocks * Bumped the library version * Changed the default X-Nonce-Length header for authentication from 32 to 44 as the previous value isn't supported anymore Signed-off-by: Tanel Metsar <[email protected]>
1 parent 798f9ca commit 9b43f27

File tree

5 files changed

+70
-43
lines changed

5 files changed

+70
-43
lines changed

lib/public/webeid/authenticate.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ function init() {
3030
headers: document.getElementById("authHeaders"),
3131
userInteractionTimeout: document.getElementById("authUserInteractionTimeout"),
3232
serverRequestTimeout: document.getElementById("authServerRequestTimeout"),
33+
authLanguage: document.getElementById("authLanguage"),
3334
result: document.getElementById("authResult"),
3435
}
3536

3637
ui.getAuthChallengeUrl.value = window.location.origin + "/auth/challenge";
3738
ui.postAuthTokenUrl.value = window.location.origin + "/auth/token";
3839
ui.headers.placeholder = "{ }";
39-
ui.headers.value = '{ "X-Nonce-Length": "32" }';
40+
ui.headers.value = '{ "X-Nonce-Length": "44" }';
4041
ui.userInteractionTimeout.placeholder = config.DEFAULT_USER_INTERACTION_TIMEOUT;
4142
ui.serverRequestTimeout.placeholder = config.DEFAULT_SERVER_REQUEST_TIMEOUT;
4243
ui.result.value = "";
@@ -45,6 +46,7 @@ function init() {
4546
const headers = JSON.parse(ui.headers.value || "{}");
4647
const userInteractionTimeout = ui.userInteractionTimeout.value;
4748
const serverRequestTimeout = ui.serverRequestTimeout.value;
49+
const lang = ui.authLanguage.value;
4850

4951
const options = {
5052
getAuthChallengeUrl: ui.getAuthChallengeUrl.value,
@@ -54,6 +56,7 @@ function init() {
5456
...(headers ? { headers } : {}),
5557
...(userInteractionTimeout ? { userInteractionTimeout } : {}),
5658
...(serverRequestTimeout ? { serverRequestTimeout } : {}),
59+
...(lang ? { lang } : {}),
5760
};
5861

5962
ui.result.value = "";

lib/public/webeid/sign.js

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function init() {
3030
headers: document.getElementById("signHeaders"),
3131
userInteractionTimeout: document.getElementById("signUserInteractionTimeout"),
3232
serverRequestTimeout: document.getElementById("signServerRequestTimeout"),
33+
signLanguage: document.getElementById("signLanguage"),
3334
result: document.getElementById("signResult"),
3435
};
3536

@@ -45,6 +46,7 @@ function init() {
4546
const headers = JSON.parse(ui.headers.value || "{}");
4647
const userInteractionTimeout = ui.userInteractionTimeout.value;
4748
const serverRequestTimeout = ui.serverRequestTimeout.value;
49+
const lang = ui.signLanguage.value;
4850

4951
const options = {
5052
postPrepareSigningUrl: ui.postPrepareSigningUrl.value,
@@ -54,6 +56,7 @@ function init() {
5456
...(headers ? { headers } : {}),
5557
...(userInteractionTimeout ? { userInteractionTimeout } : {}),
5658
...(serverRequestTimeout ? { serverRequestTimeout } : {}),
59+
...(lang ? { lang } : {}),
5760
};
5861

5962
ui.result.value = "";

lib/views/webeid.hbs

+30
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@
6060
<td>serverRequestTimeout</td>
6161
<td><input id="authServerRequestTimeout" type="text"></td>
6262
</tr>
63+
<tr>
64+
<td>Language</td>
65+
<td>
66+
<select name="authLanguage" id="authLanguage">
67+
<option value="" selected>(not specified)</option>
68+
<option value="et">et</option>
69+
<option value="en">en</option>
70+
<option value="ru">ru</option>
71+
<option value="lt">lt</option>
72+
<option value="lv">lv</option>
73+
<option value="tr">tr</option>
74+
<option value="xx">xx (not supported)</option>
75+
</select>
76+
</td>
77+
</tr>
6378
</tbody>
6479
</table>
6580

@@ -99,6 +114,21 @@
99114
<td>serverRequestTimeout</td>
100115
<td><input id="signServerRequestTimeout" type="text"></td>
101116
</tr>
117+
<tr>
118+
<td>Language</td>
119+
<td>
120+
<select name="signLanguage" id="signLanguage">
121+
<option value="" selected>(not specified)</option>
122+
<option value="et">et</option>
123+
<option value="en">en</option>
124+
<option value="ru">ru</option>
125+
<option value="lt">lt</option>
126+
<option value="lv">lv</option>
127+
<option value="tr">tr</option>
128+
<option value="xx">xx (not supported)</option>
129+
</select>
130+
</td>
131+
</tr>
102132
</tbody>
103133
</table>
104134

package-lock.json

+30-39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webextension-service-mock",
3-
"version": "0.0.0",
3+
"version": "1.0.0",
44
"private": true,
55
"scripts": {
66
"lint": "eslint . --ext .js",
@@ -12,11 +12,11 @@
1212
"author": "Tanel Metsar",
1313
"license": "MIT",
1414
"dependencies": {
15-
"@web-eid/web-eid-library": "^0.1.2",
15+
"@web-eid/web-eid-library": "~1.0.0",
1616
"cookie-parser": "~1.4.4",
1717
"debug": "^4.1.1",
1818
"express": "^4.17.1",
19-
"hbs": "^4.1.1",
19+
"hbs": "^4.1.2",
2020
"helmet": "^4.1.1",
2121
"http-errors": "~1.6.3",
2222
"morgan": "~1.9.1"

0 commit comments

Comments
 (0)