From ad0d29fb579ad2e3737bacb5cb8a21707baa1b58 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 16 Dec 2022 00:17:41 +0100 Subject: [PATCH] [DEV] Many small clean and remove external dependency --- front/src/app/app-routing.module.ts | 9 ++- front/src/app/app.component.ts | 3 - front/src/app/service/data.ts | 2 +- front/src/assets/.gitkeep | 0 .../src/assets/js_3rd_party/dateFormat.min.js | 27 -------- .../common/component/top-menu/top-menu.html | 8 +-- front/src/common/service/user.ts | 6 +- front/src/common/utils/index.ts | 2 + .../sha512.js => common/utils/sha512.ts} | 68 +++++++++---------- front/src/environments/environment.prod.ts | 1 - front/src/environments/environment.ts | 3 - front/src/index.html | 4 -- 12 files changed, 48 insertions(+), 85 deletions(-) delete mode 100644 front/src/assets/.gitkeep delete mode 100644 front/src/assets/js_3rd_party/dateFormat.min.js rename front/src/{assets/js_3rd_party/sha512.js => common/utils/sha512.ts} (87%) diff --git a/front/src/app/app-routing.module.ts b/front/src/app/app-routing.module.ts index e2aaeef..637ebb5 100644 --- a/front/src/app/app-routing.module.ts +++ b/front/src/app/app-routing.module.ts @@ -6,7 +6,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; // CLI imports router -import { ForbiddenScene, HomeOutScene, SsoScene } from 'common/scene'; +import { ForbiddenScene, HomeOutScene, NotFound404Scene, SsoScene } from 'common/scene'; import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service'; import { HelpScene, HomeScene, SeasonEditScene, SeasonScene, SeriesEditScene, SeriesScene, SettingsScene, TypeScene, VideoEditScene, VideoScene } from './scene'; @@ -21,6 +21,9 @@ const routes: Routes = [ { path: 'forbidden', component: ForbiddenScene }, + // ------------------------------------ + // -- home global interface + // ------------------------------------ { path: 'home', component: HomeScene, @@ -95,6 +98,10 @@ const routes: Routes = [ component: SettingsScene, canActivate: [OnlyUsersGuard], }, + { + path: '**', + component: NotFound404Scene, + }, ]; @NgModule({ diff --git a/front/src/app/app.component.ts b/front/src/app/app.component.ts index fa7becb..f81a72c 100644 --- a/front/src/app/app.component.ts +++ b/front/src/app/app.component.ts @@ -5,7 +5,6 @@ */ import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; import { EventOnMenu } from 'common/component/top-menu/top-menu'; import { MenuItem, MenuPosition } from 'common/model'; import { UserService, SessionService, SSOService } from 'common/service'; @@ -38,7 +37,6 @@ export class AppComponent implements OnInit { location: string = "home"; constructor( - private router: Router, private userService: UserService, private sessionService: SessionService, private ssoService: SSOService, @@ -48,7 +46,6 @@ export class AppComponent implements OnInit { } ngOnInit() { - console.log(`>>>> APLLICATION INIT: BASE PATH: ${this.location}`); this.autoConnectedDone = false; this.isConnected = false; this.updateMainMenu(); diff --git a/front/src/app/service/data.ts b/front/src/app/service/data.ts index badd3e6..56fe496 100644 --- a/front/src/app/service/data.ts +++ b/front/src/app/service/data.ts @@ -15,7 +15,7 @@ export class DataService { private serviceName:string = 'data'; constructor(private http: HttpWrapperService) { - console.log('Start TypeService'); + console.log('Start DataService'); } getData():any { diff --git a/front/src/assets/.gitkeep b/front/src/assets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/front/src/assets/js_3rd_party/dateFormat.min.js b/front/src/assets/js_3rd_party/dateFormat.min.js deleted file mode 100644 index cdb588c..0000000 --- a/front/src/assets/js_3rd_party/dateFormat.min.js +++ /dev/null @@ -1,27 +0,0 @@ -; function dateFormat(g, c, k) { - function l(a, b) { a.setHours(a.getHours() + parseFloat(b)); return a } function m(a, b) { var c = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "); return b ? c[a.getDay()].substr(0, 3) : c[a.getDay()] } function n(a, b) { var c = "January February March April May June July August September October November December".split(" "); return b ? c[a.getMonth()].substr(0, 3) : c[a.getMonth()] } var d = { - d: function () { var a = this.getDate(); return 9 < a ? a : "0" + a }, D: function () { return m(this, !0) }, j: function () { return this.getDate() }, - l: function () { return m(this) }, N: function () { return this.getDay() + 1 }, S: function () { var a = this.getDate(); return /^1[0-9]$/.test(a) ? "th" : /1$/.test(a) ? "st" : /2$/.test(a) ? "nd" : /3$/.test(a) ? "rd" : "th" }, w: function () { return this.getDay() }, z: function () { return Math.round(Math.abs((this.getTime() - (new Date("1/1/" + this.getFullYear())).getTime()) / 864E5)) }, W: function () { var a = new Date(this.getFullYear(), 0, 1); return Math.ceil(((this - a) / 864E5 + a.getDay() + 1) / 7) }, F: function () { return n(this) }, m: function () { - var a = this.getMonth() + - 1; return 9 < a ? a : "0" + a - }, M: function () { return n(this, !0) }, n: function () { return this.getMonth() + 1 }, t: function () { return (new Date(this.getFullYear(), this.getMonth() + 1, 0)).getDate() }, L: function () { var a = this.getFullYear(); return 0 == a % 4 && 0 != a % 100 || 0 == a % 400 }, o: function () { return parseInt(this.getFullYear()) }, Y: function () { return parseInt(this.getFullYear()) }, y: function () { return parseInt((this.getFullYear() + "").substr(-2)) }, a: function () { return 12 <= this.getHours() ? "pm" : "am" }, A: function () { - return 12 <= this.getHours() ? - "PM" : "AM" - }, B: function () { return "@" + ("00" + Math.floor((60 * ((this.getHours() + 1) % 24 * 60 + this.getMinutes()) + this.getSeconds() + .001 * this.getMilliseconds()) / 86.4)).slice(-3) }, g: function () { var a = this.getHours(); return 0 == a ? 12 : 12 >= a ? a : a - 12 }, G: function () { return this.getHours() }, h: function () { var a = this.getHours(), a = 12 >= a ? a : a - 12; return 0 == a ? 12 : 9 < a ? a : "0" + a }, H: function () { var a = this.getHours(); return 9 < a ? a : "0" + a }, i: function () { var a = this.getMinutes(); return 9 < a ? a : "0" + a }, s: function () { - var a = this.getSeconds(); return 9 < - a ? a : "0" + a - }, u: function () { return this.getMilliseconds() }, e: function () { var a = this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/); return 1 < a.length ? a[1] : "" }, I: function () { var a = new Date(this.getFullYear(), 0, 1), b = new Date(this.getFullYear(), 6, 1), a = Math.max(a.getTimezoneOffset(), b.getTimezoneOffset()); return this.getTimezoneOffset() < a ? 1 : 0 }, O: function () { var a = this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/); return 2 < a.length ? a[2] : "" }, P: function () { - var a = this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/); - return 2 < a.length ? a[2].substr(0, 3) + ":" + a[2].substr(3, 2) : "" - }, T: function () { return this.toLocaleString("en", { timeZoneName: "short" }).split(" ").pop() }, Z: function () { return 60 * this.getTimezoneOffset() }, c: function () { return l(new Date(this), -(this.getTimezoneOffset() / 60)).toISOString() }, r: function () { return l(new Date(this), -(this.getTimezoneOffset() / 60)).toISOString() }, U: function () { return this.getTime() / 1E3 | 0 } - }, e = { - commonLogFormat: "d/M/Y:G:i:s", exif: "Y:m:d G:i:s", isoYearWeek: "Y\\WW", isoYearWeek2: "Y-\\WW", - isoYearWeekDay: "Y\\WWj", isoYearWeekDay2: "Y-\\WW-j", mySQL: "Y-m-d h:i:s", postgreSQL: "Y.z", postgreSQL2: "Yz", soap: "Y-m-d\\TH:i:s.u", soap2: "Y-m-d\\TH:i:s.uP", unixTimestamp: "@U", xmlrpc: "Ymd\\TG:i:s", xmlrpcCompact: "Ymd\\tGis", wddx: "Y-n-j\\TG:i:s" - }, h = { - AMERICAN: "F j, Y", AMERICANSHORT: "m/d/Y", AMERICANSHORTWTIME: "m/d/Y h:i:sA", ATOM: "Y-m-d\\TH:i:sP", COOKIE: "l, d-M-Y H:i:s T", EUROPEAN: "j F Y", EUROPEANSHORT: "d.m.Y", EUROPEANSHORTWTIME: "d.m.Y H:i:s", ISO8601: "Y-m-d\\TH:i:sO", LEGAL: "j F Y", RFC822: "D, d M y H:i:s O", - RFC850: "l, d-M-y H:i:s T", RFC1036: "D, d M y H:i:s O", RFC1123: "D, d M Y H:i:s O", RFC2822: "D, d M Y H:i:s O", RFC3339: "Y-m-d\\TH:i:sP", RSS: "D, d M Y H:i:s O", W3C: "Y-m-d\\TH:i:sP" - }, f = { "pretty-a": "g:i.sA l jS \\o\\f F, Y", "pretty-b": "g:iA l jS \\o\\f F, Y", "pretty-c": "n/d/Y g:iA", "pretty-d": "n/d/Y", "pretty-e": "F jS - g:ia", "pretty-f": "g:iA", "pretty-g": "F jS, Y", "pretty-h": "F jS, Y g:mA" }; if (c) { - if ("compound" == c) { if (!1 === k) return e; var d = {}, b; for (b in e) d[b] = dateFormat(g, e[b]); return d } if (e[c]) return dateFormat(g, - e[c], k); if ("constants" == c) { if (!1 === k) return h; d = {}; for (b in h) d[b] = dateFormat(g, h[b]); return d } if (h[c]) return dateFormat(g, h[c], k); if ("pretty" == c) { if (!1 === k) return f; d = {}; for (b in f) d[b] = dateFormat(g, f[b]); return d } if (f[c]) return dateFormat(g, f[c], k); e = c.split(""); h = ""; for (b in e) (f = e[b]) && /[a-z]/i.test(f) && !/\\/.test(h + f) && (e[b] = d[f] ? d[f].apply(g) : f), h = e[b]; return e.join("").replace(/\\/g, "") - } return g -}; diff --git a/front/src/common/component/top-menu/top-menu.html b/front/src/common/component/top-menu/top-menu.html index fd3469c..542fb59 100644 --- a/front/src/common/component/top-menu/top-menu.html +++ b/front/src/common/component/top-menu/top-menu.html @@ -67,16 +67,10 @@ [ngStyle]="{'float': data.position}" [ngClass]="getClassModel(data.model)" [disable]="false"> -
{{data.icon}} {{data.title}}
-
- {{data.icon}} -
{{data.title}} diff --git a/front/src/common/service/user.ts b/front/src/common/service/user.ts index 7e800fa..8c56047 100644 --- a/front/src/common/service/user.ts +++ b/front/src/common/service/user.ts @@ -13,7 +13,7 @@ import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } import { StorageService } from 'common/service/local-storage'; import { SessionService } from './session'; import { SSOService } from './sso'; -import { getApplicationLocation, isNullOrUndefined } from 'common/utils'; +import { getApplicationLocation, isNullOrUndefined, sha512 } from 'common/utils'; interface MessageLogIn { login: string; @@ -30,8 +30,6 @@ interface MessageAnswer_USER_CONNECT { avatar: string } -declare function SHA512(param1: any): any; - @Injectable() export class UserService { // 0: Not hide password; 1 hide password; @@ -197,7 +195,7 @@ export class UserService { } create(login : string, email : string, password : string) { - return this.createSha(login, email, SHA512(password)); + return this.createSha(login, email, sha512(password)); } createSha(login : string, email : string, password : string) { let data = { diff --git a/front/src/common/utils/index.ts b/front/src/common/utils/index.ts index eab7a9c..17445d1 100644 --- a/front/src/common/utils/index.ts +++ b/front/src/common/utils/index.ts @@ -2,6 +2,7 @@ import { getApplicationLocation } from "./applPath"; import { DataInterface, TypeCheck } from "./dataInterface"; +import { sha512 } from "./sha512"; import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined, isArrayOfs, isInArray, isStringNullOrUndefined } from "./validator"; export { @@ -23,5 +24,6 @@ export { DataInterface, TypeCheck, getApplicationLocation, + sha512, } diff --git a/front/src/assets/js_3rd_party/sha512.js b/front/src/common/utils/sha512.ts similarity index 87% rename from front/src/assets/js_3rd_party/sha512.js rename to front/src/common/utils/sha512.ts index fc46edf..25ecdda 100644 --- a/front/src/assets/js_3rd_party/sha512.js +++ b/front/src/common/utils/sha512.ts @@ -2,18 +2,18 @@ * Secure Hash Algorithm (SHA512) */ -function SHA512(str) { +export function sha512(str) { function int64(msint_32, lsint_32) { this.highOrder = msint_32; this.lowOrder = lsint_32; } - var H = [new int64(0x6a09e667, 0xf3bcc908), new int64(0xbb67ae85, 0x84caa73b), + let H = [new int64(0x6a09e667, 0xf3bcc908), new int64(0xbb67ae85, 0x84caa73b), new int64(0x3c6ef372, 0xfe94f82b), new int64(0xa54ff53a, 0x5f1d36f1), new int64(0x510e527f, 0xade682d1), new int64(0x9b05688c, 0x2b3e6c1f), new int64(0x1f83d9ab, 0xfb41bd6b), new int64(0x5be0cd19, 0x137e2179)]; - var K = [new int64(0x428a2f98, 0xd728ae22), new int64(0x71374491, 0x23ef65cd), + let K = [new int64(0x428a2f98, 0xd728ae22), new int64(0x71374491, 0x23ef65cd), new int64(0xb5c0fbcf, 0xec4d3b2f), new int64(0xe9b5dba5, 0x8189dbbc), new int64(0x3956c25b, 0xf348b538), new int64(0x59f111f1, 0xb605d019), new int64(0x923f82a4, 0xaf194f9b), new int64(0xab1c5ed5, 0xda6d8118), @@ -54,21 +54,21 @@ function SHA512(str) { new int64(0x4cc5d4be, 0xcb3e42b6), new int64(0x597f299c, 0xfc657e2a), new int64(0x5fcb6fab, 0x3ad6faec), new int64(0x6c44198c, 0x4a475817)]; - var W = new Array(64); - var a, b, c, d, e, f, g, h, i, j; - var T1, T2; - var charsize = 8; + let W = new Array(64); + let a, b, c, d, e, f, g, h, i, j; + let T1, T2; + let charsize = 8; function utf8_encode(str) { return unescape(encodeURIComponent(str)); } function str2binb(str) { - var bin = []; - var mask = (1 << charsize) - 1; - var len = str.length * charsize; + let bin = []; + let mask = (1 << charsize) - 1; + let len = str.length * charsize; - for (var i = 0; i < len; i += charsize) { + for (let i = 0; i < len; i += charsize) { bin[i >> 5] |= (str.charCodeAt(i / charsize) & mask) << (32 - charsize - (i % 32)); } @@ -76,12 +76,12 @@ function SHA512(str) { } function binb2hex(binarray) { - var hex_tab = "0123456789abcdef"; - var str = ""; - var length = binarray.length * 4; - var srcByte; + let hex_tab = "0123456789abcdef"; + let str = ""; + let length = binarray.length * 4; + let srcByte; - for (var i = 0; i < length; i += 1) { + for (let i = 0; i < length; i += 1) { srcByte = binarray[i >> 2] >> ((3 - (i % 4)) * 8); str += hex_tab.charAt((srcByte >> 4) & 0xF) + hex_tab.charAt(srcByte & 0xF); } @@ -90,7 +90,7 @@ function SHA512(str) { } function safe_add_2(x, y) { - var lsw, msw, lowOrder, highOrder; + let lsw, msw, lowOrder, highOrder; lsw = (x.lowOrder & 0xFFFF) + (y.lowOrder & 0xFFFF); msw = (x.lowOrder >>> 16) + (y.lowOrder >>> 16) + (lsw >>> 16); @@ -104,7 +104,7 @@ function SHA512(str) { } function safe_add_4(a, b, c, d) { - var lsw, msw, lowOrder, highOrder; + let lsw, msw, lowOrder, highOrder; lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) + (c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF); msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) + (c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (lsw >>> 16); @@ -118,7 +118,7 @@ function SHA512(str) { } function safe_add_5(a, b, c, d, e) { - var lsw, msw, lowOrder, highOrder; + let lsw, msw, lowOrder, highOrder; lsw = (a.lowOrder & 0xFFFF) + (b.lowOrder & 0xFFFF) + (c.lowOrder & 0xFFFF) + (d.lowOrder & 0xFFFF) + (e.lowOrder & 0xFFFF); msw = (a.lowOrder >>> 16) + (b.lowOrder >>> 16) + (c.lowOrder >>> 16) + (d.lowOrder >>> 16) + (e.lowOrder >>> 16) + (lsw >>> 16); @@ -160,9 +160,9 @@ function SHA512(str) { } function sigma0(x) { - var rotr28 = rotr(x, 28); - var rotr34 = rotr(x, 34); - var rotr39 = rotr(x, 39); + let rotr28 = rotr(x, 28); + let rotr34 = rotr(x, 34); + let rotr39 = rotr(x, 39); return new int64( rotr28.highOrder ^ rotr34.highOrder ^ rotr39.highOrder, @@ -171,9 +171,9 @@ function SHA512(str) { } function sigma1(x) { - var rotr14 = rotr(x, 14); - var rotr18 = rotr(x, 18); - var rotr41 = rotr(x, 41); + let rotr14 = rotr(x, 14); + let rotr18 = rotr(x, 18); + let rotr41 = rotr(x, 41); return new int64( rotr14.highOrder ^ rotr18.highOrder ^ rotr41.highOrder, @@ -182,7 +182,7 @@ function SHA512(str) { } function gamma0(x) { - var rotr1 = rotr(x, 1), rotr8 = rotr(x, 8), shr7 = shr(x, 7); + let rotr1 = rotr(x, 1), rotr8 = rotr(x, 8), shr7 = shr(x, 7); return new int64( rotr1.highOrder ^ rotr8.highOrder ^ shr7.highOrder, @@ -191,9 +191,9 @@ function SHA512(str) { } function gamma1(x) { - var rotr19 = rotr(x, 19); - var rotr61 = rotr(x, 61); - var shr6 = shr(x, 6); + let rotr19 = rotr(x, 19); + let rotr61 = rotr(x, 61); + let shr6 = shr(x, 6); return new int64( rotr19.highOrder ^ rotr61.highOrder ^ shr6.highOrder, @@ -216,13 +216,13 @@ function SHA512(str) { } str = utf8_encode(str); - strlen = str.length*charsize; + let strlen = str.length*charsize; str = str2binb(str); str[strlen >> 5] |= 0x80 << (24 - strlen % 32); str[(((strlen + 128) >> 10) << 5) + 31] = strlen; - for (var i = 0; i < str.length; i += 32) { + for (let i = 0; i < str.length; i += 32) { a = H[0]; b = H[1]; c = H[2]; @@ -232,7 +232,7 @@ function SHA512(str) { g = H[6]; h = H[7]; - for (var j = 0; j < 80; j++) { + for (let j = 0; j < 80; j++) { if (j < 16) { W[j] = new int64(str[j*2 + i], str[j*2 + i + 1]); } else { @@ -261,8 +261,8 @@ function SHA512(str) { H[7] = safe_add_2(h, H[7]); } - var binarray = []; - for (var i = 0; i < H.length; i++) { + let binarray = []; + for (let i = 0; i < H.length; i++) { binarray.push(H[i].highOrder); binarray.push(H[i].lowOrder); } diff --git a/front/src/environments/environment.prod.ts b/front/src/environments/environment.prod.ts index 645c339..3843dcb 100644 --- a/front/src/environments/environment.prod.ts +++ b/front/src/environments/environment.prod.ts @@ -17,6 +17,5 @@ export const environment = { ssoSignOut: `${location.origin}/karso/signout/karideo/`, frontBaseUrl: '', tokenStoredInPermanentStorage: false, - //apiMode: 'REWRITE' }; diff --git a/front/src/environments/environment.ts b/front/src/environments/environment.ts index 1993ae2..166086c 100644 --- a/front/src/environments/environment.ts +++ b/front/src/environments/environment.ts @@ -17,7 +17,6 @@ const environment_back_prod = { ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/', frontBaseUrl: '', tokenStoredInPermanentStorage: false, - //apiMode: 'REWRITE' }; const environment_local = { @@ -34,7 +33,6 @@ const environment_local = { ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/', frontBaseUrl: '', tokenStoredInPermanentStorage: false, - //apiMode: 'REWRITE' }; const environment_hybrid = { @@ -51,7 +49,6 @@ const environment_hybrid = { ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/', frontBaseUrl: '', tokenStoredInPermanentStorage: false, - //apiMode: 'REWRITE' }; diff --git a/front/src/index.html b/front/src/index.html index 8ef0cdc..be26628 100644 --- a/front/src/index.html +++ b/front/src/index.html @@ -18,10 +18,6 @@ - - - -