@twin.org/web 0.9.2-next.5 → 0.9.2-next.7

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,7 +1,7 @@
1
1
  // Copyright 2024 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  import { GeneralError, Guards, Is } from "@twin.org/core";
4
- import { CompactSign, flattenedVerify } from "jose";
4
+ import { FlattenedSign, flattenedVerify } from "jose";
5
5
  /**
6
6
  * Class to handle JSON Web Signatures.
7
7
  */
@@ -21,14 +21,14 @@ export class Jws {
21
21
  Guards.defined(Jws.CLASS_NAME, "privateKey", privateKey);
22
22
  Guards.uint8Array(Jws.CLASS_NAME, "hash", hash);
23
23
  try {
24
- const jws = await new CompactSign(hash)
24
+ const jws = await new FlattenedSign(hash)
25
25
  .setProtectedHeader({
26
26
  alg: algOverride ?? (Is.uint8Array(privateKey) ? "EdDSA" : privateKey.algorithm.name),
27
27
  b64: false,
28
28
  crit: ["b64"]
29
29
  })
30
30
  .sign(privateKey);
31
- return jws;
31
+ return `${jws.protected}.${jws.payload}.${jws.signature}`;
32
32
  }
33
33
  catch (err) {
34
34
  throw new GeneralError(Jws.CLASS_NAME, "createFailed", undefined, err);
@@ -1 +1 @@
1
- {"version":3,"file":"jws.js","sourceRoot":"","sources":["../../../src/utils/jws.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGpD;;GAEG;AACH,MAAM,OAAO,GAAG;IACf;;OAEG;IACI,MAAM,CAAU,UAAU,SAAyB;IAE1D;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACzB,UAAwB,EACxB,IAAgB,EAChB,WAAoB;QAEpB,MAAM,CAAC,OAAO,CAAC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F,OAAO,IAAI,CAAC;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QACxE,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { CompactSign, flattenedVerify } from \"jose\";\nimport type { JwkCryptoKey } from \"../models/jwkCryptoKey.js\";\n\n/**\n * Class to handle JSON Web Signatures.\n */\nexport class Jws {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Jws>();\n\n\t/**\n\t * Create a signature.\n\t * @param privateKey The private key to use.\n\t * @param hash The hash to sign.\n\t * @param algOverride An optional algorithm override.\n\t * @returns The signature.\n\t */\n\tpublic static async create(\n\t\tprivateKey: JwkCryptoKey,\n\t\thash: Uint8Array,\n\t\talgOverride?: string\n\t): Promise<string> {\n\t\tGuards.defined(Jws.CLASS_NAME, nameof(privateKey), privateKey);\n\t\tGuards.uint8Array(Jws.CLASS_NAME, nameof(hash), hash);\n\n\t\ttry {\n\t\t\tconst jws = await new CompactSign(hash)\n\t\t\t\t.setProtectedHeader({\n\t\t\t\t\talg: algOverride ?? (Is.uint8Array(privateKey) ? \"EdDSA\" : privateKey.algorithm.name),\n\t\t\t\t\tb64: false,\n\t\t\t\t\tcrit: [\"b64\"]\n\t\t\t\t})\n\t\t\t\t.sign(privateKey);\n\n\t\t\treturn jws;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(Jws.CLASS_NAME, \"createFailed\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Verify a signature.\n\t * @param jws The signature to verify.\n\t * @param publicKey The public key to verify the signature with.\n\t * @param hash The hash to verify.\n\t * @returns True if the signature was verified.\n\t */\n\tpublic static async verify(\n\t\tjws: string,\n\t\tpublicKey: JwkCryptoKey,\n\t\thash: Uint8Array\n\t): Promise<boolean> {\n\t\tGuards.stringValue(Jws.CLASS_NAME, nameof(jws), jws);\n\t\tGuards.defined(Jws.CLASS_NAME, nameof(publicKey), publicKey);\n\t\tGuards.uint8Array(Jws.CLASS_NAME, nameof(hash), hash);\n\n\t\ttry {\n\t\t\tconst jwsParts: string[] = jws.split(\".\");\n\n\t\t\tawait flattenedVerify(\n\t\t\t\t{ protected: jwsParts[0], payload: hash, signature: jwsParts[2] },\n\t\t\t\tpublicKey\n\t\t\t);\n\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(Jws.CLASS_NAME, \"verifyFailed\", undefined, err);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"jws.js","sourceRoot":"","sources":["../../../src/utils/jws.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,GAAG;IACf;;OAEG;IACI,MAAM,CAAU,UAAU,SAAyB;IAE1D;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACzB,UAAwB,EACxB,IAAgB,EAChB,WAAoB;QAEpB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QAC/D,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,UAAgB,IAAI,CAAC,CAAC;QAEtD,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC;iBACvC,kBAAkB,CAAC;gBACnB,GAAG,EAAE,WAAW,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,O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nimport { GeneralError, Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { FlattenedSign, flattenedVerify } from \"jose\";\nimport type { JwkCryptoKey } from \"../models/jwkCryptoKey.js\";\n\n/**\n * Class to handle JSON Web Signatures.\n */\nexport class Jws {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Jws>();\n\n\t/**\n\t * Create a signature.\n\t * @param privateKey The private key to use.\n\t * @param hash The hash to sign.\n\t * @param algOverride An optional algorithm override.\n\t * @returns The signature.\n\t */\n\tpublic static async create(\n\t\tprivateKey: JwkCryptoKey,\n\t\thash: Uint8Array,\n\t\talgOverride?: string\n\t): Promise<string> {\n\t\tGuards.defined(Jws.CLASS_NAME, nameof(privateKey), privateKey);\n\t\tGuards.uint8Array(Jws.CLASS_NAME, nameof(hash), hash);\n\n\t\ttry {\n\t\t\tconst jws = await new FlattenedSign(hash)\n\t\t\t\t.setProtectedHeader({\n\t\t\t\t\talg: algOverride ?? (Is.uint8Array(privateKey) ? \"EdDSA\" : privateKey.algorithm.name),\n\t\t\t\t\tb64: false,\n\t\t\t\t\tcrit: [\"b64\"]\n\t\t\t\t})\n\t\t\t\t.sign(privateKey);\n\n\t\t\treturn `${jws.protected}.${jws.payload}.${jws.signature}`;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(Jws.CLASS_NAME, \"createFailed\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Verify a signature.\n\t * @param jws The signature to verify.\n\t * @param publicKey The public key to verify the signature with.\n\t * @param hash The hash to verify.\n\t * @returns True if the signature was verified.\n\t */\n\tpublic static async verify(\n\t\tjws: string,\n\t\tpublicKey: JwkCryptoKey,\n\t\thash: Uint8Array\n\t): Promise<boolean> {\n\t\tGuards.stringValue(Jws.CLASS_NAME, nameof(jws), jws);\n\t\tGuards.defined(Jws.CLASS_NAME, nameof(publicKey), publicKey);\n\t\tGuards.uint8Array(Jws.CLASS_NAME, nameof(hash), hash);\n\n\t\ttry {\n\t\t\tconst jwsParts: string[] = jws.split(\".\");\n\n\t\t\tawait flattenedVerify(\n\t\t\t\t{ protected: jwsParts[0], payload: hash, signature: jwsParts[2] },\n\t\t\t\tpublicKey\n\t\t\t);\n\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(Jws.CLASS_NAME, \"verifyFailed\", undefined, err);\n\t\t}\n\t}\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.2-next.7](https://github.com/iotaledger/twin-framework/compare/web-v0.9.2-next.6...web-v0.9.2-next.7) (2026-08-07)
4
+
5
+
6
+ ### Features
7
+
8
+ * linting and dependency update ([676b4e9](https://github.com/iotaledger/twin-framework/commit/676b4e9d9bce158065200bbf875bb31da81d166d))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/core bumped from 0.9.2-next.6 to 0.9.2-next.7
16
+ * @twin.org/crypto bumped from 0.9.2-next.6 to 0.9.2-next.7
17
+ * @twin.org/nameof bumped from 0.9.2-next.6 to 0.9.2-next.7
18
+ * devDependencies
19
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.6 to 0.9.2-next.7
20
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.6 to 0.9.2-next.7
21
+ * @twin.org/validate-locales bumped from 0.9.2-next.6 to 0.9.2-next.7
22
+
23
+ ## [0.9.2-next.6](https://github.com/iotaledger/twin-framework/compare/web-v0.9.2-next.5...web-v0.9.2-next.6) (2026-08-04)
24
+
25
+
26
+ ### Miscellaneous Chores
27
+
28
+ * **web:** Synchronize repo versions
29
+
30
+
31
+ ### Dependencies
32
+
33
+ * The following workspace dependencies were updated
34
+ * dependencies
35
+ * @twin.org/core bumped from 0.9.2-next.5 to 0.9.2-next.6
36
+ * @twin.org/crypto bumped from 0.9.2-next.5 to 0.9.2-next.6
37
+ * @twin.org/nameof bumped from 0.9.2-next.5 to 0.9.2-next.6
38
+ * devDependencies
39
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.5 to 0.9.2-next.6
40
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.5 to 0.9.2-next.6
41
+ * @twin.org/validate-locales bumped from 0.9.2-next.5 to 0.9.2-next.6
42
+
3
43
  ## [0.9.2-next.5](https://github.com/iotaledger/twin-framework/compare/web-v0.9.2-next.4...web-v0.9.2-next.5) (2026-08-03)
4
44
 
5
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/web",
3
- "version": "0.9.2-next.5",
3
+ "version": "0.9.2-next.7",
4
4
  "description": "Classes for use with web operations",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,10 +14,10 @@
14
14
  "node": ">=24.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.9.2-next.5",
18
- "@twin.org/crypto": "0.9.2-next.5",
19
- "@twin.org/nameof": "0.9.2-next.5",
20
- "jose": "6.2.4"
17
+ "@twin.org/core": "0.9.2-next.7",
18
+ "@twin.org/crypto": "0.9.2-next.7",
19
+ "@twin.org/nameof": "0.9.2-next.7",
20
+ "jose": "6.2.8"
21
21
  },
22
22
  "main": "./dist/es/index.js",
23
23
  "types": "./dist/types/index.d.ts",