Skip to content

Commit 4d6edcf

Browse files
feat(activityLog): update the authentication of ActivityLog to be EnrolledDevice
- Update typing to use the EnrolledDevice auth - Update the handler to fetch enrolledDeviceCredentials
1 parent 2ae90f1 commit 4d6edcf

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/command-handlers/teamLogs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { getAuditLogs } from '../endpoints/index.js';
2-
import { getTeamDeviceCredentials, jsonToCsv, epochTimestampToIso } from '../utils/index.js';
2+
import { jsonToCsv, epochTimestampToIso, getEnrolledTeamDeviceCredentials } from '../utils/index.js';
33
import { logger } from '../logger.js';
44

55
export const runTeamLogs = async (options: { start: string; end: string; csv: boolean; humanReadable: boolean }) => {
6-
const teamDeviceCredentials = getTeamDeviceCredentials();
6+
const enrolledTeamDeviceCredentials = getEnrolledTeamDeviceCredentials();
77
const { start, end } = options;
88

99
let logs = await getAuditLogs({
10-
teamDeviceCredentials,
10+
enrolledTeamDeviceCredentials,
1111
queryParams: {
1212
startDateRangeUnixMs: parseInt(start),
1313
endDateRangeUnixMs: parseInt(end),

src/endpoints/getAuditLogs.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { apiConnect } from '../modules/tunnel-api-connect/apiconnect.js';
22
import { logger } from '../logger.js';
3-
import { TeamDeviceCredentials } from '../types.js';
3+
import { EnrolledTeamDeviceCredentials } from '../types.js';
44
import { GenericLog } from '../types/logs.js';
55

66
export interface StartAuditLogsQueryParams {
@@ -22,7 +22,7 @@ export interface StartAuditLogsQueryOutput {
2222
}
2323

2424
export interface StartAuditLogsQueryRequest {
25-
path: 'logs-teamdevice/StartAuditLogsQuery';
25+
path: 'cli/StartAuditLogsQuery';
2626
input: StartAuditLogsQueryParams;
2727
output: StartAuditLogsQueryOutput;
2828
}
@@ -58,31 +58,29 @@ export interface GetAuditLogQueryResultsOutput {
5858
}
5959

6060
export interface GetAuditLogQueryResultsRequest {
61-
path: 'logs-teamdevice/GetAuditLogQueryResults';
61+
path: 'cli/GetAuditLogQueryResults';
6262
input: GetAuditLogQueryResultsParams;
6363
output: GetAuditLogQueryResultsOutput;
6464
}
65-
6665
const MAX_RESULT = 1000;
6766

6867
export const getAuditLogs = async (params: {
6968
queryParams: StartAuditLogsQueryParams;
70-
teamDeviceCredentials: TeamDeviceCredentials;
69+
enrolledTeamDeviceCredentials: EnrolledTeamDeviceCredentials;
7170
}): Promise<GenericLog[]> => {
72-
const { teamDeviceCredentials, queryParams } = params;
71+
const { enrolledTeamDeviceCredentials, queryParams } = params;
7372

7473
const api = await apiConnect({
7574
useProductionCertificate: true,
7675
});
7776

7877
const { queryExecutionId } = await api.sendSecureContent<StartAuditLogsQueryRequest>({
7978
...api,
80-
path: 'logs-teamdevice/StartAuditLogsQuery',
79+
path: 'cli/StartAuditLogsQuery',
8180
payload: queryParams,
8281
authentication: {
83-
type: 'teamDevice',
84-
teamDeviceKeys: teamDeviceCredentials,
85-
teamUuid: teamDeviceCredentials.uuid,
82+
type: 'enrolledDevice',
83+
enrolledTeamDeviceKeys: enrolledTeamDeviceCredentials,
8684
},
8785
});
8886

@@ -93,12 +91,11 @@ export const getAuditLogs = async (params: {
9391
await new Promise((resolve) => setTimeout(resolve, 2000));
9492
result = await api.sendSecureContent<GetAuditLogQueryResultsRequest>({
9593
...api,
96-
path: 'logs-teamdevice/GetAuditLogQueryResults',
94+
path: 'cli/GetAuditLogQueryResults',
9795
payload: { queryExecutionId, maxResults: MAX_RESULT, nextToken: result?.nextToken },
9896
authentication: {
99-
type: 'teamDevice',
100-
teamDeviceKeys: teamDeviceCredentials,
101-
teamUuid: teamDeviceCredentials.uuid,
97+
type: 'enrolledDevice',
98+
enrolledTeamDeviceKeys: enrolledTeamDeviceCredentials,
10299
},
103100
});
104101
logger.debug(`Query state: ${result.state}`);

0 commit comments

Comments
 (0)