@rivascva/dt-idl 1.1.66 → 1.1.68

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.
@@ -12,21 +12,13 @@ import (
12
12
  "github.com/RivasCVA/dt-idl/go/utils/responder"
13
13
  )
14
14
 
15
- // Adds shared headers to all responses.
16
- func CommonHeaders(next http.Handler) http.Handler {
17
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
18
- w.Header().Add("content-type", "application/json")
19
- next.ServeHTTP(w, r)
20
- })
21
- }
22
-
23
- // Returns a middleware function that perform authentication checks for a request.
15
+ // Returns a middleware function that authenticates all requests except for the login endpoints.
24
16
  // It attaches the token to the request context.
25
17
  func GetAuthMiddleware(secret string) func(http.Handler) http.Handler {
26
18
  responder := responder.NewStandardResponder(logger.NewConsoleLoggerWithPrefix("GetAuthMiddleware:"), "ERROR")
27
19
  return func(next http.Handler) http.Handler {
28
20
  return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
29
- // check if the request is for the login endpoint
21
+ // check if the request is a login endpoint
30
22
  if slices.Contains([]string{"/v1/login", "/v1/login/provider"}, r.URL.Path) {
31
23
  next.ServeHTTP(w, r)
32
24
  return
@@ -40,7 +32,7 @@ func GetAuthMiddleware(secret string) func(http.Handler) http.Handler {
40
32
  return
41
33
  }
42
34
 
43
- // validate the JWT token
35
+ // validate the token
44
36
  token, err := jwt.ValidateToken(arr[1], secret)
45
37
  if err != nil {
46
38
  responder.WriteError(w, http.StatusUnauthorized, "invalid token")
@@ -55,3 +47,11 @@ func GetAuthMiddleware(secret string) func(http.Handler) http.Handler {
55
47
  })
56
48
  }
57
49
  }
50
+
51
+ // Adds shared headers to all responses.
52
+ func CommonHeaders(next http.Handler) http.Handler {
53
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
54
+ w.Header().Add("content-type", "application/json")
55
+ next.ServeHTTP(w, r)
56
+ })
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivascva/dt-idl",
3
- "version": "1.1.66",
3
+ "version": "1.1.68",
4
4
  "description": "Dream Trade - Interface Definition Language",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",