@fungi.computer/oyster 0.39.1 → 0.40.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/dist/auth.d.ts +3 -1
- package/dist/auth.js +35 -8
- package/dist/workers-git.d.ts +2 -0
- package/dist/workers-git.js +4 -0
- package/docs/api/auth.md +16 -5
- package/docs/api/workers-git.md +18 -0
- package/package.json +6 -6
package/dist/auth.d.ts
CHANGED
|
@@ -9,5 +9,7 @@ export declare const returningCookieName = "oyster_returning";
|
|
|
9
9
|
* cookie holding the owner key's digest. The key is never stored in the browser.
|
|
10
10
|
*/
|
|
11
11
|
export declare function ownerKeyAuth(ownerKey: string, ownerId?: string): OysterAuth;
|
|
12
|
+
/** How stale a key's last-used time may be: calls inside this window do not re-stamp it. */
|
|
13
|
+
export declare const lastUsedGranularityMs: number;
|
|
12
14
|
/** The owner key, or a named key admitted as its canonical Team-key actor. */
|
|
13
|
-
export declare function ownerOrKeyAuth(ownerKey: string, ownerId: string, keys: () => Pick<OysterKeyStore, "verify">): OysterAuth;
|
|
15
|
+
export declare function ownerOrKeyAuth(ownerKey: string, ownerId: string, keys: () => Pick<OysterKeyStore, "verify" | "touch">): OysterAuth;
|
package/dist/auth.js
CHANGED
|
@@ -82,9 +82,33 @@ export function ownerKeyAuth(ownerKey, ownerId = "owner") {
|
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
+
/** How stale a key's last-used time may be: calls inside this window do not re-stamp it. */
|
|
86
|
+
export const lastUsedGranularityMs = 5 * 60 * 1000;
|
|
85
87
|
/** The owner key, or a named key admitted as its canonical Team-key actor. */
|
|
86
88
|
export function ownerOrKeyAuth(ownerKey, ownerId, keys) {
|
|
87
89
|
const owner = ownerKeyAuth(ownerKey, ownerId);
|
|
90
|
+
// When this isolate last tried to stamp each key. A key's "Last used" is
|
|
91
|
+
// accurate to `lastUsedGranularityMs`, so a burst of calls costs one write.
|
|
92
|
+
const lastStamp = new Map();
|
|
93
|
+
const stampLastUsed = async (keyId) => {
|
|
94
|
+
const now = Date.now();
|
|
95
|
+
const last = lastStamp.get(keyId);
|
|
96
|
+
if (last !== undefined && now - last < lastUsedGranularityMs)
|
|
97
|
+
return;
|
|
98
|
+
lastStamp.set(keyId, now);
|
|
99
|
+
// The call is already admitted: a failed stamp is reported, never fatal.
|
|
100
|
+
try {
|
|
101
|
+
const touched = await keys().touch(keyId);
|
|
102
|
+
if (touched.kind !== "ok")
|
|
103
|
+
console.error("Oyster key last-used stamp refused", {
|
|
104
|
+
keyId,
|
|
105
|
+
code: touched.error.code,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
console.error("Oyster key last-used stamp failed", keyId, error);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
88
112
|
return {
|
|
89
113
|
resolve: (actor) => owner.resolve(actor),
|
|
90
114
|
async authenticate(request) {
|
|
@@ -98,14 +122,17 @@ export function ownerOrKeyAuth(ownerKey, ownerId, keys) {
|
|
|
98
122
|
// A revoked or expired key, or one belonging to a different owner (a
|
|
99
123
|
// presented secret can never prove that on its own), authenticates as
|
|
100
124
|
// no one; the owner-key result above still stands.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
:
|
|
125
|
+
if (verified.kind !== "ok" || verified.value.owner !== ownerId)
|
|
126
|
+
return result;
|
|
127
|
+
// The one place a named key is admitted for every door (Git, MCP, HTTP):
|
|
128
|
+
// stamp its Ear Tag last-used time here, so no caller can miss it.
|
|
129
|
+
await stampLastUsed(verified.value.keyId);
|
|
130
|
+
return {
|
|
131
|
+
kind: "admitted",
|
|
132
|
+
principal: {
|
|
133
|
+
actor: { kind: "team-key", keyId: verified.value.keyId },
|
|
134
|
+
},
|
|
135
|
+
};
|
|
109
136
|
},
|
|
110
137
|
login: (request) => owner.login?.(request) ??
|
|
111
138
|
Promise.resolve(new Response("Sign-in is not available", { status: 404 })),
|
package/dist/workers-git.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ export declare class OysterKeys extends DurableObject<OysterKeysEnv> {
|
|
|
63
63
|
list(owner: string): ReturnType<KeyStore<OysterKeyCapability>["list"]>;
|
|
64
64
|
/** Verify a bearer secret and return its current principal. */
|
|
65
65
|
verify(secret: string): ReturnType<KeyStore<OysterKeyCapability>["verify"]>;
|
|
66
|
+
/** Stamp a key's last-used time; refuses `denied` for an unknown key. */
|
|
67
|
+
touch(keyId: string): ReturnType<KeyStore<OysterKeyCapability>["touch"]>;
|
|
66
68
|
/** The live facts behind one key id, for the host's `keys.live` port; `null` for an unknown, revoked, expired or suspended key. */
|
|
67
69
|
live(keyId: string): Promise<LiveOysterKey | null>;
|
|
68
70
|
}
|
package/dist/workers-git.js
CHANGED
|
@@ -476,6 +476,10 @@ export class OysterKeys extends DurableObject {
|
|
|
476
476
|
verify(secret) {
|
|
477
477
|
return this.#store.verify(secret);
|
|
478
478
|
}
|
|
479
|
+
/** Stamp a key's last-used time; refuses `denied` for an unknown key. */
|
|
480
|
+
touch(keyId) {
|
|
481
|
+
return this.#store.touch(keyId);
|
|
482
|
+
}
|
|
479
483
|
/** The live facts behind one key id, for the host's `keys.live` port; `null` for an unknown, revoked, expired or suspended key. */
|
|
480
484
|
async live(keyId) {
|
|
481
485
|
const result = await this.#store.live({ keyId });
|
package/docs/api/auth.md
CHANGED
|
@@ -28,6 +28,17 @@ const returningCookieName: "oyster_returning" = "oyster_returning";
|
|
|
28
28
|
|
|
29
29
|
Marks a browser that has signed in here before; it carries no authority.
|
|
30
30
|
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### lastUsedGranularityMs
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
const lastUsedGranularityMs: number;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
How stale a key's last-used time may be: calls inside this window do not
|
|
40
|
+
re-stamp it.
|
|
41
|
+
|
|
31
42
|
## Functions
|
|
32
43
|
|
|
33
44
|
### ownerKeyAuth()
|
|
@@ -62,11 +73,11 @@ The owner key, or a named key admitted as its canonical Team-key actor.
|
|
|
62
73
|
|
|
63
74
|
#### Parameters
|
|
64
75
|
|
|
65
|
-
| Parameter | Type
|
|
66
|
-
| ---------- |
|
|
67
|
-
| `ownerKey` | `string`
|
|
68
|
-
| `ownerId` | `string`
|
|
69
|
-
| `keys` | () => `Pick`\<[`OysterKeyStore`](keys.md#oysterkeystore), `"verify"`\> |
|
|
76
|
+
| Parameter | Type |
|
|
77
|
+
| ---------- | ----------------------------------------------------------------------------------- |
|
|
78
|
+
| `ownerKey` | `string` |
|
|
79
|
+
| `ownerId` | `string` |
|
|
80
|
+
| `keys` | () => `Pick`\<[`OysterKeyStore`](keys.md#oysterkeystore), `"verify"` \| `"touch"`\> |
|
|
70
81
|
|
|
71
82
|
#### Returns
|
|
72
83
|
|
package/docs/api/workers-git.md
CHANGED
|
@@ -198,6 +198,24 @@ Verify a bearer secret and return its current principal.
|
|
|
198
198
|
`name`: `string`; `scope`: `Scope`\<`Capability`\>; `grantVersion`: `number`;
|
|
199
199
|
`expiresAt`: `number` \| `null`; \}\>\>\>
|
|
200
200
|
|
|
201
|
+
##### touch()
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
touch(keyId): Promise<KeyOutcome<void>>;
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Stamp a key's last-used time; refuses `denied` for an unknown key.
|
|
208
|
+
|
|
209
|
+
###### Parameters
|
|
210
|
+
|
|
211
|
+
| Parameter | Type |
|
|
212
|
+
| --------- | -------- |
|
|
213
|
+
| `keyId` | `string` |
|
|
214
|
+
|
|
215
|
+
###### Returns
|
|
216
|
+
|
|
217
|
+
`Promise`\<`KeyOutcome`\<`void`\>\>
|
|
218
|
+
|
|
201
219
|
##### live()
|
|
202
220
|
|
|
203
221
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/oyster",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Oyster by Fungi: open-source Apps for people and AI agents. Try with one command or run on your own Cloudflare account.",
|
|
6
6
|
"homepage": "https://docs.fungi.computer/oyster",
|
|
@@ -376,19 +376,19 @@
|
|
|
376
376
|
"@fungi.computer/lantern": "0.4.2",
|
|
377
377
|
"@fungi.computer/mycelium": "0.4.7",
|
|
378
378
|
"@fungi.computer/nacre": "0.8.2",
|
|
379
|
-
"@fungi.computer/parakeet": "0.14.
|
|
379
|
+
"@fungi.computer/parakeet": "0.14.1",
|
|
380
380
|
"@fungi.computer/puffball": "0.12.0",
|
|
381
381
|
"@fungi.computer/seam": "0.2.6",
|
|
382
|
-
"@fungi.computer/shiitake": "0.21.
|
|
383
|
-
"@fungi.computer/shiitake-extensions": "0.11.
|
|
382
|
+
"@fungi.computer/shiitake": "0.21.1",
|
|
383
|
+
"@fungi.computer/shiitake-extensions": "0.11.11",
|
|
384
384
|
"@fungi.computer/sigils": "0.3.2",
|
|
385
385
|
"@fungi.computer/sprite": "0.2.2",
|
|
386
386
|
"@fungi.computer/sprite-zdog": "0.3.2",
|
|
387
|
-
"@fungi.computer/veil": "0.8.
|
|
387
|
+
"@fungi.computer/veil": "0.8.2",
|
|
388
388
|
"@fungi.computer/watchdog": "0.1.4",
|
|
389
389
|
"@fungi.computer/whistle": "0.3.0",
|
|
390
390
|
"@fungi.computer/workflows-wire": "0.5.4",
|
|
391
|
-
"@fungi.computer/zookeeper": "0.0.
|
|
391
|
+
"@fungi.computer/zookeeper": "0.0.43",
|
|
392
392
|
"@jellybrick/dbus-next": "0.11.4",
|
|
393
393
|
"@modelcontextprotocol/server": "2.0.0",
|
|
394
394
|
"@msgpack/msgpack": "3.1.3",
|