@rivascva/dt-idl 1.1.70 → 1.1.71

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.
@@ -2,6 +2,8 @@ package utils
2
2
 
3
3
  import (
4
4
  "context"
5
+ "errors"
6
+ "fmt"
5
7
 
6
8
  "github.com/RivasCVA/dt-idl/go/models"
7
9
  "github.com/golang-jwt/jwt/v5"
@@ -15,3 +17,19 @@ func GetTokenFromContext(ctx context.Context) *jwt.Token {
15
17
  }
16
18
  return token
17
19
  }
20
+
21
+ func GetUserIdFromContext(ctx context.Context) (string, error) {
22
+ // get the token from the context
23
+ token := GetTokenFromContext(ctx)
24
+ if token == nil {
25
+ return "", errors.New("token not found in the context")
26
+ }
27
+
28
+ // get the subject (userId) from the token
29
+ userId, err := token.Claims.GetSubject()
30
+ if err != nil {
31
+ return "", fmt.Errorf("failed to get the subject from the token: %w", err)
32
+ }
33
+
34
+ return userId, nil
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivascva/dt-idl",
3
- "version": "1.1.70",
3
+ "version": "1.1.71",
4
4
  "description": "Dream Trade - Interface Definition Language",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",