| 1 |
"""Constants for Cookidoo API.""" |
| 2 |
|
| 3 |
from typing import Final |
| 4 |
|
| 5 |
DEFAULT_API_HEADERS: Final = { |
| 6 |
"ACCEPT": "application/json", |
| 7 |
} |
| 8 |
|
| 9 |
# A browser-like User-Agent for the login flow requests only. The login |
| 10 |
# flow is served behind Cloudflare and clients without a recognizable |
| 11 |
# browser User-Agent (e.g. Home Assistant's default "Home Assistant/x.y |
| 12 |
# aiohttp/x.y Python/x.y") are more likely to be flagged as bots, causing |
| 13 |
# intermittent 403s. This does not touch the caller's session defaults, |
| 14 |
# it is only sent with the login requests below. |
| 15 |
# See https://github.com/miaucl/cookidoo-api/issues/230 |
| 16 |
LOGIN_HEADERS: Final = { |
| 17 |
"User-Agent": ( |
| 18 |
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " |
| 19 |
"(KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" |
| 20 |
), |
| 21 |
} |
| 22 |
|
| 23 |
CIAM_BASE_URL: Final = "https://ciam.prod.cookidoo.vorwerk-digital.com" |
| 24 |
CIAM_LOGIN_SRV_URL: Final = f"{CIAM_BASE_URL}/login-srv/login" |
| 25 |
OIDC_DISCOVERY_URL: Final = f"{CIAM_BASE_URL}/.well-known/openid-configuration" |
| 26 |
|
| 27 |
# OAuth2 / OIDC client. The bearer token it yields works against the same |
| 28 |
# api_endpoint as the previous cookie session, and additionally reaches the |
| 29 |
# remote-monitoring backend (which the cookie session could not). |
| 30 |
# |
| 31 |
# The login runs as a *public* client: authorization code + PKCE, with the |
| 32 |
# client id sent in the token request body and no client secret anywhere. CIAM |
| 33 |
# accepts that -- with a `code_verifier` present it does not verify a client |
| 34 |
# secret at all (a request carrying a deliberately wrong secret is accepted just |
| 35 |
# the same), and it rejects the exchange only when neither PKCE nor a secret is |
| 36 |
# supplied. So the secret the mobile app happens to ship is not a credential |
| 37 |
# this flow needs, and nothing secret is embedded here: |
| 38 |
# |
| 39 |
# * the client id is a public identifier by definition -- RFC 6749 sec. 2.2: |
| 40 |
# "The client identifier is not a secret; it is exposed to the resource owner |
| 41 |
# and MUST NOT be used alone for client authentication." |
| 42 |
# * the redirect uri is the app's public URL scheme; it travels in the query |
| 43 |
# string of every authorize request and is declared in the app manifest. |
| 44 |
# |
| 45 |
# Both are overridable via `CookidooConfig` should the app's registration ever |
| 46 |
# change, but callers are not expected to supply anything. |
| 47 |
OAUTH_CLIENT_ID: Final = "mobile-android" |
| 48 |
OAUTH_REDIRECT_URI: Final = "com.vorwerk.cookidoo://code-grant" |
| 49 |
OAUTH_SCOPE: Final = "openid profile email offline offline_access" |
| 50 |
# Refresh a little before the (12h) access token actually expires. |
| 51 |
TOKEN_EXPIRY_MARGIN_S: Final = 300 |
| 52 |
|
| 53 |
LOGIN_PATH: Final = "profile/{language}/login" |
| 54 |
LOGIN_REDIRECT: Final = "%2Ffoundation%2F{language}%2Ffor-you" |
| 55 |
RECIPE_PATH: Final = "recipes/recipe/{language}/{id}" |
| 56 |
CUSTOM_RECIPES_PATH: Final = "created-recipes/{language}" |
| 57 |
CUSTOM_RECIPES_PATH_ACCEPT: Final = "application/vnd.vorwerk.customer-recipe.full+json" |
| 58 |
CUSTOM_RECIPE_PATH: Final = "created-recipes/{language}/{id}" |
| 59 |
SHOPPING_LIST_RECIPES_PATH: Final = "shopping/{language}" |
| 60 |
EDIT_OWNERSHIP_INGREDIENT_ITEMS_PATH: Final = ( |
| 61 |
"shopping/{language}/owned-ingredients/ownership/edit" |
| 62 |
) |
| 63 |
ADD_INGREDIENT_ITEMS_FOR_RECIPES_PATH: Final = "shopping/{language}/recipes/add" |
| 64 |
REMOVE_INGREDIENT_ITEMS_FOR_RECIPES_PATH: Final = "shopping/{language}/recipes/remove" |
| 65 |
ADD_ADDITIONAL_ITEMS_PATH: Final = "shopping/{language}/additional-items/add" |
| 66 |
EDIT_ADDITIONAL_ITEMS_PATH: Final = "shopping/{language}/additional-items/edit" |
| 67 |
EDIT_OWNERSHIP_ADDITIONAL_ITEMS_PATH: Final = ( |
| 68 |
"shopping/{language}/additional-items/ownership/edit" |
| 69 |
) |
| 70 |
REMOVE_ADDITIONAL_ITEMS_PATH: Final = "shopping/{language}/additional-items/remove" |
| 71 |
|
| 72 |
COMMUNITY_PROFILE_PATH: Final = "community/profile/{language}" |
| 73 |
SUBSCRIPTIONS_PATH: Final = "ownership/subscriptions" |
| 74 |
|
| 75 |
# Paired Thermomix appliances on the account. Returns the machine types, e.g. |
| 76 |
# ``["TM7"]``. Language-independent path (customer-devices service). |
| 77 |
DEVICES_PATH: Final = "customer-devices/api/my-devices/versions" |
| 78 |
|
| 79 |
SEARCH_PATH: Final = "search/{locale}" |
| 80 |
|
| 81 |
# --- Remote monitoring (device management) -------------------------------- |
| 82 |
# The remote-monitoring (RMI) endpoints live on a dedicated IoT backend that is |
| 83 |
# discovered from the mobile home document -> rmi-config sub-document. Reaching |
| 84 |
# them requires the OAuth2 bearer token (the previous cookie session was refused). |
| 85 |
MOBILE_HOME_PATH: Final = ".well-known/mobile-home" |
| 86 |
HAL_ACCEPT: Final = ( |
| 87 |
"application/vnd.vorwerk.tmde2.rhd.mobile.hal+json, application/hal+json" |
| 88 |
) |
| 89 |
# The RMI write endpoints require this API-version header. |
| 90 |
RMI_API_VERSION: Final = "2026-06-01" |
| 91 |
|
| 92 |
REL_RMI_CONFIG: Final = "tmde2:rmi-config" |
| 93 |
RMI_REGISTER_TOKEN: Final = "rmi:register-token" |
| 94 |
RMI_UNREGISTER: Final = "rmi:unregister" |
| 95 |
RMI_DEVICES: Final = "rmi:devices" |
| 96 |
|
| 97 |
# Fields for the push-token registration payload. |
| 98 |
PUSH_BUNDLE_ID: Final = "com.vorwerk.cookidoo" |
| 99 |
PUSH_PLATFORM: Final = "AN" # Android; the value the app sends |
| 100 |
|
| 101 |
CUSTOM_COLLECTIONS_PATH: Final = "organize/{language}/api/custom-list" |
| 102 |
CUSTOM_COLLECTIONS_PATH_ACCEPT: Final = ( |
| 103 |
"application/vnd.vorwerk.organize.custom-list.mobile+json" |
| 104 |
) |
| 105 |
REMOVE_CUSTOM_COLLECTION_PATH: Final = "organize/{language}/api/custom-list/{id}" |
| 106 |
REMOVE_RECIPE_FROM_CUSTOM_COLLECTION_PATH: Final = ( |
| 107 |
"organize/{language}/api/custom-list/{id}/recipes/{recipe}" |
| 108 |
) |
| 109 |
MANAGED_COLLECTIONS_PATH: Final = "organize/{language}/api/managed-list" |
| 110 |
MANAGED_COLLECTIONS_PATH_ACCEPT: Final = ( |
| 111 |
"application/vnd.vorwerk.organize.managed-list.mobile+json" |
| 112 |
) |
| 113 |
REMOVE_MANAGED_COLLECTION_PATH: Final = "organize/{language}/api/managed-list/{id}" |
| 114 |
RECIPES_IN_CALENDAR_WEEK_PATH: Final = "planning/{language}/api/my-week/{day}" |
| 115 |
ADD_RECIPES_TO_CALENDER_PATH: Final = "planning/{language}/api/my-day" |
| 116 |
REMOVE_RECIPE_FROM_CALENDER_PATH: Final = ( |
| 117 |
"planning/{language}/api/my-day/{day}/recipes/{recipe}" |
| 118 |
) |