Skip to content

Commit 278e602

Browse files
authored
Add REST message to get online PAM controllers (#119)
1 parent aaaffdd commit 278e602

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

keeperapi/package-lock.json

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

keeperapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@keeper-security/keeperapi",
33
"description": "Keeper API Javascript SDK",
4-
"version": "17.1.0",
4+
"version": "17.1.1",
55
"browser": "dist/index.es.js",
66
"main": "dist/index.cjs.js",
77
"types": "dist/node/index.d.ts",

keeperapi/src/pam.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Auth } from './auth'
22
import { GraphSync } from './proto'
33
import { normal64Bytes, webSafe64FromBytes } from './utils'
4-
import { pamGetLeafsMessage, pamMultiSyncMessage, pamSyncMessage } from './restMessages'
4+
import { pamGetLeafsMessage, pamGetOnlineControllersMessage, pamMultiSyncMessage, pamSyncMessage } from './restMessages'
5+
import { PAM } from './proto'
56

67
/**
78
* Syncs the PAM link DAG for a single record UID.
@@ -102,3 +103,17 @@ export async function getConfigRootsForRecordUids(
102103
const result = await auth.executeRouterRest(pamGetLeafsMessage({ vertices }))
103104
return result.refs ?? []
104105
}
106+
107+
/**
108+
* Returns the UIDs of all PAM controllers that are accessible to the user.
109+
*/
110+
export async function getOnlinePamControllerUids(auth: Auth): Promise<string[]> {
111+
const result = await auth.executeRouterRest(pamGetOnlineControllersMessage())
112+
const controllerUids: string[] = []
113+
for (const c of result.controllers) {
114+
if (c.controllerUid && c.controllerUid.length > 0) {
115+
controllerUids.push(webSafe64FromBytes(c.controllerUid))
116+
}
117+
}
118+
return controllerUids
119+
}

keeperapi/src/restMessages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Automator,
1010
Enterprise,
1111
GraphSync,
12+
PAM,
1213
Records,
1314
ServiceLogger,
1415
SsoCloud,
@@ -866,3 +867,6 @@ export const pamGetLeafsMessage = (
866867
GraphSync.GraphSyncLeafsQuery,
867868
GraphSync.GraphSyncRefsResult
868869
)
870+
871+
export const pamGetOnlineControllersMessage = (): RestMessage<PAM.IPAMOnlineControllers, PAM.PAMOnlineControllers> =>
872+
createMessage({}, 'api/user/get_controllers', PAM.PAMOnlineControllers, PAM.PAMOnlineControllers)

0 commit comments

Comments
 (0)