@civitai/sdk 0.10.0 → 0.10.2
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 +9 -2
- package/dist/core/errors.js +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,7 +71,11 @@ observed two ways is two values that can disagree.
|
|
|
71
71
|
A block opts in by declaring `auth: "oauth"` in its `block.manifest.json`. The
|
|
72
72
|
host then hands it a real OAuth access token that `/api/v1`, the orchestrator
|
|
73
73
|
and the MCP accept, and consent — including `requestGrants` — goes through the
|
|
74
|
-
host's consent dialog.
|
|
74
|
+
host's consent dialog. The manifest must also declare `user:read:self`, which
|
|
75
|
+
every OAuth token carries: on civitai.com the host never mints one without it
|
|
76
|
+
and hands back the block token. The dev tunnel mints one regardless, so a
|
|
77
|
+
missing `user:read:self` only shows up after approval. And `auth: "oauth"` cannot be declared alongside any
|
|
78
|
+
`apps:storage:*` scope: such a manifest is refused at submit.
|
|
75
79
|
|
|
76
80
|
### When the token is the block-scoped one
|
|
77
81
|
|
|
@@ -357,7 +361,10 @@ wider scope — and refuses without one.
|
|
|
357
361
|
| `publishGenerationOutputs({ workflowId, imageIndexes })` | Publishes your own workflow's outputs, behind the host's confirmation; resolves the new image ids |
|
|
358
362
|
|
|
359
363
|
Host failures reject with a `BridgeError` carrying a `code` (`forbidden`,
|
|
360
|
-
`unauthenticated`, `rate-limited`, …).
|
|
364
|
+
`unauthenticated`, `rate-limited`, …). `unauthenticated` includes a viewer whose
|
|
365
|
+
session ended (signed out in another tab) — offer `requestSignIn()`. A session
|
|
366
|
+
that now belongs to a different account is `forbidden`; its `message` asks the
|
|
367
|
+
viewer to reload the page. Timeouts are the host's to set; pass a
|
|
361
368
|
`signal` to cancel. `ApiError` and `BridgeError` both extend `CivitaiError`, so
|
|
362
369
|
one `catch` can tell a refusal from a bug.
|
|
363
370
|
|
package/dist/core/errors.js
CHANGED
|
@@ -20,11 +20,18 @@ export class BridgeError extends CivitaiError {
|
|
|
20
20
|
* The messages this bridge already had report failure as the server's own
|
|
21
21
|
* sentence — the host holds the tRPC code and drops it. Unmatched text is
|
|
22
22
|
* `unavailable`; `message` still carries what the host said.
|
|
23
|
+
*
|
|
24
|
+
* Procedures that need the viewer's signed-in session can refuse with a bare
|
|
25
|
+
* `UNAUTHORIZED` (the session ended, e.g. signed out in another tab), which is
|
|
26
|
+
* `unauthenticated`, or with "…belongs to a different account; reload the page
|
|
27
|
+
* to continue" (the page's session changed account), which is `forbidden`:
|
|
28
|
+
* signing in again does not help, reloading the page does.
|
|
23
29
|
*/
|
|
24
30
|
const HOST_FAILURES = [
|
|
25
31
|
[/authenticated viewer|no block token/i, 'unauthenticated'],
|
|
32
|
+
[/^UNAUTHORIZED$/, 'unauthenticated'],
|
|
26
33
|
[
|
|
27
|
-
/(requires|lacks) .+ scope|not approved|revoked|invalid block token|not enabled|review preview|^banned$/i,
|
|
34
|
+
/(requires|lacks) .+ scope|not approved|revoked|invalid block token|not enabled|review preview|belongs to a different account|^banned$/i,
|
|
28
35
|
'forbidden',
|
|
29
36
|
],
|
|
30
37
|
[/rate limit|^busy$/i, 'rate-limited'],
|
package/package.json
CHANGED