mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
testing ciphering page
This commit is contained in:
parent
2a4219e149
commit
40c0c38889
@ -21,9 +21,9 @@
|
||||
"mock:server": "json-server --port 8000 --watch ./mocks/db.json --routes ./mocks/routes.json",
|
||||
"start:proxy": "ng serve --proxy-config proxy.conf.json",
|
||||
"start:proxymock": "concurrently --kill-others \"yarn mock:server\" \"yarn start:proxy\"",
|
||||
"i18n:init": "ngx-translate-extract --input ./src --output ./src/assets/i18n/template.json --key-as-default-value --replace --format json",
|
||||
"i18n:extract": "ngx-translate-extract --input ./src --output ./src/assets/i18n/{en,da,de,fi,nb,nl,sv}.json --clean --format json"
|
||||
},
|
||||
"i18n:init": "ngx-translate-extract --input ./src --output ./src/assets/i18n/template.json --key-as-default-value --replace --format json",
|
||||
"i18n:extract": "ngx-translate-extract --input ./src --output ./src/assets/i18n/{en,da,de,fi,nb,nl,sv}.json --clean --format json"
|
||||
},
|
||||
"private": false,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^9.1.1",
|
||||
@ -52,6 +52,7 @@
|
||||
"ngx-clipboard": "^13.0.0",
|
||||
"ngx-markdown": "^9.0.0",
|
||||
"ngx-webstorage": "^5.0.0",
|
||||
"node-forge": "^0.10.0",
|
||||
"primeng": "^9.0.6",
|
||||
"quill": "^1.3.7",
|
||||
"rxjs": "^6.5.5",
|
||||
|
@ -26,6 +26,7 @@ import { SharedModule } from './shared/shared.module';
|
||||
import { CguComponent } from './features/shared/components/ui/static-pages/cgu/cgu.component';
|
||||
import { LegalComponent } from './features/shared/components/ui/static-pages/legal/legal.component';
|
||||
import { PrivacyComponent } from './features/shared/components/ui/static-pages/privacy/privacy.component';
|
||||
import { CipheringComponent } from './features/shared/components/ui/static-pages/ciphering/ciphering.component';
|
||||
registerLocaleData(localeEn, 'en-EN');
|
||||
registerLocaleData(localeFr, 'fr-FR');
|
||||
|
||||
@ -40,7 +41,7 @@ export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [AppComponent, CguComponent, LegalComponent, PrivacyComponent],
|
||||
declarations: [AppComponent, CguComponent, LegalComponent, PrivacyComponent, CipheringComponent],
|
||||
imports: [
|
||||
AppRoutingModule,
|
||||
BrowserAnimationsModule,
|
||||
|
@ -228,7 +228,6 @@ export class PollService implements Resolve<Poll> {
|
||||
adminKey: '', // key to change config of the poll
|
||||
owner_modifier_token: '', // key to change a vote stack
|
||||
canModifyAnswers: newpoll.configuration.isAllowingtoChangeOwnAnswers, // bool for the frontend selector
|
||||
whoModifiesAnswers: newpoll.configuration.whoCanChangeAnswers, // everybody, self, nobody (: just admin)
|
||||
whoCanChangeAnswers: newpoll.configuration.whoCanChangeAnswers, // everybody, self, nobody (: just admin)
|
||||
dateList: newpoll.dateChoices, // sets of days as strings, config to set identical time for days in a special days poll
|
||||
timeList: newpoll.timeChoices, // ranges of time expressed as strings
|
||||
|
@ -1,13 +1,11 @@
|
||||
import { ChangeDetectorRef, Component, Inject, Input, OnInit } from '@angular/core';
|
||||
import { Poll } from '../../../core/models/poll.model';
|
||||
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { UuidService } from '../../../core/services/uuid.service';
|
||||
import { ApiService } from '../../../core/services/api.service';
|
||||
import { ToastService } from '../../../core/services/toast.service';
|
||||
import { PollService } from '../../../core/services/poll.service';
|
||||
import { DateUtilities } from '../../old-stuff/config/DateUtilities';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { CdkDragDrop } from '@angular/cdk/drag-drop';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
@ -28,7 +26,6 @@ export class FormComponent implements OnInit {
|
||||
private uuidService: UuidService,
|
||||
private toastService: ToastService,
|
||||
private pollService: PollService,
|
||||
public dateUtilities: DateUtilities,
|
||||
private apiService: ApiService,
|
||||
private router: Router,
|
||||
@Inject(DOCUMENT) private document: any
|
||||
@ -48,10 +45,21 @@ export class FormComponent implements OnInit {
|
||||
creatorEmail: ['', [Validators.required]],
|
||||
slug: [this.uuidService.getUUID(), [Validators.required]],
|
||||
description: ['', [Validators.required]],
|
||||
choices: new FormArray([]),
|
||||
// configuration: new FormGroup(),
|
||||
whoModifiesAnswers: ['', [Validators.required]],
|
||||
whoCanChangeAnswers: ['', [Validators.required]],
|
||||
choices: this.fb.array([
|
||||
this.fb.group({
|
||||
label: ['', [Validators.required]],
|
||||
imageUrl: ['', [Validators.required]],
|
||||
}),
|
||||
]),
|
||||
configuration: this.fb.group({
|
||||
whoCanChangeAnswers: ['everybody', [Validators.required]],
|
||||
// isProtectedByPassword: false,
|
||||
// isOwnerNotifiedByEmailOnNewVote: false,
|
||||
// isOwnerNotifiedByEmailOnNewComment: false,
|
||||
// isMaybeAnswerAvailable: false,
|
||||
// areResultsPublic: true,
|
||||
// expiracyNumberOfDays: 60,
|
||||
}),
|
||||
isAboutDate: [true, [Validators.required]],
|
||||
isProtectedByPassword: [false, [Validators.required]],
|
||||
startDateInterval: ['', [Validators.required]],
|
||||
@ -71,6 +79,7 @@ export class FormComponent implements OnInit {
|
||||
|
||||
if (showDemoValues) {
|
||||
this.setDemoValues();
|
||||
this.toastService.display('default values filled for demo');
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,9 +94,8 @@ export class FormComponent implements OnInit {
|
||||
creatorPseudo: 'Chuck Norris',
|
||||
creatorEmail: 'chucknorris@example.com',
|
||||
isAboutDate: true,
|
||||
hasSeveralHours: true,
|
||||
// hasSeveralHours: true,
|
||||
configuration: {
|
||||
whoModifiesAnswers: 'everybody',
|
||||
whoCanChangeAnswers: 'everybody',
|
||||
isProtectedByPassword: false,
|
||||
isOwnerNotifiedByEmailOnNewVote: false,
|
||||
|
@ -62,7 +62,6 @@ export class PollConfig {
|
||||
adminKey = ''; // key to change config of the poll
|
||||
owner_modifier_token = ''; // key to change a vote stack
|
||||
canModifyAnswers = true; // bool for the frontend selector
|
||||
whoModifiesAnswers = 'everybody'; // everybody, self, nobody (= just admin)
|
||||
whoCanChangeAnswers = 'everybody'; // everybody, self, nobody (= just admin)
|
||||
dateList: any = otherDefaultDates; // sets of days as strings, config to set identical time for days in a special days poll
|
||||
timeList: DateChoice[] = otherDefaultDates; // ranges of time expressed as strings
|
||||
|
@ -73,7 +73,7 @@
|
||||
name="modificationScope"
|
||||
id="modificationScope"
|
||||
*ngIf="true == !!config.canModifyAnswers"
|
||||
[(ngModel)]="config.whoModifiesAnswers"
|
||||
[(ngModel)]="config.whoCanChangeAnswers"
|
||||
[disabled]="false == !!config.canModifyAnswers"
|
||||
>
|
||||
<option value="self">
|
||||
|
@ -84,7 +84,6 @@ export class ConfigService extends PollConfig {
|
||||
password: this.password,
|
||||
customUrl: this.customUrl,
|
||||
canModifyAnswers: this.canModifyAnswers,
|
||||
whoModifiesAnswers: this.whoModifiesAnswers,
|
||||
dateList: this.dateList,
|
||||
timeList: this.timeList,
|
||||
answers: this.answers,
|
||||
|
@ -0,0 +1,22 @@
|
||||
<div class="ciphering padded">
|
||||
<h2>
|
||||
Test de chiffrement
|
||||
</h2>
|
||||
<br />
|
||||
<input type="text" [(ngModel)]="plainText" (ngModelChange)="encrypt(plainText)" />
|
||||
texte clair
|
||||
<br />
|
||||
<input type="text" [(ngModel)]="salt" />
|
||||
salt
|
||||
<br />
|
||||
<input type="text" [(ngModel)]="key" />
|
||||
pepper
|
||||
|
||||
<br />
|
||||
<input type="text" [(ngModel)]="cipheredText" />
|
||||
texte chiffré
|
||||
|
||||
<br />
|
||||
<input type="text" [(ngModel)]="otherCipheredText" />
|
||||
texte à déchiffrer
|
||||
</div>
|
@ -0,0 +1,24 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CipheringComponent } from './ciphering.component';
|
||||
|
||||
describe('CipheringComponent', () => {
|
||||
let component: CipheringComponent;
|
||||
let fixture: ComponentFixture<CipheringComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [CipheringComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CipheringComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,47 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
const forge = require('node-forge');
|
||||
|
||||
@Component({
|
||||
selector: 'app-ciphering',
|
||||
templateUrl: './ciphering.component.html',
|
||||
styleUrls: ['./ciphering.component.scss'],
|
||||
})
|
||||
export class CipheringComponent implements OnInit {
|
||||
public plainText = 'le texte à chiffrer';
|
||||
public cipheredText = '';
|
||||
public salt = forge.random.getBytesSync(128);
|
||||
public key = forge.random.getBytesSync(128);
|
||||
public otherCipheredText: any;
|
||||
|
||||
constructor() {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.encrypt(this.plainText);
|
||||
}
|
||||
|
||||
encrypt(someText) {
|
||||
// generate a random key and IV
|
||||
// Note: a key size of 16 bytes will use AES-128, 24 => AES-192, 32 => AES-256
|
||||
// const key = forge.random.getBytesSync(16);
|
||||
// const iv = forge.random.getBytesSync(16);
|
||||
|
||||
/* alternatively, generate a password-based 16-byte key
|
||||
var salt = forge.random.getBytesSync(128);
|
||||
var key = forge.pkcs5.pbkdf2('password', salt, numIterations, 16);
|
||||
*/
|
||||
|
||||
// encrypt some bytes using CBC mode
|
||||
// (other modes include: ECB, CFB, OFB, CTR, and GCM)
|
||||
// Note: CBC and ECB modes use PKCS#7 padding as default
|
||||
// const cipher = forge.cipher.createCipher('AES-CBC', this.key);
|
||||
// cipher.start({ iv: this.salt });
|
||||
// cipher.update(forge.util.createBuffer(someText));
|
||||
// cipher.finish();
|
||||
// const encrypted = cipher.output;
|
||||
// this.cipheredText = encrypted.toHex();
|
||||
this.cipheredText = someText;
|
||||
// outputs encrypted hex
|
||||
console.log(this.cipheredText);
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import { WipTodoComponent } from './shared/components/ui/wip-todo/wip-todo.compo
|
||||
import { CguComponent } from './features/shared/components/ui/static-pages/cgu/cgu.component';
|
||||
import { LegalComponent } from './features/shared/components/ui/static-pages/legal/legal.component';
|
||||
import { PrivacyComponent } from './features/shared/components/ui/static-pages/privacy/privacy.component';
|
||||
import { CipheringComponent } from './features/shared/components/ui/static-pages/ciphering/ciphering.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{ path: '', component: HomeComponent },
|
||||
@ -60,6 +61,10 @@ export const routes: Routes = [
|
||||
path: 'privacy',
|
||||
component: PrivacyComponent,
|
||||
},
|
||||
{
|
||||
path: 'ciphering',
|
||||
component: CipheringComponent,
|
||||
},
|
||||
{ path: 'page-not-found', component: PageNotFoundComponent },
|
||||
{ path: '**', redirectTo: 'page-not-found', pathMatch: 'full' },
|
||||
];
|
||||
|
@ -8193,6 +8193,11 @@ node-forge@0.9.0:
|
||||
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579"
|
||||
integrity sha512-7ASaDa3pD+lJ3WvXFsxekJQelBKRpne+GOVbLbtHYdd7pFspyeuJHnWfLplGf3SwKGbfs/aYl5V/JCIaHVUKKQ==
|
||||
|
||||
node-forge@^0.10.0:
|
||||
version "0.10.0"
|
||||
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3"
|
||||
integrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==
|
||||
|
||||
node-int64@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
|
||||
|
Loading…
Reference in New Issue
Block a user