Developers · What Unlock codes do

Developers

Unlock Codes

Which refused requests get the unusual activity page, what the page sends back, and how a code, a chat or an emailed link turns into access.

Which Requests Get The Page

It needs the Edge Observer: without it nothing is refused, so nothing gets the page.

When the Edge Observer refuses a request and the page is on (Site Settings, Bots, Unlock Codes), a browser asking for a page gets the unusual activity page instead of a bare refusal. Stattery treats a request as a page when it is a GET or HEAD with Sec-Fetch-Dest: document, or with no such header and an Accept that includes text/html.

  • Files (images, scripts, styles, fonts), /wp-json/ routes and feeds keep getting a plain 403.
  • Cart and checkout calls from scripts keep getting the cart_refused JSON described in No bots in the cart.
  • The page never says why the request was refused.

What The Page Sends Back

HTTP 403 with Content-Type: text/html; charset=utf-8, Cache-Control: no-store and X-Robots-Tag: noindex, plus a robots meta tag, so it is never cached or listed by search engines. It shows the business name, phone (a tel: link) or email from Site Settings, Overview, Business Info, and a form for a 4-digit code.

The form posts application/x-www-form-urlencoded to /.well-known/stattery-unlock on your own domain, with two fields: code and back (the path the visitor asked for; anything that isn’t a path on the same site becomes /). The Edge Observer answers it itself; the request never reaches your server.

How A Code Becomes Access

  • A right code answers 303 See Other to back and sets the cookie stt_ul (Path=/; Secure; HttpOnly; SameSite=Lax). It is signed with a key unique to the site and checked by the Edge Observer on every request, so access opens at once everywhere.
  • The visitor’s address goes on the site’s Allowed list with the caller’s name, which lifts its bans and keeps Auto-ban away from it. Remove it there to undo.
  • Your WordPress plugin is asked to fetch its rules again right away, so the plugin’s own checks let the address in too.
  • A wrong, used, cancelled or ended code shows the page again with a short message. Codes work once and end on their own, and repeated wrong codes shut a connection out.
  • Codes are made by people with the Bots permission in Site Settings, Bots, Unlock Codes. The list keeps who each code was for, who made it, and when and from where it was used.

Related: No bots in the cart, Enforce robots.txt.

Chat And Email Links

The page offers two more ways back in. Both are answered by the Edge Observer at /.well-known/stattery-unlock, like the code form.

  • Chat with us shows when the site’s Stattery chat is on. It asks the Edge Observer for a short-lived chat pass tied to the visitor’s connection (GET /.well-known/stattery-unlock?ct=1, JSON {"t": "..."}), then loads the site’s chat script with it. Stattery lets that connection chat even though the site refused it, and marks the conversation as coming from the page. Staff with the Bots permission get a Send Unlock Code button in that chat, which makes a code and sends it as a chat message.
  • Email me a link posts the fields email and back. If the address belongs to a customer of the store (an order Stattery recorded, or an account or order your WordPress plugin reports), Stattery emails a one-time link at once. Otherwise the request waits in Site Settings, Bots, Unlock Codes, Link Requests until someone approves it, and the site’s security notice goes out. The page answers the same way in both cases.
  • The link is https://your-site/.well-known/stattery-unlock?t=.... Opening it shows one Get back in button that posts the field t, so a mail scanner that opens links can’t use it up. A good link works once, ends on its own, and does what a right code does: the stt_ul cookie, the Allowed list entry (noted with the email address) and a 303 back to the page the visitor wanted.
  • Stattery keeps only a hash of each link’s secret, and limits how often a connection can ask for links.

Banned While On The Page

This also needs the Edge Observer. When a ban is saved, by hand or by Auto-ban, Stattery tells that visitor’s open pages over the connection the Stattery tag already keeps (its regular check-in, or the chat connection when chat is on). Nothing new polls.

  • The tag sends the top page to its own address with the query parameter stt_bye (an id for the ban). Each ban moves a browser at most once.
  • The Edge Observer answers that request itself. If the ban still covers the address, the visitor gets the unusual activity page described above, with its code form, chat and email link. If not (the ban was lifted, or the address is allowed), the page loads as normal.
  • stt_bye is taken off before the request goes on, so it never reaches your server, and the tag removes it from the address bar if the page loads.
  • Addresses on the Allowed list, addresses marked Mine and Stattery’s own checkers are never moved.