Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 86 additions & 7 deletions vaults/1password.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ the login values. then:
2. create a `credential` item with `account` set to that item's key to describe the login you need. see [define a login request](#define-a-login-request).
3. invoke `1pw_create_access_request`, give the user the approval link, and poll `1pw_access_request_status`. neither needs a browser. see [request access and hand off approval](#request-access-and-hand-off-approval).
4. once the user approves, create a vault-attached browser and invoke `1pw_fill` on that item. see [fill and submit](#fill-and-submit).
5. when the user disconnects KERNEL in your application, invoke `1pw_disconnect` on the account. see [disconnect an account](#disconnect-an-account).

#### Your own OAuth client (advanced)

Expand Down Expand Up @@ -221,6 +222,7 @@ connection secrets.
| `connected` | the connection is usable | define credential items |
| `declined` | the user declined consent | repeat the upsert to get a new authorization url, or use `1pw_recover` when it's advertised |
| `reconnect_required` | the connection needs reauthorization; `state.status_reason` explains why | repeat the upsert, or use `1pw_recover` when it's advertised |
| `revoking` | the account was disconnected or deleted, and 1Password hasn't confirmed yet. new fills are refused. | wait; KERNEL finishes it in the background. don't upsert the account until it leaves `revoking` |

the authorization url expires after a short time. repeating the same upsert
returns the current url while it's valid and issues a new one after it
Expand All @@ -237,6 +239,50 @@ completes, start a new authorization on the same item by repeating the account
upsert. don't delete the account to recover, and don't retry recovery
automatically.

#### Disconnect an account

when the user disconnects KERNEL in your application, invoke `1pw_disconnect`
on the account. it ends the 1Password connection but keeps the item, so the
user can link it again later. the account advertises the operation while it's
`connected` and your api key has `vaults:use` and `vaults:write`.

- new fills from the account are refused immediately.
- KERNEL revokes the connection at 1Password, unless another vault still uses it; then only this vault's link ends.
- the account returns to `reconnect_required`. once it's no longer `revoking`, repeat the account upsert to link it again.
- the account's `credential` items return to `pending_authorization` without their approvals. after the account is linked again, create a new access request for each one.

<CodeGroup>

```typescript TypeScript
const disconnected = await kernel.vaults.items.performOperation("1password-account", {
id_or_name: vault.id,
type: "1pw_disconnect",
}, { maxRetries: 0 });
```

```python Python
disconnected = kernel.with_options(max_retries=0).vaults.items.perform_operation(
"1password-account",
id_or_name=vault.id,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the TypeScript sample: turn off SDK retries so a 409 provider_revocation_pending isn't sent again.

Suggested change
id_or_name=vault.id,
disconnected = kernel.with_options(max_retries=0).vaults.items.perform_operation(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 25eb20d: the Python sample uses with_options(max_retries=0).

type="1pw_disconnect",
)
```

</CodeGroup>

if 1Password hasn't confirmed the revoke yet, the operation returns `409`
`provider_revocation_pending`. new fills are still refused, and the account stays
`revoking` while KERNEL finishes the disconnect in the background, so don't
invoke it again. the account's events record how it ended:

| event | meaning |
| --- | --- |
| `credential_account_revocation_started` | KERNEL started revoking the connection at 1Password |
| `credential_account_revocation_pending` | 1Password hasn't confirmed yet; KERNEL keeps trying |
| `credential_account_revoked` | 1Password confirmed the connection ended |
| `credential_account_detached` | another vault still uses the connection, so only this vault's link ended |
| `credential_account_revocation_unconfirmed` | KERNEL ended its side of the connection, but 1Password didn't confirm the revoke. the connection lapses when its refresh token expires, within 30 days of its last refresh. |

### Define a login request

create a `credential` item with `provider: "1password"` and `account` set to
Expand Down Expand Up @@ -816,15 +862,48 @@ again.
### Delete items

delete a 1Password `credential` item to discard its approval references and,
for a stored-token item, its encrypted token and key. delete every
`credential` item that references an account before deleting the
`credential_account`; otherwise the api returns `409`. deleting the account
removes KERNEL's stored connection. deleting either item doesn't remove the
connection or revoke the token in the user's 1Password account. if you use your
own oauth client, revoke the connection from your backend when the user
disconnects; see 1Password's
for a stored-token item, its encrypted token and key. if you use your own oauth
client, revoke the connection from your backend when the user disconnects; see
1Password's
[disconnect guide](https://www.1password.dev/agentic-autofill/partners/disconnect).

before deleting a `credential_account`, delete every `credential` item that
references it; otherwise the api returns `409`. deleting the account ends its
connection the same way as [disconnecting it](#disconnect-an-account). if
1Password hasn't confirmed the revoke yet, the delete returns `409`
`provider_revocation_pending`; the account stays `revoking` and KERNEL finishes
deleting it in the background.

deleting a vault disconnects each of its 1Password accounts, then deletes the
vault. if 1Password hasn't confirmed one of them, the delete returns `409`
`provider_revocation_pending` and keeps the vault, but its accounts are already
disconnected and their `credential` items have lost their approvals. don't keep
using the vault; retry the deletion later.

to read an account's events after it or its vault is deleted, pass
`include_deleted: true` with the account's id. a key matches a live item first,
so after an account is recreated under the same key, the key returns the new
account's events. look up a deleted vault by its id, not its name.

<CodeGroup>

```typescript TypeScript
const events = await kernel.vaults.items.events(account.id, {
id_or_name: vault.id,
include_deleted: true,
});
```

```python Python
events = kernel.vaults.items.events(
account.id,
id_or_name=vault.id,
include_deleted=True,
)
```

</CodeGroup>

## Limitations

- **not secret isolation:** for each fill, KERNEL gives the extension inside the attached browser access to the connected account or supplied token, and it doesn't remove the extension afterward. access requests and status checks don't involve the browser. use a dedicated browser for 1Password operations, don't give untrusted automation access to it, and don't load extensions you don't trust alongside it. the filled values are in the page between fill and submit.
Expand Down
Loading