@rivascva/dt-idl 1.1.92 → 1.1.93

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 (2) hide show
  1. package/go/auth/utils.go +25 -0
  2. package/package.json +1 -1
package/go/auth/utils.go CHANGED
@@ -32,3 +32,28 @@ func CanActorAccessResourcesForUser(ctx context.Context, userId string) (bool, e
32
32
  return false, fmt.Errorf("invalid token type %s", tokenType)
33
33
  }
34
34
  }
35
+
36
+ // CanActorAccessResourcesForAll checks if the actor is allowed to access resources for all users.
37
+ func CanActorAccessResourcesForAll(ctx context.Context) (bool, error) {
38
+ // get the actor id from the context
39
+ actorId, err := utils.GetActorIdFromContext(ctx)
40
+ if err != nil {
41
+ return false, fmt.Errorf("failed to get the actor id from the context: %w", err)
42
+ }
43
+
44
+ // get the token type from the context
45
+ tokenType, err := utils.GetTokenTypeFromContext(ctx)
46
+ if err != nil {
47
+ return false, fmt.Errorf("failed to get the token type from the context: %w", err)
48
+ }
49
+
50
+ // check if the actor is allowed to access the user id
51
+ switch tokenType {
52
+ case "user":
53
+ return false, nil
54
+ case "service":
55
+ return slices.Contains(approvedServices, actorId), nil
56
+ default:
57
+ return false, fmt.Errorf("invalid token type %s", tokenType)
58
+ }
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivascva/dt-idl",
3
- "version": "1.1.92",
3
+ "version": "1.1.93",
4
4
  "description": "Dream Trade - Interface Definition Language",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",