Skip to content

Commit 165d85b

Browse files
authored
Implement PAM gateway commands (#242)
1 parent 7af6317 commit 165d85b

19 files changed

Lines changed: 2066 additions & 13 deletions

KeeperSdk/package-lock.json

Lines changed: 110 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

KeeperSdk/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"prepublishOnly": "npm run build"
2525
},
2626
"dependencies": {
27-
"@keeper-security/keeperapi": "18.1.0",
27+
"@keeper-security/keeperapi": "18.1.1",
28+
"@keeper-security/secrets-manager-core": "^17.5.0",
2829
"asmcrypto.js": "^2.3.2",
2930
"ts-node": "^10.7.0",
3031
"typescript": "^4.6.3"

KeeperSdk/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export {
277277
UserActionStatus,
278278
UserActionSkipReason,
279279
} from './users/actionUser'
280-
280+
export { AliasOperation } from './users/aliasUser'
281281
export {
282282
formatAddTeamResult,
283283
renderAddTeamAsciiTable,

KeeperSdk/src/index.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export {
5656
AuditReportErrorCode,
5757
ActionReportErrorCode,
5858
PasswordReportErrorCode,
59+
PamErrorCode,
5960
KEEPER_PUBLIC_HOSTS,
6061
isBoolean,
6162
isString,
@@ -852,6 +853,78 @@ export type {
852853
NsfResolvedShareRecipient,
853854
} from './nestedShareFolders'
854855

856+
export {
857+
PamManager,
858+
GatewayManager,
859+
listGateways,
860+
formatGatewaysTable,
861+
renderGatewaysAsciiTable,
862+
formatGatewaysJson,
863+
formatGatewaysOutput,
864+
createGateway,
865+
editGateway,
866+
removeGateway,
867+
setGatewayMaxInstances,
868+
GatewayListFormat,
869+
GatewayStatus,
870+
GatewayConfigInitFormat,
871+
KSM_APP_RECORD_VERSION,
872+
SUPPORTED_KSM_APP_RECORD_VERSIONS,
873+
APP_NOT_ACCESSIBLE_LABEL,
874+
KSM_CLIENT_ID_MESSAGE,
875+
DEFAULT_GATEWAY_TOKEN_EXPIRES_IN_MIN,
876+
MAX_GATEWAY_TOKEN_EXPIRES_IN_MIN,
877+
MIN_GATEWAY_MAX_INSTANCES,
878+
MAX_GATEWAY_MAX_INSTANCES,
879+
EMPTY_GATEWAYS_MESSAGE,
880+
GATEWAY_LIST_DEFAULT_HEADERS,
881+
GATEWAY_LIST_VERBOSE_HEADERS,
882+
getKeeperRouterBaseUrl,
883+
webSafeUidFromBytes,
884+
controllerUidsEqual,
885+
toFiniteNumber,
886+
formatTimestampMs,
887+
parseGatewayVersionString,
888+
getKsmApplicationDisplayInfo,
889+
resolveKsmApplication,
890+
getKeeperRegionAbbreviation,
891+
formatGatewayOneTimeToken,
892+
findEnterpriseGatewayByUidOrName,
893+
requireEnterpriseGatewayByUidOrName,
894+
fetchEnterprisePamControllers,
895+
groupOnlineGatewaysByControllerUid,
896+
isKeeperRouterConnectionError,
897+
} from './pam'
898+
export type {
899+
ListGatewaysOptions,
900+
GatewayCounts,
901+
GatewayOsMetadata,
902+
GatewayVersionParts,
903+
GatewayPoolInstance,
904+
GatewayListRow,
905+
GatewayConnectivityStatus,
906+
ListGatewaysResult,
907+
FormattedGatewaysTable,
908+
FormatGatewaysTableOptions,
909+
RenderGatewaysAsciiTableOptions,
910+
GatewayListFormatInput,
911+
GatewayConfigInitFormatInput,
912+
KsmApplicationDisplayInfo,
913+
ResolvedKsmApplication,
914+
CreateGatewayInput,
915+
CreateGatewayResult,
916+
EditGatewayInput,
917+
EditGatewayResult,
918+
RemoveGatewayInput,
919+
RemoveGatewayResult,
920+
SetGatewayMaxInstancesInput,
921+
SetGatewayMaxInstancesResult,
922+
GatewayJsonPoolInstance,
923+
GatewayJsonEntry,
924+
GatewaysJsonPayload,
925+
KsmAppRecordVersion,
926+
} from './pam'
927+
855928
export type {
856929
DRecord,
857930
DRecordMetadata,

KeeperSdk/src/pam/PamManager.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import type { Auth } from '@keeper-security/keeperapi'
2+
import type { InMemoryStorage } from '../storage/InMemoryStorage'
3+
import { GatewayManager } from './gateway/GatewayManager'
4+
import type {
5+
CreateGatewayInput,
6+
CreateGatewayResult,
7+
EditGatewayInput,
8+
EditGatewayResult,
9+
FormatGatewaysTableOptions,
10+
FormattedGatewaysTable,
11+
ListGatewaysOptions,
12+
ListGatewaysResult,
13+
RemoveGatewayInput,
14+
RemoveGatewayResult,
15+
RenderGatewaysAsciiTableOptions,
16+
SetGatewayMaxInstancesInput,
17+
SetGatewayMaxInstancesResult,
18+
} from './gateway/gatewayTypes'
19+
20+
export type AuthProvider = () => Auth
21+
22+
export class PamManager {
23+
private readonly gatewayManager: GatewayManager
24+
25+
constructor(storage: InMemoryStorage, authProvider: AuthProvider) {
26+
this.gatewayManager = new GatewayManager(storage, authProvider)
27+
}
28+
29+
public getGatewayManager(): GatewayManager {
30+
return this.gatewayManager
31+
}
32+
33+
public async listGateways(options: ListGatewaysOptions = {}): Promise<ListGatewaysResult> {
34+
return this.gatewayManager.listGateways(options)
35+
}
36+
37+
public async createGateway(input: CreateGatewayInput): Promise<CreateGatewayResult> {
38+
return this.gatewayManager.createGateway(input)
39+
}
40+
41+
public async editGateway(input: EditGatewayInput): Promise<EditGatewayResult> {
42+
return this.gatewayManager.editGateway(input)
43+
}
44+
45+
public async removeGateway(input: RemoveGatewayInput): Promise<RemoveGatewayResult> {
46+
return this.gatewayManager.removeGateway(input)
47+
}
48+
49+
public async setGatewayMaxInstances(input: SetGatewayMaxInstancesInput): Promise<SetGatewayMaxInstancesResult> {
50+
return this.gatewayManager.setGatewayMaxInstances(input)
51+
}
52+
53+
public formatGatewaysTable(
54+
result: ListGatewaysResult,
55+
options: FormatGatewaysTableOptions = {}
56+
): FormattedGatewaysTable {
57+
return this.gatewayManager.formatGatewaysTable(result, options)
58+
}
59+
60+
public renderGatewaysAsciiTable(
61+
table: FormattedGatewaysTable,
62+
options: RenderGatewaysAsciiTableOptions = {}
63+
): string {
64+
return this.gatewayManager.renderGatewaysAsciiTable(table, options)
65+
}
66+
67+
public formatGatewaysJson(result: ListGatewaysResult, options: ListGatewaysOptions = {}): string {
68+
return this.gatewayManager.formatGatewaysJson(result, options)
69+
}
70+
71+
public formatGatewaysOutput(result: ListGatewaysResult, options: ListGatewaysOptions = {}): string {
72+
return this.gatewayManager.formatGatewaysOutput(result, options)
73+
}
74+
}

0 commit comments

Comments
 (0)