@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.
- package/CHANGELOG.md +1215 -0
- package/README.md +14 -0
- package/THIRD-PARTY-NOTICES.md +5 -89
- package/dist/apikey.d.ts +32 -34
- package/dist/approval.js +64 -0
- package/dist/approvalDescriptors.js +26 -0
- package/dist/auth.js +369 -0
- package/dist/boundedRing.js +27 -0
- package/dist/businessRule.js +11 -0
- package/dist/connection.js +73 -0
- package/dist/devActivity.js +4 -0
- package/dist/errorValue.js +21 -0
- package/dist/event.js +104 -0
- package/dist/idempotency.js +66 -0
- package/dist/identity.js +5 -9
- package/dist/index.d.ts +1494 -1366
- package/dist/index.js +42 -1411
- package/dist/inspect.d.ts +88 -88
- package/dist/inspect.js +14 -190
- package/dist/inspectBackfill.js +52 -0
- package/dist/inspectCommandRejection.js +21 -0
- package/dist/inspectProjection.js +133 -0
- package/dist/inspectStorageProjection.js +86 -0
- package/dist/inspectValueIdentity.js +4 -0
- package/dist/inspectWorkflowExecution.js +34 -0
- package/dist/inspectWorkflowQueuedStart.js +31 -0
- package/dist/jsonSchema.js +54 -0
- package/dist/jwt.d.ts +32 -34
- package/dist/outbox.js +10 -0
- package/dist/pairing.js +75 -0
- package/dist/plugin.js +61 -0
- package/dist/pluginNaming.js +32 -0
- package/dist/procedure.js +262 -0
- package/dist/publicApi.js +344 -0
- package/dist/reactivityChannel.js +34 -0
- package/dist/rest.d.ts +105 -57
- package/dist/rest.js +259 -437
- package/dist/restFormat.js +163 -0
- package/dist/rowEquality.js +31 -0
- package/dist/rowPatch.js +182 -0
- package/dist/schemaShape.js +67 -0
- package/dist/scopes.js +240 -0
- package/dist/serverErrorBus.js +15 -0
- package/dist/serviceCall.js +14 -0
- package/dist/session.d.ts +90 -96
- package/dist/session.js +13 -15
- package/dist/{sessionHeader-DriTZhmv.js → sessionHeader.js} +1 -1
- package/dist/storageAccess.js +14 -0
- package/dist/storeErrors.js +66 -0
- package/dist/storeScreenshots.js +90 -0
- package/dist/strictInput.js +27 -0
- package/dist/subscriptionEvent.js +37 -0
- package/dist/tenantSelection.js +40 -0
- package/dist/time.js +7 -0
- package/dist/undo.js +38 -0
- package/dist/validation.js +39 -0
- package/dist/webSocketGateway.js +10 -0
- package/dist/workflow.js +297 -0
- package/dist/workflowAccess.js +61 -0
- package/dist/workflowRestart.js +45 -0
- package/dist/workflowRetry.js +44 -0
- package/dist/workflowStartOutcome.js +30 -0
- package/package.json +4 -8
- package/dist/restFormat-EZ8k9ZcQ.js +0 -304
- 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<
|
|
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<
|
|
177
|
-
id:
|
|
178
|
-
tenantId:
|
|
179
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
182
|
-
id:
|
|
183
|
-
tenantId:
|
|
184
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
187
|
-
id:
|
|
188
|
-
tenantId:
|
|
189
|
-
metadata: Schema.optional<Schema
|
|
190
|
-
auditActorId: Schema.
|
|
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<
|
|
195
|
-
id:
|
|
196
|
-
tenantId: Schema.NullOr<
|
|
197
|
-
credentialRejected: Schema.optional<
|
|
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<
|
|
200
|
-
id:
|
|
201
|
-
tenantId:
|
|
202
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
205
|
-
id:
|
|
206
|
-
tenantId:
|
|
207
|
-
metadata: Schema.optional<Schema
|
|
208
|
-
service:
|
|
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:
|
|
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:
|
|
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<
|
|
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<
|
|
283
|
-
id:
|
|
284
|
-
tenantId:
|
|
285
|
-
scopes: Schema.optional<Schema
|
|
286
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
289
|
-
id:
|
|
290
|
-
tenantId:
|
|
291
|
-
scopes: Schema.optional<Schema
|
|
292
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
295
|
-
id:
|
|
296
|
-
tenantId:
|
|
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.
|
|
300
|
-
|
|
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<
|
|
306
|
-
id:
|
|
307
|
-
tenantId: Schema.NullOr<
|
|
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<
|
|
320
|
+
readonly credentialRejected: Schema.optional<Schema.String>;
|
|
325
321
|
}>, Schema.Struct<{
|
|
326
|
-
type: Schema.Literal<
|
|
327
|
-
id:
|
|
328
|
-
tenantId:
|
|
329
|
-
scopes: Schema.optional<Schema
|
|
330
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
333
|
-
id:
|
|
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:
|
|
336
|
-
tenantId:
|
|
337
|
-
scopes: Schema.optional<Schema
|
|
338
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
345
|
-
id:
|
|
346
|
-
tenantId:
|
|
347
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
350
|
-
id:
|
|
351
|
-
tenantId:
|
|
352
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
355
|
-
id:
|
|
356
|
-
tenantId:
|
|
357
|
-
metadata: Schema.optional<Schema
|
|
358
|
-
auditActorId: Schema.
|
|
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<
|
|
363
|
-
id:
|
|
364
|
-
tenantId: Schema.NullOr<
|
|
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<
|
|
375
|
+
readonly credentialRejected: Schema.optional<Schema.String>;
|
|
382
376
|
}>, Schema.Struct<{
|
|
383
|
-
type: Schema.Literal<
|
|
384
|
-
id:
|
|
385
|
-
tenantId:
|
|
386
|
-
metadata: Schema.optional<Schema
|
|
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<
|
|
389
|
-
id:
|
|
390
|
-
tenantId:
|
|
391
|
-
metadata: Schema.optional<Schema
|
|
392
|
-
service:
|
|
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 {
|
|
2
|
-
import {
|
|
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:
|
|
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 = (
|
|
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
|
|
46
|
-
if (o.length > 0) throw Error(`signSession: refusing to mint a session cookie for a ${
|
|
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(
|
|
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) =>
|
|
116
|
-
let t =
|
|
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
|
-
|
|
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,
|
|
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 };
|
|
@@ -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 };
|