@voltro/protocol 0.84.0 → 0.86.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +1215 -0
  2. package/README.md +14 -0
  3. package/THIRD-PARTY-NOTICES.md +5 -89
  4. package/dist/apikey.d.ts +32 -34
  5. package/dist/approval.js +64 -0
  6. package/dist/approvalDescriptors.js +26 -0
  7. package/dist/auth.js +369 -0
  8. package/dist/boundedRing.js +27 -0
  9. package/dist/businessRule.js +11 -0
  10. package/dist/connection.js +73 -0
  11. package/dist/devActivity.js +4 -0
  12. package/dist/errorValue.js +21 -0
  13. package/dist/event.js +104 -0
  14. package/dist/idempotency.js +66 -0
  15. package/dist/identity.js +5 -9
  16. package/dist/index.d.ts +1494 -1366
  17. package/dist/index.js +42 -1411
  18. package/dist/inspect.d.ts +88 -88
  19. package/dist/inspect.js +14 -190
  20. package/dist/inspectBackfill.js +52 -0
  21. package/dist/inspectCommandRejection.js +21 -0
  22. package/dist/inspectProjection.js +133 -0
  23. package/dist/inspectStorageProjection.js +86 -0
  24. package/dist/inspectValueIdentity.js +4 -0
  25. package/dist/inspectWorkflowExecution.js +34 -0
  26. package/dist/inspectWorkflowQueuedStart.js +31 -0
  27. package/dist/jsonSchema.js +54 -0
  28. package/dist/jwt.d.ts +32 -34
  29. package/dist/outbox.js +10 -0
  30. package/dist/pairing.js +75 -0
  31. package/dist/plugin.js +61 -0
  32. package/dist/pluginNaming.js +32 -0
  33. package/dist/procedure.js +262 -0
  34. package/dist/publicApi.js +344 -0
  35. package/dist/reactivityChannel.js +34 -0
  36. package/dist/rest.d.ts +105 -57
  37. package/dist/rest.js +259 -437
  38. package/dist/restFormat.js +163 -0
  39. package/dist/rowEquality.js +31 -0
  40. package/dist/rowPatch.js +182 -0
  41. package/dist/schemaShape.js +67 -0
  42. package/dist/scopes.js +240 -0
  43. package/dist/serverErrorBus.js +15 -0
  44. package/dist/serviceCall.js +14 -0
  45. package/dist/session.d.ts +90 -96
  46. package/dist/session.js +13 -15
  47. package/dist/{sessionHeader-DriTZhmv.js → sessionHeader.js} +1 -1
  48. package/dist/storageAccess.js +14 -0
  49. package/dist/storeErrors.js +66 -0
  50. package/dist/storeScreenshots.js +90 -0
  51. package/dist/strictInput.js +27 -0
  52. package/dist/subscriptionEvent.js +37 -0
  53. package/dist/tenantSelection.js +40 -0
  54. package/dist/time.js +7 -0
  55. package/dist/undo.js +38 -0
  56. package/dist/validation.js +39 -0
  57. package/dist/webSocketGateway.js +10 -0
  58. package/dist/workflow.js +297 -0
  59. package/dist/workflowAccess.js +61 -0
  60. package/dist/workflowRestart.js +45 -0
  61. package/dist/workflowRetry.js +44 -0
  62. package/dist/workflowStartOutcome.js +30 -0
  63. package/package.json +4 -8
  64. package/dist/restFormat-EZ8k9ZcQ.js +0 -304
  65. package/dist/scopes-Di756ENh.js +0 -518
@@ -0,0 +1,15 @@
1
+ //#region src/serverErrorBus.ts
2
+ var e = (e) => {
3
+ let t = e.error, n = t instanceof Error ? t.name : typeof t?._tag == "string" ? String(t._tag) : "Error", r = [e.name === void 0 ? e.source : `${e.source} '${e.name}'`, ...typeof e.fields?.runId == "string" ? [`run ${e.fields.runId}`] : []].join(", "), i = /* @__PURE__ */ Error(`[message withheld: ${r} is declared encrypted — read it where the run is shown]`);
4
+ i.name = n;
5
+ let a = t instanceof Error && typeof t.stack == "string" ? t.stack : "", o = a.search(/^\s+at /m);
6
+ return i.stack = `${n}: ${i.message}${o === -1 ? "" : `\n${a.slice(o)}`}`, i;
7
+ }, t = /* @__PURE__ */ new Set(), n = (e) => {
8
+ for (let n of t) try {
9
+ n(e);
10
+ } catch {}
11
+ }, r = (e) => (t.add(e), () => {
12
+ t.delete(e);
13
+ });
14
+ //#endregion
15
+ export { n as publishServerError, r as subscribeServerErrors, e as withheldServerError };
@@ -0,0 +1,14 @@
1
+ import { Schema as e } from "effect";
2
+ //#region src/serviceCall.ts
3
+ var t = class extends e.TaggedError()("ApiUnavailable", {
4
+ api: e.String,
5
+ tag: e.String,
6
+ reason: e.Literals([
7
+ "timeout",
8
+ "transport",
9
+ "closed"
10
+ ]),
11
+ message: e.String
12
+ }) {}, n = (e) => typeof e == "object" && !!e && e._tag === "ApiUnavailable";
13
+ //#endregion
14
+ export { t as ApiUnavailable, n as isApiUnavailable };
package/dist/session.d.ts CHANGED
@@ -170,53 +170,51 @@ export declare type SessionPayload = typeof SessionPayload_2.Type;
170
170
 
171
171
  declare const SessionPayload_2: Schema.Struct<{
172
172
  /** Payload format version. Required and pinned — see the header. */
173
- v: Schema.Literal<[2]>;
173
+ readonly v: Schema.Literal<2>;
174
174
  /** WHO, never WHAT-THEY-MAY-DO. `SubjectIdentity` has no `scopes` field. */
175
- subject: Schema.Union<[Schema.Struct<{
176
- type: Schema.Literal<["user"]>;
177
- id: typeof Schema.String;
178
- tenantId: typeof Schema.String;
179
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
175
+ readonly subject: Schema.Union<readonly [Schema.Struct<{
176
+ readonly type: Schema.Literal<"user">;
177
+ readonly id: Schema.String;
178
+ readonly tenantId: Schema.String;
179
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
180
180
  }>, Schema.Struct<{
181
- type: Schema.Literal<["apiKey"]>;
182
- id: typeof Schema.String;
183
- tenantId: typeof Schema.String;
184
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
181
+ readonly type: Schema.Literal<"apiKey">;
182
+ readonly id: Schema.String;
183
+ readonly tenantId: Schema.String;
184
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
185
185
  }>, Schema.Struct<{
186
- type: Schema.Literal<["serviceAccount"]>;
187
- id: typeof Schema.String;
188
- tenantId: typeof Schema.String;
189
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
190
- auditActorId: Schema.optionalWith<Schema.NullOr<typeof Schema.String>, {
191
- exact: true;
192
- }>;
186
+ readonly type: Schema.Literal<"serviceAccount">;
187
+ readonly id: Schema.String;
188
+ readonly tenantId: Schema.String;
189
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
190
+ readonly auditActorId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
193
191
  }>, Schema.Struct<{
194
- type: Schema.Literal<["anonymous"]>;
195
- id: typeof Schema.Null;
196
- tenantId: Schema.NullOr<typeof Schema.String>;
197
- credentialRejected: Schema.optional<typeof Schema.String>;
192
+ readonly type: Schema.Literal<"anonymous">;
193
+ readonly id: Schema.Null;
194
+ readonly tenantId: Schema.NullOr<Schema.String>;
195
+ readonly credentialRejected: Schema.optional<Schema.String>;
198
196
  }>, Schema.Struct<{
199
- type: Schema.Literal<["system"]>;
200
- id: typeof Schema.String;
201
- tenantId: typeof Schema.Null;
202
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
197
+ readonly type: Schema.Literal<"system">;
198
+ readonly id: Schema.String;
199
+ readonly tenantId: Schema.Null;
200
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
203
201
  }>, Schema.Struct<{
204
- type: Schema.Literal<["service"]>;
205
- id: typeof Schema.String;
206
- tenantId: typeof Schema.Null;
207
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
208
- service: typeof Schema.String;
202
+ readonly type: Schema.Literal<"service">;
203
+ readonly id: Schema.String;
204
+ readonly tenantId: Schema.Null;
205
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
206
+ readonly service: Schema.String;
209
207
  }>]>;
210
208
  /** Unix seconds when this session expires. Verify rejects past expiry. */
211
- exp: typeof Schema.Number;
209
+ readonly exp: Schema.Number;
212
210
  /** Unix seconds when this session was issued. Drives sliding-window
213
211
  * auto-renewal: verify signals a renew once `now - iat` passes the
214
212
  * renewal threshold (default 70% of the session's lifetime). */
215
- iat: typeof Schema.Number;
213
+ readonly iat: Schema.Number;
216
214
  /** Key id of the signing secret. Stamped from the current key on sign;
217
215
  * read on verify to pick which secret to check first. Absent on
218
216
  * values minted with a bare-string secret (single-key path). */
219
- kid: Schema.optional<typeof Schema.String>;
217
+ readonly kid: Schema.optional<Schema.String>;
220
218
  }>;
221
219
 
222
220
  declare type SessionPayload = typeof SessionPayload_2.Type;
@@ -278,33 +276,31 @@ export declare interface SignOptions {
278
276
  */
279
277
  export declare const signSession: (subject: Subject | SubjectIdentity, secret: string | KeyedSecret, options?: SignOptions) => string;
280
278
 
281
- declare const Subject: Schema.Union<[Schema.Struct<{
282
- type: Schema.Literal<["user"]>;
283
- id: typeof Schema.String;
284
- tenantId: typeof Schema.String;
285
- scopes: Schema.optional<Schema.Array$<typeof Schema.String>>;
286
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
279
+ declare const Subject: Schema.Union<readonly [Schema.Struct<{
280
+ readonly type: Schema.Literal<"user">;
281
+ readonly id: Schema.String;
282
+ readonly tenantId: Schema.String;
283
+ readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
284
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
287
285
  }>, Schema.Struct<{
288
- type: Schema.Literal<["apiKey"]>;
289
- id: typeof Schema.String;
290
- tenantId: typeof Schema.String;
291
- scopes: Schema.optional<Schema.Array$<typeof Schema.String>>;
292
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
286
+ readonly type: Schema.Literal<"apiKey">;
287
+ readonly id: Schema.String;
288
+ readonly tenantId: Schema.String;
289
+ readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
290
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
293
291
  }>, Schema.Struct<{
294
- type: Schema.Literal<["serviceAccount"]>;
295
- id: typeof Schema.String;
296
- tenantId: typeof Schema.String;
292
+ readonly type: Schema.Literal<"serviceAccount">;
293
+ readonly id: Schema.String;
294
+ readonly tenantId: Schema.String;
297
295
  /** Application actor used for audit columns; null means machine work with
298
296
  * no application actor. Identity only, never a permission grant. */
299
- auditActorId: Schema.optionalWith<Schema.NullOr<typeof Schema.String>, {
300
- exact: true;
301
- }>;
302
- scopes: Schema.optional<Schema.Array$<typeof Schema.String>>;
303
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
297
+ readonly auditActorId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
298
+ readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
299
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
304
300
  }>, Schema.Struct<{
305
- type: Schema.Literal<["anonymous"]>;
306
- id: typeof Schema.Null;
307
- tenantId: Schema.NullOr<typeof Schema.String>;
301
+ readonly type: Schema.Literal<"anonymous">;
302
+ readonly id: Schema.Null;
303
+ readonly tenantId: Schema.NullOr<Schema.String>;
308
304
  /**
309
305
  * Set when this caller PRESENTED a credential and it was rejected — an
310
306
  * expired token above all. Absent when they presented none.
@@ -321,47 +317,45 @@ declare const Subject: Schema.Union<[Schema.Struct<{
321
317
  * must not break an `openAccess` procedure that needs no session at all. The
322
318
  * fact travels, and only a guard that actually refuses spends it.
323
319
  */
324
- credentialRejected: Schema.optional<typeof Schema.String>;
320
+ readonly credentialRejected: Schema.optional<Schema.String>;
325
321
  }>, Schema.Struct<{
326
- type: Schema.Literal<["system"]>;
327
- id: typeof Schema.String;
328
- tenantId: typeof Schema.Null;
329
- scopes: Schema.optional<Schema.Array$<typeof Schema.String>>;
330
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
322
+ readonly type: Schema.Literal<"system">;
323
+ readonly id: Schema.String;
324
+ readonly tenantId: Schema.Null;
325
+ readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
326
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
331
327
  }>, Schema.Struct<{
332
- type: Schema.Literal<["service"]>;
333
- id: typeof Schema.String;
328
+ readonly type: Schema.Literal<"service">;
329
+ readonly id: Schema.String;
334
330
  /** The calling app's name, as the callee lists it in `serviceCallers`. */
335
- service: typeof Schema.String;
336
- tenantId: typeof Schema.Null;
337
- scopes: Schema.optional<Schema.Array$<typeof Schema.String>>;
338
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
331
+ readonly service: Schema.String;
332
+ readonly tenantId: Schema.Null;
333
+ readonly scopes: Schema.optional<Schema.$Array<Schema.String>>;
334
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
339
335
  }>]>;
340
336
 
341
337
  declare type Subject = typeof Subject.Type;
342
338
 
343
- declare const SubjectIdentity: Schema.Union<[Schema.Struct<{
344
- type: Schema.Literal<["user"]>;
345
- id: typeof Schema.String;
346
- tenantId: typeof Schema.String;
347
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
339
+ declare const SubjectIdentity: Schema.Union<readonly [Schema.Struct<{
340
+ readonly type: Schema.Literal<"user">;
341
+ readonly id: Schema.String;
342
+ readonly tenantId: Schema.String;
343
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
348
344
  }>, Schema.Struct<{
349
- type: Schema.Literal<["apiKey"]>;
350
- id: typeof Schema.String;
351
- tenantId: typeof Schema.String;
352
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
345
+ readonly type: Schema.Literal<"apiKey">;
346
+ readonly id: Schema.String;
347
+ readonly tenantId: Schema.String;
348
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
353
349
  }>, Schema.Struct<{
354
- type: Schema.Literal<["serviceAccount"]>;
355
- id: typeof Schema.String;
356
- tenantId: typeof Schema.String;
357
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
358
- auditActorId: Schema.optionalWith<Schema.NullOr<typeof Schema.String>, {
359
- exact: true;
360
- }>;
350
+ readonly type: Schema.Literal<"serviceAccount">;
351
+ readonly id: Schema.String;
352
+ readonly tenantId: Schema.String;
353
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
354
+ readonly auditActorId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
361
355
  }>, Schema.Struct<{
362
- type: Schema.Literal<["anonymous"]>;
363
- id: typeof Schema.Null;
364
- tenantId: Schema.NullOr<typeof Schema.String>;
356
+ readonly type: Schema.Literal<"anonymous">;
357
+ readonly id: Schema.Null;
358
+ readonly tenantId: Schema.NullOr<Schema.String>;
365
359
  /**
366
360
  * Set when this caller PRESENTED a credential and it was rejected — an
367
361
  * expired token above all. Absent when they presented none.
@@ -378,18 +372,18 @@ declare const SubjectIdentity: Schema.Union<[Schema.Struct<{
378
372
  * must not break an `openAccess` procedure that needs no session at all. The
379
373
  * fact travels, and only a guard that actually refuses spends it.
380
374
  */
381
- credentialRejected: Schema.optional<typeof Schema.String>;
375
+ readonly credentialRejected: Schema.optional<Schema.String>;
382
376
  }>, Schema.Struct<{
383
- type: Schema.Literal<["system"]>;
384
- id: typeof Schema.String;
385
- tenantId: typeof Schema.Null;
386
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
377
+ readonly type: Schema.Literal<"system">;
378
+ readonly id: Schema.String;
379
+ readonly tenantId: Schema.Null;
380
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
387
381
  }>, Schema.Struct<{
388
- type: Schema.Literal<["service"]>;
389
- id: typeof Schema.String;
390
- tenantId: typeof Schema.Null;
391
- metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
392
- service: typeof Schema.String;
382
+ readonly type: Schema.Literal<"service">;
383
+ readonly id: Schema.String;
384
+ readonly tenantId: Schema.Null;
385
+ readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
386
+ readonly service: Schema.String;
393
387
  }>]>;
394
388
 
395
389
  declare type SubjectIdentity = typeof SubjectIdentity.Type;
package/dist/session.js CHANGED
@@ -1,12 +1,13 @@
1
- import { j as e, nt as t, z as n } from "./scopes-Di756ENh.js";
2
- import { n as r, t as i } from "./sessionHeader-DriTZhmv.js";
1
+ import { SubjectIdentity as e, subjectIdentity as t } from "./auth.js";
2
+ import { subjectScopes as n } from "./scopes.js";
3
+ import { SESSION_HEADER_NAME as r, sessionValueFromHeaders as i } from "./sessionHeader.js";
3
4
  import { Schema as a } from "effect";
4
5
  import { createHmac as o, timingSafeEqual as s } from "node:crypto";
5
6
  import { createLogger as c } from "@voltro/logger";
6
7
  //#region src/session.ts
7
8
  var l = c({ scope: "@voltro/protocol:session" }), u = 2, d = a.Struct({
8
9
  v: a.Literal(2),
9
- subject: n,
10
+ subject: e,
10
11
  exp: a.Number,
11
12
  iat: a.Number,
12
13
  kid: a.optional(a.String)
@@ -39,14 +40,14 @@ var l = c({ scope: "@voltro/protocol:session" }), u = 2, d = a.Struct({
39
40
  }, T = 604800, E = .7, D = (e, t) => C(o("sha256", t).update(e).digest()), O = (e) => typeof e == "string" ? {
40
41
  kid: "k0",
41
42
  secret: e
42
- } : e, k = (n, r, i = {}) => {
43
+ } : e, k = (e, r, i = {}) => {
43
44
  let a = O(r);
44
45
  if (!a.secret) throw Error("signSession: secret must be a non-empty string");
45
- let o = e(n);
46
- if (o.length > 0) throw Error(`signSession: refusing to mint a session cookie for a ${n.type} subject carrying ${o.length} scope(s) (${o.slice(0, 5).join(", ")}). A session cookie carries IDENTITY only — authority is resolved per request, so that removing a role takes effect on the session that already exists instead of in up to 7 days. Mint the session from the identity and move the scopes into the auth.resolveScopes resolver, which runs on every request and can be invalidated the moment a role changes.`);
46
+ let o = n(e);
47
+ if (o.length > 0) throw Error(`signSession: refusing to mint a session cookie for a ${e.type} subject carrying ${o.length} scope(s) (${o.slice(0, 5).join(", ")}). A session cookie carries IDENTITY only — authority is resolved per request, so that removing a role takes effect on the session that already exists instead of in up to 7 days. Mint the session from the identity and move the scopes into the auth.resolveScopes resolver, which runs on every request and can be invalidated the moment a role changes.`);
47
48
  let s = i.ttlSeconds ?? T, c = Math.floor((i.now ?? Date.now)() / 1e3), l = {
48
49
  v: 2,
49
- subject: t(n),
50
+ subject: t(e),
50
51
  exp: c + s,
51
52
  iat: c,
52
53
  ...typeof r == "string" ? {} : { kid: a.kid }
@@ -112,19 +113,16 @@ var l = c({ scope: "@voltro/protocol:session" }), u = 2, d = a.Struct({
112
113
  e >= 0 && r.splice(e, 1);
113
114
  }
114
115
  return r.push(`SameSite=${n.sameSite ?? "Lax"}`), (n.secure ?? !0) && r.push("Secure"), n.domain && r.push(`Domain=${n.domain}`), r.join("; ");
115
- }, L = process.env.VOLTRO_SESSION_COOKIE ?? "voltro:session", R = (e, t = L) => r(e, t, F), z = (e) => {
116
- let t = r(e, L, F);
116
+ }, L = process.env.VOLTRO_SESSION_COOKIE ?? "voltro:session", R = (e, t = L) => i(e, t, F), z = (e) => {
117
+ let t = i(e, L, F);
117
118
  if (!t) return;
118
119
  let n = v();
119
- if (!n) {
120
- V();
121
- return;
122
- }
123
- return M(t, n)?.exp;
120
+ if (!n) V();
121
+ else return M(t, n)?.exp;
124
122
  }, B = !1, V = () => {
125
123
  B || (B = !0, l.error("a `voltro:session` cookie was presented but VOLTRO_SESSION_SECRET is not set — the session cannot be verified, so no credential-expiry bound is imposed and realtime subscriptions on this connection will not be cut off when the session expires. Set VOLTRO_SESSION_SECRET (`voltro secret generate session`); `voltro dev` mints one, `voltro serve` refuses to boot without one.", { cookieName: L }));
126
124
  }, H = () => {
127
125
  B = !1;
128
126
  };
129
127
  //#endregion
130
- export { p as DEFAULT_PREVIOUS_SESSION_KID, f as DEFAULT_SESSION_KID, y as MIN_SESSION_SECRET_LENGTH, L as SESSION_COOKIE_NAME, i as SESSION_HEADER_NAME, u as SESSION_PAYLOAD_VERSION, b as assertProductionSessionSecret, I as buildSetCookie, P as checkBearer, F as readCookie, R as readSessionValue, H as resetSessionSecretWarningLatch, v as resolveOptionalSessionSecrets, h as resolveSessionSecret, g as resolveSessionSecrets, z as sessionExpiryFromHeaders, k as signSession, N as timingSafeStringEqual, j as verifySession, M as verifySessionKeyed };
128
+ export { p as DEFAULT_PREVIOUS_SESSION_KID, f as DEFAULT_SESSION_KID, y as MIN_SESSION_SECRET_LENGTH, L as SESSION_COOKIE_NAME, r as SESSION_HEADER_NAME, u as SESSION_PAYLOAD_VERSION, b as assertProductionSessionSecret, I as buildSetCookie, P as checkBearer, F as readCookie, R as readSessionValue, H as resetSessionSecretWarningLatch, v as resolveOptionalSessionSecrets, h as resolveSessionSecret, g as resolveSessionSecrets, z as sessionExpiryFromHeaders, k as signSession, N as timingSafeStringEqual, j as verifySession, M as verifySessionKeyed };
@@ -4,4 +4,4 @@ var e = "x-voltro-session", t = (e, t, n) => {
4
4
  return r !== void 0 && r.length > 0 ? r : n(e.cookie ?? e.Cookie, t);
5
5
  };
6
6
  //#endregion
7
- export { t as n, e as t };
7
+ export { e as SESSION_HEADER_NAME, t as sessionValueFromHeaders };
@@ -0,0 +1,14 @@
1
+ import { Schema as e } from "effect";
2
+ //#region src/storageAccess.ts
3
+ var t = e.Array(e.String).pipe(e.check(e.isMaxLength(64))), n = e.Struct({
4
+ owner: e.optional(e.Boolean),
5
+ roles: e.optional(t),
6
+ groups: e.optional(t),
7
+ scopes: e.optional(t),
8
+ tenant: e.optional(e.Boolean),
9
+ apiKey: e.optional(e.Boolean),
10
+ password: e.optional(e.Boolean),
11
+ guard: e.optional(e.String)
12
+ }), r = e.Array(n).pipe(e.check(e.isMaxLength(32)));
13
+ //#endregion
14
+ export { r as StorageAccessPolicySchema, n as StorageAccessRuleSchema };
@@ -0,0 +1,66 @@
1
+ import { Schema as e } from "effect";
2
+ //#region src/storeErrors.ts
3
+ var t = class extends e.TaggedError()("TenantScopeViolation", {
4
+ table: e.String,
5
+ reason: e.String
6
+ }) {}, n = class extends e.TaggedError()("StoreOperationFailed", {
7
+ operation: e.String,
8
+ table: e.String,
9
+ cause: e.String
10
+ }) {
11
+ get message() {
12
+ return `${this.operation} on '${this.table}' failed: ${this.cause}`;
13
+ }
14
+ }, r = class extends e.TaggedError()("NoRowFound", {
15
+ table: e.String,
16
+ found: e.Number
17
+ }) {
18
+ get message() {
19
+ return this.found === 0 ? `expected exactly one row in '${this.table}', found none` : `expected exactly one row in '${this.table}', found more than one`;
20
+ }
21
+ }, i = class extends e.TaggedError()("TableValidationFailed", {
22
+ table: e.String,
23
+ summary: e.String,
24
+ issues: e.Array(e.Struct({
25
+ path: e.String,
26
+ message: e.String
27
+ }))
28
+ }) {
29
+ get message() {
30
+ return this.summary;
31
+ }
32
+ }, a = class extends e.TaggedError()("TenantRowNotFound", {
33
+ table: e.String,
34
+ id: e.String,
35
+ reason: e.String
36
+ }) {}, o = class extends e.TaggedError()("ServerOnlyColumnWrite", {
37
+ table: e.String,
38
+ columns: e.Array(e.String)
39
+ }) {}, s = class extends e.TaggedError()("ConstraintViolation", {
40
+ kind: e.Literals([
41
+ "foreignKey",
42
+ "foreignKeyInUse",
43
+ "unique",
44
+ "notNull",
45
+ "check"
46
+ ]),
47
+ table: e.String,
48
+ operation: e.String,
49
+ constraint: e.optional(e.String),
50
+ column: e.optional(e.String),
51
+ detail: e.optional(e.String)
52
+ }) {
53
+ get message() {
54
+ if (this.detail !== void 0) return this.detail;
55
+ let e = this.constraint ?? this.column, t = e === void 0 ? `on ${this.table}` : `${e} on ${this.table}`;
56
+ switch (this.kind) {
57
+ case "foreignKey": return `foreign key ${t}: the referenced row does not exist`;
58
+ case "foreignKeyInUse": return `foreign key ${t}: the row is still referenced by other rows`;
59
+ case "unique": return `unique constraint ${t}: a row with this value already exists`;
60
+ case "notNull": return `not-null constraint ${t}: the column requires a value`;
61
+ case "check": return `check constraint ${t}: the row does not satisfy it`;
62
+ }
63
+ }
64
+ };
65
+ //#endregion
66
+ export { s as ConstraintViolation, r as NoRowFound, o as ServerOnlyColumnWrite, n as StoreOperationFailed, i as TableValidationFailed, a as TenantRowNotFound, t as TenantScopeViolation };
@@ -0,0 +1,90 @@
1
+ //#region src/storeScreenshots.ts
2
+ var e = [
3
+ "app-store",
4
+ "play",
5
+ "mac-app-store",
6
+ "microsoft-store"
7
+ ], t = [
8
+ {
9
+ name: "iphone-6.7",
10
+ label: "iPhone 6.7″ — 1290×2796",
11
+ kind: "phone",
12
+ viewport: {
13
+ width: 430,
14
+ height: 932
15
+ },
16
+ deviceScaleFactor: 3,
17
+ stores: ["app-store"]
18
+ },
19
+ {
20
+ name: "iphone-6.5",
21
+ label: "iPhone 6.5″ — 1242×2688",
22
+ kind: "phone",
23
+ viewport: {
24
+ width: 414,
25
+ height: 896
26
+ },
27
+ deviceScaleFactor: 3,
28
+ stores: ["app-store"]
29
+ },
30
+ {
31
+ name: "ipad-12.9",
32
+ label: "iPad 12.9″ — 2048×2732",
33
+ kind: "tablet",
34
+ viewport: {
35
+ width: 1024,
36
+ height: 1366
37
+ },
38
+ deviceScaleFactor: 2,
39
+ stores: ["app-store"]
40
+ },
41
+ {
42
+ name: "android-phone",
43
+ label: "Android phone — 1080×2160",
44
+ kind: "phone",
45
+ viewport: {
46
+ width: 360,
47
+ height: 720
48
+ },
49
+ deviceScaleFactor: 3,
50
+ stores: ["play"]
51
+ },
52
+ {
53
+ name: "android-tablet-10",
54
+ label: "Android 10″ tablet — 1600×2560",
55
+ kind: "tablet",
56
+ viewport: {
57
+ width: 800,
58
+ height: 1280
59
+ },
60
+ deviceScaleFactor: 2,
61
+ stores: ["play"]
62
+ },
63
+ {
64
+ name: "mac",
65
+ label: "Mac — 2880×1800",
66
+ kind: "desktop",
67
+ viewport: {
68
+ width: 1440,
69
+ height: 900
70
+ },
71
+ deviceScaleFactor: 2,
72
+ stores: ["mac-app-store"]
73
+ },
74
+ {
75
+ name: "windows",
76
+ label: "Windows — 1366×768",
77
+ kind: "desktop",
78
+ viewport: {
79
+ width: 1366,
80
+ height: 768
81
+ },
82
+ deviceScaleFactor: 1,
83
+ stores: ["microsoft-store"]
84
+ }
85
+ ], n = t.map((e) => e.name), r = (e) => t.find((t) => t.name === e), i = (e) => ({
86
+ width: e.viewport.width * e.deviceScaleFactor,
87
+ height: e.viewport.height * e.deviceScaleFactor
88
+ }), a = (e) => t.filter((t) => t.stores.includes(e));
89
+ //#endregion
90
+ export { t as STORE_SCREENSHOT_PRESETS, n as STORE_SCREENSHOT_PRESET_NAMES, e as STORE_SCREENSHOT_STORES, i as storeScreenshotPixels, r as storeScreenshotPreset, a as storeScreenshotPresetsFor };
@@ -0,0 +1,27 @@
1
+ import { Effect as e, Schema as t, SchemaIssue as n } from "effect";
2
+ import * as r from "effect/SchemaAST";
3
+ //#region src/strictInput.ts
4
+ var i = (e, t) => {
5
+ let n = `${e ?? "this procedure"} input`;
6
+ return t === !0 ? `${n} (guarded — the guard did NOT run: the payload failed to decode first, so this says nothing about access)` : n;
7
+ }, a = n.makeFormatterDefault(), o = (e) => t.Never.annotate({ message: e.size === 0 ? "is unexpected: the input declares no keys" : `is unexpected: the input declares ${[...e].map(String).join(", ")}` }).ast, s = (e) => t.String.check(t.makeFilter((t) => e.has(t) ? "a declared key" : void 0)).ast, c = (e, t = /* @__PURE__ */ new Map()) => {
8
+ let n = t.get(e);
9
+ if (n !== void 0) return n;
10
+ let r = l(e, t);
11
+ return t.set(e, r), r;
12
+ }, l = (e, n) => {
13
+ if (e.encoding !== void 0) {
14
+ let i = r.toEncoded(e), a = c(i, n);
15
+ return a === i ? e : t.make(a).pipe(t.decodeTo(t.make(e))).ast;
16
+ }
17
+ if (r.isObjects(e)) {
18
+ let t = e.propertySignatures.map((e) => new r.PropertySignature(e.name, c(e.type, n))), i = new Set(t.map((e) => e.name)), a = e.indexSignatures.length > 0 ? e.indexSignatures.map((e) => new r.IndexSignature(e.parameter, c(e.type, n))) : [new r.IndexSignature(s(i), o(i))];
19
+ return new r.Objects(t, a, e.annotations, e.checks, void 0, e.context);
20
+ }
21
+ return r.isArrays(e) ? new r.Arrays(e.isMutable, e.elements.map((e) => c(e, n)), e.rest.map((e) => c(e, n)), e.annotations, e.checks, void 0, e.context) : r.isUnion(e) ? new r.Union(e.types.map((e) => c(e, n)), e.options, e.annotations, e.checks, void 0, e.context) : r.isSuspend(e) ? new r.Suspend(() => c(e.thunk(), n), e.annotations, e.checks, void 0, e.context) : e;
22
+ }, u = (r, o, s) => {
23
+ let l = i(o, s);
24
+ return t.make(c(r.ast)).pipe(t.middlewareDecoding((t) => e.catch(t, (t) => e.fail(new n.InvalidValue({ message: `${l}\n${a(t)}` })))));
25
+ };
26
+ //#endregion
27
+ export { i as inputLabel, u as strictInput };
@@ -0,0 +1,37 @@
1
+ import { rowPatchSchema as e } from "./rowPatch.js";
2
+ import { Schema as t, SchemaGetter as n } from "effect";
3
+ //#region src/subscriptionEvent.ts
4
+ var r = t.Json.pipe(t.decodeTo(t.Unknown, {
5
+ decode: n.passthrough({ strict: !1 }),
6
+ encode: n.transform((e) => JSON.parse(JSON.stringify(e)))
7
+ })), i = (n) => t.Union([
8
+ t.Struct({
9
+ _tag: t.Literal("snapshot"),
10
+ revision: t.Number,
11
+ data: n,
12
+ computed: t.optional(t.Boolean),
13
+ reconciles: t.optional(t.String)
14
+ }),
15
+ t.Struct({
16
+ _tag: t.Literal("delta"),
17
+ revision: t.Number,
18
+ emittedAt: t.Number,
19
+ patch: e
20
+ }),
21
+ t.Struct({
22
+ _tag: t.Literal("error"),
23
+ error: r,
24
+ revision: t.optional(t.Number)
25
+ })
26
+ ]), a = (e, t, n) => {
27
+ if (!t || typeof t != "object" || !("_tag" in t)) return t;
28
+ let r = t;
29
+ switch (r._tag) {
30
+ case "snapshot": return r.data;
31
+ case "error": throw r.error === void 0 ? Error(`${n} ${e}: the rpc refused without an error value`) : r.error;
32
+ case "delta": throw Error(`${n} ${e}: received a 'delta' as the first event, which should be impossible — a subscription always opens with a snapshot. This is a framework bug.`);
33
+ default: return t;
34
+ }
35
+ };
36
+ //#endregion
37
+ export { a as firstEventValue, i as subscriptionEvent };
@@ -0,0 +1,40 @@
1
+ import { Schema as e } from "effect";
2
+ //#region src/tenantSelection.ts
3
+ var t = class extends e.TaggedError()("RequestedTenantRefused", { reason: e.Literals([
4
+ "target-unavailable",
5
+ "invalid-target",
6
+ "memberships-unavailable",
7
+ "not-a-member",
8
+ "subject-has-no-tenant"
9
+ ]) }) {}, n = (e) => e.type === "user" || e.type === "apiKey" || e.type === "serviceAccount", r = class extends e.TaggedError()("TenantSelectionRefused", {
10
+ subjectType: e.String,
11
+ subjectId: e.NullOr(e.String),
12
+ tenantId: e.String,
13
+ reason: e.Literals(["not-a-member", "subject-has-no-tenant"])
14
+ }) {}, i = (e, t, i) => {
15
+ if (!n(e)) throw new r({
16
+ subjectType: e.type,
17
+ subjectId: e.id,
18
+ tenantId: t,
19
+ reason: "subject-has-no-tenant"
20
+ });
21
+ if (!i.some((e) => e.tenantId === t)) throw new r({
22
+ subjectType: e.type,
23
+ subjectId: e.id,
24
+ tenantId: t,
25
+ reason: "not-a-member"
26
+ });
27
+ return {
28
+ ...e,
29
+ tenantId: t,
30
+ metadata: {
31
+ ...e.metadata,
32
+ memberships: i.map((e) => e.role === void 0 ? { tenantId: e.tenantId } : {
33
+ tenantId: e.tenantId,
34
+ role: e.role
35
+ })
36
+ }
37
+ };
38
+ };
39
+ //#endregion
40
+ export { t as RequestedTenantRefused, r as TenantSelectionRefused, n as isTenantSelectable, i as selectSubjectTenant };
package/dist/time.js ADDED
@@ -0,0 +1,7 @@
1
+ //#region src/time.ts
2
+ var e = (e) => {
3
+ let t = e instanceof Date ? e.getTime() : typeof e == "number" ? e : typeof e == "string" ? new Date(e).getTime() : 0;
4
+ return Number.isNaN(t) ? 0 : t;
5
+ };
6
+ //#endregion
7
+ export { e as tsMs };