@twin.org/web 0.0.2-next.19 → 0.0.2-next.21
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 +63 -62
- package/dist/esm/index.mjs +63 -62
- package/dist/types/utils/fetchHelper.d.ts +4 -0
- package/dist/types/utils/jwk.d.ts +4 -0
- package/dist/types/utils/jws.d.ts +4 -0
- package/dist/types/utils/jwt.d.ts +4 -0
- package/docs/changelog.md +39 -0
- package/docs/reference/classes/FetchHelper.md +8 -0
- package/docs/reference/classes/Jwk.md +8 -0
- package/docs/reference/classes/Jws.md +8 -0
- package/docs/reference/classes/Jwt.md +8 -0
- package/locales/.validate-ignore +1 -0
- package/locales/en.json +3 -2
- package/package.json +20 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -455,9 +455,8 @@ const MimeTypes = {
|
|
|
455
455
|
class FetchHelper {
|
|
456
456
|
/**
|
|
457
457
|
* Runtime name for the class.
|
|
458
|
-
* @internal
|
|
459
458
|
*/
|
|
460
|
-
static
|
|
459
|
+
static CLASS_NAME = "FetchHelper";
|
|
461
460
|
/**
|
|
462
461
|
* Prefix to use for cache entries.
|
|
463
462
|
* @internal
|
|
@@ -473,28 +472,28 @@ class FetchHelper {
|
|
|
473
472
|
* @returns The response.
|
|
474
473
|
*/
|
|
475
474
|
static async fetch(source, url, method, body, options) {
|
|
476
|
-
core.Guards.string(FetchHelper.
|
|
477
|
-
core.Guards.string(FetchHelper.
|
|
478
|
-
core.Guards.arrayOneOf(FetchHelper.
|
|
475
|
+
core.Guards.string(FetchHelper.CLASS_NAME, "source", source);
|
|
476
|
+
core.Guards.string(FetchHelper.CLASS_NAME, "url", url);
|
|
477
|
+
core.Guards.arrayOneOf(FetchHelper.CLASS_NAME, "method", method, Object.values(HttpMethod));
|
|
479
478
|
if (!core.Is.undefined(body) && !core.Is.uint8Array(body)) {
|
|
480
|
-
core.Guards.string(FetchHelper.
|
|
479
|
+
core.Guards.string(FetchHelper.CLASS_NAME, "body", body);
|
|
481
480
|
}
|
|
482
481
|
if (!core.Is.undefined(options)) {
|
|
483
|
-
core.Guards.object(FetchHelper.
|
|
482
|
+
core.Guards.object(FetchHelper.CLASS_NAME, "options", options);
|
|
484
483
|
if (!core.Is.undefined(options.headers)) {
|
|
485
|
-
core.Guards.object(FetchHelper.
|
|
484
|
+
core.Guards.object(FetchHelper.CLASS_NAME, "options.headers", options.headers);
|
|
486
485
|
}
|
|
487
486
|
if (!core.Is.undefined(options.timeoutMs)) {
|
|
488
|
-
core.Guards.integer(FetchHelper.
|
|
487
|
+
core.Guards.integer(FetchHelper.CLASS_NAME, "options.timeoutMs", options.timeoutMs);
|
|
489
488
|
}
|
|
490
489
|
if (!core.Is.undefined(options.includeCredentials)) {
|
|
491
|
-
core.Guards.boolean(FetchHelper.
|
|
490
|
+
core.Guards.boolean(FetchHelper.CLASS_NAME, "options.includeCredentials", options.includeCredentials);
|
|
492
491
|
}
|
|
493
492
|
if (!core.Is.undefined(options.retryCount)) {
|
|
494
|
-
core.Guards.integer(FetchHelper.
|
|
493
|
+
core.Guards.integer(FetchHelper.CLASS_NAME, "options.retryCount", options.retryCount);
|
|
495
494
|
}
|
|
496
495
|
if (!core.Is.undefined(options.retryDelayMs)) {
|
|
497
|
-
core.Guards.integer(FetchHelper.
|
|
496
|
+
core.Guards.integer(FetchHelper.CLASS_NAME, "options.retryDelayMs", options.retryDelayMs);
|
|
498
497
|
}
|
|
499
498
|
}
|
|
500
499
|
let controller;
|
|
@@ -566,7 +565,12 @@ class FetchHelper {
|
|
|
566
565
|
if (isErr && "statusText" in err) {
|
|
567
566
|
props.statusText = err.statusText;
|
|
568
567
|
}
|
|
569
|
-
|
|
568
|
+
if (isAbort) {
|
|
569
|
+
lastError = new FetchError(source, `${"fetchHelper"}.timeout`, httpStatus, props, err);
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
lastError = new FetchError(source, `${"fetchHelper"}.general`, httpStatus, props, err);
|
|
573
|
+
}
|
|
570
574
|
}
|
|
571
575
|
}
|
|
572
576
|
finally {
|
|
@@ -658,7 +662,7 @@ class FetchHelper {
|
|
|
658
662
|
if (core.Is.undefined(options.headers[HeaderTypes.ContentType])) {
|
|
659
663
|
options.headers[HeaderTypes.ContentType] = MimeTypes.OctetStream;
|
|
660
664
|
}
|
|
661
|
-
const response = await
|
|
665
|
+
const response = await FetchHelper.fetch(source, url, method, requestData, options);
|
|
662
666
|
if (response.ok) {
|
|
663
667
|
if (method === HttpMethod.GET) {
|
|
664
668
|
if (response.status === HttpStatusCode.noContent) {
|
|
@@ -759,9 +763,8 @@ class HeaderHelper {
|
|
|
759
763
|
class Jwk {
|
|
760
764
|
/**
|
|
761
765
|
* Runtime name for the class.
|
|
762
|
-
* @internal
|
|
763
766
|
*/
|
|
764
|
-
static
|
|
767
|
+
static CLASS_NAME = "Jwk";
|
|
765
768
|
/**
|
|
766
769
|
* Convert the JWK to a crypto key.
|
|
767
770
|
* @param jwk The JWK to convert.
|
|
@@ -769,12 +772,12 @@ class Jwk {
|
|
|
769
772
|
* @returns The crypto key.
|
|
770
773
|
*/
|
|
771
774
|
static async toCryptoKey(jwk, alg) {
|
|
772
|
-
core.Guards.object(Jwk.
|
|
775
|
+
core.Guards.object(Jwk.CLASS_NAME, "jwk", jwk);
|
|
773
776
|
try {
|
|
774
777
|
return jose.importJWK(jwk, alg);
|
|
775
778
|
}
|
|
776
779
|
catch (err) {
|
|
777
|
-
throw new core.GeneralError(Jwk.
|
|
780
|
+
throw new core.GeneralError(Jwk.CLASS_NAME, "jwkImportFailed", undefined, err);
|
|
778
781
|
}
|
|
779
782
|
}
|
|
780
783
|
/**
|
|
@@ -784,7 +787,7 @@ class Jwk {
|
|
|
784
787
|
* @returns The crypto key.
|
|
785
788
|
*/
|
|
786
789
|
static async fromEd25519Private(privateKey, overrideUse) {
|
|
787
|
-
core.Guards.uint8Array(Jwk.
|
|
790
|
+
core.Guards.uint8Array(Jwk.CLASS_NAME, "privateKey", privateKey);
|
|
788
791
|
const publicKey = crypto.Ed25519.publicKeyFromPrivateKey(privateKey);
|
|
789
792
|
const jwk = {
|
|
790
793
|
kty: "OKP",
|
|
@@ -803,7 +806,7 @@ class Jwk {
|
|
|
803
806
|
* @returns The crypto key.
|
|
804
807
|
*/
|
|
805
808
|
static async fromEd25519Public(publicKey, overrideUse) {
|
|
806
|
-
core.Guards.uint8Array(Jwk.
|
|
809
|
+
core.Guards.uint8Array(Jwk.CLASS_NAME, "publicKey", publicKey);
|
|
807
810
|
const jwk = {
|
|
808
811
|
kty: "OKP",
|
|
809
812
|
use: overrideUse ?? "sig",
|
|
@@ -819,7 +822,7 @@ class Jwk {
|
|
|
819
822
|
* @returns The crypto key.
|
|
820
823
|
*/
|
|
821
824
|
static async toRaw(jwk) {
|
|
822
|
-
core.Guards.object(Jwk.
|
|
825
|
+
core.Guards.object(Jwk.CLASS_NAME, "jwk", jwk);
|
|
823
826
|
let publicKey;
|
|
824
827
|
let privateKey;
|
|
825
828
|
if (core.Is.stringBase64Url(jwk.x)) {
|
|
@@ -839,7 +842,7 @@ class Jwk {
|
|
|
839
842
|
* @returns The KID.
|
|
840
843
|
*/
|
|
841
844
|
static async generateKid(jwk) {
|
|
842
|
-
core.Guards.object(Jwk.
|
|
845
|
+
core.Guards.object(Jwk.CLASS_NAME, "jwk", jwk);
|
|
843
846
|
const kidProps = core.ObjectHelper.pick(jwk, ["crv", "kty", "x"]);
|
|
844
847
|
const canonicalJson = core.JsonHelper.canonicalize(kidProps);
|
|
845
848
|
const hash = crypto.Sha256.sum256(core.Converter.utf8ToBytes(canonicalJson));
|
|
@@ -855,9 +858,8 @@ class Jwk {
|
|
|
855
858
|
class Jws {
|
|
856
859
|
/**
|
|
857
860
|
* Runtime name for the class.
|
|
858
|
-
* @internal
|
|
859
861
|
*/
|
|
860
|
-
static
|
|
862
|
+
static CLASS_NAME = "Jws";
|
|
861
863
|
/**
|
|
862
864
|
* Create a signature.
|
|
863
865
|
* @param privateKey The private key to use.
|
|
@@ -866,8 +868,8 @@ class Jws {
|
|
|
866
868
|
* @returns The signature.
|
|
867
869
|
*/
|
|
868
870
|
static async create(privateKey, hash, algOverride) {
|
|
869
|
-
core.Guards.defined(Jws.
|
|
870
|
-
core.Guards.uint8Array(Jws.
|
|
871
|
+
core.Guards.defined(Jws.CLASS_NAME, "privateKey", privateKey);
|
|
872
|
+
core.Guards.uint8Array(Jws.CLASS_NAME, "hash", hash);
|
|
871
873
|
try {
|
|
872
874
|
const jws = await new jose.CompactSign(hash)
|
|
873
875
|
.setProtectedHeader({
|
|
@@ -879,7 +881,7 @@ class Jws {
|
|
|
879
881
|
return jws;
|
|
880
882
|
}
|
|
881
883
|
catch (err) {
|
|
882
|
-
throw new core.GeneralError(Jws.
|
|
884
|
+
throw new core.GeneralError(Jws.CLASS_NAME, "createFailed", undefined, err);
|
|
883
885
|
}
|
|
884
886
|
}
|
|
885
887
|
/**
|
|
@@ -890,16 +892,16 @@ class Jws {
|
|
|
890
892
|
* @returns True if the signature was verified.
|
|
891
893
|
*/
|
|
892
894
|
static async verify(jws, publicKey, hash) {
|
|
893
|
-
core.Guards.stringValue(Jws.
|
|
894
|
-
core.Guards.defined(Jws.
|
|
895
|
-
core.Guards.uint8Array(Jws.
|
|
895
|
+
core.Guards.stringValue(Jws.CLASS_NAME, "jws", jws);
|
|
896
|
+
core.Guards.defined(Jws.CLASS_NAME, "publicKey", publicKey);
|
|
897
|
+
core.Guards.uint8Array(Jws.CLASS_NAME, "hash", hash);
|
|
896
898
|
try {
|
|
897
899
|
const jwsParts = jws.split(".");
|
|
898
900
|
await jose.flattenedVerify({ protected: jwsParts[0], payload: hash, signature: jwsParts[2] }, publicKey);
|
|
899
901
|
return true;
|
|
900
902
|
}
|
|
901
903
|
catch (err) {
|
|
902
|
-
throw new core.GeneralError(Jws.
|
|
904
|
+
throw new core.GeneralError(Jws.CLASS_NAME, "verifyFailed", undefined, err);
|
|
903
905
|
}
|
|
904
906
|
}
|
|
905
907
|
}
|
|
@@ -912,9 +914,8 @@ class Jws {
|
|
|
912
914
|
class Jwt {
|
|
913
915
|
/**
|
|
914
916
|
* Runtime name for the class.
|
|
915
|
-
* @internal
|
|
916
917
|
*/
|
|
917
|
-
static
|
|
918
|
+
static CLASS_NAME = "Jwt";
|
|
918
919
|
/**
|
|
919
920
|
* Encode a token.
|
|
920
921
|
* @param header The header to encode.
|
|
@@ -923,9 +924,9 @@ class Jwt {
|
|
|
923
924
|
* @returns The encoded token.
|
|
924
925
|
*/
|
|
925
926
|
static async encode(header, payload, key) {
|
|
926
|
-
core.Guards.object(Jwt.
|
|
927
|
-
core.Guards.object(Jwt.
|
|
928
|
-
core.Guards.defined(Jwt.
|
|
927
|
+
core.Guards.object(Jwt.CLASS_NAME, "header", header);
|
|
928
|
+
core.Guards.object(Jwt.CLASS_NAME, "payload", payload);
|
|
929
|
+
core.Guards.defined(Jwt.CLASS_NAME, "key", key);
|
|
929
930
|
return Jwt.internalEncode(header, payload, key);
|
|
930
931
|
}
|
|
931
932
|
/**
|
|
@@ -936,10 +937,10 @@ class Jwt {
|
|
|
936
937
|
* @returns The encoded token.
|
|
937
938
|
*/
|
|
938
939
|
static async encodeWithSigner(header, payload, signer) {
|
|
939
|
-
core.Guards.object(Jwt.
|
|
940
|
-
core.Guards.stringValue(Jwt.
|
|
941
|
-
core.Guards.object(Jwt.
|
|
942
|
-
core.Guards.function(Jwt.
|
|
940
|
+
core.Guards.object(Jwt.CLASS_NAME, "header", header);
|
|
941
|
+
core.Guards.stringValue(Jwt.CLASS_NAME, "header.alg", header.alg);
|
|
942
|
+
core.Guards.object(Jwt.CLASS_NAME, "payload", payload);
|
|
943
|
+
core.Guards.function(Jwt.CLASS_NAME, "signer", signer);
|
|
943
944
|
return Jwt.internalEncode(header, payload, undefined, signer);
|
|
944
945
|
}
|
|
945
946
|
/**
|
|
@@ -948,7 +949,7 @@ class Jwt {
|
|
|
948
949
|
* @returns The decoded payload.
|
|
949
950
|
*/
|
|
950
951
|
static async decode(token) {
|
|
951
|
-
core.Guards.stringValue(Jwt.
|
|
952
|
+
core.Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
952
953
|
let header;
|
|
953
954
|
let payload;
|
|
954
955
|
let signature;
|
|
@@ -983,8 +984,8 @@ class Jwt {
|
|
|
983
984
|
* @returns The decoded payload.
|
|
984
985
|
*/
|
|
985
986
|
static async verify(token, key) {
|
|
986
|
-
core.Guards.stringValue(Jwt.
|
|
987
|
-
core.Guards.defined(Jwt.
|
|
987
|
+
core.Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
988
|
+
core.Guards.defined(Jwt.CLASS_NAME, "key", key);
|
|
988
989
|
return Jwt.verifySignature(token, key);
|
|
989
990
|
}
|
|
990
991
|
/**
|
|
@@ -994,8 +995,8 @@ class Jwt {
|
|
|
994
995
|
* @returns The decoded payload.
|
|
995
996
|
*/
|
|
996
997
|
static async verifyWithVerifier(token, verifier) {
|
|
997
|
-
core.Guards.stringValue(Jwt.
|
|
998
|
-
core.Guards.function(Jwt.
|
|
998
|
+
core.Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
999
|
+
core.Guards.function(Jwt.CLASS_NAME, "verifier", verifier);
|
|
999
1000
|
return Jwt.verifySignature(token, undefined, verifier);
|
|
1000
1001
|
}
|
|
1001
1002
|
/**
|
|
@@ -1006,11 +1007,11 @@ class Jwt {
|
|
|
1006
1007
|
* @returns True if the parts are verified.
|
|
1007
1008
|
*/
|
|
1008
1009
|
static async verifySignature(token, key, verifier) {
|
|
1009
|
-
core.Guards.stringValue(Jwt.
|
|
1010
|
+
core.Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
1010
1011
|
const hasKey = core.Is.notEmpty(key);
|
|
1011
1012
|
const hasVerifier = core.Is.notEmpty(verifier);
|
|
1012
1013
|
if (!hasKey && !hasVerifier) {
|
|
1013
|
-
throw new core.GeneralError(Jwt.
|
|
1014
|
+
throw new core.GeneralError(Jwt.CLASS_NAME, "noKeyOrVerifier");
|
|
1014
1015
|
}
|
|
1015
1016
|
verifier ??= async (t, k) => Jwt.defaultVerifier(t, k);
|
|
1016
1017
|
return verifier(token, key);
|
|
@@ -1023,9 +1024,9 @@ class Jwt {
|
|
|
1023
1024
|
* @returns The signature.
|
|
1024
1025
|
*/
|
|
1025
1026
|
static async defaultSigner(header, payload, key) {
|
|
1026
|
-
core.Guards.object(Jwt.
|
|
1027
|
-
core.Guards.object(Jwt.
|
|
1028
|
-
core.Guards.defined(Jwt.
|
|
1027
|
+
core.Guards.object(Jwt.CLASS_NAME, "header", header);
|
|
1028
|
+
core.Guards.object(Jwt.CLASS_NAME, "payload", payload);
|
|
1029
|
+
core.Guards.defined(Jwt.CLASS_NAME, "key", key);
|
|
1029
1030
|
const signer = new jose.SignJWT(payload);
|
|
1030
1031
|
signer.setProtectedHeader(header);
|
|
1031
1032
|
let finalKey = key;
|
|
@@ -1042,8 +1043,8 @@ class Jwt {
|
|
|
1042
1043
|
* @returns The header and payload if verification successful.
|
|
1043
1044
|
*/
|
|
1044
1045
|
static async defaultVerifier(token, key) {
|
|
1045
|
-
core.Guards.stringValue(Jwt.
|
|
1046
|
-
core.Guards.defined(Jwt.
|
|
1046
|
+
core.Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
1047
|
+
core.Guards.defined(Jwt.CLASS_NAME, "key", key);
|
|
1047
1048
|
try {
|
|
1048
1049
|
const result = await jose.jwtVerify(token, key);
|
|
1049
1050
|
return {
|
|
@@ -1052,7 +1053,7 @@ class Jwt {
|
|
|
1052
1053
|
};
|
|
1053
1054
|
}
|
|
1054
1055
|
catch (err) {
|
|
1055
|
-
throw new core.GeneralError(Jwt.
|
|
1056
|
+
throw new core.GeneralError(Jwt.CLASS_NAME, "verifyFailed", undefined, err);
|
|
1056
1057
|
}
|
|
1057
1058
|
}
|
|
1058
1059
|
/**
|
|
@@ -1062,8 +1063,8 @@ class Jwt {
|
|
|
1062
1063
|
* @returns The bytes to sign.
|
|
1063
1064
|
*/
|
|
1064
1065
|
static toSigningBytes(header, payload) {
|
|
1065
|
-
core.Guards.object(Jwt.
|
|
1066
|
-
core.Guards.object(Jwt.
|
|
1066
|
+
core.Guards.object(Jwt.CLASS_NAME, "header", header);
|
|
1067
|
+
core.Guards.object(Jwt.CLASS_NAME, "payload", payload);
|
|
1067
1068
|
const segments = [];
|
|
1068
1069
|
const headerBytes = core.Converter.utf8ToBytes(JSON.stringify(header));
|
|
1069
1070
|
segments.push(core.Converter.bytesToBase64Url(headerBytes));
|
|
@@ -1078,10 +1079,10 @@ class Jwt {
|
|
|
1078
1079
|
* @throws If the signing bytes are invalid
|
|
1079
1080
|
*/
|
|
1080
1081
|
static fromSigningBytes(signingBytes) {
|
|
1081
|
-
core.Guards.uint8Array(Jwt.
|
|
1082
|
+
core.Guards.uint8Array(Jwt.CLASS_NAME, "signingBytes", signingBytes);
|
|
1082
1083
|
const segments = core.Converter.bytesToUtf8(signingBytes).split(".");
|
|
1083
1084
|
if (segments.length !== 2) {
|
|
1084
|
-
throw new core.GeneralError(Jwt.
|
|
1085
|
+
throw new core.GeneralError(Jwt.CLASS_NAME, "invalidSigningBytes");
|
|
1085
1086
|
}
|
|
1086
1087
|
const headerBytes = core.Converter.base64UrlToBytes(segments[0]);
|
|
1087
1088
|
const payloadBytes = core.Converter.base64UrlToBytes(segments[1]);
|
|
@@ -1097,8 +1098,8 @@ class Jwt {
|
|
|
1097
1098
|
* @returns The token.
|
|
1098
1099
|
*/
|
|
1099
1100
|
static tokenFromBytes(signingBytes, signature) {
|
|
1100
|
-
core.Guards.uint8Array(Jwt.
|
|
1101
|
-
core.Guards.uint8Array(Jwt.
|
|
1101
|
+
core.Guards.uint8Array(Jwt.CLASS_NAME, "signingBytes", signingBytes);
|
|
1102
|
+
core.Guards.uint8Array(Jwt.CLASS_NAME, "signature", signature);
|
|
1102
1103
|
const signedBytesUtf8 = core.Converter.bytesToUtf8(signingBytes);
|
|
1103
1104
|
const signatureBase64 = core.Converter.bytesToBase64Url(signature);
|
|
1104
1105
|
return `${signedBytesUtf8}.${signatureBase64}`;
|
|
@@ -1110,10 +1111,10 @@ class Jwt {
|
|
|
1110
1111
|
* @throws If the token is invalid.
|
|
1111
1112
|
*/
|
|
1112
1113
|
static tokenToBytes(token) {
|
|
1113
|
-
core.Guards.stringValue(Jwt.
|
|
1114
|
+
core.Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
1114
1115
|
const segments = token.split(".");
|
|
1115
1116
|
if (segments.length !== 3) {
|
|
1116
|
-
throw new core.GeneralError(Jwt.
|
|
1117
|
+
throw new core.GeneralError(Jwt.CLASS_NAME, "invalidTokenParts");
|
|
1117
1118
|
}
|
|
1118
1119
|
const signingBytes = core.Converter.utf8ToBytes(`${segments[0]}.${segments[1]}`);
|
|
1119
1120
|
const signature = core.Converter.base64UrlToBytes(segments[2]);
|
|
@@ -1135,7 +1136,7 @@ class Jwt {
|
|
|
1135
1136
|
const hasKey = core.Is.notEmpty(key);
|
|
1136
1137
|
const hasSigner = core.Is.notEmpty(signer);
|
|
1137
1138
|
if (!hasKey && !hasSigner) {
|
|
1138
|
-
throw new core.GeneralError(Jwt.
|
|
1139
|
+
throw new core.GeneralError(Jwt.CLASS_NAME, "noKeyOrSigner");
|
|
1139
1140
|
}
|
|
1140
1141
|
signer ??= async (h, p, k) => Jwt.defaultSigner(h, p, k);
|
|
1141
1142
|
if (core.Is.undefined(header.typ)) {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -453,9 +453,8 @@ const MimeTypes = {
|
|
|
453
453
|
class FetchHelper {
|
|
454
454
|
/**
|
|
455
455
|
* Runtime name for the class.
|
|
456
|
-
* @internal
|
|
457
456
|
*/
|
|
458
|
-
static
|
|
457
|
+
static CLASS_NAME = "FetchHelper";
|
|
459
458
|
/**
|
|
460
459
|
* Prefix to use for cache entries.
|
|
461
460
|
* @internal
|
|
@@ -471,28 +470,28 @@ class FetchHelper {
|
|
|
471
470
|
* @returns The response.
|
|
472
471
|
*/
|
|
473
472
|
static async fetch(source, url, method, body, options) {
|
|
474
|
-
Guards.string(FetchHelper.
|
|
475
|
-
Guards.string(FetchHelper.
|
|
476
|
-
Guards.arrayOneOf(FetchHelper.
|
|
473
|
+
Guards.string(FetchHelper.CLASS_NAME, "source", source);
|
|
474
|
+
Guards.string(FetchHelper.CLASS_NAME, "url", url);
|
|
475
|
+
Guards.arrayOneOf(FetchHelper.CLASS_NAME, "method", method, Object.values(HttpMethod));
|
|
477
476
|
if (!Is.undefined(body) && !Is.uint8Array(body)) {
|
|
478
|
-
Guards.string(FetchHelper.
|
|
477
|
+
Guards.string(FetchHelper.CLASS_NAME, "body", body);
|
|
479
478
|
}
|
|
480
479
|
if (!Is.undefined(options)) {
|
|
481
|
-
Guards.object(FetchHelper.
|
|
480
|
+
Guards.object(FetchHelper.CLASS_NAME, "options", options);
|
|
482
481
|
if (!Is.undefined(options.headers)) {
|
|
483
|
-
Guards.object(FetchHelper.
|
|
482
|
+
Guards.object(FetchHelper.CLASS_NAME, "options.headers", options.headers);
|
|
484
483
|
}
|
|
485
484
|
if (!Is.undefined(options.timeoutMs)) {
|
|
486
|
-
Guards.integer(FetchHelper.
|
|
485
|
+
Guards.integer(FetchHelper.CLASS_NAME, "options.timeoutMs", options.timeoutMs);
|
|
487
486
|
}
|
|
488
487
|
if (!Is.undefined(options.includeCredentials)) {
|
|
489
|
-
Guards.boolean(FetchHelper.
|
|
488
|
+
Guards.boolean(FetchHelper.CLASS_NAME, "options.includeCredentials", options.includeCredentials);
|
|
490
489
|
}
|
|
491
490
|
if (!Is.undefined(options.retryCount)) {
|
|
492
|
-
Guards.integer(FetchHelper.
|
|
491
|
+
Guards.integer(FetchHelper.CLASS_NAME, "options.retryCount", options.retryCount);
|
|
493
492
|
}
|
|
494
493
|
if (!Is.undefined(options.retryDelayMs)) {
|
|
495
|
-
Guards.integer(FetchHelper.
|
|
494
|
+
Guards.integer(FetchHelper.CLASS_NAME, "options.retryDelayMs", options.retryDelayMs);
|
|
496
495
|
}
|
|
497
496
|
}
|
|
498
497
|
let controller;
|
|
@@ -564,7 +563,12 @@ class FetchHelper {
|
|
|
564
563
|
if (isErr && "statusText" in err) {
|
|
565
564
|
props.statusText = err.statusText;
|
|
566
565
|
}
|
|
567
|
-
|
|
566
|
+
if (isAbort) {
|
|
567
|
+
lastError = new FetchError(source, `${"fetchHelper"}.timeout`, httpStatus, props, err);
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
lastError = new FetchError(source, `${"fetchHelper"}.general`, httpStatus, props, err);
|
|
571
|
+
}
|
|
568
572
|
}
|
|
569
573
|
}
|
|
570
574
|
finally {
|
|
@@ -656,7 +660,7 @@ class FetchHelper {
|
|
|
656
660
|
if (Is.undefined(options.headers[HeaderTypes.ContentType])) {
|
|
657
661
|
options.headers[HeaderTypes.ContentType] = MimeTypes.OctetStream;
|
|
658
662
|
}
|
|
659
|
-
const response = await
|
|
663
|
+
const response = await FetchHelper.fetch(source, url, method, requestData, options);
|
|
660
664
|
if (response.ok) {
|
|
661
665
|
if (method === HttpMethod.GET) {
|
|
662
666
|
if (response.status === HttpStatusCode.noContent) {
|
|
@@ -757,9 +761,8 @@ class HeaderHelper {
|
|
|
757
761
|
class Jwk {
|
|
758
762
|
/**
|
|
759
763
|
* Runtime name for the class.
|
|
760
|
-
* @internal
|
|
761
764
|
*/
|
|
762
|
-
static
|
|
765
|
+
static CLASS_NAME = "Jwk";
|
|
763
766
|
/**
|
|
764
767
|
* Convert the JWK to a crypto key.
|
|
765
768
|
* @param jwk The JWK to convert.
|
|
@@ -767,12 +770,12 @@ class Jwk {
|
|
|
767
770
|
* @returns The crypto key.
|
|
768
771
|
*/
|
|
769
772
|
static async toCryptoKey(jwk, alg) {
|
|
770
|
-
Guards.object(Jwk.
|
|
773
|
+
Guards.object(Jwk.CLASS_NAME, "jwk", jwk);
|
|
771
774
|
try {
|
|
772
775
|
return importJWK(jwk, alg);
|
|
773
776
|
}
|
|
774
777
|
catch (err) {
|
|
775
|
-
throw new GeneralError(Jwk.
|
|
778
|
+
throw new GeneralError(Jwk.CLASS_NAME, "jwkImportFailed", undefined, err);
|
|
776
779
|
}
|
|
777
780
|
}
|
|
778
781
|
/**
|
|
@@ -782,7 +785,7 @@ class Jwk {
|
|
|
782
785
|
* @returns The crypto key.
|
|
783
786
|
*/
|
|
784
787
|
static async fromEd25519Private(privateKey, overrideUse) {
|
|
785
|
-
Guards.uint8Array(Jwk.
|
|
788
|
+
Guards.uint8Array(Jwk.CLASS_NAME, "privateKey", privateKey);
|
|
786
789
|
const publicKey = Ed25519.publicKeyFromPrivateKey(privateKey);
|
|
787
790
|
const jwk = {
|
|
788
791
|
kty: "OKP",
|
|
@@ -801,7 +804,7 @@ class Jwk {
|
|
|
801
804
|
* @returns The crypto key.
|
|
802
805
|
*/
|
|
803
806
|
static async fromEd25519Public(publicKey, overrideUse) {
|
|
804
|
-
Guards.uint8Array(Jwk.
|
|
807
|
+
Guards.uint8Array(Jwk.CLASS_NAME, "publicKey", publicKey);
|
|
805
808
|
const jwk = {
|
|
806
809
|
kty: "OKP",
|
|
807
810
|
use: overrideUse ?? "sig",
|
|
@@ -817,7 +820,7 @@ class Jwk {
|
|
|
817
820
|
* @returns The crypto key.
|
|
818
821
|
*/
|
|
819
822
|
static async toRaw(jwk) {
|
|
820
|
-
Guards.object(Jwk.
|
|
823
|
+
Guards.object(Jwk.CLASS_NAME, "jwk", jwk);
|
|
821
824
|
let publicKey;
|
|
822
825
|
let privateKey;
|
|
823
826
|
if (Is.stringBase64Url(jwk.x)) {
|
|
@@ -837,7 +840,7 @@ class Jwk {
|
|
|
837
840
|
* @returns The KID.
|
|
838
841
|
*/
|
|
839
842
|
static async generateKid(jwk) {
|
|
840
|
-
Guards.object(Jwk.
|
|
843
|
+
Guards.object(Jwk.CLASS_NAME, "jwk", jwk);
|
|
841
844
|
const kidProps = ObjectHelper.pick(jwk, ["crv", "kty", "x"]);
|
|
842
845
|
const canonicalJson = JsonHelper.canonicalize(kidProps);
|
|
843
846
|
const hash = Sha256.sum256(Converter.utf8ToBytes(canonicalJson));
|
|
@@ -853,9 +856,8 @@ class Jwk {
|
|
|
853
856
|
class Jws {
|
|
854
857
|
/**
|
|
855
858
|
* Runtime name for the class.
|
|
856
|
-
* @internal
|
|
857
859
|
*/
|
|
858
|
-
static
|
|
860
|
+
static CLASS_NAME = "Jws";
|
|
859
861
|
/**
|
|
860
862
|
* Create a signature.
|
|
861
863
|
* @param privateKey The private key to use.
|
|
@@ -864,8 +866,8 @@ class Jws {
|
|
|
864
866
|
* @returns The signature.
|
|
865
867
|
*/
|
|
866
868
|
static async create(privateKey, hash, algOverride) {
|
|
867
|
-
Guards.defined(Jws.
|
|
868
|
-
Guards.uint8Array(Jws.
|
|
869
|
+
Guards.defined(Jws.CLASS_NAME, "privateKey", privateKey);
|
|
870
|
+
Guards.uint8Array(Jws.CLASS_NAME, "hash", hash);
|
|
869
871
|
try {
|
|
870
872
|
const jws = await new CompactSign(hash)
|
|
871
873
|
.setProtectedHeader({
|
|
@@ -877,7 +879,7 @@ class Jws {
|
|
|
877
879
|
return jws;
|
|
878
880
|
}
|
|
879
881
|
catch (err) {
|
|
880
|
-
throw new GeneralError(Jws.
|
|
882
|
+
throw new GeneralError(Jws.CLASS_NAME, "createFailed", undefined, err);
|
|
881
883
|
}
|
|
882
884
|
}
|
|
883
885
|
/**
|
|
@@ -888,16 +890,16 @@ class Jws {
|
|
|
888
890
|
* @returns True if the signature was verified.
|
|
889
891
|
*/
|
|
890
892
|
static async verify(jws, publicKey, hash) {
|
|
891
|
-
Guards.stringValue(Jws.
|
|
892
|
-
Guards.defined(Jws.
|
|
893
|
-
Guards.uint8Array(Jws.
|
|
893
|
+
Guards.stringValue(Jws.CLASS_NAME, "jws", jws);
|
|
894
|
+
Guards.defined(Jws.CLASS_NAME, "publicKey", publicKey);
|
|
895
|
+
Guards.uint8Array(Jws.CLASS_NAME, "hash", hash);
|
|
894
896
|
try {
|
|
895
897
|
const jwsParts = jws.split(".");
|
|
896
898
|
await flattenedVerify({ protected: jwsParts[0], payload: hash, signature: jwsParts[2] }, publicKey);
|
|
897
899
|
return true;
|
|
898
900
|
}
|
|
899
901
|
catch (err) {
|
|
900
|
-
throw new GeneralError(Jws.
|
|
902
|
+
throw new GeneralError(Jws.CLASS_NAME, "verifyFailed", undefined, err);
|
|
901
903
|
}
|
|
902
904
|
}
|
|
903
905
|
}
|
|
@@ -910,9 +912,8 @@ class Jws {
|
|
|
910
912
|
class Jwt {
|
|
911
913
|
/**
|
|
912
914
|
* Runtime name for the class.
|
|
913
|
-
* @internal
|
|
914
915
|
*/
|
|
915
|
-
static
|
|
916
|
+
static CLASS_NAME = "Jwt";
|
|
916
917
|
/**
|
|
917
918
|
* Encode a token.
|
|
918
919
|
* @param header The header to encode.
|
|
@@ -921,9 +922,9 @@ class Jwt {
|
|
|
921
922
|
* @returns The encoded token.
|
|
922
923
|
*/
|
|
923
924
|
static async encode(header, payload, key) {
|
|
924
|
-
Guards.object(Jwt.
|
|
925
|
-
Guards.object(Jwt.
|
|
926
|
-
Guards.defined(Jwt.
|
|
925
|
+
Guards.object(Jwt.CLASS_NAME, "header", header);
|
|
926
|
+
Guards.object(Jwt.CLASS_NAME, "payload", payload);
|
|
927
|
+
Guards.defined(Jwt.CLASS_NAME, "key", key);
|
|
927
928
|
return Jwt.internalEncode(header, payload, key);
|
|
928
929
|
}
|
|
929
930
|
/**
|
|
@@ -934,10 +935,10 @@ class Jwt {
|
|
|
934
935
|
* @returns The encoded token.
|
|
935
936
|
*/
|
|
936
937
|
static async encodeWithSigner(header, payload, signer) {
|
|
937
|
-
Guards.object(Jwt.
|
|
938
|
-
Guards.stringValue(Jwt.
|
|
939
|
-
Guards.object(Jwt.
|
|
940
|
-
Guards.function(Jwt.
|
|
938
|
+
Guards.object(Jwt.CLASS_NAME, "header", header);
|
|
939
|
+
Guards.stringValue(Jwt.CLASS_NAME, "header.alg", header.alg);
|
|
940
|
+
Guards.object(Jwt.CLASS_NAME, "payload", payload);
|
|
941
|
+
Guards.function(Jwt.CLASS_NAME, "signer", signer);
|
|
941
942
|
return Jwt.internalEncode(header, payload, undefined, signer);
|
|
942
943
|
}
|
|
943
944
|
/**
|
|
@@ -946,7 +947,7 @@ class Jwt {
|
|
|
946
947
|
* @returns The decoded payload.
|
|
947
948
|
*/
|
|
948
949
|
static async decode(token) {
|
|
949
|
-
Guards.stringValue(Jwt.
|
|
950
|
+
Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
950
951
|
let header;
|
|
951
952
|
let payload;
|
|
952
953
|
let signature;
|
|
@@ -981,8 +982,8 @@ class Jwt {
|
|
|
981
982
|
* @returns The decoded payload.
|
|
982
983
|
*/
|
|
983
984
|
static async verify(token, key) {
|
|
984
|
-
Guards.stringValue(Jwt.
|
|
985
|
-
Guards.defined(Jwt.
|
|
985
|
+
Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
986
|
+
Guards.defined(Jwt.CLASS_NAME, "key", key);
|
|
986
987
|
return Jwt.verifySignature(token, key);
|
|
987
988
|
}
|
|
988
989
|
/**
|
|
@@ -992,8 +993,8 @@ class Jwt {
|
|
|
992
993
|
* @returns The decoded payload.
|
|
993
994
|
*/
|
|
994
995
|
static async verifyWithVerifier(token, verifier) {
|
|
995
|
-
Guards.stringValue(Jwt.
|
|
996
|
-
Guards.function(Jwt.
|
|
996
|
+
Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
997
|
+
Guards.function(Jwt.CLASS_NAME, "verifier", verifier);
|
|
997
998
|
return Jwt.verifySignature(token, undefined, verifier);
|
|
998
999
|
}
|
|
999
1000
|
/**
|
|
@@ -1004,11 +1005,11 @@ class Jwt {
|
|
|
1004
1005
|
* @returns True if the parts are verified.
|
|
1005
1006
|
*/
|
|
1006
1007
|
static async verifySignature(token, key, verifier) {
|
|
1007
|
-
Guards.stringValue(Jwt.
|
|
1008
|
+
Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
1008
1009
|
const hasKey = Is.notEmpty(key);
|
|
1009
1010
|
const hasVerifier = Is.notEmpty(verifier);
|
|
1010
1011
|
if (!hasKey && !hasVerifier) {
|
|
1011
|
-
throw new GeneralError(Jwt.
|
|
1012
|
+
throw new GeneralError(Jwt.CLASS_NAME, "noKeyOrVerifier");
|
|
1012
1013
|
}
|
|
1013
1014
|
verifier ??= async (t, k) => Jwt.defaultVerifier(t, k);
|
|
1014
1015
|
return verifier(token, key);
|
|
@@ -1021,9 +1022,9 @@ class Jwt {
|
|
|
1021
1022
|
* @returns The signature.
|
|
1022
1023
|
*/
|
|
1023
1024
|
static async defaultSigner(header, payload, key) {
|
|
1024
|
-
Guards.object(Jwt.
|
|
1025
|
-
Guards.object(Jwt.
|
|
1026
|
-
Guards.defined(Jwt.
|
|
1025
|
+
Guards.object(Jwt.CLASS_NAME, "header", header);
|
|
1026
|
+
Guards.object(Jwt.CLASS_NAME, "payload", payload);
|
|
1027
|
+
Guards.defined(Jwt.CLASS_NAME, "key", key);
|
|
1027
1028
|
const signer = new SignJWT(payload);
|
|
1028
1029
|
signer.setProtectedHeader(header);
|
|
1029
1030
|
let finalKey = key;
|
|
@@ -1040,8 +1041,8 @@ class Jwt {
|
|
|
1040
1041
|
* @returns The header and payload if verification successful.
|
|
1041
1042
|
*/
|
|
1042
1043
|
static async defaultVerifier(token, key) {
|
|
1043
|
-
Guards.stringValue(Jwt.
|
|
1044
|
-
Guards.defined(Jwt.
|
|
1044
|
+
Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
1045
|
+
Guards.defined(Jwt.CLASS_NAME, "key", key);
|
|
1045
1046
|
try {
|
|
1046
1047
|
const result = await jwtVerify(token, key);
|
|
1047
1048
|
return {
|
|
@@ -1050,7 +1051,7 @@ class Jwt {
|
|
|
1050
1051
|
};
|
|
1051
1052
|
}
|
|
1052
1053
|
catch (err) {
|
|
1053
|
-
throw new GeneralError(Jwt.
|
|
1054
|
+
throw new GeneralError(Jwt.CLASS_NAME, "verifyFailed", undefined, err);
|
|
1054
1055
|
}
|
|
1055
1056
|
}
|
|
1056
1057
|
/**
|
|
@@ -1060,8 +1061,8 @@ class Jwt {
|
|
|
1060
1061
|
* @returns The bytes to sign.
|
|
1061
1062
|
*/
|
|
1062
1063
|
static toSigningBytes(header, payload) {
|
|
1063
|
-
Guards.object(Jwt.
|
|
1064
|
-
Guards.object(Jwt.
|
|
1064
|
+
Guards.object(Jwt.CLASS_NAME, "header", header);
|
|
1065
|
+
Guards.object(Jwt.CLASS_NAME, "payload", payload);
|
|
1065
1066
|
const segments = [];
|
|
1066
1067
|
const headerBytes = Converter.utf8ToBytes(JSON.stringify(header));
|
|
1067
1068
|
segments.push(Converter.bytesToBase64Url(headerBytes));
|
|
@@ -1076,10 +1077,10 @@ class Jwt {
|
|
|
1076
1077
|
* @throws If the signing bytes are invalid
|
|
1077
1078
|
*/
|
|
1078
1079
|
static fromSigningBytes(signingBytes) {
|
|
1079
|
-
Guards.uint8Array(Jwt.
|
|
1080
|
+
Guards.uint8Array(Jwt.CLASS_NAME, "signingBytes", signingBytes);
|
|
1080
1081
|
const segments = Converter.bytesToUtf8(signingBytes).split(".");
|
|
1081
1082
|
if (segments.length !== 2) {
|
|
1082
|
-
throw new GeneralError(Jwt.
|
|
1083
|
+
throw new GeneralError(Jwt.CLASS_NAME, "invalidSigningBytes");
|
|
1083
1084
|
}
|
|
1084
1085
|
const headerBytes = Converter.base64UrlToBytes(segments[0]);
|
|
1085
1086
|
const payloadBytes = Converter.base64UrlToBytes(segments[1]);
|
|
@@ -1095,8 +1096,8 @@ class Jwt {
|
|
|
1095
1096
|
* @returns The token.
|
|
1096
1097
|
*/
|
|
1097
1098
|
static tokenFromBytes(signingBytes, signature) {
|
|
1098
|
-
Guards.uint8Array(Jwt.
|
|
1099
|
-
Guards.uint8Array(Jwt.
|
|
1099
|
+
Guards.uint8Array(Jwt.CLASS_NAME, "signingBytes", signingBytes);
|
|
1100
|
+
Guards.uint8Array(Jwt.CLASS_NAME, "signature", signature);
|
|
1100
1101
|
const signedBytesUtf8 = Converter.bytesToUtf8(signingBytes);
|
|
1101
1102
|
const signatureBase64 = Converter.bytesToBase64Url(signature);
|
|
1102
1103
|
return `${signedBytesUtf8}.${signatureBase64}`;
|
|
@@ -1108,10 +1109,10 @@ class Jwt {
|
|
|
1108
1109
|
* @throws If the token is invalid.
|
|
1109
1110
|
*/
|
|
1110
1111
|
static tokenToBytes(token) {
|
|
1111
|
-
Guards.stringValue(Jwt.
|
|
1112
|
+
Guards.stringValue(Jwt.CLASS_NAME, "token", token);
|
|
1112
1113
|
const segments = token.split(".");
|
|
1113
1114
|
if (segments.length !== 3) {
|
|
1114
|
-
throw new GeneralError(Jwt.
|
|
1115
|
+
throw new GeneralError(Jwt.CLASS_NAME, "invalidTokenParts");
|
|
1115
1116
|
}
|
|
1116
1117
|
const signingBytes = Converter.utf8ToBytes(`${segments[0]}.${segments[1]}`);
|
|
1117
1118
|
const signature = Converter.base64UrlToBytes(segments[2]);
|
|
@@ -1133,7 +1134,7 @@ class Jwt {
|
|
|
1133
1134
|
const hasKey = Is.notEmpty(key);
|
|
1134
1135
|
const hasSigner = Is.notEmpty(signer);
|
|
1135
1136
|
if (!hasKey && !hasSigner) {
|
|
1136
|
-
throw new GeneralError(Jwt.
|
|
1137
|
+
throw new GeneralError(Jwt.CLASS_NAME, "noKeyOrSigner");
|
|
1137
1138
|
}
|
|
1138
1139
|
signer ??= async (h, p, k) => Jwt.defaultSigner(h, p, k);
|
|
1139
1140
|
if (Is.undefined(header.typ)) {
|
|
@@ -4,6 +4,10 @@ import type { IFetchOptions } from "../models/IFetchOptions";
|
|
|
4
4
|
* Class to helper with fetch operations.
|
|
5
5
|
*/
|
|
6
6
|
export declare class FetchHelper {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
7
11
|
/**
|
|
8
12
|
* Perform a fetch request.
|
|
9
13
|
* @param source The source for the request.
|
|
@@ -4,6 +4,10 @@ import type { JwkCryptoKey } from "../models/jwkCryptoKey";
|
|
|
4
4
|
* Class to handle JSON Web Keys.
|
|
5
5
|
*/
|
|
6
6
|
export declare class Jwk {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
7
11
|
/**
|
|
8
12
|
* Convert the JWK to a crypto key.
|
|
9
13
|
* @param jwk The JWK to convert.
|
|
@@ -3,6 +3,10 @@ import type { JwkCryptoKey } from "../models/jwkCryptoKey";
|
|
|
3
3
|
* Class to handle JSON Web Signatures.
|
|
4
4
|
*/
|
|
5
5
|
export declare class Jws {
|
|
6
|
+
/**
|
|
7
|
+
* Runtime name for the class.
|
|
8
|
+
*/
|
|
9
|
+
static readonly CLASS_NAME: string;
|
|
6
10
|
/**
|
|
7
11
|
* Create a signature.
|
|
8
12
|
* @param privateKey The private key to use.
|
|
@@ -5,6 +5,10 @@ import type { JwkCryptoKey } from "../models/jwkCryptoKey";
|
|
|
5
5
|
* Class to handle JSON Web Tokens.
|
|
6
6
|
*/
|
|
7
7
|
export declare class Jwt {
|
|
8
|
+
/**
|
|
9
|
+
* Runtime name for the class.
|
|
10
|
+
*/
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
8
12
|
/**
|
|
9
13
|
* Encode a token.
|
|
10
14
|
* @param header The header to encode.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @twin.org/web - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.21](https://github.com/twinfoundation/framework/compare/web-v0.0.2-next.20...web-v0.0.2-next.21) (2025-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
16
|
+
* @twin.org/crypto bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
17
|
+
* @twin.org/nameof bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
18
|
+
* devDependencies
|
|
19
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
20
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
21
|
+
* @twin.org/validate-locales bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
22
|
+
|
|
23
|
+
## [0.0.2-next.20](https://github.com/twinfoundation/framework/compare/web-v0.0.2-next.19...web-v0.0.2-next.20) (2025-10-02)
|
|
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.0.2-next.19 to 0.0.2-next.20
|
|
36
|
+
* @twin.org/crypto bumped from 0.0.2-next.19 to 0.0.2-next.20
|
|
37
|
+
* @twin.org/nameof bumped from 0.0.2-next.19 to 0.0.2-next.20
|
|
38
|
+
* devDependencies
|
|
39
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.19 to 0.0.2-next.20
|
|
40
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.19 to 0.0.2-next.20
|
|
41
|
+
|
|
3
42
|
## [0.0.2-next.19](https://github.com/twinfoundation/framework/compare/web-v0.0.2-next.18...web-v0.0.2-next.19) (2025-09-30)
|
|
4
43
|
|
|
5
44
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
^errorMessages.fetch.*$
|
package/locales/en.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"error": {
|
|
3
3
|
"fetchHelper": {
|
|
4
|
-
"decodingJSON": "Decoding JSON failed for route \"{
|
|
4
|
+
"decodingJSON": "Decoding JSON failed for route \"{url}\"",
|
|
5
5
|
"failureStatusText": "The request to the API failed: \"{statusText}\"",
|
|
6
6
|
"connectivity": "The request failed, the API could be offline, or there are other connectivity issues",
|
|
7
7
|
"timeout": "The request timed out",
|
|
8
|
-
"general": "A general failure occurred during the request"
|
|
8
|
+
"general": "A general failure occurred during the request",
|
|
9
|
+
"retryLimitExceeded": "The retry limit was exceeded for route \"{url}\""
|
|
9
10
|
},
|
|
10
11
|
"jwt": {
|
|
11
12
|
"noKeyOrSigner": "No key or signer was provided for JWT creation",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/web",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.21",
|
|
4
4
|
"description": "Contains classes for use with web operations",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/core": "0.0.2-next.
|
|
18
|
-
"@twin.org/crypto": "0.0.2-next.
|
|
19
|
-
"@twin.org/nameof": "0.0.2-next.
|
|
17
|
+
"@twin.org/core": "0.0.2-next.21",
|
|
18
|
+
"@twin.org/crypto": "0.0.2-next.21",
|
|
19
|
+
"@twin.org/nameof": "0.0.2-next.21",
|
|
20
20
|
"jose": "6.1.0"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -35,5 +35,20 @@
|
|
|
35
35
|
"dist/types",
|
|
36
36
|
"locales",
|
|
37
37
|
"docs"
|
|
38
|
-
]
|
|
38
|
+
],
|
|
39
|
+
"keywords": [
|
|
40
|
+
"twin",
|
|
41
|
+
"trade",
|
|
42
|
+
"iota",
|
|
43
|
+
"framework",
|
|
44
|
+
"blockchain",
|
|
45
|
+
"web",
|
|
46
|
+
"http",
|
|
47
|
+
"rest",
|
|
48
|
+
"api"
|
|
49
|
+
],
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "git+https://github.com/twinfoundation/framework/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://twindev.org"
|
|
39
54
|
}
|