@@ -4,7 +4,7 @@ A Serverless Workflow 1.x function that decodes JWT (JSON Web Token) payloads us
4
4
5
5
## Technical Implementation
6
6
7
- This function implements JWT payload extraction through a ` set ` task using jq expressions:
7
+ This function implements JWT payload extraction through a ` run ` task using jq expressions:
8
8
9
9
** Core JWT Decoding Logic:**
10
10
``` jq
@@ -36,10 +36,10 @@ document:
36
36
version : 1.0.0
37
37
do :
38
38
- decodeJWT :
39
- use : jwt-parser
39
+ call : jwt-parser
40
40
with :
41
41
token : ${ .headers.authorization }
42
- # Returns: { claims: {...}, result: {...} }
42
+ # Returns: complete JWT payload as JSON object
43
43
```
44
44
45
45
### Specific Claim Extraction
@@ -52,17 +52,17 @@ document:
52
52
version : 1.0.0
53
53
do :
54
54
- extractSubject :
55
- use : jwt-parser
55
+ call : jwt-parser
56
56
with :
57
57
token : ${ .headers.authorization }
58
58
claimPath : " .sub"
59
- # Returns: { claims: {...}, result: "user-id-123" }
59
+ # Returns: "user-id-123"
60
60
- extractNestedClaim :
61
- use : jwt-parser
61
+ call : jwt-parser
62
62
with :
63
63
token : ${ .headers.authorization }
64
64
claimPath : " .custom.department"
65
- # Returns: { claims: {...}, result: "engineering" }
65
+ # Returns: "engineering"
66
66
```
67
67
68
68
### Token Format Handling
@@ -75,11 +75,11 @@ document:
75
75
version : 1.0.0
76
76
do :
77
77
- parseRawToken :
78
- use : jwt-parser
78
+ call : jwt-parser
79
79
with :
80
80
token : " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.signature"
81
81
- parseBearerToken :
82
- use : jwt-parser
82
+ call : jwt-parser
83
83
with :
84
84
token : " Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.signature"
85
85
# Both handle the token format automatically
94
94
| ` claimPath ` | string | No | jq path expression for specific claim extraction |
95
95
96
96
### Output Structure
97
+
98
+ ** When ` claimPath ` is NOT provided** (complete payload):
97
99
``` json
98
100
{
99
- "claims" : {
100
- "sub" : " user-123" ,
101
- "preferred_username" : " john.doe" ,
102
-
103
- "exp" : 1234567890 ,
104
- "iat" : 1234567800
105
- },
106
- "result" : " ..." // Complete payload or specific claim based on claimPath
101
+ "sub" : " user-123" ,
102
+ "preferred_username" : " john.doe" ,
103
+
104
+ "exp" : 1234567890 ,
105
+ "iat" : 1234567800
107
106
}
108
107
```
109
108
109
+ ** When ` claimPath ` is provided** (specific claim value):
110
+ ``` json
111
+ " user-123"
112
+ ```
113
+ or
114
+ ``` json
115
+ " engineering"
116
+ ```
117
+
110
118
## Technical Details
111
119
112
120
### JWT Token Structure
0 commit comments