prostgles-server 4.2.643 → 4.2.644
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/debug/fixes-review-build.log +4 -0
- package/debug/fixes-review-client-schema.backup +745 -0
- package/debug/fixes-review-generated-schema.backup +489 -0
- package/debug/fixes-review-probes-build.log +0 -0
- package/debug/fixes-review-probes.patch +43 -0
- package/debug/fixes-review-restore-build.log +0 -0
- package/debug/fixes-review-tests-build.log +0 -0
- package/debug/fixes-review-typecheck.log +8 -0
- package/debug/review-current-fixes-build.log +4 -0
- package/debug/review-current-fixes-client.backup +745 -0
- package/debug/review-current-fixes-probes-build.log +0 -0
- package/debug/review-current-fixes-probes.patch +55 -0
- package/debug/review-current-fixes-restore-build.log +0 -0
- package/debug/review-current-fixes-rls.backup +478 -0
- package/debug/review-current-fixes-schema.backup +489 -0
- package/debug/review-current-fixes-test-build.log +0 -0
- package/debug/review-current-fixes-typecheck.log +8 -0
- package/debug/review-user-identity-build.log +4 -0
- package/debug/review-user-identity-probes-build.log +0 -0
- package/debug/review-user-identity-probes.log +558 -0
- package/debug/review-user-identity-probes.patch +45 -0
- package/debug/review-user-identity-restore-build.log +0 -0
- package/debug/review-user-identity-rls.backup +463 -0
- package/debug/review-user-identity-schema.backup +720 -0
- package/debug/review-user-identity-server.log +3248 -0
- package/debug/review-user-identity-test-build.log +0 -0
- package/debug/review-user-identity-typecheck.log +8 -0
- package/debug/server-user-lint.log +4 -0
- package/debug/server-user-test-server.log +538 -0
- package/debug/server-user-typecheck.log +8 -0
- package/debug/user-identity-direct-call-build.log +0 -0
- package/debug/user-identity-direct-call-schema.backup +489 -0
- package/debug/user-identity-regressions-build.log +4 -0
- package/debug/user-identity-regressions-generated-schema.backup +489 -0
- package/debug/user-identity-regressions-test-build.log +0 -0
- package/dist/Auth/AuthHandler.js +1 -1
- package/dist/Auth/AuthHandler.js.map +1 -1
- package/dist/Auth/AuthTypes.d.ts +8 -6
- package/dist/Auth/AuthTypes.d.ts.map +1 -1
- package/dist/Auth/AuthTypes.js.map +1 -1
- package/dist/Auth/utils/getClientRequestIPsInfo.d.ts +2 -1
- package/dist/Auth/utils/getClientRequestIPsInfo.d.ts.map +1 -1
- package/dist/Auth/utils/getClientRequestIPsInfo.js +8 -1
- package/dist/Auth/utils/getClientRequestIPsInfo.js.map +1 -1
- package/dist/Auth/utils/getSessionUser.d.ts +4 -3
- package/dist/Auth/utils/getSessionUser.d.ts.map +1 -1
- package/dist/Auth/utils/getSessionUser.js +4 -2
- package/dist/Auth/utils/getSessionUser.js.map +1 -1
- package/dist/Auth/utils/getSessionUser.spec.js +2 -4
- package/dist/Auth/utils/getSessionUser.spec.js.map +1 -1
- package/dist/Auth/utils/handleGetUser.d.ts.map +1 -1
- package/dist/Auth/utils/handleGetUser.js +16 -0
- package/dist/Auth/utils/handleGetUser.js.map +1 -1
- package/dist/Auth/utils/serverSideRequest.d.ts +17 -0
- package/dist/Auth/utils/serverSideRequest.d.ts.map +1 -0
- package/dist/Auth/utils/serverSideRequest.js +20 -0
- package/dist/Auth/utils/serverSideRequest.js.map +1 -0
- package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts +0 -4
- package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/ViewHandler.js +5 -8
- package/dist/DboBuilder/ViewHandler/ViewHandler.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/count.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/count.js +2 -1
- package/dist/DboBuilder/ViewHandler/count.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/find.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/find.js +2 -1
- package/dist/DboBuilder/ViewHandler/find.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/getDbHandlerWithAbort.d.ts +9 -2
- package/dist/DboBuilder/ViewHandler/getDbHandlerWithAbort.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/getDbHandlerWithAbort.js +57 -23
- package/dist/DboBuilder/ViewHandler/getDbHandlerWithAbort.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/size.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/size.js +2 -1
- package/dist/DboBuilder/ViewHandler/size.js.map +1 -1
- package/dist/initProstgles.d.ts +12 -2
- package/dist/initProstgles.d.ts.map +1 -1
- package/dist/initProstgles.js +10 -1
- package/dist/initProstgles.js.map +1 -1
- package/dist/runClientRequest.d.ts.map +1 -1
- package/dist/runClientRequest.js +4 -3
- package/dist/runClientRequest.js.map +1 -1
- package/lib/Auth/AuthHandler.ts +1 -1
- package/lib/Auth/AuthTypes.ts +9 -6
- package/lib/Auth/utils/getClientRequestIPsInfo.ts +11 -2
- package/lib/Auth/utils/getSessionUser.spec.ts +4 -6
- package/lib/Auth/utils/getSessionUser.ts +8 -5
- package/lib/Auth/utils/handleGetUser.ts +13 -0
- package/lib/Auth/utils/serverSideRequest.ts +27 -0
- package/lib/DboBuilder/ViewHandler/ViewHandler.ts +11 -11
- package/lib/DboBuilder/ViewHandler/count.ts +2 -1
- package/lib/DboBuilder/ViewHandler/find.ts +2 -1
- package/lib/DboBuilder/ViewHandler/getDbHandlerWithAbort.ts +72 -29
- package/lib/DboBuilder/ViewHandler/size.ts +2 -1
- package/lib/initProstgles.ts +31 -5
- package/lib/runClientRequest.ts +8 -5
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import type { ViewHandler } from "./ViewHandler";
|
|
10
10
|
import { getReturnTypeQuery } from "./getReturnTypeQuery";
|
|
11
11
|
import type { Param3 } from "./find";
|
|
12
|
+
import { getDbHandlerWithAbort } from "./getDbHandlerWithAbort";
|
|
12
13
|
export async function size(
|
|
13
14
|
this: ViewHandler,
|
|
14
15
|
_filter?: Filter,
|
|
@@ -62,7 +63,7 @@ export async function size(
|
|
|
62
63
|
return queryToReturn as unknown[];
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
const handler =
|
|
66
|
+
const handler = getDbHandlerWithAbort(this, localParams, {
|
|
66
67
|
abortSignal: selectParams?.abortSignal,
|
|
67
68
|
abortSignalId: param3?.abortSignalId,
|
|
68
69
|
});
|
package/lib/initProstgles.ts
CHANGED
|
@@ -19,6 +19,17 @@ import { updateConfiguration, type clientOnlyUpdateKeys } from "./updateConfigur
|
|
|
19
19
|
import { sleep } from "./utils/utils";
|
|
20
20
|
import { getClientHandlers } from "./WebsocketAPI/getClientHandlers";
|
|
21
21
|
import { getAdminClient } from "./DboBuilder/runSql/getAdminClient";
|
|
22
|
+
import { createServerSideRequest } from "./Auth/utils/serverSideRequest";
|
|
23
|
+
|
|
24
|
+
type ClientDBHandlerRequest =
|
|
25
|
+
| AuthClientRequest
|
|
26
|
+
| {
|
|
27
|
+
/** Trusted server-only identity, resolved through auth.findUser on every operation. */
|
|
28
|
+
userId: string;
|
|
29
|
+
socket?: never;
|
|
30
|
+
httpReq?: never;
|
|
31
|
+
res?: never;
|
|
32
|
+
};
|
|
22
33
|
|
|
23
34
|
/**
|
|
24
35
|
* Database connection details
|
|
@@ -125,9 +136,12 @@ export type InitResult<
|
|
|
125
136
|
update: (newOpts: UpdatableOptions<S, SUser, Context>, force?: true) => Promise<void>;
|
|
126
137
|
restart: () => Promise<InitResult<S, SUser, Context, ClientSchema>>;
|
|
127
138
|
options: ProstglesInitOptions<S, SUser, Context>;
|
|
128
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Uses the configured client schema by default and accepts a publish-profile schema override.
|
|
141
|
+
* Only pass userId from trusted server code; never forward client-supplied input here.
|
|
142
|
+
*/
|
|
129
143
|
getClientDBHandlers: <NarrowedClientSchema = ClientSchema>(
|
|
130
|
-
clientReq:
|
|
144
|
+
clientReq: ClientDBHandlerRequest,
|
|
131
145
|
scope: PermissionScope | undefined,
|
|
132
146
|
) => ReturnType<typeof getClientHandlers<NarrowedClientSchema>>;
|
|
133
147
|
|
|
@@ -333,10 +347,22 @@ export const initProstgles = async function (
|
|
|
333
347
|
await sleep(1000);
|
|
334
348
|
return true;
|
|
335
349
|
},
|
|
336
|
-
getClientDBHandlers: <ClientSchema = void>(
|
|
337
|
-
clientReq:
|
|
350
|
+
getClientDBHandlers: async <ClientSchema = void>(
|
|
351
|
+
clientReq: ClientDBHandlerRequest,
|
|
338
352
|
scope: PermissionScope | undefined,
|
|
339
|
-
) =>
|
|
353
|
+
) => {
|
|
354
|
+
if ("userId" in clientReq) {
|
|
355
|
+
if ("socket" in clientReq || "httpReq" in clientReq || "res" in clientReq) {
|
|
356
|
+
throw new Error("userId cannot be combined with a client request");
|
|
357
|
+
}
|
|
358
|
+
return getClientHandlers<ClientSchema>(
|
|
359
|
+
this,
|
|
360
|
+
createServerSideRequest(this, clientReq.userId),
|
|
361
|
+
scope,
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
return getClientHandlers<ClientSchema>(this, clientReq, scope);
|
|
365
|
+
},
|
|
340
366
|
};
|
|
341
367
|
|
|
342
368
|
return initResult;
|
package/lib/runClientRequest.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { canRunSQL } from "./DboBuilder/runSql/runSQL";
|
|
|
15
15
|
import type { Prostgles } from "./Prostgles";
|
|
16
16
|
import type { ParsedTableRule } from "./PublishParser/publishTypesAndUtils";
|
|
17
17
|
import { type PermissionScope } from "./PublishParser/publishTypesAndUtils";
|
|
18
|
+
import { getAbortSignalKeys } from "./DboBuilder/ViewHandler/getDbHandlerWithAbort";
|
|
18
19
|
|
|
19
20
|
const TABLE_METHODS = {
|
|
20
21
|
find: 1,
|
|
@@ -104,9 +105,12 @@ export const runClientRequest = async function (
|
|
|
104
105
|
);
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
const tableHandler =
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
const tableHandler =
|
|
109
|
+
transactionHandlers ?
|
|
110
|
+
Object.hasOwn(transactionHandlers, tableName) ?
|
|
111
|
+
transactionHandlers[tableName]
|
|
112
|
+
: undefined
|
|
113
|
+
: this.dboBuilder.dboMap.get(tableName);
|
|
110
114
|
if (!tableHandler) {
|
|
111
115
|
throw `tableName ${tableName} is invalid or not allowed`;
|
|
112
116
|
}
|
|
@@ -123,7 +127,7 @@ export const runClientRequest = async function (
|
|
|
123
127
|
scope,
|
|
124
128
|
});
|
|
125
129
|
|
|
126
|
-
const sessionUser = getSessionUser(clientInfo);
|
|
130
|
+
const sessionUser = getSessionUser(clientInfo, this.opts.auth?.sessionFields);
|
|
127
131
|
const localParams: LocalParams = {
|
|
128
132
|
clientReq,
|
|
129
133
|
isRemoteRequest: { user: sessionUser, clientInfo },
|
|
@@ -155,7 +159,6 @@ export const runClientRequest = async function (
|
|
|
155
159
|
scope,
|
|
156
160
|
);
|
|
157
161
|
|
|
158
|
-
tableHandler.abortRequests.add(validation.data.param1.abortSignalId);
|
|
159
162
|
return tableHandler.abortRemoteQuery(validation.data.param1.abortSignalId, localParams);
|
|
160
163
|
} else {
|
|
161
164
|
this.publishParser.validateRequestRule(
|