This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ruby - https://github.com/RubyCrypto/rbnacl | |
| JavaScript - https://github.com/dchest/tweetnacl-js | |
| ## FE encrypt -> BE decrypt | |
| # FE | |
| const { publicKey, secretKey } = nacl.box.keyPair(); | |
| // every time you encrypt change the nonce | |
| const nonce = nacl.randomBytes(nacl.secretbox.nonceLength); | |
| const encodedNonce = nacl.util.encodeBase64(nonce); | |
| const encodedPublic = nacl.util.encodeBase64(publicKey); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| Injectable, | |
| Inject, | |
| OpaqueToken | |
| } from '@angular/core'; | |
| let resolveParameters = function (target: any, params: any[]) { | |
| if(params) { | |
| params.forEach((param, index) => { | |
| // this code is needed to make @Inject work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let resolveParameters = function (target: any, params: any[]) { | |
| if(params) { | |
| params.forEach((param, index) => { | |
| // this code is needed to make @Inject work | |
| if (param && param.annotation && param.annotation instanceof Inject) { | |
| param(target, void 0, index); | |
| } | |
| }); | |
| } | |
| return Reflect.getMetadata('parameters', target); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @MixinInjectable(Dependency, AnotherDependency, Inject(YetAnotherDependency)) | |
| class Mixin extends Base { | |
| dependency: Dependency; | |
| anotherDependency: AnotherDependency; | |
| yetAnotherDependency: IYetAnotherDependency; | |
| constructor(...args: any[]) { | |
| super(...args.slice(3)); | |
| this.dependency = args[0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface IPoint { | |
| x: number; | |
| y: number; | |
| } | |
| const WithLocation = <T extends Constructor<IPoint>>(Base: T) => | |
| class extends Base { | |
| getLocation(): [number, number] { | |
| return [this.x, this.y]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Point { | |
| constructor(public x: number, public y: number) {} | |
| } | |
| class Person { | |
| constructor(public name: string) {} | |
| } | |
| type Constructor<T> = new(...args: any[]) => T; |