@pgds/api-interface 1.2.5

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 (65) hide show
  1. package/README.md +410 -0
  2. package/client/FairtrailClient.d.ts +38 -0
  3. package/client/FairtrailClient.js +219 -0
  4. package/client/FairtrailClient.js.map +1 -0
  5. package/client/HttpClient.d.ts +36 -0
  6. package/client/HttpClient.js +360 -0
  7. package/client/HttpClient.js.map +1 -0
  8. package/client/index.d.ts +3 -0
  9. package/client/index.js +8 -0
  10. package/client/index.js.map +1 -0
  11. package/constants/index.d.ts +8 -0
  12. package/constants/index.js +13 -0
  13. package/constants/index.js.map +1 -0
  14. package/errors/index.d.ts +1 -0
  15. package/errors/index.js +72 -0
  16. package/errors/index.js.map +1 -0
  17. package/index.d.ts +7 -0
  18. package/index.js +23 -0
  19. package/lib/auth/mustbeConfig.d.ts +13 -0
  20. package/lib/auth/mustbeConfig.js +167 -0
  21. package/lib/auth/mustbeConfig.js.map +1 -0
  22. package/lib/constants/constants.d.ts +3 -0
  23. package/lib/constants/constants.js +8 -0
  24. package/lib/constants/constants.js.map +1 -0
  25. package/lib/index.d.ts +255 -0
  26. package/lib/index.js +462 -0
  27. package/lib/index.js.map +1 -0
  28. package/lib/models/Http.d.ts +62 -0
  29. package/lib/models/Http.js +3 -0
  30. package/lib/models/Http.js.map +1 -0
  31. package/lib/models/ReqUser.d.ts +10 -0
  32. package/lib/models/ReqUser.js +3 -0
  33. package/lib/models/ReqUser.js.map +1 -0
  34. package/lib/server/server.d.ts +13 -0
  35. package/lib/server/server.js +154 -0
  36. package/lib/server/server.js.map +1 -0
  37. package/lib/utils/asyncHooks.d.ts +28 -0
  38. package/lib/utils/asyncHooks.js +99 -0
  39. package/lib/utils/asyncHooks.js.map +1 -0
  40. package/lib/utils/jsonSchemaUtils.d.ts +14 -0
  41. package/lib/utils/jsonSchemaUtils.js +187 -0
  42. package/lib/utils/jsonSchemaUtils.js.map +1 -0
  43. package/lib/utils/logger.d.ts +5 -0
  44. package/lib/utils/logger.js +33 -0
  45. package/lib/utils/logger.js.map +1 -0
  46. package/lib/utils/urlUtils.d.ts +1 -0
  47. package/lib/utils/urlUtils.js +14 -0
  48. package/lib/utils/urlUtils.js.map +1 -0
  49. package/package.json +104 -0
  50. package/types/hiot.d.ts +368 -0
  51. package/types/mustbe/config/activities.d.ts +11 -0
  52. package/types/mustbe/config/index.d.ts +77 -0
  53. package/types/mustbe/config/parameter-map.d.ts +8 -0
  54. package/types/mustbe/config/route-helpers.d.ts +17 -0
  55. package/types/mustbe/config/user-identity.d.ts +7 -0
  56. package/types/mustbe/core.d.ts +23 -0
  57. package/types/mustbe/identities/userIdentity.d.ts +10 -0
  58. package/types/mustbe/index.d.ts +6 -0
  59. package/types/mustbe/principals/index.d.ts +10 -0
  60. package/types/mustbe/registry.d.ts +11 -0
  61. package/types/mustbe/routeHelpers/index.d.ts +20 -0
  62. package/types/mustbe/verifier/index.d.ts +10 -0
  63. package/utils/index.d.ts +13 -0
  64. package/utils/index.js +32 -0
  65. package/utils/index.js.map +1 -0
@@ -0,0 +1,13 @@
1
+ import { ReqUser } from "../lib/models/ReqUser";
2
+ /**
3
+ * Check if a user has a specific activity.
4
+ * @param reqUser The user to check.
5
+ * @param activity The activity to check for.
6
+ * @param wildcardCheck If true, will check for wildcard activities (the same way as activities on endpoints are checked). Otherwise will only check for exact matches. @default true
7
+ */
8
+ export declare function hasActivity(reqUser: ReqUser, activity: string, wildcardCheck?: boolean): boolean;
9
+ export declare function isGlobal(reqUser: ReqUser): boolean;
10
+ /**
11
+ * Short hand function to check if a user has the `canManageOrganization`(`CAN_MANAGE_ORGANIZATION_ACTIVITY`) activity.
12
+ */
13
+ export declare function canManageOrganization(reqUser: ReqUser): boolean;
package/utils/index.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasActivity = hasActivity;
4
+ exports.isGlobal = isGlobal;
5
+ exports.canManageOrganization = canManageOrganization;
6
+ var constants_1 = require("../constants");
7
+ var mustbeConfig_1 = require("../lib/auth/mustbeConfig");
8
+ /**
9
+ * Check if a user has a specific activity.
10
+ * @param reqUser The user to check.
11
+ * @param activity The activity to check for.
12
+ * @param wildcardCheck If true, will check for wildcard activities (the same way as activities on endpoints are checked). Otherwise will only check for exact matches. @default true
13
+ */
14
+ function hasActivity(reqUser, activity, wildcardCheck) {
15
+ if (wildcardCheck === void 0) { wildcardCheck = true; }
16
+ if (wildcardCheck) {
17
+ return (0, mustbeConfig_1.isUserAuthorized)(reqUser.activities, activity);
18
+ }
19
+ else {
20
+ return isGlobal(reqUser) || !!reqUser.activities[activity];
21
+ }
22
+ }
23
+ function isGlobal(reqUser) {
24
+ return !!reqUser.activities[constants_1.GLOBAL_ACTIVITY];
25
+ }
26
+ /**
27
+ * Short hand function to check if a user has the `canManageOrganization`(`CAN_MANAGE_ORGANIZATION_ACTIVITY`) activity.
28
+ */
29
+ function canManageOrganization(reqUser) {
30
+ return hasActivity(reqUser, constants_1.CAN_MANAGE_ORGANIZATION_ACTIVITY);
31
+ }
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAUA,kCAMC;AAED,4BAEC;AAKD,sDAEC;AA3BD,0CAAiF;AACjF,yDAA4D;AAG5D;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,OAAgB,EAAE,QAAgB,EAAE,aAA6B;IAA7B,8BAAA,EAAA,oBAA6B;IAC3F,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,IAAA,+BAAgB,EAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC;AAED,SAAgB,QAAQ,CAAC,OAAgB;IACvC,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,2BAAe,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,OAAgB;IACpD,OAAO,WAAW,CAAC,OAAO,EAAE,4CAAgC,CAAC,CAAC;AAChE,CAAC"}