@fitzzero/quickdraw-core 5.1.1 → 5.1.3
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/README.md +1308 -219
- package/dist/{admin-DKwkIh5i.d.ts → admin-CS7JB_UH.d.ts} +2 -2
- package/dist/{adminSchemas-2DUA_hZ8.d.ts → adminSchemas-29cGgrg5.d.ts} +6 -4
- package/dist/{auth-BhWqdyb-.d.ts → auth-DtdYjrZ9.d.ts} +51 -21
- package/dist/{caller-CXTFswBO.d.ts → caller-BTwGl7vm.d.ts} +296 -33
- package/dist/chunk-2FDSKLBO.js +82 -0
- package/dist/chunk-2FDSKLBO.js.map +1 -0
- package/dist/{chunk-RT6OILOI.js → chunk-4D2DOGAW.js} +2 -14
- package/dist/chunk-4D2DOGAW.js.map +1 -0
- package/dist/{chunk-OECZPRPW.js → chunk-64I6MYBC.js} +162 -775
- package/dist/chunk-64I6MYBC.js.map +1 -0
- package/dist/chunk-7473HK24.js +17 -0
- package/dist/chunk-7473HK24.js.map +1 -0
- package/dist/chunk-7Y5ROPXL.js +33 -0
- package/dist/chunk-7Y5ROPXL.js.map +1 -0
- package/dist/chunk-A2RBQD66.js +7 -0
- package/dist/chunk-A2RBQD66.js.map +1 -0
- package/dist/chunk-AK23XSWD.js +16 -0
- package/dist/chunk-AK23XSWD.js.map +1 -0
- package/dist/chunk-ASAMUGHG.js +651 -0
- package/dist/chunk-ASAMUGHG.js.map +1 -0
- package/dist/{chunk-B2P7AZ25.js → chunk-CYE4UBOB.js} +6 -4
- package/dist/chunk-CYE4UBOB.js.map +1 -0
- package/dist/chunk-DKE6QO26.js +136 -0
- package/dist/chunk-DKE6QO26.js.map +1 -0
- package/dist/chunk-DNP65TD5.js +832 -0
- package/dist/chunk-DNP65TD5.js.map +1 -0
- package/dist/{chunk-H23KEFBA.js → chunk-DUBU3BB3.js} +30 -1
- package/dist/chunk-DUBU3BB3.js.map +1 -0
- package/dist/chunk-GYLWEJHW.js +19 -0
- package/dist/chunk-GYLWEJHW.js.map +1 -0
- package/dist/{chunk-SHEGLZEP.js → chunk-I3JCFS7H.js} +34 -13
- package/dist/chunk-I3JCFS7H.js.map +1 -0
- package/dist/{chunk-X5CWPX7H.js → chunk-IIQ3WMJK.js} +13 -2
- package/dist/chunk-IIQ3WMJK.js.map +1 -0
- package/dist/{chunk-RZTP4IEW.js → chunk-JVTONQFI.js} +6339 -4226
- package/dist/chunk-JVTONQFI.js.map +1 -0
- package/dist/{chunk-QEKVYG5F.js → chunk-KKQANRLG.js} +2 -2
- package/dist/chunk-KKQANRLG.js.map +1 -0
- package/dist/{chunk-CDKG4TFA.js → chunk-MPQAT55F.js} +38 -205
- package/dist/chunk-MPQAT55F.js.map +1 -0
- package/dist/chunk-NO4M6PO5.js +101 -0
- package/dist/chunk-NO4M6PO5.js.map +1 -0
- package/dist/{chunk-TBMKJ26R.js → chunk-NW6U45HX.js} +3 -1
- package/dist/chunk-NW6U45HX.js.map +1 -0
- package/dist/chunk-NX2V6SIL.js +202 -0
- package/dist/chunk-NX2V6SIL.js.map +1 -0
- package/dist/{chunk-ZIVPHYRG.js → chunk-NZHA4TZD.js} +72 -175
- package/dist/chunk-NZHA4TZD.js.map +1 -0
- package/dist/{chunk-2PWMUVC7.js → chunk-OCZJ4EYV.js} +518 -27
- package/dist/chunk-OCZJ4EYV.js.map +1 -0
- package/dist/{chunk-REX5YPHX.js → chunk-PHCURHC7.js} +76 -21
- package/dist/chunk-PHCURHC7.js.map +1 -0
- package/dist/{chunk-4YO5H5ON.js → chunk-Q4OGQM5I.js} +4 -10
- package/dist/chunk-Q4OGQM5I.js.map +1 -0
- package/dist/chunk-QSU47XEX.js +13 -0
- package/dist/chunk-QSU47XEX.js.map +1 -0
- package/dist/{chunk-DD4SKCNO.js → chunk-RZXJTDH5.js} +13 -2
- package/dist/chunk-RZXJTDH5.js.map +1 -0
- package/dist/{chunk-Z2LZ7IZ7.js → chunk-SN3OZVEQ.js} +5 -31
- package/dist/chunk-SN3OZVEQ.js.map +1 -0
- package/dist/{chunk-4DIQHASK.js → chunk-SQ5VUG77.js} +28 -8
- package/dist/chunk-SQ5VUG77.js.map +1 -0
- package/dist/chunk-STH5DLQP.js +1192 -0
- package/dist/chunk-STH5DLQP.js.map +1 -0
- package/dist/{chunk-QCHKWIRS.js → chunk-VZFJTKIW.js} +13 -13
- package/dist/{chunk-QCHKWIRS.js.map → chunk-VZFJTKIW.js.map} +1 -1
- package/dist/{chunk-VSQBHPWH.js → chunk-X4ZU4QH5.js} +54 -22
- package/dist/chunk-X4ZU4QH5.js.map +1 -0
- package/dist/chunk-XD7SRDUY.js +188 -0
- package/dist/chunk-XD7SRDUY.js.map +1 -0
- package/dist/chunk-XH2IZVLT.js +62 -0
- package/dist/chunk-XH2IZVLT.js.map +1 -0
- package/dist/chunk-Z7I6SONO.js +825 -0
- package/dist/chunk-Z7I6SONO.js.map +1 -0
- package/dist/cli/quickdraw-docs.js +132 -112
- package/dist/cli/quickdraw-docs.js.map +1 -1
- package/dist/client/core.d.ts +387 -0
- package/dist/client/core.js +109 -0
- package/dist/client/index.d.ts +52 -203
- package/dist/client/index.js +59 -218
- package/dist/client/index.js.map +1 -1
- package/dist/{clientTypes-Bc-G8n-U.d.ts → clientTypes-CUUNJwWs.d.ts} +3 -3
- package/dist/{connection-Cr1BU07W.d.ts → connection-2EeQ_Et0.d.ts} +22 -11
- package/dist/{createServer-CP9eDHZZ.d.ts → createServer-Bx5HOcYK.d.ts} +67 -17
- package/dist/{createTestApp-UKVGEmOf.d.ts → createTestApp-DAMANT79.d.ts} +46 -13
- package/dist/{envelope-Cp3YcVxC.d.ts → envelope-BMBaxppV.d.ts} +216 -10
- package/dist/{http-Djj2Inuu.d.ts → http-YzLAar3w.d.ts} +76 -60
- package/dist/index.d.ts +8 -7
- package/dist/index.js +82 -25
- package/dist/index.js.map +1 -1
- package/dist/{infer-Teo1xpsd.d.ts → infer-Br62cnyW.d.ts} +82 -11
- package/dist/logger-Yz93KzdV.d.ts +30 -0
- package/dist/{metrics-BdBu5o8G.d.ts → metrics-CTVpw0gu.d.ts} +2 -2
- package/dist/origins-kvpxnVcW.d.ts +8 -0
- package/dist/parser.js +2 -1
- package/dist/prisma/index.d.ts +14 -7
- package/dist/prisma/index.js +279 -70
- package/dist/prisma/index.js.map +1 -1
- package/dist/{rateLimit-ZMIZJUZF.js → rateLimit-5RKBFLUR.js} +2 -2
- package/dist/rateLimit-5RKBFLUR.js.map +1 -0
- package/dist/remote-N7OUAGOW.js +15 -0
- package/dist/remote-N7OUAGOW.js.map +1 -0
- package/dist/server/auth/index.d.ts +82 -33
- package/dist/server/auth/index.js +277 -270
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/express/index.d.ts +9 -2
- package/dist/server/express/index.js +1 -1
- package/dist/server/index.d.ts +268 -84
- package/dist/server/index.js +664 -418
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp/index.d.ts +89 -27
- package/dist/server/mcp/index.js +281 -62
- package/dist/server/mcp/index.js.map +1 -1
- package/dist/server/otel.d.ts +3 -3
- package/dist/{sharing-DVa8W-yR.d.ts → sharing-BrsmlDv_.d.ts} +3 -3
- package/dist/testing/client.d.ts +14 -14
- package/dist/testing/client.js +19 -10
- package/dist/testing/client.js.map +1 -1
- package/dist/testing/index.d.ts +50 -13
- package/dist/testing/index.js +113 -21
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/mock.d.ts +5 -5
- package/dist/testing/mock.js +17 -9
- package/dist/tracked-BR5b2O-U.d.ts +43 -0
- package/dist/{types-Cu0vmx7c.d.ts → types-CLRCQGnO.d.ts} +4 -3
- package/dist/types-tMagHbjy.d.ts +151 -0
- package/dist/utils/index.d.ts +16 -4
- package/dist/utils/index.js +6 -3
- package/package.json +5 -1
- package/dist/chunk-2PWMUVC7.js.map +0 -1
- package/dist/chunk-4DIQHASK.js.map +0 -1
- package/dist/chunk-4YO5H5ON.js.map +0 -1
- package/dist/chunk-B2P7AZ25.js.map +0 -1
- package/dist/chunk-CDKG4TFA.js.map +0 -1
- package/dist/chunk-DD4SKCNO.js.map +0 -1
- package/dist/chunk-H23KEFBA.js.map +0 -1
- package/dist/chunk-OECZPRPW.js.map +0 -1
- package/dist/chunk-QEKVYG5F.js.map +0 -1
- package/dist/chunk-REX5YPHX.js.map +0 -1
- package/dist/chunk-RT6OILOI.js.map +0 -1
- package/dist/chunk-RZTP4IEW.js.map +0 -1
- package/dist/chunk-SHEGLZEP.js.map +0 -1
- package/dist/chunk-TBMKJ26R.js.map +0 -1
- package/dist/chunk-VSQBHPWH.js.map +0 -1
- package/dist/chunk-X5CWPX7H.js.map +0 -1
- package/dist/chunk-YSWH776Y.js +0 -13
- package/dist/chunk-YSWH776Y.js.map +0 -1
- package/dist/chunk-Z2LZ7IZ7.js.map +0 -1
- package/dist/chunk-ZIVPHYRG.js.map +0 -1
- package/dist/logger-BY28acW-.d.ts +0 -16
- /package/dist/{rateLimit-ZMIZJUZF.js.map → client/core.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as StandardSchemaWithJSON, d as StandardSchemaV1, I as InferInput, c as InferOutput, X as RowSchema, Q as QueryDef, P as ProjectionList, p as MutationDef, J as AnyContract, ap as MethodName } from './infer-
|
|
2
|
-
import { d as ListSort, c as ListQuery, b as ListPage, D as AdminWritable, u as AdminListInput, v as AdminListQuery, y as AdminPage, r as AdminCreateInput, s as AdminCreateQuery, B as AdminUpdateInput, C as AdminUpdateQuery, w as AdminMetaInput, n as AdminServiceMeta, z as AdminSubscribers } from './adminSchemas-
|
|
1
|
+
import { e as StandardSchemaWithJSON, d as StandardSchemaV1, I as InferInput, c as InferOutput, X as RowSchema, Q as QueryDef, P as ProjectionList, p as MutationDef, J as AnyContract, ap as MethodName } from './infer-Br62cnyW.js';
|
|
2
|
+
import { d as ListSort, c as ListQuery, b as ListPage, D as AdminWritable, u as AdminListInput, v as AdminListQuery, y as AdminPage, r as AdminCreateInput, s as AdminCreateQuery, B as AdminUpdateInput, C as AdminUpdateQuery, w as AdminMetaInput, n as AdminServiceMeta, z as AdminSubscribers } from './adminSchemas-29cGgrg5.js';
|
|
3
3
|
|
|
4
4
|
/** A schema a kit generates: validation, and its JSON Schema. */
|
|
5
5
|
type KitSchema<Input, Output = Input> = StandardSchemaWithJSON<Input, Output>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z as SortDirection, A as AccessLevel } from './infer-
|
|
1
|
+
import { z as SortDirection, A as AccessLevel } from './infer-Br62cnyW.js';
|
|
2
2
|
|
|
3
3
|
/** `list`'s page size when the caller gives none. */
|
|
4
4
|
declare const LIST_DEFAULT_LIMIT = 50;
|
|
@@ -111,9 +111,11 @@ interface AdminFieldConfig {
|
|
|
111
111
|
readonly relationService?: string;
|
|
112
112
|
/**
|
|
113
113
|
* What the field holds, when the kit knows it: `"grants"` for a user's
|
|
114
|
-
* service-wide grants (`serviceAccess
|
|
115
|
-
*
|
|
116
|
-
*
|
|
114
|
+
* service-wide grants (`serviceAccess`, or the column the server's
|
|
115
|
+
* `auth.serviceAccessSource` names, whatever its name), which
|
|
116
|
+
* `admin.handlers(contract, { grants: true })` shows. An admin screen with
|
|
117
|
+
* a grants editor of its own finds that field by it, never by its name.
|
|
118
|
+
* Absent for any other field.
|
|
117
119
|
*/
|
|
118
120
|
readonly kind?: "grants";
|
|
119
121
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IncomingMessage, IncomingHttpHeaders } from 'node:http';
|
|
2
2
|
import { Socket } from 'socket.io';
|
|
3
|
-
import { A as AccessLevel } from './infer-
|
|
4
|
-
import { P as Principal, M as MaybePromise } from './types-
|
|
3
|
+
import { A as AccessLevel } from './infer-Br62cnyW.js';
|
|
4
|
+
import { P as Principal, M as MaybePromise } from './types-CLRCQGnO.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A request as Express leaves it: maybe with `body` from `express.json()`,
|
|
@@ -13,10 +13,13 @@ type HttpRequest = IncomingMessage & {
|
|
|
13
13
|
readonly secure?: unknown;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* a browser sends with a request any
|
|
18
|
-
* the request's `Origin`
|
|
19
|
-
* `Authorization: Bearer` header, which a
|
|
16
|
+
* The credential the HTTP transport chose for a call (the cookie first).
|
|
17
|
+
* `"cookie"`: the session cookie, which a browser sends with a request any
|
|
18
|
+
* page makes, so whoever accepts it checks the request's `Origin`
|
|
19
|
+
* (`socketAuth` does). `"bearer"`: an `Authorization: Bearer` header, which a
|
|
20
|
+
* page sends only on purpose. For an `authenticate` `socketAuth` did not
|
|
21
|
+
* make, `auth.token` holds the bearer token alone, even when this says
|
|
22
|
+
* `"cookie"`; the cookie is `request.sessionCookie`.
|
|
20
23
|
*/
|
|
21
24
|
type HttpCredentialSource = "cookie" | "bearer";
|
|
22
25
|
|
|
@@ -26,7 +29,10 @@ interface AuthenticateRequestBase {
|
|
|
26
29
|
/**
|
|
27
30
|
* The credentials. For a socket, its handshake `auth` as the client sent
|
|
28
31
|
* it (`{ token, qd }` from a v5 client). For an HTTP request, `{ token }`
|
|
29
|
-
* with its
|
|
32
|
+
* with its bearer token, or `{}` without one; for `socketAuth`'s
|
|
33
|
+
* `authenticate` alone, the session cookie when the request carries one,
|
|
34
|
+
* else the bearer token. Every other `authenticate` finds the cookie only
|
|
35
|
+
* in `sessionCookie`.
|
|
30
36
|
*/
|
|
31
37
|
readonly auth: Readonly<Record<string, unknown>>;
|
|
32
38
|
/** The request's headers, or the socket handshake's. */
|
|
@@ -42,13 +48,23 @@ interface HttpAuthenticateRequest extends AuthenticateRequestBase {
|
|
|
42
48
|
readonly transport: "http";
|
|
43
49
|
readonly req: IncomingMessage;
|
|
44
50
|
/**
|
|
45
|
-
*
|
|
46
|
-
* cookie, which a browser sends with a
|
|
47
|
-
* `authenticate` that accepts it checks the
|
|
48
|
-
* `socketAuth` does; `"bearer"
|
|
49
|
-
* a page sends only on purpose.
|
|
51
|
+
* The credential the transport chose (finding F7.1): `"cookie"` when the
|
|
52
|
+
* request carries the session cookie, which a browser sends with a
|
|
53
|
+
* request any page makes, so an `authenticate` that accepts it checks the
|
|
54
|
+
* request's `Origin` as `socketAuth` does; else `"bearer"` for an
|
|
55
|
+
* `Authorization: Bearer` header, which a page sends only on purpose.
|
|
56
|
+
* Absent with neither.
|
|
50
57
|
*/
|
|
51
58
|
readonly credential?: HttpCredentialSource;
|
|
59
|
+
/**
|
|
60
|
+
* The session cookie's value, when the request carries one. It is
|
|
61
|
+
* ambient (a browser sends it with a request any page makes), so an
|
|
62
|
+
* `authenticate` that accepts it first checks
|
|
63
|
+
* `cookieOriginAllowed(request, allowedOrigins)`, then the session store,
|
|
64
|
+
* on every call (`liveSession`). It is in `auth.token` only for
|
|
65
|
+
* `socketAuth`'s `authenticate`.
|
|
66
|
+
*/
|
|
67
|
+
readonly sessionCookie?: string;
|
|
52
68
|
}
|
|
53
69
|
/** What `authenticate` is asked about: a socket connecting, or an HTTP call. */
|
|
54
70
|
type AuthenticateRequest = SocketAuthenticateRequest | HttpAuthenticateRequest;
|
|
@@ -64,11 +80,15 @@ type AuthenticateResult<P extends Principal> = P | ({
|
|
|
64
80
|
interface ServerAuth<P extends Principal = Principal> {
|
|
65
81
|
/**
|
|
66
82
|
* Says who is calling. Throwing refuses the socket connection ("Authentication
|
|
67
|
-
* failed"
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
83
|
+
* failed") or answers the HTTP call with `UNAUTHENTICATED`; returning
|
|
84
|
+
* nothing lets the caller in anonymously, so only `"public"` methods pass.
|
|
85
|
+
* Throw a `QuickdrawError("UNAUTHENTICATED", ...)` (or `"FORBIDDEN"`) for a
|
|
86
|
+
* refusal that is the caller's doing: it logs at debug, and a socket's
|
|
87
|
+
* `connect_error` data is `{ code: "UNAUTHENTICATED" }`, which signs a
|
|
88
|
+
* client out. Anything else thrown is the server's failure (its session
|
|
89
|
+
* store down, say): it logs at error, and the data is `{ code: "INTERNAL" }`,
|
|
90
|
+
* which a client retries, keeping the user, so never throw a plain `Error`
|
|
91
|
+
* for bad credentials.
|
|
72
92
|
* On an HTTP call a thrown `QuickdrawError("FORBIDDEN", ...)` is answered
|
|
73
93
|
* as it is, with 403 (logged at debug): a credential the request may not
|
|
74
94
|
* use from where it came, as `socketAuth` answers a session cookie sent
|
|
@@ -87,7 +107,13 @@ interface ServerAuth<P extends Principal = Principal> {
|
|
|
87
107
|
* sets that column, or creates, deletes or touches such a row, refreshes
|
|
88
108
|
* that user's grants once it is flushed (`server.access.refresh`), so a
|
|
89
109
|
* changed grant reaches their sockets without a reconnect (RFC 0003
|
|
90
|
-
* section 4.4).
|
|
110
|
+
* section 4.4). `createServer` gives it to its dispatcher, whose admin kit
|
|
111
|
+
* on that model treats the column as the grants field, whatever its name:
|
|
112
|
+
* hidden unless `grants: true`, and then for service-wide Admins only. A
|
|
113
|
+
* dispatcher made without `createServer` takes it as
|
|
114
|
+
* `createDispatcher({ serviceAccessSource })`, and `createHttpRouter`
|
|
115
|
+
* refuses an `auth.serviceAccessSource` its dispatcher does not name.
|
|
116
|
+
* Needs `loadServiceAccess`.
|
|
91
117
|
*/
|
|
92
118
|
readonly serviceAccessSource?: ServiceAccessSource;
|
|
93
119
|
}
|
|
@@ -101,9 +127,13 @@ interface ServiceAccessSource {
|
|
|
101
127
|
/**
|
|
102
128
|
* Records the session a socket authenticated with, so that
|
|
103
129
|
* `server.access.disconnectUser(userId, { sessionId })` can end that
|
|
104
|
-
* session's sockets alone
|
|
105
|
-
*
|
|
130
|
+
* session's sockets alone, and, with `expiresAt`, so that the server
|
|
131
|
+
* disconnects the socket when the session expires (the 5.1 audit's AUTH-4)
|
|
132
|
+
* and refuses its handshake when it already has. `expiresAt` is a `Date`, a
|
|
133
|
+
* date string, or epoch milliseconds: a JWT's `exp` is in seconds, so pass
|
|
134
|
+
* `exp * 1000`. `socketAuth` calls it for the auth routes' sessions; an
|
|
135
|
+
* app's own `authenticate` may too.
|
|
106
136
|
*/
|
|
107
|
-
declare function recordSocketSession(socket: object, sessionId: string): void;
|
|
137
|
+
declare function recordSocketSession(socket: object, sessionId: string, expiresAt?: Date | number | string): void;
|
|
108
138
|
|
|
109
139
|
export { type AuthenticateResult as A, type HttpRequest as H, type ServerAuth as S, type ServiceGrants as a, type AuthenticateRequest as b, type HttpAuthenticateRequest as c, type HttpCredentialSource as d, type ServiceAccessSource as e, type SocketAuthenticateRequest as f, recordSocketSession as r };
|