@@ -37,19 +37,16 @@ <h1>VAPID verification</h1>
3737 < div class ="description "> This is the content of the
3838 < code > Authorization</ code > header included as part of the subscription
3939 POST update.</ div >
40- < textarea name ="auth " placeholder ="Bearer abCDef... "> </ textarea >
40+ < textarea name ="auth " id ="auth " placeholder ="WebPush abCDef... "> </ textarea >
41+ < div class ="v1 ">
4142 < label for ="crypt "> Crypto-Key Header:</ label >
4243 < div class ="description "> This is included
4344 as part of the < code > Crypto-Key</ code > header, which is included
4445 as part of the subscription POST update. < code > Crypto-Key</ code >
4546 may contain more than one part. Each part should be separated by a
4647 comma (",") (NOTE: For Draft-02, this header is not required)</ div >
4748 < textarea name ="crypt " placeholder ="p256ecdsa=abCDef.. "> </ textarea >
48- < div class ="control ">
49- < label for ="publicKey "> Public Key:</ label >
50- < div class ="description "> This is the VAPID key you would use when adding
51- applications to your Dashboard.</ div >
52- < div name ="publicKey " class ="value " > </ div >
49+ </ div >
5350 < button id ="check "> Check headers</ button >
5451</ div >
5552</ div >
@@ -82,14 +79,7 @@ <h1>VAPID verification</h1>
8279 < button id ="gen "> Generate VAPID</ button >
8380 </ div >
8481 < h3 > Claims JSON object:</ h3 >
85- < pre class ="brush: js line-numbers lanuage-js ">
86- < code id ="raw_claims " > None</ code >
87- </ pre >
88- < div id ="ignored " class ="hidden ">
89- < div class ="title "> The following were ignored.
90- < div class ="items "> </ div >
91- </ div >
92- </ div >
82+ < pre class ="brush: js line-numbers lanuage-js "> < code id ="raw_claims " > None</ code > </ pre >
9383</ div >
9484< div id ="keys " class ="section ">
9585 < a name ="export "> < h2 > Exported Keys</ h2 > </ a >
@@ -127,6 +117,26 @@ <h3>Claims JSON object:</h3>
127117 return new VapidToken02 ( ) ;
128118}
129119
120+ function vers_click ( e ) {
121+ if ( document . getElementById ( 'version' ) . getElementsByTagName ( 'input' ) [ 0 ] . checked ) {
122+ document . getElementById ( 'auth' ) . placeholder = "WebPush abCDef..." ;
123+ for ( item of document . getElementsByClassName ( 'v2' ) ) {
124+ item . classList . add ( 'hidden' )
125+ }
126+ for ( item of document . getElementsByClassName ( 'v1' ) ) {
127+ item . classList . remove ( 'hidden' )
128+ }
129+ } else {
130+ document . getElementById ( 'auth' ) . placeholder = "vapid t=abCDef..., k=aBcD..." ;
131+ for ( item of document . getElementsByClassName ( 'v1' ) ) {
132+ item . classList . add ( 'hidden' )
133+ }
134+ for ( item of document . getElementsByClassName ( 'v2' ) ) {
135+ item . classList . remove ( 'hidden' )
136+ }
137+ }
138+ }
139+
130140function error ( ex = null , msg = null , clear = false ) {
131141 let er = document . getElementById ( "err" ) ;
132142 if ( clear ) {
@@ -142,6 +152,7 @@ <h3>Claims JSON object:</h3>
142152}
143153
144154function success ( claims ) {
155+ document . getElementById ( 'raw_claims' ) . innerHTML = JSON . stringify ( claims , null , 2 ) ;
145156 for ( let n of [ "sub" , "exp" ] ) {
146157 let item = document . getElementsByName ( n ) [ 0 ] ;
147158 item . value = claims [ n ] ;
@@ -151,13 +162,6 @@ <h3>Claims JSON object:</h3>
151162 let err = document . getElementById ( "err" ) ;
152163 err . innerHTML = "" ;
153164 err . classList . add ( "hidden" ) ;
154- let extra = JSON . stringify ( claims , " " ) ;
155- if ( extra . length > 2 ) {
156- let ignored = document . getElementsById ( "ignored" ) ;
157- ignored . getElementsByClassName ( "items" )
158- . innerHTML = extra ;
159- ignored . classList . remove ( "hidden" ) ;
160- }
161165}
162166
163167
@@ -304,6 +308,8 @@ <h3>Claims JSON object:</h3>
304308 }
305309}
306310
311+
312+ document . getElementById ( "version" ) . addEventListener ( "click" , vers_click ) ;
307313document . getElementById ( "check" ) . addEventListener ( "click" , check ) ;
308314document . getElementById ( "gen" ) . addEventListener ( "click" , gen ) ;
309315document . getElementById ( 'vapid_exp' ) . value = parseInt ( Date . now ( ) * .001 ) + 86400 ;
0 commit comments