@chatbridge/provider 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/index.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
# @chatbridge/provider
|
|
2
2
|
|
|
3
3
|
The provider contract for [chatbridge](https://github.com/7milch/chatbridge-cli): the interface service-specific browser behaviour implements.
|
|
4
|
+
|
|
5
|
+
## Optional: `detectBlock`
|
|
6
|
+
|
|
7
|
+
`detectBlock(page)` lets a provider tell a bot challenge or an IdP refusing
|
|
8
|
+
the automated browser apart from an expired login. The core calls it only
|
|
9
|
+
after `isLoggedIn` returned `false`. Return a short description to raise
|
|
10
|
+
`BlockedError` (CLI exit 6, message suggests `--headful`); return
|
|
11
|
+
`undefined` for an ordinary logged-out page. Example for a Cloudflare
|
|
12
|
+
interstitial:
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
async detectBlock(page) {
|
|
16
|
+
return (await page.title()) === "Just a moment..." ? "challenge page" : undefined;
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Detecting a block is all the framework does; evading it is out of scope.
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ export interface Provider {
|
|
|
22
22
|
* return the response to the most recent `sendMessage` only, never an
|
|
23
23
|
* earlier turn's. */
|
|
24
24
|
waitForResponse(page: Page): Promise<string>;
|
|
25
|
+
/** Optional. When the page shows a block that logging in again would not
|
|
26
|
+
* clear (a bot challenge interstitial, an IdP refusing the automated
|
|
27
|
+
* browser), return a short description of it; otherwise undefined. The
|
|
28
|
+
* core calls this only after `isLoggedIn` returned false. Must not throw
|
|
29
|
+
* on an ordinary logged-out page. */
|
|
30
|
+
detectBlock?(page: Page): Promise<string | undefined>;
|
|
25
31
|
}
|
|
26
32
|
/** Identity helper: gives provider authors type inference and a future
|
|
27
33
|
* validation hook without any runtime cost today. */
|