Skip to content

Commit

Permalink
Added passkey field type for login record type (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
idimov-keeper committed May 18, 2023
1 parent 16ae8e7 commit b8457b7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
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

0 comments on commit b8457b7

Please sign in to comment.