Skip to content

Commit ae52da0

Browse files
feat: Select 1Password fill pages by target and return stored-token grants
Stainless-Generated-From: d4635fa160b38160e0eee5c369943c9509877c89
1 parent 8f51b16 commit ae52da0

5 files changed

Lines changed: 64 additions & 8 deletions

File tree

‎src/kernel/resources/vaults/items.py‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,7 @@ def perform_operation(
12181218
page_url: str,
12191219
type: Literal["1pw_fill"],
12201220
entry_id: str | Omit = omit,
1221+
target_id: str | Omit = omit,
12211222
timeout_ms: int | Omit = omit,
12221223
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
12231224
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1263,11 +1264,16 @@ def perform_operation(
12631264
browser_id: Browser session ID, not a reusable browser name.
12641265
12651266
page_url: Exact current top-level page URL. Must match exactly one open page in the
1266-
browser.
1267+
browser unless target_id is supplied.
12671268
12681269
entry_id: ID of an approved request entry. Required when several approved entries have the
12691270
page's origin.
12701271
1272+
target_id: CDP target ID of the page to fill, such as tab.target_id from
1273+
playwright.execute. Use it when several open pages have page_url. The page's
1274+
current URL must equal page_url. Kernel brings the page to the front of its
1275+
window before filling.
1276+
12711277
extra_headers: Send extra headers
12721278
12731279
extra_query: Add additional query parameters to the request
@@ -1658,6 +1664,7 @@ def perform_operation(
16581664
reason: str | Omit = omit,
16591665
timeout_seconds: int | Omit = omit,
16601666
entry_id: str | Omit = omit,
1667+
target_id: str | Omit = omit,
16611668
access_token: str | Omit = omit,
16621669
access_token_expires_at: Union[str, datetime] | Omit = omit,
16631670
bindings: Iterable[VaultWebmcpBindingParam] | Omit = omit,
@@ -1700,6 +1707,7 @@ def perform_operation(
17001707
"reason": reason,
17011708
"timeout_seconds": timeout_seconds,
17021709
"entry_id": entry_id,
1710+
"target_id": target_id,
17031711
"access_token": access_token,
17041712
"access_token_expires_at": access_token_expires_at,
17051713
"bindings": bindings,
@@ -3195,6 +3203,7 @@ async def perform_operation(
31953203
page_url: str,
31963204
type: Literal["1pw_fill"],
31973205
entry_id: str | Omit = omit,
3206+
target_id: str | Omit = omit,
31983207
timeout_ms: int | Omit = omit,
31993208
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
32003209
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -3240,11 +3249,16 @@ async def perform_operation(
32403249
browser_id: Browser session ID, not a reusable browser name.
32413250
32423251
page_url: Exact current top-level page URL. Must match exactly one open page in the
3243-
browser.
3252+
browser unless target_id is supplied.
32443253
32453254
entry_id: ID of an approved request entry. Required when several approved entries have the
32463255
page's origin.
32473256
3257+
target_id: CDP target ID of the page to fill, such as tab.target_id from
3258+
playwright.execute. Use it when several open pages have page_url. The page's
3259+
current URL must equal page_url. Kernel brings the page to the front of its
3260+
window before filling.
3261+
32483262
extra_headers: Send extra headers
32493263
32503264
extra_query: Add additional query parameters to the request
@@ -3635,6 +3649,7 @@ async def perform_operation(
36353649
reason: str | Omit = omit,
36363650
timeout_seconds: int | Omit = omit,
36373651
entry_id: str | Omit = omit,
3652+
target_id: str | Omit = omit,
36383653
access_token: str | Omit = omit,
36393654
access_token_expires_at: Union[str, datetime] | Omit = omit,
36403655
bindings: Iterable[VaultWebmcpBindingParam] | Omit = omit,
@@ -3677,6 +3692,7 @@ async def perform_operation(
36773692
"reason": reason,
36783693
"timeout_seconds": timeout_seconds,
36793694
"entry_id": entry_id,
3695+
"target_id": target_id,
36803696
"access_token": access_token,
36813697
"access_token_expires_at": access_token_expires_at,
36823698
"bindings": bindings,

‎src/kernel/types/vaults/item_perform_operation_params.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class OnePasswordFillVaultItemOperationRequest(TypedDict, total=False):
207207
page_url: Required[str]
208208
"""Exact current top-level page URL.
209209
210-
Must match exactly one open page in the browser.
210+
Must match exactly one open page in the browser unless target_id is supplied.
211211
"""
212212

213213
type: Required[Literal["1pw_fill"]]
@@ -218,6 +218,14 @@ class OnePasswordFillVaultItemOperationRequest(TypedDict, total=False):
218218
Required when several approved entries have the page's origin.
219219
"""
220220

221+
target_id: str
222+
"""CDP target ID of the page to fill, such as tab.target_id from
223+
playwright.execute.
224+
225+
Use it when several open pages have page_url. The page's current URL must equal
226+
page_url. Kernel brings the page to the front of its window before filling.
227+
"""
228+
221229
timeout_ms: int
222230

223231

‎src/kernel/types/vaults/one_password_credential_vault_item_state.py‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"AccessRequestRequest",
1616
"AccessRequestRequestEntry",
1717
"AccessRequestRequestEntryParameters",
18+
"AccessRequestResolved",
1819
]
1920

2021

@@ -63,10 +64,22 @@ class AccessRequestRequest(BaseModel):
6364
version: Optional[int] = None
6465

6566

67+
class AccessRequestResolved(BaseModel):
68+
reference: str
69+
"""1Password credential reference.
70+
71+
Pass it unchanged as resourcePath to the extension's fillCredential or to the
72+
1Password SDK.
73+
"""
74+
75+
entry_id: Optional[str] = FieldInfo(alias="entryId", default=None)
76+
"""The requested entry this login satisfies, when known."""
77+
78+
6679
class AccessRequest(BaseModel):
6780
"""Non-secret broker state.
6881
69-
Granted credential references stay encrypted server-side and can only be used by the fill operation.
82+
Granted credential references are returned in resolved only for credentials with a customer-supplied access token; otherwise they stay encrypted server-side and can only be used by the fill operation.
7083
"""
7184

7285
id: str
@@ -103,6 +116,14 @@ class AccessRequest(BaseModel):
103116
The observed create response may omit entries; no entry IDs are invented.
104117
"""
105118

119+
resolved: Optional[List[AccessRequestResolved]] = None
120+
"""Granted logins in the shape 1Password's getAccessRequestStatus returns.
121+
122+
Present only for ready credentials with a customer-supplied access token, on
123+
single-item responses to callers that can use the vault. Each reference works
124+
only with that credential's access token and integration key.
125+
"""
126+
106127

107128
class OnePasswordCredentialVaultItemState(BaseModel):
108129
provider: Literal["1password"]
@@ -112,8 +133,9 @@ class OnePasswordCredentialVaultItemState(BaseModel):
112133
access_request: Optional[AccessRequest] = None
113134
"""Non-secret broker state.
114135
115-
Granted credential references stay encrypted server-side and can only be used by
116-
the fill operation.
136+
Granted credential references are returned in resolved only for credentials with
137+
a customer-supplied access token; otherwise they stay encrypted server-side and
138+
can only be used by the fill operation.
117139
"""
118140

119141
access_request_id: Optional[str] = None

‎src/kernel/types/vaults/one_password_fill_vault_item_operation_request_param.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class OnePasswordFillVaultItemOperationRequestParam(TypedDict, total=False):
1111
"""Fill and submit an approved 1Password login in the selected browser page.
1212
13-
The page must share the selected entry's login origin. Supply entry_id when more than one approved entry matches the page origin. The extension selects fields; callers cannot supply selectors or secret values. Submission does not confirm website authentication.
13+
The page must share the selected entry's login origin. Supply entry_id when more than one approved entry matches the page origin, and target_id when more than one open page has page_url. The extension selects fields; callers cannot supply selectors or secret values. Submission does not confirm website authentication.
1414
"""
1515

1616
browser_id: Required[str]
@@ -19,7 +19,7 @@ class OnePasswordFillVaultItemOperationRequestParam(TypedDict, total=False):
1919
page_url: Required[str]
2020
"""Exact current top-level page URL.
2121
22-
Must match exactly one open page in the browser.
22+
Must match exactly one open page in the browser unless target_id is supplied.
2323
"""
2424

2525
type: Required[Literal["1pw_fill"]]
@@ -30,4 +30,12 @@ class OnePasswordFillVaultItemOperationRequestParam(TypedDict, total=False):
3030
Required when several approved entries have the page's origin.
3131
"""
3232

33+
target_id: str
34+
"""CDP target ID of the page to fill, such as tab.target_id from
35+
playwright.execute.
36+
37+
Use it when several open pages have page_url. The page's current URL must equal
38+
page_url. Kernel brings the page to the front of its window before filling.
39+
"""
40+
3341
timeout_ms: int

‎tests/api_resources/vaults/test_items.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,7 @@ def test_method_perform_operation_with_all_params_overload_12(self, client: Kern
14941494
page_url="https://example.com",
14951495
type="1pw_fill",
14961496
entry_id="x",
1497+
target_id="x",
14971498
timeout_ms=1,
14981499
)
14991500
assert_matches_type(VaultItemOperationResponse, item, path=["response"])
@@ -4096,6 +4097,7 @@ async def test_method_perform_operation_with_all_params_overload_12(self, async_
40964097
page_url="https://example.com",
40974098
type="1pw_fill",
40984099
entry_id="x",
4100+
target_id="x",
40994101
timeout_ms=1,
41004102
)
41014103
assert_matches_type(VaultItemOperationResponse, item, path=["response"])

0 commit comments

Comments
 (0)