jsonauthtoken 1.0.1 → 3.0.0

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.
@@ -1,26 +0,0 @@
1
- import crypto from 'crypto'
2
- import decoading from './decoading.lib.js';
3
-
4
- const signature = () => {
5
-
6
- const createSign = (algorithm, key, header, payload) => {
7
- const signature = crypto
8
- .createHmac(algorithm, key)
9
- .update(header + '.' + payload)
10
- .digest('base64url');
11
- return signature
12
- }
13
-
14
- const verifySign = (token,key) => {
15
- const [encodedHeader, encodedPayload, signature] = token.split('.');
16
- const header= decoading(encodedHeader)
17
-
18
- let newSign=createSign(header.algorithm, key, encodedHeader, encodedPayload)
19
-
20
- if(newSign == signature) return true
21
- else return false
22
- }
23
- return { createSign, verifySign }
24
- }
25
-
26
- export default signature