@twin.org/crypto 0.0.4-next.8 → 0.9.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.
Files changed (60) hide show
  1. package/dist/es/curves/ed25519.js +1 -1
  2. package/dist/es/curves/ed25519.js.map +1 -1
  3. package/dist/es/curves/secp256k1.js +1 -1
  4. package/dist/es/curves/secp256k1.js.map +1 -1
  5. package/dist/es/hashes/argon2id.js +1 -1
  6. package/dist/es/hashes/argon2id.js.map +1 -1
  7. package/dist/es/hashes/blake2b.js +1 -1
  8. package/dist/es/hashes/blake2b.js.map +1 -1
  9. package/dist/es/hashes/blake3.js +1 -1
  10. package/dist/es/hashes/blake3.js.map +1 -1
  11. package/dist/es/hashes/hmacSha1.js +1 -1
  12. package/dist/es/hashes/hmacSha1.js.map +1 -1
  13. package/dist/es/hashes/hmacSha256.js +2 -1
  14. package/dist/es/hashes/hmacSha256.js.map +1 -1
  15. package/dist/es/hashes/hmacSha512.js +2 -1
  16. package/dist/es/hashes/hmacSha512.js.map +1 -1
  17. package/dist/es/hashes/sha1.js +1 -1
  18. package/dist/es/hashes/sha1.js.map +1 -1
  19. package/dist/es/hashes/sha256.js +2 -1
  20. package/dist/es/hashes/sha256.js.map +1 -1
  21. package/dist/es/hashes/sha3.js +2 -1
  22. package/dist/es/hashes/sha3.js.map +1 -1
  23. package/dist/es/hashes/sha512.js +2 -1
  24. package/dist/es/hashes/sha512.js.map +1 -1
  25. package/dist/es/helpers/integrityHelper.js +1 -1
  26. package/dist/es/helpers/integrityHelper.js.map +1 -1
  27. package/dist/es/keys/slip0010.js +1 -1
  28. package/dist/es/keys/slip0010.js.map +1 -1
  29. package/dist/es/otp/totp.js +1 -1
  30. package/dist/es/otp/totp.js.map +1 -1
  31. package/dist/types/curves/ed25519.d.ts +1 -1
  32. package/dist/types/curves/secp256k1.d.ts +1 -1
  33. package/dist/types/hashes/argon2id.d.ts +1 -1
  34. package/dist/types/hashes/blake2b.d.ts +1 -1
  35. package/dist/types/hashes/blake3.d.ts +1 -1
  36. package/dist/types/hashes/hmacSha1.d.ts +1 -1
  37. package/dist/types/hashes/hmacSha256.d.ts +2 -1
  38. package/dist/types/hashes/hmacSha512.d.ts +2 -1
  39. package/dist/types/hashes/sha1.d.ts +1 -1
  40. package/dist/types/hashes/sha256.d.ts +2 -1
  41. package/dist/types/hashes/sha3.d.ts +2 -1
  42. package/dist/types/hashes/sha512.d.ts +2 -1
  43. package/dist/types/keys/slip0010.d.ts +1 -1
  44. package/dist/types/otp/totp.d.ts +1 -1
  45. package/docs/changelog.md +219 -0
  46. package/docs/reference/classes/Argon2id.md +1 -1
  47. package/docs/reference/classes/Blake2b.md +1 -1
  48. package/docs/reference/classes/Blake3.md +1 -1
  49. package/docs/reference/classes/Ed25519.md +1 -1
  50. package/docs/reference/classes/HmacSha1.md +1 -1
  51. package/docs/reference/classes/HmacSha256.md +5 -1
  52. package/docs/reference/classes/HmacSha512.md +5 -1
  53. package/docs/reference/classes/Secp256k1.md +1 -1
  54. package/docs/reference/classes/Sha1.md +1 -1
  55. package/docs/reference/classes/Sha256.md +5 -1
  56. package/docs/reference/classes/Sha3.md +5 -1
  57. package/docs/reference/classes/Sha512.md +5 -1
  58. package/docs/reference/classes/Slip0010.md +1 -1
  59. package/docs/reference/classes/Totp.md +1 -1
  60. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"totp.js","sourceRoot":"","sources":["../../../src/otp/totp.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AAEjD;;;GAGG;AACH,MAAM,OAAO,IAAI;IAChB;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,CACrB,GAAe,EACf,WAAmB,EAAE,EACrB,YAAoB,IAAI,CAAC,GAAG,EAAE;QAE9B,OAAO,GAAG,CAA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kBAAkB,CAAC,MAAM,CAAC,CAAC;QACjD,OAAO,kBAAkB,aAAa,MAAM,kBAAkB,CAC7D,KAAK,CACL,WAAW,YAAY,WAAW,aAAa,sCAAsC,CAAC;IACxF,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Base32, RandomHelper } from \"@twin.org/core\";\nimport * as otp from \"micro-key-producer/otp.js\";\n\n/**\n * Perform TOTP.\n * Implementation of https://datatracker.ietf.org/doc/html/rfc4226 .\n */\nexport class Totp {\n\t/**\n\t * Generate a time based One Time Password.\n\t * @param key Key for the one time password.\n\t * @param interval The time step of the counter.\n\t * @param timestamp The timestamp.\n\t * @returns The one time password.\n\t */\n\tpublic static generate(\n\t\tkey: Uint8Array,\n\t\tinterval: number = 30,\n\t\ttimestamp: number = Date.now()\n\t): string {\n\t\treturn otp.totp({ secret: key, digits: 6, algorithm: \"sha1\", interval }, timestamp);\n\t}\n\n\t/**\n\t * Check a One Time Password based on a timer.\n\t * @param token Passcode to validate.\n\t * @param key Key for the one time password. This should be unique and secret for\n\t * every user as it is the seed used to calculate the HMAC.\n\t * @param window The allowable margin for the counter.\n\t * @param interval The time step of the counter.\n\t * @param timestamp The timestamp now.\n\t * @returns Undefined if failure, delta on success\n\t */\n\tpublic static verify(\n\t\ttoken: string,\n\t\tkey: Uint8Array,\n\t\twindow: number = 2,\n\t\tinterval: number = 30,\n\t\ttimestamp: number = Date.now()\n\t): number | undefined {\n\t\tfor (let i = -window; i < window; i++) {\n\t\t\tconst intervalWindow = i * interval * 1000;\n\t\t\tif (timestamp + intervalWindow > 0) {\n\t\t\t\tconst gen = Totp.generate(key, interval, timestamp + intervalWindow);\n\t\t\t\tif (gen === token) {\n\t\t\t\t\t// We have found a matching code\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If we get to here then no codes have matched, return undefined\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Generate a secret.\n\t * @param length The length of the secret to generate.\n\t * @returns The secret encoded as base32.\n\t */\n\tpublic static generateSecret(length: number): string {\n\t\tconst encodedBase32 = Base32.encode(RandomHelper.generate(length));\n\n\t\t// Strip the trailing = the authenticator apps don't need them\n\t\treturn encodedBase32.replace(/=/g, \"\");\n\t}\n\n\t/**\n\t * Convert the secret back to bytes.\n\t * @param secretBase32 The secret encoded as base32.\n\t * @returns The bytes of the secret.\n\t */\n\tpublic static secretToBytes(secretBase32: string): Uint8Array {\n\t\treturn Base32.decode(secretBase32);\n\t}\n\n\t/**\n\t * Generate a url for use with authenticator apps.\n\t * See https://github.com/google/google-authenticator/wiki/Key-Uri-Format .\n\t * @param issuer The issuer of the totp.\n\t * @param label The label that will show in auth apps.\n\t * @param secretBase32 The secret as base 32.\n\t * @returns The url.\n\t */\n\tpublic static generateAuthUrl(issuer: string, label: string, secretBase32: string): string {\n\t\tconst encodedIssuer = encodeURIComponent(issuer);\n\t\treturn `otpauth://totp/${encodedIssuer}%3A${encodeURIComponent(\n\t\t\tlabel\n\t\t)}?secret=${secretBase32}&issuer=${encodedIssuer}&digits=6&algorithm=SHA1&interval=30`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"totp.js","sourceRoot":"","sources":["../../../src/otp/totp.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AAEjD;;;GAGG;AACH,MAAM,OAAO,IAAI;IAChB;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,CACrB,GAAe,EACf,WAAmB,EAAE,EACrB,YAAoB,IAAI,CAAC,GAAG,EAAE;QAE9B,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CA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AC;IACxF,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Base32, RandomHelper } from \"@twin.org/core\";\nimport * as otp from \"micro-key-producer/otp.js\";\n\n/**\n * Perform TOTP.\n * Implementation of https://datatracker.ietf.org/doc/html/rfc4226 .\n */\nexport class Totp {\n\t/**\n\t * Generate a time based One Time Password.\n\t * @param key Key for the one time password.\n\t * @param interval The time step of the counter.\n\t * @param timestamp The timestamp.\n\t * @returns The one time password.\n\t */\n\tpublic static generate(\n\t\tkey: Uint8Array,\n\t\tinterval: number = 30,\n\t\ttimestamp: number = Date.now()\n\t): string {\n\t\treturn otp.totp({ secret: key, digits: 6, algorithm: \"sha1\", interval }, timestamp);\n\t}\n\n\t/**\n\t * Check a One Time Password based on a timer.\n\t * @param token Passcode to validate.\n\t * @param key Key for the one time password. This should be unique and secret for\n\t * every user as it is the seed used to calculate the HMAC.\n\t * @param window The allowable margin for the counter.\n\t * @param interval The time step of the counter.\n\t * @param timestamp The timestamp now.\n\t * @returns The counter delta on success, or undefined if no matching code is found within the window.\n\t */\n\tpublic static verify(\n\t\ttoken: string,\n\t\tkey: Uint8Array,\n\t\twindow: number = 2,\n\t\tinterval: number = 30,\n\t\ttimestamp: number = Date.now()\n\t): number | undefined {\n\t\tfor (let i = -window; i < window; i++) {\n\t\t\tconst intervalWindow = i * interval * 1000;\n\t\t\tif (timestamp + intervalWindow > 0) {\n\t\t\t\tconst gen = Totp.generate(key, interval, timestamp + intervalWindow);\n\t\t\t\tif (gen === token) {\n\t\t\t\t\t// We have found a matching code\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If we get to here then no codes have matched, return undefined\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Generate a secret.\n\t * @param length The length of the secret to generate.\n\t * @returns The secret encoded as base32.\n\t */\n\tpublic static generateSecret(length: number): string {\n\t\tconst encodedBase32 = Base32.encode(RandomHelper.generate(length));\n\n\t\t// Strip the trailing = the authenticator apps don't need them\n\t\treturn encodedBase32.replace(/=/g, \"\");\n\t}\n\n\t/**\n\t * Convert the secret back to bytes.\n\t * @param secretBase32 The secret encoded as base32.\n\t * @returns The bytes of the secret.\n\t */\n\tpublic static secretToBytes(secretBase32: string): Uint8Array {\n\t\treturn Base32.decode(secretBase32);\n\t}\n\n\t/**\n\t * Generate a url for use with authenticator apps.\n\t * See https://github.com/google/google-authenticator/wiki/Key-Uri-Format .\n\t * @param issuer The issuer of the totp.\n\t * @param label The label that will show in auth apps.\n\t * @param secretBase32 The secret as base 32.\n\t * @returns The url.\n\t */\n\tpublic static generateAuthUrl(issuer: string, label: string, secretBase32: string): string {\n\t\tconst encodedIssuer = encodeURIComponent(issuer);\n\t\treturn `otpauth://totp/${encodedIssuer}%3A${encodeURIComponent(\n\t\t\tlabel\n\t\t)}?secret=${secretBase32}&issuer=${encodedIssuer}&digits=6&algorithm=SHA1&interval=30`;\n\t}\n}\n"]}
@@ -22,7 +22,7 @@ export declare class Ed25519 {
22
22
  */
23
23
  static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array;
24
24
  /**
25
- * Sign the block with privateKey and returns a signature.
25
+ * Signs the block with the private key and returns a signature.
26
26
  * @param privateKey The private key.
27
27
  * @param block The block to sign.
28
28
  * @returns The signature.
@@ -22,7 +22,7 @@ export declare class Secp256k1 {
22
22
  */
23
23
  static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array;
24
24
  /**
25
- * Sign the block with privateKey and returns a signature.
25
+ * Signs the block with the private key and returns a signature.
26
26
  * @param privateKey The private key.
27
27
  * @param block The block to sign.
28
28
  * @returns The signature.
@@ -16,7 +16,7 @@ export declare class Argon2id {
16
16
  * @param options.p Number of parallel threads to use, default 1.
17
17
  * @param options.dkLen The length of the derived key in bytes, default 32.
18
18
  * @param options.maxmem The maximum amount of memory to use in bytes, default 2^30.
19
- * @returns The derived key.
19
+ * @returns A promise that resolves with the derived key bytes.
20
20
  */
21
21
  static hash(password: Uint8Array, salt: Uint8Array, options?: {
22
22
  t?: number;
@@ -53,7 +53,7 @@ export declare class Blake2b {
53
53
  update(block: Uint8Array): Blake2b;
54
54
  /**
55
55
  * Get the digest for the hash.
56
- * @returns The instance for chaining.
56
+ * @returns The computed hash as bytes.
57
57
  */
58
58
  digest(): Uint8Array;
59
59
  }
@@ -42,7 +42,7 @@ export declare class Blake3 {
42
42
  update(block: Uint8Array): Blake3;
43
43
  /**
44
44
  * Get the digest for the hash.
45
- * @returns The instance for chaining.
45
+ * @returns The computed hash as bytes.
46
46
  */
47
47
  digest(): Uint8Array;
48
48
  }
@@ -26,7 +26,7 @@ export declare class HmacSha1 {
26
26
  update(block: Uint8Array): HmacSha1;
27
27
  /**
28
28
  * Get the digest for the hash.
29
- * @returns The instance for chaining.
29
+ * @returns The computed hash as bytes.
30
30
  */
31
31
  digest(): Uint8Array;
32
32
  }
@@ -18,6 +18,7 @@ export declare class HmacSha256 {
18
18
  * Create a new instance of HmacSha256.
19
19
  * @param key The key for the hmac.
20
20
  * @param bits The number of bits.
21
+ * @throws GeneralError If the bits are not a valid size.
21
22
  */
22
23
  constructor(key: Uint8Array, bits?: number);
23
24
  /**
@@ -42,7 +43,7 @@ export declare class HmacSha256 {
42
43
  update(block: Uint8Array): HmacSha256;
43
44
  /**
44
45
  * Get the digest for the hash.
45
- * @returns The instance for chaining.
46
+ * @returns The computed hash as bytes.
46
47
  */
47
48
  digest(): Uint8Array;
48
49
  }
@@ -26,6 +26,7 @@ export declare class HmacSha512 {
26
26
  * Create a new instance of HmacSha512.
27
27
  * @param key The key for the hmac.
28
28
  * @param bits The number of bits.
29
+ * @throws GeneralError If the bits are not a valid size.
29
30
  */
30
31
  constructor(key: Uint8Array, bits?: number);
31
32
  /**
@@ -64,7 +65,7 @@ export declare class HmacSha512 {
64
65
  update(block: Uint8Array): HmacSha512;
65
66
  /**
66
67
  * Get the digest for the hash.
67
- * @returns The instance for chaining.
68
+ * @returns The computed hash as bytes.
68
69
  */
69
70
  digest(): Uint8Array;
70
71
  }
@@ -24,7 +24,7 @@ export declare class Sha1 {
24
24
  update(block: Uint8Array): Sha1;
25
25
  /**
26
26
  * Get the digest for the hash.
27
- * @returns The instance for chaining.
27
+ * @returns The computed hash as bytes.
28
28
  */
29
29
  digest(): Uint8Array;
30
30
  }
@@ -17,6 +17,7 @@ export declare class Sha256 {
17
17
  /**
18
18
  * Create a new instance of Sha256.
19
19
  * @param bits The number of bits.
20
+ * @throws GeneralError If the bits are not a valid size.
20
21
  */
21
22
  constructor(bits?: number);
22
23
  /**
@@ -39,7 +40,7 @@ export declare class Sha256 {
39
40
  update(block: Uint8Array): Sha256;
40
41
  /**
41
42
  * Get the digest for the hash.
42
- * @returns The instance for chaining.
43
+ * @returns The computed hash as bytes.
43
44
  */
44
45
  digest(): Uint8Array;
45
46
  }
@@ -25,6 +25,7 @@ export declare class Sha3 {
25
25
  /**
26
26
  * Create a new instance of Sha3.
27
27
  * @param bits The number of bits.
28
+ * @throws GeneralError If the bits are not a valid size.
28
29
  */
29
30
  constructor(bits?: number);
30
31
  /**
@@ -59,7 +60,7 @@ export declare class Sha3 {
59
60
  update(block: Uint8Array): Sha3;
60
61
  /**
61
62
  * Get the digest for the hash.
62
- * @returns The instance for chaining.
63
+ * @returns The computed hash as bytes.
63
64
  */
64
65
  digest(): Uint8Array;
65
66
  }
@@ -25,6 +25,7 @@ export declare class Sha512 {
25
25
  /**
26
26
  * Create a new instance of Sha512.
27
27
  * @param bits The number of bits.
28
+ * @throws GeneralError If the bits are not a valid size.
28
29
  */
29
30
  constructor(bits?: number);
30
31
  /**
@@ -59,7 +60,7 @@ export declare class Sha512 {
59
60
  update(block: Uint8Array): Sha512;
60
61
  /**
61
62
  * Get the digest for the hash.
62
- * @returns The instance for chaining.
63
+ * @returns The computed hash as bytes.
63
64
  */
64
65
  digest(): Uint8Array;
65
66
  }
@@ -35,7 +35,7 @@ export declare class Slip0010 {
35
35
  * Get the public key from the private key.
36
36
  * @param privateKey The private key.
37
37
  * @param keyType The key type.
38
- * @param withZeroByte Include a zero bute prefix.
38
+ * @param withZeroByte Include a zero byte prefix.
39
39
  * @returns The public key.
40
40
  */
41
41
  static getPublicKey(privateKey: Uint8Array, keyType?: KeyType, withZeroByte?: boolean): Uint8Array;
@@ -19,7 +19,7 @@ export declare class Totp {
19
19
  * @param window The allowable margin for the counter.
20
20
  * @param interval The time step of the counter.
21
21
  * @param timestamp The timestamp now.
22
- * @returns Undefined if failure, delta on success
22
+ * @returns The counter delta on success, or undefined if no matching code is found within the window.
23
23
  */
24
24
  static verify(token: string, key: Uint8Array, window?: number, interval?: number, timestamp?: number): number | undefined;
25
25
  /**
package/docs/changelog.md CHANGED
@@ -1,5 +1,224 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.0](https://github.com/iotaledger/twin-framework/compare/crypto-v0.9.0...crypto-v0.9.0) (2026-06-22)
4
+
5
+
6
+ ### Features
7
+
8
+ * release to production ([b24cba1](https://github.com/iotaledger/twin-framework/commit/b24cba1b6a969278d638e632590602ec881e49fb))
9
+ * release to production ([787287d](https://github.com/iotaledger/twin-framework/commit/787287d06ea8319657401589d61fff369310c422))
10
+ * release to production ([53f4843](https://github.com/iotaledger/twin-framework/commit/53f484326b2851d7a506d2620db24c4a65cee7b3))
11
+ * release to production ([56cda4d](https://github.com/iotaledger/twin-framework/commit/56cda4da93e978c5be19ec7cfd421ae2a7fe4147))
12
+ * release to production ([f7c6586](https://github.com/iotaledger/twin-framework/commit/f7c6586f6976b903b647b4c5ac5ad9421e0c9051))
13
+ * release to production ([829d53d](https://github.com/iotaledger/twin-framework/commit/829d53d3953b1e1b40b0243c04cfdfd3842aac7b))
14
+ * release to production ([5cf3a76](https://github.com/iotaledger/twin-framework/commit/5cf3a76a09eff2e6414d0cba846c7c37400a11d6))
15
+ * release to production ([#330](https://github.com/iotaledger/twin-framework/issues/330)) ([d73f565](https://github.com/iotaledger/twin-framework/commit/d73f565588d156d23ef49b2a5718973756f7a696))
16
+ * release to production ([#382](https://github.com/iotaledger/twin-framework/issues/382)) ([bbed01a](https://github.com/iotaledger/twin-framework/commit/bbed01a605ee9724bda77a0f7feab249118c2d90))
17
+
18
+
19
+ ### Miscellaneous Chores
20
+
21
+ * release to production ([63cae24](https://github.com/iotaledger/twin-framework/commit/63cae2401f6c11f93b2a01260b665064e8bd28e0))
22
+
23
+ ## [0.9.0-next.1](https://github.com/iotaledger/twin-framework/compare/crypto-v0.9.0-next.0...crypto-v0.9.0-next.1) (2026-06-22)
24
+
25
+
26
+ ### Features
27
+
28
+ * add context id features ([#206](https://github.com/iotaledger/twin-framework/issues/206)) ([ef0d4ee](https://github.com/iotaledger/twin-framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
29
+ * add crypto argon2id ([#255](https://github.com/iotaledger/twin-framework/issues/255)) ([27fe3a7](https://github.com/iotaledger/twin-framework/commit/27fe3a72eeb0f398a278ebb3f1cb9c4dd459743c))
30
+ * add mnemonic validation ([4b43491](https://github.com/iotaledger/twin-framework/commit/4b43491cf04bb626c27faea66e5c74b3971b111d))
31
+ * add rsa cipher support ([7af6cc6](https://github.com/iotaledger/twin-framework/commit/7af6cc67512d3363bd4a2f2e87bd7733c2800147))
32
+ * add RSA support for public key components ([7126259](https://github.com/iotaledger/twin-framework/commit/7126259103b758c291e52a8a03818eb822d1aad1))
33
+ * additional RSA methods and async ([1fceee2](https://github.com/iotaledger/twin-framework/commit/1fceee2d1248a24a7620846025fcf906495c07f4))
34
+ * change method accessibility ([c1b77fc](https://github.com/iotaledger/twin-framework/commit/c1b77fcfb61c092a01c97aebb2fe2dc2bbaa221b))
35
+ * eslint migration to flat config ([74427d7](https://github.com/iotaledger/twin-framework/commit/74427d78d342167f7850e49ab87269326355befe))
36
+ * factory create and integrity ([#235](https://github.com/iotaledger/twin-framework/issues/235)) ([9f98b99](https://github.com/iotaledger/twin-framework/commit/9f98b99daf46eb365346fae49cc4ffba63e74cb3))
37
+ * improve signatures ([cdd24be](https://github.com/iotaledger/twin-framework/commit/cdd24be6fb898d33955b6f2f93c3ddbd73582269))
38
+ * improved password generation and validation ([#232](https://github.com/iotaledger/twin-framework/issues/232)) ([ca4e18f](https://github.com/iotaledger/twin-framework/commit/ca4e18f388b1882cdfb774fc0d0921b8530fac33))
39
+ * locales validation ([#197](https://github.com/iotaledger/twin-framework/issues/197)) ([55fdadb](https://github.com/iotaledger/twin-framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
40
+ * relocate core packages from tools ([bcab8f3](https://github.com/iotaledger/twin-framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
41
+ * typescript 6 update ([1d10f31](https://github.com/iotaledger/twin-framework/commit/1d10f31e6516ec622773f45e88af82fe749b384a))
42
+ * update dependencies ([4da77ab](https://github.com/iotaledger/twin-framework/commit/4da77ab30f499e52825ac5a76f51436ceb59c26e))
43
+ * update dependencies ([f3bd015](https://github.com/iotaledger/twin-framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
44
+ * use cause instead of inner for errors ([1f4acc4](https://github.com/iotaledger/twin-framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * docs ([9df46e0](https://github.com/iotaledger/twin-framework/commit/9df46e0a3940a4d1f479373f58830519262f9590))
50
+ * docs ([67c8887](https://github.com/iotaledger/twin-framework/commit/67c888739448e753106ea067a8703d058e0ddf12))
51
+ * ensure __decorate is defined for decorators ([103a563](https://github.com/iotaledger/twin-framework/commit/103a563ce01ebdef6240d2e590e7b026e8692684))
52
+
53
+
54
+ ### Dependencies
55
+
56
+ * The following workspace dependencies were updated
57
+ * dependencies
58
+ * @twin.org/core bumped from 0.9.0-next.0 to 0.9.0-next.1
59
+ * @twin.org/nameof bumped from 0.9.0-next.0 to 0.9.0-next.1
60
+ * devDependencies
61
+ * @twin.org/nameof-transformer bumped from 0.9.0-next.0 to 0.9.0-next.1
62
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.0-next.0 to 0.9.0-next.1
63
+ * @twin.org/validate-locales bumped from 0.9.0-next.0 to 0.9.0-next.1
64
+
65
+ ## [0.0.4-next.15](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.14...crypto-v0.0.4-next.15) (2026-06-19)
66
+
67
+
68
+ ### Miscellaneous Chores
69
+
70
+ * **crypto:** Synchronize repo versions
71
+
72
+
73
+ ### Dependencies
74
+
75
+ * The following workspace dependencies were updated
76
+ * dependencies
77
+ * @twin.org/core bumped from 0.0.4-next.14 to 0.0.4-next.15
78
+ * @twin.org/nameof bumped from 0.0.4-next.14 to 0.0.4-next.15
79
+ * devDependencies
80
+ * @twin.org/nameof-transformer bumped from 0.0.4-next.14 to 0.0.4-next.15
81
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.14 to 0.0.4-next.15
82
+ * @twin.org/validate-locales bumped from 0.0.4-next.14 to 0.0.4-next.15
83
+
84
+ ## [0.0.4-next.14](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.13...crypto-v0.0.4-next.14) (2026-06-18)
85
+
86
+
87
+ ### Miscellaneous Chores
88
+
89
+ * **crypto:** Synchronize repo versions
90
+
91
+
92
+ ### Dependencies
93
+
94
+ * The following workspace dependencies were updated
95
+ * dependencies
96
+ * @twin.org/core bumped from 0.0.4-next.13 to 0.0.4-next.14
97
+ * @twin.org/nameof bumped from 0.0.4-next.13 to 0.0.4-next.14
98
+ * devDependencies
99
+ * @twin.org/nameof-transformer bumped from 0.0.4-next.13 to 0.0.4-next.14
100
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.13 to 0.0.4-next.14
101
+ * @twin.org/validate-locales bumped from 0.0.4-next.13 to 0.0.4-next.14
102
+
103
+ ## [0.0.4-next.13](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.12...crypto-v0.0.4-next.13) (2026-06-18)
104
+
105
+
106
+ ### Miscellaneous Chores
107
+
108
+ * **crypto:** Synchronize repo versions
109
+
110
+
111
+ ### Dependencies
112
+
113
+ * The following workspace dependencies were updated
114
+ * dependencies
115
+ * @twin.org/core bumped from 0.0.4-next.12 to 0.0.4-next.13
116
+ * @twin.org/nameof bumped from 0.0.4-next.12 to 0.0.4-next.13
117
+ * devDependencies
118
+ * @twin.org/nameof-transformer bumped from 0.0.4-next.12 to 0.0.4-next.13
119
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.12 to 0.0.4-next.13
120
+ * @twin.org/validate-locales bumped from 0.0.4-next.12 to 0.0.4-next.13
121
+
122
+ ## [0.0.4-next.12](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.11...crypto-v0.0.4-next.12) (2026-06-18)
123
+
124
+
125
+ ### Miscellaneous Chores
126
+
127
+ * **crypto:** Synchronize repo versions
128
+
129
+
130
+ ### Dependencies
131
+
132
+ * The following workspace dependencies were updated
133
+ * dependencies
134
+ * @twin.org/core bumped from 0.0.4-next.11 to 0.0.4-next.12
135
+ * @twin.org/nameof bumped from 0.0.4-next.11 to 0.0.4-next.12
136
+ * devDependencies
137
+ * @twin.org/nameof-transformer bumped from 0.0.4-next.11 to 0.0.4-next.12
138
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.11 to 0.0.4-next.12
139
+ * @twin.org/validate-locales bumped from 0.0.4-next.11 to 0.0.4-next.12
140
+
141
+ ## [0.0.4-next.11](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.10...crypto-v0.0.4-next.11) (2026-06-15)
142
+
143
+
144
+ ### Miscellaneous Chores
145
+
146
+ * **crypto:** Synchronize repo versions
147
+
148
+
149
+ ### Dependencies
150
+
151
+ * The following workspace dependencies were updated
152
+ * dependencies
153
+ * @twin.org/core bumped from 0.0.4-next.10 to 0.0.4-next.11
154
+ * @twin.org/nameof bumped from 0.0.4-next.10 to 0.0.4-next.11
155
+ * devDependencies
156
+ * @twin.org/nameof-transformer bumped from 0.0.4-next.10 to 0.0.4-next.11
157
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.10 to 0.0.4-next.11
158
+ * @twin.org/validate-locales bumped from 0.0.4-next.10 to 0.0.4-next.11
159
+
160
+ ## [0.0.4-next.10](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.9...crypto-v0.0.4-next.10) (2026-06-15)
161
+
162
+
163
+ ### Features
164
+
165
+ * add context id features ([#206](https://github.com/iotaledger/twin-framework/issues/206)) ([ef0d4ee](https://github.com/iotaledger/twin-framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
166
+ * add crypto argon2id ([#255](https://github.com/iotaledger/twin-framework/issues/255)) ([27fe3a7](https://github.com/iotaledger/twin-framework/commit/27fe3a72eeb0f398a278ebb3f1cb9c4dd459743c))
167
+ * add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/iotaledger/twin-framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
168
+ * add mnemonic validation ([4b43491](https://github.com/iotaledger/twin-framework/commit/4b43491cf04bb626c27faea66e5c74b3971b111d))
169
+ * add rsa cipher support ([7af6cc6](https://github.com/iotaledger/twin-framework/commit/7af6cc67512d3363bd4a2f2e87bd7733c2800147))
170
+ * add RSA support for public key components ([7126259](https://github.com/iotaledger/twin-framework/commit/7126259103b758c291e52a8a03818eb822d1aad1))
171
+ * additional RSA methods and async ([1fceee2](https://github.com/iotaledger/twin-framework/commit/1fceee2d1248a24a7620846025fcf906495c07f4))
172
+ * change method accessibility ([c1b77fc](https://github.com/iotaledger/twin-framework/commit/c1b77fcfb61c092a01c97aebb2fe2dc2bbaa221b))
173
+ * eslint migration to flat config ([74427d7](https://github.com/iotaledger/twin-framework/commit/74427d78d342167f7850e49ab87269326355befe))
174
+ * factory create and integrity ([#235](https://github.com/iotaledger/twin-framework/issues/235)) ([9f98b99](https://github.com/iotaledger/twin-framework/commit/9f98b99daf46eb365346fae49cc4ffba63e74cb3))
175
+ * improve signatures ([cdd24be](https://github.com/iotaledger/twin-framework/commit/cdd24be6fb898d33955b6f2f93c3ddbd73582269))
176
+ * improved password generation and validation ([#232](https://github.com/iotaledger/twin-framework/issues/232)) ([ca4e18f](https://github.com/iotaledger/twin-framework/commit/ca4e18f388b1882cdfb774fc0d0921b8530fac33))
177
+ * locales validation ([#197](https://github.com/iotaledger/twin-framework/issues/197)) ([55fdadb](https://github.com/iotaledger/twin-framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
178
+ * relocate core packages from tools ([bcab8f3](https://github.com/iotaledger/twin-framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
179
+ * typescript 6 update ([1d10f31](https://github.com/iotaledger/twin-framework/commit/1d10f31e6516ec622773f45e88af82fe749b384a))
180
+ * update dependencies ([4da77ab](https://github.com/iotaledger/twin-framework/commit/4da77ab30f499e52825ac5a76f51436ceb59c26e))
181
+ * update dependencies ([f3bd015](https://github.com/iotaledger/twin-framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
182
+ * use cause instead of inner for errors ([1f4acc4](https://github.com/iotaledger/twin-framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
183
+
184
+
185
+ ### Bug Fixes
186
+
187
+ * docs ([9df46e0](https://github.com/iotaledger/twin-framework/commit/9df46e0a3940a4d1f479373f58830519262f9590))
188
+ * docs ([67c8887](https://github.com/iotaledger/twin-framework/commit/67c888739448e753106ea067a8703d058e0ddf12))
189
+ * ensure __decorate is defined for decorators ([103a563](https://github.com/iotaledger/twin-framework/commit/103a563ce01ebdef6240d2e590e7b026e8692684))
190
+
191
+
192
+ ### Dependencies
193
+
194
+ * The following workspace dependencies were updated
195
+ * dependencies
196
+ * @twin.org/core bumped from 0.0.4-next.9 to 0.0.4-next.10
197
+ * @twin.org/nameof bumped from 0.0.4-next.9 to 0.0.4-next.10
198
+ * devDependencies
199
+ * @twin.org/nameof-transformer bumped from 0.0.4-next.9 to 0.0.4-next.10
200
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.9 to 0.0.4-next.10
201
+ * @twin.org/validate-locales bumped from 0.0.4-next.9 to 0.0.4-next.10
202
+
203
+ ## [0.0.4-next.9](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.8...crypto-v0.0.4-next.9) (2026-06-15)
204
+
205
+
206
+ ### Miscellaneous Chores
207
+
208
+ * **crypto:** Synchronize repo versions
209
+
210
+
211
+ ### Dependencies
212
+
213
+ * The following workspace dependencies were updated
214
+ * dependencies
215
+ * @twin.org/core bumped from 0.0.4-next.8 to 0.0.4-next.9
216
+ * @twin.org/nameof bumped from 0.0.4-next.8 to 0.0.4-next.9
217
+ * devDependencies
218
+ * @twin.org/nameof-transformer bumped from 0.0.4-next.8 to 0.0.4-next.9
219
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.8 to 0.0.4-next.9
220
+ * @twin.org/validate-locales bumped from 0.0.4-next.8 to 0.0.4-next.9
221
+
3
222
  ## [0.0.4-next.8](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.7...crypto-v0.0.4-next.8) (2026-06-10)
4
223
 
5
224
 
@@ -80,4 +80,4 @@ The maximum amount of memory to use in bytes, default 2^30.
80
80
 
81
81
  `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
82
82
 
83
- The derived key.
83
+ A promise that resolves with the derived key bytes.
@@ -178,4 +178,4 @@ Get the digest for the hash.
178
178
 
179
179
  `Uint8Array`
180
180
 
181
- The instance for chaining.
181
+ The computed hash as bytes.
@@ -142,4 +142,4 @@ Get the digest for the hash.
142
142
 
143
143
  `Uint8Array`
144
144
 
145
- The instance for chaining.
145
+ The computed hash as bytes.
@@ -68,7 +68,7 @@ Error if the private key is not the correct length.
68
68
 
69
69
  > `static` **sign**(`privateKey`, `block`): `Uint8Array`
70
70
 
71
- Sign the block with privateKey and returns a signature.
71
+ Signs the block with the private key and returns a signature.
72
72
 
73
73
  #### Parameters
74
74
 
@@ -92,4 +92,4 @@ Get the digest for the hash.
92
92
 
93
93
  `Uint8Array`
94
94
 
95
- The instance for chaining.
95
+ The computed hash as bytes.
@@ -28,6 +28,10 @@ The number of bits.
28
28
 
29
29
  `HmacSha256`
30
30
 
31
+ #### Throws
32
+
33
+ GeneralError If the bits are not a valid size.
34
+
31
35
  ## Properties
32
36
 
33
37
  ### SIZE\_256 {#size_256}
@@ -142,4 +146,4 @@ Get the digest for the hash.
142
146
 
143
147
  `Uint8Array`
144
148
 
145
- The instance for chaining.
149
+ The computed hash as bytes.
@@ -28,6 +28,10 @@ The number of bits.
28
28
 
29
29
  `HmacSha512`
30
30
 
31
+ #### Throws
32
+
33
+ GeneralError If the bits are not a valid size.
34
+
31
35
  ## Properties
32
36
 
33
37
  ### SIZE\_224 {#size_224}
@@ -214,4 +218,4 @@ Get the digest for the hash.
214
218
 
215
219
  `Uint8Array`
216
220
 
217
- The instance for chaining.
221
+ The computed hash as bytes.
@@ -68,7 +68,7 @@ Error if the private key is not the correct length.
68
68
 
69
69
  > `static` **sign**(`privateKey`, `block`): `Uint8Array`
70
70
 
71
- Sign the block with privateKey and returns a signature.
71
+ Signs the block with the private key and returns a signature.
72
72
 
73
73
  #### Parameters
74
74
 
@@ -78,4 +78,4 @@ Get the digest for the hash.
78
78
 
79
79
  `Uint8Array`
80
80
 
81
- The instance for chaining.
81
+ The computed hash as bytes.
@@ -22,6 +22,10 @@ The number of bits.
22
22
 
23
23
  `Sha256`
24
24
 
25
+ #### Throws
26
+
27
+ GeneralError If the bits are not a valid size.
28
+
25
29
  ## Properties
26
30
 
27
31
  ### SIZE\_256 {#size_256}
@@ -124,4 +128,4 @@ Get the digest for the hash.
124
128
 
125
129
  `Uint8Array`
126
130
 
127
- The instance for chaining.
131
+ The computed hash as bytes.
@@ -22,6 +22,10 @@ The number of bits.
22
22
 
23
23
  `Sha3`
24
24
 
25
+ #### Throws
26
+
27
+ GeneralError If the bits are not a valid size.
28
+
25
29
  ## Properties
26
30
 
27
31
  ### SIZE\_224 {#size_224}
@@ -184,4 +188,4 @@ Get the digest for the hash.
184
188
 
185
189
  `Uint8Array`
186
190
 
187
- The instance for chaining.
191
+ The computed hash as bytes.
@@ -22,6 +22,10 @@ The number of bits.
22
22
 
23
23
  `Sha512`
24
24
 
25
+ #### Throws
26
+
27
+ GeneralError If the bits are not a valid size.
28
+
25
29
  ## Properties
26
30
 
27
31
  ### SIZE\_224 {#size_224}
@@ -184,4 +188,4 @@ Get the digest for the hash.
184
188
 
185
189
  `Uint8Array`
186
190
 
187
- The instance for chaining.
191
+ The computed hash as bytes.
@@ -129,7 +129,7 @@ The key type.
129
129
 
130
130
  `boolean` = `true`
131
131
 
132
- Include a zero bute prefix.
132
+ Include a zero byte prefix.
133
133
 
134
134
  #### Returns
135
135
 
@@ -92,7 +92,7 @@ The timestamp now.
92
92
 
93
93
  `number` \| `undefined`
94
94
 
95
- Undefined if failure, delta on success
95
+ The counter delta on success, or undefined if no matching code is found within the window.
96
96
 
97
97
  ***
98
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/crypto",
3
- "version": "0.0.4-next.8",
3
+ "version": "0.9.0",
4
4
  "description": "Helper methods and classes which implement cryptographic functions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,9 +20,9 @@
20
20
  "@scure/base": "2.2.0",
21
21
  "@scure/bip32": "2.2.0",
22
22
  "@scure/bip39": "2.2.0",
23
- "@twin.org/core": "0.0.4-next.8",
24
- "@twin.org/nameof": "0.0.4-next.8",
25
- "micro-key-producer": "0.8.6"
23
+ "@twin.org/core": "^0.9.0",
24
+ "@twin.org/nameof": "^0.9.0",
25
+ "micro-key-producer": "0.9.0"
26
26
  },
27
27
  "main": "./dist/es/index.js",
28
28
  "types": "./dist/types/index.d.ts",