@twin.org/crypto 0.0.1-next.2 → 0.0.1-next.21
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 +218 -0
- package/dist/esm/index.mjs +217 -1
- package/dist/types/address/bip44.d.ts +15 -0
- package/dist/types/hashes/blake3.d.ts +44 -0
- package/dist/types/hashes/sha3.d.ts +61 -0
- package/dist/types/index.d.ts +2 -0
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/Bech32.md +12 -4
- package/docs/reference/classes/Bip32Path.md +12 -4
- package/docs/reference/classes/Bip39.md +24 -8
- package/docs/reference/classes/Bip44.md +118 -18
- package/docs/reference/classes/Blake2b.md +27 -9
- package/docs/reference/classes/Blake3.md +137 -0
- package/docs/reference/classes/ChaCha20Poly1305.md +15 -5
- package/docs/reference/classes/Ed25519.md +18 -6
- package/docs/reference/classes/HmacSha1.md +12 -4
- package/docs/reference/classes/HmacSha256.md +21 -7
- package/docs/reference/classes/HmacSha512.md +33 -11
- package/docs/reference/classes/Hotp.md +6 -2
- package/docs/reference/classes/PasswordGenerator.md +3 -1
- package/docs/reference/classes/PasswordValidator.md +19 -7
- package/docs/reference/classes/Pbkdf2.md +24 -8
- package/docs/reference/classes/Secp256k1.md +18 -6
- package/docs/reference/classes/Sha1.md +6 -2
- package/docs/reference/classes/Sha256.md +12 -4
- package/docs/reference/classes/Sha3.md +179 -0
- package/docs/reference/classes/Sha512.md +18 -6
- package/docs/reference/classes/Slip0010.md +24 -8
- package/docs/reference/classes/Totp.md +39 -13
- package/docs/reference/classes/X25519.md +6 -2
- package/docs/reference/classes/Zip215.md +9 -3
- package/docs/reference/index.md +2 -0
- package/locales/en.json +3 -6
- package/package.json +10 -36
|
@@ -23,11 +23,15 @@ Get the master key from the seed.
|
|
|
23
23
|
|
|
24
24
|
#### Parameters
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
##### seed
|
|
27
|
+
|
|
28
|
+
`Uint8Array`
|
|
27
29
|
|
|
28
30
|
The seed to generate the master key from.
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
##### keyType
|
|
33
|
+
|
|
34
|
+
[`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
|
|
31
35
|
|
|
32
36
|
The key type.
|
|
33
37
|
|
|
@@ -59,15 +63,21 @@ Derive a key from the path.
|
|
|
59
63
|
|
|
60
64
|
#### Parameters
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
##### seed
|
|
67
|
+
|
|
68
|
+
`Uint8Array`
|
|
63
69
|
|
|
64
70
|
The seed.
|
|
65
71
|
|
|
66
|
-
|
|
72
|
+
##### path
|
|
73
|
+
|
|
74
|
+
[`Bip32Path`](Bip32Path.md)
|
|
67
75
|
|
|
68
76
|
The path.
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
##### keyType
|
|
79
|
+
|
|
80
|
+
[`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
|
|
71
81
|
|
|
72
82
|
The key type.
|
|
73
83
|
|
|
@@ -95,15 +105,21 @@ Get the public key from the private key.
|
|
|
95
105
|
|
|
96
106
|
#### Parameters
|
|
97
107
|
|
|
98
|
-
|
|
108
|
+
##### privateKey
|
|
109
|
+
|
|
110
|
+
`Uint8Array`
|
|
99
111
|
|
|
100
112
|
The private key.
|
|
101
113
|
|
|
102
|
-
|
|
114
|
+
##### keyType
|
|
115
|
+
|
|
116
|
+
[`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
|
|
103
117
|
|
|
104
118
|
The key type.
|
|
105
119
|
|
|
106
|
-
|
|
120
|
+
##### withZeroByte
|
|
121
|
+
|
|
122
|
+
`boolean` = `true`
|
|
107
123
|
|
|
108
124
|
Include a zero bute prefix.
|
|
109
125
|
|
|
@@ -23,15 +23,21 @@ Generate a time 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
|
+
##### interval
|
|
33
|
+
|
|
34
|
+
`number` = `30`
|
|
31
35
|
|
|
32
36
|
The time step of the counter.
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
##### timestamp
|
|
39
|
+
|
|
40
|
+
`number` = `...`
|
|
35
41
|
|
|
36
42
|
The timestamp.
|
|
37
43
|
|
|
@@ -51,24 +57,34 @@ Check a One Time Password based on a timer.
|
|
|
51
57
|
|
|
52
58
|
#### Parameters
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
##### token
|
|
61
|
+
|
|
62
|
+
`string`
|
|
55
63
|
|
|
56
64
|
Passcode to validate.
|
|
57
65
|
|
|
58
|
-
|
|
66
|
+
##### key
|
|
67
|
+
|
|
68
|
+
`Uint8Array`
|
|
59
69
|
|
|
60
70
|
Key for the one time password. This should be unique and secret for
|
|
61
71
|
every user as it is the seed used to calculate the HMAC.
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
##### window
|
|
74
|
+
|
|
75
|
+
`number` = `2`
|
|
64
76
|
|
|
65
77
|
The allowable margin for the counter.
|
|
66
78
|
|
|
67
|
-
|
|
79
|
+
##### interval
|
|
80
|
+
|
|
81
|
+
`number` = `30`
|
|
68
82
|
|
|
69
83
|
The time step of the counter.
|
|
70
84
|
|
|
71
|
-
|
|
85
|
+
##### timestamp
|
|
86
|
+
|
|
87
|
+
`number` = `...`
|
|
72
88
|
|
|
73
89
|
The timestamp now.
|
|
74
90
|
|
|
@@ -88,7 +104,9 @@ Generate a secret.
|
|
|
88
104
|
|
|
89
105
|
#### Parameters
|
|
90
106
|
|
|
91
|
-
|
|
107
|
+
##### length
|
|
108
|
+
|
|
109
|
+
`number`
|
|
92
110
|
|
|
93
111
|
The length of the secret to generate.
|
|
94
112
|
|
|
@@ -108,7 +126,9 @@ Convert the secret back to bytes.
|
|
|
108
126
|
|
|
109
127
|
#### Parameters
|
|
110
128
|
|
|
111
|
-
|
|
129
|
+
##### secretBase32
|
|
130
|
+
|
|
131
|
+
`string`
|
|
112
132
|
|
|
113
133
|
The secret encoded as base32.
|
|
114
134
|
|
|
@@ -129,15 +149,21 @@ See https://github.com/google/google-authenticator/wiki/Key-Uri-Format .
|
|
|
129
149
|
|
|
130
150
|
#### Parameters
|
|
131
151
|
|
|
132
|
-
|
|
152
|
+
##### issuer
|
|
153
|
+
|
|
154
|
+
`string`
|
|
133
155
|
|
|
134
156
|
The issuer of the totp.
|
|
135
157
|
|
|
136
|
-
|
|
158
|
+
##### label
|
|
159
|
+
|
|
160
|
+
`string`
|
|
137
161
|
|
|
138
162
|
The label that will show in auth apps.
|
|
139
163
|
|
|
140
|
-
|
|
164
|
+
##### secretBase32
|
|
165
|
+
|
|
166
|
+
`string`
|
|
141
167
|
|
|
142
168
|
The secret as base 32.
|
|
143
169
|
|
|
@@ -22,7 +22,9 @@ Convert Ed25519 private key to X25519 private key.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### ed25519PrivateKey
|
|
26
|
+
|
|
27
|
+
`Uint8Array`
|
|
26
28
|
|
|
27
29
|
The ed25519 private key to convert.
|
|
28
30
|
|
|
@@ -42,7 +44,9 @@ Convert Ed25519 public key to X25519 public key.
|
|
|
42
44
|
|
|
43
45
|
#### Parameters
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
##### ed25519PublicKey
|
|
48
|
+
|
|
49
|
+
`Uint8Array`
|
|
46
50
|
|
|
47
51
|
The ed25519 public key to convert.
|
|
48
52
|
|
|
@@ -24,15 +24,21 @@ for use in consensus-critical contexts.
|
|
|
24
24
|
|
|
25
25
|
#### Parameters
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
##### publicKey
|
|
28
|
+
|
|
29
|
+
`Uint8Array`
|
|
28
30
|
|
|
29
31
|
The public key for the block.
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
##### block
|
|
34
|
+
|
|
35
|
+
`Uint8Array`
|
|
32
36
|
|
|
33
37
|
The block content to validate.
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
##### sig
|
|
40
|
+
|
|
41
|
+
`Uint8Array`
|
|
36
42
|
|
|
37
43
|
The signature to verify.
|
|
38
44
|
|
package/docs/reference/index.md
CHANGED
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
- [X25519](classes/X25519.md)
|
|
11
11
|
- [Zip215](classes/Zip215.md)
|
|
12
12
|
- [Blake2b](classes/Blake2b.md)
|
|
13
|
+
- [Blake3](classes/Blake3.md)
|
|
13
14
|
- [HmacSha1](classes/HmacSha1.md)
|
|
14
15
|
- [HmacSha256](classes/HmacSha256.md)
|
|
15
16
|
- [HmacSha512](classes/HmacSha512.md)
|
|
16
17
|
- [Pbkdf2](classes/Pbkdf2.md)
|
|
17
18
|
- [Sha1](classes/Sha1.md)
|
|
18
19
|
- [Sha256](classes/Sha256.md)
|
|
20
|
+
- [Sha3](classes/Sha3.md)
|
|
19
21
|
- [Sha512](classes/Sha512.md)
|
|
20
22
|
- [Bip32Path](classes/Bip32Path.md)
|
|
21
23
|
- [Bip39](classes/Bip39.md)
|
package/locales/en.json
CHANGED
|
@@ -31,18 +31,15 @@
|
|
|
31
31
|
"sha256": {
|
|
32
32
|
"bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
|
|
33
33
|
},
|
|
34
|
+
"sha3": {
|
|
35
|
+
"bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
|
|
36
|
+
},
|
|
34
37
|
"hmacSha256": {
|
|
35
38
|
"bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
|
|
36
39
|
},
|
|
37
40
|
"hmacSha512": {
|
|
38
41
|
"bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
|
|
39
42
|
},
|
|
40
|
-
"base32": {
|
|
41
|
-
"invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
|
|
42
|
-
},
|
|
43
|
-
"base64": {
|
|
44
|
-
"length4Multiple": "Invalid length should be a multiple of 4, it is \"{value}\""
|
|
45
|
-
},
|
|
46
43
|
"bech32": {
|
|
47
44
|
"decodeFailed": "The address contains decoding failed for address \"{bech32}\"",
|
|
48
45
|
"invalidChecksum": "The address contains an invalid checksum in address, \"{bech32}\"",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/crypto",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.21",
|
|
4
4
|
"description": "Contains helper methods and classes which implement cryptographic functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,42 +13,16 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist coverage docs/reference",
|
|
18
|
-
"build": "tspc",
|
|
19
|
-
"test": "vitest --run --config ./vitest.config.ts --no-cache",
|
|
20
|
-
"coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
|
|
21
|
-
"bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
|
|
22
|
-
"bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
|
|
23
|
-
"bundle": "npm run bundle:esm && npm run bundle:cjs",
|
|
24
|
-
"docs:clean": "rimraf docs/reference",
|
|
25
|
-
"docs:generate": "typedoc",
|
|
26
|
-
"docs": "npm run docs:clean && npm run docs:generate",
|
|
27
|
-
"dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
|
|
28
|
-
},
|
|
29
16
|
"dependencies": {
|
|
30
|
-
"@
|
|
17
|
+
"@noble/ciphers": "1.2.0",
|
|
18
|
+
"@noble/curves": "1.8.0",
|
|
19
|
+
"@noble/hashes": "1.7.0",
|
|
20
|
+
"@scure/base": "1.2.1",
|
|
21
|
+
"@scure/bip32": "1.6.1",
|
|
22
|
+
"@scure/bip39": "1.5.1",
|
|
23
|
+
"@twin.org/core": "0.0.1-next.21",
|
|
31
24
|
"@twin.org/nameof": "next",
|
|
32
|
-
"
|
|
33
|
-
"@noble/curves": "1.6.0",
|
|
34
|
-
"@noble/hashes": "1.5.0",
|
|
35
|
-
"@scure/base": "1.1.9",
|
|
36
|
-
"@scure/bip32": "1.5.0",
|
|
37
|
-
"@scure/bip39": "1.4.0",
|
|
38
|
-
"micro-key-producer": "0.7.0"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@twin.org/nameof-transformer": "next",
|
|
42
|
-
"@vitest/coverage-v8": "2.1.1",
|
|
43
|
-
"copyfiles": "2.4.1",
|
|
44
|
-
"rimraf": "6.0.1",
|
|
45
|
-
"rollup": "4.21.3",
|
|
46
|
-
"rollup-plugin-typescript2": "0.36.0",
|
|
47
|
-
"ts-patch": "3.2.1",
|
|
48
|
-
"typedoc": "0.26.7",
|
|
49
|
-
"typedoc-plugin-markdown": "4.2.7",
|
|
50
|
-
"typescript": "5.6.2",
|
|
51
|
-
"vitest": "2.1.1"
|
|
25
|
+
"micro-key-producer": "0.7.3"
|
|
52
26
|
},
|
|
53
27
|
"main": "./dist/cjs/index.cjs",
|
|
54
28
|
"module": "./dist/esm/index.mjs",
|
|
@@ -59,7 +33,7 @@
|
|
|
59
33
|
"import": "./dist/esm/index.mjs",
|
|
60
34
|
"types": "./dist/types/index.d.ts"
|
|
61
35
|
},
|
|
62
|
-
"./locales": "./locales"
|
|
36
|
+
"./locales/*.json": "./locales/*.json"
|
|
63
37
|
},
|
|
64
38
|
"files": [
|
|
65
39
|
"dist/cjs",
|