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

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.
@@ -784,6 +784,18 @@ class Jwk {
784
784
  privateKey
785
785
  };
786
786
  }
787
+ /**
788
+ * Generate a KID for the JWK.
789
+ * @param jwk The JWK to generate a KID for.
790
+ * @returns The KID.
791
+ */
792
+ static async generateKid(jwk) {
793
+ core.Guards.object(Jwk._CLASS_NAME, "jwk", jwk);
794
+ const kidProps = core.ObjectHelper.pick(jwk, ["crv", "kty", "x"]);
795
+ const canonicalJson = core.JsonHelper.canonicalize(kidProps);
796
+ const hash = crypto.Sha256.sum256(core.Converter.utf8ToBytes(canonicalJson));
797
+ return core.Converter.bytesToBase64Url(hash);
798
+ }
787
799
  }
788
800
 
789
801
  // Copyright 2024 IOTA Stiftung.
@@ -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.
@@ -782,6 +782,18 @@ class Jwk {
782
782
  privateKey
783
783
  };
784
784
  }
785
+ /**
786
+ * Generate a KID for the JWK.
787
+ * @param jwk The JWK to generate a KID for.
788
+ * @returns The KID.
789
+ */
790
+ static async generateKid(jwk) {
791
+ Guards.object(Jwk._CLASS_NAME, "jwk", jwk);
792
+ const kidProps = ObjectHelper.pick(jwk, ["crv", "kty", "x"]);
793
+ const canonicalJson = JsonHelper.canonicalize(kidProps);
794
+ const hash = Sha256.sum256(Converter.utf8ToBytes(canonicalJson));
795
+ return Converter.bytesToBase64Url(hash);
796
+ }
785
797
  }
786
798
 
787
799
  // Copyright 2024 IOTA Stiftung.
@@ -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,20 @@
1
1
  # @twin.org/web - Changelog
2
2
 
3
+ ## [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)
4
+
5
+
6
+ ### Features
7
+
8
+ * add kid method to Jwk ([bc9239e](https://github.com/twinfoundation/framework/commit/bc9239ed9896a053d83e00ca221e962704ebc277))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/core bumped from 0.0.1-next.62 to 0.0.1-next.63
16
+ * @twin.org/crypto bumped from 0.0.1-next.62 to 0.0.1-next.63
17
+
3
18
  ## [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
19
 
5
20
 
@@ -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.
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.63",
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.63",
18
+ "@twin.org/crypto": "0.0.1-next.63",
19
19
  "@twin.org/nameof": "next",
20
20
  "jose": "6.0.11"
21
21
  },