@rivascva/dt-idl 1.1.84 → 1.1.86

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.
@@ -1,4 +1,4 @@
1
- package jwt
1
+ package auth
2
2
 
3
3
  import (
4
4
  "fmt"
@@ -0,0 +1,18 @@
1
+ package auth
2
+
3
+ import "time"
4
+
5
+ // DefaultServiceTokenDuration is the default duration for service tokens.
6
+ const DefaultServiceTokenDuration = 60 * time.Minute
7
+
8
+ // DefaultUserTokenDuration is the default duration for user tokens.
9
+ const DefaultUserTokenDuration = 15 * time.Minute
10
+
11
+ // DefaultServiceRefreshTokenDuration is the default duration for refresh tokens.
12
+ const DefaultServiceRefreshTokenDuration = 7 * 24 * time.Hour
13
+
14
+ // DefaultUserRefreshTokenDuration is the default duration for refresh tokens.
15
+ const DefaultUserRefreshTokenDuration = 30 * 24 * time.Hour
16
+
17
+ // approvedServices is a list of services that are allowed to access sensitive data.
18
+ var approvedServices = []string{"dt-trade-service", "dt-portfolio-service", "dt-asset-service", "dt-user-service"}
@@ -1,24 +1,23 @@
1
- package utils
1
+ package auth
2
2
 
3
3
  import (
4
4
  "context"
5
5
  "fmt"
6
6
  "slices"
7
- )
8
7
 
9
- // approvedServices is a list of services that are allowed to access sensitive data.
10
- var approvedServices = []string{"dt-trade-service", "dt-portfolio-service", "dt-asset-service", "dt-user-service"}
8
+ "github.com/RivasCVA/dt-idl/go/utils"
9
+ )
11
10
 
12
11
  // CanActorAccessUserId checks if the actor is allowed to access data for the user id.
13
12
  func CanActorAccessUserId(ctx context.Context, userId string) (bool, error) {
14
13
  // get the actor id from the context
15
- actorId, err := GetActorIdFromContext(ctx)
14
+ actorId, err := utils.GetActorIdFromContext(ctx)
16
15
  if err != nil {
17
16
  return false, fmt.Errorf("failed to get the actor id from the context: %w", err)
18
17
  }
19
18
 
20
19
  // get the token type from the context
21
- tokenType, err := GetTokenTypeFromContext(ctx)
20
+ tokenType, err := utils.GetTokenTypeFromContext(ctx)
22
21
  if err != nil {
23
22
  return false, fmt.Errorf("failed to get the token type from the context: %w", err)
24
23
  }
@@ -6,7 +6,7 @@ import (
6
6
  "slices"
7
7
  "strings"
8
8
 
9
- "github.com/RivasCVA/dt-idl/go/jwt"
9
+ "github.com/RivasCVA/dt-idl/go/auth"
10
10
  "github.com/RivasCVA/dt-idl/go/log"
11
11
  "github.com/RivasCVA/dt-idl/go/models"
12
12
  "github.com/RivasCVA/dt-idl/go/write"
@@ -35,7 +35,7 @@ func GetAuthMiddleware(secret string) func(http.Handler) http.Handler {
35
35
  }
36
36
 
37
37
  // validate the token
38
- token, err := jwt.ValidateToken(arr[1], secret)
38
+ token, err := auth.ValidateToken(arr[1], secret)
39
39
  if err != nil {
40
40
  write.ResponseWithError(r.Context(), w, http.StatusUnauthorized, "invalid token")
41
41
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivascva/dt-idl",
3
- "version": "1.1.84",
3
+ "version": "1.1.86",
4
4
  "description": "Dream Trade - Interface Definition Language",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,6 +0,0 @@
1
- package jwt
2
-
3
- import "time"
4
-
5
- // DefaultServiceTokenDuration is the default duration for service tokens.
6
- const DefaultServiceTokenDuration = 30 * time.Minute