@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.
Files changed (152) hide show
  1. package/README.md +1308 -219
  2. package/dist/{admin-DKwkIh5i.d.ts → admin-CS7JB_UH.d.ts} +2 -2
  3. package/dist/{adminSchemas-2DUA_hZ8.d.ts → adminSchemas-29cGgrg5.d.ts} +6 -4
  4. package/dist/{auth-BhWqdyb-.d.ts → auth-DtdYjrZ9.d.ts} +51 -21
  5. package/dist/{caller-CXTFswBO.d.ts → caller-BTwGl7vm.d.ts} +296 -33
  6. package/dist/chunk-2FDSKLBO.js +82 -0
  7. package/dist/chunk-2FDSKLBO.js.map +1 -0
  8. package/dist/{chunk-RT6OILOI.js → chunk-4D2DOGAW.js} +2 -14
  9. package/dist/chunk-4D2DOGAW.js.map +1 -0
  10. package/dist/{chunk-OECZPRPW.js → chunk-64I6MYBC.js} +162 -775
  11. package/dist/chunk-64I6MYBC.js.map +1 -0
  12. package/dist/chunk-7473HK24.js +17 -0
  13. package/dist/chunk-7473HK24.js.map +1 -0
  14. package/dist/chunk-7Y5ROPXL.js +33 -0
  15. package/dist/chunk-7Y5ROPXL.js.map +1 -0
  16. package/dist/chunk-A2RBQD66.js +7 -0
  17. package/dist/chunk-A2RBQD66.js.map +1 -0
  18. package/dist/chunk-AK23XSWD.js +16 -0
  19. package/dist/chunk-AK23XSWD.js.map +1 -0
  20. package/dist/chunk-ASAMUGHG.js +651 -0
  21. package/dist/chunk-ASAMUGHG.js.map +1 -0
  22. package/dist/{chunk-B2P7AZ25.js → chunk-CYE4UBOB.js} +6 -4
  23. package/dist/chunk-CYE4UBOB.js.map +1 -0
  24. package/dist/chunk-DKE6QO26.js +136 -0
  25. package/dist/chunk-DKE6QO26.js.map +1 -0
  26. package/dist/chunk-DNP65TD5.js +832 -0
  27. package/dist/chunk-DNP65TD5.js.map +1 -0
  28. package/dist/{chunk-H23KEFBA.js → chunk-DUBU3BB3.js} +30 -1
  29. package/dist/chunk-DUBU3BB3.js.map +1 -0
  30. package/dist/chunk-GYLWEJHW.js +19 -0
  31. package/dist/chunk-GYLWEJHW.js.map +1 -0
  32. package/dist/{chunk-SHEGLZEP.js → chunk-I3JCFS7H.js} +34 -13
  33. package/dist/chunk-I3JCFS7H.js.map +1 -0
  34. package/dist/{chunk-X5CWPX7H.js → chunk-IIQ3WMJK.js} +13 -2
  35. package/dist/chunk-IIQ3WMJK.js.map +1 -0
  36. package/dist/{chunk-RZTP4IEW.js → chunk-JVTONQFI.js} +6339 -4226
  37. package/dist/chunk-JVTONQFI.js.map +1 -0
  38. package/dist/{chunk-QEKVYG5F.js → chunk-KKQANRLG.js} +2 -2
  39. package/dist/chunk-KKQANRLG.js.map +1 -0
  40. package/dist/{chunk-CDKG4TFA.js → chunk-MPQAT55F.js} +38 -205
  41. package/dist/chunk-MPQAT55F.js.map +1 -0
  42. package/dist/chunk-NO4M6PO5.js +101 -0
  43. package/dist/chunk-NO4M6PO5.js.map +1 -0
  44. package/dist/{chunk-TBMKJ26R.js → chunk-NW6U45HX.js} +3 -1
  45. package/dist/chunk-NW6U45HX.js.map +1 -0
  46. package/dist/chunk-NX2V6SIL.js +202 -0
  47. package/dist/chunk-NX2V6SIL.js.map +1 -0
  48. package/dist/{chunk-ZIVPHYRG.js → chunk-NZHA4TZD.js} +72 -175
  49. package/dist/chunk-NZHA4TZD.js.map +1 -0
  50. package/dist/{chunk-2PWMUVC7.js → chunk-OCZJ4EYV.js} +518 -27
  51. package/dist/chunk-OCZJ4EYV.js.map +1 -0
  52. package/dist/{chunk-REX5YPHX.js → chunk-PHCURHC7.js} +76 -21
  53. package/dist/chunk-PHCURHC7.js.map +1 -0
  54. package/dist/{chunk-4YO5H5ON.js → chunk-Q4OGQM5I.js} +4 -10
  55. package/dist/chunk-Q4OGQM5I.js.map +1 -0
  56. package/dist/chunk-QSU47XEX.js +13 -0
  57. package/dist/chunk-QSU47XEX.js.map +1 -0
  58. package/dist/{chunk-DD4SKCNO.js → chunk-RZXJTDH5.js} +13 -2
  59. package/dist/chunk-RZXJTDH5.js.map +1 -0
  60. package/dist/{chunk-Z2LZ7IZ7.js → chunk-SN3OZVEQ.js} +5 -31
  61. package/dist/chunk-SN3OZVEQ.js.map +1 -0
  62. package/dist/{chunk-4DIQHASK.js → chunk-SQ5VUG77.js} +28 -8
  63. package/dist/chunk-SQ5VUG77.js.map +1 -0
  64. package/dist/chunk-STH5DLQP.js +1192 -0
  65. package/dist/chunk-STH5DLQP.js.map +1 -0
  66. package/dist/{chunk-QCHKWIRS.js → chunk-VZFJTKIW.js} +13 -13
  67. package/dist/{chunk-QCHKWIRS.js.map → chunk-VZFJTKIW.js.map} +1 -1
  68. package/dist/{chunk-VSQBHPWH.js → chunk-X4ZU4QH5.js} +54 -22
  69. package/dist/chunk-X4ZU4QH5.js.map +1 -0
  70. package/dist/chunk-XD7SRDUY.js +188 -0
  71. package/dist/chunk-XD7SRDUY.js.map +1 -0
  72. package/dist/chunk-XH2IZVLT.js +62 -0
  73. package/dist/chunk-XH2IZVLT.js.map +1 -0
  74. package/dist/chunk-Z7I6SONO.js +825 -0
  75. package/dist/chunk-Z7I6SONO.js.map +1 -0
  76. package/dist/cli/quickdraw-docs.js +132 -112
  77. package/dist/cli/quickdraw-docs.js.map +1 -1
  78. package/dist/client/core.d.ts +387 -0
  79. package/dist/client/core.js +109 -0
  80. package/dist/client/index.d.ts +52 -203
  81. package/dist/client/index.js +59 -218
  82. package/dist/client/index.js.map +1 -1
  83. package/dist/{clientTypes-Bc-G8n-U.d.ts → clientTypes-CUUNJwWs.d.ts} +3 -3
  84. package/dist/{connection-Cr1BU07W.d.ts → connection-2EeQ_Et0.d.ts} +22 -11
  85. package/dist/{createServer-CP9eDHZZ.d.ts → createServer-Bx5HOcYK.d.ts} +67 -17
  86. package/dist/{createTestApp-UKVGEmOf.d.ts → createTestApp-DAMANT79.d.ts} +46 -13
  87. package/dist/{envelope-Cp3YcVxC.d.ts → envelope-BMBaxppV.d.ts} +216 -10
  88. package/dist/{http-Djj2Inuu.d.ts → http-YzLAar3w.d.ts} +76 -60
  89. package/dist/index.d.ts +8 -7
  90. package/dist/index.js +82 -25
  91. package/dist/index.js.map +1 -1
  92. package/dist/{infer-Teo1xpsd.d.ts → infer-Br62cnyW.d.ts} +82 -11
  93. package/dist/logger-Yz93KzdV.d.ts +30 -0
  94. package/dist/{metrics-BdBu5o8G.d.ts → metrics-CTVpw0gu.d.ts} +2 -2
  95. package/dist/origins-kvpxnVcW.d.ts +8 -0
  96. package/dist/parser.js +2 -1
  97. package/dist/prisma/index.d.ts +14 -7
  98. package/dist/prisma/index.js +279 -70
  99. package/dist/prisma/index.js.map +1 -1
  100. package/dist/{rateLimit-ZMIZJUZF.js → rateLimit-5RKBFLUR.js} +2 -2
  101. package/dist/rateLimit-5RKBFLUR.js.map +1 -0
  102. package/dist/remote-N7OUAGOW.js +15 -0
  103. package/dist/remote-N7OUAGOW.js.map +1 -0
  104. package/dist/server/auth/index.d.ts +82 -33
  105. package/dist/server/auth/index.js +277 -270
  106. package/dist/server/auth/index.js.map +1 -1
  107. package/dist/server/express/index.d.ts +9 -2
  108. package/dist/server/express/index.js +1 -1
  109. package/dist/server/index.d.ts +268 -84
  110. package/dist/server/index.js +664 -418
  111. package/dist/server/index.js.map +1 -1
  112. package/dist/server/mcp/index.d.ts +89 -27
  113. package/dist/server/mcp/index.js +281 -62
  114. package/dist/server/mcp/index.js.map +1 -1
  115. package/dist/server/otel.d.ts +3 -3
  116. package/dist/{sharing-DVa8W-yR.d.ts → sharing-BrsmlDv_.d.ts} +3 -3
  117. package/dist/testing/client.d.ts +14 -14
  118. package/dist/testing/client.js +19 -10
  119. package/dist/testing/client.js.map +1 -1
  120. package/dist/testing/index.d.ts +50 -13
  121. package/dist/testing/index.js +113 -21
  122. package/dist/testing/index.js.map +1 -1
  123. package/dist/testing/mock.d.ts +5 -5
  124. package/dist/testing/mock.js +17 -9
  125. package/dist/tracked-BR5b2O-U.d.ts +43 -0
  126. package/dist/{types-Cu0vmx7c.d.ts → types-CLRCQGnO.d.ts} +4 -3
  127. package/dist/types-tMagHbjy.d.ts +151 -0
  128. package/dist/utils/index.d.ts +16 -4
  129. package/dist/utils/index.js +6 -3
  130. package/package.json +5 -1
  131. package/dist/chunk-2PWMUVC7.js.map +0 -1
  132. package/dist/chunk-4DIQHASK.js.map +0 -1
  133. package/dist/chunk-4YO5H5ON.js.map +0 -1
  134. package/dist/chunk-B2P7AZ25.js.map +0 -1
  135. package/dist/chunk-CDKG4TFA.js.map +0 -1
  136. package/dist/chunk-DD4SKCNO.js.map +0 -1
  137. package/dist/chunk-H23KEFBA.js.map +0 -1
  138. package/dist/chunk-OECZPRPW.js.map +0 -1
  139. package/dist/chunk-QEKVYG5F.js.map +0 -1
  140. package/dist/chunk-REX5YPHX.js.map +0 -1
  141. package/dist/chunk-RT6OILOI.js.map +0 -1
  142. package/dist/chunk-RZTP4IEW.js.map +0 -1
  143. package/dist/chunk-SHEGLZEP.js.map +0 -1
  144. package/dist/chunk-TBMKJ26R.js.map +0 -1
  145. package/dist/chunk-VSQBHPWH.js.map +0 -1
  146. package/dist/chunk-X5CWPX7H.js.map +0 -1
  147. package/dist/chunk-YSWH776Y.js +0 -13
  148. package/dist/chunk-YSWH776Y.js.map +0 -1
  149. package/dist/chunk-Z2LZ7IZ7.js.map +0 -1
  150. package/dist/chunk-ZIVPHYRG.js.map +0 -1
  151. package/dist/logger-BY28acW-.d.ts +0 -16
  152. /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-Teo1xpsd.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-2DUA_hZ8.js';
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-Teo1xpsd.js';
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`), which `admin.handlers(contract,
115
- * { grants: true })` shows. An admin screen with a grants editor of its own
116
- * finds that field by it, never by its name. Absent for any other field.
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-Teo1xpsd.js';
4
- import { P as Principal, M as MaybePromise } from './types-Cu0vmx7c.js';
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
- * Where an HTTP call's token came from. `"cookie"`: the session cookie, which
17
- * a browser sends with a request any page makes, so whoever accepts it checks
18
- * the request's `Origin` (`socketAuth` does). `"bearer"`: an
19
- * `Authorization: Bearer` header, which a page sends only on purpose.
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 session cookie or bearer token, or `{}` when it has neither.
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
- * Where `auth.token` came from (finding F7.1): `"cookie"`, the session
46
- * cookie, which a browser sends with a request any page makes, so an
47
- * `authenticate` that accepts it checks the request's `Origin` as
48
- * `socketAuth` does; `"bearer"`, an `Authorization: Bearer` header, which
49
- * a page sends only on purpose. Absent without a token.
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", with `{ code: "UNAUTHENTICATED" }` as the `connect_error` data) or
68
- * answers the HTTP call with `UNAUTHENTICATED`; returning nothing lets the
69
- * caller in anonymously, so only `"public"` methods pass. Throw a
70
- * `QuickdrawError("UNAUTHENTICATED", ...)` for a refusal that is the
71
- * caller's doing (it logs at debug; anything else thrown logs at error).
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). Needs `loadServiceAccess`.
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. `socketAuth` calls it for the auth routes'
105
- * sessions; an app's own `authenticate` may too.
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 };