@1auth/crypto 0.0.0-alpha.41 → 0.0.0-alpha.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -283,7 +283,7 @@ export const symetricEncrypt = (
|
|
|
283
283
|
return encryptedDataPacket
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
export const
|
|
286
|
+
export const symmetricDecryptFields = (
|
|
287
287
|
encryptedValues,
|
|
288
288
|
{ encryptedKey, encryptionKey, sub },
|
|
289
289
|
fields = []
|
|
@@ -412,6 +412,7 @@ export const makeSymmetricSignature = (
|
|
|
412
412
|
encryptionKey,
|
|
413
413
|
{ algorithm } = {}
|
|
414
414
|
) => {
|
|
415
|
+
// if (typeof data !== 'string') throw new TypeError('data must me a string')
|
|
415
416
|
encryptionKey ??= options.symetricEncryptionKey
|
|
416
417
|
algorithm ??= options.hmacAlgorithm
|
|
417
418
|
const signature = createHmac('sha256', encryptionKey)
|
|
@@ -427,6 +428,7 @@ export const verifySymmetricSignature = (
|
|
|
427
428
|
encryptionKey,
|
|
428
429
|
{ algorithm } = {}
|
|
429
430
|
) => {
|
|
431
|
+
if (typeof signedData !== 'string') return false
|
|
430
432
|
const data = signedData.slice(0, signedData.lastIndexOf('.'))
|
|
431
433
|
const signedDataExpected = makeSymmetricSignature(data, encryptionKey, {
|
|
432
434
|
algorithm
|