dasang module is added

This commit is contained in:
병준 박 2019-12-15 18:07:25 +09:00
parent 0271d86add
commit f309e14397
20 changed files with 367 additions and 16 deletions

View File

@ -1720,6 +1720,39 @@
} }
} }
} }
},
"ucap-webmessenger-daesang": {
"projectType": "library",
"root": "projects/ucap-webmessenger-daesang",
"sourceRoot": "projects/ucap-webmessenger-daesang/src",
"prefix": "ucap-daesang",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ucap-webmessenger-daesang/tsconfig.lib.json",
"project": "projects/ucap-webmessenger-daesang/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/ucap-webmessenger-daesang/src/test.ts",
"tsConfig": "projects/ucap-webmessenger-daesang/tsconfig.spec.json",
"karmaConfig": "projects/ucap-webmessenger-daesang/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/ucap-webmessenger-daesang/tsconfig.lib.json",
"projects/ucap-webmessenger-daesang/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
}
}
}
} }
}, },
"defaultProject": "ucap-webmessenger-app" "defaultProject": "ucap-webmessenger-app"

View File

@ -287,32 +287,32 @@ ipcMain.on(UpdaterChannel.Check, (event: IpcMainEvent, ...args: any[]) => {
ipcMain.on( ipcMain.on(
UpdaterChannel.StartCheckInstant, UpdaterChannel.StartCheckInstant,
(event: IpcMainEvent, ...args: any[]) => { (event: IpcMainEvent, ...args: any[]) => {
const config = args[0] as UpdateCheckConfig; // const config = args[0] as UpdateCheckConfig;
if (!!rendererUpdater) { // if (!!rendererUpdater) {
rendererUpdater.stopCheck(); // rendererUpdater.stopCheck();
rendererUpdater = null; // rendererUpdater = null;
} // }
rendererUpdater = new RendererUpdater(appWindow.browserWindow, config); // default 10min // rendererUpdater = new RendererUpdater(appWindow.browserWindow, config); // default 10min
rendererUpdater.startCheck(); // rendererUpdater.startCheck();
} }
); );
ipcMain.on( ipcMain.on(
UpdaterChannel.StopCheckInstant, UpdaterChannel.StopCheckInstant,
(event: IpcMainEvent, ...args: any[]) => { (event: IpcMainEvent, ...args: any[]) => {
if (!!rendererUpdater) { // if (!!rendererUpdater) {
rendererUpdater.stopCheck(); // rendererUpdater.stopCheck();
rendererUpdater = null; // rendererUpdater = null;
} // }
} }
); );
ipcMain.on( ipcMain.on(
UpdaterChannel.ApplyInstant, UpdaterChannel.ApplyInstant,
(event: IpcMainEvent, ...args: any[]) => { (event: IpcMainEvent, ...args: any[]) => {
if (!!rendererUpdater) { // if (!!rendererUpdater) {
rendererUpdater.apply(); // rendererUpdater.apply();
} // }
} }
); );

View File

@ -33,6 +33,8 @@ import { UCapServiceProtocolModule } from '@ucap-webmessenger/protocol-service';
import { UCapStatusProtocolModule } from '@ucap-webmessenger/protocol-status'; import { UCapStatusProtocolModule } from '@ucap-webmessenger/protocol-status';
import { UCapSyncProtocolModule } from '@ucap-webmessenger/protocol-sync'; import { UCapSyncProtocolModule } from '@ucap-webmessenger/protocol-sync';
import { UCapDaesangModule } from '@ucap-webmessenger/daesang';
import { LoggerModule, NgxLoggerLevel } from 'ngx-logger'; import { LoggerModule, NgxLoggerLevel } from 'ngx-logger';
import { AppProviderModule } from './app-provider.module'; import { AppProviderModule } from './app-provider.module';
@ -79,6 +81,8 @@ import { environment } from '../environments/environment';
UCapStatusProtocolModule.forRoot(), UCapStatusProtocolModule.forRoot(),
UCapSyncProtocolModule.forRoot(), UCapSyncProtocolModule.forRoot(),
UCapDaesangModule.forRoot(),
UCapUiModule.forRoot(), UCapUiModule.forRoot(),
UCapUiAccountModule.forRoot(), UCapUiAccountModule.forRoot(),

View File

@ -9,6 +9,7 @@ import { LoginInfo, KEY_LOGIN_INFO } from '../types';
import { KEY_VER_INFO } from '@app/types/ver-info.type'; import { KEY_VER_INFO } from '@app/types/ver-info.type';
import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type';
import { PasswordUtil } from '@ucap-webmessenger/pi'; import { PasswordUtil } from '@ucap-webmessenger/pi';
import { DaesangCipherService } from '@ucap-webmessenger/daesang';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -18,7 +19,8 @@ export class AppAuthenticationService {
constructor( constructor(
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private localStorageService: LocalStorageService private localStorageService: LocalStorageService,
private daesangCipherService: DaesangCipherService
) {} ) {}
authenticated(): boolean { authenticated(): boolean {
@ -32,7 +34,12 @@ export class AppAuthenticationService {
this.sessionStorageService.set<LoginInfo>(KEY_LOGIN_INFO, { this.sessionStorageService.set<LoginInfo>(KEY_LOGIN_INFO, {
...loginInfo, ...loginInfo,
initPw: loginInfo.loginId === loginInfo.loginPw, initPw: loginInfo.loginId === loginInfo.loginPw,
loginPw: PasswordUtil.encrypt(loginInfo.loginPw) // loginPw: PasswordUtil.encrypt(loginInfo.loginPw)
loginPw: this.daesangCipherService.encrypt(
'DaesangSSOProject',
loginInfo.loginPw,
'N'
)
}); });
if (rememberMe) { if (rememberMe) {

View File

@ -0,0 +1,24 @@
# UcapWebmessengerDaesang
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.11.
## Code scaffolding
Run `ng generate component component-name --project ucap-webmessenger-daesang` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ucap-webmessenger-daesang`.
> Note: Don't forget to add `--project ucap-webmessenger-daesang` or else it will be added to the default project in your `angular.json` file.
## Build
Run `ng build ucap-webmessenger-daesang` to build the project. The build artifacts will be stored in the `dist/` directory.
## Publishing
After building your library with `ng build ucap-webmessenger-daesang`, go to the dist folder `cd dist/ucap-webmessenger-daesang` and run `npm publish`.
## Running unit tests
Run `ng test ucap-webmessenger-daesang` 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).

View 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-daesang'),
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
});
};

View File

@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/ucap-webmessenger-daesang",
"lib": {
"entryFile": "src/public-api.ts"
}
}

View File

@ -0,0 +1,8 @@
{
"name": "@ucap-webmessenger/daesang",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^8.2.11",
"@angular/core": "^8.2.11"
}
}

View File

@ -0,0 +1,4 @@
export interface CipherKeyDTD {
key: Uint8Array;
iv: Uint8Array;
}

View File

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { DaesangCipherService } from './daesang-cipher.service';
describe('DaesangCipherService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: DaesangCipherService = TestBed.get(DaesangCipherService);
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,37 @@
import { Injectable } from '@angular/core';
import crypto from 'crypto';
import { CipherUtil } from '../utils/CipherUtil';
@Injectable({
providedIn: 'root'
})
export class DaesangCipherService {
constructor() {}
encrypt(pvUserKey: string, pvSource: string, isBase64: string): string {
const cipherKeyDTD = CipherUtil.makeCipherKey('AES', pvUserKey);
const cipher = crypto.createCipheriv(
'aes-128-cbc',
cipherKeyDTD.key,
cipherKeyDTD.iv
);
cipher.setAutoPadding(true);
let outputEncoding: 'base64' | 'hex';
if ('Y' === isBase64) {
outputEncoding = 'base64';
} else {
outputEncoding = 'hex';
}
const cipherChunks = [];
cipherChunks.push(cipher.update(pvSource, 'utf8', outputEncoding));
cipherChunks.push(cipher.final(outputEncoding));
return cipherChunks.join('');
}
}

View File

@ -0,0 +1,19 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import { DaesangCipherService } from './services/daesang-cipher.service';
const SERVICES = [DaesangCipherService];
@NgModule({
declarations: [],
imports: [],
exports: []
})
export class UCapDaesangModule {
public static forRoot(): ModuleWithProviders<UCapDaesangModule> {
return {
ngModule: UCapDaesangModule,
providers: [...SERVICES]
};
}
}

View File

@ -0,0 +1,32 @@
export class ByteUtils {
static toBytesFromHexString(hex: string): Uint8Array {
if (!hex) {
return new Uint8Array();
}
return new Uint8Array(hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
}
static toHexString(bytes: Uint8Array): string {
if (!bytes) {
return '';
}
return bytes.reduce(
(str, byte) => str + byte.toString(16).padStart(2, '0'),
''
);
}
static toBytesFromString(s: string): Uint8Array {
if (!s) {
return new Uint8Array();
}
return new TextEncoder().encode(s);
}
static toStringFromBytes(bytes: Uint8Array): string {
if (!bytes) {
return '';
}
return new TextDecoder('utf-8').decode(bytes);
}
}

View File

@ -0,0 +1,41 @@
import CryptoJS from 'crypto-js';
import { ByteUtils } from './ByteUtils';
import { CipherKeyDTD } from '../models/CipherKeyDTD';
export class CipherUtil {
static makeCipherKey(pvAlgorithm: string, pvUserKey: string): CipherKeyDTD {
let keyBytes: Uint8Array;
let ivBytes: Uint8Array;
if (
!pvUserKey ||
'' === pvUserKey.trim() ||
'eMateOnepass_SSO' === pvUserKey
) {
keyBytes = ByteUtils.toBytesFromString('eMateOnepass_SSO');
ivBytes = ByteUtils.toBytesFromString('eMateOnepass_SSO');
} else if (
'201007GYCSSOPROJ' === pvUserKey ||
'201005KICSSOPROJ' === pvUserKey
) {
keyBytes = ByteUtils.toBytesFromString(pvUserKey);
ivBytes = ByteUtils.toBytesFromString(pvUserKey);
} else {
const bytes = ByteUtils.toBytesFromHexString(
CryptoJS.SHA1(pvUserKey).toString()
);
keyBytes = bytes.slice(0, 16);
ivBytes = ByteUtils.toBytesFromHexString(
CryptoJS.SHA1(ByteUtils.toHexString(bytes.slice(16, 20))).toString()
).slice(0, 16);
}
return {
key: keyBytes,
iv: ivBytes
} as CipherKeyDTD;
}
}

View File

@ -0,0 +1,7 @@
/*
* Public API Surface of ucap-webmessenger-daesang
*/
export * from './lib/services/daesang-cipher.service';
export * from './lib/ucap-daesang.module';

View 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);

View 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"
]
}

View 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"
]
}

View File

@ -0,0 +1,17 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"ucapDaesang",
"camelCase"
],
"component-selector": [
true,
"element",
"ucap-daesang",
"kebab-case"
]
}
}

View File

@ -146,6 +146,9 @@
], ],
"@ucap-webmessenger/electron": [ "@ucap-webmessenger/electron": [
"electron-projects/ucap-webmessenger-electron/src/public-api" "electron-projects/ucap-webmessenger-electron/src/public-api"
],
"@ucap-webmessenger/daesang": [
"projects/ucap-webmessenger-daesang/src/public-api"
] ]
} }
}, },