@twin.org/web 0.0.1-next.62 → 0.0.1-next.64

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.
@@ -389,6 +389,10 @@ const MimeTypes = {
389
389
  * Application GZIP - application/gzip
390
390
  */
391
391
  Gzip: "application/gzip",
392
+ /**
393
+ * Application deflate - application/zlib
394
+ */
395
+ Zlib: "application/zlib",
392
396
  /**
393
397
  * Application BZIP2 - application/x-bzip2
394
398
  */
@@ -784,6 +788,18 @@ class Jwk {
784
788
  privateKey
785
789
  };
786
790
  }
791
+ /**
792
+ * Generate a KID for the JWK.
793
+ * @param jwk The JWK to generate a KID for.
794
+ * @returns The KID.
795
+ */
796
+ static async generateKid(jwk) {
797
+ core.Guards.object(Jwk._CLASS_NAME, "jwk", jwk);
798
+ const kidProps = core.ObjectHelper.pick(jwk, ["crv", "kty", "x"]);
799
+ const canonicalJson = core.JsonHelper.canonicalize(kidProps);
800
+ const hash = crypto.Sha256.sum256(core.Converter.utf8ToBytes(canonicalJson));
801
+ return core.Converter.bytesToBase64Url(hash);
802
+ }
787
803
  }
788
804
 
789
805
  // Copyright 2024 IOTA Stiftung.
@@ -1120,6 +1136,11 @@ class MimeTypeHelper {
1120
1136
  if (MimeTypeHelper.checkBytes(data, [0x1f, 0x8b, 0x8])) {
1121
1137
  return MimeTypes.Gzip;
1122
1138
  }
1139
+ if (MimeTypeHelper.checkBytes(data, [0x78, 0x01]) ||
1140
+ MimeTypeHelper.checkBytes(data, [0x78, 0x9c]) ||
1141
+ MimeTypeHelper.checkBytes(data, [0x78, 0xda])) {
1142
+ return MimeTypes.Zlib;
1143
+ }
1123
1144
  if (MimeTypeHelper.checkBytes(data, [0x42, 0x5a, 0x68])) {
1124
1145
  return MimeTypes.Bzip2;
1125
1146
  }
@@ -1172,6 +1193,7 @@ class MimeTypeHelper {
1172
1193
  [MimeTypes.Xml]: "xml",
1173
1194
  [MimeTypes.OctetStream]: "bin",
1174
1195
  [MimeTypes.Gzip]: "gzip",
1196
+ [MimeTypes.Zlib]: "zlib",
1175
1197
  [MimeTypes.Bzip2]: "bz2",
1176
1198
  [MimeTypes.Zip]: "zip",
1177
1199
  [MimeTypes.Pdf]: "pdf",
@@ -1,5 +1,5 @@
1
- import { BaseError, StringHelper, Guards, Is, AsyncCache, ObjectHelper, GeneralError, Converter } from '@twin.org/core';
2
- import { Ed25519 } from '@twin.org/crypto';
1
+ import { BaseError, StringHelper, Guards, Is, AsyncCache, ObjectHelper, GeneralError, Converter, JsonHelper } from '@twin.org/core';
2
+ import { Ed25519, Sha256 } from '@twin.org/crypto';
3
3
  import { importJWK, CompactSign, flattenedVerify, SignJWT, jwtVerify } from 'jose';
4
4
 
5
5
  // Copyright 2024 IOTA Stiftung.
@@ -387,6 +387,10 @@ const MimeTypes = {
387
387
  * Application GZIP - application/gzip
388
388
  */
389
389
  Gzip: "application/gzip",
390
+ /**
391
+ * Application deflate - application/zlib
392
+ */
393
+ Zlib: "application/zlib",
390
394
  /**
391
395
  * Application BZIP2 - application/x-bzip2
392
396
  */
@@ -782,6 +786,18 @@ class Jwk {
782
786
  privateKey
783
787
  };
784
788
  }
789
+ /**
790
+ * Generate a KID for the JWK.
791
+ * @param jwk The JWK to generate a KID for.
792
+ * @returns The KID.
793
+ */
794
+ static async generateKid(jwk) {
795
+ Guards.object(Jwk._CLASS_NAME, "jwk", jwk);
796
+ const kidProps = ObjectHelper.pick(jwk, ["crv", "kty", "x"]);
797
+ const canonicalJson = JsonHelper.canonicalize(kidProps);
798
+ const hash = Sha256.sum256(Converter.utf8ToBytes(canonicalJson));
799
+ return Converter.bytesToBase64Url(hash);
800
+ }
785
801
  }
786
802
 
787
803
  // Copyright 2024 IOTA Stiftung.
@@ -1118,6 +1134,11 @@ class MimeTypeHelper {
1118
1134
  if (MimeTypeHelper.checkBytes(data, [0x1f, 0x8b, 0x8])) {
1119
1135
  return MimeTypes.Gzip;
1120
1136
  }
1137
+ if (MimeTypeHelper.checkBytes(data, [0x78, 0x01]) ||
1138
+ MimeTypeHelper.checkBytes(data, [0x78, 0x9c]) ||
1139
+ MimeTypeHelper.checkBytes(data, [0x78, 0xda])) {
1140
+ return MimeTypes.Zlib;
1141
+ }
1121
1142
  if (MimeTypeHelper.checkBytes(data, [0x42, 0x5a, 0x68])) {
1122
1143
  return MimeTypes.Bzip2;
1123
1144
  }
@@ -1170,6 +1191,7 @@ class MimeTypeHelper {
1170
1191
  [MimeTypes.Xml]: "xml",
1171
1192
  [MimeTypes.OctetStream]: "bin",
1172
1193
  [MimeTypes.Gzip]: "gzip",
1194
+ [MimeTypes.Zlib]: "zlib",
1173
1195
  [MimeTypes.Bzip2]: "bz2",
1174
1196
  [MimeTypes.Zip]: "zip",
1175
1197
  [MimeTypes.Pdf]: "pdf",
@@ -38,6 +38,10 @@ export declare const MimeTypes: {
38
38
  * Application GZIP - application/gzip
39
39
  */
40
40
  readonly Gzip: "application/gzip";
41
+ /**
42
+ * Application deflate - application/zlib
43
+ */
44
+ readonly Zlib: "application/zlib";
41
45
  /**
42
46
  * Application BZIP2 - application/x-bzip2
43
47
  */
@@ -32,4 +32,10 @@ export declare class Jwk {
32
32
  publicKey?: Uint8Array;
33
33
  privateKey?: Uint8Array;
34
34
  }>;
35
+ /**
36
+ * Generate a KID for the JWK.
37
+ * @param jwk The JWK to generate a KID for.
38
+ * @returns The KID.
39
+ */
40
+ static generateKid(jwk: IJwk): Promise<string>;
35
41
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @twin.org/web - Changelog
2
2
 
3
+ ## [0.0.1-next.64](https://github.com/twinfoundation/framework/compare/web-v0.0.1-next.63...web-v0.0.1-next.64) (2025-06-19)
4
+
5
+
6
+ ### Features
7
+
8
+ * add zlib/deflate mime types detection ([72c472b](https://github.com/twinfoundation/framework/commit/72c472b5a35a973e7109336f5b6cdd84dbb8bbcb))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/core bumped from 0.0.1-next.63 to 0.0.1-next.64
16
+ * @twin.org/crypto bumped from 0.0.1-next.63 to 0.0.1-next.64
17
+
18
+ ## [0.0.1-next.63](https://github.com/twinfoundation/framework/compare/web-v0.0.1-next.62...web-v0.0.1-next.63) (2025-06-18)
19
+
20
+
21
+ ### Features
22
+
23
+ * add kid method to Jwk ([bc9239e](https://github.com/twinfoundation/framework/commit/bc9239ed9896a053d83e00ca221e962704ebc277))
24
+
25
+
26
+ ### Dependencies
27
+
28
+ * The following workspace dependencies were updated
29
+ * dependencies
30
+ * @twin.org/core bumped from 0.0.1-next.62 to 0.0.1-next.63
31
+ * @twin.org/crypto bumped from 0.0.1-next.62 to 0.0.1-next.63
32
+
3
33
  ## [0.0.1-next.62](https://github.com/twinfoundation/framework/compare/web-v0.0.1-next.61...web-v0.0.1-next.62) (2025-06-17)
4
34
 
5
35
 
@@ -105,3 +105,25 @@ The JWK to convert to raw.
105
105
  `Promise`\<\{ `publicKey?`: `Uint8Array`\<`ArrayBufferLike`\>; `privateKey?`: `Uint8Array`\<`ArrayBufferLike`\>; \}\>
106
106
 
107
107
  The crypto key.
108
+
109
+ ***
110
+
111
+ ### generateKid()
112
+
113
+ > `static` **generateKid**(`jwk`): `Promise`\<`string`\>
114
+
115
+ Generate a KID for the JWK.
116
+
117
+ #### Parameters
118
+
119
+ ##### jwk
120
+
121
+ [`IJwk`](../interfaces/IJwk.md)
122
+
123
+ The JWK to generate a KID for.
124
+
125
+ #### Returns
126
+
127
+ `Promise`\<`string`\>
128
+
129
+ The KID.
@@ -60,6 +60,12 @@ Application Octet Stream, arbitrary binary - application/octet-stream
60
60
 
61
61
  Application GZIP - application/gzip
62
62
 
63
+ ### Zlib
64
+
65
+ > `readonly` **Zlib**: `"application/zlib"` = `"application/zlib"`
66
+
67
+ Application deflate - application/zlib
68
+
63
69
  ### Bzip2
64
70
 
65
71
  > `readonly` **Bzip2**: `"application/x-bzip2"` = `"application/x-bzip2"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/web",
3
- "version": "0.0.1-next.62",
3
+ "version": "0.0.1-next.64",
4
4
  "description": "Contains classes for use with web operations",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,8 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.0.1-next.62",
18
- "@twin.org/crypto": "0.0.1-next.62",
17
+ "@twin.org/core": "0.0.1-next.64",
18
+ "@twin.org/crypto": "0.0.1-next.64",
19
19
  "@twin.org/nameof": "next",
20
20
  "jose": "6.0.11"
21
21
  },