File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,15 @@ function formatAsPem(header: string, keyData: ArrayBuffer) {
205
205
return `-----BEGIN ${ header } -----\n${ lines . join ( "\n" ) } \n-----END ${ header } -----` ;
206
206
}
207
207
208
+ /**
209
+ * Imports a CryptoKey from a PEM-formatted string or file.
210
+ *
211
+ * @param {string } keyDataOrPath - The PEM-formatted key data or the path to a file containing the PEM data.
212
+ * @param {SupportedKeyPairAlgorithms } algorithm - The identifier of the key algorithm.
213
+ * @returns {Promise<CryptoKey> } A Promise resolving to the imported CryptoKey.
214
+ * @throws {JWTUnsupportedAlgorithmError } If the specified algorithm is not supported.
215
+ * @throws {JWTFormatError } If the provided keyDataOrPath is not in a valid PEM format.
216
+ */
208
217
export async function importPEMKey ( keyDataOrPath : string , algorithm : SupportedKeyPairAlgorithms ) : Promise < CryptoKey > {
209
218
if ( algorithm === "none" || ! algorithmMapping [ algorithm ] ) {
210
219
throw new JWTUnsupportedAlgorithmError ( "Unsupported key algorithm" ) ;
You can’t perform that action at this time.
0 commit comments