-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplayground.html
226 lines (182 loc) · 7.66 KB
/
playground.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/buefy/dist/buefy.min.css">
<style>
label.required::after {
content: "*";
color: red;
}
.field .field {
flex-basis: 0;
overflow: auto;
}
.hint {
color: #777;
opacity: 0.7;
}
.field:hover .hint {
opacity: 1;
}
.with-big-icon {
margin: 5rem 0 1rem 0;
display: flex;
justify-content: center;
align-items: center;
}
.with-big-icon img {
height: 4rem;
margin: 0 1rem;
}
.col {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
</style>
</head>
<body>
<main id="app" class="container p-3">
<header class="block has-text-centered">
<h1 class="title">Passwordless Playground</h1>
</header>
<p>Using this tool, you can experiment with the various parameters of the JS helper library (to be released).</p>
<section>
<header class="with-big-icon">
<img src="img/icon_register.svg"/>
<h2 class="title">Registration</h2>
</header>
<b-field label="Username" horizontal custom-class="required">
<b-input v-model="registration.username" placeholder="Username or E-Mail"></b-input>
<div class="hint">A username, email or other identifier</div>
</b-field>
<b-field label="Challenge" horizontal custom-class="required">
<b-field>
<b-input v-model="registration.challenge" placeholder="Challenge" expanded></b-input>
<p class="control">
<b-button type="is-primary" label="↻" @click="registration.challenge = newChallenge()"/>
</p>
</b-field>
<div class="hint">A server-side randomly generated string.</div>
</b-field>
<b-field label="authenticatorType" horizontal>
<b-select v-model="registration.options.authenticatorType" expanded>
<option>auto</option>
<option>local</option>
<option>extern</option>
<option>both</option>
</b-select>
<div class="hint">Which device to use as authenticator.</div>
</b-field>
<b-field label="Timeout" horizontal>
<b-input v-model="registration.options.timeout" placeholder="60000" expanded></b-input>
<div class="hint">Number of milliseconds the user has to respond to the biometric/PIN check.</div>
</b-field>
<b-field label="userVerification" horizontal>
<b-select v-model="registration.options.userVerification" expanded>
<option>required</option>
<option>preferred</option>
<option>discouraged</option>
</b-select>
<div class="hint">Whether to prompt for biometric/PIN check or not.</div>
</b-field>
<b-field label="attestation" horizontal>
<b-checkbox v-model="registration.options.attestation" expanded></b-checkbox>
<div class="hint">
<p>If enabled, the device attestation and clientData will be provided as base64 encoded binary data. Not
available on some platforms.</p>
</div>
</b-field>
<div class="block">
<pre>passwordless.register("{{registration.username}}", "{{registration.challenge}}", {{registration.options}})</pre>
</div>
<b-button type="is-primary" @click="register()">Register device</b-button>
<div v-if="registration.result" class="block">
<pre>{{registration.result}}</pre>
</div>
</section>
<header class="with-big-icon">
<img src="img/icon_authenticate.svg"/>
<h2 class="title">Authentication</h2>
</header>
<b-field label="Credential ID" horizontal custom-class="required">
<b-input v-model="authentication.credentialId" placeholder="Credential ID"></b-input>
<div></div>
</b-field>
<b-field label="Challenge" horizontal custom-class="required">
<b-input v-model="authentication.challenge" placeholder="Challenge"></b-input>
<div class="hint">A server-side randomly generated string, the base64 encoded version will be signed.</div>
</b-field>
<b-field label="authenticatorType" horizontal>
<b-select v-model="authentication.options.authenticatorType" expanded>
<option>auto</option>
<option>local</option>
<option>extern</option>
<option>both</option>
</b-select>
<div class="hint">Which device to use as authenticator.</div>
</b-field>
<b-field label="Timeout" horizontal>
<b-input v-model="authentication.options.timeout" placeholder="60000" expanded></b-input>
<div class="hint">Number of milliseconds the user has to respond to the biometric/PIN check.</div>
</b-field>
<b-field label="UserVerification" horizontal>
<b-select v-model="authentication.options.userVerification" expanded>
<option>required</option>
<option>preferred</option>
<option>discouraged</option>
</b-select>
<div class="hint">Whether to prompt for biometric/PIN check or not.</div>
</b-field>
<pre>passwordless.login(["{{authentication.credentialId}}"], "{{authentication.challenge}}", {{authentication.options}})</pre>
<b-button type="is-primary" @click="login()">Login</b-button>
<pre>{{authentication.result}}</pre>
<header class="with-big-icon">
<img src="img/icon_validate.svg"/>
<h2 class="title">Validation</h2>
</header>
<b-field label="Algorithm" horizontal>
<b-select v-model="verification.algorithm" expanded>
<option>RS256</option>
<option>ES256</option>
</b-select>
<div class="hint">The algorithm used for the public key created during registration.</div>
</b-field>
<b-field label="PublicKey" horizontal>
<b-input v-model="verification.publicKey" type="textarea"></b-input>
<div class="hint">The public key created during registration.</div>
</b-field>
<hr/>
<b-field label="AuthenticatorData" horizontal>
<b-input v-model="verification.authenticatorData" type="textarea"></b-input>
<div class="hint"><pre>{{parseAuthData(verification.authenticatorData)}}</pre></div>
</b-field>
<b-field label="ClientData" horizontal>
<b-input v-model="verification.clientData" type="textarea"></b-input>
<div class="hint"><pre>{{parseClientData(verification.clientData)}}</pre></div>
</b-field>
<b-field label="Signature" horizontal>
<b-input v-model="verification.signature" type="textarea"></b-input>
<div class="hint">
<p>signature = sign(algorithm, publicKey, authenticatorData + sha256(clientData))</p>
</div>
</b-field>
<b-field horizontal>
<b-button @click="verifySignature()">Verify</b-button>
</b-field>
<div class="message" :class="{'is-success': verification.isValid, 'is-danger': !verification.isValid}"
v-if="verification.isValid !== null">
<div class="message-body">
Signature is {{verification.isValid ? 'valid' : 'invalid'}}
</div>
</div>
</main>
<script src="https://unpkg.com/vue@2"></script>
<script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script type="module" src="js/playground.js"></script>
</body>
</html>