2019-09-18 15:02:21 +09:00
|
|
|
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core';
|
2019-09-20 11:39:09 +09:00
|
|
|
import {
|
|
|
|
ProtocolRequest,
|
|
|
|
ProtocolResponse,
|
|
|
|
ProtocolEncoder,
|
|
|
|
PacketBody,
|
|
|
|
PacketBodyValue,
|
|
|
|
ProtocolDecoder,
|
|
|
|
ProtocolMessage
|
|
|
|
} from '@ucap-webmessenger/protocol';
|
2019-09-18 15:02:21 +09:00
|
|
|
import { SSOMode } from '../types/sso-mode';
|
|
|
|
import { RoleCode } from '../types/role-code';
|
|
|
|
|
|
|
|
export interface LoginRequest extends ProtocolRequest {
|
|
|
|
// 0. LoginID(s)
|
|
|
|
loginId: string;
|
|
|
|
// 1. LoginPW(e)
|
|
|
|
loginPw: string;
|
|
|
|
// 2. 단말타입(s) (WEB)
|
|
|
|
deviceType: DeviceType;
|
|
|
|
// 3. 디바이스ID(s) (for mobile)
|
|
|
|
deviceId: string;
|
|
|
|
// 4. Token(n)
|
2019-09-19 15:51:42 +09:00
|
|
|
token: string;
|
2019-09-18 15:02:21 +09:00
|
|
|
// 5. 언어코드(s)
|
|
|
|
localeCode: LocaleCode;
|
|
|
|
// 6. Push ID (for mobile)
|
|
|
|
pushId: string;
|
|
|
|
// 7. 기관코드(s)
|
|
|
|
companyCode: string;
|
|
|
|
// 8. PW_ENC_T
|
|
|
|
passwordEncodingType: number;
|
|
|
|
// 9. Client버전(s)
|
|
|
|
clientVersion: string;
|
|
|
|
// 10. 재연결여부(s)
|
|
|
|
reconnect: boolean;
|
|
|
|
// 11. IP(s)
|
|
|
|
ip: string;
|
|
|
|
// 12. 호스트명(s)
|
|
|
|
hostName: string;
|
|
|
|
// 13. SSO모드(SSO_NONE=0:사용안함, SSO_AUTH=1:사용, SSO_AUTO=2:자동실행, SSO_VALI=3:세션연장)
|
|
|
|
ssoMode: SSOMode;
|
|
|
|
// 14. 사용자고유정보(s)
|
|
|
|
userSpecificInformation: string;
|
|
|
|
// 15. 제품 ID(s)
|
|
|
|
productId: string;
|
|
|
|
// 16. 제품명(s)
|
|
|
|
productName: string;
|
|
|
|
// 17. EncData(s)
|
|
|
|
encriptionData?: string;
|
|
|
|
// 18. AccessToken(s)
|
|
|
|
accessToken?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface LoginResponse extends ProtocolResponse {
|
|
|
|
loginId: string;
|
|
|
|
userSeq: number;
|
|
|
|
userInfo: string;
|
|
|
|
token: number;
|
|
|
|
companyCode: string;
|
|
|
|
departmentCode: number;
|
|
|
|
userId: string;
|
|
|
|
passwordEncodingType: number;
|
|
|
|
encriptionKey: string;
|
|
|
|
existingPid: boolean;
|
|
|
|
roleCode: RoleCode;
|
|
|
|
statusMessage1: string;
|
|
|
|
statusMessage2: string;
|
|
|
|
statusMessage3: string;
|
|
|
|
fileDownloadAllow: boolean;
|
|
|
|
fileRetentionPeriod: number;
|
|
|
|
passwordValidityPeriod: number;
|
|
|
|
privateInformationAgree: boolean;
|
|
|
|
madn: string;
|
|
|
|
hardPhoneSadn: string;
|
|
|
|
fmcSadn: string;
|
|
|
|
pbxIndex: number;
|
|
|
|
passwordExpired: boolean;
|
|
|
|
validAccount: boolean;
|
|
|
|
validDevice: boolean;
|
|
|
|
useableDevice: boolean;
|
|
|
|
deviceScreenForcedLock: boolean;
|
|
|
|
tokenString: string;
|
|
|
|
havePermissionsForIntegratedMessageBox: boolean;
|
|
|
|
talkWithMeBotSeq: number;
|
|
|
|
pinCode: string;
|
|
|
|
permissionsForViewSchedule: string;
|
|
|
|
havePermissionsForDevice: boolean;
|
|
|
|
}
|
2019-09-20 11:39:09 +09:00
|
|
|
|
|
|
|
export const encodeLogin: ProtocolEncoder<LoginRequest> = (
|
|
|
|
req: LoginRequest
|
|
|
|
) => {
|
|
|
|
const bodyList: PacketBody[] = [];
|
|
|
|
|
|
|
|
bodyList.push(
|
|
|
|
{ type: PacketBodyValue.String, value: req.loginId },
|
|
|
|
{ type: PacketBodyValue.String, value: req.loginPw },
|
|
|
|
{ type: PacketBodyValue.String, value: req.deviceType },
|
|
|
|
{ type: PacketBodyValue.String, value: req.deviceId },
|
|
|
|
{ type: PacketBodyValue.String, value: req.token },
|
|
|
|
{ type: PacketBodyValue.String, value: req.localeCode },
|
|
|
|
{ type: PacketBodyValue.String, value: req.pushId },
|
|
|
|
{ type: PacketBodyValue.String, value: req.companyCode },
|
|
|
|
{ type: PacketBodyValue.Integer, value: req.passwordEncodingType },
|
|
|
|
{ type: PacketBodyValue.String, value: req.clientVersion },
|
|
|
|
{ type: PacketBodyValue.String, value: req.reconnect ? 'Y' : 'N' },
|
|
|
|
{ type: PacketBodyValue.String, value: req.ip },
|
|
|
|
{ type: PacketBodyValue.String, value: req.hostName },
|
|
|
|
{ type: PacketBodyValue.Integer, value: req.encriptionData ? 2 : 1 },
|
|
|
|
{ type: PacketBodyValue.String, value: req.userSpecificInformation },
|
|
|
|
{ type: PacketBodyValue.String, value: req.productId },
|
|
|
|
{ type: PacketBodyValue.String, value: req.productName }
|
|
|
|
);
|
|
|
|
|
|
|
|
if (req.encriptionData) {
|
|
|
|
bodyList.push(
|
|
|
|
{ type: PacketBodyValue.String, value: req.encriptionData },
|
|
|
|
{ type: PacketBodyValue.String, value: req.accessToken }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bodyList;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const decodeLogin: ProtocolDecoder<LoginResponse> = (
|
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
|
|
|
return {
|
|
|
|
loginId: message.bodyList[0],
|
|
|
|
userSeq: message.bodyList[1],
|
|
|
|
userInfo: message.bodyList[2],
|
|
|
|
token: message.bodyList[3],
|
|
|
|
companyCode: message.bodyList[4],
|
|
|
|
departmentCode: message.bodyList[5],
|
|
|
|
userId: message.bodyList[6],
|
|
|
|
passwordEncodingType: message.bodyList[7],
|
|
|
|
encriptionKey: message.bodyList[8],
|
|
|
|
existingPid: message.bodyList[9] === 'Y' ? true : false,
|
|
|
|
roleCode: message.bodyList[10] as RoleCode,
|
|
|
|
statusMessage1: message.bodyList[11],
|
|
|
|
statusMessage2: message.bodyList[12],
|
|
|
|
statusMessage3: message.bodyList[13],
|
|
|
|
fileDownloadAllow: message.bodyList[14] === 'Y' ? true : false,
|
|
|
|
fileRetentionPeriod: message.bodyList[15],
|
|
|
|
passwordValidityPeriod: message.bodyList[16],
|
|
|
|
privateInformationAgree: message.bodyList[17] === 'Y' ? true : false,
|
|
|
|
madn: message.bodyList[18],
|
|
|
|
hardPhoneSadn: message.bodyList[19],
|
|
|
|
fmcSadn: message.bodyList[20],
|
|
|
|
pbxIndex: message.bodyList[21],
|
|
|
|
passwordExpired: message.bodyList[22] === 'Y' ? true : false,
|
|
|
|
validAccount: message.bodyList[23] === 'Y' ? true : false,
|
|
|
|
validDevice: message.bodyList[24] === 'Y' ? true : false,
|
|
|
|
useableDevice: message.bodyList[25] === 'Y' ? true : false,
|
|
|
|
deviceScreenForcedLock: message.bodyList[26] === 'Y' ? true : false,
|
|
|
|
tokenString: message.bodyList[27],
|
|
|
|
havePermissionsForIntegratedMessageBox:
|
|
|
|
message.bodyList[28] === 'Y' ? true : false,
|
|
|
|
talkWithMeBotSeq: message.bodyList[29],
|
|
|
|
pinCode: message.bodyList[30],
|
|
|
|
permissionsForViewSchedule: message.bodyList[31],
|
|
|
|
havePermissionsForDevice: message.bodyList[32] === 'Y' ? true : false
|
|
|
|
} as LoginResponse;
|
|
|
|
};
|