@twin.org/crypto 0.0.3-next.16 → 0.0.3-next.18
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/es/helpers/integrityHelper.js +67 -0
- package/dist/es/helpers/integrityHelper.js.map +1 -0
- package/dist/es/index.js +2 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/integrityAlgorithm.js +21 -0
- package/dist/es/models/integrityAlgorithm.js.map +1 -0
- package/dist/es/passwords/passwordGenerator.js +2 -0
- package/dist/es/passwords/passwordGenerator.js.map +1 -1
- package/dist/types/helpers/integrityHelper.d.ts +26 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/models/integrityAlgorithm.d.ts +21 -0
- package/dist/types/passwords/passwordGenerator.d.ts +0 -12
- package/docs/changelog.md +44 -0
- package/docs/reference/classes/IntegrityHelper.md +85 -0
- package/docs/reference/index.md +3 -0
- package/docs/reference/type-aliases/IntegrityAlgorithm.md +5 -0
- package/docs/reference/variables/IntegrityAlgorithm.md +25 -0
- package/package.json +3 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Copyright 2026 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { Converter, Guards } from "@twin.org/core";
|
|
4
|
+
import { Sha256 } from "../hashes/sha256.js";
|
|
5
|
+
import { Sha512 } from "../hashes/sha512.js";
|
|
6
|
+
import { IntegrityAlgorithm } from "../models/integrityAlgorithm.js";
|
|
7
|
+
/**
|
|
8
|
+
* Helper class for creating integrity signatures.
|
|
9
|
+
* @see https://www.w3.org/TR/SRI/
|
|
10
|
+
*/
|
|
11
|
+
export class IntegrityHelper {
|
|
12
|
+
/**
|
|
13
|
+
* Runtime name for the class.
|
|
14
|
+
*/
|
|
15
|
+
static CLASS_NAME = "IntegrityHelper";
|
|
16
|
+
/**
|
|
17
|
+
* Generate an integrity signature for the given content using the specified hash algorithm.
|
|
18
|
+
* @param type The hash algorithm to use, either "sha256", "sha384" or "sha512".
|
|
19
|
+
* @param content The content to hash as a Uint8Array.
|
|
20
|
+
* @returns The integrity signature in the format "type-base64hash".
|
|
21
|
+
*/
|
|
22
|
+
static generate(type, content) {
|
|
23
|
+
Guards.arrayOneOf(IntegrityHelper.CLASS_NAME, "type", type, Object.values(IntegrityAlgorithm));
|
|
24
|
+
Guards.uint8Array(IntegrityHelper.CLASS_NAME, "content", content);
|
|
25
|
+
return `${type}-${IntegrityHelper.generateHash(type, content)}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Verify an integrity signature for the given content.
|
|
29
|
+
* @param integrity The integrity signature in the format "type-base64hash".
|
|
30
|
+
* @param content The content to hash as a Uint8Array.
|
|
31
|
+
* @returns True if the integrity signature matches the content.
|
|
32
|
+
* @throws If the integrity signature is invalid.
|
|
33
|
+
*/
|
|
34
|
+
static verify(integrity, content) {
|
|
35
|
+
Guards.stringValue(IntegrityHelper.CLASS_NAME, "integrity", integrity);
|
|
36
|
+
Guards.uint8Array(IntegrityHelper.CLASS_NAME, "content", content);
|
|
37
|
+
const parts = integrity.split("-");
|
|
38
|
+
if (parts.length !== 2) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const [type, hash] = parts;
|
|
42
|
+
Guards.arrayOneOf(IntegrityHelper.CLASS_NAME, "type", type, Object.values(IntegrityAlgorithm));
|
|
43
|
+
Guards.stringValue(IntegrityHelper.CLASS_NAME, "hash", hash);
|
|
44
|
+
return IntegrityHelper.generateHash(type, content) === hash;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generate a hash for the given content using the specified type.
|
|
48
|
+
* @param type The hash algorithm to use, either "sha256", "sha384" or "sha512".
|
|
49
|
+
* @param content The content to hash as a Uint8Array.
|
|
50
|
+
* @returns The integrity signature in the format "type-base64hash".
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
static generateHash(type, content) {
|
|
54
|
+
let hash;
|
|
55
|
+
if (type === IntegrityAlgorithm.Sha384) {
|
|
56
|
+
hash = Sha512.sum384(content);
|
|
57
|
+
}
|
|
58
|
+
else if (type === IntegrityAlgorithm.Sha512) {
|
|
59
|
+
hash = Sha512.sum512(content);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
hash = Sha256.sum256(content);
|
|
63
|
+
}
|
|
64
|
+
return Converter.bytesToBase64(hash);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=integrityHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrityHelper.js","sourceRoot":"","sources":["../../../src/helpers/integrityHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC3B;;OAEG;IACI,MAAM,CAAU,UAAU,qBAAqC;IAEtE;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAwB,EAAE,OAAmB;QACnE,MAAM,CAAC,UAAU,CAChB,eAAe,CAAC,UAAU,UAE1B,IAAI,EACJ,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CACjC,CAAC;QACF,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAExE,OAAO,GAAG,IAAI,IAAI,eAAe,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;IACjE,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,SAAiB,EAAE,OAAmB;QAC1D,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,eAAqB,SAAS,CAAC,CAAC;QAC7E,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAExE,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACd,CAAC;QAED,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC;QAE3B,MAAM,CAAC,UAAU,CAChB,eAAe,CAAC,UAAU,UAE1B,IAA0B,EAC1B,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CACjC,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,UAAgB,IAAI,CAAC,CAAC;QAEnE,OAAO,eAAe,CAAC,YAAY,CAAC,IAA0B,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACnF,CAAC;IAED;;;;;;OAMG;IACK,MAAM,CAAC,YAAY,CAAC,IAAwB,EAAE,OAAmB;QACxE,IAAI,IAAI,CAAC;QACT,IAAI,IAAI,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;YACxC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;aAAM,IAAI,IAAI,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;YAC/C,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACP,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Sha256 } from \"../hashes/sha256.js\";\nimport { Sha512 } from \"../hashes/sha512.js\";\nimport { IntegrityAlgorithm } from \"../models/integrityAlgorithm.js\";\n\n/**\n * Helper class for creating integrity signatures.\n * @see https://www.w3.org/TR/SRI/\n */\nexport class IntegrityHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IntegrityHelper>();\n\n\t/**\n\t * Generate an integrity signature for the given content using the specified hash algorithm.\n\t * @param type The hash algorithm to use, either \"sha256\", \"sha384\" or \"sha512\".\n\t * @param content The content to hash as a Uint8Array.\n\t * @returns The integrity signature in the format \"type-base64hash\".\n\t */\n\tpublic static generate(type: IntegrityAlgorithm, content: Uint8Array): string {\n\t\tGuards.arrayOneOf(\n\t\t\tIntegrityHelper.CLASS_NAME,\n\t\t\tnameof(type),\n\t\t\ttype,\n\t\t\tObject.values(IntegrityAlgorithm)\n\t\t);\n\t\tGuards.uint8Array(IntegrityHelper.CLASS_NAME, nameof(content), content);\n\n\t\treturn `${type}-${IntegrityHelper.generateHash(type, content)}`;\n\t}\n\n\t/**\n\t * Verify an integrity signature for the given content.\n\t * @param integrity The integrity signature in the format \"type-base64hash\".\n\t * @param content The content to hash as a Uint8Array.\n\t * @returns True if the integrity signature matches the content.\n\t * @throws If the integrity signature is invalid.\n\t */\n\tpublic static verify(integrity: string, content: Uint8Array): boolean {\n\t\tGuards.stringValue(IntegrityHelper.CLASS_NAME, nameof(integrity), integrity);\n\t\tGuards.uint8Array(IntegrityHelper.CLASS_NAME, nameof(content), content);\n\n\t\tconst parts = integrity.split(\"-\");\n\t\tif (parts.length !== 2) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst [type, hash] = parts;\n\n\t\tGuards.arrayOneOf(\n\t\t\tIntegrityHelper.CLASS_NAME,\n\t\t\tnameof(type),\n\t\t\ttype as IntegrityAlgorithm,\n\t\t\tObject.values(IntegrityAlgorithm)\n\t\t);\n\t\tGuards.stringValue(IntegrityHelper.CLASS_NAME, nameof(hash), hash);\n\n\t\treturn IntegrityHelper.generateHash(type as IntegrityAlgorithm, content) === hash;\n\t}\n\n\t/**\n\t * Generate a hash for the given content using the specified type.\n\t * @param type The hash algorithm to use, either \"sha256\", \"sha384\" or \"sha512\".\n\t * @param content The content to hash as a Uint8Array.\n\t * @returns The integrity signature in the format \"type-base64hash\".\n\t * @internal\n\t */\n\tprivate static generateHash(type: IntegrityAlgorithm, content: Uint8Array): string {\n\t\tlet hash;\n\t\tif (type === IntegrityAlgorithm.Sha384) {\n\t\t\thash = Sha512.sum384(content);\n\t\t} else if (type === IntegrityAlgorithm.Sha512) {\n\t\t\thash = Sha512.sum512(content);\n\t\t} else {\n\t\t\thash = Sha256.sum256(content);\n\t\t}\n\t\treturn Converter.bytesToBase64(hash);\n\t}\n}\n"]}
|
package/dist/es/index.js
CHANGED
|
@@ -17,10 +17,12 @@ export * from "./hashes/sha1.js";
|
|
|
17
17
|
export * from "./hashes/sha256.js";
|
|
18
18
|
export * from "./hashes/sha3.js";
|
|
19
19
|
export * from "./hashes/sha512.js";
|
|
20
|
+
export * from "./helpers/integrityHelper.js";
|
|
20
21
|
export * from "./helpers/pemHelper.js";
|
|
21
22
|
export * from "./keys/bip32Path.js";
|
|
22
23
|
export * from "./keys/bip39.js";
|
|
23
24
|
export * from "./keys/slip0010.js";
|
|
25
|
+
export * from "./models/integrityAlgorithm.js";
|
|
24
26
|
export * from "./models/keyType.js";
|
|
25
27
|
export * from "./otp/hotp.js";
|
|
26
28
|
export * from "./otp/totp.js";
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./address/bech32.js\";\nexport * from \"./address/bip44.js\";\nexport * from \"./ciphers/chaCha20Poly1305.js\";\nexport * from \"./curves/ed25519.js\";\nexport * from \"./curves/secp256k1.js\";\nexport * from \"./curves/x25519.js\";\nexport * from \"./curves/zip215.js\";\nexport * from \"./hashes/blake2b.js\";\nexport * from \"./hashes/blake3.js\";\nexport * from \"./hashes/hmacSha1.js\";\nexport * from \"./hashes/hmacSha256.js\";\nexport * from \"./hashes/hmacSha512.js\";\nexport * from \"./hashes/pbkdf2.js\";\nexport * from \"./hashes/sha1.js\";\nexport * from \"./hashes/sha256.js\";\nexport * from \"./hashes/sha3.js\";\nexport * from \"./hashes/sha512.js\";\nexport * from \"./helpers/pemHelper.js\";\nexport * from \"./keys/bip32Path.js\";\nexport * from \"./keys/bip39.js\";\nexport * from \"./keys/slip0010.js\";\nexport * from \"./models/keyType.js\";\nexport * from \"./otp/hotp.js\";\nexport * from \"./otp/totp.js\";\nexport * from \"./passwords/passwordGenerator.js\";\nexport * from \"./passwords/passwordValidator.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./address/bech32.js\";\nexport * from \"./address/bip44.js\";\nexport * from \"./ciphers/chaCha20Poly1305.js\";\nexport * from \"./curves/ed25519.js\";\nexport * from \"./curves/secp256k1.js\";\nexport * from \"./curves/x25519.js\";\nexport * from \"./curves/zip215.js\";\nexport * from \"./hashes/blake2b.js\";\nexport * from \"./hashes/blake3.js\";\nexport * from \"./hashes/hmacSha1.js\";\nexport * from \"./hashes/hmacSha256.js\";\nexport * from \"./hashes/hmacSha512.js\";\nexport * from \"./hashes/pbkdf2.js\";\nexport * from \"./hashes/sha1.js\";\nexport * from \"./hashes/sha256.js\";\nexport * from \"./hashes/sha3.js\";\nexport * from \"./hashes/sha512.js\";\nexport * from \"./helpers/integrityHelper.js\";\nexport * from \"./helpers/pemHelper.js\";\nexport * from \"./keys/bip32Path.js\";\nexport * from \"./keys/bip39.js\";\nexport * from \"./keys/slip0010.js\";\nexport * from \"./models/integrityAlgorithm.js\";\nexport * from \"./models/keyType.js\";\nexport * from \"./otp/hotp.js\";\nexport * from \"./otp/totp.js\";\nexport * from \"./passwords/passwordGenerator.js\";\nexport * from \"./passwords/passwordValidator.js\";\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The names of the integrity algorithms.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const IntegrityAlgorithm = {
|
|
8
|
+
/**
|
|
9
|
+
* Sha256.
|
|
10
|
+
*/
|
|
11
|
+
Sha256: "sha256",
|
|
12
|
+
/**
|
|
13
|
+
* Sha384.
|
|
14
|
+
*/
|
|
15
|
+
Sha384: "sha384",
|
|
16
|
+
/**
|
|
17
|
+
* Sha512.
|
|
18
|
+
*/
|
|
19
|
+
Sha512: "sha512"
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=integrityAlgorithm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrityAlgorithm.js","sourceRoot":"","sources":["../../../src/models/integrityAlgorithm.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC;;OAEG;IACH,MAAM,EAAE,QAAQ;IAEhB;;OAEG;IACH,MAAM,EAAE,QAAQ;IAEhB;;OAEG;IACH,MAAM,EAAE,QAAQ;CACP,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The names of the integrity algorithms.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const IntegrityAlgorithm = {\n\t/**\n\t * Sha256.\n\t */\n\tSha256: \"sha256\",\n\n\t/**\n\t * Sha384.\n\t */\n\tSha384: \"sha384\",\n\n\t/**\n\t * Sha512.\n\t */\n\tSha512: \"sha512\"\n} as const;\n\n/**\n * Integrity algorithms.\n */\nexport type IntegrityAlgorithm = (typeof IntegrityAlgorithm)[keyof typeof IntegrityAlgorithm];\n"]}
|
|
@@ -60,6 +60,7 @@ export class PasswordGenerator {
|
|
|
60
60
|
* Get a random character from the given character set.
|
|
61
61
|
* @param charSet The character set to get a random character from.
|
|
62
62
|
* @returns A random character from the given character set.
|
|
63
|
+
* @internal
|
|
63
64
|
*/
|
|
64
65
|
static getRandomChar(charSet) {
|
|
65
66
|
let b = 0;
|
|
@@ -72,6 +73,7 @@ export class PasswordGenerator {
|
|
|
72
73
|
* Push a random character from the given character set to the chars array, ensuring no three repeated characters in a row.
|
|
73
74
|
* @param chars The array to push the character to.
|
|
74
75
|
* @param charSet The character set to get a random character from.
|
|
76
|
+
* @internal
|
|
75
77
|
*/
|
|
76
78
|
static pushChar(chars, charSet) {
|
|
77
79
|
let next = PasswordGenerator.getRandomChar(charSet);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passwordGenerator.js","sourceRoot":"","sources":["../../../src/passwords/passwordGenerator.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAC7B;;OAEG;IACI,MAAM,CAAU,UAA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OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEhD,OAAO,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACK,MAAM,CAAC,aAAa,CAAC,OAAe;QAC3C,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,GAAG,CAAC;YACH,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE;QAC9B,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACK,MAAM,CAAC,QAAQ,CAAC,KAAe,EAAE,OAAe;QACvD,IAAI,IAAI,GAAG,iBAAiB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,IAAI,GAAG,iBAAiB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACjD,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Guards, RandomHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Blake2b } from \"../hashes/blake2b.js\";\n\n/**\n * Generate random passwords.\n */\nexport class PasswordGenerator {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<PasswordGenerator>();\n\n\t/**\n\t * The minimum password length, 15 to match owasp rules.\n\t * @see https://www.owasp.org/index.php/Authentication_Cheat_Sheet#Implement_Proper_Password_Strength_Controls .\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_MIN_PASSWORD_LENGTH: number = 15;\n\n\t/**\n\t * Generate a password of given length.\n\t * @param length The length of the password to generate, default to 15.\n\t * @returns The random password.\n\t */\n\tpublic static generate(length: number = PasswordGenerator._DEFAULT_MIN_PASSWORD_LENGTH): string {\n\t\tconst lower = \"abcdefghijklmnopqrstuvwxyz\";\n\t\tconst upper = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\t\tconst digits = \"0123456789\";\n\t\tconst specials = \"!#$£%^&*+=@~?}\";\n\t\tconst alphabet = `${lower}${upper}`;\n\t\tconst allChars = `${alphabet}${digits}${specials}`;\n\n\t\tconst targetLength = Math.max(length, PasswordGenerator._DEFAULT_MIN_PASSWORD_LENGTH);\n\t\tconst chars: string[] = [];\n\n\t\t// Ensure required character classes are present.\n\t\tPasswordGenerator.pushChar(chars, lower);\n\t\tPasswordGenerator.pushChar(chars, upper);\n\t\tPasswordGenerator.pushChar(chars, digits);\n\t\tPasswordGenerator.pushChar(chars, specials);\n\n\t\twhile (chars.length < targetLength) {\n\t\t\tconst charSet = chars.length === 0 ? alphabet : allChars;\n\t\t\tPasswordGenerator.pushChar(chars, charSet);\n\t\t}\n\n\t\treturn chars.join(\"\");\n\t}\n\n\t/**\n\t * Hash the password for the user.\n\t * @param passwordBytes The password bytes.\n\t * @param saltBytes The salt bytes.\n\t * @returns The hashed password.\n\t */\n\tpublic static async hashPassword(\n\t\tpasswordBytes: Uint8Array,\n\t\tsaltBytes: Uint8Array\n\t): Promise<string> {\n\t\tGuards.uint8Array(PasswordGenerator.CLASS_NAME, nameof(passwordBytes), passwordBytes);\n\t\tGuards.uint8Array(PasswordGenerator.CLASS_NAME, nameof(saltBytes), saltBytes);\n\n\t\tconst combined = new Uint8Array(saltBytes.length + passwordBytes.length);\n\t\tcombined.set(saltBytes);\n\t\tcombined.set(passwordBytes, saltBytes.length);\n\n\t\tconst hashedPassword = Blake2b.sum256(combined);\n\n\t\treturn Converter.bytesToBase64(hashedPassword);\n\t}\n\n\t/**\n\t * Get a random character from the given character set.\n\t * @param charSet The character set to get a random character from.\n\t * @returns A random character from the given character set.\n\t * @internal\n\t */\n\tprivate static getRandomChar(charSet: string): string {\n\t\tlet b = 0;\n\t\tdo {\n\t\t\tb = RandomHelper.generate(1)[0];\n\t\t} while (b >= charSet.length);\n\t\treturn charSet[b];\n\t}\n\n\t/**\n\t * Push a random character from the given character set to the chars array, ensuring no three repeated characters in a row.\n\t * @param chars The array to push the character to.\n\t * @param charSet The character set to get a random character from.\n\t * @internal\n\t */\n\tprivate static pushChar(chars: string[], charSet: string): void {\n\t\tlet next = PasswordGenerator.getRandomChar(charSet);\n\t\twhile (chars.length >= 2 && next === chars.at(-1) && next === chars.at(-2)) {\n\t\t\tnext = PasswordGenerator.getRandomChar(charSet);\n\t\t}\n\t\tchars.push(next);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IntegrityAlgorithm } from "../models/integrityAlgorithm.js";
|
|
2
|
+
/**
|
|
3
|
+
* Helper class for creating integrity signatures.
|
|
4
|
+
* @see https://www.w3.org/TR/SRI/
|
|
5
|
+
*/
|
|
6
|
+
export declare class IntegrityHelper {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* Generate an integrity signature for the given content using the specified hash algorithm.
|
|
13
|
+
* @param type The hash algorithm to use, either "sha256", "sha384" or "sha512".
|
|
14
|
+
* @param content The content to hash as a Uint8Array.
|
|
15
|
+
* @returns The integrity signature in the format "type-base64hash".
|
|
16
|
+
*/
|
|
17
|
+
static generate(type: IntegrityAlgorithm, content: Uint8Array): string;
|
|
18
|
+
/**
|
|
19
|
+
* Verify an integrity signature for the given content.
|
|
20
|
+
* @param integrity The integrity signature in the format "type-base64hash".
|
|
21
|
+
* @param content The content to hash as a Uint8Array.
|
|
22
|
+
* @returns True if the integrity signature matches the content.
|
|
23
|
+
* @throws If the integrity signature is invalid.
|
|
24
|
+
*/
|
|
25
|
+
static verify(integrity: string, content: Uint8Array): boolean;
|
|
26
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,10 +15,12 @@ export * from "./hashes/sha1.js";
|
|
|
15
15
|
export * from "./hashes/sha256.js";
|
|
16
16
|
export * from "./hashes/sha3.js";
|
|
17
17
|
export * from "./hashes/sha512.js";
|
|
18
|
+
export * from "./helpers/integrityHelper.js";
|
|
18
19
|
export * from "./helpers/pemHelper.js";
|
|
19
20
|
export * from "./keys/bip32Path.js";
|
|
20
21
|
export * from "./keys/bip39.js";
|
|
21
22
|
export * from "./keys/slip0010.js";
|
|
23
|
+
export * from "./models/integrityAlgorithm.js";
|
|
22
24
|
export * from "./models/keyType.js";
|
|
23
25
|
export * from "./otp/hotp.js";
|
|
24
26
|
export * from "./otp/totp.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names of the integrity algorithms.
|
|
3
|
+
*/
|
|
4
|
+
export declare const IntegrityAlgorithm: {
|
|
5
|
+
/**
|
|
6
|
+
* Sha256.
|
|
7
|
+
*/
|
|
8
|
+
readonly Sha256: "sha256";
|
|
9
|
+
/**
|
|
10
|
+
* Sha384.
|
|
11
|
+
*/
|
|
12
|
+
readonly Sha384: "sha384";
|
|
13
|
+
/**
|
|
14
|
+
* Sha512.
|
|
15
|
+
*/
|
|
16
|
+
readonly Sha512: "sha512";
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Integrity algorithms.
|
|
20
|
+
*/
|
|
21
|
+
export type IntegrityAlgorithm = (typeof IntegrityAlgorithm)[keyof typeof IntegrityAlgorithm];
|
|
@@ -19,16 +19,4 @@ export declare class PasswordGenerator {
|
|
|
19
19
|
* @returns The hashed password.
|
|
20
20
|
*/
|
|
21
21
|
static hashPassword(passwordBytes: Uint8Array, saltBytes: Uint8Array): Promise<string>;
|
|
22
|
-
/**
|
|
23
|
-
* Get a random character from the given character set.
|
|
24
|
-
* @param charSet The character set to get a random character from.
|
|
25
|
-
* @returns A random character from the given character set.
|
|
26
|
-
*/
|
|
27
|
-
private static getRandomChar;
|
|
28
|
-
/**
|
|
29
|
-
* Push a random character from the given character set to the chars array, ensuring no three repeated characters in a row.
|
|
30
|
-
* @param chars The array to push the character to.
|
|
31
|
-
* @param charSet The character set to get a random character from.
|
|
32
|
-
*/
|
|
33
|
-
private static pushChar;
|
|
34
22
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @twin.org/crypto - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.18](https://github.com/twinfoundation/framework/compare/crypto-v0.0.3-next.17...crypto-v0.0.3-next.18) (2026-02-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **crypto:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.3-next.17 to 0.0.3-next.18
|
|
16
|
+
* @twin.org/nameof bumped from 0.0.3-next.17 to 0.0.3-next.18
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.17 to 0.0.3-next.18
|
|
19
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.17 to 0.0.3-next.18
|
|
20
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.17 to 0.0.3-next.18
|
|
21
|
+
|
|
22
|
+
## [0.0.3-next.17](https://github.com/twinfoundation/framework/compare/crypto-v0.0.3-next.16...crypto-v0.0.3-next.17) (2026-02-09)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* factory create and integrity ([#235](https://github.com/twinfoundation/framework/issues/235)) ([9f98b99](https://github.com/twinfoundation/framework/commit/9f98b99daf46eb365346fae49cc4ffba63e74cb3))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* docs ([9df46e0](https://github.com/twinfoundation/framework/commit/9df46e0a3940a4d1f479373f58830519262f9590))
|
|
33
|
+
* docs ([67c8887](https://github.com/twinfoundation/framework/commit/67c888739448e753106ea067a8703d058e0ddf12))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Dependencies
|
|
37
|
+
|
|
38
|
+
* The following workspace dependencies were updated
|
|
39
|
+
* dependencies
|
|
40
|
+
* @twin.org/core bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
41
|
+
* @twin.org/nameof bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
42
|
+
* devDependencies
|
|
43
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
44
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
45
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
46
|
+
|
|
3
47
|
## [0.0.3-next.16](https://github.com/twinfoundation/framework/compare/crypto-v0.0.3-next.15...crypto-v0.0.3-next.16) (2026-02-06)
|
|
4
48
|
|
|
5
49
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Class: IntegrityHelper
|
|
2
|
+
|
|
3
|
+
Helper class for creating integrity signatures.
|
|
4
|
+
|
|
5
|
+
## See
|
|
6
|
+
|
|
7
|
+
https://www.w3.org/TR/SRI/
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new IntegrityHelper**(): `IntegrityHelper`
|
|
14
|
+
|
|
15
|
+
#### Returns
|
|
16
|
+
|
|
17
|
+
`IntegrityHelper`
|
|
18
|
+
|
|
19
|
+
## Properties
|
|
20
|
+
|
|
21
|
+
### CLASS\_NAME
|
|
22
|
+
|
|
23
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
24
|
+
|
|
25
|
+
Runtime name for the class.
|
|
26
|
+
|
|
27
|
+
## Methods
|
|
28
|
+
|
|
29
|
+
### generate()
|
|
30
|
+
|
|
31
|
+
> `static` **generate**(`type`, `content`): `string`
|
|
32
|
+
|
|
33
|
+
Generate an integrity signature for the given content using the specified hash algorithm.
|
|
34
|
+
|
|
35
|
+
#### Parameters
|
|
36
|
+
|
|
37
|
+
##### type
|
|
38
|
+
|
|
39
|
+
[`IntegrityAlgorithm`](../type-aliases/IntegrityAlgorithm.md)
|
|
40
|
+
|
|
41
|
+
The hash algorithm to use, either "sha256", "sha384" or "sha512".
|
|
42
|
+
|
|
43
|
+
##### content
|
|
44
|
+
|
|
45
|
+
`Uint8Array`
|
|
46
|
+
|
|
47
|
+
The content to hash as a Uint8Array.
|
|
48
|
+
|
|
49
|
+
#### Returns
|
|
50
|
+
|
|
51
|
+
`string`
|
|
52
|
+
|
|
53
|
+
The integrity signature in the format "type-base64hash".
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### verify()
|
|
58
|
+
|
|
59
|
+
> `static` **verify**(`integrity`, `content`): `boolean`
|
|
60
|
+
|
|
61
|
+
Verify an integrity signature for the given content.
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
##### integrity
|
|
66
|
+
|
|
67
|
+
`string`
|
|
68
|
+
|
|
69
|
+
The integrity signature in the format "type-base64hash".
|
|
70
|
+
|
|
71
|
+
##### content
|
|
72
|
+
|
|
73
|
+
`Uint8Array`
|
|
74
|
+
|
|
75
|
+
The content to hash as a Uint8Array.
|
|
76
|
+
|
|
77
|
+
#### Returns
|
|
78
|
+
|
|
79
|
+
`boolean`
|
|
80
|
+
|
|
81
|
+
True if the integrity signature matches the content.
|
|
82
|
+
|
|
83
|
+
#### Throws
|
|
84
|
+
|
|
85
|
+
If the integrity signature is invalid.
|
package/docs/reference/index.md
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
- [Sha256](classes/Sha256.md)
|
|
20
20
|
- [Sha3](classes/Sha3.md)
|
|
21
21
|
- [Sha512](classes/Sha512.md)
|
|
22
|
+
- [IntegrityHelper](classes/IntegrityHelper.md)
|
|
22
23
|
- [PemHelper](classes/PemHelper.md)
|
|
23
24
|
- [Bip32Path](classes/Bip32Path.md)
|
|
24
25
|
- [Bip39](classes/Bip39.md)
|
|
@@ -30,8 +31,10 @@
|
|
|
30
31
|
|
|
31
32
|
## Type Aliases
|
|
32
33
|
|
|
34
|
+
- [IntegrityAlgorithm](type-aliases/IntegrityAlgorithm.md)
|
|
33
35
|
- [KeyType](type-aliases/KeyType.md)
|
|
34
36
|
|
|
35
37
|
## Variables
|
|
36
38
|
|
|
39
|
+
- [IntegrityAlgorithm](variables/IntegrityAlgorithm.md)
|
|
37
40
|
- [KeyType](variables/KeyType.md)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Variable: IntegrityAlgorithm
|
|
2
|
+
|
|
3
|
+
> `const` **IntegrityAlgorithm**: `object`
|
|
4
|
+
|
|
5
|
+
The names of the integrity algorithms.
|
|
6
|
+
|
|
7
|
+
## Type Declaration
|
|
8
|
+
|
|
9
|
+
### Sha256
|
|
10
|
+
|
|
11
|
+
> `readonly` **Sha256**: `"sha256"` = `"sha256"`
|
|
12
|
+
|
|
13
|
+
Sha256.
|
|
14
|
+
|
|
15
|
+
### Sha384
|
|
16
|
+
|
|
17
|
+
> `readonly` **Sha384**: `"sha384"` = `"sha384"`
|
|
18
|
+
|
|
19
|
+
Sha384.
|
|
20
|
+
|
|
21
|
+
### Sha512
|
|
22
|
+
|
|
23
|
+
> `readonly` **Sha512**: `"sha512"` = `"sha512"`
|
|
24
|
+
|
|
25
|
+
Sha512.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/crypto",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.18",
|
|
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.1",
|
|
22
22
|
"@scure/bip39": "2.0.1",
|
|
23
|
-
"@twin.org/core": "0.0.3-next.
|
|
24
|
-
"@twin.org/nameof": "0.0.3-next.
|
|
23
|
+
"@twin.org/core": "0.0.3-next.18",
|
|
24
|
+
"@twin.org/nameof": "0.0.3-next.18",
|
|
25
25
|
"crypto-browserify": "3.12.1",
|
|
26
26
|
"micro-key-producer": "0.8.2"
|
|
27
27
|
},
|