Skip to content

Commit b8ede33

Browse files
committed
[js] Moving from static to const to make js-dossier happy
1 parent f5f2887 commit b8ede33

6 files changed

Lines changed: 50 additions & 39 deletions

File tree

javascript/node/gendocs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function getModules() {
116116
path.join(__dirname, 'selenium-webdriver/lib/safari'),
117117
path.join(__dirname, 'selenium-webdriver/lib/test'),
118118
path.join(__dirname, 'selenium-webdriver/lib/tools'),
119+
path.join(__dirname, 'selenium-webdriver/devtools/generator'),
119120
path.join(__dirname, 'selenium-webdriver/node_modules'),
120121
path.join(__dirname, 'selenium-webdriver/test')
121122
];

javascript/node/selenium-webdriver/lib/virtual_authenticator.js

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,38 @@
1717

1818
'use strict'
1919

20+
/**
21+
* Protocol for virtual authenticators
22+
* @enum {string}
23+
*/
24+
const Protocol = {
25+
'CTAP2': 'ctap2',
26+
'U2F': 'ctap1/u2f',
27+
}
28+
29+
/**
30+
* AuthenticatorTransport values
31+
* @enum {string}
32+
*/
33+
const Transport = {
34+
'BLE': 'ble',
35+
'USB': 'usb',
36+
'NFC': 'nfc',
37+
'INTERNAL': 'internal',
38+
}
39+
2040
/**
2141
* Options for the creation of virtual authenticators.
2242
* @see http://w3c.github.io/webauthn/#sctn-automation
2343
*/
2444
class VirtualAuthenticatorOptions {
2545

26-
static Protocol = {
27-
"CTAP2": 'ctap2',
28-
"U2F": 'ctap1/u2f',
29-
}
30-
31-
static Transport = {
32-
"BLE": 'ble',
33-
"USB": 'usb',
34-
"NFC": 'nfc',
35-
"INTERNAL": 'internal',
36-
}
37-
3846
/**
3947
* Constructor to initialise VirtualAuthenticatorOptions object.
4048
*/
4149
constructor() {
42-
this._protocol = VirtualAuthenticatorOptions.Protocol["CTAP2"]
43-
this._transport = VirtualAuthenticatorOptions.Transport["USB"]
50+
this._protocol = Protocol['CTAP2']
51+
this._transport = Transport['USB']
4452
this._hasResidentKey = false
4553
this._hasUserVerification = false
4654
this._isUserConsenting = true
@@ -102,8 +110,7 @@ class VirtualAuthenticatorOptions {
102110
"hasResidentKey": this.getHasResidentKey(),
103111
"hasUserVerification": this.getHasUserVerification(),
104112
"isUserConsenting": this.getIsUserConsenting(),
105-
"isUserVerified": this.getIsUserVerified(),
106-
113+
'isUserVerified': this.getIsUserVerified()
107114
}
108115
}
109116
}
@@ -113,14 +120,13 @@ class VirtualAuthenticatorOptions {
113120
* @see https://w3c.github.io/webauthn/#credential-parameters
114121
*/
115122
class Credential {
116-
constructor(
123+
constructor (
117124
credentialId,
118125
isResidentCredential,
119126
rpId,
120127
userHandle,
121128
privateKey,
122-
signCount
123-
) {
129+
signCount) {
124130
this._id = credentialId
125131
this._isResidentCredential = isResidentCredential
126132
this._rpId = rpId
@@ -224,7 +230,8 @@ class Credential {
224230
}
225231
}
226232

227-
module.exports = {
228-
Credential,
229-
VirtualAuthenticatorOptions,
230-
}
233+
module.exports.Credential = Credential
234+
module.exports.VirtualAuthenticatorOptions = VirtualAuthenticatorOptions
235+
module.exports.Transport = Transport
236+
module.exports.Protocol = Protocol
237+

javascript/node/selenium-webdriver/lib/webdriver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ class WebDriver {
15311531

15321532
/**
15331533
* Adds a virtual authenticator with the given options.
1534-
* @param options VirtualAuthenticatorOptions object to set authenticator optons.
1534+
* @param options VirtualAuthenticatorOptions object to set authenticator options.
15351535
*/
15361536
async addVirtualAuthenticator(options) {
15371537
this.authenticatorId_ = await this.execute(

javascript/node/selenium-webdriver/test/lib/virtualauthenticatoroptions_test.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
const assert = require('assert')
2121
const virtualAuthenticatorOptions =
2222
require('../../lib/virtual_authenticator').VirtualAuthenticatorOptions
23+
const Transport = require('../../lib/virtual_authenticator').Transport
24+
const Protocol = require('../../lib/virtual_authenticator').Protocol
2325

2426
let options
2527

@@ -29,34 +31,34 @@ describe('VirtualAuthenticatorOptions', function () {
2931
})
3032

3133
it('can testSetTransport', function () {
32-
options.setTransport(virtualAuthenticatorOptions.Transport['USB'])
34+
options.setTransport(Transport['USB'])
3335
assert.equal(
3436
options.getTransport(),
35-
virtualAuthenticatorOptions.Transport['USB']
37+
Transport['USB']
3638
)
3739
})
3840

3941
it('can testGetTransport', function () {
40-
options._transport = virtualAuthenticatorOptions.Transport['NFC']
42+
options._transport = Transport['NFC']
4143
assert.equal(
4244
options.getTransport(),
43-
virtualAuthenticatorOptions.Transport['NFC']
45+
Transport['NFC']
4446
)
4547
})
4648

4749
it('can testSetProtocol', function () {
48-
options.setProtocol(virtualAuthenticatorOptions.Protocol['U2F'])
50+
options.setProtocol(Protocol['U2F'])
4951
assert.equal(
5052
options.getProtocol(),
51-
virtualAuthenticatorOptions.Protocol['U2F']
53+
Protocol['U2F']
5254
)
5355
})
5456

5557
it('can testGetProtocol', function () {
56-
options._protocol = virtualAuthenticatorOptions.Protocol['CTAP2']
58+
options._protocol = Protocol['CTAP2']
5759
assert.equal(
5860
options.getProtocol(),
59-
virtualAuthenticatorOptions.Protocol['CTAP2']
61+
Protocol['CTAP2']
6062
)
6163
})
6264

@@ -104,11 +106,11 @@ describe('VirtualAuthenticatorOptions', function () {
104106
let default_options = options.toDict()
105107
assert.equal(
106108
default_options['transport'],
107-
virtualAuthenticatorOptions.Transport['USB']
109+
Transport['USB']
108110
)
109111
assert.equal(
110112
default_options['protocol'],
111-
virtualAuthenticatorOptions.Protocol['CTAP2']
113+
Protocol['CTAP2']
112114
)
113115
assert.equal(default_options['hasResidentKey'], false)
114116
assert.equal(default_options['hasUserVerification'], false)

javascript/node/selenium-webdriver/test/virtualAuthenticator_test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const virtualAuthenticatorCredential =
2222
require('../lib/virtual_authenticator').Credential
2323
const virtualAuthenticatorOptions =
2424
require('../lib/virtual_authenticator').VirtualAuthenticatorOptions
25+
const Protocol = require('../lib/virtual_authenticator').Protocol
2526
const { ignore, suite } = require('../lib/test')
2627
const { Browser } = require('../lib/capabilities')
2728
const fileServer = require('../lib/test/fileserver')
@@ -37,7 +38,7 @@ const GET_CREDENTIAL = `getCredential([{
3738
async function createRkEnabledU2fAuthenticator(driver) {
3839
let options
3940
options = new virtualAuthenticatorOptions()
40-
options.setProtocol(virtualAuthenticatorOptions.Protocol['U2F'])
41+
options.setProtocol(Protocol['U2F'])
4142
options.setHasResidentKey(true)
4243
await driver.addVirtualAuthenticator(options)
4344
return driver
@@ -46,7 +47,7 @@ async function createRkEnabledU2fAuthenticator(driver) {
4647
async function createRkDisabledU2fAuthenticator(driver) {
4748
let options
4849
options = new virtualAuthenticatorOptions()
49-
options.setProtocol(virtualAuthenticatorOptions.Protocol['U2F'])
50+
options.setProtocol(Protocol['U2F'])
5051
options.setHasResidentKey(false)
5152
await driver.addVirtualAuthenticator(options)
5253
return driver
@@ -55,7 +56,7 @@ async function createRkDisabledU2fAuthenticator(driver) {
5556
async function createRkEnabledCTAP2Authenticator(driver) {
5657
let options
5758
options = new virtualAuthenticatorOptions()
58-
options.setProtocol(virtualAuthenticatorOptions.Protocol['CTAP2'])
59+
options.setProtocol(Protocol['CTAP2'])
5960
options.setHasResidentKey(true)
6061
options.setHasUserVerification(true)
6162
options.setIsUserVerified(true)
@@ -66,7 +67,7 @@ async function createRkEnabledCTAP2Authenticator(driver) {
6667
async function createRkDisabledCTAP2Authenticator(driver) {
6768
let options
6869
options = new virtualAuthenticatorOptions()
69-
options.setProtocol(virtualAuthenticatorOptions.Protocol['CTAP2'])
70+
options.setProtocol(Protocol['CTAP2'])
7071
options.setHasResidentKey(false)
7172
options.setHasUserVerification(true)
7273
options.setIsUserVerified(true)

javascript/node/selenium-webdriver/testing/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function warn(msg) {
8888
* Extracts the browsers for a test suite to target from the `SELENIUM_BROWSER`
8989
* environment variable.
9090
*
91-
* @return {{name: string, version: string, platform: string}[]} the browsers to target.
91+
* @return {{name: string, version: string, platform: string}}[] the browsers to target.
9292
*/
9393
function getBrowsersToTestFromEnv() {
9494
let browsers = process.env['SELENIUM_BROWSER']

0 commit comments

Comments
 (0)