@twin.org/web 0.0.1-next.43 → 0.0.1-next.45

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.
@@ -754,6 +754,26 @@ class Jwk {
754
754
  };
755
755
  return jwk;
756
756
  }
757
+ /**
758
+ * Convert the JWK to raw keys.
759
+ * @param jwk The JWK to convert to raw.
760
+ * @returns The crypto key.
761
+ */
762
+ static async toRaw(jwk) {
763
+ core.Guards.object(Jwk._CLASS_NAME, "jwk", jwk);
764
+ let publicKey;
765
+ let privateKey;
766
+ if (core.Is.stringBase64Url(jwk.x)) {
767
+ publicKey = core.Converter.base64UrlToBytes(jwk.x);
768
+ }
769
+ if (core.Is.stringBase64Url(jwk.d)) {
770
+ privateKey = core.Converter.base64UrlToBytes(jwk.d);
771
+ }
772
+ return {
773
+ publicKey,
774
+ privateKey
775
+ };
776
+ }
757
777
  }
758
778
 
759
779
  // Copyright 2024 IOTA Stiftung.
@@ -752,6 +752,26 @@ class Jwk {
752
752
  };
753
753
  return jwk;
754
754
  }
755
+ /**
756
+ * Convert the JWK to raw keys.
757
+ * @param jwk The JWK to convert to raw.
758
+ * @returns The crypto key.
759
+ */
760
+ static async toRaw(jwk) {
761
+ Guards.object(Jwk._CLASS_NAME, "jwk", jwk);
762
+ let publicKey;
763
+ let privateKey;
764
+ if (Is.stringBase64Url(jwk.x)) {
765
+ publicKey = Converter.base64UrlToBytes(jwk.x);
766
+ }
767
+ if (Is.stringBase64Url(jwk.d)) {
768
+ privateKey = Converter.base64UrlToBytes(jwk.d);
769
+ }
770
+ return {
771
+ publicKey,
772
+ privateKey
773
+ };
774
+ }
755
775
  }
756
776
 
757
777
  // Copyright 2024 IOTA Stiftung.
@@ -22,4 +22,13 @@ export declare class Jwk {
22
22
  * @returns The crypto key.
23
23
  */
24
24
  static fromEd25519Public(publicKey: Uint8Array): Promise<IJwk>;
25
+ /**
26
+ * Convert the JWK to raw keys.
27
+ * @param jwk The JWK to convert to raw.
28
+ * @returns The crypto key.
29
+ */
30
+ static toRaw(jwk: IJwk): Promise<{
31
+ publicKey?: Uint8Array;
32
+ privateKey?: Uint8Array;
33
+ }>;
25
34
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/web - Changelog
2
2
 
3
- ## 0.0.1-next.43
3
+ ## 0.0.1-next.45
4
4
 
5
5
  - Initial Release
@@ -77,3 +77,25 @@ The private key to use.
77
77
  `Promise`\<[`IJwk`](../interfaces/IJwk.md)\>
78
78
 
79
79
  The crypto key.
80
+
81
+ ***
82
+
83
+ ### toRaw()
84
+
85
+ > `static` **toRaw**(`jwk`): `Promise`\<\{ `publicKey`: `Uint8Array`; `privateKey`: `Uint8Array`; \}\>
86
+
87
+ Convert the JWK to raw keys.
88
+
89
+ #### Parameters
90
+
91
+ ##### jwk
92
+
93
+ [`IJwk`](../interfaces/IJwk.md)
94
+
95
+ The JWK to convert to raw.
96
+
97
+ #### Returns
98
+
99
+ `Promise`\<\{ `publicKey`: `Uint8Array`; `privateKey`: `Uint8Array`; \}\>
100
+
101
+ The crypto key.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/web",
3
- "version": "0.0.1-next.43",
3
+ "version": "0.0.1-next.45",
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.43",
18
- "@twin.org/crypto": "0.0.1-next.43",
17
+ "@twin.org/core": "0.0.1-next.45",
18
+ "@twin.org/crypto": "0.0.1-next.45",
19
19
  "@twin.org/nameof": "next",
20
20
  "jose": "6.0.8"
21
21
  },