@twin.org/crypto 0.0.1-next.9 → 0.0.2-next.3
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/dist/cjs/index.cjs +304 -1
- package/dist/esm/index.mjs +304 -3
- package/dist/types/address/bip44.d.ts +15 -0
- package/dist/types/ciphers/rsa.d.ts +63 -0
- package/dist/types/curves/ed25519.d.ts +12 -0
- package/dist/types/helpers/pemHelper.d.ts +19 -0
- package/dist/types/index.d.ts +2 -0
- package/docs/changelog.md +400 -1
- package/docs/reference/classes/Bech32.md +15 -7
- package/docs/reference/classes/Bip32Path.md +17 -9
- package/docs/reference/classes/Bip39.md +28 -12
- package/docs/reference/classes/Bip44.md +121 -21
- package/docs/reference/classes/Blake2b.md +35 -17
- package/docs/reference/classes/Blake3.md +28 -14
- package/docs/reference/classes/ChaCha20Poly1305.md +18 -8
- package/docs/reference/classes/Ed25519.md +65 -9
- package/docs/reference/classes/HmacSha1.md +17 -9
- package/docs/reference/classes/HmacSha256.md +26 -12
- package/docs/reference/classes/HmacSha512.md +38 -16
- package/docs/reference/classes/Hotp.md +9 -5
- package/docs/reference/classes/PasswordGenerator.md +6 -4
- package/docs/reference/classes/PasswordValidator.md +23 -11
- package/docs/reference/classes/Pbkdf2.md +27 -11
- package/docs/reference/classes/PemHelper.md +69 -0
- package/docs/reference/classes/RSA.md +213 -0
- package/docs/reference/classes/Secp256k1.md +21 -9
- package/docs/reference/classes/Sha1.md +11 -7
- package/docs/reference/classes/Sha256.md +17 -9
- package/docs/reference/classes/Sha3.md +23 -11
- package/docs/reference/classes/Sha512.md +23 -11
- package/docs/reference/classes/Slip0010.md +27 -11
- package/docs/reference/classes/Totp.md +42 -16
- package/docs/reference/classes/X25519.md +9 -5
- package/docs/reference/classes/Zip215.md +12 -6
- package/docs/reference/index.md +2 -0
- package/docs/reference/type-aliases/KeyType.md +1 -1
- package/locales/en.json +4 -0
- package/package.json +13 -13
|
@@ -4,13 +4,13 @@ Implementation of Ed25519.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new Ed25519**():
|
|
9
|
+
> **new Ed25519**(): `Ed25519`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`Ed25519`
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
@@ -38,7 +38,9 @@ Public returns the PublicKey corresponding to private.
|
|
|
38
38
|
|
|
39
39
|
#### Parameters
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
##### privateKey
|
|
42
|
+
|
|
43
|
+
`Uint8Array`
|
|
42
44
|
|
|
43
45
|
The private key to get the corresponding public key.
|
|
44
46
|
|
|
@@ -62,11 +64,15 @@ Sign the block with privateKey and returns a signature.
|
|
|
62
64
|
|
|
63
65
|
#### Parameters
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
##### privateKey
|
|
68
|
+
|
|
69
|
+
`Uint8Array`
|
|
66
70
|
|
|
67
71
|
The private key.
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
##### block
|
|
74
|
+
|
|
75
|
+
`Uint8Array`
|
|
70
76
|
|
|
71
77
|
The block to sign.
|
|
72
78
|
|
|
@@ -90,15 +96,21 @@ Verify reports whether sig is a valid signature of block by publicKey.
|
|
|
90
96
|
|
|
91
97
|
#### Parameters
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
##### publicKey
|
|
100
|
+
|
|
101
|
+
`Uint8Array`
|
|
94
102
|
|
|
95
103
|
The public key to verify the signature.
|
|
96
104
|
|
|
97
|
-
|
|
105
|
+
##### block
|
|
106
|
+
|
|
107
|
+
`Uint8Array`
|
|
98
108
|
|
|
99
109
|
The block for the signature.
|
|
100
110
|
|
|
101
|
-
|
|
111
|
+
##### signature
|
|
112
|
+
|
|
113
|
+
`Uint8Array`
|
|
102
114
|
|
|
103
115
|
The signature.
|
|
104
116
|
|
|
@@ -111,3 +123,47 @@ True if the signature matches.
|
|
|
111
123
|
#### Throws
|
|
112
124
|
|
|
113
125
|
Error if the public key is not the correct length.
|
|
126
|
+
|
|
127
|
+
***
|
|
128
|
+
|
|
129
|
+
### privateKeyToPkcs8()
|
|
130
|
+
|
|
131
|
+
> `static` **privateKeyToPkcs8**(`privateKey`): `Promise`\<`CryptoKey`\>
|
|
132
|
+
|
|
133
|
+
Convert a private key in PKCS8 format.
|
|
134
|
+
|
|
135
|
+
#### Parameters
|
|
136
|
+
|
|
137
|
+
##### privateKey
|
|
138
|
+
|
|
139
|
+
`Uint8Array`
|
|
140
|
+
|
|
141
|
+
The private key to convert.
|
|
142
|
+
|
|
143
|
+
#### Returns
|
|
144
|
+
|
|
145
|
+
`Promise`\<`CryptoKey`\>
|
|
146
|
+
|
|
147
|
+
The private key in PKCS8 format.
|
|
148
|
+
|
|
149
|
+
***
|
|
150
|
+
|
|
151
|
+
### pkcs8ToPrivateKey()
|
|
152
|
+
|
|
153
|
+
> `static` **pkcs8ToPrivateKey**(`cryptoKey`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
|
|
154
|
+
|
|
155
|
+
Convert a crypto key to raw private key.
|
|
156
|
+
|
|
157
|
+
#### Parameters
|
|
158
|
+
|
|
159
|
+
##### cryptoKey
|
|
160
|
+
|
|
161
|
+
`CryptoKey`
|
|
162
|
+
|
|
163
|
+
The crypto key to convert.
|
|
164
|
+
|
|
165
|
+
#### Returns
|
|
166
|
+
|
|
167
|
+
`Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
|
|
168
|
+
|
|
169
|
+
The raw private key.
|
|
@@ -4,21 +4,23 @@ Class to help with HmacSha1 scheme.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new HmacSha1**(`key`):
|
|
9
|
+
> **new HmacSha1**(`key`): `HmacSha1`
|
|
10
10
|
|
|
11
11
|
Create a new instance of HmacSha1.
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
##### key
|
|
16
|
+
|
|
17
|
+
`Uint8Array`
|
|
16
18
|
|
|
17
19
|
The key for the hmac.
|
|
18
20
|
|
|
19
21
|
#### Returns
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
`HmacSha1`
|
|
22
24
|
|
|
23
25
|
## Methods
|
|
24
26
|
|
|
@@ -30,11 +32,15 @@ Perform Sum on the block.
|
|
|
30
32
|
|
|
31
33
|
#### Parameters
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
##### key
|
|
36
|
+
|
|
37
|
+
`Uint8Array`
|
|
34
38
|
|
|
35
39
|
The key for the hmac.
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
##### block
|
|
42
|
+
|
|
43
|
+
`Uint8Array`
|
|
38
44
|
|
|
39
45
|
The block to operate on.
|
|
40
46
|
|
|
@@ -48,19 +54,21 @@ The sum of the block.
|
|
|
48
54
|
|
|
49
55
|
### update()
|
|
50
56
|
|
|
51
|
-
> **update**(`block`):
|
|
57
|
+
> **update**(`block`): `HmacSha1`
|
|
52
58
|
|
|
53
59
|
Update the hash with the block.
|
|
54
60
|
|
|
55
61
|
#### Parameters
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
##### block
|
|
64
|
+
|
|
65
|
+
`Uint8Array`
|
|
58
66
|
|
|
59
67
|
The block to update the hash with.
|
|
60
68
|
|
|
61
69
|
#### Returns
|
|
62
70
|
|
|
63
|
-
|
|
71
|
+
`HmacSha1`
|
|
64
72
|
|
|
65
73
|
The instance for chaining.
|
|
66
74
|
|
|
@@ -4,25 +4,29 @@ Class to help with HmacSha256 scheme.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new HmacSha256**(`key`, `bits`):
|
|
9
|
+
> **new HmacSha256**(`key`, `bits`): `HmacSha256`
|
|
10
10
|
|
|
11
11
|
Create a new instance of HmacSha256.
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
##### key
|
|
16
|
+
|
|
17
|
+
`Uint8Array`
|
|
16
18
|
|
|
17
19
|
The key for the hmac.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
##### bits
|
|
22
|
+
|
|
23
|
+
`number` = `HmacSha256.SIZE_256`
|
|
20
24
|
|
|
21
25
|
The number of bits.
|
|
22
26
|
|
|
23
27
|
#### Returns
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
`HmacSha256`
|
|
26
30
|
|
|
27
31
|
## Properties
|
|
28
32
|
|
|
@@ -50,11 +54,15 @@ Perform Sum 224 on the block.
|
|
|
50
54
|
|
|
51
55
|
#### Parameters
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
##### key
|
|
58
|
+
|
|
59
|
+
`Uint8Array`
|
|
54
60
|
|
|
55
61
|
The key for the hmac.
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
##### block
|
|
64
|
+
|
|
65
|
+
`Uint8Array`
|
|
58
66
|
|
|
59
67
|
The block to operate on.
|
|
60
68
|
|
|
@@ -74,11 +82,15 @@ Perform Sum 256 on the block.
|
|
|
74
82
|
|
|
75
83
|
#### Parameters
|
|
76
84
|
|
|
77
|
-
|
|
85
|
+
##### key
|
|
86
|
+
|
|
87
|
+
`Uint8Array`
|
|
78
88
|
|
|
79
89
|
The key for the hmac.
|
|
80
90
|
|
|
81
|
-
|
|
91
|
+
##### block
|
|
92
|
+
|
|
93
|
+
`Uint8Array`
|
|
82
94
|
|
|
83
95
|
The block to operate on.
|
|
84
96
|
|
|
@@ -92,19 +104,21 @@ The sum 256 of the block.
|
|
|
92
104
|
|
|
93
105
|
### update()
|
|
94
106
|
|
|
95
|
-
> **update**(`block`):
|
|
107
|
+
> **update**(`block`): `HmacSha256`
|
|
96
108
|
|
|
97
109
|
Update the hash with the block.
|
|
98
110
|
|
|
99
111
|
#### Parameters
|
|
100
112
|
|
|
101
|
-
|
|
113
|
+
##### block
|
|
114
|
+
|
|
115
|
+
`Uint8Array`
|
|
102
116
|
|
|
103
117
|
The block to update the hash with.
|
|
104
118
|
|
|
105
119
|
#### Returns
|
|
106
120
|
|
|
107
|
-
|
|
121
|
+
`HmacSha256`
|
|
108
122
|
|
|
109
123
|
The instance for chaining.
|
|
110
124
|
|
|
@@ -4,25 +4,29 @@ Class to help with HmacSha512 scheme.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new HmacSha512**(`key`, `bits`):
|
|
9
|
+
> **new HmacSha512**(`key`, `bits`): `HmacSha512`
|
|
10
10
|
|
|
11
11
|
Create a new instance of HmacSha512.
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
##### key
|
|
16
|
+
|
|
17
|
+
`Uint8Array`
|
|
16
18
|
|
|
17
19
|
The key for the hmac.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
##### bits
|
|
22
|
+
|
|
23
|
+
`number` = `HmacSha512.SIZE_512`
|
|
20
24
|
|
|
21
25
|
The number of bits.
|
|
22
26
|
|
|
23
27
|
#### Returns
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
`HmacSha512`
|
|
26
30
|
|
|
27
31
|
## Properties
|
|
28
32
|
|
|
@@ -66,11 +70,15 @@ Perform Sum 512 on the block.
|
|
|
66
70
|
|
|
67
71
|
#### Parameters
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
##### key
|
|
74
|
+
|
|
75
|
+
`Uint8Array`
|
|
70
76
|
|
|
71
77
|
The key for the hmac.
|
|
72
78
|
|
|
73
|
-
|
|
79
|
+
##### block
|
|
80
|
+
|
|
81
|
+
`Uint8Array`
|
|
74
82
|
|
|
75
83
|
The block to operate on.
|
|
76
84
|
|
|
@@ -90,11 +98,15 @@ Perform Sum 384 on the block.
|
|
|
90
98
|
|
|
91
99
|
#### Parameters
|
|
92
100
|
|
|
93
|
-
|
|
101
|
+
##### key
|
|
102
|
+
|
|
103
|
+
`Uint8Array`
|
|
94
104
|
|
|
95
105
|
The key for the hmac.
|
|
96
106
|
|
|
97
|
-
|
|
107
|
+
##### block
|
|
108
|
+
|
|
109
|
+
`Uint8Array`
|
|
98
110
|
|
|
99
111
|
The block to operate on.
|
|
100
112
|
|
|
@@ -114,11 +126,15 @@ Perform Sum 256 on the block.
|
|
|
114
126
|
|
|
115
127
|
#### Parameters
|
|
116
128
|
|
|
117
|
-
|
|
129
|
+
##### key
|
|
130
|
+
|
|
131
|
+
`Uint8Array`
|
|
118
132
|
|
|
119
133
|
The key for the hmac.
|
|
120
134
|
|
|
121
|
-
|
|
135
|
+
##### block
|
|
136
|
+
|
|
137
|
+
`Uint8Array`
|
|
122
138
|
|
|
123
139
|
The block to operate on.
|
|
124
140
|
|
|
@@ -138,11 +154,15 @@ Perform Sum 224 on the block.
|
|
|
138
154
|
|
|
139
155
|
#### Parameters
|
|
140
156
|
|
|
141
|
-
|
|
157
|
+
##### key
|
|
158
|
+
|
|
159
|
+
`Uint8Array`
|
|
142
160
|
|
|
143
161
|
The key for the hmac.
|
|
144
162
|
|
|
145
|
-
|
|
163
|
+
##### block
|
|
164
|
+
|
|
165
|
+
`Uint8Array`
|
|
146
166
|
|
|
147
167
|
The block to operate on.
|
|
148
168
|
|
|
@@ -156,19 +176,21 @@ The sum 224 of the block.
|
|
|
156
176
|
|
|
157
177
|
### update()
|
|
158
178
|
|
|
159
|
-
> **update**(`block`):
|
|
179
|
+
> **update**(`block`): `HmacSha512`
|
|
160
180
|
|
|
161
181
|
Update the hash with the block.
|
|
162
182
|
|
|
163
183
|
#### Parameters
|
|
164
184
|
|
|
165
|
-
|
|
185
|
+
##### block
|
|
186
|
+
|
|
187
|
+
`Uint8Array`
|
|
166
188
|
|
|
167
189
|
The block to update the hash with.
|
|
168
190
|
|
|
169
191
|
#### Returns
|
|
170
192
|
|
|
171
|
-
|
|
193
|
+
`HmacSha512`
|
|
172
194
|
|
|
173
195
|
The instance for chaining.
|
|
174
196
|
|
|
@@ -5,13 +5,13 @@ Implementation of https://datatracker.ietf.org/doc/html/rfc4226 .
|
|
|
5
5
|
|
|
6
6
|
## Constructors
|
|
7
7
|
|
|
8
|
-
###
|
|
8
|
+
### Constructor
|
|
9
9
|
|
|
10
|
-
> **new Hotp**():
|
|
10
|
+
> **new Hotp**(): `Hotp`
|
|
11
11
|
|
|
12
12
|
#### Returns
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
`Hotp`
|
|
15
15
|
|
|
16
16
|
## Methods
|
|
17
17
|
|
|
@@ -23,11 +23,15 @@ Generate a counter based One Time Password.
|
|
|
23
23
|
|
|
24
24
|
#### Parameters
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
##### key
|
|
27
|
+
|
|
28
|
+
`Uint8Array`
|
|
27
29
|
|
|
28
30
|
Key for the one time password.
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
##### counter
|
|
33
|
+
|
|
34
|
+
`number`
|
|
31
35
|
|
|
32
36
|
This should be stored by the application,
|
|
33
37
|
must be user specific, and be incremented for each request.
|
|
@@ -4,13 +4,13 @@ Generate random passwords.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new PasswordGenerator**():
|
|
9
|
+
> **new PasswordGenerator**(): `PasswordGenerator`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`PasswordGenerator`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
@@ -22,7 +22,9 @@ Generate a password of given length.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### length
|
|
26
|
+
|
|
27
|
+
`number`
|
|
26
28
|
|
|
27
29
|
The length of the password to generate.
|
|
28
30
|
|
|
@@ -5,49 +5,61 @@ Ref https://www.owasp.org/index.php/Authentication_Cheat_Sheet#Implement_Proper_
|
|
|
5
5
|
|
|
6
6
|
## Constructors
|
|
7
7
|
|
|
8
|
-
###
|
|
8
|
+
### Constructor
|
|
9
9
|
|
|
10
|
-
> **new PasswordValidator**():
|
|
10
|
+
> **new PasswordValidator**(): `PasswordValidator`
|
|
11
11
|
|
|
12
12
|
#### Returns
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
`PasswordValidator`
|
|
15
15
|
|
|
16
16
|
## Methods
|
|
17
17
|
|
|
18
18
|
### validate()
|
|
19
19
|
|
|
20
|
-
> `static` **validate**(`property`, `password`, `failures`, `options
|
|
20
|
+
> `static` **validate**(`property`, `password`, `failures`, `options?`): `void`
|
|
21
21
|
|
|
22
22
|
Test the strength of the password.
|
|
23
23
|
|
|
24
24
|
#### Parameters
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
##### property
|
|
27
|
+
|
|
28
|
+
`string`
|
|
27
29
|
|
|
28
30
|
The name of the property.
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
##### password
|
|
33
|
+
|
|
34
|
+
`string`
|
|
31
35
|
|
|
32
36
|
The password to test.
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
##### failures
|
|
39
|
+
|
|
40
|
+
`IValidationFailure`[]
|
|
35
41
|
|
|
36
42
|
The list of failures to add to.
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
##### options?
|
|
39
45
|
|
|
40
46
|
Options to configure the testing.
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
###### minLength?
|
|
49
|
+
|
|
50
|
+
`number`
|
|
43
51
|
|
|
44
52
|
The minimum length of the password, defaults to 8.
|
|
45
53
|
|
|
46
|
-
|
|
54
|
+
###### maxLength?
|
|
55
|
+
|
|
56
|
+
`number`
|
|
47
57
|
|
|
48
58
|
The minimum length of the password, defaults to 128.
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
###### minPhraseLength?
|
|
61
|
+
|
|
62
|
+
`number`
|
|
51
63
|
|
|
52
64
|
The minimum length of the password for it to be considered a pass phrase.
|
|
53
65
|
|
|
@@ -4,13 +4,13 @@ Implementation of the password based key derivation function 2.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new Pbkdf2**():
|
|
9
|
+
> **new Pbkdf2**(): `Pbkdf2`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`Pbkdf2`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
@@ -22,19 +22,27 @@ Derive a key from the parameters using Sha256.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### password
|
|
26
|
+
|
|
27
|
+
`Uint8Array`
|
|
26
28
|
|
|
27
29
|
The password to derive the key from.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### salt
|
|
32
|
+
|
|
33
|
+
`Uint8Array`
|
|
30
34
|
|
|
31
35
|
The salt for the derivation.
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
##### iterations
|
|
38
|
+
|
|
39
|
+
`number`
|
|
34
40
|
|
|
35
41
|
Number of iterations to perform.
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
##### keyLength
|
|
44
|
+
|
|
45
|
+
`number`
|
|
38
46
|
|
|
39
47
|
The length of the key to derive.
|
|
40
48
|
|
|
@@ -54,19 +62,27 @@ Derive a key from the parameters using Sha512.
|
|
|
54
62
|
|
|
55
63
|
#### Parameters
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
##### password
|
|
66
|
+
|
|
67
|
+
`Uint8Array`
|
|
58
68
|
|
|
59
69
|
The password to derive the key from.
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
##### salt
|
|
72
|
+
|
|
73
|
+
`Uint8Array`
|
|
62
74
|
|
|
63
75
|
The salt for the derivation.
|
|
64
76
|
|
|
65
|
-
|
|
77
|
+
##### iterations
|
|
78
|
+
|
|
79
|
+
`number`
|
|
66
80
|
|
|
67
81
|
Number of iterations to perform.
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
##### keyLength
|
|
84
|
+
|
|
85
|
+
`number`
|
|
70
86
|
|
|
71
87
|
The length of the key to derive.
|
|
72
88
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Class: PemHelper
|
|
2
|
+
|
|
3
|
+
Helper class for working with PEM (Privacy-Enhanced Mail) formatted data.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new PemHelper**(): `PemHelper`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`PemHelper`
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### stripPemMarkers()
|
|
18
|
+
|
|
19
|
+
> `static` **stripPemMarkers**(`pemContent`): `string`
|
|
20
|
+
|
|
21
|
+
Strip the PEM content of its headers, footers, and newlines.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
##### pemContent
|
|
26
|
+
|
|
27
|
+
`string`
|
|
28
|
+
|
|
29
|
+
The PEM content to strip.
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`string`
|
|
34
|
+
|
|
35
|
+
The stripped PEM content in bas64 format.
|
|
36
|
+
|
|
37
|
+
***
|
|
38
|
+
|
|
39
|
+
### formatPem()
|
|
40
|
+
|
|
41
|
+
> `static` **formatPem**(`marker`, `base64Content`, `lineLength`): `string`
|
|
42
|
+
|
|
43
|
+
Format the PEM content to have a specific line length.
|
|
44
|
+
|
|
45
|
+
#### Parameters
|
|
46
|
+
|
|
47
|
+
##### marker
|
|
48
|
+
|
|
49
|
+
`string`
|
|
50
|
+
|
|
51
|
+
The marker for the PEM content, e.g. RSA PRIVATE KEY
|
|
52
|
+
|
|
53
|
+
##### base64Content
|
|
54
|
+
|
|
55
|
+
`string`
|
|
56
|
+
|
|
57
|
+
The base64 content to format.
|
|
58
|
+
|
|
59
|
+
##### lineLength
|
|
60
|
+
|
|
61
|
+
`number` = `64`
|
|
62
|
+
|
|
63
|
+
The length of each line in the PEM content, default is 64 characters.
|
|
64
|
+
|
|
65
|
+
#### Returns
|
|
66
|
+
|
|
67
|
+
`string`
|
|
68
|
+
|
|
69
|
+
The formatted PEM content.
|