@fungi.computer/oyster 0.19.2 → 0.19.4

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 CHANGED
@@ -5,8 +5,8 @@ export declare const ownerKeyCookieName = "oyster_session";
5
5
  /** Marks a browser that has signed in here before; it carries no authority. */
6
6
  export declare const returningCookieName = "oyster_returning";
7
7
  /**
8
- * Single-owner sign-in: a bearer token or a session cookie holding the
9
- * owner key's digest. The key itself is never stored in the browser.
8
+ * Single-owner sign-in: a bearer token, a Git Basic-auth password, or a session
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
12
  /** The owner key, or a named key admitted as its canonical Team-key actor. */
package/dist/auth.js CHANGED
@@ -20,8 +20,8 @@ async function constantTimeEqual(a, b) {
20
20
  return difference === 0;
21
21
  }
22
22
  /**
23
- * Single-owner sign-in: a bearer token or a session cookie holding the
24
- * owner key's digest. The key itself is never stored in the browser.
23
+ * Single-owner sign-in: a bearer token, a Git Basic-auth password, or a session
24
+ * cookie holding the owner key's digest. The key is never stored in the browser.
25
25
  */
26
26
  export function ownerKeyAuth(ownerKey, ownerId = "owner") {
27
27
  if (ownerKey.length < 24)
@@ -41,6 +41,13 @@ export function ownerKeyAuth(ownerKey, ownerId = "owner") {
41
41
  return (await constantTimeEqual(authorization.slice(7), ownerKey))
42
42
  ? owner
43
43
  : { kind: "refused", status: 401 };
44
+ if (authorization?.startsWith("Basic ") === true) {
45
+ const presented = presentedGitKey(request);
46
+ return presented.kind === "key" &&
47
+ (await constantTimeEqual(presented.value, ownerKey))
48
+ ? owner
49
+ : { kind: "refused", status: 401 };
50
+ }
44
51
  const cookie = (request.headers.get("Cookie") ?? "")
45
52
  .split(";")
46
53
  .map((part) => part.trim())
@@ -66,7 +66,16 @@ export const BACKEND_CONSTRUCTION_FACET = "candidate";
66
66
  * authority are never copied. A unique Loader ID isolates candidate globals.
67
67
  * No invocation frame or guestEnv factory is accepted.
68
68
  */
69
- export async function checkBackendConstruction(ctx, loader, artifact, limits, priorStateSchema) {
69
+ export function checkBackendConstruction(ctx, loader, artifact, limits, priorStateSchema) {
70
+ // One disposable facet per host: overlapping probes would delete each
71
+ // other's candidate ("Facet was deleted."), so each waits for the last.
72
+ const previous = probesInFlight.get(ctx.facets) ?? Promise.resolve();
73
+ const probe = previous.then(() => constructOnce(ctx, loader, artifact, limits, priorStateSchema));
74
+ probesInFlight.set(ctx.facets, probe.then(() => undefined, () => undefined));
75
+ return probe;
76
+ }
77
+ const probesInFlight = new WeakMap();
78
+ async function constructOnce(ctx, loader, artifact, limits, priorStateSchema) {
70
79
  if (loader === undefined)
71
80
  throw new BootGateError("boot_runner_unavailable");
72
81
  const name = BACKEND_CONSTRUCTION_FACET;
package/docs/api/auth.md CHANGED
@@ -36,8 +36,8 @@ Marks a browser that has signed in here before; it carries no authority.
36
36
  function ownerKeyAuth(ownerKey, ownerId?): OysterAuth;
37
37
  ```
38
38
 
39
- Single-owner sign-in: a bearer token or a session cookie holding the owner key's
40
- digest. The key itself is never stored in the browser.
39
+ Single-owner sign-in: a bearer token, a Git Basic-auth password, or a session
40
+ cookie holding the owner key's digest. The key is never stored in the browser.
41
41
 
42
42
  #### Parameters
43
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/oyster",
3
- "version": "0.19.2",
3
+ "version": "0.19.4",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Run your own Apps on Cloudflare Workers or celld: installable App Releases, each with its own Durable Object, SQLite database and declared bindings",
6
6
  "type": "module",