diff --git a/docs/server.md b/docs/server.md index 284402d0..6164b21e 100644 --- a/docs/server.md +++ b/docs/server.md @@ -139,7 +139,7 @@ prostgles({ Data access rules applied to clients. By default, nothing is allowed. -- **publishRawSQL** optional (params: PublishParams<S, SUser>) => boolean | "*" | Promise<boolean | "*"> +- **publishRawSQL** optional (params: PublishParams<S, SUser>) => Awaitable<boolean | "*"> If defined and resolves to true then the connected client can run SQL queries @@ -194,7 +194,7 @@ prostgles({ Name of the cookie or socket hadnshake query param that represents the session id. Defaults to "session_id" - - **getUser** required (sid: string | undefined, dbo: DBOFullyTyped<S>, db: DB, client: AuthClientRequest & LoginClientInfo) => Awaitable<AuthResult<...>> + - **getUser** required (sid: string | undefined, dbo: DBOFullyTyped<S>, db: DB, client: AuthClientRequest & LoginClientInfo) => Awaitable<AuthResultOrError<...>> undefined sid is allowed to enable public users - **expressConfig** optional ExpressConfig diff --git a/lib/Auth/AuthHandler.ts b/lib/Auth/AuthHandler.ts index d8171512..4d8bd3b7 100644 --- a/lib/Auth/AuthHandler.ts +++ b/lib/Auth/AuthHandler.ts @@ -15,6 +15,7 @@ import { AuthClientRequest, AuthResult, AuthResultOrError, + AuthResultWithSID, BasicSession, ExpressReq, ExpressRes, @@ -145,7 +146,7 @@ export class AuthHandler { } }; - getUserAndHandleError = async (localParams: AuthClientRequest): Promise => { + getUserAndHandleError = async (localParams: AuthClientRequest): Promise => { const sid = this.getSID(localParams); if (!sid) return undefined; const handlerError = (code: AuthFailure["code"]) => { @@ -170,7 +171,7 @@ export class AuthHandler { return handlerError(userOrErrorCode); } - return userOrErrorCode; + return { sid, ...userOrErrorCode }; } catch (_err) { return handlerError("server-error"); } diff --git a/lib/Auth/AuthTypes.ts b/lib/Auth/AuthTypes.ts index 49fb26d9..37ece4bb 100644 --- a/lib/Auth/AuthTypes.ts +++ b/lib/Auth/AuthTypes.ts @@ -263,7 +263,7 @@ export type AuthResultOrError = AuthFailure["code"] | AuthResu export type AuthRequestParams = { db: DB; dbo: DBOFullyTyped; - getUser: () => Promise>; + getUser: () => Promise>; }; export type Auth = { diff --git a/package-lock.json b/package-lock.json index 55e6ec2b..2a246a86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "prostgles-server", - "version": "4.2.192", + "version": "4.2.193", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "prostgles-server", - "version": "4.2.192", + "version": "4.2.193", "license": "MIT", "dependencies": { "@aws-sdk/client-ses": "^3.699.0", diff --git a/package.json b/package.json index 0779fb4b..1c3ee33e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prostgles-server", - "version": "4.2.192", + "version": "4.2.193", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/tests/server/package-lock.json b/tests/server/package-lock.json index fab2c558..117fe429 100644 --- a/tests/server/package-lock.json +++ b/tests/server/package-lock.json @@ -21,7 +21,7 @@ }, "../..": { "name": "prostgles-server", - "version": "4.2.192", + "version": "4.2.193", "license": "MIT", "dependencies": { "@aws-sdk/client-ses": "^3.699.0",