@webiny/api-audit-logs 6.6.0-alpha.12 → 6.6.0-alpha.14
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.
- package/features/GetAuditLog/GetAuditLogUseCase.js +3 -0
- package/features/GetAuditLog/GetAuditLogUseCase.js.map +1 -1
- package/package.json +23 -23
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.d.ts +2 -2
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js +7 -4
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js.map +1 -1
- package/utils/expiresAt.js +1 -1
- package/utils/expiresAt.js.map +1 -1
|
@@ -8,6 +8,9 @@ class GetAuditLogUseCaseImpl {
|
|
|
8
8
|
this.permissions = permissions;
|
|
9
9
|
}
|
|
10
10
|
async execute(id) {
|
|
11
|
+
if (!await this.permissions.canAccessAll()) return Result.fail(new NotAuthorizedError({
|
|
12
|
+
message: "You cannot access audit logs."
|
|
13
|
+
}));
|
|
11
14
|
const result = await this.repository.get(id);
|
|
12
15
|
if (result.isFail()) return Result.fail(result.error);
|
|
13
16
|
const canAccess = await this.permissions.canAccess(result.value.action);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/GetAuditLog/GetAuditLogUseCase.js","sources":["../../../src/features/GetAuditLog/GetAuditLogUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/errors.js\";\nimport { AuditLogPermissions } from \"~/features/AuditLogPermissions/abstractions.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { GetAuditLogUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { GetAuditLogRepository } from \"./abstractions.js\";\n\nclass GetAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private readonly repository: GetAuditLogRepository.Interface,\n private readonly permissions: AuditLogPermissions.Interface\n ) {}\n\n public async execute(id: string): Promise<Result<IAuditLog, UseCaseAbstraction.Error>> {\n const result = await this.repository.get(id);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const canAccess = await this.permissions.canAccess(result.value.action);\n if (!canAccess) {\n return Result.fail(\n new NotAuthorizedError({ message: \"You cannot access audit logs.\" })\n );\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const GetAuditLogUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetAuditLogUseCaseImpl,\n dependencies: [GetAuditLogRepository, AuditLogPermissions]\n});\n"],"names":["GetAuditLogUseCaseImpl","repository","permissions","id","
|
|
1
|
+
{"version":3,"file":"features/GetAuditLog/GetAuditLogUseCase.js","sources":["../../../src/features/GetAuditLog/GetAuditLogUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/errors.js\";\nimport { AuditLogPermissions } from \"~/features/AuditLogPermissions/abstractions.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { GetAuditLogUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { GetAuditLogRepository } from \"./abstractions.js\";\n\nclass GetAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private readonly repository: GetAuditLogRepository.Interface,\n private readonly permissions: AuditLogPermissions.Interface\n ) {}\n\n public async execute(id: string): Promise<Result<IAuditLog, UseCaseAbstraction.Error>> {\n // Checked before the record is loaded, so the response does not reveal whether the ID exists.\n if (!(await this.permissions.canAccessAll())) {\n return Result.fail(\n new NotAuthorizedError({ message: \"You cannot access audit logs.\" })\n );\n }\n\n const result = await this.repository.get(id);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const canAccess = await this.permissions.canAccess(result.value.action);\n if (!canAccess) {\n return Result.fail(\n new NotAuthorizedError({ message: \"You cannot access audit logs.\" })\n );\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const GetAuditLogUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetAuditLogUseCaseImpl,\n dependencies: [GetAuditLogRepository, AuditLogPermissions]\n});\n"],"names":["GetAuditLogUseCaseImpl","repository","permissions","id","Result","NotAuthorizedError","result","canAccess","GetAuditLogUseCase","UseCaseAbstraction","GetAuditLogRepository","AuditLogPermissions"],"mappings":";;;;AAOA,MAAMA;IACF,YACqBC,UAA2C,EAC3CC,WAA0C,CAC7D;aAFmBD,UAAU,GAAVA;aACAC,WAAW,GAAXA;IAClB;IAEH,MAAa,QAAQC,EAAU,EAAwD;QAEnF,IAAI,CAAE,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,IACrC,OAAOC,OAAO,IAAI,CACd,IAAIC,mBAAmB;YAAE,SAAS;QAAgC;QAI1E,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAACH;QACzC,IAAIG,OAAO,MAAM,IACb,OAAOF,OAAO,IAAI,CAACE,OAAO,KAAK;QAGnC,MAAMC,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAACD,OAAO,KAAK,CAAC,MAAM;QACtE,IAAI,CAACC,WACD,OAAOH,OAAO,IAAI,CACd,IAAIC,mBAAmB;YAAE,SAAS;QAAgC;QAI1E,OAAOD,OAAO,EAAE,CAACE,OAAO,KAAK;IACjC;AACJ;AAEO,MAAME,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBT;IAChB,cAAc;QAACU;QAAuBC;KAAoB;AAC9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-audit-logs",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.14",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "./index.js",
|
|
6
6
|
"./*": "./*"
|
|
@@ -22,32 +22,32 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@webiny/api-core-testing": "6.6.0-alpha.
|
|
26
|
-
"@webiny/api-headless-cms-testing": "6.6.0-alpha.
|
|
27
|
-
"@webiny/
|
|
25
|
+
"@webiny/api-core-testing": "6.6.0-alpha.14",
|
|
26
|
+
"@webiny/api-headless-cms-testing": "6.6.0-alpha.14",
|
|
27
|
+
"@webiny/api-kernel-core": "6.6.0-alpha.14",
|
|
28
|
+
"@webiny/db-dynamodb": "6.6.0-alpha.14",
|
|
28
29
|
"@webiny/di": "2.0.0",
|
|
29
|
-
"@webiny/
|
|
30
|
-
"@webiny/
|
|
31
|
-
"
|
|
32
|
-
"graphql": "16.14.2",
|
|
30
|
+
"@webiny/handler": "6.6.0-alpha.14",
|
|
31
|
+
"@webiny/plugins": "6.6.0-alpha.14",
|
|
32
|
+
"graphql": "16.15.0",
|
|
33
33
|
"typescript": "7.0.2",
|
|
34
|
-
"vitest": "5.
|
|
34
|
+
"vitest": "5.1.1"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@webiny/api": "6.6.0-alpha.
|
|
38
|
-
"@webiny/api-aco": "6.6.0-alpha.
|
|
39
|
-
"@webiny/api-core": "6.6.0-alpha.
|
|
40
|
-
"@webiny/api-file-manager": "6.6.0-alpha.
|
|
41
|
-
"@webiny/api-graphql": "6.6.0-alpha.
|
|
42
|
-
"@webiny/api-headless-cms": "6.6.0-alpha.
|
|
43
|
-
"@webiny/api-mailer": "6.6.0-alpha.
|
|
44
|
-
"@webiny/api-website-builder": "6.6.0-alpha.
|
|
45
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
46
|
-
"@webiny/common-audit-logs": "6.6.0-alpha.
|
|
47
|
-
"@webiny/error": "6.6.0-alpha.
|
|
48
|
-
"@webiny/feature": "6.6.0-alpha.
|
|
49
|
-
"@webiny/utils": "6.6.0-alpha.
|
|
50
|
-
"@webiny/wcp": "6.6.0-alpha.
|
|
37
|
+
"@webiny/api": "6.6.0-alpha.14",
|
|
38
|
+
"@webiny/api-aco": "6.6.0-alpha.14",
|
|
39
|
+
"@webiny/api-core": "6.6.0-alpha.14",
|
|
40
|
+
"@webiny/api-file-manager": "6.6.0-alpha.14",
|
|
41
|
+
"@webiny/api-graphql": "6.6.0-alpha.14",
|
|
42
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.14",
|
|
43
|
+
"@webiny/api-mailer": "6.6.0-alpha.14",
|
|
44
|
+
"@webiny/api-website-builder": "6.6.0-alpha.14",
|
|
45
|
+
"@webiny/build-tools": "6.6.0-alpha.14",
|
|
46
|
+
"@webiny/common-audit-logs": "6.6.0-alpha.14",
|
|
47
|
+
"@webiny/error": "6.6.0-alpha.14",
|
|
48
|
+
"@webiny/feature": "6.6.0-alpha.14",
|
|
49
|
+
"@webiny/utils": "6.6.0-alpha.14",
|
|
50
|
+
"@webiny/wcp": "6.6.0-alpha.14",
|
|
51
51
|
"zod": "4.6.7"
|
|
52
52
|
},
|
|
53
53
|
"webiny": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MailerSettingsAfterSaveEventHandler } from "@webiny/api-mailer
|
|
1
|
+
import { MailerSettingsAfterSaveEventHandler } from "@webiny/api-mailer";
|
|
2
2
|
import { RecordAuditLogUseCase } from "../../../features/RecordAuditLog/abstractions.js";
|
|
3
3
|
declare class AuditLogMailerSettingsAfterSaveHandlerImpl implements MailerSettingsAfterSaveEventHandler.Interface {
|
|
4
4
|
private recordAuditLog;
|
|
@@ -6,6 +6,6 @@ declare class AuditLogMailerSettingsAfterSaveHandlerImpl implements MailerSettin
|
|
|
6
6
|
handle(event: MailerSettingsAfterSaveEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const AuditLogMailerSettingsAfterSaveHandler: typeof AuditLogMailerSettingsAfterSaveHandlerImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-core/features/eventPublisher").DomainEvent<import("@webiny/api-mailer
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-core/features/eventPublisher").DomainEvent<import("@webiny/api-mailer").MailerSettingsAfterSavePayload>>>;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _webiny_error from "@webiny/error";
|
|
2
|
-
import { MailerSettingsAfterSaveEventHandler } from "@webiny/api-mailer
|
|
2
|
+
import { MailerSettingsAfterSaveEventHandler } from "@webiny/api-mailer";
|
|
3
3
|
import { RecordAuditLogUseCase } from "../../../features/RecordAuditLog/abstractions.js";
|
|
4
4
|
import { AUDIT } from "../../../config.js";
|
|
5
5
|
class AuditLogMailerSettingsAfterSaveHandlerImpl {
|
|
@@ -8,14 +8,17 @@ class AuditLogMailerSettingsAfterSaveHandlerImpl {
|
|
|
8
8
|
}
|
|
9
9
|
async handle(event) {
|
|
10
10
|
try {
|
|
11
|
-
const { settings } = event.payload;
|
|
11
|
+
const { transport, settings } = event.payload;
|
|
12
12
|
const recordResult = await this.recordAuditLog.execute({
|
|
13
13
|
audit: AUDIT.MAILER.SETTINGS.UPDATE,
|
|
14
14
|
message: "Settings updated",
|
|
15
15
|
content: {
|
|
16
|
-
after:
|
|
16
|
+
after: {
|
|
17
|
+
transport,
|
|
18
|
+
...settings
|
|
19
|
+
}
|
|
17
20
|
},
|
|
18
|
-
entityId:
|
|
21
|
+
entityId: transport
|
|
19
22
|
});
|
|
20
23
|
if (recordResult.isFail()) throw recordResult.error;
|
|
21
24
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js","sources":["../../../../src/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { MailerSettingsAfterSaveEventHandler } from \"@webiny/api-mailer
|
|
1
|
+
{"version":3,"file":"subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js","sources":["../../../../src/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { MailerSettingsAfterSaveEventHandler } from \"@webiny/api-mailer\";\nimport { RecordAuditLogUseCase } from \"~/features/RecordAuditLog/abstractions.js\";\nimport { AUDIT } from \"~/config.js\";\n\nclass AuditLogMailerSettingsAfterSaveHandlerImpl\n implements MailerSettingsAfterSaveEventHandler.Interface\n{\n constructor(private recordAuditLog: RecordAuditLogUseCase.Interface) {}\n\n async handle(event: MailerSettingsAfterSaveEventHandler.Event): Promise<void> {\n try {\n // Any transport with stored settings publishes this event; secrets are already left out.\n const { transport, settings } = event.payload;\n\n const recordResult = await this.recordAuditLog.execute({\n audit: AUDIT.MAILER.SETTINGS.UPDATE,\n message: \"Settings updated\",\n content: { after: { transport, ...settings } },\n entityId: transport\n });\n if (recordResult.isFail()) {\n throw recordResult.error;\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing AuditLogMailerSettingsAfterSaveHandler\",\n code: \"AUDIT_LOGS_AFTER_MAILER_SETTINGS_SAVE_HANDLER\"\n });\n }\n }\n}\n\nexport const AuditLogMailerSettingsAfterSaveHandler =\n MailerSettingsAfterSaveEventHandler.createImplementation({\n implementation: AuditLogMailerSettingsAfterSaveHandlerImpl,\n dependencies: [RecordAuditLogUseCase]\n });\n"],"names":["AuditLogMailerSettingsAfterSaveHandlerImpl","recordAuditLog","event","transport","settings","recordResult","AUDIT","error","WebinyError","AuditLogMailerSettingsAfterSaveHandler","MailerSettingsAfterSaveEventHandler","RecordAuditLogUseCase"],"mappings":";;;;AAKA,MAAMA;IAGF,YAAoBC,cAA+C,CAAE;aAAjDA,cAAc,GAAdA;IAAkD;IAEtE,MAAM,OAAOC,KAAgD,EAAiB;QAC1E,IAAI;YAEA,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGF,MAAM,OAAO;YAE7C,MAAMG,eAAe,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBACnD,OAAOC,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM;gBACnC,SAAS;gBACT,SAAS;oBAAE,OAAO;wBAAEH;wBAAW,GAAGC,QAAQ;oBAAC;gBAAE;gBAC7C,UAAUD;YACd;YACA,IAAIE,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAEhC,EAAE,OAAOE,OAAO;YACZ,MAAMC,cAAAA,IAAgB,CAACD,OAAO;gBAC1B,SAAS;gBACT,MAAM;YACV;QACJ;IACJ;AACJ;AAEO,MAAME,yCACTC,oCAAoC,oBAAoB,CAAC;IACrD,gBAAgBV;IAChB,cAAc;QAACW;KAAsB;AACzC"}
|
package/utils/expiresAt.js
CHANGED
package/utils/expiresAt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/expiresAt.js","sources":["../../src/utils/expiresAt.ts"],"sourcesContent":["export const convertExpiresAtDaysToDate = (days: number): Date => {\n const date = new Date();\n date.setTime(days * 24 * 60 * 60 * 1000 + date.getTime());\n return date;\n};\n\nexport const convertExpiresAtToUnixTimestamp = (expiresAt: Date | string): number => {\n if (typeof expiresAt === \"string\") {\n expiresAt = new Date(expiresAt);\n }\n return Math.floor(expiresAt.getTime() / 1000);\n};\n\nexport const convertUnixTimestampToDate = (\n expiresAt: number | undefined | null\n): Date | undefined => {\n if (!expiresAt) {\n return undefined;\n }\n return new Date(expiresAt * 1000);\n};\n\nexport const convertUnixTimestampToISODateString = (\n expiresAt: number | undefined | null\n): string | undefined => {\n if (!expiresAt) {\n return undefined;\n }\n return convertUnixTimestampToDate(expiresAt)?.toISOString();\n};\n"],"names":["convertExpiresAtDaysToDate","days","date","Date","convertExpiresAtToUnixTimestamp","expiresAt","Math","convertUnixTimestampToDate","convertUnixTimestampToISODateString"],"mappings":"AAAO,MAAMA,6BAA6B,CAACC;IACvC,MAAMC,OAAO,IAAIC;IACjBD,KAAK,OAAO,CAACD,AAAO,KAAPA,
|
|
1
|
+
{"version":3,"file":"utils/expiresAt.js","sources":["../../src/utils/expiresAt.ts"],"sourcesContent":["export const convertExpiresAtDaysToDate = (days: number): Date => {\n const date = new Date();\n date.setTime(days * 24 * 60 * 60 * 1000 + date.getTime());\n return date;\n};\n\nexport const convertExpiresAtToUnixTimestamp = (expiresAt: Date | string): number => {\n if (typeof expiresAt === \"string\") {\n expiresAt = new Date(expiresAt);\n }\n return Math.floor(expiresAt.getTime() / 1000);\n};\n\nexport const convertUnixTimestampToDate = (\n expiresAt: number | undefined | null\n): Date | undefined => {\n if (!expiresAt) {\n return undefined;\n }\n return new Date(expiresAt * 1000);\n};\n\nexport const convertUnixTimestampToISODateString = (\n expiresAt: number | undefined | null\n): string | undefined => {\n if (!expiresAt) {\n return undefined;\n }\n return convertUnixTimestampToDate(expiresAt)?.toISOString();\n};\n"],"names":["convertExpiresAtDaysToDate","days","date","Date","convertExpiresAtToUnixTimestamp","expiresAt","Math","convertUnixTimestampToDate","convertUnixTimestampToISODateString"],"mappings":"AAAO,MAAMA,6BAA6B,CAACC;IACvC,MAAMC,OAAO,IAAIC;IACjBD,KAAK,OAAO,CAACD,AAAO,KAAPA,OAAY,KAAK,KAAK,OAAOC,KAAK,OAAO;IACtD,OAAOA;AACX;AAEO,MAAME,kCAAkC,CAACC;IAC5C,IAAI,AAAqB,YAArB,OAAOA,WACPA,YAAY,IAAIF,KAAKE;IAEzB,OAAOC,KAAK,KAAK,CAACD,UAAU,OAAO,KAAK;AAC5C;AAEO,MAAME,6BAA6B,CACtCF;IAEA,IAAI,CAACA,WACD;IAEJ,OAAO,IAAIF,KAAKE,AAAY,OAAZA;AACpB;AAEO,MAAMG,sCAAsC,CAC/CH;IAEA,IAAI,CAACA,WACD;IAEJ,OAAOE,2BAA2BF,YAAY;AAClD"}
|