@twin.org/web 0.0.1-next.9 → 0.0.2-next.3

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.
Files changed (35) hide show
  1. package/dist/cjs/index.cjs +298 -94
  2. package/dist/esm/index.mjs +299 -96
  3. package/dist/types/index.d.ts +3 -1
  4. package/dist/types/models/IJwk.d.ts +2 -58
  5. package/dist/types/models/IJwtHeader.d.ts +2 -18
  6. package/dist/types/models/IJwtPayload.d.ts +2 -33
  7. package/dist/types/models/jwkCryptoKey.d.ts +4 -0
  8. package/dist/types/models/mimeTypes.d.ts +8 -0
  9. package/dist/types/utils/fetchHelper.d.ts +7 -0
  10. package/dist/types/utils/jwk.d.ts +41 -0
  11. package/dist/types/utils/jws.d.ts +22 -0
  12. package/dist/types/utils/jwt.d.ts +67 -29
  13. package/docs/changelog.md +480 -1
  14. package/docs/reference/classes/FetchError.md +16 -8
  15. package/docs/reference/classes/FetchHelper.md +104 -28
  16. package/docs/reference/classes/Jwk.md +129 -0
  17. package/docs/reference/classes/Jws.md +81 -0
  18. package/docs/reference/classes/Jwt.md +261 -105
  19. package/docs/reference/classes/MimeTypeHelper.md +9 -5
  20. package/docs/reference/index.md +3 -2
  21. package/docs/reference/interfaces/IHttpHeaders.md +1 -1
  22. package/docs/reference/interfaces/IJwk.md +2 -106
  23. package/docs/reference/interfaces/IJwtHeader.md +5 -23
  24. package/docs/reference/interfaces/IJwtPayload.md +5 -55
  25. package/docs/reference/type-aliases/HeaderTypes.md +1 -1
  26. package/docs/reference/type-aliases/HttpMethod.md +1 -1
  27. package/docs/reference/type-aliases/HttpStatusCode.md +1 -1
  28. package/docs/reference/type-aliases/JwkCryptoKey.md +5 -0
  29. package/docs/reference/type-aliases/MimeTypes.md +1 -1
  30. package/docs/reference/variables/MimeTypes.md +12 -0
  31. package/locales/en.json +11 -1
  32. package/package.json +7 -6
  33. package/dist/types/models/jwtAlgorithms.d.ts +0 -17
  34. package/docs/reference/type-aliases/JwtAlgorithms.md +0 -5
  35. package/docs/reference/variables/JwtAlgorithms.md +0 -19
@@ -2,110 +2,6 @@
2
2
 
3
3
  The fields in a JSON Web Key.
4
4
 
5
- ## Indexable
5
+ ## Extends
6
6
 
7
- \[`key`: `string`\]: `unknown`
8
-
9
- ## Properties
10
-
11
- ### alg?
12
-
13
- > `optional` **alg**: [`JwtAlgorithms`](../type-aliases/JwtAlgorithms.md)
14
-
15
- The cryptographic algorithm for the key.
16
-
17
- ***
18
-
19
- ### use?
20
-
21
- > `optional` **use**: `string`
22
-
23
- The intended use for the key.
24
-
25
- ***
26
-
27
- ### key\_ops?
28
-
29
- > `optional` **key\_ops**: `string`[]
30
-
31
- The operation(s) that the key is intended to be used for.
32
-
33
- ***
34
-
35
- ### kty
36
-
37
- > **kty**: `string`
38
-
39
- The key type parameter.
40
-
41
- ***
42
-
43
- ### n?
44
-
45
- > `optional` **n**: `string`
46
-
47
- The public key parameters.
48
-
49
- ***
50
-
51
- ### e?
52
-
53
- > `optional` **e**: `string`
54
-
55
- Exponent parameter.
56
-
57
- ***
58
-
59
- ### d?
60
-
61
- > `optional` **d**: `string`
62
-
63
- The private key parameters.
64
-
65
- ***
66
-
67
- ### p?
68
-
69
- > `optional` **p**: `string`
70
-
71
- The private key parameters.
72
-
73
- ***
74
-
75
- ### q?
76
-
77
- > `optional` **q**: `string`
78
-
79
- The private key parameters.
80
-
81
- ***
82
-
83
- ### dp?
84
-
85
- > `optional` **dp**: `string`
86
-
87
- The private key parameters.
88
-
89
- ***
90
-
91
- ### dq?
92
-
93
- > `optional` **dq**: `string`
94
-
95
- The private key parameters.
96
-
97
- ***
98
-
99
- ### qi?
100
-
101
- > `optional` **qi**: `string`
102
-
103
- The private key parameters.
104
-
105
- ***
106
-
107
- ### kid?
108
-
109
- > `optional` **kid**: `string`
110
-
111
- The key ID.
7
+ - `JWK`
@@ -2,30 +2,12 @@
2
2
 
3
3
  The fields in a JSON Web Token header.
4
4
 
5
- ## Indexable
6
-
7
- \[`key`: `string`\]: `unknown`
8
-
9
- ## Properties
10
-
11
- ### typ?
12
-
13
- > `optional` **typ**: `string`
14
-
15
- The type of the token.
5
+ ## Extends
16
6
 
17
- ***
7
+ - `JWTHeaderParameters`
18
8
 
19
- ### alg
20
-
21
- > **alg**: [`JwtAlgorithms`](../type-aliases/JwtAlgorithms.md)
22
-
23
- The algorithm used to sign the token.
24
-
25
- ***
26
-
27
- ### kid?
9
+ ## Indexable
28
10
 
29
- > `optional` **kid**: `string`
11
+ \[`propName`: `string`\]: `unknown`
30
12
 
31
- The key ID.
13
+ Any other JWS Header member.
@@ -2,62 +2,12 @@
2
2
 
3
3
  The fields in a JSON Web Token payload.
4
4
 
5
- ## Indexable
6
-
7
- \[`key`: `string`\]: `unknown`
8
-
9
- ## Properties
10
-
11
- ### iss?
12
-
13
- > `optional` **iss**: `string`
14
-
15
- The issuer of the token.
16
-
17
- ***
18
-
19
- ### sub?
20
-
21
- > `optional` **sub**: `string`
22
-
23
- The subject of the token.
24
-
25
- ***
26
-
27
- ### aud?
28
-
29
- > `optional` **aud**: `string`
30
-
31
- The audience of the token.
5
+ ## Extends
32
6
 
33
- ***
7
+ - `JWTPayload`
34
8
 
35
- ### exp?
36
-
37
- > `optional` **exp**: `number`
38
-
39
- The expiration time of the token.
40
-
41
- ***
42
-
43
- ### nbf?
44
-
45
- > `optional` **nbf**: `number`
46
-
47
- The not before time of the token.
48
-
49
- ***
50
-
51
- ### iat?
52
-
53
- > `optional` **iat**: `number`
54
-
55
- The issued at time of the token.
56
-
57
- ***
58
-
59
- ### jti?
9
+ ## Indexable
60
10
 
61
- > `optional` **jti**: `string`
11
+ \[`propName`: `string`\]: `unknown`
62
12
 
63
- The JWT ID.
13
+ Any other JWT Claim Set member.
@@ -1,5 +1,5 @@
1
1
  # Type Alias: HeaderTypes
2
2
 
3
- > **HeaderTypes**: *typeof* [`HeaderTypes`](../variables/HeaderTypes.md)\[keyof *typeof* [`HeaderTypes`](../variables/HeaderTypes.md)\]
3
+ > **HeaderTypes** = *typeof* [`HeaderTypes`](../variables/HeaderTypes.md)\[keyof *typeof* [`HeaderTypes`](../variables/HeaderTypes.md)\]
4
4
 
5
5
  Common http header types.
@@ -1,5 +1,5 @@
1
1
  # Type Alias: HttpMethod
2
2
 
3
- > **HttpMethod**: *typeof* [`HttpMethod`](../variables/HttpMethod.md)\[keyof *typeof* [`HttpMethod`](../variables/HttpMethod.md)\]
3
+ > **HttpMethod** = *typeof* [`HttpMethod`](../variables/HttpMethod.md)\[keyof *typeof* [`HttpMethod`](../variables/HttpMethod.md)\]
4
4
 
5
5
  The HTTP Methods.
@@ -1,5 +1,5 @@
1
1
  # Type Alias: HttpStatusCode
2
2
 
3
- > **HttpStatusCode**: *typeof* [`HttpStatusCode`](../variables/HttpStatusCode.md)\[keyof *typeof* [`HttpStatusCode`](../variables/HttpStatusCode.md)\]
3
+ > **HttpStatusCode** = *typeof* [`HttpStatusCode`](../variables/HttpStatusCode.md)\[keyof *typeof* [`HttpStatusCode`](../variables/HttpStatusCode.md)\]
4
4
 
5
5
  Standard HTTP status codes.
@@ -0,0 +1,5 @@
1
+ # Type Alias: JwkCryptoKey
2
+
3
+ > **JwkCryptoKey** = `CryptoKey` \| `Uint8Array`
4
+
5
+ The crypto key for a JWK.
@@ -1,5 +1,5 @@
1
1
  # Type Alias: MimeTypes
2
2
 
3
- > **MimeTypes**: *typeof* [`MimeTypes`](../variables/MimeTypes.md)\[keyof *typeof* [`MimeTypes`](../variables/MimeTypes.md)\]
3
+ > **MimeTypes** = *typeof* [`MimeTypes`](../variables/MimeTypes.md)\[keyof *typeof* [`MimeTypes`](../variables/MimeTypes.md)\]
4
4
 
5
5
  Common mime types.
@@ -36,6 +36,12 @@ JSON - application/json
36
36
 
37
37
  JSON-LD - application/ld+json
38
38
 
39
+ ### Jwt
40
+
41
+ > `readonly` **Jwt**: `"application/jwt"` = `"application/jwt"`
42
+
43
+ JWT - application/jwt
44
+
39
45
  ### Xml
40
46
 
41
47
  > `readonly` **Xml**: `"application/xml"` = `"application/xml"`
@@ -54,6 +60,12 @@ Application Octet Stream, arbitrary binary - application/octet-stream
54
60
 
55
61
  Application GZIP - application/gzip
56
62
 
63
+ ### Zlib
64
+
65
+ > `readonly` **Zlib**: `"application/zlib"` = `"application/zlib"`
66
+
67
+ Application deflate - application/zlib
68
+
57
69
  ### Bzip2
58
70
 
59
71
  > `readonly` **Bzip2**: `"application/x-bzip2"` = `"application/x-bzip2"`
package/locales/en.json CHANGED
@@ -9,7 +9,17 @@
9
9
  },
10
10
  "jwt": {
11
11
  "noKeyOrSigner": "No key or signer was provided for JWT creation",
12
- "noKeyOrVerifier": "No key or verifier was provided for JWT creation"
12
+ "noKeyOrVerifier": "No key or verifier was provided for JWT creation",
13
+ "verifyFailed": "Failed to verify JWT",
14
+ "invalidTokenParts": "The JSON Web Token could not be parsed, it should contain three parts separated by dots",
15
+ "invalidSigningBytes": "The signing bytes are invalid, it should contain two parts separated by a dot"
16
+ },
17
+ "jwk": {
18
+ "jwkImportFailed": "Failed to import JWK"
19
+ },
20
+ "jws": {
21
+ "createFailed": "Failed to create JWS",
22
+ "verifyFailed": "Failed to verify JWS"
13
23
  }
14
24
  },
15
25
  "errorMessages": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/web",
3
- "version": "0.0.1-next.9",
3
+ "version": "0.0.2-next.3",
4
4
  "description": "Contains classes for use with web operations",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,18 +14,19 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.0.1-next.9",
18
- "@twin.org/crypto": "0.0.1-next.9",
19
- "@twin.org/nameof": "next"
17
+ "@twin.org/core": "0.0.2-next.3",
18
+ "@twin.org/crypto": "0.0.2-next.3",
19
+ "@twin.org/nameof": "0.0.2-next.3",
20
+ "jose": "6.0.11"
20
21
  },
21
22
  "main": "./dist/cjs/index.cjs",
22
23
  "module": "./dist/esm/index.mjs",
23
24
  "types": "./dist/types/index.d.ts",
24
25
  "exports": {
25
26
  ".": {
27
+ "types": "./dist/types/index.d.ts",
26
28
  "require": "./dist/cjs/index.cjs",
27
- "import": "./dist/esm/index.mjs",
28
- "types": "./dist/types/index.d.ts"
29
+ "import": "./dist/esm/index.mjs"
29
30
  }
30
31
  },
31
32
  "files": [
@@ -1,17 +0,0 @@
1
- /**
2
- * The cryptographic algorithms supported for JSON Web Tokens and JSON Web Keys.
3
- */
4
- export declare const JwtAlgorithms: {
5
- /**
6
- * HMAC using SHA-256.
7
- */
8
- readonly HS256: "HS256";
9
- /**
10
- * EdDSA using Ed25519.
11
- */
12
- readonly EdDSA: "EdDSA";
13
- };
14
- /**
15
- * The cryptographic algorithms supported for JSON Web Tokens and JSON Web Keys.
16
- */
17
- export type JwtAlgorithms = (typeof JwtAlgorithms)[keyof typeof JwtAlgorithms];
@@ -1,5 +0,0 @@
1
- # Type Alias: JwtAlgorithms
2
-
3
- > **JwtAlgorithms**: *typeof* [`JwtAlgorithms`](../variables/JwtAlgorithms.md)\[keyof *typeof* [`JwtAlgorithms`](../variables/JwtAlgorithms.md)\]
4
-
5
- The cryptographic algorithms supported for JSON Web Tokens and JSON Web Keys.
@@ -1,19 +0,0 @@
1
- # Variable: JwtAlgorithms
2
-
3
- > `const` **JwtAlgorithms**: `object`
4
-
5
- The cryptographic algorithms supported for JSON Web Tokens and JSON Web Keys.
6
-
7
- ## Type declaration
8
-
9
- ### HS256
10
-
11
- > `readonly` **HS256**: `"HS256"` = `"HS256"`
12
-
13
- HMAC using SHA-256.
14
-
15
- ### EdDSA
16
-
17
- > `readonly` **EdDSA**: `"EdDSA"` = `"EdDSA"`
18
-
19
- EdDSA using Ed25519.