@floristcloud/api-lib 1.0.83 → 1.2.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/build/commands/auth/index.js +1 -0
- package/build/commands/auth/login-user.command.js +0 -1
- package/build/commands/auth/mobile-login-user.command.js +22 -0
- package/build/commands/auth/reset-password-by-security-code.command.js +5 -2
- package/build/commands/index.js +1 -0
- package/build/commands/session/create-ws-ticket.command.js +11 -0
- package/build/commands/session/get-active-sessions.query.js +12 -0
- package/build/commands/session/index.js +15 -0
- package/build/commands/session/session-logout.command.js +11 -0
- package/build/commands/session/session-revoke-all.command.js +11 -0
- package/build/commands/session/validate-session-s2s.query.js +25 -0
- package/build/commands/session/validate-ws-ticket-s2s.query.js +12 -0
- package/build/constant/error.js +16 -0
- package/build/enum/index.js +1 -0
- package/build/enum/session-platform.enum.js +8 -0
- package/build/schemas/index.js +1 -0
- package/build/schemas/session/session.schema.js +13 -0
- package/commands/auth/index.ts +1 -0
- package/commands/auth/login-user.command.ts +0 -1
- package/commands/auth/mobile-login-user.command.ts +24 -0
- package/commands/auth/reset-password-by-security-code.command.ts +5 -2
- package/commands/index.ts +1 -0
- package/commands/session/create-ws-ticket.command.ts +10 -0
- package/commands/session/get-active-sessions.query.ts +11 -0
- package/commands/session/index.ts +6 -0
- package/commands/session/session-logout.command.ts +10 -0
- package/commands/session/session-revoke-all.command.ts +10 -0
- package/commands/session/validate-session-s2s.query.ts +27 -0
- package/commands/session/validate-ws-ticket-s2s.query.ts +12 -0
- package/constant/error.ts +20 -0
- package/enum/index.ts +1 -0
- package/enum/session-platform.enum.ts +4 -0
- package/package.json +5 -3
- package/schemas/index.ts +1 -0
- package/schemas/session/session.schema.ts +11 -0
|
@@ -21,3 +21,4 @@ __exportStar(require("./login-user.command"), exports);
|
|
|
21
21
|
__exportStar(require("./reset-password-by-token.command"), exports);
|
|
22
22
|
__exportStar(require("./restore-password-by-security-code.command"), exports);
|
|
23
23
|
__exportStar(require("./reset-password-by-security-code.command"), exports);
|
|
24
|
+
__exportStar(require("./mobile-login-user.command"), exports);
|
|
@@ -9,7 +9,6 @@ const LoginUserRequestSchema = zod_1.z.object({
|
|
|
9
9
|
isRemember: zod_1.z.coerce.boolean(),
|
|
10
10
|
});
|
|
11
11
|
const LoginUserResponseSchema = zod_1.z.object({
|
|
12
|
-
accessToken: zod_1.z.string(),
|
|
13
12
|
user: zod_1.z.object({
|
|
14
13
|
uuid: zod_1.z.uuid(),
|
|
15
14
|
email: zod_1.z.email().nullable(),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MobileLoginUserContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const MobileLoginUserRequestSchema = zod_1.z.object({
|
|
6
|
+
email: zod_1.z.email().toLowerCase().optional(),
|
|
7
|
+
phone: zod_1.z.string().optional(),
|
|
8
|
+
password: zod_1.z.string(),
|
|
9
|
+
});
|
|
10
|
+
const MobileLoginUserResponseSchema = zod_1.z.object({
|
|
11
|
+
sessionToken: zod_1.z.string(),
|
|
12
|
+
user: zod_1.z.object({
|
|
13
|
+
uuid: zod_1.z.uuid(),
|
|
14
|
+
email: zod_1.z.email().nullable(),
|
|
15
|
+
phone: zod_1.z.string().nullable(),
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
var MobileLoginUserContractCommand;
|
|
19
|
+
(function (MobileLoginUserContractCommand) {
|
|
20
|
+
MobileLoginUserContractCommand.RequestSchema = MobileLoginUserRequestSchema;
|
|
21
|
+
MobileLoginUserContractCommand.ResponseSchema = MobileLoginUserResponseSchema;
|
|
22
|
+
})(MobileLoginUserContractCommand || (exports.MobileLoginUserContractCommand = MobileLoginUserContractCommand = {}));
|
|
@@ -9,9 +9,12 @@ exports.ResetPasswordBySecurityCodeRequestSchema = zod_1.z.object({
|
|
|
9
9
|
password: zod_1.z.string().min(6),
|
|
10
10
|
});
|
|
11
11
|
exports.ResetPasswordBySecurityCodeResponseSchema = zod_1.z.object({
|
|
12
|
-
message: zod_1.z.string().optional(),
|
|
13
12
|
data: zod_1.z.object({
|
|
14
|
-
|
|
13
|
+
user: zod_1.z.object({
|
|
14
|
+
uuid: zod_1.z.string(),
|
|
15
|
+
email: zod_1.z.string().nullable(),
|
|
16
|
+
phone: zod_1.z.string().nullable(),
|
|
17
|
+
}),
|
|
15
18
|
}),
|
|
16
19
|
});
|
|
17
20
|
var ResetPasswordBySecurityCodeContractCommand;
|
package/build/commands/index.js
CHANGED
|
@@ -62,3 +62,4 @@ __exportStar(require("./product-configuration/delete-product-configuration.comma
|
|
|
62
62
|
__exportStar(require("./product-configuration/find-product-configuration-by-attributes.query"), exports);
|
|
63
63
|
__exportStar(require("./bank-payment"), exports);
|
|
64
64
|
__exportStar(require("./integration"), exports);
|
|
65
|
+
__exportStar(require("./session"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateWsTicketContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const CreateWsTicketResponseSchema = zod_1.z.object({
|
|
6
|
+
ticket: zod_1.z.string(),
|
|
7
|
+
});
|
|
8
|
+
var CreateWsTicketContractCommand;
|
|
9
|
+
(function (CreateWsTicketContractCommand) {
|
|
10
|
+
CreateWsTicketContractCommand.ResponseSchema = CreateWsTicketResponseSchema;
|
|
11
|
+
})(CreateWsTicketContractCommand || (exports.CreateWsTicketContractCommand = CreateWsTicketContractCommand = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetActiveSessionsContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const schemas_1 = require("../../schemas");
|
|
6
|
+
const GetActiveSessionsResponseSchema = zod_1.z.object({
|
|
7
|
+
data: zod_1.z.array(schemas_1.SessionSchema),
|
|
8
|
+
});
|
|
9
|
+
var GetActiveSessionsContractQuery;
|
|
10
|
+
(function (GetActiveSessionsContractQuery) {
|
|
11
|
+
GetActiveSessionsContractQuery.ResponseSchema = GetActiveSessionsResponseSchema;
|
|
12
|
+
})(GetActiveSessionsContractQuery || (exports.GetActiveSessionsContractQuery = GetActiveSessionsContractQuery = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidateWsTicketS2SContractQuery = exports.CreateWsTicketContractCommand = exports.ValidateSessionS2SContractQuery = exports.GetActiveSessionsContractQuery = exports.SessionRevokeAllContractCommand = exports.SessionLogoutContractCommand = void 0;
|
|
4
|
+
var session_logout_command_1 = require("./session-logout.command");
|
|
5
|
+
Object.defineProperty(exports, "SessionLogoutContractCommand", { enumerable: true, get: function () { return session_logout_command_1.SessionLogoutContractCommand; } });
|
|
6
|
+
var session_revoke_all_command_1 = require("./session-revoke-all.command");
|
|
7
|
+
Object.defineProperty(exports, "SessionRevokeAllContractCommand", { enumerable: true, get: function () { return session_revoke_all_command_1.SessionRevokeAllContractCommand; } });
|
|
8
|
+
var get_active_sessions_query_1 = require("./get-active-sessions.query");
|
|
9
|
+
Object.defineProperty(exports, "GetActiveSessionsContractQuery", { enumerable: true, get: function () { return get_active_sessions_query_1.GetActiveSessionsContractQuery; } });
|
|
10
|
+
var validate_session_s2s_query_1 = require("./validate-session-s2s.query");
|
|
11
|
+
Object.defineProperty(exports, "ValidateSessionS2SContractQuery", { enumerable: true, get: function () { return validate_session_s2s_query_1.ValidateSessionS2SContractQuery; } });
|
|
12
|
+
var create_ws_ticket_command_1 = require("./create-ws-ticket.command");
|
|
13
|
+
Object.defineProperty(exports, "CreateWsTicketContractCommand", { enumerable: true, get: function () { return create_ws_ticket_command_1.CreateWsTicketContractCommand; } });
|
|
14
|
+
var validate_ws_ticket_s2s_query_1 = require("./validate-ws-ticket-s2s.query");
|
|
15
|
+
Object.defineProperty(exports, "ValidateWsTicketS2SContractQuery", { enumerable: true, get: function () { return validate_ws_ticket_s2s_query_1.ValidateWsTicketS2SContractQuery; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionLogoutContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const SessionLogoutResponseSchema = zod_1.z.object({
|
|
6
|
+
success: zod_1.z.boolean(),
|
|
7
|
+
});
|
|
8
|
+
var SessionLogoutContractCommand;
|
|
9
|
+
(function (SessionLogoutContractCommand) {
|
|
10
|
+
SessionLogoutContractCommand.ResponseSchema = SessionLogoutResponseSchema;
|
|
11
|
+
})(SessionLogoutContractCommand || (exports.SessionLogoutContractCommand = SessionLogoutContractCommand = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionRevokeAllContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const SessionRevokeAllResponseSchema = zod_1.z.object({
|
|
6
|
+
success: zod_1.z.boolean(),
|
|
7
|
+
});
|
|
8
|
+
var SessionRevokeAllContractCommand;
|
|
9
|
+
(function (SessionRevokeAllContractCommand) {
|
|
10
|
+
SessionRevokeAllContractCommand.ResponseSchema = SessionRevokeAllResponseSchema;
|
|
11
|
+
})(SessionRevokeAllContractCommand || (exports.SessionRevokeAllContractCommand = SessionRevokeAllContractCommand = {}));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidateSessionS2SContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enum_1 = require("../../enum");
|
|
6
|
+
const ValidateSessionS2SRequestSchema = zod_1.z.object({
|
|
7
|
+
sessionToken: zod_1.z.string(),
|
|
8
|
+
});
|
|
9
|
+
const ValidateSessionS2SResponseSchema = zod_1.z.object({
|
|
10
|
+
data: zod_1.z.object({
|
|
11
|
+
userUUID: zod_1.z.string(),
|
|
12
|
+
companyUUID: zod_1.z.string(),
|
|
13
|
+
email: zod_1.z.string().nullable(),
|
|
14
|
+
phone: zod_1.z.string().nullable(),
|
|
15
|
+
roles: zod_1.z.array(zod_1.z.nativeEnum(enum_1.UserRoleEnum)),
|
|
16
|
+
status: zod_1.z.nativeEnum(enum_1.UserStatusEnum),
|
|
17
|
+
isGlobal: zod_1.z.boolean(),
|
|
18
|
+
type: zod_1.z.string().nullable(),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
var ValidateSessionS2SContractQuery;
|
|
22
|
+
(function (ValidateSessionS2SContractQuery) {
|
|
23
|
+
ValidateSessionS2SContractQuery.RequestSchema = ValidateSessionS2SRequestSchema;
|
|
24
|
+
ValidateSessionS2SContractQuery.ResponseSchema = ValidateSessionS2SResponseSchema;
|
|
25
|
+
})(ValidateSessionS2SContractQuery || (exports.ValidateSessionS2SContractQuery = ValidateSessionS2SContractQuery = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidateWsTicketS2SContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const ValidateWsTicketS2SRequestSchema = zod_1.z.object({
|
|
6
|
+
ticket: zod_1.z.string(),
|
|
7
|
+
});
|
|
8
|
+
var ValidateWsTicketS2SContractQuery;
|
|
9
|
+
(function (ValidateWsTicketS2SContractQuery) {
|
|
10
|
+
ValidateWsTicketS2SContractQuery.RequestSchema = ValidateWsTicketS2SRequestSchema;
|
|
11
|
+
// Response is the same as ValidateSessionS2SContractQuery.Response
|
|
12
|
+
})(ValidateWsTicketS2SContractQuery || (exports.ValidateWsTicketS2SContractQuery = ValidateWsTicketS2SContractQuery = {}));
|
package/build/constant/error.js
CHANGED
|
@@ -896,4 +896,20 @@ exports.ERRORS = {
|
|
|
896
896
|
IMPORT_UNKNOWN_ERROR: { code: 'ID002', message: 'Unknown error', httpCode: 500 },
|
|
897
897
|
IMPORT_ITEMS_COUNT_LIMIT_EXCEEDED: { code: 'ID003', message: 'Items count limit exceeded', httpCode: 400 },
|
|
898
898
|
NOT_IMPLEMENTED: { code: 'G001', message: 'Not implemented', httpCode: 501 },
|
|
899
|
+
// SESSION
|
|
900
|
+
SESSION_NOT_FOUND: { code: 'SES001', message: 'Session not found', httpCode: 401 },
|
|
901
|
+
SESSION_REVOKED: { code: 'SES002', message: 'Session has been revoked', httpCode: 401 },
|
|
902
|
+
SESSION_CROSS_TENANT: { code: 'SES003', message: 'Session does not belong to this tenant', httpCode: 401 },
|
|
903
|
+
SESSION_CREATE_FAILED: { code: 'SES004', message: 'Failed to create session', httpCode: 500 },
|
|
904
|
+
SESSION_LIMIT_EXCEEDED: { code: 'SES005', message: 'Maximum number of active sessions exceeded', httpCode: 429 },
|
|
905
|
+
SESSION_REVOKE_FAILED: { code: 'SES006', message: 'Failed to revoke session', httpCode: 500 },
|
|
906
|
+
SESSION_FETCH_FAILED: { code: 'SES007', message: 'Failed to fetch sessions', httpCode: 500 },
|
|
907
|
+
// CSRF
|
|
908
|
+
CSRF_TOKEN_MISSING: { code: 'CSRF001', message: 'CSRF token is missing', httpCode: 403 },
|
|
909
|
+
CSRF_TOKEN_INVALID: { code: 'CSRF002', message: 'CSRF token is invalid', httpCode: 403 },
|
|
910
|
+
// MOBILE AUTH
|
|
911
|
+
MOBILE_BROWSER_REQUEST_REJECTED: { code: 'MOB001', message: 'Browser requests are not allowed on this endpoint', httpCode: 403 },
|
|
912
|
+
MOBILE_RATE_LIMIT_EXCEEDED: { code: 'MOB002', message: 'Too many requests to mobile login endpoint', httpCode: 429 },
|
|
913
|
+
// UNIFIED AUTH (replaces separate USER_NOT_FOUND / INCORRECT_CREDENTIALS for login)
|
|
914
|
+
INVALID_CREDENTIALS: { code: 'AUTH001', message: 'Invalid credentials', httpCode: 401 },
|
|
899
915
|
};
|
package/build/enum/index.js
CHANGED
|
@@ -79,3 +79,4 @@ __exportStar(require("./transaction-type-groups"), exports);
|
|
|
79
79
|
__exportStar(require("./chat-has-manager-mode.enum"), exports);
|
|
80
80
|
__exportStar(require("./chat-no-manager-mode.enum"), exports);
|
|
81
81
|
__exportStar(require("./match-confidence.enum"), exports);
|
|
82
|
+
__exportStar(require("./session-platform.enum"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionPlatformEnum = void 0;
|
|
4
|
+
var SessionPlatformEnum;
|
|
5
|
+
(function (SessionPlatformEnum) {
|
|
6
|
+
SessionPlatformEnum["WEB"] = "WEB";
|
|
7
|
+
SessionPlatformEnum["MOBILE"] = "MOBILE";
|
|
8
|
+
})(SessionPlatformEnum || (exports.SessionPlatformEnum = SessionPlatformEnum = {}));
|
package/build/schemas/index.js
CHANGED
|
@@ -74,3 +74,4 @@ __exportStar(require("./client-payment-identifier/client-payment-identifier.sche
|
|
|
74
74
|
__exportStar(require("./bank-payment/get-bank-payment-match-suggestions.schema"), exports);
|
|
75
75
|
__exportStar(require("./messenger-profile"), exports);
|
|
76
76
|
__exportStar(require("./error-message.schema"), exports);
|
|
77
|
+
__exportStar(require("./session/session.schema"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enum_1 = require("../../enum");
|
|
6
|
+
exports.SessionSchema = zod_1.z.object({
|
|
7
|
+
id: zod_1.z.string(),
|
|
8
|
+
platform: zod_1.z.nativeEnum(enum_1.SessionPlatformEnum),
|
|
9
|
+
userAgent: zod_1.z.string().nullable(),
|
|
10
|
+
ipAddress: zod_1.z.string().nullable(),
|
|
11
|
+
lastActiveAt: zod_1.z.coerce.date(),
|
|
12
|
+
createdAt: zod_1.z.coerce.date(),
|
|
13
|
+
});
|
package/commands/auth/index.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const MobileLoginUserRequestSchema = z.object({
|
|
4
|
+
email: z.email().toLowerCase().optional(),
|
|
5
|
+
phone: z.string().optional(),
|
|
6
|
+
password: z.string(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const MobileLoginUserResponseSchema = z.object({
|
|
10
|
+
sessionToken: z.string(),
|
|
11
|
+
user: z.object({
|
|
12
|
+
uuid: z.uuid(),
|
|
13
|
+
email: z.email().nullable(),
|
|
14
|
+
phone: z.string().nullable(),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export namespace MobileLoginUserContractCommand {
|
|
19
|
+
export const RequestSchema = MobileLoginUserRequestSchema;
|
|
20
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
21
|
+
|
|
22
|
+
export const ResponseSchema = MobileLoginUserResponseSchema;
|
|
23
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
24
|
+
}
|
|
@@ -8,9 +8,12 @@ export const ResetPasswordBySecurityCodeRequestSchema = z.object({
|
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
export const ResetPasswordBySecurityCodeResponseSchema = z.object({
|
|
11
|
-
message: z.string().optional(),
|
|
12
11
|
data: z.object({
|
|
13
|
-
|
|
12
|
+
user: z.object({
|
|
13
|
+
uuid: z.string(),
|
|
14
|
+
email: z.string().nullable(),
|
|
15
|
+
phone: z.string().nullable(),
|
|
16
|
+
}),
|
|
14
17
|
}),
|
|
15
18
|
});
|
|
16
19
|
|
package/commands/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const CreateWsTicketResponseSchema = z.object({
|
|
4
|
+
ticket: z.string(),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export namespace CreateWsTicketContractCommand {
|
|
8
|
+
export const ResponseSchema = CreateWsTicketResponseSchema;
|
|
9
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SessionSchema } from '../../schemas';
|
|
3
|
+
|
|
4
|
+
const GetActiveSessionsResponseSchema = z.object({
|
|
5
|
+
data: z.array(SessionSchema),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export namespace GetActiveSessionsContractQuery {
|
|
9
|
+
export const ResponseSchema = GetActiveSessionsResponseSchema;
|
|
10
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { SessionLogoutContractCommand } from './session-logout.command';
|
|
2
|
+
export { SessionRevokeAllContractCommand } from './session-revoke-all.command';
|
|
3
|
+
export { GetActiveSessionsContractQuery } from './get-active-sessions.query';
|
|
4
|
+
export { ValidateSessionS2SContractQuery } from './validate-session-s2s.query';
|
|
5
|
+
export { CreateWsTicketContractCommand } from './create-ws-ticket.command';
|
|
6
|
+
export { ValidateWsTicketS2SContractQuery } from './validate-ws-ticket-s2s.query';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const SessionLogoutResponseSchema = z.object({
|
|
4
|
+
success: z.boolean(),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export namespace SessionLogoutContractCommand {
|
|
8
|
+
export const ResponseSchema = SessionLogoutResponseSchema;
|
|
9
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const SessionRevokeAllResponseSchema = z.object({
|
|
4
|
+
success: z.boolean(),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export namespace SessionRevokeAllContractCommand {
|
|
8
|
+
export const ResponseSchema = SessionRevokeAllResponseSchema;
|
|
9
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { UserRoleEnum, UserStatusEnum } from '../../enum';
|
|
3
|
+
|
|
4
|
+
const ValidateSessionS2SRequestSchema = z.object({
|
|
5
|
+
sessionToken: z.string(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const ValidateSessionS2SResponseSchema = z.object({
|
|
9
|
+
data: z.object({
|
|
10
|
+
userUUID: z.string(),
|
|
11
|
+
companyUUID: z.string(),
|
|
12
|
+
email: z.string().nullable(),
|
|
13
|
+
phone: z.string().nullable(),
|
|
14
|
+
roles: z.array(z.nativeEnum(UserRoleEnum)),
|
|
15
|
+
status: z.nativeEnum(UserStatusEnum),
|
|
16
|
+
isGlobal: z.boolean(),
|
|
17
|
+
type: z.string().nullable(),
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export namespace ValidateSessionS2SContractQuery {
|
|
22
|
+
export const RequestSchema = ValidateSessionS2SRequestSchema;
|
|
23
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
24
|
+
|
|
25
|
+
export const ResponseSchema = ValidateSessionS2SResponseSchema;
|
|
26
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const ValidateWsTicketS2SRequestSchema = z.object({
|
|
4
|
+
ticket: z.string(),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export namespace ValidateWsTicketS2SContractQuery {
|
|
8
|
+
export const RequestSchema = ValidateWsTicketS2SRequestSchema;
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
// Response is the same as ValidateSessionS2SContractQuery.Response
|
|
12
|
+
}
|
package/constant/error.ts
CHANGED
|
@@ -948,4 +948,24 @@ export const ERRORS = {
|
|
|
948
948
|
IMPORT_ITEMS_COUNT_LIMIT_EXCEEDED: { code: 'ID003', message: 'Items count limit exceeded', httpCode: 400 },
|
|
949
949
|
|
|
950
950
|
NOT_IMPLEMENTED: { code: 'G001', message: 'Not implemented', httpCode: 501 },
|
|
951
|
+
|
|
952
|
+
// SESSION
|
|
953
|
+
SESSION_NOT_FOUND: { code: 'SES001', message: 'Session not found', httpCode: 401 },
|
|
954
|
+
SESSION_REVOKED: { code: 'SES002', message: 'Session has been revoked', httpCode: 401 },
|
|
955
|
+
SESSION_CROSS_TENANT: { code: 'SES003', message: 'Session does not belong to this tenant', httpCode: 401 },
|
|
956
|
+
SESSION_CREATE_FAILED: { code: 'SES004', message: 'Failed to create session', httpCode: 500 },
|
|
957
|
+
SESSION_LIMIT_EXCEEDED: { code: 'SES005', message: 'Maximum number of active sessions exceeded', httpCode: 429 },
|
|
958
|
+
SESSION_REVOKE_FAILED: { code: 'SES006', message: 'Failed to revoke session', httpCode: 500 },
|
|
959
|
+
SESSION_FETCH_FAILED: { code: 'SES007', message: 'Failed to fetch sessions', httpCode: 500 },
|
|
960
|
+
|
|
961
|
+
// CSRF
|
|
962
|
+
CSRF_TOKEN_MISSING: { code: 'CSRF001', message: 'CSRF token is missing', httpCode: 403 },
|
|
963
|
+
CSRF_TOKEN_INVALID: { code: 'CSRF002', message: 'CSRF token is invalid', httpCode: 403 },
|
|
964
|
+
|
|
965
|
+
// MOBILE AUTH
|
|
966
|
+
MOBILE_BROWSER_REQUEST_REJECTED: { code: 'MOB001', message: 'Browser requests are not allowed on this endpoint', httpCode: 403 },
|
|
967
|
+
MOBILE_RATE_LIMIT_EXCEEDED: { code: 'MOB002', message: 'Too many requests to mobile login endpoint', httpCode: 429 },
|
|
968
|
+
|
|
969
|
+
// UNIFIED AUTH (replaces separate USER_NOT_FOUND / INCORRECT_CREDENTIALS for login)
|
|
970
|
+
INVALID_CREDENTIALS: { code: 'AUTH001', message: 'Invalid credentials', httpCode: 401 },
|
|
951
971
|
} as const;
|
package/enum/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floristcloud/api-lib",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"main": "./build/index.js"
|
|
7
|
+
},
|
|
6
8
|
"scripts": {
|
|
7
9
|
"prepublish": "rm -rf build && tsc",
|
|
8
|
-
"build": "tsc",
|
|
10
|
+
"build": "rm -rf build && tsc",
|
|
9
11
|
"clean": "rm -rf build node_modules"
|
|
10
12
|
},
|
|
11
13
|
"keywords": [],
|
package/schemas/index.ts
CHANGED
|
@@ -58,3 +58,4 @@ export * from './client-payment-identifier/client-payment-identifier.schema';
|
|
|
58
58
|
export * from './bank-payment/get-bank-payment-match-suggestions.schema';
|
|
59
59
|
export * from './messenger-profile';
|
|
60
60
|
export * from './error-message.schema';
|
|
61
|
+
export * from './session/session.schema';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SessionPlatformEnum } from '../../enum';
|
|
3
|
+
|
|
4
|
+
export const SessionSchema = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
platform: z.nativeEnum(SessionPlatformEnum),
|
|
7
|
+
userAgent: z.string().nullable(),
|
|
8
|
+
ipAddress: z.string().nullable(),
|
|
9
|
+
lastActiveAt: z.coerce.date(),
|
|
10
|
+
createdAt: z.coerce.date(),
|
|
11
|
+
});
|