File tree Expand file tree Collapse file tree
KeeperSdk/src/nestedShareFolders Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -876,10 +876,16 @@ export async function fetchLiveRecordAccessEntries(
876876 } [ ]
877877> {
878878 try {
879- const [ response , shareUsers ] = await Promise . all ( [
880- auth . executeRest ( getRecordAccessMessage ( { recordUids : [ normal64Bytes ( recordUid ) ] } ) ) ,
881- loadShareUserMap ( auth , storage ) ,
882- ] )
879+ let response : record . v3 . details . IRecordAccessResponse
880+ try {
881+ response = await auth . executeRest ( getRecordAccessMessage ( { recordUids : [ normal64Bytes ( recordUid ) ] } ) )
882+ } catch ( restErr ) {
883+ if ( restErr instanceof Error && restErr . message . includes ( 'decrypt' ) ) {
884+ return [ ]
885+ }
886+ throw restErr
887+ }
888+ const shareUsers = await loadShareUserMap ( auth , storage )
883889
884890 return ( response . recordAccesses ?? [ ] )
885891 . filter ( ( entry ) => {
Original file line number Diff line number Diff line change 7878 "pam:config:new" : " ts-node src/pam/config/create_config.ts" ,
7979 "pam:config:edit" : " ts-node src/pam/config/edit_config.ts" ,
8080 "pam:config:remove" : " ts-node src/pam/config/remove_config.ts" ,
81+ "pam:rotation:list" : " ts-node src/pam/rotation/list_rotations.ts" ,
82+ "pam:rotation:info" : " ts-node src/pam/rotation/rotation_info.ts" ,
83+ "pam:rotation:edit" : " ts-node src/pam/rotation/edit_rotation.ts" ,
84+ "pam:rotation:delete" : " ts-node src/pam/rotation/delete_rotation.ts" ,
85+ "pam:rotation:list-script" : " ts-node src/pam/rotation/list_scripts.ts" ,
86+ "pam:rotation:add-script" : " ts-node src/pam/rotation/add_script.ts" ,
87+ "pam:rotation:edit-script" : " ts-node src/pam/rotation/edit_script.ts" ,
88+ "pam:rotation:delete-script" : " ts-node src/pam/rotation/delete_script.ts" ,
8189 "link-local" : " cd ../../KeeperSdk && npm link ../keeperapi && cd ../examples/sdk_example && npm link ../../keeperapi" ,
8290 "types" : " tsc --watch" ,
8391 "types:ci" : " tsc"
Original file line number Diff line number Diff line change 1+ import {
2+ cleanup ,
3+ extractErrorMessage ,
4+ login ,
5+ logger ,
6+ prompt ,
7+ } from '@keeper-security/keeper-sdk-javascript'
8+ import { runExample } from '../../utils/runner'
9+
10+ async function addRotationScriptExample ( ) {
11+ const vault = await login ( )
12+
13+ try {
14+ const record = ( await prompt ( 'Target PAM record UID or name: ' ) ) . trim ( )
15+ if ( ! record ) {
16+ logger . error ( 'Record is required.' )
17+ return
18+ }
19+
20+ const scriptPath = ( await prompt ( 'Script file path: ' ) ) . trim ( )
21+ if ( ! scriptPath ) {
22+ logger . error ( 'Script path is required.' )
23+ return
24+ }
25+
26+ const scriptCommand = ( await prompt ( 'Script command (optional): ' ) ) . trim ( ) || undefined
27+
28+ const credentialStr = ( await prompt ( 'Credential UIDs (comma-separated, optional): ' ) ) . trim ( )
29+ const credentialUids = credentialStr
30+ ? credentialStr . split ( ',' ) . map ( ( s ) => s . trim ( ) )
31+ : undefined
32+
33+ logger . info ( '\nAdding rotation script...\n' )
34+
35+ const result = await vault . addRotationScript ( {
36+ record,
37+ scriptPath,
38+ scriptCommand,
39+ credentialUids,
40+ } )
41+
42+ if ( ! result . success ) {
43+ logger . error ( `Error: ${ result . message } ` )
44+ process . exitCode = 1
45+ return
46+ }
47+
48+ logger . info ( `✓ ${ result . message } ` )
49+ logger . info ( `Script File UID: ${ result . scriptFileUid } ` )
50+
51+ if ( result . warnings . length > 0 ) {
52+ logger . warn ( '\nWarnings:' )
53+ result . warnings . forEach ( ( w ) => logger . warn ( ` - ${ w } ` ) )
54+ }
55+
56+ logger . info ( '' )
57+ } catch ( err ) {
58+ logger . error ( `Operation failed: ${ extractErrorMessage ( err ) } ` )
59+ process . exitCode = 1
60+ } finally {
61+ cleanup ( vault )
62+ }
63+ }
64+
65+ runExample ( addRotationScriptExample )
Original file line number Diff line number Diff line change 1+ import {
2+ cleanup ,
3+ extractErrorMessage ,
4+ login ,
5+ logger ,
6+ prompt ,
7+ } from '@keeper-security/keeper-sdk-javascript'
8+ import { isYes } from '../../utils/promptCommands'
9+ import { runExample } from '../../utils/runner'
10+
11+ async function deleteRotationScriptExample ( ) {
12+ const vault = await login ( )
13+
14+ try {
15+ const record = ( await prompt ( 'Target PAM record UID or name: ' ) ) . trim ( )
16+ if ( ! record ) {
17+ logger . error ( 'Record is required.' )
18+ return
19+ }
20+
21+ const script = ( await prompt ( 'Script UID or name (optional - leaves empty to delete first script): ' ) ) . trim ( )
22+
23+ const confirm = await prompt ( 'Are you sure you want to delete this script? (yes/no): ' )
24+ if ( ! isYes ( confirm ) ) {
25+ logger . info ( 'Operation cancelled.' )
26+ return
27+ }
28+
29+ logger . info ( '\nDeleting rotation script...\n' )
30+
31+ const result = await vault . deleteRotationScript ( {
32+ record,
33+ script,
34+ } )
35+
36+ if ( ! result . success ) {
37+ logger . error ( `Error: ${ result . message } ` )
38+ process . exitCode = 1
39+ return
40+ }
41+
42+ logger . info ( `✓ ${ result . message } ` )
43+
44+ if ( result . warnings . length > 0 ) {
45+ logger . warn ( '\nWarnings:' )
46+ result . warnings . forEach ( ( w ) => logger . warn ( ` - ${ w } ` ) )
47+ }
48+
49+ logger . info ( '' )
50+ } catch ( err ) {
51+ logger . error ( `Operation failed: ${ extractErrorMessage ( err ) } ` )
52+ process . exitCode = 1
53+ } finally {
54+ cleanup ( vault )
55+ }
56+ }
57+
58+ runExample ( deleteRotationScriptExample )
You can’t perform that action at this time.
0 commit comments