@twin.org/web 0.0.1-next.4 → 0.0.1-next.41

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 (32) hide show
  1. package/dist/cjs/index.cjs +251 -96
  2. package/dist/esm/index.mjs +252 -98
  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/headerTypes.d.ts +8 -8
  8. package/dist/types/models/jwkCryptoKey.d.ts +4 -0
  9. package/dist/types/models/mimeTypes.d.ts +4 -0
  10. package/dist/types/utils/jwk.d.ts +25 -0
  11. package/dist/types/utils/jws.d.ts +20 -0
  12. package/dist/types/utils/jwt.d.ts +67 -29
  13. package/docs/changelog.md +1 -1
  14. package/docs/reference/classes/FetchError.md +13 -5
  15. package/docs/reference/classes/FetchHelper.md +51 -17
  16. package/docs/reference/classes/Jwk.md +79 -0
  17. package/docs/reference/classes/Jws.md +75 -0
  18. package/docs/reference/classes/Jwt.md +222 -102
  19. package/docs/reference/classes/MimeTypeHelper.md +6 -2
  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 +4 -24
  24. package/docs/reference/interfaces/IJwtPayload.md +4 -56
  25. package/docs/reference/type-aliases/JwkCryptoKey.md +5 -0
  26. package/docs/reference/variables/HeaderTypes.md +8 -8
  27. package/docs/reference/variables/MimeTypes.md +6 -0
  28. package/locales/en.json +11 -1
  29. package/package.json +7 -6
  30. package/dist/types/models/jwtAlgorithms.d.ts +0 -17
  31. package/docs/reference/type-aliases/JwtAlgorithms.md +0 -5
  32. package/docs/reference/variables/JwtAlgorithms.md +0 -19
@@ -2,30 +2,10 @@
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?
28
-
29
- > `optional` **kid**: `string`
9
+ ## Indexable
30
10
 
31
- The key ID.
11
+ \[`propName`: `string`\]: `unknown`
@@ -2,62 +2,10 @@
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?
60
-
61
- > `optional` **jti**: `string`
9
+ ## Indexable
62
10
 
63
- The JWT ID.
11
+ \[`propName`: `string`\]: `unknown`
@@ -0,0 +1,5 @@
1
+ # Type Alias: JwkCryptoKey
2
+
3
+ > **JwkCryptoKey**: `CryptoKey` \| `Uint8Array`
4
+
5
+ The crypto key for a JWK.
@@ -8,48 +8,48 @@ Common http header types.
8
8
 
9
9
  ### ContentType
10
10
 
11
- > `readonly` **ContentType**: `"Content-Type"` = `"Content-Type"`
11
+ > `readonly` **ContentType**: `"content-type"` = `"content-type"`
12
12
 
13
13
  Content Type.
14
14
 
15
15
  ### ContentLength
16
16
 
17
- > `readonly` **ContentLength**: `"Content-Length"` = `"Content-Length"`
17
+ > `readonly` **ContentLength**: `"content-length"` = `"content-length"`
18
18
 
19
19
  Content Length.
20
20
 
21
21
  ### ContentDisposition
22
22
 
23
- > `readonly` **ContentDisposition**: `"Content-Disposition"` = `"Content-Disposition"`
23
+ > `readonly` **ContentDisposition**: `"content-disposition"` = `"content-disposition"`
24
24
 
25
25
  Content Disposition.
26
26
 
27
27
  ### Accept
28
28
 
29
- > `readonly` **Accept**: `"Accept"` = `"Accept"`
29
+ > `readonly` **Accept**: `"accept"` = `"accept"`
30
30
 
31
31
  Accept.
32
32
 
33
33
  ### Authorization
34
34
 
35
- > `readonly` **Authorization**: `"Authorization"` = `"Authorization"`
35
+ > `readonly` **Authorization**: `"authorization"` = `"authorization"`
36
36
 
37
37
  Authorization.
38
38
 
39
39
  ### Cookie
40
40
 
41
- > `readonly` **Cookie**: `"Cookie"` = `"Cookie"`
41
+ > `readonly` **Cookie**: `"cookie"` = `"cookie"`
42
42
 
43
43
  Cookie.
44
44
 
45
45
  ### SetCookie
46
46
 
47
- > `readonly` **SetCookie**: `"Set-Cookie"` = `"Set-Cookie"`
47
+ > `readonly` **SetCookie**: `"set-cookie"` = `"set-cookie"`
48
48
 
49
49
  Set Cookie.
50
50
 
51
51
  ### Location
52
52
 
53
- > `readonly` **Location**: `"Location"` = `"Location"`
53
+ > `readonly` **Location**: `"location"` = `"location"`
54
54
 
55
55
  Location
@@ -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"`
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.4",
3
+ "version": "0.0.1-next.41",
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.4",
18
- "@twin.org/crypto": "0.0.1-next.4",
19
- "@twin.org/nameof": "next"
17
+ "@twin.org/core": "0.0.1-next.41",
18
+ "@twin.org/crypto": "0.0.1-next.41",
19
+ "@twin.org/nameof": "next",
20
+ "jose": "6.0.8"
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.