Adding parsing

This commit is contained in:
2020-07-06 13:01:41 +02:00
parent a8548007d5
commit 9a8c414936
28 changed files with 587 additions and 173 deletions

View File

@@ -1,4 +1,5 @@
const { app, BrowserWindow, Menu } = require('electron')
const { app, BrowserWindow, Menu } = require('electron');
const { settings } = require('cluster');
let win;
@@ -13,8 +14,11 @@ function createWindow () {
//icon: `file://${__dirname}/dist/offpass-electron/assets/logo.png`
})
Menu.setApplicationMenu(null)
win.loadURL(`file://${__dirname}/dist/offpass-electron/index.html`)
//set.loadURL(`file://${__dirname}/dist/ofpass-electron/settinds`)
//// uncomment below to open the DevTools.
// win.webContents.openDevTools()

29
package-lock.json generated
View File

@@ -1997,6 +1997,24 @@
"integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==",
"dev": true
},
"@zxing/library": {
"version": "0.15.2",
"resolved": "https://registry.npmjs.org/@zxing/library/-/library-0.15.2.tgz",
"integrity": "sha512-J+N88Eyg6eI2SKIk2YIkjjNICbMSqmLZnB3oD1S21Bi3k+Ddg2eKe/nW+Hce4NKAFAZtY1mdDM08Bj9eu87HSg==",
"requires": {
"text-encoding": "^0.7.0",
"ts-custom-error": "^3.0.0"
}
},
"@zxing/ngx-scanner": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@zxing/ngx-scanner/-/ngx-scanner-3.0.0.tgz",
"integrity": "sha512-WK3VwklpGp2zBhZdBIUETO9igk5fOOvLUZpTjk2LDsqAxAhdNYbtOQVYJGSwSsF3evP8sKPxmyNlW3FF9vr7yQ==",
"requires": {
"@zxing/library": "^0.15.1",
"tslib": "^1.9.0"
}
},
"JSONStream": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
@@ -12305,6 +12323,12 @@
}
}
},
"text-encoding": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz",
"integrity": "sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==",
"optional": true
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
@@ -12447,6 +12471,11 @@
"utf8-byte-length": "^1.0.1"
}
},
"ts-custom-error": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/ts-custom-error/-/ts-custom-error-3.1.1.tgz",
"integrity": "sha512-f/syoy+pTE4z82qaiRuthEeZtCGNKzlfs0Zc8jpQFcz/CYMaFSwFSdfFt1sSFnPlDLOEm7RCROdIxZ44N8UlwA=="
},
"ts-node": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz",

View File

@@ -19,6 +19,7 @@
"@angular/platform-browser": "~9.1.11",
"@angular/platform-browser-dynamic": "~9.1.11",
"@angular/router": "~9.1.11",
"@zxing/ngx-scanner": "^3.0.0",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"

View File

@@ -0,0 +1 @@
<p>addpass works!</p>

View File

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AddpassComponent } from './addpass.component';
describe('AddpassComponent', () => {
let component: AddpassComponent;
let fixture: ComponentFixture<AddpassComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddpassComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddpassComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-addpass',
templateUrl: './addpass.component.html',
styleUrls: ['./addpass.component.scss']
})
export class AddpassComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -1,22 +1 @@
<div>
<div class="red"></div>
<div class="black"></div>
<img class="bg" src="assets/op-desktop-bg-new.png">
<img class="logo" src="assets/logo_text.png">
<div class="button1">
<p class="scan">Click to scan</p>
</div>
<p class="alpha">Alpha</p>
<div class="donate-div">
<img class="donate-img" src="assets/donate.png">
<p class="donate-text">Donate</p>
</div>
<div class="new-div">
<img class="new-img" src="assets/add.png">
<p class="new-text">New</p>
</div>
<div class="settings-div">
<img class="settings-img" src="assets/settings.png">
<p class="settings-text">Settings</p>
</div>
</div>
<router-outlet></router-outlet>

View File

@@ -1,147 +0,0 @@
@import url('https://fonts.googleapis.com/css2?family=Righteous&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Righteous&family=Roboto&display=swap');
//* Pictures *\\
.bg{
position: absolute;
left: 0;
top: 0;
z-index: -1;
}
.logo{
position: absolute;
width: 280px;
height: 280px;
left: 267px;
top: -30px;
}
.donate-img{
position: absolute;
left: 38%;
right: 57%;
top: 56.17%;
bottom: 37.5%;
}
.new-img{
position: absolute;
left: 48.25%;
right: 46.12%;
top: 55.17%;
bottom: 37.5%;
}
.settings-img{
position: absolute;
width: 43.85px;
height: 43.85px;
left: 476px;
top: 320px;
}
//*Divs colors*\\
.red{
position: absolute;
width: 322.63px;
height: 848.08px;
padding-top: 300px;
background: #FF2A2A;
transform: rotate(110.24deg);
}
.black{
position: absolute;
width: 444.58px;
height: 839.77px;
padding-top: 800px;
background: #1C1C1C;
transform: rotate(-114.86deg);
}
//* Texte *\\
.alpha{
position: absolute;
padding-top: 500px;
padding-left: 700px;
font-family: 'Righteous', cursive;
font-style: normal;
font-weight: normal;
font-size: 24px;
line-height: 30px;
letter-spacing: 0.13em;
color: white;
}
.scan{
position: absolute;
bottom: -11px;
left: 42px;
font-family: 'Roboto', sans-serif;
font-style: normal;
font-weight: normal;
font-size: 24px;
line-height: 28px;
color: white;
}
.donate-text{
position: absolute;
width: 45px;
height: 16px;
left: 304px;
top: 370px;
font-family: 'Roboto', sans-serif;
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 16px;
color: #1C1C1C;
}
.new-text{
position: absolute;
width: 28px;
height: 16px;
left: 393px;
top: 370px;
font-family: 'Roboto', sans-serif;
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 16px;
color: #1C1C1C;
}
.settings-text{
position: absolute;
width: 52px;
height: 16px;
left: 468px;
top: 370px;
font-family: 'Roboto', sans-serif;
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 16px;
}
//* Buttons *\\
.button1{
position: absolute;
left: 37.25%;
right: 35%;
top: 40.5%;
bottom: 50.83%;
background: #1C1C1C;
mix-blend-mode: normal;
border-radius: 4px;
}

View File

@@ -3,14 +3,35 @@ import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AddpassComponent } from './addpass/addpass.component';
import { SettingsComponent } from './settings/settings.component';
import { ScanComponent } from './scan/scan.component';
import { DonateComponent } from './donate/donate.component';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { ZXingScannerModule } from '@zxing/ngx-scanner';
const routes: Routes = [
{ path: '', component: HomeComponent},
{ path: 'settings', component: SettingsComponent },
{ path: 'donate', component: DonateComponent },
{ path: 'scan', component: ScanComponent },
{ path: 'addpass', component: AddpassComponent }
];
@NgModule({
declarations: [
AppComponent
AppComponent,
AddpassComponent,
SettingsComponent,
ScanComponent,
DonateComponent,
HomeComponent
],
imports: [
RouterModule.forRoot(routes),
BrowserModule,
AppRoutingModule
AppRoutingModule,
ZXingScannerModule
],
providers: [],
bootstrap: [AppComponent]

View File

@@ -0,0 +1 @@
<p>donate works!</p>

View File

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DonateComponent } from './donate.component';
describe('DonateComponent', () => {
let component: DonateComponent;
let fixture: ComponentFixture<DonateComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DonateComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DonateComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-donate',
templateUrl: './donate.component.html',
styleUrls: ['./donate.component.scss']
})
export class DonateComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -0,0 +1,29 @@
<div>
<div class="red"></div>
<div class="black"></div>
<img class="bg" src="assets/op-desktop-bg-new.png">
<img class="logo" src="assets/logo_text.png">
<a [routerLink]="['/scan']">
<div class="button1">
<p class="scan">Click to scan</p>
</div>
</a>
<a [routerLink]="['/donate']">
<div class="donate-div">
<img class="donate-img" src="assets/donate.png">
<p class="donate-text">Donate</p>
</div>
</a>
<a [routerLink]="['/addpass']">
<div class="new-div">
<img class="new-img" src="assets/add.png">
<p class="new-text">New</p>
</div>
</a>
<a [routerLink]="['/settings']">
<div class="settings-div">
<img class="settings-img" src="assets/settings.png">
<p class="settings-text">Settings</p>
</div>
</a>
</div>

View File

@@ -0,0 +1,134 @@
@import url('https://fonts.googleapis.com/css2?family=Righteous&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Righteous&family=Roboto&display=swap');
//* Pictures *\\
.bg{
position: absolute;
left: 0;
top: 0;
z-index: -1;
}
.logo{
position: absolute;
width: 280px;
height: 280px;
left: 267px;
top: -30px;
}
.donate-img{
position: absolute;
left: 38%;
right: 57%;
top: 56.17%;
bottom: 37.5%;
}
.new-img{
position: absolute;
left: 48.25%;
right: 46.12%;
top: 55.17%;
bottom: 37.5%;
}
.settings-img{
position: absolute;
width: 43.85px;
height: 43.85px;
left: 476px;
top: 333px;
}
//*Divs colors*\\
.red{
position: absolute;
width: 322.63px;
height: 848.08px;
padding-top: 300px;
background: #FF2A2A;
transform: rotate(110.24deg);
}
.black{
position: absolute;
width: 444.58px;
height: 839.77px;
padding-top: 800px;
background: #1C1C1C;
transform: rotate(-114.86deg);
}
//* Texte *\\
.scan{
position: absolute;
bottom: -11px;
left: 42px;
font-family: 'Roboto', sans-serif;
font-style: normal;
font-weight: normal;
font-size: 24px;
line-height: 28px;
color: white;
}
.donate-text{
position: absolute;
width: 45px;
height: 16px;
left: 304px;
top: 370px;
font-family: 'Roboto', sans-serif;
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 16px;
color: #1C1C1C;
}
.new-text{
position: absolute;
width: 28px;
height: 16px;
left: 393px;
top: 370px;
font-family: 'Roboto', sans-serif;
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 16px;
color: #1C1C1C;
}
.settings-text{
position: absolute;
width: 52px;
height: 16px;
left: 468px;
top: 370px;
font-family: 'Roboto', sans-serif;
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 16px;
}
//* Buttons *\\
.button1{
position: absolute;
left: 37.25%;
right: 35%;
top: 40.5%;
bottom: 50.83%;
background: #1C1C1C;
mix-blend-mode: normal;
border-radius: 4px;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HomeComponent } from './home.component';
describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomeComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -0,0 +1,2 @@
<zxing-scanner (scanSuccess)="scanSuccessHandler($event)">
</zxing-scanner>

View File

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ScanComponent } from './scan.component';
describe('ScanComponent', () => {
let component: ScanComponent;
let fixture: ComponentFixture<ScanComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ScanComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ScanComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,25 @@
import { Component, ViewChild, ViewEncapsulation, OnInit } from '@angular/core';
import { SchemaService } from '../schema.service';
@Component({
selector: 'app-scan',
templateUrl: './scan.component.html',
styleUrls: ['./scan.component.scss']
})
export class ScanComponent implements OnInit {
constructor(private schema:SchemaService){
}
ngOnInit() {
this.schema.decrypted_raw = "%JtuB4O9M42%Gitea|Nicolas|542superGoOD_pW&|klier.nicolas@protonmail.com|https://nicolasklier.de:3000|($vb)$O4|()What's your favorite series%Rick and morty|(2fa)otpauth://totp/OffPass%20Test?secret=d34gfkki5dkd5knifysrpgndd5xb2c7eddwki7ya4pvoisfa5c3ko5pv&issuer=Nicolas%20Klier"
this.schema.parse()
}
scanSuccessHandler(scan) {
console.log(scan)
}
}

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { SchemaService } from './schema.service';
describe('SshemaService', () => {
let service: SchemaService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(SchemaService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

133
src/app/schema.service.ts Normal file
View File

@@ -0,0 +1,133 @@
import { Injectable } from '@angular/core';
import { element } from 'protractor';
import { parseSelectorToR3Selector } from '@angular/compiler/src/core';
export interface ICustom {
key: string;
value: string;
}
export interface IFormat {
session_key?: string;
title: string;
username?: string;
password: string;
email?: string;
website_url?: URL | null;
custom?: Map<String, String>;
question_awnser?: Map<String, String>
}
@Injectable({
providedIn: 'root'
})
export class SchemaService {
raw: String = ""
decrypted_raw: String = ""
// Parsed content
text: string = null;
format: IFormat = {
session_key: "",
title: "",
username: "",
password: "",
email: "",
website_url: null,
custom: new Map<String, String>(), // All defined custom/optional fields
question_awnser: new Map<String, String>()
};
isCompatible(): boolean {
return true;
}
decrypt() {
if (this.isCompatible) {
}
}
encrypt() {
}
parse() {
const parts = this.decrypted_raw.split('|')
this.format.title = parts[0];
if (this.format.title.startsWith('%')) {
this.format.session_key = "";
for (let i = 1; i < this.format.title.length; i++) {
const char = this.format.title.charAt(i);
if (char != '%') {
this.format.session_key += char;
} else {
break;
}
}
this.format.title = this.format.title.substr(this.format.session_key.length + 2, this.format.title.length)
}
this.format.username = parts[1]
this.format.password = parts[2]
this.format.email = parts[3]
this.format.website_url = new URL(parts[4])
for(let i = 5; i < parts.length; i++){
const target_part = parts[i]
if(target_part.startsWith + "("){
const key = target_part.substring(1, target_part.indexOf(")"))
const value = target_part.substring(target_part.indexOf(")") + 1, target_part.length)
//sec question
if(key == ""){
const splitted = value.split("%")
this.format.question_awnser.set(splitted[0], splitted[1])
}
this.format.custom.set(key, value)
}
}
console.log(this)
}
build(data?: IFormat): string {
if (data == undefined) data = this.format;
let raw = "";
if (data.session_key != undefined) {
raw += "%" + data.session_key + "%";
}
raw += data.title + "|";
raw += data.username + "|";
raw += data.password + "|";
raw += data.email + "|";
raw += data.website_url + "|";
if (data.custom != undefined) {
data.custom.forEach((value, key, map) => {
raw += `(${key})${value}|`;
});
}
raw = raw.substr(0, raw.length - 1);
return raw;
}
}

View File

@@ -0,0 +1 @@
<p>settings works!</p>

View File

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SettingsComponent } from './settings.component';
describe('SettingsComponent', () => {
let component: SettingsComponent;
let fixture: ComponentFixture<SettingsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SettingsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SettingsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-settings',
templateUrl: './settings.component.html',
styleUrls: ['./settings.component.scss']
})
export class SettingsComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}