@vibes.diy/prompts 12.0.7 → 12.1.1
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/llms/backend.md +43 -0
- package/package.json +4 -4
package/llms/backend.md
CHANGED
|
@@ -81,6 +81,44 @@ than `forbidden` — keep scheduled writes small and well-guarded. `fetch` and
|
|
|
81
81
|
`onChange` never get admin mode: they're user-triggerable, and a handler any
|
|
82
82
|
visitor can invoke must not run owner-privileged.
|
|
83
83
|
|
|
84
|
+
### Taking on the authorization job: `config.fetch.unfilteredReads`
|
|
85
|
+
|
|
86
|
+
Because the `fetch` lane runs as the calling user, a `fetch` handler by default
|
|
87
|
+
reads nothing for a caller with no session, and cannot read an access-fn-bound
|
|
88
|
+
database without an opt-in. Some routes legitimately need to: a calendar feed at
|
|
89
|
+
`GET /_api/faves.ics?t=<token>` is fetched by a calendar app that carries no
|
|
90
|
+
login, and the docs it serves are private to one user. For those, `backend.js`
|
|
91
|
+
can opt in — per database, `fetch` lane only:
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
export const config = {
|
|
95
|
+
fetch: {
|
|
96
|
+
unfilteredReads: {
|
|
97
|
+
dbs: ["faves"],
|
|
98
|
+
why: "serves per-user .ics calendar feeds authorized by an unguessable token",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This is an **obligation, not a convenience**. Inside that handler, for those
|
|
105
|
+
databases, you are taking on the authorization job the platform normally does:
|
|
106
|
+
both the anonymous refusal and the access-function scoping come off, so
|
|
107
|
+
`ctx.db.query`/`ctx.db.get` return **every** document in the named databases —
|
|
108
|
+
all users, all channels — to whoever called the route. The legitimate pattern is
|
|
109
|
+
a **capability**: an unguessable, per-user, revocable token in the URL or a
|
|
110
|
+
header, checked before you read, with the response scoped to exactly that
|
|
111
|
+
token's owner. "The URL is hard to guess" only holds if you mint the token
|
|
112
|
+
yourself with real entropy and never print it anywhere else.
|
|
113
|
+
|
|
114
|
+
Two things to design around. The opt-in is scoped to the **lane, not the
|
|
115
|
+
route**: `backend.js` exports one `fetch` handler that routes internally, so
|
|
116
|
+
every path inside it can read those databases — keep the check at the top and
|
|
117
|
+
name as few databases as the feature needs. And it is a **static declaration**:
|
|
118
|
+
`dbs` must be plain string literals and `why` a non-empty string literal saying
|
|
119
|
+
who is authorized and how, or the push is rejected. There is no call-site flag,
|
|
120
|
+
and no other lane can opt in.
|
|
121
|
+
|
|
84
122
|
## ctx — what a handler gets
|
|
85
123
|
|
|
86
124
|
```js
|
|
@@ -106,6 +144,11 @@ const res = await ctx.fetch("https://api.example.com/x", { headers }); // outbou
|
|
|
106
144
|
doc, across all users and channels. In `fetch`/`onChange`, databases bound
|
|
107
145
|
to an access function cannot be queried (keep those lanes' read databases on
|
|
108
146
|
plain ACLs). Made for `scheduled` sweeps: read, decide, then `put`/`delete`.
|
|
147
|
+
- The one exception to that last sentence is the declared opt-in above,
|
|
148
|
+
`config.fetch.unfilteredReads` — a `fetch` handler that names a database there
|
|
149
|
+
reads it unfiltered, anonymous callers included, and owes the authorization
|
|
150
|
+
check itself. Nothing changes for writes, or for any lane or database you
|
|
151
|
+
didn't name.
|
|
109
152
|
- `ctx.secrets` carries the owner's per-vibe secrets, set in the vibe's settings
|
|
110
153
|
page or with `vibes-diy secrets set KEY`. Use it to verify inbound credentials —
|
|
111
154
|
a webhook's shared secret or token — or to authenticate outbound calls
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibes.diy/prompts",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"description": "",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@adviser/cement": "~0.5.34",
|
|
27
|
-
"@vibes.diy/call-ai-v2": "^12.
|
|
28
|
-
"@vibes.diy/identity": "^12.
|
|
29
|
-
"@vibes.diy/use-vibes-types": "^12.
|
|
27
|
+
"@vibes.diy/call-ai-v2": "^12.1.1",
|
|
28
|
+
"@vibes.diy/identity": "^12.1.1",
|
|
29
|
+
"@vibes.diy/use-vibes-types": "^12.1.1",
|
|
30
30
|
"arktype": "~2.2.3",
|
|
31
31
|
"json-schema-faker": "~0.6.2"
|
|
32
32
|
},
|