1Password/connect-sdk-go

Have a list of constants for Item field purposes

edif2008 opened this issue · 0 comments

Summary

Currently when making an Item, you need to specify a purpose for a field to make sure it is used in autofill (e.g. username and password fields). However, it can be a bit tricky to know by heart what the right purpose is for each field.
Therefore, we want to add the constants for supported field purposes, according to the API spec.

Tasks to be done

  • Add a new type that will be used as a field purpose, along with the constants that represent the supported field purposes. Add this in onepassword/items.go
    type ItemFieldPurpose string
    
    const (
        FieldPurposeUsername ItemFieldPurpose = "USERNAME"
        FieldPurposePassword ItemFieldPurpose = "PASSWORD"
        FieldPurposeNotes    ItemFieldPurpose = "NOTES"
    )
  • Change the Purpose property of the ItemFiled struct to have the new type. (line 109)
    // ItemField Representation of a single field on an Item
    type ItemField struct {
        ID       string           `json:"id"`
        Section  *ItemSection     `json:"section,omitempty"`
        Type     string           `json:"type"`
        Purpose  ItemFieldPurpose `json:"purpose,omitempty"`
        Label    string           `json:"label,omitempty"`
        Value    string           `json:"value,omitempty"`
        Generate bool             `json:"generate,omitempty"`
        Recipe   *GeneratorRecipe `json:"recipe,omitempty"`
        Entropy  float64          `json:"entropy,omitempty"`
        TOTP     string           `json:"totp,omitempty"`
    }