1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import generateAssertionOptions from './generateAssertionOptions';
test('should generate credential request options suitable for sending via JSON', () => {
const challenge = 'totallyrandomvalue';
const options = generateAssertionOptions(
challenge,
[
Buffer.from('1234', 'ascii').toString('base64'),
Buffer.from('5678', 'ascii').toString('base64'),
],
1,
);
expect(options).toEqual({
publicKey: {
challenge,
allowCredentials: [
{
id: 'MTIzNA==',
type: 'public-key',
transports: ['usb', 'ble', 'nfc'],
},
{
id: 'NTY3OA==',
type: 'public-key',
transports: ['usb', 'ble', 'nfc'],
},
],
timeout: 1,
},
});
});
test('defaults to 60 seconds if no timeout is specified', () => {
const options = generateAssertionOptions(
'totallyrandomvalue',
[
Buffer.from('1234', 'ascii').toString('base64'),
Buffer.from('5678', 'ascii').toString('base64'),
],
);
expect(options.publicKey.timeout).toEqual(60000);
});
|