@twin.org/web 0.0.1-next.53 → 0.0.1-next.55
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.
- package/dist/cjs/index.cjs +6 -5
- package/dist/esm/index.mjs +6 -5
- package/dist/types/utils/jwk.d.ts +2 -1
- package/docs/changelog.md +30 -0
- package/docs/reference/classes/Jwk.md +7 -1
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -543,7 +543,7 @@ class FetchHelper {
|
|
|
543
543
|
if (isErr && core.Is.stringValue(err.message) && err.message.includes("Failed to fetch")) {
|
|
544
544
|
lastError = new FetchError(source, `${FetchHelper._CLASS_NAME_CAMEL_CASE}.connectivity`, HttpStatusCode.serviceUnavailable, {
|
|
545
545
|
url
|
|
546
|
-
});
|
|
546
|
+
}, err);
|
|
547
547
|
}
|
|
548
548
|
else {
|
|
549
549
|
const isAbort = isErr && err.name === "AbortError";
|
|
@@ -558,7 +558,7 @@ class FetchHelper {
|
|
|
558
558
|
if (isErr && "statusText" in err) {
|
|
559
559
|
props.statusText = err.statusText;
|
|
560
560
|
}
|
|
561
|
-
lastError = new FetchError(source, `${FetchHelper._CLASS_NAME_CAMEL_CASE}.${isAbort ? "timeout" : "general"}`, httpStatus, props);
|
|
561
|
+
lastError = new FetchError(source, `${FetchHelper._CLASS_NAME_CAMEL_CASE}.${isAbort ? "timeout" : "general"}`, httpStatus, props, err);
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
564
|
finally {
|
|
@@ -718,12 +718,13 @@ class Jwk {
|
|
|
718
718
|
/**
|
|
719
719
|
* Convert the JWK to a crypto key.
|
|
720
720
|
* @param jwk The JWK to convert.
|
|
721
|
+
* @param alg The alg to be used, defaults to jwk.alg.
|
|
721
722
|
* @returns The crypto key.
|
|
722
723
|
*/
|
|
723
|
-
static async toCryptoKey(jwk) {
|
|
724
|
+
static async toCryptoKey(jwk, alg) {
|
|
724
725
|
core.Guards.object(Jwk._CLASS_NAME, "jwk", jwk);
|
|
725
726
|
try {
|
|
726
|
-
return jose.importJWK(jwk);
|
|
727
|
+
return jose.importJWK(jwk, alg);
|
|
727
728
|
}
|
|
728
729
|
catch (err) {
|
|
729
730
|
throw new core.GeneralError(Jwk._CLASS_NAME, "jwkImportFailed", undefined, err);
|
|
@@ -809,7 +810,7 @@ class Jws {
|
|
|
809
810
|
try {
|
|
810
811
|
const jws = await new jose.CompactSign(hash)
|
|
811
812
|
.setProtectedHeader({
|
|
812
|
-
alg: core.Is.uint8Array(privateKey) ?
|
|
813
|
+
alg: algOverride ?? (core.Is.uint8Array(privateKey) ? "EdDSA" : privateKey.algorithm.name),
|
|
813
814
|
b64: false,
|
|
814
815
|
crit: ["b64"]
|
|
815
816
|
})
|
package/dist/esm/index.mjs
CHANGED
|
@@ -541,7 +541,7 @@ class FetchHelper {
|
|
|
541
541
|
if (isErr && Is.stringValue(err.message) && err.message.includes("Failed to fetch")) {
|
|
542
542
|
lastError = new FetchError(source, `${FetchHelper._CLASS_NAME_CAMEL_CASE}.connectivity`, HttpStatusCode.serviceUnavailable, {
|
|
543
543
|
url
|
|
544
|
-
});
|
|
544
|
+
}, err);
|
|
545
545
|
}
|
|
546
546
|
else {
|
|
547
547
|
const isAbort = isErr && err.name === "AbortError";
|
|
@@ -556,7 +556,7 @@ class FetchHelper {
|
|
|
556
556
|
if (isErr && "statusText" in err) {
|
|
557
557
|
props.statusText = err.statusText;
|
|
558
558
|
}
|
|
559
|
-
lastError = new FetchError(source, `${FetchHelper._CLASS_NAME_CAMEL_CASE}.${isAbort ? "timeout" : "general"}`, httpStatus, props);
|
|
559
|
+
lastError = new FetchError(source, `${FetchHelper._CLASS_NAME_CAMEL_CASE}.${isAbort ? "timeout" : "general"}`, httpStatus, props, err);
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
562
|
finally {
|
|
@@ -716,12 +716,13 @@ class Jwk {
|
|
|
716
716
|
/**
|
|
717
717
|
* Convert the JWK to a crypto key.
|
|
718
718
|
* @param jwk The JWK to convert.
|
|
719
|
+
* @param alg The alg to be used, defaults to jwk.alg.
|
|
719
720
|
* @returns The crypto key.
|
|
720
721
|
*/
|
|
721
|
-
static async toCryptoKey(jwk) {
|
|
722
|
+
static async toCryptoKey(jwk, alg) {
|
|
722
723
|
Guards.object(Jwk._CLASS_NAME, "jwk", jwk);
|
|
723
724
|
try {
|
|
724
|
-
return importJWK(jwk);
|
|
725
|
+
return importJWK(jwk, alg);
|
|
725
726
|
}
|
|
726
727
|
catch (err) {
|
|
727
728
|
throw new GeneralError(Jwk._CLASS_NAME, "jwkImportFailed", undefined, err);
|
|
@@ -807,7 +808,7 @@ class Jws {
|
|
|
807
808
|
try {
|
|
808
809
|
const jws = await new CompactSign(hash)
|
|
809
810
|
.setProtectedHeader({
|
|
810
|
-
alg: Is.uint8Array(privateKey) ?
|
|
811
|
+
alg: algOverride ?? (Is.uint8Array(privateKey) ? "EdDSA" : privateKey.algorithm.name),
|
|
811
812
|
b64: false,
|
|
812
813
|
crit: ["b64"]
|
|
813
814
|
})
|
|
@@ -7,9 +7,10 @@ export declare class Jwk {
|
|
|
7
7
|
/**
|
|
8
8
|
* Convert the JWK to a crypto key.
|
|
9
9
|
* @param jwk The JWK to convert.
|
|
10
|
+
* @param alg The alg to be used, defaults to jwk.alg.
|
|
10
11
|
* @returns The crypto key.
|
|
11
12
|
*/
|
|
12
|
-
static toCryptoKey(jwk: IJwk): Promise<JwkCryptoKey>;
|
|
13
|
+
static toCryptoKey(jwk: IJwk, alg?: string): Promise<JwkCryptoKey>;
|
|
13
14
|
/**
|
|
14
15
|
* Convert the Ed25519 private key to a crypto key.
|
|
15
16
|
* @param privateKey The private key to use.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @twin.org/web - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.1-next.55](https://github.com/twinfoundation/framework/compare/web-v0.0.1-next.54...web-v0.0.1-next.55) (2025-05-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* ensure the alg is the correct one when generating JWK or JWS ([#136](https://github.com/twinfoundation/framework/issues/136)) ([46a5af1](https://github.com/twinfoundation/framework/commit/46a5af127192d7048068275d14f555f09add3642))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.1-next.54 to 0.0.1-next.55
|
|
16
|
+
* @twin.org/crypto bumped from 0.0.1-next.54 to 0.0.1-next.55
|
|
17
|
+
|
|
18
|
+
## [0.0.1-next.54](https://github.com/twinfoundation/framework/compare/web-v0.0.1-next.53...web-v0.0.1-next.54) (2025-05-06)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* wrap inner error within FetchError / 2 ([#134](https://github.com/twinfoundation/framework/issues/134)) ([2ddb101](https://github.com/twinfoundation/framework/commit/2ddb101c3778be4e99559e37aa036cd7101585fb))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Dependencies
|
|
27
|
+
|
|
28
|
+
* The following workspace dependencies were updated
|
|
29
|
+
* dependencies
|
|
30
|
+
* @twin.org/core bumped from 0.0.1-next.53 to 0.0.1-next.54
|
|
31
|
+
* @twin.org/crypto bumped from 0.0.1-next.53 to 0.0.1-next.54
|
|
32
|
+
|
|
3
33
|
## [0.0.1-next.53](https://github.com/twinfoundation/framework/compare/web-v0.0.1-next.52...web-v0.0.1-next.53) (2025-05-01)
|
|
4
34
|
|
|
5
35
|
|
|
@@ -16,7 +16,7 @@ Class to handle JSON Web Keys.
|
|
|
16
16
|
|
|
17
17
|
### toCryptoKey()
|
|
18
18
|
|
|
19
|
-
> `static` **toCryptoKey**(`jwk`): `Promise`\<[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)\>
|
|
19
|
+
> `static` **toCryptoKey**(`jwk`, `alg?`): `Promise`\<[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)\>
|
|
20
20
|
|
|
21
21
|
Convert the JWK to a crypto key.
|
|
22
22
|
|
|
@@ -28,6 +28,12 @@ Convert the JWK to a crypto key.
|
|
|
28
28
|
|
|
29
29
|
The JWK to convert.
|
|
30
30
|
|
|
31
|
+
##### alg?
|
|
32
|
+
|
|
33
|
+
`string`
|
|
34
|
+
|
|
35
|
+
The alg to be used, defaults to jwk.alg.
|
|
36
|
+
|
|
31
37
|
#### Returns
|
|
32
38
|
|
|
33
39
|
`Promise`\<[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)\>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/web",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.55",
|
|
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.
|
|
18
|
-
"@twin.org/crypto": "0.0.1-next.
|
|
17
|
+
"@twin.org/core": "0.0.1-next.55",
|
|
18
|
+
"@twin.org/crypto": "0.0.1-next.55",
|
|
19
19
|
"@twin.org/nameof": "next",
|
|
20
20
|
"jose": "6.0.10"
|
|
21
21
|
},
|