File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,9 @@ export default (QUnit: QUnit, lib: typeof jose) => {
120
120
; [ alg , crv ] = alg
121
121
}
122
122
123
+ let x509 = false
123
124
let importFn : typeof lib . importSPKI | typeof lib . importPKCS8 | typeof lib . importX509
124
- let exportFn : typeof lib . exportSPKI | typeof lib . exportPKCS8 | undefined = undefined
125
+ let exportFn : typeof lib . exportSPKI | typeof lib . exportPKCS8
125
126
switch ( true ) {
126
127
case pem . startsWith ( '-----BEGIN PRIVATE KEY-----' ) : {
127
128
importFn = lib . importPKCS8
@@ -135,17 +136,21 @@ export default (QUnit: QUnit, lib: typeof jose) => {
135
136
}
136
137
case pem . startsWith ( '-----BEGIN CERTIFICATE-----' ) : {
137
138
importFn = lib . importX509
139
+ exportFn = lib . exportSPKI
140
+ x509 = true
138
141
break
139
142
}
140
143
default :
141
- continue
144
+ throw new Error ( )
142
145
}
143
146
144
147
const execute = async ( t : typeof QUnit . assert ) => {
145
148
const k = await importFn ( pem , < string > alg , { extractable : true } )
146
149
147
- if ( exportFn ) {
150
+ if ( ! x509 ) {
148
151
t . strictEqual ( normalize ( await exportFn ( k ) ) , normalize ( pem ) )
152
+ } else {
153
+ await exportFn ( k )
149
154
}
150
155
t . ok ( 1 )
151
156
}
You can’t perform that action at this time.
0 commit comments