Commit 9b29e1f0 authored by David Burke's avatar David Burke

tests

parent 2f579591
matrix:
include:
- os: linux
language: android
jdk: oraclejdk8
before_script:
- echo no | android create avd --force -n test -t android-21 -b armeabi-v7a
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
before_install:
- nvm install 6
script: npm run test.android
- os: osx
language: node_js
node_js: "6"
jdk: oraclejdk8
osx_image: xcode8.3
script: npm run test.ios
android:
components:
- tools
- platform-tools
- build-tools-23.0.2
- android-23
- extra-android-m2repository
- sys-img-armeabi-v7a-android-21
install:
- npm install -g nativescript
- tns usage-reporting disable
- tns error-reporting disable
- cd src
\ No newline at end of file
......@@ -8,7 +8,6 @@ export class HelloWorldModel extends Observable {
constructor() {
super();
this.libsodium = new Libsodium();
this.message = this.libsodium.message;
this.message = Libsodium.DEMO_MSG();
}
}
\ No newline at end of file
var Libsodium = require("nativescript-libsodium").Libsodium;
var libsodium = new Libsodium();
describe("greet function", function () {
it("exists", function () {
expect(libsodium.greet).toBeDefined();
});
it("returns a string", function () {
expect(libsodium.greet()).toEqual("Hello, NS");
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var nativescript_libsodium_1 = require("nativescript-libsodium");
describe("libsodium nativescript wrapper", function () {
it("can generate a keypair", function () {
var keypair = nativescript_libsodium_1.Libsodium.crypto_box_keypair();
expect(keypair.privateKey).toBeDefined();
expect(keypair.publicKey).toBeDefined();
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0ZXN0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsd0JBQXdCLENBQUMsQ0FBQyxTQUFTLENBQUM7QUFDNUQsSUFBSSxTQUFTLEdBQUcsSUFBSSxTQUFTLEVBQUUsQ0FBQztBQUVoQyxRQUFRLENBQUMsZ0JBQWdCLEVBQUU7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QixFQUFFO1FBQ3pCLElBQUksT0FBTyxHQUFHLGtDQUFTLENBQUMsa0JBQWtCLEVBQUUsQ0FBQztRQUM3QyxNQUFNLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDLFdBQVcsRUFBRSxDQUFDO1FBQ3pDLE1BQU0sQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUMsV0FBVyxFQUFFLENBQUM7SUFDNUMsQ0FBQyxDQUFDLENBQUM7QUFFUCxDQUFDLENBQUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IExpYnNvZGl1bSB9IGZyb20gXCJuYXRpdmVzY3JpcHQtbGlic29kaXVtXCI7XG5cbmRlc2NyaWJlKFwibGlic29kaXVtIG5hdGl2ZXNjcmlwdCB3cmFwcGVyXCIsIGZ1bmN0aW9uKCkge1xuICAgIGl0KFwiY2FuIGdlbmVyYXRlIGEga2V5cGFpclwiLCBmdW5jdGlvbigpIHtcbiAgICAgICAgbGV0IGtleXBhaXIgPSBMaWJzb2RpdW0uY3J5cHRvX2JveF9rZXlwYWlyKCk7XG4gICAgICAgIGV4cGVjdChrZXlwYWlyLnByaXZhdGVLZXkpLnRvQmVEZWZpbmVkKCk7XG4gICAgICAgIGV4cGVjdChrZXlwYWlyLnB1YmxpY0tleSkudG9CZURlZmluZWQoKTtcbiAgICB9KTtcblxufSk7XG4iXX0=
\ No newline at end of file
let Libsodium = require("nativescript-libsodium").Libsodium;
let libsodium = new Libsodium();
import { Libsodium } from "nativescript-libsodium";
describe("greet function", function() {
it("exists", function() {
expect(libsodium.greet).toBeDefined();
describe("libsodium nativescript wrapper", function() {
it("can generate a keypair", function() {
let keypair = Libsodium.crypto_box_keypair();
expect(keypair.privateKey).toBeDefined();
expect(keypair.publicKey).toBeDefined();
});
it("returns a string", function() {
expect(libsodium.greet()).toEqual("Hello, NS");
});
});
import { Observable } from 'tns-core-modules/data/observable';
export declare class Common extends Observable {
message: string;
constructor();
}
export interface IKeyPair {
keyType?: string;
privateKey: Uint8Array;
publicKey: Uint8Array;
}
export declare class SodiumWrapper {
export declare class Common {
static BASE64_FLAGS: number;
private static javaByteArrayToUint8Array(javaBytes);
static Uint8ArrayToJavaByteArray(inBytes: Uint8Array): native.Array<number>;
......@@ -16,6 +11,6 @@ export declare class SodiumWrapper {
static from_base64(sBase64: string): Uint8Array;
static randombytes_buf(length: number): Uint8Array;
static crypto_box_keypair(): IKeyPair;
static crypto_pwhashcrypto_pwhash(keyLength: number, password: String | Uint8Array, salt: Uint8Array, opsLimit: number, memlimit: number, algorithm: number): native.Array<number>;
static SUCCESS_MSG(): string;
static crypto_pwhash(keyLength: number, password: String | Uint8Array, salt: Uint8Array, opsLimit: number, memlimit: number, algorithm: number): native.Array<number>;
static DEMO_MSG(): string;
}
......@@ -9,22 +9,13 @@ const Sodium = org.libsodium.jni.Sodium;
let Base64 = android.util.Base64;
export class Common extends Observable {
public message: string;
constructor() {
super();
this.message = SodiumWrapper.SUCCESS_MSG();
}
}
export interface IKeyPair {
keyType?: string;
privateKey: Uint8Array;
publicKey: Uint8Array;
}
export class SodiumWrapper {
export class Common {
static BASE64_FLAGS = Base64.NO_WRAP | Base64.NO_CLOSE;
private static javaByteArrayToUint8Array(javaBytes: native.Array<number>) {
......@@ -68,7 +59,7 @@ export class SodiumWrapper {
};
}
public static crypto_pwhashcrypto_pwhash(keyLength: number, password: String | Uint8Array, salt: Uint8Array, opsLimit: number, memlimit: number, algorithm: number) {
public static crypto_pwhash(keyLength: number, password: String | Uint8Array, salt: Uint8Array, opsLimit: number, memlimit: number, algorithm: number) {
let passwd: Uint8Array;
if (password instanceof String) {
passwd = new TextEncoder('utf-8').encode(password);
......@@ -93,15 +84,15 @@ export class SodiumWrapper {
return key;
}
public static SUCCESS_MSG(): string {
// let rand = this.randombytes_buf(org.libsodium.jni.SodiumConstants.SECRETKEY_BYTES);
let x = this.crypto_box_keypair();
let key = x.privateKey;
let bb = new Uint8Array([1, 1, 1]);
console.log(typeof(key));
console.log(typeof(bb));
let y = this.to_base64(key);
let msg = `Your plugin is working on ${y}`;
public static DEMO_MSG(): string {
let msg = '';
let rand = this.randombytes_buf(org.libsodium.jni.SodiumConstants.SECRETKEY_BYTES);
msg += `Some random bytes: ${rand}\n`;
let keypair = this.crypto_box_keypair();
let privateKey64 = this.to_base64(keypair.privateKey);
msg += `Private key in base64: ${privateKey64}\n`;
return msg;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment