Skip to content

Commit abe385d

Browse files
committed
format fix
1 parent 59257f4 commit abe385d

14 files changed

Lines changed: 56 additions & 153 deletions

KeeperSdk/src/pam/PamManager.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ export class PamManager {
164164
return this.configManager.formatPamConfigurationsOutput(result, options)
165165
}
166166

167-
public async listRotationSchedules(options: ListRotationSchedulesOptions = {}): Promise<ListRotationSchedulesResult> {
167+
public async listRotationSchedules(
168+
options: ListRotationSchedulesOptions = {}
169+
): Promise<ListRotationSchedulesResult> {
168170
return this.rotationManager.listRotationSchedules(options)
169171
}
170172

@@ -215,9 +217,7 @@ export class PamManager {
215217
return this.rotationManager.editRotation(input)
216218
}
217219

218-
public async listRotationScripts(
219-
options: ListRotationScriptsOptions = {}
220-
): Promise<ListRotationScriptsResult> {
220+
public async listRotationScripts(options: ListRotationScriptsOptions = {}): Promise<ListRotationScriptsResult> {
221221
return this.rotationManager.listRotationScripts(options)
222222
}
223223

@@ -229,21 +229,15 @@ export class PamManager {
229229
return this.rotationManager.formatRotationScriptsJson(result)
230230
}
231231

232-
public async addRotationScript(
233-
input: AddRotationScriptInput
234-
): Promise<AddRotationScriptResult> {
232+
public async addRotationScript(input: AddRotationScriptInput): Promise<AddRotationScriptResult> {
235233
return this.rotationManager.addRotationScript(input)
236234
}
237235

238-
public async editRotationScript(
239-
input: EditRotationScriptInput
240-
): Promise<EditRotationScriptResult> {
236+
public async editRotationScript(input: EditRotationScriptInput): Promise<EditRotationScriptResult> {
241237
return this.rotationManager.editRotationScript(input)
242238
}
243239

244-
public async deleteRotationScript(
245-
input: DeleteRotationScriptInput
246-
): Promise<DeleteRotationScriptResult> {
240+
public async deleteRotationScript(input: DeleteRotationScriptInput): Promise<DeleteRotationScriptResult> {
247241
return this.rotationManager.deleteRotationScript(input)
248242
}
249243
}

KeeperSdk/src/pam/rotation/RotationManager.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ import {
1010
renderRotationSchedulesAsciiTable,
1111
} from './listRotations'
1212
import { editRotation, validateRotationInput } from './editRotation'
13-
import {
14-
listRotationScripts,
15-
formatRotationScriptsTable,
16-
formatRotationScriptsJson,
17-
} from './listRotationScripts'
13+
import { listRotationScripts, formatRotationScriptsTable, formatRotationScriptsJson } from './listRotationScripts'
1814
import { addRotationScript } from './addRotationScript'
1915
import { editRotationScript } from './editRotationScript'
2016
import { deleteRotationScript } from './deleteRotationScript'
@@ -59,7 +55,9 @@ export class RotationManager {
5955
return auth
6056
}
6157

62-
public async listRotationSchedules(options: ListRotationSchedulesOptions = {}): Promise<ListRotationSchedulesResult> {
58+
public async listRotationSchedules(
59+
options: ListRotationSchedulesOptions = {}
60+
): Promise<ListRotationSchedulesResult> {
6361
return listRotationSchedules(this.requireAuth(), this.storage, options)
6462
}
6563

@@ -119,9 +117,7 @@ export class RotationManager {
119117

120118
/* ========== Rotation Script Operations ========== */
121119

122-
public async listRotationScripts(
123-
options: ListRotationScriptsOptions = {}
124-
): Promise<ListRotationScriptsResult> {
120+
public async listRotationScripts(options: ListRotationScriptsOptions = {}): Promise<ListRotationScriptsResult> {
125121
return listRotationScripts(this.requireAuth(), this.storage, options)
126122
}
127123

@@ -133,21 +129,15 @@ export class RotationManager {
133129
return formatRotationScriptsJson(result)
134130
}
135131

136-
public async addRotationScript(
137-
input: AddRotationScriptInput
138-
): Promise<AddRotationScriptResult> {
132+
public async addRotationScript(input: AddRotationScriptInput): Promise<AddRotationScriptResult> {
139133
return addRotationScript(this.requireAuth(), this.storage, input)
140134
}
141135

142-
public async editRotationScript(
143-
input: EditRotationScriptInput
144-
): Promise<EditRotationScriptResult> {
136+
public async editRotationScript(input: EditRotationScriptInput): Promise<EditRotationScriptResult> {
145137
return editRotationScript(this.requireAuth(), this.storage, input)
146138
}
147139

148-
public async deleteRotationScript(
149-
input: DeleteRotationScriptInput
150-
): Promise<DeleteRotationScriptResult> {
140+
public async deleteRotationScript(input: DeleteRotationScriptInput): Promise<DeleteRotationScriptResult> {
151141
return deleteRotationScript(this.requireAuth(), this.storage, input)
152142
}
153143
}

KeeperSdk/src/pam/rotation/addRotationScript.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ export async function addRotationScript(
2424
try {
2525
const scriptPath = input.scriptPath?.trim()
2626
if (!scriptPath) {
27-
throw new KeeperSdkError(
28-
'Script file path is required',
29-
ResultCodes.INVALID_PATTERN
30-
)
27+
throw new KeeperSdkError('Script file path is required', ResultCodes.INVALID_PATTERN)
3128
}
3229

3330
const expandedPath = validateScriptFileExists(scriptPath)

KeeperSdk/src/pam/rotation/editRotation.ts

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ import {
1010
RotationProfile,
1111
ScheduleData,
1212
} from './rotationTypes'
13-
import {
14-
getVaultRecord,
15-
recordExistsInVault,
16-
getVaultRecordTitleType,
17-
} from './rotationHelpers'
13+
import { getVaultRecord, recordExistsInVault, getVaultRecordTitleType } from './rotationHelpers'
1814
import { RECORD_ROTATION_KIND } from './rotationConstants'
1915

2016
const DEFAULT_PAM_SPECIAL_CHAR = '!@#$%^&*()_+-=[]{}|;:,.<>?'
@@ -54,15 +50,12 @@ export async function editRotation(
5450
const skippedRecords: EditRotationResult['skippedRecords'] = []
5551

5652
try {
57-
const currentRotation = storage.getByUid<DRecordRotation>(
58-
RECORD_ROTATION_KIND,
59-
recordUid
60-
)
53+
const currentRotation = storage.getByUid<DRecordRotation>(RECORD_ROTATION_KIND, recordUid)
6154

6255
if (!currentRotation && !input.configUid && !input.iamAadConfigUid && !input.saasConfigUid) {
6356
throw new KeeperSdkError(
6457
`Record "${recordUid}" does not have rotation configured yet. ` +
65-
`You must provide a PAM Configuration UID (--config) to configure rotation for this record.`,
58+
`You must provide a PAM Configuration UID (--config) to configure rotation for this record.`,
6659
ResultCodes.PAM_ROTATION_RECORD_REQUIRED
6760
)
6861
}
@@ -75,7 +68,7 @@ export async function editRotation(
7568
if (!configUid && !currentRotation) {
7669
throw new KeeperSdkError(
7770
`PAM Configuration UID is required when setting up rotation for the first time. ` +
78-
`Provide it with --config, --iam-aad-config, or --saas-config.`,
71+
`Provide it with --config, --iam-aad-config, or --saas-config.`,
7972
ResultCodes.PAM_ROTATION_RECORD_REQUIRED
8073
)
8174
}
@@ -93,9 +86,10 @@ export async function editRotation(
9386
let scheduleData = validateAndBuildScheduleData(input)
9487
if (!scheduleData && currentRotation?.schedule) {
9588
try {
96-
scheduleData = typeof currentRotation.schedule === 'string'
97-
? JSON.parse(currentRotation.schedule)
98-
: currentRotation.schedule
89+
scheduleData =
90+
typeof currentRotation.schedule === 'string'
91+
? JSON.parse(currentRotation.schedule)
92+
: currentRotation.schedule
9993
} catch (e) {
10094
scheduleData = null
10195
}
@@ -109,9 +103,10 @@ export async function editRotation(
109103
if (currentRotation) {
110104
if (currentRotation.schedule) {
111105
try {
112-
currentSchedule = typeof currentRotation.schedule === 'string'
113-
? currentRotation.schedule
114-
: JSON.stringify(currentRotation.schedule)
106+
currentSchedule =
107+
typeof currentRotation.schedule === 'string'
108+
? currentRotation.schedule
109+
: JSON.stringify(currentRotation.schedule)
115110
} catch (e) {
116111
currentSchedule = ''
117112
}
@@ -151,11 +146,7 @@ export async function editRotation(
151146

152147
let passwordComplexityEncrypted = currentComplexity
153148
if (input.passwordComplexity) {
154-
const encrypted = await encryptPasswordComplexity(
155-
storage,
156-
recordUid,
157-
input.passwordComplexity
158-
)
149+
const encrypted = await encryptPasswordComplexity(storage, recordUid, input.passwordComplexity)
159150
if (encrypted) {
160151
passwordComplexityEncrypted = platform.base64ToBytes(encrypted)
161152
}
@@ -164,9 +155,7 @@ export async function editRotation(
164155
let finalScheduleData = scheduleData
165156
if (!finalScheduleData && currentSchedule) {
166157
try {
167-
finalScheduleData = typeof currentSchedule === 'string'
168-
? JSON.parse(currentSchedule)
169-
: currentSchedule
158+
finalScheduleData = typeof currentSchedule === 'string' ? JSON.parse(currentSchedule) : currentSchedule
170159
} catch (e) {
171160
finalScheduleData = null
172161
}
@@ -295,10 +284,7 @@ async function encryptPasswordComplexity(
295284
}
296285

297286
const plainText = JSON.stringify(complexityData)
298-
const encrypted = await platform.aesGcmEncrypt(
299-
platform.stringToBytes(plainText),
300-
recordKey
301-
)
287+
const encrypted = await platform.aesGcmEncrypt(platform.stringToBytes(plainText), recordKey)
302288
return platform.bytesToBase64(encrypted)
303289
} catch (err) {
304290
throw new KeeperSdkError(

KeeperSdk/src/pam/rotation/editRotationScript.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
} from './rotationScriptHelpers'
1414
import type { PamRecordData } from './rotationScriptTypes'
1515

16-
1716
export async function editRotationScript(
1817
auth: Auth,
1918
storage: InMemoryStorage,
@@ -24,10 +23,7 @@ export async function editRotationScript(
2423
try {
2524
const scriptName = input.script?.trim()
2625
if (!scriptName) {
27-
throw new KeeperSdkError(
28-
'Script UID or name is required',
29-
ResultCodes.INVALID_PATTERN
30-
)
26+
throw new KeeperSdkError('Script UID or name is required', ResultCodes.INVALID_PATTERN)
3127
}
3228

3329
const record = getSinglePamRecord(storage, input.record)

KeeperSdk/src/pam/rotation/getRotationInfo.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import type { Auth } from '@keeper-security/keeperapi'
2-
import {
3-
getRotationInfoMessage,
4-
normal64Bytes,
5-
pamGetRotationSchedulesMessage,
6-
} from '@keeper-security/keeperapi'
2+
import { getRotationInfoMessage, normal64Bytes, pamGetRotationSchedulesMessage } from '@keeper-security/keeperapi'
73
import type { InMemoryStorage } from '../../storage/InMemoryStorage'
84
import { extractErrorMessage, KeeperSdkError, ResultCodes } from '../../utils'
95
import { toFiniteNumber, webSafeUidFromBytes } from '../gateway/gatewayHelpers'
@@ -69,9 +65,7 @@ export async function getRotationInfo(
6965

7066
const pamConfigUid = webSafeUidFromBytes(rotationInfo.configurationUid)
7167
const gatewayUid = webSafeUidFromBytes(rotationInfo.controllerUid) || MISSING_VALUE_LABEL
72-
const adminResourceUid = rotationInfo.resourceUid?.length
73-
? webSafeUidFromBytes(rotationInfo.resourceUid)
74-
: null
68+
const adminResourceUid = rotationInfo.resourceUid?.length ? webSafeUidFromBytes(rotationInfo.resourceUid) : null
7569
const passwordComplexity = rotationInfo.pwdComplexity || null
7670
const passwordComplexityDetail = await decryptPasswordComplexity(storage, recordUid, passwordComplexity)
7771

@@ -141,9 +135,7 @@ export function formatRotationInfoJson(result: RotationInfoResult): string {
141135

142136
function formatPasswordComplexityData(detail: NonNullable<RotationInfoResult['passwordComplexityDetail']>): string {
143137
const symbolsChars =
144-
detail.specialChars != null && String(detail.specialChars).trim() !== ''
145-
? String(detail.specialChars)
146-
: 'None'
138+
detail.specialChars != null && String(detail.specialChars).trim() !== '' ? String(detail.specialChars) : 'None'
147139
return [
148140
`Length: ${detail.length ?? ''}`,
149141
`Lowercase: ${detail.lowercase ?? ''}`,
@@ -175,10 +167,7 @@ function formatRotationInfoDetail(result: RotationInfoResult): string {
175167
if (result.readyToRotate) {
176168
rows.push(['PAM Config UID', result.pamConfigUid || ''])
177169
if (result.nodeId != null) rows.push(['Node ID', String(result.nodeId)])
178-
rows.push([
179-
'Gateway Name where the rotation will be performed',
180-
result.gatewayName || MISSING_VALUE_LABEL,
181-
])
170+
rows.push(['Gateway Name where the rotation will be performed', result.gatewayName || MISSING_VALUE_LABEL])
182171
rows.push(['Gateway Uid', result.gatewayUid || MISSING_VALUE_LABEL])
183172
if (result.adminResourceUid) rows.push(['Admin Resource Uid', result.adminResourceUid])
184173
if (result.passwordComplexity) rows.push(['Password Complexity', result.passwordComplexity])

KeeperSdk/src/pam/rotation/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ export { getRotationInfo, formatRotationInfoJson, formatRotationInfoOutput } fro
1313

1414
export { editRotation, validateRotationInput } from './editRotation'
1515

16-
export {
17-
listRotationScripts,
18-
formatRotationScriptsTable,
19-
formatRotationScriptsJson,
20-
} from './listRotationScripts'
16+
export { listRotationScripts, formatRotationScriptsTable, formatRotationScriptsJson } from './listRotationScripts'
2117

2218
export { addRotationScript } from './addRotationScript'
2319
export { editRotationScript } from './editRotationScript'

KeeperSdk/src/pam/rotation/listRotationScripts.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,7 @@ export function formatRotationScriptsTable(result: ListRotationScriptsResult): s
7979
return []
8080
}
8181

82-
const headers = [
83-
'Record UID',
84-
'Record Title',
85-
'Record Type',
86-
'Script UID',
87-
'Script Name',
88-
'Credentials',
89-
'Command',
90-
]
82+
const headers = ['Record UID', 'Record Title', 'Record Type', 'Script UID', 'Script Name', 'Credentials', 'Command']
9183

9284
const rows = result.scripts.map((script) => [
9385
script.recordUid,

KeeperSdk/src/pam/rotation/listRotations.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import type { Auth } from '@keeper-security/keeperapi'
22
import { pamGetOnlineControllersMessage, pamGetRotationSchedulesMessage } from '@keeper-security/keeperapi'
33
import type { InMemoryStorage } from '../../storage/InMemoryStorage'
44
import { extractErrorMessage, KeeperSdkError, ResultCodes } from '../../utils'
5-
import {
6-
fetchEnterprisePamControllers,
7-
webSafeUidFromBytes,
8-
} from '../gateway/gatewayHelpers'
5+
import { fetchEnterprisePamControllers, webSafeUidFromBytes } from '../gateway/gatewayHelpers'
96
import {
107
EMPTY_ROTATION_SCHEDULES_MESSAGE,
118
PAM_USER_RECORD_TYPE,
@@ -142,7 +139,10 @@ export function renderRotationSchedulesAsciiTable(
142139
})
143140

144141
const formatRow = (cells: string[]): string =>
145-
cells.map((cell, i) => (cell || '').padEnd(widths[i])).join(' ').trimEnd()
142+
cells
143+
.map((cell, i) => (cell || '').padEnd(widths[i]))
144+
.join(' ')
145+
.trimEnd()
146146

147147
return [
148148
formatRow([...table.headers]),
@@ -190,7 +190,5 @@ export function formatRotationSchedulesOutput(
190190

191191
if (result.message && result.rotations.length === 0) return result.message
192192

193-
return renderRotationSchedulesAsciiTable(
194-
formatRotationSchedulesTable(result, { verbose: options.verbose })
195-
)
193+
return renderRotationSchedulesAsciiTable(formatRotationSchedulesTable(result, { verbose: options.verbose }))
196194
}

KeeperSdk/src/pam/rotation/rotationConstants.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ export const RECORD_UNTITLED_LABEL = '[Untitled]' as const
99
export const PAM_USER_RECORD_TYPE = 'pamUser' as const
1010
export const RECORD_ROTATION_KIND = 'non_shared_data' as const
1111
export const EMPTY_ROTATION_SCHEDULES_MESSAGE = 'No rotation schedules found' as const
12-
export const ROTATION_LIST_DEFAULT_HEADERS = [
13-
'Record',
14-
'Status',
15-
'Schedule',
16-
'Last',
17-
] as const
12+
export const ROTATION_LIST_DEFAULT_HEADERS = ['Record', 'Status', 'Schedule', 'Last'] as const
1813
export const ROTATION_LIST_VERBOSE_HEADERS = [
1914
'Record UID',
2015
'Record Title',

0 commit comments

Comments
 (0)