1Password / onepassword-sdk-js

The official JavaScript SDK for 1Password
https://developer.1password.com/docs/sdks/
MIT License
37 stars 3 forks source link

Feature request: A method to load all sections or fields in an item #52

Closed ShravanSunder closed 1 month ago

ShravanSunder commented 2 months ago

Use Case

It would be much easier to load data for a .env file if we could load all the fiends in a section/item with a single service account call.

We could use this to populate a dict for dot env variables. I would find this much easier to use. related: https://github.com/1Password/onepassword-sdk-python/issues/56

2024-06-15 0633 Brave Browser Use secret references with 1Password CLI  1Password Developer

Requirements and desired behavior

Currently load single fields

Additional information

No response

AndyTitu commented 1 month ago

Hey @ShravanSunder, thank you for this feature request!

From my understanding of your use case, what could already be doing is:

// Retrieves item
    item, err := client.Items.Get(context.Background(), existingVaultID, existingItemID)
    if err != nil {
        panic(err)
    }

    allSectionsOfTheItem := item.Sections
        allFieldsOfTheItem := item.Fields

Let me know if this solves your problem!

ShravanSunder commented 1 month ago

@AndyTitu wouldn't this be multiple requests? We'd hit the rate limit very quickly with somthing like this

SimonBarendse commented 1 month ago

@ShravanSunder This would be a single API call for just the client.Items.Get request. The server response already contains all sections and fields on the item. When you item.Sections this doesn't trigger any additional HTTP requests.

ShravanSunder commented 1 month ago

oh thanks @SimonBarendse! to confirm the above is possible with py and ts libs too?

SimonBarendse commented 1 month ago

Yes, that's right.