Add session mode: signing in and adding to the cart.
With cart_mode = "session", dibs signs in to the shop's account and puts an item in the cart when it fires. The account's cookies are kept apart from the watcher's and stored encrypted, with the key in the OS keyring. Without a keyring, they're stored in a file only you can read. An alert now goes out right away, without a cart link, and a second one follows once the item is in the cart. If adding fails, the second alert carries the cart link instead. Amazon only accepts additions its page scripts have seen, so plugins can now press a button in headless Chrome with ctx:click. The TUI asks for one-time codes and shows the plugin's warning about account locks in a modal. 'dibs login' signs in from a terminal, or with --browser in a Chrome window, and 'dibs logout' deletes the cookies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e2cbc1a55c
commit
15a34e1f84
39 files changed
+3529
-163
No files matched your search
@@ -27,10 +27,18 @@ const PayloadVersion = 1
|
||||
// "previous_currency": null,
|
||||
// "seller": "first_party",
|
||||
// "cart_link": "https://www.amazon.de/gp/aws/cart/add.html?ASIN.1=B0HMX2FSTF&Quantity.1=1",
|
||||
// "cart": null,
|
||||
// "cart_url": null,
|
||||
// "cart_error": null,
|
||||
// "time": "2026-10-14T09:30:00Z"
|
||||
// }
|
||||
//
|
||||
// Every key is always present; values that do not apply are null.
|
||||
//
|
||||
// In session mode, an item that fires sends up to two payloads: one with
|
||||
// "cart": "adding" and no cart_link, then one with "cart": "added" and the
|
||||
// cart page in cart_url, or "cart": "failed", the reason in cart_error and
|
||||
// the cart link.
|
||||
type Payload struct {
|
||||
Version int `json:"version"`
|
||||
// Test is true for the sample alert of `dibs notify test`.
|
||||
@@ -55,6 +63,11 @@ type Payload struct {
|
||||
// Seller is "first_party", "fulfilled", "third_party" or "unknown".
|
||||
Seller string `json:"seller"`
|
||||
CartLink *string `json:"cart_link"`
|
||||
// Cart is null without session mode, else "adding", "added" or
|
||||
// "failed".
|
||||
Cart *string `json:"cart"`
|
||||
CartURL *string `json:"cart_url"`
|
||||
CartError *string `json:"cart_error"`
|
||||
// Time is when the page was checked, in UTC.
|
||||
Time time.Time `json:"time"`
|
||||
}
|
||||
@@ -75,6 +88,9 @@ func NewPayload(a alert.Alert) Payload {
|
||||
PreviousCurrency: orNull(a.PreviousCurrency),
|
||||
Seller: a.Seller,
|
||||
CartLink: orNull(a.CartLink),
|
||||
Cart: orNull(a.Cart),
|
||||
CartURL: orNull(a.CartURL),
|
||||
CartError: orNull(a.CartError),
|
||||
Time: a.Time.UTC().Truncate(time.Second),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user