1Password / onepassword-sdk-go

https://developer.1password.com/docs/sdks/
MIT License
52 stars 5 forks source link

URLs unavailable in Field types. #131

Closed sebastianlivoni closed 3 weeks ago

sebastianlivoni commented 3 months ago

Scenario & Reproduction Steps

When retrieving an item, it seems to only include username and password field types. According to the documentation, URLs should also be supported, but they are not present in the Item.Fields within the 1Password item structure.

// Item represents a 1Password item.
type Item struct {
    // ID is the unique identifier of the item.
    ID string `json:"id"`
    // Title is the title of the item.
    Title string `json:"title"`
    // Category represents the item's category.
    Category ItemCategory `json:"category"`
    // VaultID is the identifier of the vault where the item is stored.
    VaultID string `json:"vaultId"`
    // Fields contains the item's fields.
    Fields []ItemField `json:"fields"`
    // Sections holds the sections of the item.
    Sections []ItemSection `json:"sections"`
    // Version represents the item's version.
    Version uint32 `json:"version"`
}

func getItem(token string, vaultID string, itemID string) onepassword.Item {
    client := createClient(token)

    item, err := client.Items.Get(context.Background(), vaultID, itemID)

        // This will only print username or password and never URL
    for _, field := range item.Fields {
        print(field.ID)
    }

    if err != nil {
        panic(err)
    }

    return item
}

Actual Behavior

URLs does not appear in Item.Fields

Expected Behavior

URLs should appear in Item.Fields

SDK version

v0.1.1

Additional information

No response

Marton6 commented 3 months ago

Hey @sebastianlivoni! Thanks for reporting this bug.

I think I was able to reproduce the issue you are encountering from the details that you provided. It seems that the websites associated to an item are not returned by the SDK.

Is this the issue you were running into?

URL-type fields are supported and returned correctly by the SDK (based on my testing), but they are different from the websites associated to an item.

Can you confirm if this is the issue you're running into? If so we will look into fixing it soon.

sebastianlivoni commented 3 months ago

I think I was able to reproduce the issue you are encountering from the details that you provided. It seems that the websites associated to an item are not returned by the SDK.

Is this the issue you were running into?

Exactly, I'm not able to see associated websites from items ☺️

Also the associated websites are not available in the JavaScript SDK.

AndyTitu commented 2 months ago

@sebastianlivoni what is your use case exactly? In order to make sure we offer support URLs in the most useful way possible, we wanted to learn more about your use case: How do you plan to use the URLs in your workflow? What type of app are you writing and how does this app use the websites it retrieves from 1Password? Of course, feel free to not share details that you don't want to share, but we're interested in your overall plan. Thanks!

AndyTitu commented 2 months ago

@sebastianlivoni A very relevant question for us: do you see it as a requirement that URLs are available to you fast? For example, in a context where you have 2000 items in a vault, do you want to list all items and quickly look have the URLs available to you prior to seeing the rest of the item details, such as other secret fields and sections?

sebastianlivoni commented 2 months ago

Hi @AndyTitu. Thank you for looking into it :)

How do you plan to use the URLs in your workflow?

I'm implementing an Autofill Credential Provider Extension App on macOS for personal use in order to provide "macOS Native Autofill".

What type of app are you writing and how does this app use the websites it retrieves from 1Password?

The app is designed to provide autofill functionality. :)

A very relevant question for us: do you see it as a requirement that URLs are available to you fast?

No, not for my use case, as I need all the item details, including the username and password, for my implementation. However, I can see how that approach might make sense in other contexts.

For example, in a context where you have 2000 items in a vault, do you want to list all items and quickly look have the URLs available to you prior to seeing the rest of the item details, such as other secret fields and sections?

Currently, I'm fetching all items and saving them in the Keychain for fast autofill (currently with sample URLs, as they are unavailable 😊) and I think I keep this approach instead of only fetching Title, Username and URLs and then retrieving the password later.

For my use case, I'd prefer a query system similar to GraphQL, allowing me to request only the specific data I need, such as Title, Username, Password, URL(s), and 2FA, without fetching unnecessary information.

hculea commented 3 weeks ago

@sebastianlivoni version 0.1.3 of the SDK adds support for websites.

I'll be closing this issue, but do feel free to reopen if this doesn't address your use-case. Thanks!