@webiny/api-audit-logs 0.0.0-unstable.06b2ede40f

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 (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/app/app.d.ts +2 -0
  4. package/app/app.js +119 -0
  5. package/app/app.js.map +1 -0
  6. package/app/contants.d.ts +2 -0
  7. package/app/contants.js +10 -0
  8. package/app/contants.js.map +1 -0
  9. package/app/createAppModifier.d.ts +4 -0
  10. package/app/createAppModifier.js +14 -0
  11. package/app/createAppModifier.js.map +1 -0
  12. package/app/index.d.ts +4 -0
  13. package/app/index.js +43 -0
  14. package/app/index.js.map +1 -0
  15. package/app/types.d.ts +7 -0
  16. package/app/types.js +7 -0
  17. package/app/types.js.map +1 -0
  18. package/config.d.ts +14 -0
  19. package/config.js +293 -0
  20. package/config.js.map +1 -0
  21. package/index.d.ts +5 -0
  22. package/index.js +49 -0
  23. package/index.js.map +1 -0
  24. package/package.json +47 -0
  25. package/subscriptions/aco/folders.d.ts +4 -0
  26. package/subscriptions/aco/folders.js +94 -0
  27. package/subscriptions/aco/folders.js.map +1 -0
  28. package/subscriptions/aco/index.d.ts +2 -0
  29. package/subscriptions/aco/index.js +18 -0
  30. package/subscriptions/aco/index.js.map +1 -0
  31. package/subscriptions/apw/changeRequests.d.ts +4 -0
  32. package/subscriptions/apw/changeRequests.js +80 -0
  33. package/subscriptions/apw/changeRequests.js.map +1 -0
  34. package/subscriptions/apw/comments.d.ts +2 -0
  35. package/subscriptions/apw/comments.js +28 -0
  36. package/subscriptions/apw/comments.js.map +1 -0
  37. package/subscriptions/apw/contentReviews.d.ts +2 -0
  38. package/subscriptions/apw/contentReviews.js +28 -0
  39. package/subscriptions/apw/contentReviews.js.map +1 -0
  40. package/subscriptions/apw/index.d.ts +2 -0
  41. package/subscriptions/apw/index.js +26 -0
  42. package/subscriptions/apw/index.js.map +1 -0
  43. package/subscriptions/apw/workflows.d.ts +4 -0
  44. package/subscriptions/apw/workflows.js +64 -0
  45. package/subscriptions/apw/workflows.js.map +1 -0
  46. package/subscriptions/fileManager/files.d.ts +4 -0
  47. package/subscriptions/fileManager/files.js +64 -0
  48. package/subscriptions/fileManager/files.js.map +1 -0
  49. package/subscriptions/fileManager/index.d.ts +2 -0
  50. package/subscriptions/fileManager/index.js +17 -0
  51. package/subscriptions/fileManager/index.js.map +1 -0
  52. package/subscriptions/fileManager/settings.d.ts +2 -0
  53. package/subscriptions/fileManager/settings.js +32 -0
  54. package/subscriptions/fileManager/settings.js.map +1 -0
  55. package/subscriptions/headlessCms/entries.d.ts +9 -0
  56. package/subscriptions/headlessCms/entries.js +183 -0
  57. package/subscriptions/headlessCms/entries.js.map +1 -0
  58. package/subscriptions/headlessCms/groups.d.ts +4 -0
  59. package/subscriptions/headlessCms/groups.js +64 -0
  60. package/subscriptions/headlessCms/groups.js.map +1 -0
  61. package/subscriptions/headlessCms/index.d.ts +2 -0
  62. package/subscriptions/headlessCms/index.js +31 -0
  63. package/subscriptions/headlessCms/index.js.map +1 -0
  64. package/subscriptions/headlessCms/models.d.ts +4 -0
  65. package/subscriptions/headlessCms/models.js +64 -0
  66. package/subscriptions/headlessCms/models.js.map +1 -0
  67. package/subscriptions/headlessCms/utils/isSearchModelEntry.d.ts +1 -0
  68. package/subscriptions/headlessCms/utils/isSearchModelEntry.js +13 -0
  69. package/subscriptions/headlessCms/utils/isSearchModelEntry.js.map +1 -0
  70. package/subscriptions/i18n/index.d.ts +2 -0
  71. package/subscriptions/i18n/index.js +15 -0
  72. package/subscriptions/i18n/index.js.map +1 -0
  73. package/subscriptions/i18n/locales.d.ts +4 -0
  74. package/subscriptions/i18n/locales.js +64 -0
  75. package/subscriptions/i18n/locales.js.map +1 -0
  76. package/subscriptions/index.d.ts +2 -0
  77. package/subscriptions/index.js +25 -0
  78. package/subscriptions/index.js.map +1 -0
  79. package/subscriptions/mailer/index.d.ts +2 -0
  80. package/subscriptions/mailer/index.js +13 -0
  81. package/subscriptions/mailer/index.js.map +1 -0
  82. package/subscriptions/mailer/settings.d.ts +2 -0
  83. package/subscriptions/mailer/settings.js +32 -0
  84. package/subscriptions/mailer/settings.js.map +1 -0
  85. package/subscriptions/security/apiKeys.d.ts +4 -0
  86. package/subscriptions/security/apiKeys.js +85 -0
  87. package/subscriptions/security/apiKeys.js.map +1 -0
  88. package/subscriptions/security/index.d.ts +2 -0
  89. package/subscriptions/security/index.js +27 -0
  90. package/subscriptions/security/index.js.map +1 -0
  91. package/subscriptions/security/roles.d.ts +4 -0
  92. package/subscriptions/security/roles.js +64 -0
  93. package/subscriptions/security/roles.js.map +1 -0
  94. package/subscriptions/security/teams.d.ts +4 -0
  95. package/subscriptions/security/teams.js +64 -0
  96. package/subscriptions/security/teams.js.map +1 -0
  97. package/subscriptions/security/users.d.ts +4 -0
  98. package/subscriptions/security/users.js +64 -0
  99. package/subscriptions/security/users.js.map +1 -0
  100. package/types.d.ts +53 -0
  101. package/types.js +18 -0
  102. package/types.js.map +1 -0
  103. package/utils/getAuditConfig.d.ts +36 -0
  104. package/utils/getAuditConfig.js +149 -0
  105. package/utils/getAuditConfig.js.map +1 -0
  106. package/utils/getAuditObject.d.ts +2 -0
  107. package/utils/getAuditObject.js +25 -0
  108. package/utils/getAuditObject.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onLocaleAfterCreateHook","context","i18n","locales","onLocaleAfterCreate","subscribe","locale","createAuditLog","getAuditConfig","AUDIT","I18N","LOCALE","CREATE","code","error","WebinyError","from","message","exports","onLocaleAfterUpdateHook","onLocaleAfterUpdate","original","UPDATE","before","after","onLocaleAfterDeleteHook","onLocaleAfterDelete","DELETE"],"sources":["locales.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const onLocaleAfterCreateHook = (context: AuditLogsContext) => {\n context.i18n.locales.onLocaleAfterCreate.subscribe(async ({ locale }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.I18N.LOCALE.CREATE);\n\n await createAuditLog(\"Locale created\", locale, locale.code, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onLocaleAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_LOCALE_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onLocaleAfterUpdateHook = (context: AuditLogsContext) => {\n context.i18n.locales.onLocaleAfterUpdate.subscribe(async ({ locale, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.I18N.LOCALE.UPDATE);\n\n await createAuditLog(\n \"Locale updated\",\n { before: original, after: locale },\n locale.code,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onLocaleAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_LOCALE_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onLocaleAfterDeleteHook = (context: AuditLogsContext) => {\n context.i18n.locales.onLocaleAfterDelete.subscribe(async ({ locale }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.I18N.LOCALE.DELETE);\n\n await createAuditLog(\"Locale deleted\", locale, locale.code, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onLocaleAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_LOCALE_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,uBAAuB,GAAIC,OAAyB,IAAK;EAClEA,OAAO,CAACC,IAAI,CAACC,OAAO,CAACC,mBAAmB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAO,CAAC,KAAK;IACrE,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,IAAI,CAACC,MAAM,CAACC,MAAM,CAAC;MAE/D,MAAML,cAAc,CAAC,gBAAgB,EAAED,MAAM,EAAEA,MAAM,CAACO,IAAI,EAAEZ,OAAO,CAAC;IACxE,CAAC,CAAC,OAAOa,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,oDAAoD;QAC7DJ,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAAlB,uBAAA,GAAAA,uBAAA;AAEK,MAAMmB,uBAAuB,GAAIlB,OAAyB,IAAK;EAClEA,OAAO,CAACC,IAAI,CAACC,OAAO,CAACiB,mBAAmB,CAACf,SAAS,CAAC,OAAO;IAAEC,MAAM;IAAEe;EAAS,CAAC,KAAK;IAC/E,IAAI;MACA,MAAMd,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,IAAI,CAACC,MAAM,CAACW,MAAM,CAAC;MAE/D,MAAMf,cAAc,CAChB,gBAAgB,EAChB;QAAEgB,MAAM,EAAEF,QAAQ;QAAEG,KAAK,EAAElB;MAAO,CAAC,EACnCA,MAAM,CAACO,IAAI,EACXZ,OACJ,CAAC;IACL,CAAC,CAAC,OAAOa,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,oDAAoD;QAC7DJ,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAAC,uBAAA,GAAAA,uBAAA;AAEK,MAAMM,uBAAuB,GAAIxB,OAAyB,IAAK;EAClEA,OAAO,CAACC,IAAI,CAACC,OAAO,CAACuB,mBAAmB,CAACrB,SAAS,CAAC,OAAO;IAAEC;EAAO,CAAC,KAAK;IACrE,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,IAAI,CAACC,MAAM,CAACgB,MAAM,CAAC;MAE/D,MAAMpB,cAAc,CAAC,gBAAgB,EAAED,MAAM,EAAEA,MAAM,CAACO,IAAI,EAAEZ,OAAO,CAAC;IACxE,CAAC,CAAC,OAAOa,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,oDAAoD;QAC7DJ,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAAO,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { AuditLogsContext } from "../types";
2
+ export declare const createSubscriptionHooks: (context: AuditLogsContext) => void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSubscriptionHooks = void 0;
7
+ var _fileManager = require("./fileManager");
8
+ var _headlessCms = require("./headlessCms");
9
+ var _security = require("./security");
10
+ var _i18n = require("./i18n");
11
+ var _mailer = require("./mailer");
12
+ var _aco = require("./aco");
13
+ var _apw = require("./apw");
14
+ const createSubscriptionHooks = context => {
15
+ (0, _fileManager.createFileManagerHooks)(context);
16
+ (0, _headlessCms.createHeadlessCmsHooks)(context);
17
+ (0, _security.createSecurityHooks)(context);
18
+ (0, _i18n.createI18NHooks)(context);
19
+ (0, _mailer.createMailerHooks)(context);
20
+ (0, _aco.createAcoHooks)(context);
21
+ context.wcp.canUseFeature("advancedPublishingWorkflow") && (0, _apw.createApwHooks)(context);
22
+ };
23
+ exports.createSubscriptionHooks = createSubscriptionHooks;
24
+
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_fileManager","require","_headlessCms","_security","_i18n","_mailer","_aco","_apw","createSubscriptionHooks","context","createFileManagerHooks","createHeadlessCmsHooks","createSecurityHooks","createI18NHooks","createMailerHooks","createAcoHooks","wcp","canUseFeature","createApwHooks","exports"],"sources":["index.ts"],"sourcesContent":["import { createFileManagerHooks } from \"./fileManager\";\nimport { createHeadlessCmsHooks } from \"./headlessCms\";\nimport { createSecurityHooks } from \"./security\";\nimport { createI18NHooks } from \"./i18n\";\nimport { createMailerHooks } from \"./mailer\";\nimport { createAcoHooks } from \"./aco\";\nimport { createApwHooks } from \"./apw\";\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const createSubscriptionHooks = (context: AuditLogsContext) => {\n createFileManagerHooks(context);\n createHeadlessCmsHooks(context);\n createSecurityHooks(context);\n createI18NHooks(context);\n createMailerHooks(context);\n createAcoHooks(context);\n context.wcp.canUseFeature(\"advancedPublishingWorkflow\") && createApwHooks(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AAGO,MAAMO,uBAAuB,GAAIC,OAAyB,IAAK;EAClE,IAAAC,mCAAsB,EAACD,OAAO,CAAC;EAC/B,IAAAE,mCAAsB,EAACF,OAAO,CAAC;EAC/B,IAAAG,6BAAmB,EAACH,OAAO,CAAC;EAC5B,IAAAI,qBAAe,EAACJ,OAAO,CAAC;EACxB,IAAAK,yBAAiB,EAACL,OAAO,CAAC;EAC1B,IAAAM,mBAAc,EAACN,OAAO,CAAC;EACvBA,OAAO,CAACO,GAAG,CAACC,aAAa,CAAC,4BAA4B,CAAC,IAAI,IAAAC,mBAAc,EAACT,OAAO,CAAC;AACtF,CAAC;AAACU,OAAA,CAAAX,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { AuditLogsContext } from "../../types";
2
+ export declare const createMailerHooks: (context: AuditLogsContext) => void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createMailerHooks = void 0;
7
+ var _settings = require("./settings");
8
+ const createMailerHooks = context => {
9
+ (0, _settings.onSettingsAfterUpdateHook)(context);
10
+ };
11
+ exports.createMailerHooks = createMailerHooks;
12
+
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_settings","require","createMailerHooks","context","onSettingsAfterUpdateHook","exports"],"sources":["index.ts"],"sourcesContent":["import { onSettingsAfterUpdateHook } from \"./settings\";\n\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const createMailerHooks = (context: AuditLogsContext) => {\n onSettingsAfterUpdateHook(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAIO,MAAMC,iBAAiB,GAAIC,OAAyB,IAAK;EAC5D,IAAAC,mCAAyB,EAACD,OAAO,CAAC;AACtC,CAAC;AAACE,OAAA,CAAAH,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { AuditLogsContext } from "../../types";
2
+ export declare const onSettingsAfterUpdateHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onSettingsAfterUpdateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ const onSettingsAfterUpdateHook = context => {
12
+ context.mailer.onSettingsAfterUpdate.subscribe(async ({
13
+ settings,
14
+ original
15
+ }) => {
16
+ try {
17
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.MAILER.SETTINGS.UPDATE);
18
+ await createAuditLog("Settings updated", {
19
+ before: original,
20
+ after: settings
21
+ }, "-", context);
22
+ } catch (error) {
23
+ throw _error.default.from(error, {
24
+ message: "Error while executing onSettingsAfterUpdateHook hook",
25
+ code: "AUDIT_LOGS_AFTER_SETTINGS_UPDATE_HOOK"
26
+ });
27
+ }
28
+ });
29
+ };
30
+ exports.onSettingsAfterUpdateHook = onSettingsAfterUpdateHook;
31
+
32
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onSettingsAfterUpdateHook","context","mailer","onSettingsAfterUpdate","subscribe","settings","original","createAuditLog","getAuditConfig","AUDIT","MAILER","SETTINGS","UPDATE","before","after","error","WebinyError","from","message","code","exports"],"sources":["settings.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const onSettingsAfterUpdateHook = (context: AuditLogsContext) => {\n context.mailer.onSettingsAfterUpdate.subscribe(async ({ settings, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.MAILER.SETTINGS.UPDATE);\n\n await createAuditLog(\n \"Settings updated\",\n { before: original, after: settings },\n \"-\",\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onSettingsAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_SETTINGS_UPDATE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,yBAAyB,GAAIC,OAAyB,IAAK;EACpEA,OAAO,CAACC,MAAM,CAACC,qBAAqB,CAACC,SAAS,CAAC,OAAO;IAAEC,QAAQ;IAAEC;EAAS,CAAC,KAAK;IAC7E,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;MAEnE,MAAML,cAAc,CAChB,kBAAkB,EAClB;QAAEM,MAAM,EAAEP,QAAQ;QAAEQ,KAAK,EAAET;MAAS,CAAC,EACrC,GAAG,EACHJ,OACJ,CAAC;IACL,CAAC,CAAC,OAAOc,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,sDAAsD;QAC/DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAApB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { AuditLogsContext } from "../../types";
2
+ export declare const onApiKeyAfterCreateHook: (context: AuditLogsContext) => void;
3
+ export declare const onApiKeyAfterUpdateHook: (context: AuditLogsContext) => void;
4
+ export declare const onApiKeyAfterDeleteHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onApiKeyAfterUpdateHook = exports.onApiKeyAfterDeleteHook = exports.onApiKeyAfterCreateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ /**
12
+ * We need to remove the token from the API Key object, as it is a security risk.
13
+ *
14
+ * We assign the API Key object explicitly, so we do not miss any new properties that might be added in the future - and they should not be in the log.
15
+ */
16
+ const cleanupApiKey = apiKey => {
17
+ return {
18
+ id: apiKey.id,
19
+ createdBy: apiKey.createdBy,
20
+ createdOn: apiKey.createdOn,
21
+ description: apiKey.description,
22
+ name: apiKey.name,
23
+ permissions: apiKey.permissions,
24
+ tenant: apiKey.tenant,
25
+ webinyVersion: apiKey.webinyVersion
26
+ };
27
+ };
28
+ const onApiKeyAfterCreateHook = context => {
29
+ context.security.onApiKeyAfterCreate.subscribe(async ({
30
+ apiKey: initialApiKey
31
+ }) => {
32
+ try {
33
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.API_KEY.CREATE);
34
+ const apiKey = cleanupApiKey(initialApiKey);
35
+ await createAuditLog("API key created", apiKey, apiKey.id, context);
36
+ } catch (error) {
37
+ throw _error.default.from(error, {
38
+ message: "Error while executing onApiKeyAfterCreateHook hook",
39
+ code: "AUDIT_LOGS_AFTER_API_KEY_CREATE_HOOK"
40
+ });
41
+ }
42
+ });
43
+ };
44
+ exports.onApiKeyAfterCreateHook = onApiKeyAfterCreateHook;
45
+ const onApiKeyAfterUpdateHook = context => {
46
+ context.security.onApiKeyAfterUpdate.subscribe(async ({
47
+ apiKey: initialApiKey,
48
+ original: initialOriginalApiKey
49
+ }) => {
50
+ try {
51
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.API_KEY.UPDATE);
52
+ const apiKey = cleanupApiKey(initialApiKey);
53
+ const original = cleanupApiKey(initialOriginalApiKey);
54
+ await createAuditLog("API key updated", {
55
+ before: original,
56
+ after: apiKey
57
+ }, apiKey.id, context);
58
+ } catch (error) {
59
+ throw _error.default.from(error, {
60
+ message: "Error while executing onApiKeyAfterUpdateHook hook",
61
+ code: "AUDIT_LOGS_AFTER_API_KEY_UPDATE_HOOK"
62
+ });
63
+ }
64
+ });
65
+ };
66
+ exports.onApiKeyAfterUpdateHook = onApiKeyAfterUpdateHook;
67
+ const onApiKeyAfterDeleteHook = context => {
68
+ context.security.onApiKeyAfterDelete.subscribe(async ({
69
+ apiKey: initialApiKey
70
+ }) => {
71
+ try {
72
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.API_KEY.DELETE);
73
+ const apiKey = cleanupApiKey(initialApiKey);
74
+ await createAuditLog("API key deleted", apiKey, apiKey.id, context);
75
+ } catch (error) {
76
+ throw _error.default.from(error, {
77
+ message: "Error while executing onApiKeyAfterDeleteHook hook",
78
+ code: "AUDIT_LOGS_AFTER_API_KEY_DELETE_HOOK"
79
+ });
80
+ }
81
+ });
82
+ };
83
+ exports.onApiKeyAfterDeleteHook = onApiKeyAfterDeleteHook;
84
+
85
+ //# sourceMappingURL=apiKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","cleanupApiKey","apiKey","id","createdBy","createdOn","description","name","permissions","tenant","webinyVersion","onApiKeyAfterCreateHook","context","security","onApiKeyAfterCreate","subscribe","initialApiKey","createAuditLog","getAuditConfig","AUDIT","SECURITY","API_KEY","CREATE","error","WebinyError","from","message","code","exports","onApiKeyAfterUpdateHook","onApiKeyAfterUpdate","original","initialOriginalApiKey","UPDATE","before","after","onApiKeyAfterDeleteHook","onApiKeyAfterDelete","DELETE"],"sources":["apiKeys.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport type { AuditLogsContext } from \"~/types\";\nimport type { ApiKey } from \"@webiny/api-security/types\";\n\n/**\n * We need to remove the token from the API Key object, as it is a security risk.\n *\n * We assign the API Key object explicitly, so we do not miss any new properties that might be added in the future - and they should not be in the log.\n */\nconst cleanupApiKey = (apiKey: ApiKey): Omit<ApiKey, \"token\"> => {\n return {\n id: apiKey.id,\n createdBy: apiKey.createdBy,\n createdOn: apiKey.createdOn,\n description: apiKey.description,\n name: apiKey.name,\n permissions: apiKey.permissions,\n tenant: apiKey.tenant,\n webinyVersion: apiKey.webinyVersion\n };\n};\n\nexport const onApiKeyAfterCreateHook = (context: AuditLogsContext) => {\n context.security.onApiKeyAfterCreate.subscribe(async ({ apiKey: initialApiKey }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.API_KEY.CREATE);\n\n const apiKey = cleanupApiKey(initialApiKey);\n\n await createAuditLog(\"API key created\", apiKey, apiKey.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onApiKeyAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_API_KEY_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onApiKeyAfterUpdateHook = (context: AuditLogsContext) => {\n context.security.onApiKeyAfterUpdate.subscribe(\n async ({ apiKey: initialApiKey, original: initialOriginalApiKey }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.API_KEY.UPDATE);\n\n const apiKey = cleanupApiKey(initialApiKey);\n const original = cleanupApiKey(initialOriginalApiKey);\n\n await createAuditLog(\n \"API key updated\",\n {\n before: original,\n after: apiKey\n },\n apiKey.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onApiKeyAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_API_KEY_UPDATE_HOOK\"\n });\n }\n }\n );\n};\n\nexport const onApiKeyAfterDeleteHook = (context: AuditLogsContext) => {\n context.security.onApiKeyAfterDelete.subscribe(async ({ apiKey: initialApiKey }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.API_KEY.DELETE);\n\n const apiKey = cleanupApiKey(initialApiKey);\n\n await createAuditLog(\"API key deleted\", apiKey, apiKey.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onApiKeyAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_API_KEY_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { AuditLogsContext } from "../../types";
2
+ export declare const createSecurityHooks: (context: AuditLogsContext) => void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSecurityHooks = void 0;
7
+ var _apiKeys = require("./apiKeys");
8
+ var _roles = require("./roles");
9
+ var _teams = require("./teams");
10
+ var _users = require("./users");
11
+ const createSecurityHooks = context => {
12
+ (0, _apiKeys.onApiKeyAfterCreateHook)(context);
13
+ (0, _apiKeys.onApiKeyAfterUpdateHook)(context);
14
+ (0, _apiKeys.onApiKeyAfterDeleteHook)(context);
15
+ (0, _roles.onRoleAfterCreateHook)(context);
16
+ (0, _roles.onRoleAfterUpdateHook)(context);
17
+ (0, _roles.onRoleAfterDeleteHook)(context);
18
+ (0, _teams.onTeamAfterCreateHook)(context);
19
+ (0, _teams.onTeamAfterUpdateHook)(context);
20
+ (0, _teams.onTeamAfterDeleteHook)(context);
21
+ (0, _users.onUserAfterCreateHook)(context);
22
+ (0, _users.onUserAfterUpdateHook)(context);
23
+ (0, _users.onUserAfterDeleteHook)(context);
24
+ };
25
+ exports.createSecurityHooks = createSecurityHooks;
26
+
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_apiKeys","require","_roles","_teams","_users","createSecurityHooks","context","onApiKeyAfterCreateHook","onApiKeyAfterUpdateHook","onApiKeyAfterDeleteHook","onRoleAfterCreateHook","onRoleAfterUpdateHook","onRoleAfterDeleteHook","onTeamAfterCreateHook","onTeamAfterUpdateHook","onTeamAfterDeleteHook","onUserAfterCreateHook","onUserAfterUpdateHook","onUserAfterDeleteHook","exports"],"sources":["index.ts"],"sourcesContent":["import {\n onApiKeyAfterCreateHook,\n onApiKeyAfterUpdateHook,\n onApiKeyAfterDeleteHook\n} from \"./apiKeys\";\nimport { onRoleAfterCreateHook, onRoleAfterUpdateHook, onRoleAfterDeleteHook } from \"./roles\";\nimport { onTeamAfterCreateHook, onTeamAfterUpdateHook, onTeamAfterDeleteHook } from \"./teams\";\nimport { onUserAfterCreateHook, onUserAfterUpdateHook, onUserAfterDeleteHook } from \"./users\";\n\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const createSecurityHooks = (context: AuditLogsContext) => {\n onApiKeyAfterCreateHook(context);\n onApiKeyAfterUpdateHook(context);\n onApiKeyAfterDeleteHook(context);\n onRoleAfterCreateHook(context);\n onRoleAfterUpdateHook(context);\n onRoleAfterDeleteHook(context);\n onTeamAfterCreateHook(context);\n onTeamAfterUpdateHook(context);\n onTeamAfterDeleteHook(context);\n onUserAfterCreateHook(context);\n onUserAfterUpdateHook(context);\n onUserAfterDeleteHook(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAIO,MAAMI,mBAAmB,GAAIC,OAAyB,IAAK;EAC9D,IAAAC,gCAAuB,EAACD,OAAO,CAAC;EAChC,IAAAE,gCAAuB,EAACF,OAAO,CAAC;EAChC,IAAAG,gCAAuB,EAACH,OAAO,CAAC;EAChC,IAAAI,4BAAqB,EAACJ,OAAO,CAAC;EAC9B,IAAAK,4BAAqB,EAACL,OAAO,CAAC;EAC9B,IAAAM,4BAAqB,EAACN,OAAO,CAAC;EAC9B,IAAAO,4BAAqB,EAACP,OAAO,CAAC;EAC9B,IAAAQ,4BAAqB,EAACR,OAAO,CAAC;EAC9B,IAAAS,4BAAqB,EAACT,OAAO,CAAC;EAC9B,IAAAU,4BAAqB,EAACV,OAAO,CAAC;EAC9B,IAAAW,4BAAqB,EAACX,OAAO,CAAC;EAC9B,IAAAY,4BAAqB,EAACZ,OAAO,CAAC;AAClC,CAAC;AAACa,OAAA,CAAAd,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { AuditLogsContext } from "../../types";
2
+ export declare const onRoleAfterCreateHook: (context: AuditLogsContext) => void;
3
+ export declare const onRoleAfterUpdateHook: (context: AuditLogsContext) => void;
4
+ export declare const onRoleAfterDeleteHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onRoleAfterUpdateHook = exports.onRoleAfterDeleteHook = exports.onRoleAfterCreateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ const onRoleAfterCreateHook = context => {
12
+ context.security.onGroupAfterCreate.subscribe(async ({
13
+ group
14
+ }) => {
15
+ try {
16
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.ROLE.CREATE);
17
+ await createAuditLog("Role created", group, group.id, context);
18
+ } catch (error) {
19
+ throw _error.default.from(error, {
20
+ message: "Error while executing onRoleAfterCreateHook hook",
21
+ code: "AUDIT_LOGS_AFTER_ROLE_CREATE_HOOK"
22
+ });
23
+ }
24
+ });
25
+ };
26
+ exports.onRoleAfterCreateHook = onRoleAfterCreateHook;
27
+ const onRoleAfterUpdateHook = context => {
28
+ context.security.onGroupAfterUpdate.subscribe(async ({
29
+ group,
30
+ original
31
+ }) => {
32
+ try {
33
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.ROLE.UPDATE);
34
+ await createAuditLog("Role updated", {
35
+ before: original,
36
+ after: group
37
+ }, group.id, context);
38
+ } catch (error) {
39
+ throw _error.default.from(error, {
40
+ message: "Error while executing onRoleAfterUpdateHook hook",
41
+ code: "AUDIT_LOGS_AFTER_ROLE_UPDATE_HOOK"
42
+ });
43
+ }
44
+ });
45
+ };
46
+ exports.onRoleAfterUpdateHook = onRoleAfterUpdateHook;
47
+ const onRoleAfterDeleteHook = context => {
48
+ context.security.onGroupAfterDelete.subscribe(async ({
49
+ group
50
+ }) => {
51
+ try {
52
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.ROLE.DELETE);
53
+ await createAuditLog("Role deleted", group, group.id, context);
54
+ } catch (error) {
55
+ throw _error.default.from(error, {
56
+ message: "Error while executing onRoleAfterDeleteHook hook",
57
+ code: "AUDIT_LOGS_AFTER_ROLE_DELETE_HOOK"
58
+ });
59
+ }
60
+ });
61
+ };
62
+ exports.onRoleAfterDeleteHook = onRoleAfterDeleteHook;
63
+
64
+ //# sourceMappingURL=roles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onRoleAfterCreateHook","context","security","onGroupAfterCreate","subscribe","group","createAuditLog","getAuditConfig","AUDIT","SECURITY","ROLE","CREATE","id","error","WebinyError","from","message","code","exports","onRoleAfterUpdateHook","onGroupAfterUpdate","original","UPDATE","before","after","onRoleAfterDeleteHook","onGroupAfterDelete","DELETE"],"sources":["roles.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const onRoleAfterCreateHook = (context: AuditLogsContext) => {\n context.security.onGroupAfterCreate.subscribe(async ({ group }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.ROLE.CREATE);\n\n await createAuditLog(\"Role created\", group, group.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onRoleAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_ROLE_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onRoleAfterUpdateHook = (context: AuditLogsContext) => {\n context.security.onGroupAfterUpdate.subscribe(async ({ group, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.ROLE.UPDATE);\n\n await createAuditLog(\n \"Role updated\",\n { before: original, after: group },\n group.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onRoleAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_ROLE_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onRoleAfterDeleteHook = (context: AuditLogsContext) => {\n context.security.onGroupAfterDelete.subscribe(async ({ group }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.ROLE.DELETE);\n\n await createAuditLog(\"Role deleted\", group, group.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onRoleAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_ROLE_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,OAAyB,IAAK;EAChEA,OAAO,CAACC,QAAQ,CAACC,kBAAkB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IAC/D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACC,MAAM,CAAC;MAEjE,MAAML,cAAc,CAAC,cAAc,EAAED,KAAK,EAAEA,KAAK,CAACO,EAAE,EAAEX,OAAO,CAAC;IAClE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAlB,qBAAA,GAAAA,qBAAA;AAEK,MAAMmB,qBAAqB,GAAIlB,OAAyB,IAAK;EAChEA,OAAO,CAACC,QAAQ,CAACkB,kBAAkB,CAAChB,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEgB;EAAS,CAAC,KAAK;IACzE,IAAI;MACA,MAAMf,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACY,MAAM,CAAC;MAEjE,MAAMhB,cAAc,CAChB,cAAc,EACd;QAAEiB,MAAM,EAAEF,QAAQ;QAAEG,KAAK,EAAEnB;MAAM,CAAC,EAClCA,KAAK,CAACO,EAAE,EACRX,OACJ,CAAC;IACL,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAEK,MAAMM,qBAAqB,GAAIxB,OAAyB,IAAK;EAChEA,OAAO,CAACC,QAAQ,CAACwB,kBAAkB,CAACtB,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IAC/D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACiB,MAAM,CAAC;MAEjE,MAAMrB,cAAc,CAAC,cAAc,EAAED,KAAK,EAAEA,KAAK,CAACO,EAAE,EAAEX,OAAO,CAAC;IAClE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAO,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { AuditLogsContext } from "../../types";
2
+ export declare const onTeamAfterCreateHook: (context: AuditLogsContext) => void;
3
+ export declare const onTeamAfterUpdateHook: (context: AuditLogsContext) => void;
4
+ export declare const onTeamAfterDeleteHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onTeamAfterUpdateHook = exports.onTeamAfterDeleteHook = exports.onTeamAfterCreateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ const onTeamAfterCreateHook = context => {
12
+ context.security.onTeamAfterCreate.subscribe(async ({
13
+ team
14
+ }) => {
15
+ try {
16
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.TEAM.CREATE);
17
+ await createAuditLog("Team created", team, team.id, context);
18
+ } catch (error) {
19
+ throw _error.default.from(error, {
20
+ message: "Error while executing onTeamAfterCreateHook hook",
21
+ code: "AUDIT_LOGS_AFTER_TEAM_CREATE_HOOK"
22
+ });
23
+ }
24
+ });
25
+ };
26
+ exports.onTeamAfterCreateHook = onTeamAfterCreateHook;
27
+ const onTeamAfterUpdateHook = context => {
28
+ context.security.onTeamAfterUpdate.subscribe(async ({
29
+ team,
30
+ original
31
+ }) => {
32
+ try {
33
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.TEAM.UPDATE);
34
+ await createAuditLog("Team updated", {
35
+ before: original,
36
+ after: team
37
+ }, team.id, context);
38
+ } catch (error) {
39
+ throw _error.default.from(error, {
40
+ message: "Error while executing onTeamAfterUpdateHook hook",
41
+ code: "AUDIT_LOGS_AFTER_TEAM_UPDATE_HOOK"
42
+ });
43
+ }
44
+ });
45
+ };
46
+ exports.onTeamAfterUpdateHook = onTeamAfterUpdateHook;
47
+ const onTeamAfterDeleteHook = context => {
48
+ context.security.onTeamAfterDelete.subscribe(async ({
49
+ team
50
+ }) => {
51
+ try {
52
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.TEAM.DELETE);
53
+ await createAuditLog("Team deleted", team, team.id, context);
54
+ } catch (error) {
55
+ throw _error.default.from(error, {
56
+ message: "Error while executing onTeamAfterDeleteHook hook",
57
+ code: "AUDIT_LOGS_AFTER_TEAM_DELETE_HOOK"
58
+ });
59
+ }
60
+ });
61
+ };
62
+ exports.onTeamAfterDeleteHook = onTeamAfterDeleteHook;
63
+
64
+ //# sourceMappingURL=teams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onTeamAfterCreateHook","context","security","onTeamAfterCreate","subscribe","team","createAuditLog","getAuditConfig","AUDIT","SECURITY","TEAM","CREATE","id","error","WebinyError","from","message","code","exports","onTeamAfterUpdateHook","onTeamAfterUpdate","original","UPDATE","before","after","onTeamAfterDeleteHook","onTeamAfterDelete","DELETE"],"sources":["teams.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const onTeamAfterCreateHook = (context: AuditLogsContext) => {\n context.security.onTeamAfterCreate.subscribe(async ({ team }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.TEAM.CREATE);\n\n await createAuditLog(\"Team created\", team, team.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTeamAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_TEAM_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onTeamAfterUpdateHook = (context: AuditLogsContext) => {\n context.security.onTeamAfterUpdate.subscribe(async ({ team, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.TEAM.UPDATE);\n\n await createAuditLog(\n \"Team updated\",\n { before: original, after: team },\n team.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTeamAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_TEAM_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onTeamAfterDeleteHook = (context: AuditLogsContext) => {\n context.security.onTeamAfterDelete.subscribe(async ({ team }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.TEAM.DELETE);\n\n await createAuditLog(\"Team deleted\", team, team.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onTeamAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_TEAM_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,OAAyB,IAAK;EAChEA,OAAO,CAACC,QAAQ,CAACC,iBAAiB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAC7D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACC,MAAM,CAAC;MAEjE,MAAML,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAlB,qBAAA,GAAAA,qBAAA;AAEK,MAAMmB,qBAAqB,GAAIlB,OAAyB,IAAK;EAChEA,OAAO,CAACC,QAAQ,CAACkB,iBAAiB,CAAChB,SAAS,CAAC,OAAO;IAAEC,IAAI;IAAEgB;EAAS,CAAC,KAAK;IACvE,IAAI;MACA,MAAMf,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACY,MAAM,CAAC;MAEjE,MAAMhB,cAAc,CAChB,cAAc,EACd;QAAEiB,MAAM,EAAEF,QAAQ;QAAEG,KAAK,EAAEnB;MAAK,CAAC,EACjCA,IAAI,CAACO,EAAE,EACPX,OACJ,CAAC;IACL,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAEK,MAAMM,qBAAqB,GAAIxB,OAAyB,IAAK;EAChEA,OAAO,CAACC,QAAQ,CAACwB,iBAAiB,CAACtB,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAC7D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACiB,MAAM,CAAC;MAEjE,MAAMrB,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAO,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { AuditLogsContext } from "../../types";
2
+ export declare const onUserAfterCreateHook: (context: AuditLogsContext) => void;
3
+ export declare const onUserAfterUpdateHook: (context: AuditLogsContext) => void;
4
+ export declare const onUserAfterDeleteHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onUserAfterUpdateHook = exports.onUserAfterDeleteHook = exports.onUserAfterCreateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ const onUserAfterCreateHook = context => {
12
+ context.adminUsers.onUserAfterCreate.subscribe(async ({
13
+ user
14
+ }) => {
15
+ try {
16
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.USER.CREATE);
17
+ await createAuditLog("User created", user, user.id, context);
18
+ } catch (error) {
19
+ throw _error.default.from(error, {
20
+ message: "Error while executing onUserAfterCreateHook hook",
21
+ code: "AUDIT_LOGS_AFTER_USER_CREATE_HOOK"
22
+ });
23
+ }
24
+ });
25
+ };
26
+ exports.onUserAfterCreateHook = onUserAfterCreateHook;
27
+ const onUserAfterUpdateHook = context => {
28
+ context.adminUsers.onUserAfterUpdate.subscribe(async ({
29
+ updatedUser,
30
+ originalUser
31
+ }) => {
32
+ try {
33
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.USER.UPDATE);
34
+ await createAuditLog("User updated", {
35
+ before: originalUser,
36
+ after: updatedUser
37
+ }, updatedUser.id, context);
38
+ } catch (error) {
39
+ throw _error.default.from(error, {
40
+ message: "Error while executing onUserAfterUpdateHook hook",
41
+ code: "AUDIT_LOGS_AFTER_USER_UPDATE_HOOK"
42
+ });
43
+ }
44
+ });
45
+ };
46
+ exports.onUserAfterUpdateHook = onUserAfterUpdateHook;
47
+ const onUserAfterDeleteHook = context => {
48
+ context.adminUsers.onUserAfterDelete.subscribe(async ({
49
+ user
50
+ }) => {
51
+ try {
52
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.SECURITY.USER.DELETE);
53
+ await createAuditLog("User deleted", user, user.id, context);
54
+ } catch (error) {
55
+ throw _error.default.from(error, {
56
+ message: "Error while executing onUserAfterDeleteHook hook",
57
+ code: "AUDIT_LOGS_AFTER_USER_DELETE_HOOK"
58
+ });
59
+ }
60
+ });
61
+ };
62
+ exports.onUserAfterDeleteHook = onUserAfterDeleteHook;
63
+
64
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onUserAfterCreateHook","context","adminUsers","onUserAfterCreate","subscribe","user","createAuditLog","getAuditConfig","AUDIT","SECURITY","USER","CREATE","id","error","WebinyError","from","message","code","exports","onUserAfterUpdateHook","onUserAfterUpdate","updatedUser","originalUser","UPDATE","before","after","onUserAfterDeleteHook","onUserAfterDelete","DELETE"],"sources":["users.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const onUserAfterCreateHook = (context: AuditLogsContext) => {\n context.adminUsers.onUserAfterCreate.subscribe(async ({ user }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.USER.CREATE);\n\n await createAuditLog(\"User created\", user, user.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onUserAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_USER_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onUserAfterUpdateHook = (context: AuditLogsContext) => {\n context.adminUsers.onUserAfterUpdate.subscribe(async ({ updatedUser, originalUser }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.USER.UPDATE);\n\n await createAuditLog(\n \"User updated\",\n { before: originalUser, after: updatedUser },\n updatedUser.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onUserAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_USER_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onUserAfterDeleteHook = (context: AuditLogsContext) => {\n context.adminUsers.onUserAfterDelete.subscribe(async ({ user }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.SECURITY.USER.DELETE);\n\n await createAuditLog(\"User deleted\", user, user.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onUserAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_USER_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,OAAyB,IAAK;EAChEA,OAAO,CAACC,UAAU,CAACC,iBAAiB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAC/D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACC,MAAM,CAAC;MAEjE,MAAML,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAlB,qBAAA,GAAAA,qBAAA;AAEK,MAAMmB,qBAAqB,GAAIlB,OAAyB,IAAK;EAChEA,OAAO,CAACC,UAAU,CAACkB,iBAAiB,CAAChB,SAAS,CAAC,OAAO;IAAEiB,WAAW;IAAEC;EAAa,CAAC,KAAK;IACpF,IAAI;MACA,MAAMhB,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACa,MAAM,CAAC;MAEjE,MAAMjB,cAAc,CAChB,cAAc,EACd;QAAEkB,MAAM,EAAEF,YAAY;QAAEG,KAAK,EAAEJ;MAAY,CAAC,EAC5CA,WAAW,CAACT,EAAE,EACdX,OACJ,CAAC;IACL,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAEK,MAAMO,qBAAqB,GAAIzB,OAAyB,IAAK;EAChEA,OAAO,CAACC,UAAU,CAACyB,iBAAiB,CAACvB,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAC/D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,QAAQ,CAACC,IAAI,CAACkB,MAAM,CAAC;MAEjE,MAAMtB,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAQ,qBAAA,GAAAA,qBAAA","ignoreList":[]}
package/types.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import type { AcoContext } from "@webiny/api-aco/types";
2
+ import type { MailerContext } from "@webiny/api-mailer/types";
3
+ import type { SecurityContext } from "@webiny/api-security/types";
4
+ import type { ApwContext } from "@webiny/api-apw/types";
5
+ import type { Context as BaseContext } from "@webiny/handler/types";
6
+ export * from "./app/types";
7
+ export interface Action {
8
+ type: string;
9
+ displayName: string;
10
+ /**
11
+ * Delay in seconds before a new audit log can be created.
12
+ * During this delay actions will update existing audit log instead of creating new ones.
13
+ */
14
+ newEntryDelay?: number;
15
+ }
16
+ export interface Entity {
17
+ type: string;
18
+ displayName: string;
19
+ linkToEntity?: (id: string) => string;
20
+ actions: Action[];
21
+ }
22
+ export interface App {
23
+ app: string;
24
+ displayName: string;
25
+ entities: Entity[];
26
+ }
27
+ export interface AuditLog {
28
+ id: string;
29
+ message: string;
30
+ app: string;
31
+ entity: string;
32
+ entityId: string;
33
+ action: string;
34
+ data: JSON;
35
+ timestamp: Date;
36
+ initiator: string;
37
+ }
38
+ export interface AuditLogsContext extends BaseContext, AcoContext, MailerContext, SecurityContext, ApwContext {
39
+ }
40
+ export interface AuditObject {
41
+ [app: string]: EntityObject;
42
+ }
43
+ export interface EntityObject {
44
+ [entity: string]: ActionObject;
45
+ }
46
+ export interface ActionObject {
47
+ [action: string]: AuditAction;
48
+ }
49
+ export interface AuditAction {
50
+ app: App;
51
+ entity: Entity;
52
+ action: Action;
53
+ }
package/types.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _types = require("./app/types");
7
+ Object.keys(_types).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _types[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _types[key];
14
+ }
15
+ });
16
+ });
17
+
18
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["types.ts"],"sourcesContent":["import type { AcoContext } from \"@webiny/api-aco/types\";\nimport type { MailerContext } from \"@webiny/api-mailer/types\";\nimport type { SecurityContext } from \"@webiny/api-security/types\";\nimport type { ApwContext } from \"@webiny/api-apw/types\";\nimport type { Context as BaseContext } from \"@webiny/handler/types\";\n\nexport * from \"~/app/types\";\n\nexport interface Action {\n type: string;\n displayName: string;\n /**\n * Delay in seconds before a new audit log can be created.\n * During this delay actions will update existing audit log instead of creating new ones.\n */\n newEntryDelay?: number;\n}\n\nexport interface Entity {\n type: string;\n displayName: string;\n linkToEntity?: (id: string) => string;\n actions: Action[];\n}\n\nexport interface App {\n app: string;\n displayName: string;\n entities: Entity[];\n}\n\nexport interface AuditLog {\n id: string;\n message: string;\n app: string;\n entity: string;\n entityId: string;\n action: string;\n data: JSON;\n timestamp: Date;\n initiator: string;\n}\n\nexport interface AuditLogsContext\n extends BaseContext,\n AcoContext,\n MailerContext,\n SecurityContext,\n ApwContext {}\n\nexport interface AuditObject {\n [app: string]: EntityObject;\n}\n\nexport interface EntityObject {\n [entity: string]: ActionObject;\n}\n\nexport interface ActionObject {\n [action: string]: AuditAction;\n}\n\nexport interface AuditAction {\n app: App;\n entity: Entity;\n action: Action;\n}\n"],"mappings":";;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ import type { AuditAction, AuditLogsContext } from "../types";
2
+ export declare const getAuditConfig: (audit: AuditAction) => (message: string, data: Record<string, any>, entityId: string, context: AuditLogsContext) => Promise<string | {
3
+ id: string;
4
+ title: string;
5
+ content: string;
6
+ tags: never[];
7
+ type: string;
8
+ location: {
9
+ folderId: string;
10
+ };
11
+ data: {
12
+ data: string;
13
+ message: string;
14
+ action: string;
15
+ timestamp: Date;
16
+ app: string;
17
+ entity: string;
18
+ entityId: string;
19
+ initiator: string;
20
+ };
21
+ } | {
22
+ data: string;
23
+ type: string;
24
+ title: string;
25
+ content?: string | undefined;
26
+ location: import("@webiny/api-aco/types").Location;
27
+ tags: string[];
28
+ id: string;
29
+ entryId: string;
30
+ createdOn: string;
31
+ modifiedOn: string | null;
32
+ savedOn: string;
33
+ createdBy: import("@webiny/api-aco/types").User;
34
+ modifiedBy: import("@webiny/api-aco/types").User | null;
35
+ savedBy: import("@webiny/api-aco/types").User;
36
+ } | undefined>;