parameter of api call is modified
This commit is contained in:
parent
9464e3b6bd
commit
d918b9a4db
35
angular.json
35
angular.json
|
@ -1206,6 +1206,41 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ucap-webmessenger-util": {
|
||||||
|
"projectType": "library",
|
||||||
|
"root": "projects/ucap-webmessenger-util",
|
||||||
|
"sourceRoot": "projects/ucap-webmessenger-util/src",
|
||||||
|
"prefix": "ucap-util",
|
||||||
|
"architect": {
|
||||||
|
"build": {
|
||||||
|
"builder": "@angular-devkit/build-ng-packagr:build",
|
||||||
|
"options": {
|
||||||
|
"tsConfig": "projects/ucap-webmessenger-util/tsconfig.lib.json",
|
||||||
|
"project": "projects/ucap-webmessenger-util/ng-package.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"builder": "@angular-devkit/build-angular:karma",
|
||||||
|
"options": {
|
||||||
|
"main": "projects/ucap-webmessenger-util/src/test.ts",
|
||||||
|
"tsConfig": "projects/ucap-webmessenger-util/tsconfig.spec.json",
|
||||||
|
"karmaConfig": "projects/ucap-webmessenger-util/karma.conf.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
|
"options": {
|
||||||
|
"tsConfig": [
|
||||||
|
"projects/ucap-webmessenger-util/tsconfig.lib.json",
|
||||||
|
"projects/ucap-webmessenger-util/tsconfig.spec.json"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"**/node_modules/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultProject": "ucap-webmessenger-app"
|
"defaultProject": "ucap-webmessenger-app"
|
||||||
|
|
16353
package-lock.json
generated
Normal file
16353
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,9 @@
|
||||||
import { DeviceType } from '@ucap-webmessenger/core';
|
import { DeviceType } from '@ucap-webmessenger/core';
|
||||||
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
|
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
|
||||||
|
import { SyncMode } from '../types/sync-mode.type';
|
||||||
|
|
||||||
export interface VersionInfoRequest extends APIRequest {
|
export interface VersionInfo2Request extends APIRequest {
|
||||||
userSeq?: string;
|
userSeq?: number;
|
||||||
deviceType: DeviceType;
|
deviceType: DeviceType;
|
||||||
token?: string;
|
token?: string;
|
||||||
companyGroupType: string;
|
companyGroupType: string;
|
||||||
|
@ -10,20 +11,19 @@ export interface VersionInfoRequest extends APIRequest {
|
||||||
loginId: string;
|
loginId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VersionInfoResponse extends APIResponse {
|
export interface VersionInfo2Response extends APIResponse {
|
||||||
protocolCode?: string;
|
protocolCode?: number;
|
||||||
syncMode?: string;
|
syncMode?: SyncMode;
|
||||||
appVersion?: string;
|
appVersion?: string;
|
||||||
installUrl?: string;
|
installUrl?: string;
|
||||||
serverIp?: string;
|
serverIp?: string;
|
||||||
serverPort?: string;
|
|
||||||
uploadUrl?: string;
|
uploadUrl?: string;
|
||||||
downloadUrl?: string;
|
downloadUrl?: string;
|
||||||
profileUploadUrl?: string;
|
profileUploadUrl?: string;
|
||||||
profileRoot?: string;
|
profileRoot?: string;
|
||||||
fileTerm?: string;
|
fileTerm?: number;
|
||||||
fileAllowSize?: string;
|
fileAllowSize?: number;
|
||||||
authIp?: string;
|
authIp?: boolean;
|
||||||
launcherAppVersion?: string;
|
launcherAppVersion?: string;
|
||||||
launcherInstallUrl?: string;
|
launcherInstallUrl?: string;
|
||||||
}
|
}
|
|
@ -6,11 +6,26 @@ import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
import { _MODULE_CONFIG } from '../types/token';
|
import { _MODULE_CONFIG } from '../types/token';
|
||||||
import {
|
import {
|
||||||
VersionInfoRequest,
|
VersionInfo2Request,
|
||||||
VersionInfoResponse
|
VersionInfo2Response
|
||||||
} from '../models/version-info';
|
} from '../models/version-info2';
|
||||||
import { UpdateInfoRequest, UpdateInfoResponse } from '../models/update-info';
|
import { UpdateInfoRequest, UpdateInfoResponse } from '../models/update-info';
|
||||||
import { ModuleConfig } from '../types/module-config';
|
import { ModuleConfig } from '../types/module-config';
|
||||||
|
import { ParameterUtil } from '@ucap-webmessenger/api';
|
||||||
|
import { SyncMode } from '../types/sync-mode.type';
|
||||||
|
|
||||||
|
const versionInfo2Parameters = {
|
||||||
|
userSeq: 'p_user_seq',
|
||||||
|
deviceType: 'p_device_type',
|
||||||
|
token: 'p_token',
|
||||||
|
companyGroupType: 'p_comp_group_type',
|
||||||
|
companyCode: 'p_comp_code',
|
||||||
|
loginId: 'p_login_id'
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateInfoParameters = {
|
||||||
|
deviceType: 'p_device_type'
|
||||||
|
};
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -21,43 +36,37 @@ export class PublicApiService {
|
||||||
private httpClient: HttpClient
|
private httpClient: HttpClient
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public versionInfo(req: VersionInfoRequest): Observable<VersionInfoResponse> {
|
public versionInfo2(
|
||||||
|
req: VersionInfo2Request
|
||||||
|
): Observable<VersionInfo2Response> {
|
||||||
return this.httpClient
|
return this.httpClient
|
||||||
.post<any>(
|
.post<any>(
|
||||||
this.moduleConfig.urls.versionInfo,
|
this.moduleConfig.urls.versionInfo2,
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
params: {
|
params: ParameterUtil.make(versionInfo2Parameters, req)
|
||||||
p_user_seq: req.userSeq,
|
|
||||||
p_device_type: req.deviceType,
|
|
||||||
p_token: req.token,
|
|
||||||
p_comp_group_type: req.companyGroupType,
|
|
||||||
p_comp_code: req.companyCode,
|
|
||||||
p_login_id: req.loginId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.pipe(
|
.pipe(
|
||||||
map(res => {
|
map((res: any) => {
|
||||||
return {
|
return {
|
||||||
statusCode: res.StatusCode,
|
statusCode: res.StatusCode,
|
||||||
errorMessage: res.ErrorMessage,
|
errorMessage: res.ErrorMessage,
|
||||||
protocolCode: res.ProtocolCD,
|
|
||||||
syncMode: res.SyncMode,
|
|
||||||
appVersion: res.AppVer,
|
appVersion: res.AppVer,
|
||||||
installUrl: res.InstallURL,
|
authIp: res.AuthIP === 'Y' ? true : false,
|
||||||
serverIp: res.ServerIP,
|
|
||||||
serverPort: res.ServerPort,
|
|
||||||
uploadUrl: res.UploadURL,
|
|
||||||
downloadUrl: res.DownloadURL,
|
downloadUrl: res.DownloadURL,
|
||||||
profileUploadUrl: res.ProfileUploadURL,
|
fileAllowSize: Number(res.FileAllowSize),
|
||||||
profileRoot: res.ProfileRoot,
|
fileTerm: Number(res.FileTerm),
|
||||||
fileTerm: res.FileTerm,
|
installUrl: res.InstallURL,
|
||||||
fileAllowSize: res.FileAllowSize,
|
|
||||||
authIp: res.AuthIP,
|
|
||||||
launcherAppVersion: res.LauncherAppVer,
|
launcherAppVersion: res.LauncherAppVer,
|
||||||
launcherInstallUrl: res.LauncherInstallURL
|
launcherInstallUrl: res.LauncherInstallURL,
|
||||||
} as VersionInfoResponse;
|
profileRoot: res.ProfileRoot,
|
||||||
|
profileUploadUrl: res.ProfileUploadURL,
|
||||||
|
protocolCode: Number(res.ProtocolCD),
|
||||||
|
serverIp: res.ServerIP,
|
||||||
|
syncMode: res.SyncMode as SyncMode,
|
||||||
|
uploadUrl: res.UploadURL
|
||||||
|
} as VersionInfo2Response;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -68,9 +77,7 @@ export class PublicApiService {
|
||||||
this.moduleConfig.urls.updateInfo,
|
this.moduleConfig.urls.updateInfo,
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
params: {
|
params: ParameterUtil.make(updateInfoParameters, req)
|
||||||
p_device_type: req.deviceType
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.pipe(
|
.pipe(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export interface ModuleConfig {
|
export interface ModuleConfig {
|
||||||
urls: {
|
urls: {
|
||||||
versionInfo: string;
|
versionInfo2: string;
|
||||||
updateInfo: string;
|
updateInfo: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
export enum SyncMode {
|
||||||
|
BC = 'BC',
|
||||||
|
SC = 'SC'
|
||||||
|
}
|
|
@ -2,11 +2,12 @@
|
||||||
* Public API Surface of ucap-webmessenger-api-public
|
* Public API Surface of ucap-webmessenger-api-public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './lib/types/module-config';
|
|
||||||
|
|
||||||
export * from './lib/models/update-info';
|
export * from './lib/models/update-info';
|
||||||
export * from './lib/models/version-info';
|
export * from './lib/models/version-info2';
|
||||||
|
|
||||||
export * from './lib/services/public-api.service';
|
export * from './lib/services/public-api.service';
|
||||||
|
|
||||||
|
export * from './lib/types/module-config';
|
||||||
|
export * from './lib/types/sync-mode.type';
|
||||||
|
|
||||||
export * from './lib/ucap-public-api.module';
|
export * from './lib/ucap-public-api.module';
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
import { StatusCode } from '../types/status-code.type';
|
||||||
|
|
||||||
export interface APIRequest {
|
export interface APIRequest {
|
||||||
_id?: string;
|
_id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface APIResponse {
|
export interface APIResponse {
|
||||||
_id?: string;
|
_id?: string;
|
||||||
statusCode: string;
|
statusCode: StatusCode;
|
||||||
errorMessage: string;
|
errorMessage: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
export type Parameter = {
|
||||||
|
[param: string]: string | string[];
|
||||||
|
} | null;
|
||||||
|
|
||||||
|
export class ParameterUtil {
|
||||||
|
public static make(parameterMap: {}, param: {}): Parameter {
|
||||||
|
const parameter: Parameter = {};
|
||||||
|
|
||||||
|
Object.keys(parameterMap).map(key => {
|
||||||
|
if (!param.hasOwnProperty(key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!!param[key]) {
|
||||||
|
parameter[parameterMap[key]] = param[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return 0 === Object.keys(parameter).length ? null : parameter;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,3 +5,5 @@
|
||||||
export * from './lib/models/api';
|
export * from './lib/models/api';
|
||||||
|
|
||||||
export * from './lib/types/status-code.type';
|
export * from './lib/types/status-code.type';
|
||||||
|
|
||||||
|
export * from './lib/utils/parameter.util';
|
||||||
|
|
|
@ -1,14 +1,28 @@
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule, APP_INITIALIZER } from '@angular/core';
|
||||||
|
|
||||||
import { SERVICES } from './services';
|
|
||||||
import { UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
|
import { UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
|
||||||
import { ElectronNativeService } from '@ucap-webmessenger/native-electron';
|
import { ElectronNativeService } from '@ucap-webmessenger/native-electron';
|
||||||
|
|
||||||
|
import { SERVICES } from './services';
|
||||||
|
import { AppService } from './services/app.service';
|
||||||
|
|
||||||
|
export function initializeApp(appService: AppService) {
|
||||||
|
return (): Promise<any> => {
|
||||||
|
return appService.postInit();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [],
|
imports: [],
|
||||||
exports: [],
|
exports: [],
|
||||||
providers: [
|
providers: [
|
||||||
...SERVICES,
|
...SERVICES,
|
||||||
|
{
|
||||||
|
provide: APP_INITIALIZER,
|
||||||
|
useFactory: initializeApp,
|
||||||
|
deps: [AppService],
|
||||||
|
multi: true
|
||||||
|
},
|
||||||
{ provide: UCAP_NATIVE_SERVICE, useClass: ElectronNativeService }
|
{ provide: UCAP_NATIVE_SERVICE, useClass: ElectronNativeService }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,11 +11,16 @@ import { UCapPublicApiModule } from '@ucap-webmessenger/api-public';
|
||||||
|
|
||||||
import { UCapPiModule } from '@ucap-webmessenger/pi';
|
import { UCapPiModule } from '@ucap-webmessenger/pi';
|
||||||
|
|
||||||
|
import { UCapProtocolModule } from '@ucap-webmessenger/protocol';
|
||||||
|
import { UCapAuthenticationProtocolModule } from '@ucap-webmessenger/protocol-authentication';
|
||||||
|
|
||||||
import { UCapUiModule } from '@ucap-webmessenger/ui';
|
import { UCapUiModule } from '@ucap-webmessenger/ui';
|
||||||
import { UCapUiAccountModule } from '@ucap-webmessenger/ui-account';
|
import { UCapUiAccountModule } from '@ucap-webmessenger/ui-account';
|
||||||
|
|
||||||
import { UCapWebStorageModule } from '@ucap-webmessenger/web-storage';
|
import { UCapWebStorageModule } from '@ucap-webmessenger/web-storage';
|
||||||
|
|
||||||
|
import { UCapUtilModule } from '@ucap-webmessenger/util';
|
||||||
|
|
||||||
import { environment } from '../environments/environment';
|
import { environment } from '../environments/environment';
|
||||||
|
|
||||||
import { AppProviderModule } from './app-provider.module';
|
import { AppProviderModule } from './app-provider.module';
|
||||||
|
@ -49,11 +54,20 @@ import { GUARDS } from './guards';
|
||||||
urls: environment.urls.pi
|
urls: environment.urls.pi
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
UCapProtocolModule.forRoot({
|
||||||
|
urls: environment.urls.protocol,
|
||||||
|
reconnect: environment.protocol.reconnect,
|
||||||
|
requestId: environment.protocol.requestId
|
||||||
|
}),
|
||||||
|
UCapAuthenticationProtocolModule.forRoot(),
|
||||||
|
|
||||||
UCapUiModule.forRoot(),
|
UCapUiModule.forRoot(),
|
||||||
UCapUiAccountModule.forRoot(),
|
UCapUiAccountModule.forRoot(),
|
||||||
|
|
||||||
UCapWebStorageModule.forRoot(),
|
UCapWebStorageModule.forRoot(),
|
||||||
|
|
||||||
|
UCapUtilModule.forRoot(),
|
||||||
|
|
||||||
AppProviderModule,
|
AppProviderModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
AppStoreModule,
|
AppStoreModule,
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AppService {
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
public postInit(): Promise<void> {
|
||||||
|
return new Promise<void>((resolve, reject) => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ import {
|
||||||
LocalStorageService
|
LocalStorageService
|
||||||
} from '@ucap-webmessenger/web-storage';
|
} from '@ucap-webmessenger/web-storage';
|
||||||
import { LoginInfo, KEY_LOGIN_INFO } from '../types';
|
import { LoginInfo, KEY_LOGIN_INFO } from '../types';
|
||||||
|
import { EnviromentUtilService } from '@ucap-webmessenger/util';
|
||||||
|
import { DeviceType } from '@ucap-webmessenger/core';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -16,7 +18,8 @@ export class AuthenticationService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private sessionStorageService: SessionStorageService,
|
private sessionStorageService: SessionStorageService,
|
||||||
private localStorageService: LocalStorageService
|
private localStorageService: LocalStorageService,
|
||||||
|
private enviromentUtilService: EnviromentUtilService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
authenticated(): boolean {
|
authenticated(): boolean {
|
||||||
|
@ -25,9 +28,22 @@ export class AuthenticationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
login(loginInfo: LoginInfo, rememberMe: boolean) {
|
login(loginInfo: LoginInfo, rememberMe: boolean) {
|
||||||
|
let deviceType: DeviceType;
|
||||||
|
|
||||||
|
if (this.enviromentUtilService.nodeWebkit()) {
|
||||||
|
deviceType = DeviceType.PC;
|
||||||
|
} else if (this.enviromentUtilService.android()) {
|
||||||
|
deviceType = DeviceType.Android;
|
||||||
|
} else if (this.enviromentUtilService.ios()) {
|
||||||
|
deviceType = DeviceType.iOS;
|
||||||
|
} else {
|
||||||
|
deviceType = DeviceType.Web;
|
||||||
|
}
|
||||||
|
|
||||||
this.sessionStorageService.set<LoginInfo>(KEY_LOGIN_INFO, {
|
this.sessionStorageService.set<LoginInfo>(KEY_LOGIN_INFO, {
|
||||||
...loginInfo,
|
...loginInfo,
|
||||||
loginPw: CryptoJS.enc.Hex.stringify(CryptoJS.SHA256(loginInfo.loginPw))
|
loginPw: CryptoJS.enc.Hex.stringify(CryptoJS.SHA256(loginInfo.loginPw)),
|
||||||
|
deviceType
|
||||||
});
|
});
|
||||||
|
|
||||||
if (rememberMe) {
|
if (rememberMe) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
import { AppService } from './app.service';
|
||||||
import { AuthenticationService } from './authentication.service';
|
import { AuthenticationService } from './authentication.service';
|
||||||
import { LoaderService } from './loader.service';
|
import { LoaderService } from './loader.service';
|
||||||
|
|
||||||
export const SERVICES = [AuthenticationService, LoaderService];
|
export const SERVICES = [AppService, AuthenticationService, LoaderService];
|
||||||
|
|
|
@ -21,6 +21,15 @@ export const loginSuccess = createAction(
|
||||||
}>()
|
}>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const postLoginSuccess = createAction(
|
||||||
|
'[Account::Authentication] Post Login Success',
|
||||||
|
props<{
|
||||||
|
loginInfo: LoginInfo;
|
||||||
|
rememberMe: boolean;
|
||||||
|
login2Response: Login2Response;
|
||||||
|
}>()
|
||||||
|
);
|
||||||
|
|
||||||
export const loginFailure = createAction(
|
export const loginFailure = createAction(
|
||||||
'[Account::Authentication] Login Failure',
|
'[Account::Authentication] Login Failure',
|
||||||
props<{ error: any }>()
|
props<{ error: any }>()
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Router } from '@angular/router';
|
||||||
import { Actions, ofType, createEffect } from '@ngrx/effects';
|
import { Actions, ofType, createEffect } from '@ngrx/effects';
|
||||||
|
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
import { catchError, exhaustMap, map, tap, switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
PiService,
|
PiService,
|
||||||
|
@ -17,7 +17,8 @@ import {
|
||||||
loginSuccess,
|
loginSuccess,
|
||||||
loginFailure,
|
loginFailure,
|
||||||
loginRedirect,
|
loginRedirect,
|
||||||
logout
|
logout,
|
||||||
|
postLoginSuccess
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import { LoginInfo } from '../../../types';
|
import { LoginInfo } from '../../../types';
|
||||||
import { AuthenticationService } from '../../../services/authentication.service';
|
import { AuthenticationService } from '../../../services/authentication.service';
|
||||||
|
@ -55,24 +56,32 @@ export class Effects {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
loginSuccess$ = createEffect(
|
loginSuccess$ = createEffect(() =>
|
||||||
() =>
|
|
||||||
this.actions$.pipe(
|
this.actions$.pipe(
|
||||||
ofType(loginSuccess),
|
ofType(loginSuccess),
|
||||||
tap(params => {
|
map(action => action),
|
||||||
this.nativeService
|
exhaustMap(
|
||||||
.checkForUpdates()
|
(params: {
|
||||||
.then(update => {
|
loginInfo: LoginInfo;
|
||||||
|
rememberMe: boolean;
|
||||||
|
login2Response: Login2Response;
|
||||||
|
}) =>
|
||||||
|
this.nativeService.checkForUpdates().pipe(
|
||||||
|
map((update: boolean) => {
|
||||||
if (!update) {
|
if (!update) {
|
||||||
this.authentication.login(params.loginInfo, params.rememberMe);
|
this.authentication.login(params.loginInfo, params.rememberMe);
|
||||||
this.router.navigate(['/messenger']);
|
this.router.navigate(['/messenger']);
|
||||||
return;
|
return postLoginSuccess({
|
||||||
|
loginInfo: params.loginInfo,
|
||||||
|
rememberMe: params.rememberMe,
|
||||||
|
login2Response: params.login2Response
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
.catch(reson => {});
|
catchError(error => of(error))
|
||||||
})
|
)
|
||||||
),
|
)
|
||||||
{ dispatch: false }
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
loginRedirect$ = createEffect(
|
loginRedirect$ = createEffect(
|
||||||
|
|
|
@ -12,10 +12,12 @@ import { storeFreeze } from 'ngrx-store-freeze';
|
||||||
import { environment } from '../../environments/environment';
|
import { environment } from '../../environments/environment';
|
||||||
|
|
||||||
import * as AccountStore from './account';
|
import * as AccountStore from './account';
|
||||||
|
import * as SettingStore from './setting';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
router: fromRouter.RouterReducerState<any>;
|
router: fromRouter.RouterReducerState<any>;
|
||||||
account: AccountStore.State;
|
account: AccountStore.State;
|
||||||
|
setting: SettingStore.State;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,11 +30,15 @@ export const ROOT_REDUCERS = new InjectionToken<
|
||||||
>('Root reducers token', {
|
>('Root reducers token', {
|
||||||
factory: () => ({
|
factory: () => ({
|
||||||
router: fromRouter.routerReducer,
|
router: fromRouter.routerReducer,
|
||||||
account: AccountStore.reducers
|
account: AccountStore.reducers,
|
||||||
|
setting: SettingStore.reducers
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
export const effects: Type<any>[] = [...AccountStore.effects];
|
export const effects: Type<any>[] = [
|
||||||
|
...AccountStore.effects,
|
||||||
|
...SettingStore.effects
|
||||||
|
];
|
||||||
|
|
||||||
export function logger(reducer: ActionReducer<State>): ActionReducer<State> {
|
export function logger(reducer: ActionReducer<State>): ActionReducer<State> {
|
||||||
return (state, action) => {
|
return (state, action) => {
|
||||||
|
@ -54,3 +60,7 @@ export const metaReducers: MetaReducer<State>[] = !environment.production
|
||||||
export const AccountSelector = AccountStore.selectors(
|
export const AccountSelector = AccountStore.selectors(
|
||||||
(state: State) => state.account
|
(state: State) => state.account
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const SettingSelector = SettingStore.selectors(
|
||||||
|
(state: State) => state.setting
|
||||||
|
);
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { Type } from '@angular/core';
|
||||||
|
import { Action, combineReducers, Selector, createSelector } from '@ngrx/store';
|
||||||
|
|
||||||
|
import * as VersionInfoStore from './version-info';
|
||||||
|
|
||||||
|
export interface State {
|
||||||
|
versionInfo: VersionInfoStore.State;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const effects: Type<any>[] = [VersionInfoStore.Effects];
|
||||||
|
|
||||||
|
export function reducers(state: State | undefined, action: Action) {
|
||||||
|
return combineReducers({
|
||||||
|
versionInfo: VersionInfoStore.reducers
|
||||||
|
})(state, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function selectors<S>(selector: Selector<any, State>) {
|
||||||
|
return {
|
||||||
|
VersionInfoSelector: VersionInfoStore.selectors(
|
||||||
|
createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.versionInfo
|
||||||
|
)
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,18 +1,18 @@
|
||||||
import { createAction, props } from '@ngrx/store';
|
import { createAction, props } from '@ngrx/store';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
VersionInfoRequest,
|
VersionInfo2Request,
|
||||||
VersionInfoResponse
|
VersionInfo2Response
|
||||||
} from '@ucap-webmessenger/api-public';
|
} from '@ucap-webmessenger/api-public';
|
||||||
|
|
||||||
export const fetch = createAction(
|
export const fetch = createAction(
|
||||||
'[Setting::VersionInfo] Fetch',
|
'[Setting::VersionInfo] Fetch',
|
||||||
props<VersionInfoRequest>()
|
props<VersionInfo2Request>()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const fetchSuccess = createAction(
|
export const fetchSuccess = createAction(
|
||||||
'[Setting::VersionInfo] Fetch Success',
|
'[Setting::VersionInfo] Fetch Success',
|
||||||
props<VersionInfoResponse>()
|
props<VersionInfo2Response>()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const fetchFailure = createAction(
|
export const fetchFailure = createAction(
|
||||||
|
|
|
@ -6,20 +6,44 @@ import { Actions, ofType, createEffect } from '@ngrx/effects';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { fetch, fetchSuccess, fetchFailure } from './actions';
|
|
||||||
import { PublicApiService } from '@ucap-webmessenger/api-public';
|
import { PublicApiService } from '@ucap-webmessenger/api-public';
|
||||||
import { StatusCode } from '@ucap-webmessenger/api';
|
import { StatusCode } from '@ucap-webmessenger/api';
|
||||||
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
|
|
||||||
|
import { postLoginSuccess } from '../../account/authentication';
|
||||||
|
|
||||||
|
import { fetch, fetchSuccess, fetchFailure } from './actions';
|
||||||
|
import { LoginInfo, KEY_LOGIN_INFO } from '../../../types';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class Effects {
|
export class Effects {
|
||||||
|
init$ = createEffect(() =>
|
||||||
|
this.actions$.pipe(
|
||||||
|
ofType(postLoginSuccess),
|
||||||
|
map(action => {
|
||||||
|
const loginInfo = this.sessionStorageService.get<LoginInfo>(
|
||||||
|
KEY_LOGIN_INFO
|
||||||
|
);
|
||||||
|
|
||||||
|
return fetch({
|
||||||
|
deviceType: loginInfo.deviceType,
|
||||||
|
companyGroupType: 'C',
|
||||||
|
companyCode: loginInfo.companyCode,
|
||||||
|
loginId: loginInfo.loginId
|
||||||
|
});
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
fetch$ = createEffect(() =>
|
fetch$ = createEffect(() =>
|
||||||
this.actions$.pipe(
|
this.actions$.pipe(
|
||||||
ofType(fetch),
|
ofType(fetch),
|
||||||
map(action => action),
|
map(action => action),
|
||||||
exhaustMap(req =>
|
exhaustMap(req =>
|
||||||
this.publicApiService.versionInfo(req).pipe(
|
this.publicApiService.versionInfo2(req).pipe(
|
||||||
map(res => {
|
map(res => {
|
||||||
if (res.statusCode === StatusCode.Success) {
|
if (res.statusCode === StatusCode.Success) {
|
||||||
|
console.log('fetchSuccess', res);
|
||||||
return fetchSuccess(res);
|
return fetchSuccess(res);
|
||||||
} else {
|
} else {
|
||||||
return fetchFailure({ error: 'Failed' });
|
return fetchFailure({ error: 'Failed' });
|
||||||
|
@ -43,6 +67,7 @@ export class Effects {
|
||||||
constructor(
|
constructor(
|
||||||
private actions$: Actions,
|
private actions$: Actions,
|
||||||
private publicApiService: PublicApiService,
|
private publicApiService: PublicApiService,
|
||||||
|
private sessionStorageService: SessionStorageService,
|
||||||
private router: Router
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
|
import { DeviceType } from '@ucap-webmessenger/core';
|
||||||
|
|
||||||
export const KEY_LOGIN_INFO = 'ucap::LOGIN_INFO';
|
export const KEY_LOGIN_INFO = 'ucap::LOGIN_INFO';
|
||||||
|
|
||||||
export interface LoginInfo {
|
export interface LoginInfo {
|
||||||
loginId?: string;
|
loginId?: string;
|
||||||
loginPw?: string;
|
loginPw?: string;
|
||||||
companyCode?: string;
|
companyCode?: string;
|
||||||
|
deviceType?: DeviceType;
|
||||||
lang?: string;
|
lang?: string;
|
||||||
encData?: string;
|
encData?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,18 @@ export abstract class UrlConfig {
|
||||||
constructor(
|
constructor(
|
||||||
protected useSsl: boolean,
|
protected useSsl: boolean,
|
||||||
protected domain: string,
|
protected domain: string,
|
||||||
protected port: number
|
protected port: number,
|
||||||
|
protected webSocket: boolean = false
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
protected getProtocol(): string {
|
protected getProtocol(): string {
|
||||||
return this.useSsl ? 'https:' : 'http:';
|
return this.webSocket
|
||||||
|
? this.useSsl
|
||||||
|
? 'wss:'
|
||||||
|
: 'ws:'
|
||||||
|
: this.useSsl
|
||||||
|
? 'https:'
|
||||||
|
: 'http:';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getUrl(extra: url.UrlObject): string {
|
protected getUrl(extra: url.UrlObject): string {
|
||||||
|
@ -26,7 +33,7 @@ export class ApiPublicUrlConfig extends UrlConfig {
|
||||||
super(useSsl, domain, port);
|
super(useSsl, domain, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get versionInfo(): string {
|
public get versionInfo2(): string {
|
||||||
return this.getUrl({
|
return this.getUrl({
|
||||||
pathname: '/Pub/verinfo2.aspx'
|
pathname: '/Pub/verinfo2.aspx'
|
||||||
});
|
});
|
||||||
|
@ -243,6 +250,18 @@ export class PiUrlConfig extends UrlConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ProtocolUrlConfig extends UrlConfig {
|
||||||
|
constructor(useSsl: boolean, domain: string, port: number) {
|
||||||
|
super(useSsl, domain, port, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get base(): string {
|
||||||
|
return this.getUrl({
|
||||||
|
pathname: '/'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class VideoConfrenceUrlConfig extends UrlConfig {
|
export class VideoConfrenceUrlConfig extends UrlConfig {
|
||||||
constructor(useSsl: boolean, domain: string, port: number) {
|
constructor(useSsl: boolean, domain: string, port: number) {
|
||||||
super(useSsl, domain, port);
|
super(useSsl, domain, port);
|
||||||
|
@ -290,9 +309,19 @@ export interface Environment {
|
||||||
apiCommon: ApiCommonUrlConfig;
|
apiCommon: ApiCommonUrlConfig;
|
||||||
apiExternal: ApiExternalUrlConfig;
|
apiExternal: ApiExternalUrlConfig;
|
||||||
pi: PiUrlConfig;
|
pi: PiUrlConfig;
|
||||||
|
protocol: ProtocolUrlConfig;
|
||||||
videoConfrence: VideoConfrenceUrlConfig;
|
videoConfrence: VideoConfrenceUrlConfig;
|
||||||
clickToCall: ClickToCallUrlConfig;
|
clickToCall: ClickToCallUrlConfig;
|
||||||
};
|
};
|
||||||
|
protocol: {
|
||||||
|
reconnect: {
|
||||||
|
delay: number;
|
||||||
|
};
|
||||||
|
requestId: {
|
||||||
|
min: number;
|
||||||
|
max: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function build(production: boolean): Environment {
|
export function build(production: boolean): Environment {
|
||||||
|
@ -314,6 +343,7 @@ export function build(production: boolean): Environment {
|
||||||
apiPublic: new ApiPublicUrlConfig(useSsl, webDomain, webPort),
|
apiPublic: new ApiPublicUrlConfig(useSsl, webDomain, webPort),
|
||||||
apiExternal: new ApiExternalUrlConfig(useSsl, webDomain, webPort),
|
apiExternal: new ApiExternalUrlConfig(useSsl, webDomain, webPort),
|
||||||
pi: new PiUrlConfig(useSsl, webDomain, devServer ? 9097 : 9097),
|
pi: new PiUrlConfig(useSsl, webDomain, devServer ? 9097 : 9097),
|
||||||
|
protocol: new ProtocolUrlConfig(useSsl, webDomain, useSsl ? 9443 : 8080),
|
||||||
videoConfrence: new VideoConfrenceUrlConfig(
|
videoConfrence: new VideoConfrenceUrlConfig(
|
||||||
useSsl,
|
useSsl,
|
||||||
devServer ? '101.55.17.24' : '101.55.17.24',
|
devServer ? '101.55.17.24' : '101.55.17.24',
|
||||||
|
@ -324,6 +354,15 @@ export function build(production: boolean): Environment {
|
||||||
devServer ? '169.56.82.147' : '169.56.82.147',
|
devServer ? '169.56.82.147' : '169.56.82.147',
|
||||||
devServer ? 9095 : 9095
|
devServer ? 9095 : 9095
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
protocol: {
|
||||||
|
reconnect: {
|
||||||
|
delay: 1000
|
||||||
|
},
|
||||||
|
requestId: {
|
||||||
|
min: 1,
|
||||||
|
max: 59999
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { ipcRenderer } from 'electron';
|
import { ipcRenderer } from 'electron';
|
||||||
|
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
import { NativeService } from '@ucap-webmessenger/native';
|
import { NativeService } from '@ucap-webmessenger/native';
|
||||||
import { Channel } from '../types/channel.type';
|
import { Channel } from '../types/channel.type';
|
||||||
|
|
||||||
|
@ -23,12 +25,14 @@ export class ElectronNativeService implements NativeService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForUpdates(): Promise<boolean> {
|
checkForUpdates(): Observable<boolean> {
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Observable<boolean>(subscriber => {
|
||||||
try {
|
try {
|
||||||
resolve(ipcRenderer.sendSync(Channel.checkForUpdates));
|
subscriber.next(ipcRenderer.sendSync(Channel.checkForUpdates));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
subscriber.error(error);
|
||||||
|
} finally {
|
||||||
|
subscriber.complete();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
export interface NativeService {
|
export interface NativeService {
|
||||||
showNotify(
|
showNotify(
|
||||||
roomSeq: number,
|
roomSeq: number,
|
||||||
|
@ -7,7 +9,7 @@ export interface NativeService {
|
||||||
useSound: boolean
|
useSound: boolean
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
checkForUpdates(): Promise<boolean>;
|
checkForUpdates(): Observable<boolean>;
|
||||||
|
|
||||||
showImageViewer(): void;
|
showImageViewer(): void;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
* Public API Surface of ucap-webmessenger-protocol-authentication
|
* Public API Surface of ucap-webmessenger-protocol-authentication
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export * from './lib/models/fmc';
|
||||||
|
export * from './lib/models/login';
|
||||||
|
|
||||||
export * from './lib/services/authentication-protocol.service';
|
export * from './lib/services/authentication-protocol.service';
|
||||||
|
|
||||||
|
export * from './lib/types/role-code';
|
||||||
|
export * from './lib/types/service';
|
||||||
|
export * from './lib/types/sso-mode';
|
||||||
|
|
||||||
export * from './lib/ucap-authentication-protocol.module';
|
export * from './lib/ucap-authentication-protocol.module';
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
PacketBodyDivider
|
PacketBodyDivider
|
||||||
} from '../types/packet-body-divider';
|
} from '../types/packet-body-divider';
|
||||||
import { PacketBodyValue } from '../types/packet-body-value.type';
|
import { PacketBodyValue } from '../types/packet-body-value.type';
|
||||||
|
import { SSVC_TYPE_ERROR_RES, ServerErrorCode } from '../types/service';
|
||||||
|
|
||||||
interface RequestState {
|
interface RequestState {
|
||||||
subject: Subject<ServerResponse>;
|
subject: Subject<ServerResponse>;
|
||||||
|
@ -45,6 +46,7 @@ export class ProtocolService {
|
||||||
private readonly pendingRequests: Map<number, RequestState>;
|
private readonly pendingRequests: Map<number, RequestState>;
|
||||||
private readonly input$: QueueingSubject<string>;
|
private readonly input$: QueueingSubject<string>;
|
||||||
private socket$: Observable<GetWebSocketResponses<any>>;
|
private socket$: Observable<GetWebSocketResponses<any>>;
|
||||||
|
private messages$: Observable<any>;
|
||||||
private messagesSubscription: Subscription | null = null;
|
private messagesSubscription: Subscription | null = null;
|
||||||
|
|
||||||
constructor(@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig) {
|
constructor(@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig) {
|
||||||
|
@ -52,9 +54,11 @@ export class ProtocolService {
|
||||||
this.input$ = new QueueingSubject<string>();
|
this.input$ = new QueueingSubject<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public connect(): void {
|
public connect(serverIp: string | null = null): void {
|
||||||
this.socket$ = makeWebSocketObservable(this.moduleConfig.url);
|
this.socket$ = makeWebSocketObservable(
|
||||||
const messages$ = this.socket$.pipe(
|
this.moduleConfig.urls.base + serverIp ? serverIp : ''
|
||||||
|
);
|
||||||
|
this.messages$ = this.socket$.pipe(
|
||||||
switchMap(getResponses => getResponses(this.input$)),
|
switchMap(getResponses => getResponses(this.input$)),
|
||||||
retryWhen(errors =>
|
retryWhen(errors =>
|
||||||
errors.pipe(delay(this.moduleConfig.reconnect.delay))
|
errors.pipe(delay(this.moduleConfig.reconnect.delay))
|
||||||
|
@ -62,7 +66,7 @@ export class ProtocolService {
|
||||||
share()
|
share()
|
||||||
);
|
);
|
||||||
|
|
||||||
this.messagesSubscription = messages$.subscribe(
|
this.messagesSubscription = this.messages$.subscribe(
|
||||||
(message: string) => {
|
(message: string) => {
|
||||||
const arg = message.split(PacketBodyDivider);
|
const arg = message.split(PacketBodyDivider);
|
||||||
if (2 > arg.length) {
|
if (2 > arg.length) {
|
||||||
|
@ -71,6 +75,26 @@ export class ProtocolService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = this.decodePacket(arg);
|
const res = this.decodePacket(arg);
|
||||||
|
|
||||||
|
let requestState: RequestState | null = null;
|
||||||
|
if (res.requestId) {
|
||||||
|
requestState = this.pendingRequests.get(res.requestId);
|
||||||
|
this.pendingRequests.delete(res.requestId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SSVC_TYPE_ERROR_RES === res.response.subServiceType) {
|
||||||
|
const errorCode: ServerErrorCode = res.response
|
||||||
|
.bodyList[0] as ServerErrorCode;
|
||||||
|
|
||||||
|
if (requestState) {
|
||||||
|
requestState.subject.error(errorCode);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestState) {
|
||||||
|
requestState.subject.next(res.response);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(error: Error) => {
|
(error: Error) => {
|
||||||
const { message } = error;
|
const { message } = error;
|
||||||
|
@ -160,11 +184,15 @@ export class ProtocolService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const serviceType = Number(cmdArg[0]);
|
||||||
|
const subServiceType = Number(cmdArg[1]);
|
||||||
|
|
||||||
const seqArg = arg[1].split(PacketBodyValueDivider);
|
const seqArg = arg[1].split(PacketBodyValueDivider);
|
||||||
if (2 > seqArg.length) {
|
if (2 > seqArg.length) {
|
||||||
// OnError(3);
|
// OnError(3);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const senderSeq = Number(seqArg[0]);
|
||||||
|
|
||||||
const bodyList: any[] | null = null;
|
const bodyList: any[] | null = null;
|
||||||
let requestId: number | null = null;
|
let requestId: number | null = null;
|
||||||
|
@ -187,7 +215,7 @@ export class ProtocolService {
|
||||||
bodyList.push(value);
|
bodyList.push(value);
|
||||||
break;
|
break;
|
||||||
case PacketBodyValue.Integer:
|
case PacketBodyValue.Integer:
|
||||||
bodyList.push(parseInt(value, 10));
|
bodyList.push(Number(value));
|
||||||
break;
|
break;
|
||||||
case PacketBodyValue.String:
|
case PacketBodyValue.String:
|
||||||
bodyList.push(value);
|
bodyList.push(value);
|
||||||
|
@ -211,6 +239,16 @@ export class ProtocolService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
requestId,
|
||||||
|
response: {
|
||||||
|
serviceType,
|
||||||
|
subServiceType,
|
||||||
|
senderSeq,
|
||||||
|
bodyList
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private encodePacket(
|
private encodePacket(
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
export interface ModuleConfig {
|
export interface ModuleConfig {
|
||||||
url: string;
|
urls: {
|
||||||
|
base: string;
|
||||||
|
};
|
||||||
reconnect: {
|
reconnect: {
|
||||||
delay: number;
|
delay: number;
|
||||||
};
|
};
|
||||||
|
|
26
projects/ucap-webmessenger-protocol/src/lib/types/service.ts
Normal file
26
projects/ucap-webmessenger-protocol/src/lib/types/service.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
export const SSVC_TYPE_ERROR_RES = 1000;
|
||||||
|
|
||||||
|
export enum ServerErrorCode {
|
||||||
|
ERRCD_FORCE_CLOSE = 10,
|
||||||
|
ERRCD_PROTOCOL = 11,
|
||||||
|
ERRCD_VERSION = 12,
|
||||||
|
ERRCD_DID = 13,
|
||||||
|
ERRCD_IDPW = 14,
|
||||||
|
ERRCD_DUPLICATE = 15,
|
||||||
|
ERRCD_TOKEN = 16,
|
||||||
|
ERRCD_SETUP_MAIN = 17,
|
||||||
|
ERRCD_FORCE_INIT = 18,
|
||||||
|
ERRCD_SSO_AUTH = 19,
|
||||||
|
ERRCD_SSO_VALI = 20,
|
||||||
|
ERRCD_DEV_NOT_SUPPORTED = 21,
|
||||||
|
ERRCD_NO_MOBILE_PID = 22,
|
||||||
|
ERRCD_SVC_EXPIRE = 99,
|
||||||
|
ERRCD_FAILED = 100,
|
||||||
|
ERRCD_DATABASE = 101,
|
||||||
|
ERRCD_EXCESS = 102,
|
||||||
|
ERRCD_NEED_AUTH = 103,
|
||||||
|
ERRCD_USERINFO = 104, // ucap 은 없음.
|
||||||
|
ERRCD_AUTH_DENY = 1000,
|
||||||
|
ERRCD_ENCRYPT = 1001, // 패킷 암호화 오류
|
||||||
|
ERRCD_RECON = 1002 // 다른 IP로 접속 요청
|
||||||
|
}
|
|
@ -10,5 +10,6 @@ export * from './lib/services/protocol.service';
|
||||||
export * from './lib/types/module-config';
|
export * from './lib/types/module-config';
|
||||||
export * from './lib/types/packet-body-divider';
|
export * from './lib/types/packet-body-divider';
|
||||||
export * from './lib/types/packet-body-value.type';
|
export * from './lib/types/packet-body-value.type';
|
||||||
|
export * from './lib/types/service';
|
||||||
|
|
||||||
export * from './lib/ucap-protocol.module';
|
export * from './lib/ucap-protocol.module';
|
||||||
|
|
24
projects/ucap-webmessenger-util/README.md
Normal file
24
projects/ucap-webmessenger-util/README.md
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# UcapWebmessengerUtil
|
||||||
|
|
||||||
|
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.5.
|
||||||
|
|
||||||
|
## Code scaffolding
|
||||||
|
|
||||||
|
Run `ng generate component component-name --project ucap-webmessenger-util` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ucap-webmessenger-util`.
|
||||||
|
> Note: Don't forget to add `--project ucap-webmessenger-util` or else it will be added to the default project in your `angular.json` file.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Run `ng build ucap-webmessenger-util` to build the project. The build artifacts will be stored in the `dist/` directory.
|
||||||
|
|
||||||
|
## Publishing
|
||||||
|
|
||||||
|
After building your library with `ng build ucap-webmessenger-util`, go to the dist folder `cd dist/ucap-webmessenger-util` and run `npm publish`.
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
Run `ng test ucap-webmessenger-util` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||||
|
|
||||||
|
## Further help
|
||||||
|
|
||||||
|
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
|
32
projects/ucap-webmessenger-util/karma.conf.js
Normal file
32
projects/ucap-webmessenger-util/karma.conf.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// Karma configuration file, see link for more information
|
||||||
|
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||||
|
|
||||||
|
module.exports = function (config) {
|
||||||
|
config.set({
|
||||||
|
basePath: '',
|
||||||
|
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||||
|
plugins: [
|
||||||
|
require('karma-jasmine'),
|
||||||
|
require('karma-chrome-launcher'),
|
||||||
|
require('karma-jasmine-html-reporter'),
|
||||||
|
require('karma-coverage-istanbul-reporter'),
|
||||||
|
require('@angular-devkit/build-angular/plugins/karma')
|
||||||
|
],
|
||||||
|
client: {
|
||||||
|
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||||
|
},
|
||||||
|
coverageIstanbulReporter: {
|
||||||
|
dir: require('path').join(__dirname, '../../coverage/ucap-webmessenger-util'),
|
||||||
|
reports: ['html', 'lcovonly', 'text-summary'],
|
||||||
|
fixWebpackSourcePaths: true
|
||||||
|
},
|
||||||
|
reporters: ['progress', 'kjhtml'],
|
||||||
|
port: 9876,
|
||||||
|
colors: true,
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
autoWatch: true,
|
||||||
|
browsers: ['Chrome'],
|
||||||
|
singleRun: false,
|
||||||
|
restartOnFileChange: true
|
||||||
|
});
|
||||||
|
};
|
7
projects/ucap-webmessenger-util/ng-package.json
Normal file
7
projects/ucap-webmessenger-util/ng-package.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
|
||||||
|
"dest": "../../dist/ucap-webmessenger-util",
|
||||||
|
"lib": {
|
||||||
|
"entryFile": "src/public-api.ts"
|
||||||
|
}
|
||||||
|
}
|
8
projects/ucap-webmessenger-util/package.json
Normal file
8
projects/ucap-webmessenger-util/package.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "@ucap-webmessenger/util",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"peerDependencies": {
|
||||||
|
"@angular/common": "^8.2.5",
|
||||||
|
"@angular/core": "^8.2.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { EnviromentUtilService } from './enviroment-util.service';
|
||||||
|
|
||||||
|
describe('EnviromentUtilService', () => {
|
||||||
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
const service: EnviromentUtilService = TestBed.get(EnviromentUtilService);
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,215 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
import { detect, BrowserInfo, BotInfo, NodeInfo } from 'detect-browser';
|
||||||
|
|
||||||
|
const deviceTypeList = ['mobile', 'tablet', 'desktop'];
|
||||||
|
|
||||||
|
const osTypeList = [
|
||||||
|
'ios',
|
||||||
|
'iphone',
|
||||||
|
'ipad',
|
||||||
|
'ipod',
|
||||||
|
'android',
|
||||||
|
'blackberry',
|
||||||
|
'macos',
|
||||||
|
'windows',
|
||||||
|
'fxos',
|
||||||
|
'meego',
|
||||||
|
'television'
|
||||||
|
];
|
||||||
|
|
||||||
|
const televisionTypeList = [
|
||||||
|
'googletv',
|
||||||
|
'viera',
|
||||||
|
'smarttv',
|
||||||
|
'internet.tv',
|
||||||
|
'netcast',
|
||||||
|
'nettv',
|
||||||
|
'appletv',
|
||||||
|
'boxee',
|
||||||
|
'kylo',
|
||||||
|
'roku',
|
||||||
|
'dlnadoc',
|
||||||
|
'pov_tv',
|
||||||
|
'hbbtv',
|
||||||
|
'ce-html'
|
||||||
|
];
|
||||||
|
|
||||||
|
const orientationTypeList = ['portrait', 'landscape'];
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class EnviromentUtilService {
|
||||||
|
private readonly userAgent: string;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.userAgent = window.navigator.userAgent.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public macos(): boolean {
|
||||||
|
return this.find('mac');
|
||||||
|
}
|
||||||
|
|
||||||
|
public ios(): boolean {
|
||||||
|
return this.iphone() || this.ipod() || this.ipad();
|
||||||
|
}
|
||||||
|
|
||||||
|
public iphone(): boolean {
|
||||||
|
return !this.windows() && this.find('iphone');
|
||||||
|
}
|
||||||
|
|
||||||
|
public ipod(): boolean {
|
||||||
|
return this.find('ipod');
|
||||||
|
}
|
||||||
|
|
||||||
|
public ipad(): boolean {
|
||||||
|
return this.find('ipad');
|
||||||
|
}
|
||||||
|
|
||||||
|
public android(): boolean {
|
||||||
|
return !this.windows() && this.find('android');
|
||||||
|
}
|
||||||
|
|
||||||
|
public androidPhone(): boolean {
|
||||||
|
return this.android() && this.find('mobile');
|
||||||
|
}
|
||||||
|
|
||||||
|
public androidTablet(): boolean {
|
||||||
|
return this.android() && !this.find('mobile');
|
||||||
|
}
|
||||||
|
|
||||||
|
public blackberry(): boolean {
|
||||||
|
return this.find('blackberry') || this.find('bb10') || this.find('rim');
|
||||||
|
}
|
||||||
|
|
||||||
|
public blackberryPhone(): boolean {
|
||||||
|
return this.blackberry() && !this.find('tablet');
|
||||||
|
}
|
||||||
|
|
||||||
|
public blackberryTablet(): boolean {
|
||||||
|
return this.blackberry() && this.find('tablet');
|
||||||
|
}
|
||||||
|
|
||||||
|
public windows(): boolean {
|
||||||
|
return this.find('windows');
|
||||||
|
}
|
||||||
|
|
||||||
|
public windowsPhone(): boolean {
|
||||||
|
return this.windows() && this.find('phone');
|
||||||
|
}
|
||||||
|
|
||||||
|
public windowsTablet(): boolean {
|
||||||
|
return this.windows() && (this.find('touch') && !this.windowsPhone());
|
||||||
|
}
|
||||||
|
|
||||||
|
public fxos(): boolean {
|
||||||
|
return (this.find('(mobile') || this.find('(tablet')) && this.find(' rv:');
|
||||||
|
}
|
||||||
|
|
||||||
|
public fxosPhone(): boolean {
|
||||||
|
return this.fxos() && this.find('mobile');
|
||||||
|
}
|
||||||
|
|
||||||
|
public fxosTablet(): boolean {
|
||||||
|
return this.fxos() && this.find('tablet');
|
||||||
|
}
|
||||||
|
|
||||||
|
public meego(): boolean {
|
||||||
|
return this.find('meego');
|
||||||
|
}
|
||||||
|
|
||||||
|
public cordova(): boolean {
|
||||||
|
return (window as any).cordova && location.protocol === 'file:';
|
||||||
|
}
|
||||||
|
|
||||||
|
public nodeWebkit(): boolean {
|
||||||
|
return typeof (window as any).process === 'object';
|
||||||
|
}
|
||||||
|
|
||||||
|
public mobile(): boolean {
|
||||||
|
return (
|
||||||
|
this.androidPhone() ||
|
||||||
|
this.iphone() ||
|
||||||
|
this.ipod() ||
|
||||||
|
this.windowsPhone() ||
|
||||||
|
this.blackberryPhone() ||
|
||||||
|
this.fxosPhone() ||
|
||||||
|
this.meego()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public tablet(): boolean {
|
||||||
|
return (
|
||||||
|
this.ipad() ||
|
||||||
|
this.androidTablet() ||
|
||||||
|
this.blackberryTablet() ||
|
||||||
|
this.windowsTablet() ||
|
||||||
|
this.fxosTablet()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public desktop(): boolean {
|
||||||
|
return !this.tablet() && !this.mobile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public television(): boolean {
|
||||||
|
let i = 0;
|
||||||
|
while (i < televisionTypeList.length) {
|
||||||
|
if (this.find(televisionTypeList[i])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public portrait(): boolean {
|
||||||
|
if (
|
||||||
|
screen.orientation &&
|
||||||
|
Object.prototype.hasOwnProperty.call(window, 'onorientationchange')
|
||||||
|
) {
|
||||||
|
return this.includes(screen.orientation.type, 'portrait');
|
||||||
|
}
|
||||||
|
return window.innerHeight / window.innerWidth > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public landscape(): boolean {
|
||||||
|
if (
|
||||||
|
screen.orientation &&
|
||||||
|
Object.prototype.hasOwnProperty.call(window, 'onorientationchange')
|
||||||
|
) {
|
||||||
|
return this.includes(screen.orientation.type, 'landscape');
|
||||||
|
}
|
||||||
|
return window.innerHeight / window.innerWidth < 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public type(): string {
|
||||||
|
return this.findMatch(deviceTypeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public os(): string {
|
||||||
|
return this.findMatch(osTypeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public browser(): BrowserInfo | BotInfo | NodeInfo {
|
||||||
|
return detect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private includes(haystack: string, needle: string): boolean {
|
||||||
|
return haystack.indexOf(needle) !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private find(needle: string): boolean {
|
||||||
|
return this.includes(this.userAgent, needle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private findMatch(arr: string[]): string {
|
||||||
|
for (const item of arr) {
|
||||||
|
if (this[item]()) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
}
|
19
projects/ucap-webmessenger-util/src/lib/ucap-util.module.ts
Normal file
19
projects/ucap-webmessenger-util/src/lib/ucap-util.module.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { NgModule, ModuleWithProviders } from '@angular/core';
|
||||||
|
|
||||||
|
import { EnviromentUtilService } from './services/enviroment-util.service';
|
||||||
|
|
||||||
|
const SERVICES = [EnviromentUtilService];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [],
|
||||||
|
exports: [],
|
||||||
|
declarations: []
|
||||||
|
})
|
||||||
|
export class UCapUtilModule {
|
||||||
|
public static forRoot(): ModuleWithProviders<UCapUtilModule> {
|
||||||
|
return {
|
||||||
|
ngModule: UCapUtilModule,
|
||||||
|
providers: [...SERVICES]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
7
projects/ucap-webmessenger-util/src/public-api.ts
Normal file
7
projects/ucap-webmessenger-util/src/public-api.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
/*
|
||||||
|
* Public API Surface of ucap-webmessenger-util
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from './lib/services/enviroment-util.service';
|
||||||
|
|
||||||
|
export * from './lib/ucap-util.module';
|
21
projects/ucap-webmessenger-util/src/test.ts
Normal file
21
projects/ucap-webmessenger-util/src/test.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||||
|
|
||||||
|
import 'zone.js/dist/zone';
|
||||||
|
import 'zone.js/dist/zone-testing';
|
||||||
|
import { getTestBed } from '@angular/core/testing';
|
||||||
|
import {
|
||||||
|
BrowserDynamicTestingModule,
|
||||||
|
platformBrowserDynamicTesting
|
||||||
|
} from '@angular/platform-browser-dynamic/testing';
|
||||||
|
|
||||||
|
declare const require: any;
|
||||||
|
|
||||||
|
// First, initialize the Angular testing environment.
|
||||||
|
getTestBed().initTestEnvironment(
|
||||||
|
BrowserDynamicTestingModule,
|
||||||
|
platformBrowserDynamicTesting()
|
||||||
|
);
|
||||||
|
// Then we find all the tests.
|
||||||
|
const context = require.context('./', true, /\.spec\.ts$/);
|
||||||
|
// And load the modules.
|
||||||
|
context.keys().map(context);
|
26
projects/ucap-webmessenger-util/tsconfig.lib.json
Normal file
26
projects/ucap-webmessenger-util/tsconfig.lib.json
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../../out-tsc/lib",
|
||||||
|
"target": "es2015",
|
||||||
|
"declaration": true,
|
||||||
|
"inlineSources": true,
|
||||||
|
"types": [],
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"es2018"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"annotateForClosureCompiler": true,
|
||||||
|
"skipTemplateCodegen": true,
|
||||||
|
"strictMetadataEmit": true,
|
||||||
|
"fullTemplateTypeCheck": true,
|
||||||
|
"strictInjectionParameters": true,
|
||||||
|
"enableResourceInlining": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"src/test.ts",
|
||||||
|
"**/*.spec.ts"
|
||||||
|
]
|
||||||
|
}
|
17
projects/ucap-webmessenger-util/tsconfig.spec.json
Normal file
17
projects/ucap-webmessenger-util/tsconfig.spec.json
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../../out-tsc/spec",
|
||||||
|
"types": [
|
||||||
|
"jasmine",
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/test.ts"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
"**/*.spec.ts",
|
||||||
|
"**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
17
projects/ucap-webmessenger-util/tslint.json
Normal file
17
projects/ucap-webmessenger-util/tslint.json
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"extends": "../../tslint.json",
|
||||||
|
"rules": {
|
||||||
|
"directive-selector": [
|
||||||
|
true,
|
||||||
|
"attribute",
|
||||||
|
"ucapUtil",
|
||||||
|
"camelCase"
|
||||||
|
],
|
||||||
|
"component-selector": [
|
||||||
|
true,
|
||||||
|
"element",
|
||||||
|
"ucap-util",
|
||||||
|
"kebab-case"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -106,6 +106,9 @@
|
||||||
],
|
],
|
||||||
"@ucap-webmessenger/web-storage": [
|
"@ucap-webmessenger/web-storage": [
|
||||||
"projects/ucap-webmessenger-web-storage/src/public-api"
|
"projects/ucap-webmessenger-web-storage/src/public-api"
|
||||||
|
],
|
||||||
|
"@ucap-webmessenger/util": [
|
||||||
|
"projects/ucap-webmessenger-util/src/public-api"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user