Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added passkey field type for login record type #24

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/dtos.go
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ func convertToKeeperRecordField(fieldData interface{}, validate bool) (interface
"|birthDate|date|expirationDate|text|securityQuestion|multiline|email|cardRef" +
"|addressRef|pinCode|phone|secret|note|accountNumber|paymentCard|bankAccount" +
"|keyPair|host|address|licenseNumber|recordRef|schedule|directoryType|databaseType" +
"|pamHostname|pamResources|checkbox|"
"|pamHostname|pamResources|checkbox|passkey|"
if fMap, ok := fieldData.(map[string]interface{}); ok {
if fType, found := fMap["type"]; found {
if sType, ok := fType.(string); ok && strings.Contains(fieldTypes, "|"+sType+"|") {
Expand Down
29 changes: 28 additions & 1 deletion core/record_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,30 @@ func NewCheckbox(value bool) *Checkbox {
}
}

type Passkey struct {
PrivateKey string `json:"privateKey,omitempty"`
CredentialId string `json:"credentialId,omitempty"`
SignCount int64 `json:"signCount,omitempty"`
UserId string `json:"userId,omitempty"`
RelyingParty string `json:"relyingParty,omitempty"`
Username string `json:"username,omitempty"`
CreatedDate int64 `json:"createdDate,omitempty"`
}

type Passkeys struct {
KeeperRecordField
Required bool `json:"required,omitempty"`
Value []Passkey `json:"value,omitempty"`
}

// Passkeys field constructor with the single value to eliminate the complexity of the passing List as a value
func NewPasskeys(value Passkey) *Passkeys {
return &Passkeys{
KeeperRecordField: KeeperRecordField{Type: "passkey"},
Value: []Passkey{value},
}
}

// getKeeperRecordField converts fieldData from generic interface{} to strongly typed interface{}
func getKeeperRecordField(fieldType string, fieldData map[string]interface{}, validate bool) (field interface{}, err error) {
if jsonField := DictToJson(fieldData); strings.TrimSpace(jsonField) != "" {
Expand Down Expand Up @@ -650,6 +674,8 @@ func getKeeperRecordField(fieldType string, fieldData map[string]interface{}, va
field = &PamResources{}
case "checkbox":
field = &Checkbox{}
case "passkey":
field = &Passkeys{}
default:
return nil, fmt.Errorf("unable to convert unknown field type %v", fieldType)
}
Expand Down Expand Up @@ -702,7 +728,8 @@ func IsFieldClass(field interface{}) bool {
SecureNote, *SecureNote,
SecurityQuestions, *SecurityQuestions,
Text, *Text,
Url, *Url:
Url, *Url,
Passkeys, *Passkeys:
return true
}
return false
Expand Down