jssign 0.2.1 → 0.2.2
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/README.md +1 -1
- package/build/cjs/index.d.ts +9 -7
- package/build/esm/index.d.ts +9 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ console.log(data) // { foo: 'bar' }
|
|
|
33
33
|
|
|
34
34
|
`options`:
|
|
35
35
|
- `expiresIn` can be a numeric value representing time in ms (no expiration by default).
|
|
36
|
-
- `sl` can be a numberic value representing salt length (default value is `
|
|
36
|
+
- `sl` can be a numberic value representing salt length (default value is `32`). Salt is a random string which is added on top of data to keep the token different everytime even for the same data.
|
|
37
37
|
|
|
38
38
|
### More secure Usage
|
|
39
39
|
For a more secure (but slower) encryption and decryption of data using a secret, `jssign` exports the following functions that uses [sjcl](https://www.npmjs.com/package/sjcl) under the hood:
|
package/build/cjs/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
expiresIn
|
|
3
|
-
sl
|
|
4
|
-
}
|
|
1
|
+
export interface SignOptions {
|
|
2
|
+
expiresIn?: number;
|
|
3
|
+
sl?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface EncryptOptions {
|
|
6
|
+
expiresIn?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function sign(data: any, secret: string, { expiresIn, sl }?: SignOptions): string;
|
|
5
9
|
declare function verify(token: string, secret: string): any;
|
|
6
|
-
declare function encrypt(data: any, secret: string, { expiresIn }?:
|
|
7
|
-
expiresIn: number;
|
|
8
|
-
}>): string;
|
|
10
|
+
declare function encrypt(data: any, secret: string, { expiresIn }?: EncryptOptions): string;
|
|
9
11
|
declare function decrypt(token: string, secret: string): any;
|
|
10
12
|
export { sign, verify, encrypt, decrypt };
|
package/build/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
expiresIn
|
|
3
|
-
sl
|
|
4
|
-
}
|
|
1
|
+
export interface SignOptions {
|
|
2
|
+
expiresIn?: number;
|
|
3
|
+
sl?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface EncryptOptions {
|
|
6
|
+
expiresIn?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function sign(data: any, secret: string, { expiresIn, sl }?: SignOptions): string;
|
|
5
9
|
declare function verify(token: string, secret: string): any;
|
|
6
|
-
declare function encrypt(data: any, secret: string, { expiresIn }?:
|
|
7
|
-
expiresIn: number;
|
|
8
|
-
}>): string;
|
|
10
|
+
declare function encrypt(data: any, secret: string, { expiresIn }?: EncryptOptions): string;
|
|
9
11
|
declare function decrypt(token: string, secret: string): any;
|
|
10
12
|
export { sign, verify, encrypt, decrypt };
|