@twin.org/crypto 0.0.2-next.7 → 0.0.2-next.9
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 +16 -0
- package/dist/esm/index.mjs +16 -0
- package/dist/types/keys/bip39.d.ts +8 -0
- package/docs/changelog.md +36 -0
- package/docs/reference/classes/Bip39.md +34 -0
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -1626,6 +1626,22 @@ class Bip39 {
|
|
|
1626
1626
|
core.Guards.arrayValue(Bip39._CLASS_NAME, "words", words);
|
|
1627
1627
|
return bip39__namespace.mnemonicToEntropy(mnemonic, words);
|
|
1628
1628
|
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Validate the mnemonic.
|
|
1631
|
+
* @param mnemonic The mnemonic to validate.
|
|
1632
|
+
* @param wordCount The expected number of words in the mnemonic, defaults to 24.
|
|
1633
|
+
* @param words The wordlist to use, defaults to the English wordlist.
|
|
1634
|
+
* @returns True if the mnemonic is valid.
|
|
1635
|
+
*/
|
|
1636
|
+
static validateMnemonic(mnemonic, wordCount = 24, words = english_js.wordlist) {
|
|
1637
|
+
core.Guards.string(Bip39._CLASS_NAME, "mnemonic", mnemonic);
|
|
1638
|
+
core.Guards.integer(Bip39._CLASS_NAME, "wordCount", wordCount);
|
|
1639
|
+
const mnemonicSplit = mnemonic.split(/\s+/);
|
|
1640
|
+
if (mnemonicSplit.length !== wordCount) {
|
|
1641
|
+
return false;
|
|
1642
|
+
}
|
|
1643
|
+
return bip39__namespace.validateMnemonic(mnemonic, words);
|
|
1644
|
+
}
|
|
1629
1645
|
}
|
|
1630
1646
|
|
|
1631
1647
|
// Copyright 2024 IOTA Stiftung.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1604,6 +1604,22 @@ class Bip39 {
|
|
|
1604
1604
|
Guards.arrayValue(Bip39._CLASS_NAME, "words", words);
|
|
1605
1605
|
return bip39.mnemonicToEntropy(mnemonic, words);
|
|
1606
1606
|
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Validate the mnemonic.
|
|
1609
|
+
* @param mnemonic The mnemonic to validate.
|
|
1610
|
+
* @param wordCount The expected number of words in the mnemonic, defaults to 24.
|
|
1611
|
+
* @param words The wordlist to use, defaults to the English wordlist.
|
|
1612
|
+
* @returns True if the mnemonic is valid.
|
|
1613
|
+
*/
|
|
1614
|
+
static validateMnemonic(mnemonic, wordCount = 24, words = wordlist) {
|
|
1615
|
+
Guards.string(Bip39._CLASS_NAME, "mnemonic", mnemonic);
|
|
1616
|
+
Guards.integer(Bip39._CLASS_NAME, "wordCount", wordCount);
|
|
1617
|
+
const mnemonicSplit = mnemonic.split(/\s+/);
|
|
1618
|
+
if (mnemonicSplit.length !== wordCount) {
|
|
1619
|
+
return false;
|
|
1620
|
+
}
|
|
1621
|
+
return bip39.validateMnemonic(mnemonic, words);
|
|
1622
|
+
}
|
|
1607
1623
|
}
|
|
1608
1624
|
|
|
1609
1625
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -33,4 +33,12 @@ export declare class Bip39 {
|
|
|
33
33
|
* @throws Error if the number of words is not a multiple of 3.
|
|
34
34
|
*/
|
|
35
35
|
static mnemonicToEntropy(mnemonic: string, words?: string[]): Uint8Array;
|
|
36
|
+
/**
|
|
37
|
+
* Validate the mnemonic.
|
|
38
|
+
* @param mnemonic The mnemonic to validate.
|
|
39
|
+
* @param wordCount The expected number of words in the mnemonic, defaults to 24.
|
|
40
|
+
* @param words The wordlist to use, defaults to the English wordlist.
|
|
41
|
+
* @returns True if the mnemonic is valid.
|
|
42
|
+
*/
|
|
43
|
+
static validateMnemonic(mnemonic: string, wordCount?: number, words?: string[]): boolean;
|
|
36
44
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @twin.org/crypto - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.9](https://github.com/twinfoundation/framework/compare/crypto-v0.0.2-next.8...crypto-v0.0.2-next.9) (2025-09-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add mnemonic validation ([4b43491](https://github.com/twinfoundation/framework/commit/4b43491cf04bb626c27faea66e5c74b3971b111d))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
16
|
+
* @twin.org/nameof bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
19
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
20
|
+
|
|
21
|
+
## [0.0.2-next.8](https://github.com/twinfoundation/framework/compare/crypto-v0.0.2-next.7...crypto-v0.0.2-next.8) (2025-09-05)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Miscellaneous Chores
|
|
25
|
+
|
|
26
|
+
* **crypto:** Synchronize repo versions
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Dependencies
|
|
30
|
+
|
|
31
|
+
* The following workspace dependencies were updated
|
|
32
|
+
* dependencies
|
|
33
|
+
* @twin.org/core bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
34
|
+
* @twin.org/nameof bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
35
|
+
* devDependencies
|
|
36
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
37
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
38
|
+
|
|
3
39
|
## [0.0.2-next.7](https://github.com/twinfoundation/framework/compare/crypto-v0.0.2-next.6...crypto-v0.0.2-next.7) (2025-08-29)
|
|
4
40
|
|
|
5
41
|
|
|
@@ -135,3 +135,37 @@ The entropy.
|
|
|
135
135
|
#### Throws
|
|
136
136
|
|
|
137
137
|
Error if the number of words is not a multiple of 3.
|
|
138
|
+
|
|
139
|
+
***
|
|
140
|
+
|
|
141
|
+
### validateMnemonic()
|
|
142
|
+
|
|
143
|
+
> `static` **validateMnemonic**(`mnemonic`, `wordCount`, `words`): `boolean`
|
|
144
|
+
|
|
145
|
+
Validate the mnemonic.
|
|
146
|
+
|
|
147
|
+
#### Parameters
|
|
148
|
+
|
|
149
|
+
##### mnemonic
|
|
150
|
+
|
|
151
|
+
`string`
|
|
152
|
+
|
|
153
|
+
The mnemonic to validate.
|
|
154
|
+
|
|
155
|
+
##### wordCount
|
|
156
|
+
|
|
157
|
+
`number` = `24`
|
|
158
|
+
|
|
159
|
+
The expected number of words in the mnemonic, defaults to 24.
|
|
160
|
+
|
|
161
|
+
##### words
|
|
162
|
+
|
|
163
|
+
`string`[] = `wordlist`
|
|
164
|
+
|
|
165
|
+
The wordlist to use, defaults to the English wordlist.
|
|
166
|
+
|
|
167
|
+
#### Returns
|
|
168
|
+
|
|
169
|
+
`boolean`
|
|
170
|
+
|
|
171
|
+
True if the mnemonic is valid.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/crypto",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.9",
|
|
4
4
|
"description": "Contains helper methods and classes which implement cryptographic functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@scure/base": "2.0.0",
|
|
21
21
|
"@scure/bip32": "2.0.0",
|
|
22
22
|
"@scure/bip39": "2.0.0",
|
|
23
|
-
"@twin.org/core": "0.0.2-next.
|
|
24
|
-
"@twin.org/nameof": "0.0.2-next.
|
|
23
|
+
"@twin.org/core": "0.0.2-next.9",
|
|
24
|
+
"@twin.org/nameof": "0.0.2-next.9",
|
|
25
25
|
"crypto-browserify": "3.12.1",
|
|
26
26
|
"micro-key-producer": "0.8.1"
|
|
27
27
|
},
|