@twin.org/crypto 0.0.3-next.38 → 0.0.3-next.39
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.
|
@@ -1 +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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,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,IAAI,EACJ,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,\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/docs/changelog.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.39](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.3-next.38...crypto-v0.0.3-next.39) (2026-05-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* improve signatures ([cdd24be](https://github.com/iotaledger/twin-framework/commit/cdd24be6fb898d33955b6f2f93c3ddbd73582269))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.3-next.38 to 0.0.3-next.39
|
|
16
|
+
* @twin.org/nameof bumped from 0.0.3-next.38 to 0.0.3-next.39
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.38 to 0.0.3-next.39
|
|
19
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.38 to 0.0.3-next.39
|
|
20
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.38 to 0.0.3-next.39
|
|
21
|
+
|
|
3
22
|
## [0.0.3-next.38](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.3-next.37...crypto-v0.0.3-next.38) (2026-05-11)
|
|
4
23
|
|
|
5
24
|
|
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.39",
|
|
4
4
|
"description": "Helper methods and classes which implement cryptographic functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
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.3-next.
|
|
24
|
-
"@twin.org/nameof": "0.0.3-next.
|
|
23
|
+
"@twin.org/core": "0.0.3-next.39",
|
|
24
|
+
"@twin.org/nameof": "0.0.3-next.39",
|
|
25
25
|
"micro-key-producer": "0.8.6"
|
|
26
26
|
},
|
|
27
27
|
"main": "./dist/es/index.js",
|