Skip to content

NSF command implementation (list, get, ln and rm)#169

Merged
ukumar-ks merged 9 commits into
feature-kd-part1from
feature-kd-p1-dev
Jun 16, 2026
Merged

NSF command implementation (list, get, ln and rm)#169
ukumar-ks merged 9 commits into
feature-kd-part1from
feature-kd-p1-dev

Conversation

@ukumar-ks

Copy link
Copy Markdown
Contributor

No description provided.

@socket-security

socket-security Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​keeper-security/​keeperapi@​17.2.3 ⏵ 17.2.775 +110081 +198 +1100

View full report

@ukumar-ks ukumar-ks marked this pull request as ready for review June 12, 2026 11:03
@ukumar-ks ukumar-ks requested review from sali-ks and sgaddala-ks and removed request for THeflinKeeper, saldoukhov and tylerccarson June 12, 2026 11:03
@ukumar-ks ukumar-ks changed the title Feature kd p1 dev NSF command implementation (list, get, ln and rm) Jun 12, 2026
Comment thread KeeperSdk/package.json Outdated
},
"dependencies": {
"@keeper-security/keeperapi": "17.2.6",
"protobufjs": "^7.6.1",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not needed as we are getting proto from keeperapi project

Comment on lines +181 to +191
return {
userPermissions: entries
.filter(isFolderUserPermission)
.map((entry) => buildFolderAccessRow(storage, folder, entry)),
shareAdmins: entries
.filter(isFolderShareAdministrator)
.map((entry) => buildFolderAccessRow(storage, folder, entry)),
teamPermissions: entries
.filter((entry) => entry.accessType === Folder.AccessType.AT_TEAM)
.map(mapFolderPermission),
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return {
userPermissions: entries
.filter(isFolderUserPermission)
.map((entry) => buildFolderAccessRow(storage, folder, entry)),
shareAdmins: entries
.filter(isFolderShareAdministrator)
.map((entry) => buildFolderAccessRow(storage, folder, entry)),
teamPermissions: entries
.filter((entry) => entry.accessType === Folder.AccessType.AT_TEAM)
.map(mapFolderPermission),
}
const userPermissions: NsfFolderAccessRow[] = [];
const shareAdmins: NsfFolderAccessRow[] = [];
const teamPermissions: NsfFolderPermission[] = [];
for (const entry of entries) {
if (isFolderUserPermission(entry)) {
userPermissions.push(buildFolderAccessRow(storage, folder, entry));
}
if (isFolderShareAdministrator(entry)) {
shareAdmins.push(buildFolderAccessRow(storage, folder, entry));
}
if (entry.accessType === Folder.AccessType.AT_TEAM) {
teamPermissions.push(mapFolderPermission(entry));
}
}
return { userPermissions, shareAdmins, teamPermissions };

There is no necessity for multiple loops -> 3x iterations to 1x

Comment on lines +212 to +220
function buildRecordFields(record: DRecord, unmask: boolean): NsfRecordView['fields'] {
return getRecordFields(record).flatMap((field) => {
if (NSF_TOP_LEVEL_FIELD_TYPES.has(field.type)) return []
const rawValue = Array.isArray(field.value) ? field.value[0] : field.value
if (rawValue == null || rawValue === '') return []
const value = !unmask && isSensitiveFieldType(field.type) ? NSF_MASKED_VALUE : String(rawValue)
return [{ type: field.type, label: field.label, value }]
})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function buildRecordFields(record: DRecord, unmask: boolean): NsfRecordView['fields'] {
return getRecordFields(record).flatMap((field) => {
if (NSF_TOP_LEVEL_FIELD_TYPES.has(field.type)) return []
const rawValue = Array.isArray(field.value) ? field.value[0] : field.value
if (rawValue == null || rawValue === '') return []
const value = !unmask && isSensitiveFieldType(field.type) ? NSF_MASKED_VALUE : String(rawValue)
return [{ type: field.type, label: field.label, value }]
})
}
ffunction buildRecordFields(record: DRecord, unmask: boolean): NsfRecordView['fields'] {
return getRecordFields(record)
// Step 1: Remove top-level types up front
.filter(field => !NSF_TOP_LEVEL_FIELD_TYPES.has(field.type))
// Step 2: Map to items with unwrapped/validated values
.map(field => {
const rawValue = Array.isArray(field.value) ? field.value[0] : field.value;
return { field, rawValue };
})
// Step 3: Filter out fields with empty values
.filter(({ rawValue }) => rawValue != null && rawValue !== '')
// Step 4: Construct final object with masked value
.map(({ field, rawValue }) => {
const isSensitive = isSensitiveFieldType(field.type);
const finalValue = !unmask && isSensitive ? NSF_MASKED_VALUE : String(rawValue);
return {
type: field.type,
label: field.label,
value: finalValue
};
});
}

will something like this fit your usecase ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the single flatMap with empty-array returns by an explicit pipeline

Comment on lines +261 to +262
.map((ext) => ext.email || '')
.filter((email) => email.length > 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map((ext) => ext.email || '')
.filter((email) => email.length > 0)
.flatMap((ext) => ext?.email ? [ext.email] : [])

message: string
}

async function resolveRecordKeyType(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be a utility function and to be moved to utils

return response
}

export function removeRecordMessage(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be moved to keeper api

@ukumar-ks ukumar-ks force-pushed the feature-kd-p1-dev branch from dbb5f0d to e3b921e Compare June 15, 2026 13:48
Comment on lines +238 to +239
.map((value) => formatNsfFieldValue(value))
.filter((value) => value.length > 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably these have to be interchanged ? I am unsure here but that reduces complexity maybe.

return lines
}

async function fetchRecordPermissions(auth: Auth, recordUid: string): Promise<NsfRecordPermission[]> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need promise as a return type here ? at end we are just returning a nullable array right ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async / Promise is required, the function calls await auth.executeRest(), so it cannot be synchronous.

ukumar-ks and others added 2 commits June 16, 2026 22:45
…d-p1-dev

Sync feature-kd-part1 updates (rest messages, proto, package) into feature-kd-p1-dev.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ukumar-ks ukumar-ks merged commit a9c6dfb into feature-kd-part1 Jun 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants