diff --git a/.gitignore b/.gitignore
index 026cd9c..33881d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,4 +18,4 @@ demo/platforms
demo/node_modules
node_modules
publish/src
-publish/package
\ No newline at end of file
+publish/package
diff --git a/demo/.nsbuildinfo b/demo/.nsbuildinfo
new file mode 100644
index 0000000..646180b
--- /dev/null
+++ b/demo/.nsbuildinfo
@@ -0,0 +1,4 @@
+{
+ "prepareTime": "Fri Aug 11 2017 00:52:11 GMT+0100 (WEST)",
+ "buildTime": "Fri Aug 11 2017 00:59:16 GMT+0100 (WEST)"
+}
\ No newline at end of file
diff --git a/demo/app/app.ts b/demo/app/app.ts
index a17b0bd..1d946a5 100644
--- a/demo/app/app.ts
+++ b/demo/app/app.ts
@@ -1,2 +1,2 @@
import * as application from 'tns-core-modules/application';
-application.start({ moduleName: "main-page" });
+application.start({ moduleName: 'main-page' });
diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts
index cb413fa..bebc97d 100644
--- a/demo/app/main-page.ts
+++ b/demo/app/main-page.ts
@@ -3,6 +3,9 @@ import * as pages from 'tns-core-modules/ui/page';
import { HelloWorldModel } from './main-view-model';
import { NSCrypto } from 'nativescript-crypto';
+import * as utils from './utils';
+
+import * as pako from 'pako';
let helloWorldModel: HelloWorldModel;
// Event handler for Page 'loaded' event attached in main-page.xml
@@ -15,11 +18,88 @@ export function pageLoaded(args: observable.EventData) {
const crypto = new NSCrypto();
+export function deflate_inflate() {
+ let start = new Date().getTime();
+ console.log(
+ 'crypto..inflate-nativo:',
+ '| native deflate ->',
+ crypto.deflate(crypto.base64encode('abc')),
+ '| pako deflate ->',
+ utils.asciiToBase64(pako.deflate('abc', { to: 'string' })),
+ '| native deflate > pako inflate ->',
+ pako.inflate(
+ utils.base64ToASCII(crypto.deflate(crypto.base64encode('abc'))),
+ { to: 'string' }
+ ),
+ '| native inflate ->',
+ crypto.inflate(utils.asciiToBase64(pako.deflate('abc', { to: 'string' }))),
+ '| pako inflate ->',
+ pako.inflate(
+ utils.base64ToASCII(crypto.deflate(crypto.base64encode('abc'))),
+ { to: 'string' }
+ ),
+ // crypto.base64encode(pako.deflate('abc', { to: 'string' })),
+ // crypto.base64encode(pako.deflate('123456', { to: 'string' })),
+ // crypto.base64encode(pako.deflate('sddddadsadas', { to: 'string' })),
+ // crypto.base64encode(
+ // pako.deflate('213871298381ds,jhsdbhbcasdbfhjkb874723', { to: 'string' })
+ // ),
+ ' elapsed ',
+ new Date().getTime() - start + 'ms'
+ );
+ console.log(new Date().getTime() - start + 'ms');
+
+ // start = new Date().getTime();
+ // console.log(
+ // 'crypto.inflate-js:',
+ // // pako.inflate(
+ // // crypto.base64decode(crypto.deflate(crypto.base64encode('abc'))),
+ // // // { to: 'string' }
+ // // //),
+ // crypto.base64encode(pako.deflate('abc', { to: 'string' })),
+ // // crypto.base64encode(pako.deflate('abc', { to: 'string' })),
+ // // crypto.base64encode(pako.deflate('123456', { to: 'string' })),
+ // // crypto.base64encode(pako.deflate('sddddadsadas', { to: 'string' })),
+ // // crypto.base64encode(
+ // // pako.deflate('213871298381ds,jhsdbhbcasdbfhjkb874723', { to: 'string' })
+ // // ),
+ // ' elapsed '
+ // );
+ // console.log(new Date().getTime() - start + 'ms');
+
+ let benchSTR = '';
+ const possible =
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ for (let i = 0; i < 1000000; i++) {
+ benchSTR += possible.charAt(Math.floor(Math.random() * possible.length));
+ }
+ const benchSTRb64 = crypto.base64encode(benchSTR);
+
+ start = new Date().getTime();
+ const nativeDef = crypto.deflate(benchSTRb64);
+ let durationNative = new Date().getTime() - start;
+ console.log('crypto.deflate-nativo:', durationNative + 'ms');
+ start = new Date().getTime();
+ const pakoDef = pako.deflate(benchSTR);
+ let durationPako = new Date().getTime() - start;
+ console.log('crypto.deflate-pako:', durationPako + 'ms');
+ console.log('deflate improvement:', durationPako / durationNative + 'x');
+ start = new Date().getTime();
+ crypto.inflate(nativeDef);
+ durationNative = new Date().getTime() - start;
+ console.log('crypto.inflate-nativo:', durationNative + 'ms');
+ start = new Date().getTime();
+ pako.inflate(pakoDef);
+ durationPako = new Date().getTime() - start;
+ console.log('crypto.inflate-pako:', durationPako + 'ms');
+ console.log('inflate improvement:', durationPako / durationNative + 'x');
+}
+
export function sha256() {
let start = new Date().getTime();
console.log(
- 'crypto.hash 256: ',
- crypto.hash('abc', 'sha256'),
+ 'crypto.hash 256:',
+ crypto.hash(crypto.base64encode('abc'), 'sha256'),
' elapsed ',
new Date().getTime() - start + 'ms'
);
@@ -149,12 +229,12 @@ CF6cPoRAME2qwxMBtItHmQso9vdsIv3TO3xpizm8zY2yXM5zPlorOcX0ldpHxQze
AnThVsu+gJq8hkjwBGjyKKMD7XjKkcFSZ4WyUN+CefBRfGaWQ3/hdRxXiABv3NV7
V04h1T7jJtgq/kDt/xL6D+M=
-----END RSA PRIVATE KEY-----`,
- crypto.base64encode('eyJhbGciOiJSUzI1NiIsImN0eSI6Impzb24ifQ.ImFiYyI'),
+ crypto.base64encode('abc'),
'sha256'
);
console.log(
'crypto.signRSA: ',
- crypto.base64encode('eyJhbGciOiJSUzI1NiIsImN0eSI6Impzb24ifQ.ImFiYyI'),
+ crypto.base64encode('abc'),
sig,
' elapsed ',
new Date().getTime() - start + 'ms'
@@ -182,3 +262,52 @@ tQIDAQAB
new Date().getTime() - start + 'ms'
);
}
+
+export function keyWrapUnWrap() {
+ let start = new Date().getTime();
+ let wrapped = crypto.keyWrapAES(
+ crypto.base64encode('5v8y/B?E(H+MbQeThWmZq3t6w9z$C&F)'),
+ crypto.base64encode('abcdefgh')
+ );
+ console.log(
+ 'crypto.keyWrapAES:',
+ wrapped,
+ crypto.keyUnWrapAES(
+ crypto.base64encode('5v8y/B?E(H+MbQeThWmZq3t6w9z$C&F)'),
+ wrapped
+ ),
+ ' elapsed',
+ new Date().getTime() - start + 'ms'
+ );
+}
+
+export function encryptAES256GCM() {
+ let start = new Date().getTime();
+ let enc = crypto.encryptAES256GCM(
+ crypto.base64encode('5v8y/B?E(H+MbQeThWmZq3t6w9z$C&F)'),
+ crypto.base64encode('abcdefgh'),
+ crypto.base64encode('aad'),
+ crypto.base64encode('5v8y/B?E(H+MbQeThWmZq3t6w9z$C&F)')
+ );
+ // enc = JSON.parse(
+ // ' {"cipherb":"EyXQdtYmN3U=","atag":"TMriPJGYM+Lev6kTzSJqkA=="}'
+ // );
+ console.log(
+ 'crypto.encryptAES256GCM: ',
+ ' - ',
+ crypto.base64encode('abcdefgh'),
+ ' - ',
+ crypto.base64encode('abcdefgh'),
+ ' - ',
+ JSON.stringify(enc),
+ crypto.decryptAES256GCM(
+ crypto.base64encode('5v8y/B?E(H+MbQeThWmZq3t6w9z$C&F)'),
+ enc.cipherb,
+ crypto.base64encode('aad'),
+ crypto.base64encode('5v8y/B?E(H+MbQeThWmZq3t6w9z$C&F)'),
+ enc.atag
+ ),
+ ' elapsed',
+ new Date().getTime() - start + 'ms'
+ );
+}
diff --git a/demo/app/main-page.xml b/demo/app/main-page.xml
index 8bcd5b8..451ba2a 100644
--- a/demo/app/main-page.xml
+++ b/demo/app/main-page.xml
@@ -4,7 +4,10 @@
-
-
+
+
+
+
+
diff --git a/demo/app/main-view-model.ts b/demo/app/main-view-model.ts
index 6efa5ee..b649019 100644
--- a/demo/app/main-view-model.ts
+++ b/demo/app/main-view-model.ts
@@ -1,11 +1,7 @@
-import { Observable } from "tns-core-modules/data/observable";
+import { Observable } from 'tns-core-modules/data/observable';
export class HelloWorldModel extends Observable {
-
-
constructor() {
super();
}
-
-
}
diff --git a/demo/app/utils.ts b/demo/app/utils.ts
new file mode 100644
index 0000000..561130b
--- /dev/null
+++ b/demo/app/utils.ts
@@ -0,0 +1,622 @@
+const base64map =
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
+const base64pad = '=';
+const BI_RM = '0123456789abcdefghijklmnopqrstuvwxyz';
+
+export const intTochar = n => {
+ return BI_RM.charAt(n);
+};
+
+export const encodeUTF8 = (s: string) => {
+ s = s.replace(/rn/g, 'n');
+ let t = '';
+ for (let n = 0; n < s.length; n++) {
+ let r = s.charCodeAt(n);
+ if (r < 128) {
+ t += String.fromCharCode(r);
+ } else if (r > 127 && r < 2048) {
+ t += String.fromCharCode((r >> 6) | 192);
+ t += String.fromCharCode((r & 63) | 128);
+ } else {
+ t += String.fromCharCode((r >> 12) | 224);
+ t += String.fromCharCode(((r >> 6) & 63) | 128);
+ t += String.fromCharCode((r & 63) | 128);
+ }
+ }
+ return t;
+};
+
+export const decodeUTF8 = (s: string) => {
+ let t = '';
+ let n = 0;
+ let c1, c2, c3;
+ let r = (c1 = c2 = 0);
+ while (n < s.length) {
+ r = s.charCodeAt(n);
+ if (r < 128) {
+ t += String.fromCharCode(r);
+ n++;
+ } else if (r > 191 && r < 224) {
+ c2 = s.charCodeAt(n + 1);
+ t += String.fromCharCode(((r & 31) << 6) | (c2 & 63));
+ n += 2;
+ } else {
+ c2 = s.charCodeAt(n + 1);
+ c3 = s.charCodeAt(n + 2);
+ t += String.fromCharCode(((r & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
+ n += 3;
+ }
+ }
+ return t;
+};
+
+export const asciiToBase64 = (str: string) => {
+ let t = '';
+ let n, r, i, s, o, u, a;
+ let f = 0;
+ // str = encodeUTF8(str);
+ while (f < str.length) {
+ n = str.charCodeAt(f++);
+ r = str.charCodeAt(f++);
+ i = str.charCodeAt(f++);
+ s = n >> 2;
+ o = ((n & 3) << 4) | (r >> 4);
+ u = ((r & 15) << 2) | (i >> 6);
+ a = i & 63;
+ if (isNaN(r)) {
+ u = a = 64;
+ } else if (isNaN(i)) {
+ a = 64;
+ }
+ t =
+ t +
+ base64map.charAt(s) +
+ base64map.charAt(o) +
+ base64map.charAt(u) +
+ base64map.charAt(a);
+ }
+ return t;
+};
+
+export const base64ToASCII = (str: string) => {
+ let t = '';
+ let n, r, i;
+ let s, o, u, a;
+ let f = 0;
+ str = str.replace(/[^A-Za-z0-9+/=]/g, '');
+ while (f < str.length) {
+ s = base64map.indexOf(str.charAt(f++));
+ o = base64map.indexOf(str.charAt(f++));
+ u = base64map.indexOf(str.charAt(f++));
+ a = base64map.indexOf(str.charAt(f++));
+ n = (s << 2) | (o >> 4);
+ r = ((o & 15) << 4) | (u >> 2);
+ i = ((u & 3) << 6) | a;
+ t = t + String.fromCharCode(n);
+ if (u !== 64) {
+ t = t + String.fromCharCode(r);
+ }
+ if (a !== 64) {
+ t = t + String.fromCharCode(i);
+ }
+ }
+ // t = decodeUTF8(t);
+ return t;
+};
+
+export const stringToBase64 = (str: string) => asciiToBase64(encodeUTF8(str));
+
+export const base64ToString = (str: string) => decodeUTF8(base64ToASCII(str));
+
+// Use a lookup table to find the index.
+const lookup = {
+ '0': 0,
+ '1': 0,
+ '2': 0,
+ '3': 0,
+ '4': 0,
+ '5': 0,
+ '6': 0,
+ '7': 0,
+ '8': 0,
+ '9': 0,
+ '10': 0,
+ '11': 0,
+ '12': 0,
+ '13': 0,
+ '14': 0,
+ '15': 0,
+ '16': 0,
+ '17': 0,
+ '18': 0,
+ '19': 0,
+ '20': 0,
+ '21': 0,
+ '22': 0,
+ '23': 0,
+ '24': 0,
+ '25': 0,
+ '26': 0,
+ '27': 0,
+ '28': 0,
+ '29': 0,
+ '30': 0,
+ '31': 0,
+ '32': 0,
+ '33': 0,
+ '34': 0,
+ '35': 0,
+ '36': 0,
+ '37': 0,
+ '38': 0,
+ '39': 0,
+ '40': 0,
+ '41': 0,
+ '42': 0,
+ '43': 62,
+ '44': 0,
+ '45': 0,
+ '46': 0,
+ '47': 63,
+ '48': 52,
+ '49': 53,
+ '50': 54,
+ '51': 55,
+ '52': 56,
+ '53': 57,
+ '54': 58,
+ '55': 59,
+ '56': 60,
+ '57': 61,
+ '58': 0,
+ '59': 0,
+ '60': 0,
+ '61': 0,
+ '62': 0,
+ '63': 0,
+ '64': 0,
+ '65': 0,
+ '66': 1,
+ '67': 2,
+ '68': 3,
+ '69': 4,
+ '70': 5,
+ '71': 6,
+ '72': 7,
+ '73': 8,
+ '74': 9,
+ '75': 10,
+ '76': 11,
+ '77': 12,
+ '78': 13,
+ '79': 14,
+ '80': 15,
+ '81': 16,
+ '82': 17,
+ '83': 18,
+ '84': 19,
+ '85': 20,
+ '86': 21,
+ '87': 22,
+ '88': 23,
+ '89': 24,
+ '90': 25,
+ '91': 0,
+ '92': 0,
+ '93': 0,
+ '94': 0,
+ '95': 0,
+ '96': 0,
+ '97': 26,
+ '98': 27,
+ '99': 28,
+ '100': 29,
+ '101': 30,
+ '102': 31,
+ '103': 32,
+ '104': 33,
+ '105': 34,
+ '106': 35,
+ '107': 36,
+ '108': 37,
+ '109': 38,
+ '110': 39,
+ '111': 40,
+ '112': 41,
+ '113': 42,
+ '114': 43,
+ '115': 44,
+ '116': 45,
+ '117': 46,
+ '118': 47,
+ '119': 48,
+ '120': 49,
+ '121': 50,
+ '122': 51,
+ '123': 0,
+ '124': 0,
+ '125': 0,
+ '126': 0,
+ '127': 0,
+ '128': 0,
+ '129': 0,
+ '130': 0,
+ '131': 0,
+ '132': 0,
+ '133': 0,
+ '134': 0,
+ '135': 0,
+ '136': 0,
+ '137': 0,
+ '138': 0,
+ '139': 0,
+ '140': 0,
+ '141': 0,
+ '142': 0,
+ '143': 0,
+ '144': 0,
+ '145': 0,
+ '146': 0,
+ '147': 0,
+ '148': 0,
+ '149': 0,
+ '150': 0,
+ '151': 0,
+ '152': 0,
+ '153': 0,
+ '154': 0,
+ '155': 0,
+ '156': 0,
+ '157': 0,
+ '158': 0,
+ '159': 0,
+ '160': 0,
+ '161': 0,
+ '162': 0,
+ '163': 0,
+ '164': 0,
+ '165': 0,
+ '166': 0,
+ '167': 0,
+ '168': 0,
+ '169': 0,
+ '170': 0,
+ '171': 0,
+ '172': 0,
+ '173': 0,
+ '174': 0,
+ '175': 0,
+ '176': 0,
+ '177': 0,
+ '178': 0,
+ '179': 0,
+ '180': 0,
+ '181': 0,
+ '182': 0,
+ '183': 0,
+ '184': 0,
+ '185': 0,
+ '186': 0,
+ '187': 0,
+ '188': 0,
+ '189': 0,
+ '190': 0,
+ '191': 0,
+ '192': 0,
+ '193': 0,
+ '194': 0,
+ '195': 0,
+ '196': 0,
+ '197': 0,
+ '198': 0,
+ '199': 0,
+ '200': 0,
+ '201': 0,
+ '202': 0,
+ '203': 0,
+ '204': 0,
+ '205': 0,
+ '206': 0,
+ '207': 0,
+ '208': 0,
+ '209': 0,
+ '210': 0,
+ '211': 0,
+ '212': 0,
+ '213': 0,
+ '214': 0,
+ '215': 0,
+ '216': 0,
+ '217': 0,
+ '218': 0,
+ '219': 0,
+ '220': 0,
+ '221': 0,
+ '222': 0,
+ '223': 0,
+ '224': 0,
+ '225': 0,
+ '226': 0,
+ '227': 0,
+ '228': 0,
+ '229': 0,
+ '230': 0,
+ '231': 0,
+ '232': 0,
+ '233': 0,
+ '234': 0,
+ '235': 0,
+ '236': 0,
+ '237': 0,
+ '238': 0,
+ '239': 0,
+ '240': 0,
+ '241': 0,
+ '242': 0,
+ '243': 0,
+ '244': 0,
+ '245': 0,
+ '246': 0,
+ '247': 0,
+ '248': 0,
+ '249': 0,
+ '250': 0,
+ '251': 0,
+ '252': 0,
+ '253': 0,
+ '254': 0,
+ '255': 0
+};
+
+export const arrayBufferToBase64 = (ab: ArrayBuffer) => {
+ let bytes = new Uint8Array(ab),
+ i,
+ len = bytes.length,
+ base64 = '';
+
+ for (i = 0; i < len; i += 3) {
+ base64 += base64map[bytes[i] >> 2];
+ base64 += base64map[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
+ base64 += base64map[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
+ base64 += base64map[bytes[i + 2] & 63];
+ }
+
+ if (len % 3 === 2) {
+ base64 = base64.substring(0, base64.length - 1) + '=';
+ } else if (len % 3 === 1) {
+ base64 = base64.substring(0, base64.length - 2) + '==';
+ }
+
+ return base64;
+};
+
+export const base64ToArrayBuffer = (base64: string) => {
+ let bufferLength = base64.length * 0.75,
+ len = base64.length,
+ i,
+ p = 0,
+ encoded1,
+ encoded2,
+ encoded3,
+ encoded4;
+
+ if (base64[base64.length - 1] === '=') {
+ bufferLength--;
+ if (base64[base64.length - 2] === '=') {
+ bufferLength--;
+ }
+ }
+
+ let arraybuffer = new ArrayBuffer(bufferLength),
+ bytes = new Uint8Array(arraybuffer);
+
+ for (i = 0; i < len; i += 4) {
+ encoded1 = lookup[base64.charCodeAt(i)];
+ encoded2 = lookup[base64.charCodeAt(i + 1)];
+ encoded3 = lookup[base64.charCodeAt(i + 2)];
+ encoded4 = lookup[base64.charCodeAt(i + 3)];
+
+ bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
+ bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
+ bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
+ }
+
+ return arraybuffer;
+};
+
+export const hexToBase64 = h => {
+ let i;
+ let c;
+ let ret = '';
+ for (i = 0; i + 3 <= h.length; i += 3) {
+ c = parseInt(h.substring(i, i + 3), 16);
+ ret += base64map.charAt(c >> 6) + base64map.charAt(c & 63);
+ }
+ if (i + 1 === h.length) {
+ c = parseInt(h.substring(i, i + 1), 16);
+ ret += base64map.charAt(c << 2);
+ } else if (i + 2 === h.length) {
+ c = parseInt(h.substring(i, i + 2), 16);
+ ret += base64map.charAt(c >> 2) + base64map.charAt((c & 3) << 4);
+ }
+ if (base64pad) {
+ while ((ret.length & 3) > 0) {
+ ret += base64pad;
+ }
+ }
+ return ret;
+};
+
+// convert a base64 string to hex
+export const base64ToHex = s => {
+ let ret = '';
+ let i;
+ let k = 0; // b64 state, 0-3
+ let slop;
+ let v;
+ for (i = 0; i < s.length; ++i) {
+ if (s.charAt(i) === base64pad) {
+ break;
+ }
+ v = base64map.indexOf(s.charAt(i));
+ if (v < 0) {
+ continue;
+ }
+ if (k === 0) {
+ ret += intTochar(v >> 2);
+ slop = v & 3;
+ k = 1;
+ } else if (k === 1) {
+ ret += intTochar((slop << 2) | (v >> 4));
+ slop = v & 0xf;
+ k = 2;
+ } else if (k === 2) {
+ ret += intTochar(slop);
+ ret += intTochar(v >> 2);
+ slop = v & 3;
+ k = 3;
+ } else {
+ ret += intTochar((slop << 2) | (v >> 4));
+ ret += intTochar(v & 0xf);
+ k = 0;
+ }
+ }
+ if (k === 1) {
+ ret += intTochar(slop << 2);
+ }
+ return ret;
+};
+
+// convert a base64 string to a byte/number array
+export const base64ToByteArray = s => {
+ // piggyback on b64tohex for now, optimize later
+ let h = base64ToHex(s);
+ let a = new Array();
+ for (let i = 0; 2 * i < h.length; ++i) {
+ a[i] = parseInt(h.substring(2 * i, 2 * i + 2), 16);
+ }
+ return a;
+};
+
+export const hexToUint8Array = (hex: string) => {
+ let out = new Uint8Array(Math.ceil(hex.length / 2));
+ let i = 0,
+ j = 0;
+ if (hex.length & 1) {
+ // odd number of characters, convert first character alone
+ i = 1;
+ out[j++] = parseInt(hex[0], 16);
+ }
+ // convert 2 characters (1 byte) at a time
+ for (; i < hex.length; i += 2) {
+ out[j++] = parseInt(hex.substr(i, 2), 16);
+ }
+ return out;
+};
+
+export const isBase64 = s => {
+ s = s.replace(/\s+/g, '');
+ if (s.match(/^[0-9A-Za-z+\/]+={0,3}$/) && s.length % 4 === 0) {
+ return true;
+ } else {
+ return false;
+ }
+};
+
+export const isBase64URL = s => {
+ if (s.match(/[+/=]/)) {
+ return false;
+ }
+ s = base64URLtoBase64(s);
+ return isBase64(s);
+};
+
+export const base64toBase64url = s => {
+ s = s.replace(/\=/g, '');
+ s = s.replace(/\+/g, '-');
+ s = s.replace(/\//g, '_');
+ return s;
+};
+
+export const base64URLtoBase64 = s => {
+ if (s.length % 4 === 2) {
+ s = s + '==';
+ } else if (s.length % 4 === 3) {
+ s = s + '=';
+ }
+ s = s.replace(/-/g, '+');
+ s = s.replace(/_/g, '/');
+ return s;
+};
+
+export const base64uToHex = s => base64ToHex(base64URLtoBase64(s));
+export const hexToBase64u = s => base64toBase64url(hexToBase64(s));
+
+export const base64uToString = s => base64ToString(base64URLtoBase64(s));
+export const stringToBase64u = s => base64toBase64url(stringToBase64(s));
+
+export const base64uToArrayBuffer = s =>
+ base64ToArrayBuffer(base64URLtoBase64(s));
+
+export const arrayBufferToBase64u = s =>
+ base64toBase64url(arrayBufferToBase64(s));
+
+export const hexTobase64WithNL = s => {
+ const b64 = hexToBase64(s);
+ let b64nl = b64.replace(/(.{64})/g, '$1\r\n');
+ b64nl = b64nl.replace(/\r\n$/, '');
+ return b64nl;
+};
+
+export const hexToPEM = (dataHex, pemHeader) => {
+ const pemBody = hexTobase64WithNL(dataHex);
+ return (
+ '-----BEGIN ' +
+ pemHeader +
+ '-----\r\n' +
+ pemBody +
+ '\r\n-----END ' +
+ pemHeader +
+ '-----\r\n'
+ );
+};
+
+export const stringToArray = (s: string) => {
+ let a: number[] = new Array();
+ for (let i = 0; i < s.length; i++) {
+ a[i] = s.charCodeAt(i);
+ }
+ return a;
+};
+
+export const stringToArrayBuffer = (s: string): ArrayBuffer => {
+ let a: Uint8Array = new Uint8Array(s.length);
+ for (let i = 0; i < s.length; i++) {
+ a[i] = s.charCodeAt(i) & 0xff;
+ }
+ return a.buffer;
+};
+
+export const arrayBufferToString = (a: ArrayBuffer): string => {
+ const array = new Uint8Array(a);
+ let str = '';
+
+ for (let i = 0; i < array.length; i++) {
+ str += String.fromCharCode(array[i]);
+ }
+ return str;
+};
+
+export const arrayToHex = (a: number[]) => {
+ let s = '';
+ for (let i = 0; i < a.length; i++) {
+ let hex1 = a[i].toString(16);
+ if (hex1.length === 1) {
+ hex1 = '0' + hex1;
+ }
+ s = s + hex1;
+ }
+ return s;
+};
+
+export const stringToHex = (s: string) => arrayToHex(stringToArray(s));
diff --git a/demo/package-lock.json b/demo/package-lock.json
new file mode 100644
index 0000000..624f92b
--- /dev/null
+++ b/demo/package-lock.json
@@ -0,0 +1,3083 @@
+{
+ "requires": true,
+ "lockfileVersion": 1,
+ "dependencies": {
+ "@types/pako": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/@types%2fpako/-/pako-1.0.0.tgz",
+ "integrity": "sha1-6q6DZNG391LiY7w/1o3+yY5hNsU="
+ },
+ "accepts": {
+ "version": "1.3.3",
+ "resolved": "https://npm.dev.mysns.pt/accepts/-/accepts-1.3.3.tgz",
+ "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=",
+ "dev": true,
+ "requires": {
+ "mime-types": "2.1.16",
+ "negotiator": "0.6.1"
+ }
+ },
+ "after": {
+ "version": "0.8.2",
+ "resolved": "https://npm.dev.mysns.pt/after/-/after-0.8.2.tgz",
+ "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=",
+ "dev": true
+ },
+ "ansi-regex": {
+ "version": "2.1.1",
+ "resolved": "https://npm.dev.mysns.pt/ansi-regex/-/ansi-regex-2.1.1.tgz",
+ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
+ "dev": true
+ },
+ "ansi-styles": {
+ "version": "2.2.1",
+ "resolved": "https://npm.dev.mysns.pt/ansi-styles/-/ansi-styles-2.2.1.tgz",
+ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
+ "dev": true
+ },
+ "anymatch": {
+ "version": "1.3.2",
+ "resolved": "https://npm.dev.mysns.pt/anymatch/-/anymatch-1.3.2.tgz",
+ "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==",
+ "dev": true,
+ "requires": {
+ "micromatch": "2.3.11",
+ "normalize-path": "2.1.1"
+ }
+ },
+ "arr-diff": {
+ "version": "2.0.0",
+ "resolved": "https://npm.dev.mysns.pt/arr-diff/-/arr-diff-2.0.0.tgz",
+ "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=",
+ "dev": true,
+ "requires": {
+ "arr-flatten": "1.1.0"
+ }
+ },
+ "arr-flatten": {
+ "version": "1.1.0",
+ "resolved": "https://npm.dev.mysns.pt/arr-flatten/-/arr-flatten-1.1.0.tgz",
+ "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
+ "dev": true
+ },
+ "array-slice": {
+ "version": "0.2.3",
+ "resolved": "https://npm.dev.mysns.pt/array-slice/-/array-slice-0.2.3.tgz",
+ "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=",
+ "dev": true
+ },
+ "array-unique": {
+ "version": "0.2.1",
+ "resolved": "https://npm.dev.mysns.pt/array-unique/-/array-unique-0.2.1.tgz",
+ "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=",
+ "dev": true
+ },
+ "arraybuffer.slice": {
+ "version": "0.0.6",
+ "resolved": "https://npm.dev.mysns.pt/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz",
+ "integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=",
+ "dev": true
+ },
+ "async-each": {
+ "version": "1.0.1",
+ "resolved": "https://npm.dev.mysns.pt/async-each/-/async-each-1.0.1.tgz",
+ "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=",
+ "dev": true
+ },
+ "babel-code-frame": {
+ "version": "6.22.0",
+ "resolved": "https://npm.dev.mysns.pt/babel-code-frame/-/babel-code-frame-6.22.0.tgz",
+ "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=",
+ "dev": true,
+ "requires": {
+ "chalk": "1.1.3",
+ "esutils": "2.0.2",
+ "js-tokens": "3.0.2"
+ }
+ },
+ "babel-messages": {
+ "version": "6.23.0",
+ "resolved": "https://npm.dev.mysns.pt/babel-messages/-/babel-messages-6.23.0.tgz",
+ "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.25.0"
+ }
+ },
+ "babel-runtime": {
+ "version": "6.25.0",
+ "resolved": "https://npm.dev.mysns.pt/babel-runtime/-/babel-runtime-6.25.0.tgz",
+ "integrity": "sha1-M7mOql1IK7AajRqmtDetKwGuxBw=",
+ "dev": true,
+ "requires": {
+ "core-js": "2.4.1",
+ "regenerator-runtime": "0.10.5"
+ }
+ },
+ "babel-traverse": {
+ "version": "6.12.0",
+ "resolved": "https://npm.dev.mysns.pt/babel-traverse/-/babel-traverse-6.12.0.tgz",
+ "integrity": "sha1-8i9U+g1u639jWFJGurbmN4WPXZQ=",
+ "dev": true,
+ "requires": {
+ "babel-code-frame": "6.22.0",
+ "babel-messages": "6.23.0",
+ "babel-runtime": "6.25.0",
+ "babel-types": "6.11.1",
+ "babylon": "6.8.4",
+ "debug": "2.6.8",
+ "globals": "8.18.0",
+ "invariant": "2.2.2",
+ "lodash": "4.17.4"
+ }
+ },
+ "babel-types": {
+ "version": "6.11.1",
+ "resolved": "https://npm.dev.mysns.pt/babel-types/-/babel-types-6.11.1.tgz",
+ "integrity": "sha1-o981W6uQ3c9mMYZAcXzywVTmZIo=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.25.0",
+ "babel-traverse": "6.12.0",
+ "esutils": "2.0.2",
+ "lodash": "4.17.4",
+ "to-fast-properties": "1.0.3"
+ }
+ },
+ "babylon": {
+ "version": "6.8.4",
+ "resolved": "https://npm.dev.mysns.pt/babylon/-/babylon-6.8.4.tgz",
+ "integrity": "sha1-CXMGuNq66VFZIlzymz6lWRIFMYA=",
+ "dev": true,
+ "requires": {
+ "babel-runtime": "6.25.0"
+ }
+ },
+ "backo2": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/backo2/-/backo2-1.0.2.tgz",
+ "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=",
+ "dev": true
+ },
+ "balanced-match": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/balanced-match/-/balanced-match-1.0.0.tgz",
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+ "dev": true
+ },
+ "base64-arraybuffer": {
+ "version": "0.1.5",
+ "resolved": "https://npm.dev.mysns.pt/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
+ "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=",
+ "dev": true
+ },
+ "base64id": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/base64id/-/base64id-1.0.0.tgz",
+ "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=",
+ "dev": true
+ },
+ "better-assert": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/better-assert/-/better-assert-1.0.2.tgz",
+ "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=",
+ "dev": true,
+ "requires": {
+ "callsite": "1.0.0"
+ }
+ },
+ "binary-extensions": {
+ "version": "1.9.0",
+ "resolved": "https://npm.dev.mysns.pt/binary-extensions/-/binary-extensions-1.9.0.tgz",
+ "integrity": "sha1-ZlBsFs5vTWkopbPNajPKQelB43s=",
+ "dev": true
+ },
+ "blob": {
+ "version": "0.0.4",
+ "resolved": "https://npm.dev.mysns.pt/blob/-/blob-0.0.4.tgz",
+ "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=",
+ "dev": true
+ },
+ "bluebird": {
+ "version": "3.5.0",
+ "resolved": "https://npm.dev.mysns.pt/bluebird/-/bluebird-3.5.0.tgz",
+ "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=",
+ "dev": true
+ },
+ "body-parser": {
+ "version": "1.17.2",
+ "resolved": "https://npm.dev.mysns.pt/body-parser/-/body-parser-1.17.2.tgz",
+ "integrity": "sha1-+IkqvI+eYn1Crtr7yma/WrmRBO4=",
+ "dev": true,
+ "requires": {
+ "bytes": "2.4.0",
+ "content-type": "1.0.2",
+ "debug": "2.6.7",
+ "depd": "1.1.1",
+ "http-errors": "1.6.1",
+ "iconv-lite": "0.4.15",
+ "on-finished": "2.3.0",
+ "qs": "6.4.0",
+ "raw-body": "2.2.0",
+ "type-is": "1.6.15"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.6.7",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.6.7.tgz",
+ "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=",
+ "dev": true,
+ "requires": {
+ "ms": "2.0.0"
+ }
+ }
+ }
+ },
+ "brace-expansion": {
+ "version": "1.1.8",
+ "resolved": "https://npm.dev.mysns.pt/brace-expansion/-/brace-expansion-1.1.8.tgz",
+ "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
+ "dev": true,
+ "requires": {
+ "balanced-match": "1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "braces": {
+ "version": "1.8.5",
+ "resolved": "https://npm.dev.mysns.pt/braces/-/braces-1.8.5.tgz",
+ "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=",
+ "dev": true,
+ "requires": {
+ "expand-range": "1.8.2",
+ "preserve": "0.2.0",
+ "repeat-element": "1.1.2"
+ }
+ },
+ "bytes": {
+ "version": "2.4.0",
+ "resolved": "https://npm.dev.mysns.pt/bytes/-/bytes-2.4.0.tgz",
+ "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=",
+ "dev": true
+ },
+ "callsite": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/callsite/-/callsite-1.0.0.tgz",
+ "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=",
+ "dev": true
+ },
+ "chalk": {
+ "version": "1.1.3",
+ "resolved": "https://npm.dev.mysns.pt/chalk/-/chalk-1.1.3.tgz",
+ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "2.2.1",
+ "escape-string-regexp": "1.0.5",
+ "has-ansi": "2.0.0",
+ "strip-ansi": "3.0.1",
+ "supports-color": "2.0.0"
+ }
+ },
+ "chokidar": {
+ "version": "1.7.0",
+ "resolved": "https://npm.dev.mysns.pt/chokidar/-/chokidar-1.7.0.tgz",
+ "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=",
+ "dev": true,
+ "requires": {
+ "anymatch": "1.3.2",
+ "async-each": "1.0.1",
+ "fsevents": "1.1.2",
+ "glob-parent": "2.0.0",
+ "inherits": "2.0.3",
+ "is-binary-path": "1.0.1",
+ "is-glob": "2.0.1",
+ "path-is-absolute": "1.0.1",
+ "readdirp": "2.1.0"
+ }
+ },
+ "colors": {
+ "version": "1.1.2",
+ "resolved": "https://npm.dev.mysns.pt/colors/-/colors-1.1.2.tgz",
+ "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=",
+ "dev": true
+ },
+ "combine-lists": {
+ "version": "1.0.1",
+ "resolved": "https://npm.dev.mysns.pt/combine-lists/-/combine-lists-1.0.1.tgz",
+ "integrity": "sha1-RYwH4J4NkA/Ci3Cj/sLazR0st/Y=",
+ "dev": true,
+ "requires": {
+ "lodash": "4.17.4"
+ }
+ },
+ "component-bind": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/component-bind/-/component-bind-1.0.0.tgz",
+ "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=",
+ "dev": true
+ },
+ "component-emitter": {
+ "version": "1.1.2",
+ "resolved": "https://npm.dev.mysns.pt/component-emitter/-/component-emitter-1.1.2.tgz",
+ "integrity": "sha1-KWWU8nU9qmOZbSrwjRWpURbJrsM=",
+ "dev": true
+ },
+ "component-inherit": {
+ "version": "0.0.3",
+ "resolved": "https://npm.dev.mysns.pt/component-inherit/-/component-inherit-0.0.3.tgz",
+ "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=",
+ "dev": true
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://npm.dev.mysns.pt/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+ "dev": true
+ },
+ "connect": {
+ "version": "3.6.2",
+ "resolved": "https://npm.dev.mysns.pt/connect/-/connect-3.6.2.tgz",
+ "integrity": "sha1-aU6NIGgb/kkCgsiriGvpjwn0L+c=",
+ "dev": true,
+ "requires": {
+ "debug": "2.6.7",
+ "finalhandler": "1.0.3",
+ "parseurl": "1.3.1",
+ "utils-merge": "1.0.0"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.6.7",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.6.7.tgz",
+ "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=",
+ "dev": true,
+ "requires": {
+ "ms": "2.0.0"
+ }
+ }
+ }
+ },
+ "content-type": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/content-type/-/content-type-1.0.2.tgz",
+ "integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0=",
+ "dev": true
+ },
+ "cookie": {
+ "version": "0.3.1",
+ "resolved": "https://npm.dev.mysns.pt/cookie/-/cookie-0.3.1.tgz",
+ "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=",
+ "dev": true
+ },
+ "core-js": {
+ "version": "2.4.1",
+ "resolved": "https://npm.dev.mysns.pt/core-js/-/core-js-2.4.1.tgz",
+ "integrity": "sha1-TekR5mew6ukSTjQlS1OupvxhjT4=",
+ "dev": true
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/core-util-is/-/core-util-is-1.0.2.tgz",
+ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
+ "dev": true
+ },
+ "custom-event": {
+ "version": "1.0.1",
+ "resolved": "https://npm.dev.mysns.pt/custom-event/-/custom-event-1.0.1.tgz",
+ "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=",
+ "dev": true
+ },
+ "debug": {
+ "version": "2.6.8",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.6.8.tgz",
+ "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
+ "dev": true,
+ "requires": {
+ "ms": "2.0.0"
+ }
+ },
+ "depd": {
+ "version": "1.1.1",
+ "resolved": "https://npm.dev.mysns.pt/depd/-/depd-1.1.1.tgz",
+ "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=",
+ "dev": true
+ },
+ "di": {
+ "version": "0.0.1",
+ "resolved": "https://npm.dev.mysns.pt/di/-/di-0.0.1.tgz",
+ "integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=",
+ "dev": true
+ },
+ "dom-serialize": {
+ "version": "2.2.1",
+ "resolved": "https://npm.dev.mysns.pt/dom-serialize/-/dom-serialize-2.2.1.tgz",
+ "integrity": "sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=",
+ "dev": true,
+ "requires": {
+ "custom-event": "1.0.1",
+ "ent": "2.2.0",
+ "extend": "3.0.1",
+ "void-elements": "2.0.1"
+ }
+ },
+ "ee-first": {
+ "version": "1.1.1",
+ "resolved": "https://npm.dev.mysns.pt/ee-first/-/ee-first-1.1.1.tgz",
+ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=",
+ "dev": true
+ },
+ "encodeurl": {
+ "version": "1.0.1",
+ "resolved": "https://npm.dev.mysns.pt/encodeurl/-/encodeurl-1.0.1.tgz",
+ "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=",
+ "dev": true
+ },
+ "engine.io": {
+ "version": "1.8.3",
+ "resolved": "https://npm.dev.mysns.pt/engine.io/-/engine.io-1.8.3.tgz",
+ "integrity": "sha1-jef5eJXSDTm4X4ju7nd7K9QrE9Q=",
+ "dev": true,
+ "requires": {
+ "accepts": "1.3.3",
+ "base64id": "1.0.0",
+ "cookie": "0.3.1",
+ "debug": "2.3.3",
+ "engine.io-parser": "1.3.2",
+ "ws": "1.1.2"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.3.3",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.3.3.tgz",
+ "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=",
+ "dev": true,
+ "requires": {
+ "ms": "0.7.2"
+ }
+ },
+ "ms": {
+ "version": "0.7.2",
+ "resolved": "https://npm.dev.mysns.pt/ms/-/ms-0.7.2.tgz",
+ "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=",
+ "dev": true
+ }
+ }
+ },
+ "engine.io-client": {
+ "version": "1.8.3",
+ "resolved": "https://npm.dev.mysns.pt/engine.io-client/-/engine.io-client-1.8.3.tgz",
+ "integrity": "sha1-F5jtk0USRkU9TG9jXXogH+lA1as=",
+ "dev": true,
+ "requires": {
+ "component-emitter": "1.2.1",
+ "component-inherit": "0.0.3",
+ "debug": "2.3.3",
+ "engine.io-parser": "1.3.2",
+ "has-cors": "1.1.0",
+ "indexof": "0.0.1",
+ "parsejson": "0.0.3",
+ "parseqs": "0.0.5",
+ "parseuri": "0.0.5",
+ "ws": "1.1.2",
+ "xmlhttprequest-ssl": "1.5.3",
+ "yeast": "0.1.2"
+ },
+ "dependencies": {
+ "component-emitter": {
+ "version": "1.2.1",
+ "resolved": "https://npm.dev.mysns.pt/component-emitter/-/component-emitter-1.2.1.tgz",
+ "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=",
+ "dev": true
+ },
+ "debug": {
+ "version": "2.3.3",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.3.3.tgz",
+ "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=",
+ "dev": true,
+ "requires": {
+ "ms": "0.7.2"
+ }
+ },
+ "ms": {
+ "version": "0.7.2",
+ "resolved": "https://npm.dev.mysns.pt/ms/-/ms-0.7.2.tgz",
+ "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=",
+ "dev": true
+ }
+ }
+ },
+ "engine.io-parser": {
+ "version": "1.3.2",
+ "resolved": "https://npm.dev.mysns.pt/engine.io-parser/-/engine.io-parser-1.3.2.tgz",
+ "integrity": "sha1-k3sHnwAH0Ik+xW1GyyILjLQ1Igo=",
+ "dev": true,
+ "requires": {
+ "after": "0.8.2",
+ "arraybuffer.slice": "0.0.6",
+ "base64-arraybuffer": "0.1.5",
+ "blob": "0.0.4",
+ "has-binary": "0.1.7",
+ "wtf-8": "1.0.0"
+ }
+ },
+ "ent": {
+ "version": "2.2.0",
+ "resolved": "https://npm.dev.mysns.pt/ent/-/ent-2.2.0.tgz",
+ "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=",
+ "dev": true
+ },
+ "escape-html": {
+ "version": "1.0.3",
+ "resolved": "https://npm.dev.mysns.pt/escape-html/-/escape-html-1.0.3.tgz",
+ "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=",
+ "dev": true
+ },
+ "escape-string-regexp": {
+ "version": "1.0.5",
+ "resolved": "https://npm.dev.mysns.pt/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
+ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
+ "dev": true
+ },
+ "esutils": {
+ "version": "2.0.2",
+ "resolved": "https://npm.dev.mysns.pt/esutils/-/esutils-2.0.2.tgz",
+ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
+ "dev": true
+ },
+ "eventemitter3": {
+ "version": "1.2.0",
+ "resolved": "https://npm.dev.mysns.pt/eventemitter3/-/eventemitter3-1.2.0.tgz",
+ "integrity": "sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg=",
+ "dev": true
+ },
+ "expand-braces": {
+ "version": "0.1.2",
+ "resolved": "https://npm.dev.mysns.pt/expand-braces/-/expand-braces-0.1.2.tgz",
+ "integrity": "sha1-SIsdHSRRyz06axks/AMPRMWFX+o=",
+ "dev": true,
+ "requires": {
+ "array-slice": "0.2.3",
+ "array-unique": "0.2.1",
+ "braces": "0.1.5"
+ },
+ "dependencies": {
+ "braces": {
+ "version": "0.1.5",
+ "resolved": "https://npm.dev.mysns.pt/braces/-/braces-0.1.5.tgz",
+ "integrity": "sha1-wIVxEIUpHYt1/ddOqw+FlygHEeY=",
+ "dev": true,
+ "requires": {
+ "expand-range": "0.1.1"
+ }
+ },
+ "expand-range": {
+ "version": "0.1.1",
+ "resolved": "https://npm.dev.mysns.pt/expand-range/-/expand-range-0.1.1.tgz",
+ "integrity": "sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ=",
+ "dev": true,
+ "requires": {
+ "is-number": "0.1.1",
+ "repeat-string": "0.2.2"
+ }
+ },
+ "is-number": {
+ "version": "0.1.1",
+ "resolved": "https://npm.dev.mysns.pt/is-number/-/is-number-0.1.1.tgz",
+ "integrity": "sha1-aaevEWlj1HIG7JvZtIoUIW8eOAY=",
+ "dev": true
+ },
+ "repeat-string": {
+ "version": "0.2.2",
+ "resolved": "https://npm.dev.mysns.pt/repeat-string/-/repeat-string-0.2.2.tgz",
+ "integrity": "sha1-x6jTI2BoNiBZp+RlH8aITosftK4=",
+ "dev": true
+ }
+ }
+ },
+ "expand-brackets": {
+ "version": "0.1.5",
+ "resolved": "https://npm.dev.mysns.pt/expand-brackets/-/expand-brackets-0.1.5.tgz",
+ "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=",
+ "dev": true,
+ "requires": {
+ "is-posix-bracket": "0.1.1"
+ }
+ },
+ "expand-range": {
+ "version": "1.8.2",
+ "resolved": "https://npm.dev.mysns.pt/expand-range/-/expand-range-1.8.2.tgz",
+ "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=",
+ "dev": true,
+ "requires": {
+ "fill-range": "2.2.3"
+ }
+ },
+ "extend": {
+ "version": "3.0.1",
+ "resolved": "https://npm.dev.mysns.pt/extend/-/extend-3.0.1.tgz",
+ "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=",
+ "dev": true
+ },
+ "extglob": {
+ "version": "0.3.2",
+ "resolved": "https://npm.dev.mysns.pt/extglob/-/extglob-0.3.2.tgz",
+ "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=",
+ "dev": true,
+ "requires": {
+ "is-extglob": "1.0.0"
+ }
+ },
+ "filename-regex": {
+ "version": "2.0.1",
+ "resolved": "https://npm.dev.mysns.pt/filename-regex/-/filename-regex-2.0.1.tgz",
+ "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=",
+ "dev": true
+ },
+ "filewalker": {
+ "version": "0.1.2",
+ "resolved": "https://npm.dev.mysns.pt/filewalker/-/filewalker-0.1.2.tgz",
+ "integrity": "sha1-IVvw6ycD1Pqt/FuKEE56pwpDMfE=",
+ "dev": true,
+ "requires": {
+ "fqueue": "0.0.0"
+ }
+ },
+ "fill-range": {
+ "version": "2.2.3",
+ "resolved": "https://npm.dev.mysns.pt/fill-range/-/fill-range-2.2.3.tgz",
+ "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=",
+ "dev": true,
+ "requires": {
+ "is-number": "2.1.0",
+ "isobject": "2.1.0",
+ "randomatic": "1.1.7",
+ "repeat-element": "1.1.2",
+ "repeat-string": "1.6.1"
+ }
+ },
+ "finalhandler": {
+ "version": "1.0.3",
+ "resolved": "https://npm.dev.mysns.pt/finalhandler/-/finalhandler-1.0.3.tgz",
+ "integrity": "sha1-70fneVDpmXgOhgIqVg4yF+DQzIk=",
+ "dev": true,
+ "requires": {
+ "debug": "2.6.7",
+ "encodeurl": "1.0.1",
+ "escape-html": "1.0.3",
+ "on-finished": "2.3.0",
+ "parseurl": "1.3.1",
+ "statuses": "1.3.1",
+ "unpipe": "1.0.0"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.6.7",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.6.7.tgz",
+ "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=",
+ "dev": true,
+ "requires": {
+ "ms": "2.0.0"
+ }
+ }
+ }
+ },
+ "for-in": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/for-in/-/for-in-1.0.2.tgz",
+ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=",
+ "dev": true
+ },
+ "for-own": {
+ "version": "0.1.5",
+ "resolved": "https://npm.dev.mysns.pt/for-own/-/for-own-0.1.5.tgz",
+ "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=",
+ "dev": true,
+ "requires": {
+ "for-in": "1.0.2"
+ }
+ },
+ "fqueue": {
+ "version": "0.0.0",
+ "resolved": "https://npm.dev.mysns.pt/fqueue/-/fqueue-0.0.0.tgz",
+ "integrity": "sha1-UzIFpPmtIbuqOPxhzvOpMML1SDY=",
+ "dev": true
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
+ "dev": true
+ },
+ "fsevents": {
+ "version": "1.1.2",
+ "resolved": "https://npm.dev.mysns.pt/fsevents/-/fsevents-1.1.2.tgz",
+ "integrity": "sha512-Sn44E5wQW4bTHXvQmvSHwqbuiXtduD6Rrjm2ZtUEGbyrig+nUH3t/QD4M4/ZXViY556TBpRgZkHLDx3JxPwxiw==",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "nan": "2.6.2",
+ "node-pre-gyp": "0.6.36"
+ },
+ "dependencies": {
+ "abbrev": {
+ "version": "1.1.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "ajv": {
+ "version": "4.11.8",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "co": "4.6.0",
+ "json-stable-stringify": "1.0.1"
+ }
+ },
+ "ansi-regex": {
+ "version": "2.1.1",
+ "bundled": true,
+ "dev": true
+ },
+ "aproba": {
+ "version": "1.1.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "are-we-there-yet": {
+ "version": "1.1.4",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "delegates": "1.0.0",
+ "readable-stream": "2.2.9"
+ }
+ },
+ "asn1": {
+ "version": "0.2.3",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "assert-plus": {
+ "version": "0.2.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "asynckit": {
+ "version": "0.4.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "aws-sign2": {
+ "version": "0.6.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "aws4": {
+ "version": "1.6.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "balanced-match": {
+ "version": "0.4.2",
+ "bundled": true,
+ "dev": true
+ },
+ "bcrypt-pbkdf": {
+ "version": "1.0.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "tweetnacl": "0.14.5"
+ }
+ },
+ "block-stream": {
+ "version": "0.0.9",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "inherits": "2.0.3"
+ }
+ },
+ "boom": {
+ "version": "2.10.1",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "hoek": "2.16.3"
+ }
+ },
+ "brace-expansion": {
+ "version": "1.1.7",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "balanced-match": "0.4.2",
+ "concat-map": "0.0.1"
+ }
+ },
+ "buffer-shims": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true
+ },
+ "caseless": {
+ "version": "0.12.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "co": {
+ "version": "4.6.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "code-point-at": {
+ "version": "1.1.0",
+ "bundled": true,
+ "dev": true
+ },
+ "combined-stream": {
+ "version": "1.0.5",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "delayed-stream": "1.0.0"
+ }
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "bundled": true,
+ "dev": true
+ },
+ "console-control-strings": {
+ "version": "1.1.0",
+ "bundled": true,
+ "dev": true
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "bundled": true,
+ "dev": true
+ },
+ "cryptiles": {
+ "version": "2.0.5",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "boom": "2.10.1"
+ }
+ },
+ "dashdash": {
+ "version": "1.14.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "assert-plus": "1.0.0"
+ },
+ "dependencies": {
+ "assert-plus": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "debug": {
+ "version": "2.6.8",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "ms": "2.0.0"
+ }
+ },
+ "deep-extend": {
+ "version": "0.4.2",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "delayed-stream": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true
+ },
+ "delegates": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "ecc-jsbn": {
+ "version": "0.1.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "jsbn": "0.1.1"
+ }
+ },
+ "extend": {
+ "version": "3.0.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "extsprintf": {
+ "version": "1.0.2",
+ "bundled": true,
+ "dev": true
+ },
+ "forever-agent": {
+ "version": "0.6.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "form-data": {
+ "version": "2.1.4",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "asynckit": "0.4.0",
+ "combined-stream": "1.0.5",
+ "mime-types": "2.1.15"
+ }
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true
+ },
+ "fstream": {
+ "version": "1.0.11",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "inherits": "2.0.3",
+ "mkdirp": "0.5.1",
+ "rimraf": "2.6.1"
+ }
+ },
+ "fstream-ignore": {
+ "version": "1.0.5",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "fstream": "1.0.11",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.4"
+ }
+ },
+ "gauge": {
+ "version": "2.7.4",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "aproba": "1.1.1",
+ "console-control-strings": "1.1.0",
+ "has-unicode": "2.0.1",
+ "object-assign": "4.1.1",
+ "signal-exit": "3.0.2",
+ "string-width": "1.0.2",
+ "strip-ansi": "3.0.1",
+ "wide-align": "1.1.2"
+ }
+ },
+ "getpass": {
+ "version": "0.1.7",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "assert-plus": "1.0.0"
+ },
+ "dependencies": {
+ "assert-plus": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "glob": {
+ "version": "7.1.2",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "fs.realpath": "1.0.0",
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.4",
+ "once": "1.4.0",
+ "path-is-absolute": "1.0.1"
+ }
+ },
+ "graceful-fs": {
+ "version": "4.1.11",
+ "bundled": true,
+ "dev": true
+ },
+ "har-schema": {
+ "version": "1.0.5",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "har-validator": {
+ "version": "4.2.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "ajv": "4.11.8",
+ "har-schema": "1.0.5"
+ }
+ },
+ "has-unicode": {
+ "version": "2.0.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "hawk": {
+ "version": "3.1.3",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "boom": "2.10.1",
+ "cryptiles": "2.0.5",
+ "hoek": "2.16.3",
+ "sntp": "1.0.9"
+ }
+ },
+ "hoek": {
+ "version": "2.16.3",
+ "bundled": true,
+ "dev": true
+ },
+ "http-signature": {
+ "version": "1.1.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "assert-plus": "0.2.0",
+ "jsprim": "1.4.0",
+ "sshpk": "1.13.0"
+ }
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "once": "1.4.0",
+ "wrappy": "1.0.2"
+ }
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "bundled": true,
+ "dev": true
+ },
+ "ini": {
+ "version": "1.3.4",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "is-fullwidth-code-point": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "number-is-nan": "1.0.1"
+ }
+ },
+ "is-typedarray": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true
+ },
+ "isstream": {
+ "version": "0.1.2",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "jodid25519": {
+ "version": "1.0.2",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "jsbn": "0.1.1"
+ }
+ },
+ "jsbn": {
+ "version": "0.1.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "json-schema": {
+ "version": "0.2.3",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "json-stable-stringify": {
+ "version": "1.0.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "jsonify": "0.0.0"
+ }
+ },
+ "json-stringify-safe": {
+ "version": "5.0.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "jsonify": {
+ "version": "0.0.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "jsprim": {
+ "version": "1.4.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "assert-plus": "1.0.0",
+ "extsprintf": "1.0.2",
+ "json-schema": "0.2.3",
+ "verror": "1.3.6"
+ },
+ "dependencies": {
+ "assert-plus": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "mime-db": {
+ "version": "1.27.0",
+ "bundled": true,
+ "dev": true
+ },
+ "mime-types": {
+ "version": "2.1.15",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "mime-db": "1.27.0"
+ }
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "brace-expansion": "1.1.7"
+ }
+ },
+ "minimist": {
+ "version": "0.0.8",
+ "bundled": true,
+ "dev": true
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "minimist": "0.0.8"
+ }
+ },
+ "ms": {
+ "version": "2.0.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "node-pre-gyp": {
+ "version": "0.6.36",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "mkdirp": "0.5.1",
+ "nopt": "4.0.1",
+ "npmlog": "4.1.0",
+ "rc": "1.2.1",
+ "request": "2.81.0",
+ "rimraf": "2.6.1",
+ "semver": "5.3.0",
+ "tar": "2.2.1",
+ "tar-pack": "3.4.0"
+ }
+ },
+ "nopt": {
+ "version": "4.0.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "abbrev": "1.1.0",
+ "osenv": "0.1.4"
+ }
+ },
+ "npmlog": {
+ "version": "4.1.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "are-we-there-yet": "1.1.4",
+ "console-control-strings": "1.1.0",
+ "gauge": "2.7.4",
+ "set-blocking": "2.0.0"
+ }
+ },
+ "number-is-nan": {
+ "version": "1.0.1",
+ "bundled": true,
+ "dev": true
+ },
+ "oauth-sign": {
+ "version": "0.8.2",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "object-assign": {
+ "version": "4.1.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "once": {
+ "version": "1.4.0",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ },
+ "os-homedir": {
+ "version": "1.0.2",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "os-tmpdir": {
+ "version": "1.0.2",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "osenv": {
+ "version": "0.1.4",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "os-homedir": "1.0.2",
+ "os-tmpdir": "1.0.2"
+ }
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "bundled": true,
+ "dev": true
+ },
+ "performance-now": {
+ "version": "0.2.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "process-nextick-args": {
+ "version": "1.0.7",
+ "bundled": true,
+ "dev": true
+ },
+ "punycode": {
+ "version": "1.4.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "qs": {
+ "version": "6.4.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "rc": {
+ "version": "1.2.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "deep-extend": "0.4.2",
+ "ini": "1.3.4",
+ "minimist": "1.2.0",
+ "strip-json-comments": "2.0.1"
+ },
+ "dependencies": {
+ "minimist": {
+ "version": "1.2.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "readable-stream": {
+ "version": "2.2.9",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "buffer-shims": "1.0.0",
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "1.0.0",
+ "process-nextick-args": "1.0.7",
+ "string_decoder": "1.0.1",
+ "util-deprecate": "1.0.2"
+ }
+ },
+ "request": {
+ "version": "2.81.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "aws-sign2": "0.6.0",
+ "aws4": "1.6.0",
+ "caseless": "0.12.0",
+ "combined-stream": "1.0.5",
+ "extend": "3.0.1",
+ "forever-agent": "0.6.1",
+ "form-data": "2.1.4",
+ "har-validator": "4.2.1",
+ "hawk": "3.1.3",
+ "http-signature": "1.1.1",
+ "is-typedarray": "1.0.0",
+ "isstream": "0.1.2",
+ "json-stringify-safe": "5.0.1",
+ "mime-types": "2.1.15",
+ "oauth-sign": "0.8.2",
+ "performance-now": "0.2.0",
+ "qs": "6.4.0",
+ "safe-buffer": "5.0.1",
+ "stringstream": "0.0.5",
+ "tough-cookie": "2.3.2",
+ "tunnel-agent": "0.6.0",
+ "uuid": "3.0.1"
+ }
+ },
+ "rimraf": {
+ "version": "2.6.1",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "glob": "7.1.2"
+ }
+ },
+ "safe-buffer": {
+ "version": "5.0.1",
+ "bundled": true,
+ "dev": true
+ },
+ "semver": {
+ "version": "5.3.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "set-blocking": {
+ "version": "2.0.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "signal-exit": {
+ "version": "3.0.2",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "sntp": {
+ "version": "1.0.9",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "hoek": "2.16.3"
+ }
+ },
+ "sshpk": {
+ "version": "1.13.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "asn1": "0.2.3",
+ "assert-plus": "1.0.0",
+ "bcrypt-pbkdf": "1.0.1",
+ "dashdash": "1.14.1",
+ "ecc-jsbn": "0.1.1",
+ "getpass": "0.1.7",
+ "jodid25519": "1.0.2",
+ "jsbn": "0.1.1",
+ "tweetnacl": "0.14.5"
+ },
+ "dependencies": {
+ "assert-plus": {
+ "version": "1.0.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ }
+ }
+ },
+ "string_decoder": {
+ "version": "1.0.1",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "safe-buffer": "5.0.1"
+ }
+ },
+ "string-width": {
+ "version": "1.0.2",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "code-point-at": "1.1.0",
+ "is-fullwidth-code-point": "1.0.0",
+ "strip-ansi": "3.0.1"
+ }
+ },
+ "stringstream": {
+ "version": "0.0.5",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "strip-json-comments": {
+ "version": "2.0.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "tar": {
+ "version": "2.2.1",
+ "bundled": true,
+ "dev": true,
+ "requires": {
+ "block-stream": "0.0.9",
+ "fstream": "1.0.11",
+ "inherits": "2.0.3"
+ }
+ },
+ "tar-pack": {
+ "version": "3.4.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "debug": "2.6.8",
+ "fstream": "1.0.11",
+ "fstream-ignore": "1.0.5",
+ "once": "1.4.0",
+ "readable-stream": "2.2.9",
+ "rimraf": "2.6.1",
+ "tar": "2.2.1",
+ "uid-number": "0.0.6"
+ }
+ },
+ "tough-cookie": {
+ "version": "2.3.2",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "punycode": "1.4.1"
+ }
+ },
+ "tunnel-agent": {
+ "version": "0.6.0",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "safe-buffer": "5.0.1"
+ }
+ },
+ "tweetnacl": {
+ "version": "0.14.5",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "uid-number": {
+ "version": "0.0.6",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "bundled": true,
+ "dev": true
+ },
+ "uuid": {
+ "version": "3.0.1",
+ "bundled": true,
+ "dev": true,
+ "optional": true
+ },
+ "verror": {
+ "version": "1.3.6",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "extsprintf": "1.0.2"
+ }
+ },
+ "wide-align": {
+ "version": "1.1.2",
+ "bundled": true,
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "string-width": "1.0.2"
+ }
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "bundled": true,
+ "dev": true
+ }
+ }
+ },
+ "glob": {
+ "version": "7.1.2",
+ "resolved": "https://npm.dev.mysns.pt/glob/-/glob-7.1.2.tgz",
+ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
+ "dev": true,
+ "requires": {
+ "fs.realpath": "1.0.0",
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.4",
+ "once": "1.4.0",
+ "path-is-absolute": "1.0.1"
+ }
+ },
+ "glob-base": {
+ "version": "0.3.0",
+ "resolved": "https://npm.dev.mysns.pt/glob-base/-/glob-base-0.3.0.tgz",
+ "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=",
+ "dev": true,
+ "requires": {
+ "glob-parent": "2.0.0",
+ "is-glob": "2.0.1"
+ }
+ },
+ "glob-parent": {
+ "version": "2.0.0",
+ "resolved": "https://npm.dev.mysns.pt/glob-parent/-/glob-parent-2.0.0.tgz",
+ "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=",
+ "dev": true,
+ "requires": {
+ "is-glob": "2.0.1"
+ }
+ },
+ "globals": {
+ "version": "8.18.0",
+ "resolved": "https://npm.dev.mysns.pt/globals/-/globals-8.18.0.tgz",
+ "integrity": "sha1-k9SmK9ysOM+vr8R9awNHaMsP/LQ=",
+ "dev": true
+ },
+ "graceful-fs": {
+ "version": "4.1.11",
+ "resolved": "https://npm.dev.mysns.pt/graceful-fs/-/graceful-fs-4.1.11.tgz",
+ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
+ "dev": true
+ },
+ "has-ansi": {
+ "version": "2.0.0",
+ "resolved": "https://npm.dev.mysns.pt/has-ansi/-/has-ansi-2.0.0.tgz",
+ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "has-binary": {
+ "version": "0.1.7",
+ "resolved": "https://npm.dev.mysns.pt/has-binary/-/has-binary-0.1.7.tgz",
+ "integrity": "sha1-aOYesWIQyVRaClzOBqhzkS/h5ow=",
+ "dev": true,
+ "requires": {
+ "isarray": "0.0.1"
+ },
+ "dependencies": {
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://npm.dev.mysns.pt/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
+ "dev": true
+ }
+ }
+ },
+ "has-cors": {
+ "version": "1.1.0",
+ "resolved": "https://npm.dev.mysns.pt/has-cors/-/has-cors-1.1.0.tgz",
+ "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=",
+ "dev": true
+ },
+ "http-errors": {
+ "version": "1.6.1",
+ "resolved": "https://npm.dev.mysns.pt/http-errors/-/http-errors-1.6.1.tgz",
+ "integrity": "sha1-X4uO2YrKVFZWv1cplzh/kEpyIlc=",
+ "dev": true,
+ "requires": {
+ "depd": "1.1.0",
+ "inherits": "2.0.3",
+ "setprototypeof": "1.0.3",
+ "statuses": "1.3.1"
+ },
+ "dependencies": {
+ "depd": {
+ "version": "1.1.0",
+ "resolved": "https://npm.dev.mysns.pt/depd/-/depd-1.1.0.tgz",
+ "integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=",
+ "dev": true
+ }
+ }
+ },
+ "http-proxy": {
+ "version": "1.16.2",
+ "resolved": "https://npm.dev.mysns.pt/http-proxy/-/http-proxy-1.16.2.tgz",
+ "integrity": "sha1-Bt/ykpUr9k2+hHH6nfcwZtTzd0I=",
+ "dev": true,
+ "requires": {
+ "eventemitter3": "1.2.0",
+ "requires-port": "1.0.0"
+ }
+ },
+ "iconv-lite": {
+ "version": "0.4.15",
+ "resolved": "https://npm.dev.mysns.pt/iconv-lite/-/iconv-lite-0.4.15.tgz",
+ "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=",
+ "dev": true
+ },
+ "indexof": {
+ "version": "0.0.1",
+ "resolved": "https://npm.dev.mysns.pt/indexof/-/indexof-0.0.1.tgz",
+ "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
+ "dev": true
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "resolved": "https://npm.dev.mysns.pt/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+ "dev": true,
+ "requires": {
+ "once": "1.4.0",
+ "wrappy": "1.0.2"
+ }
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "resolved": "https://npm.dev.mysns.pt/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
+ "dev": true
+ },
+ "invariant": {
+ "version": "2.2.2",
+ "resolved": "https://npm.dev.mysns.pt/invariant/-/invariant-2.2.2.tgz",
+ "integrity": "sha1-nh9WrArNtr8wMwbzOL47IErmA2A=",
+ "dev": true,
+ "requires": {
+ "loose-envify": "1.3.1"
+ }
+ },
+ "is-binary-path": {
+ "version": "1.0.1",
+ "resolved": "https://npm.dev.mysns.pt/is-binary-path/-/is-binary-path-1.0.1.tgz",
+ "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=",
+ "dev": true,
+ "requires": {
+ "binary-extensions": "1.9.0"
+ }
+ },
+ "is-buffer": {
+ "version": "1.1.5",
+ "resolved": "https://npm.dev.mysns.pt/is-buffer/-/is-buffer-1.1.5.tgz",
+ "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=",
+ "dev": true
+ },
+ "is-dotfile": {
+ "version": "1.0.3",
+ "resolved": "https://npm.dev.mysns.pt/is-dotfile/-/is-dotfile-1.0.3.tgz",
+ "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=",
+ "dev": true
+ },
+ "is-equal-shallow": {
+ "version": "0.1.3",
+ "resolved": "https://npm.dev.mysns.pt/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz",
+ "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=",
+ "dev": true,
+ "requires": {
+ "is-primitive": "2.0.0"
+ }
+ },
+ "is-extendable": {
+ "version": "0.1.1",
+ "resolved": "https://npm.dev.mysns.pt/is-extendable/-/is-extendable-0.1.1.tgz",
+ "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=",
+ "dev": true
+ },
+ "is-extglob": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/is-extglob/-/is-extglob-1.0.0.tgz",
+ "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=",
+ "dev": true
+ },
+ "is-glob": {
+ "version": "2.0.1",
+ "resolved": "https://npm.dev.mysns.pt/is-glob/-/is-glob-2.0.1.tgz",
+ "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
+ "dev": true,
+ "requires": {
+ "is-extglob": "1.0.0"
+ }
+ },
+ "is-number": {
+ "version": "2.1.0",
+ "resolved": "https://npm.dev.mysns.pt/is-number/-/is-number-2.1.0.tgz",
+ "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=",
+ "dev": true,
+ "requires": {
+ "kind-of": "3.2.2"
+ }
+ },
+ "is-posix-bracket": {
+ "version": "0.1.1",
+ "resolved": "https://npm.dev.mysns.pt/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz",
+ "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=",
+ "dev": true
+ },
+ "is-primitive": {
+ "version": "2.0.0",
+ "resolved": "https://npm.dev.mysns.pt/is-primitive/-/is-primitive-2.0.0.tgz",
+ "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=",
+ "dev": true
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/isarray/-/isarray-1.0.0.tgz",
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
+ "dev": true
+ },
+ "isbinaryfile": {
+ "version": "3.0.2",
+ "resolved": "https://npm.dev.mysns.pt/isbinaryfile/-/isbinaryfile-3.0.2.tgz",
+ "integrity": "sha1-Sj6XTsDLqQBNP8bN5yCeppNopiE=",
+ "dev": true
+ },
+ "isobject": {
+ "version": "2.1.0",
+ "resolved": "https://npm.dev.mysns.pt/isobject/-/isobject-2.1.0.tgz",
+ "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=",
+ "dev": true,
+ "requires": {
+ "isarray": "1.0.0"
+ }
+ },
+ "jasmine-core": {
+ "version": "2.7.0",
+ "resolved": "https://npm.dev.mysns.pt/jasmine-core/-/jasmine-core-2.7.0.tgz",
+ "integrity": "sha1-UP+MT5LY71wLLBuEbdJj7YUVIJE=",
+ "dev": true
+ },
+ "js-tokens": {
+ "version": "3.0.2",
+ "resolved": "https://npm.dev.mysns.pt/js-tokens/-/js-tokens-3.0.2.tgz",
+ "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=",
+ "dev": true
+ },
+ "json3": {
+ "version": "3.3.2",
+ "resolved": "https://npm.dev.mysns.pt/json3/-/json3-3.3.2.tgz",
+ "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=",
+ "dev": true
+ },
+ "karma": {
+ "version": "1.7.0",
+ "resolved": "https://npm.dev.mysns.pt/karma/-/karma-1.7.0.tgz",
+ "integrity": "sha1-b3oaQGRG+i4YfslTmGmPTO5HYmk=",
+ "dev": true,
+ "requires": {
+ "bluebird": "3.5.0",
+ "body-parser": "1.17.2",
+ "chokidar": "1.7.0",
+ "colors": "1.1.2",
+ "combine-lists": "1.0.1",
+ "connect": "3.6.2",
+ "core-js": "2.4.1",
+ "di": "0.0.1",
+ "dom-serialize": "2.2.1",
+ "expand-braces": "0.1.2",
+ "glob": "7.1.2",
+ "graceful-fs": "4.1.11",
+ "http-proxy": "1.16.2",
+ "isbinaryfile": "3.0.2",
+ "lodash": "3.10.1",
+ "log4js": "0.6.38",
+ "mime": "1.3.6",
+ "minimatch": "3.0.4",
+ "optimist": "0.6.1",
+ "qjobs": "1.1.5",
+ "range-parser": "1.2.0",
+ "rimraf": "2.6.1",
+ "safe-buffer": "5.1.1",
+ "socket.io": "1.7.3",
+ "source-map": "0.5.6",
+ "tmp": "0.0.31",
+ "useragent": "2.2.1"
+ },
+ "dependencies": {
+ "lodash": {
+ "version": "3.10.1",
+ "resolved": "https://npm.dev.mysns.pt/lodash/-/lodash-3.10.1.tgz",
+ "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=",
+ "dev": true
+ }
+ }
+ },
+ "karma-jasmine": {
+ "version": "1.1.0",
+ "resolved": "https://npm.dev.mysns.pt/karma-jasmine/-/karma-jasmine-1.1.0.tgz",
+ "integrity": "sha1-IuTAa/mhguUpTR9wXjczgRuBCs8=",
+ "dev": true
+ },
+ "karma-nativescript-launcher": {
+ "version": "0.4.0",
+ "resolved": "https://npm.dev.mysns.pt/karma-nativescript-launcher/-/karma-nativescript-launcher-0.4.0.tgz",
+ "integrity": "sha1-RBi4sGxu1kh1a5NPDstrI3uKhd4=",
+ "dev": true,
+ "requires": {
+ "shelljs": "0.5.3"
+ }
+ },
+ "kind-of": {
+ "version": "3.2.2",
+ "resolved": "https://npm.dev.mysns.pt/kind-of/-/kind-of-3.2.2.tgz",
+ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
+ "dev": true,
+ "requires": {
+ "is-buffer": "1.1.5"
+ }
+ },
+ "lazy": {
+ "version": "1.0.11",
+ "resolved": "https://npm.dev.mysns.pt/lazy/-/lazy-1.0.11.tgz",
+ "integrity": "sha1-2qBoIGKCVCwIgojpdcKXwa53tpA=",
+ "dev": true
+ },
+ "lodash": {
+ "version": "4.17.4",
+ "resolved": "https://npm.dev.mysns.pt/lodash/-/lodash-4.17.4.tgz",
+ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=",
+ "dev": true
+ },
+ "log4js": {
+ "version": "0.6.38",
+ "resolved": "https://npm.dev.mysns.pt/log4js/-/log4js-0.6.38.tgz",
+ "integrity": "sha1-LElBFmldb7JUgJQ9P8hy5mKlIv0=",
+ "dev": true,
+ "requires": {
+ "readable-stream": "1.0.34",
+ "semver": "4.3.6"
+ },
+ "dependencies": {
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://npm.dev.mysns.pt/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
+ "dev": true
+ },
+ "readable-stream": {
+ "version": "1.0.34",
+ "resolved": "https://npm.dev.mysns.pt/readable-stream/-/readable-stream-1.0.34.tgz",
+ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
+ "dev": true,
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "0.0.1",
+ "string_decoder": "0.10.31"
+ }
+ },
+ "string_decoder": {
+ "version": "0.10.31",
+ "resolved": "https://npm.dev.mysns.pt/string_decoder/-/string_decoder-0.10.31.tgz",
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
+ "dev": true
+ }
+ }
+ },
+ "loose-envify": {
+ "version": "1.3.1",
+ "resolved": "https://npm.dev.mysns.pt/loose-envify/-/loose-envify-1.3.1.tgz",
+ "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=",
+ "dev": true,
+ "requires": {
+ "js-tokens": "3.0.2"
+ }
+ },
+ "lru-cache": {
+ "version": "2.2.4",
+ "resolved": "https://npm.dev.mysns.pt/lru-cache/-/lru-cache-2.2.4.tgz",
+ "integrity": "sha1-bGWGGb7PFAMdDQtZSxYELOTcBj0=",
+ "dev": true
+ },
+ "media-typer": {
+ "version": "0.3.0",
+ "resolved": "https://npm.dev.mysns.pt/media-typer/-/media-typer-0.3.0.tgz",
+ "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
+ "dev": true
+ },
+ "micromatch": {
+ "version": "2.3.11",
+ "resolved": "https://npm.dev.mysns.pt/micromatch/-/micromatch-2.3.11.tgz",
+ "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=",
+ "dev": true,
+ "requires": {
+ "arr-diff": "2.0.0",
+ "array-unique": "0.2.1",
+ "braces": "1.8.5",
+ "expand-brackets": "0.1.5",
+ "extglob": "0.3.2",
+ "filename-regex": "2.0.1",
+ "is-extglob": "1.0.0",
+ "is-glob": "2.0.1",
+ "kind-of": "3.2.2",
+ "normalize-path": "2.1.1",
+ "object.omit": "2.0.1",
+ "parse-glob": "3.0.4",
+ "regex-cache": "0.4.3"
+ }
+ },
+ "mime": {
+ "version": "1.3.6",
+ "resolved": "https://npm.dev.mysns.pt/mime/-/mime-1.3.6.tgz",
+ "integrity": "sha1-WR2E02U6awtKO5343lqoEI5y5eA=",
+ "dev": true
+ },
+ "mime-db": {
+ "version": "1.29.0",
+ "resolved": "https://npm.dev.mysns.pt/mime-db/-/mime-db-1.29.0.tgz",
+ "integrity": "sha1-SNJtI1WJZRcErFkWygYAGRQmaHg=",
+ "dev": true
+ },
+ "mime-types": {
+ "version": "2.1.16",
+ "resolved": "https://npm.dev.mysns.pt/mime-types/-/mime-types-2.1.16.tgz",
+ "integrity": "sha1-K4WKUuXs1RbbiXrCvodIeDBpjiM=",
+ "dev": true,
+ "requires": {
+ "mime-db": "1.29.0"
+ }
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "resolved": "https://npm.dev.mysns.pt/minimatch/-/minimatch-3.0.4.tgz",
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "1.1.8"
+ }
+ },
+ "minimist": {
+ "version": "0.0.10",
+ "resolved": "https://npm.dev.mysns.pt/minimist/-/minimist-0.0.10.tgz",
+ "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=",
+ "dev": true
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "resolved": "https://npm.dev.mysns.pt/mkdirp/-/mkdirp-0.5.1.tgz",
+ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "dev": true,
+ "requires": {
+ "minimist": "0.0.8"
+ },
+ "dependencies": {
+ "minimist": {
+ "version": "0.0.8",
+ "resolved": "https://npm.dev.mysns.pt/minimist/-/minimist-0.0.8.tgz",
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
+ "dev": true
+ }
+ }
+ },
+ "ms": {
+ "version": "2.0.0",
+ "resolved": "https://npm.dev.mysns.pt/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
+ "dev": true
+ },
+ "nan": {
+ "version": "2.6.2",
+ "resolved": "https://npm.dev.mysns.pt/nan/-/nan-2.6.2.tgz",
+ "integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U=",
+ "dev": true,
+ "optional": true
+ },
+ "nativescript-crypto": {
+ "version": "file:../src",
+ "dependencies": {
+ "ansi-regex": {
+ "version": "2.1.1",
+ "bundled": true
+ },
+ "ansi-styles": {
+ "version": "2.2.1",
+ "bundled": true
+ },
+ "async": {
+ "version": "0.9.2",
+ "bundled": true
+ },
+ "babel-code-frame": {
+ "version": "6.22.0",
+ "bundled": true,
+ "requires": {
+ "chalk": "1.1.3",
+ "esutils": "2.0.2",
+ "js-tokens": "3.0.1"
+ }
+ },
+ "balanced-match": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "brace-expansion": {
+ "version": "1.1.8",
+ "bundled": true,
+ "requires": {
+ "balanced-match": "1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "chalk": {
+ "version": "1.1.3",
+ "bundled": true,
+ "requires": {
+ "ansi-styles": "2.2.1",
+ "escape-string-regexp": "1.0.5",
+ "has-ansi": "2.0.0",
+ "strip-ansi": "3.0.1",
+ "supports-color": "2.0.0"
+ }
+ },
+ "colors": {
+ "version": "1.1.2",
+ "bundled": true
+ },
+ "commander": {
+ "version": "2.9.0",
+ "bundled": true,
+ "requires": {
+ "graceful-readlink": "1.0.1"
+ }
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "bundled": true
+ },
+ "cycle": {
+ "version": "1.0.3",
+ "bundled": true
+ },
+ "deep-equal": {
+ "version": "0.2.2",
+ "bundled": true
+ },
+ "diff": {
+ "version": "3.2.0",
+ "bundled": true
+ },
+ "escape-string-regexp": {
+ "version": "1.0.5",
+ "bundled": true
+ },
+ "esutils": {
+ "version": "2.0.2",
+ "bundled": true
+ },
+ "eyes": {
+ "version": "0.1.8",
+ "bundled": true
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "glob": {
+ "version": "7.1.2",
+ "bundled": true,
+ "requires": {
+ "fs.realpath": "1.0.0",
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.4",
+ "once": "1.4.0",
+ "path-is-absolute": "1.0.1"
+ }
+ },
+ "graceful-readlink": {
+ "version": "1.0.1",
+ "bundled": true
+ },
+ "has-ansi": {
+ "version": "2.0.0",
+ "bundled": true,
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "i": {
+ "version": "0.3.5",
+ "bundled": true
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "bundled": true,
+ "requires": {
+ "once": "1.4.0",
+ "wrappy": "1.0.2"
+ }
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "bundled": true
+ },
+ "isstream": {
+ "version": "0.1.2",
+ "bundled": true
+ },
+ "js-tokens": {
+ "version": "3.0.1",
+ "bundled": true
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "bundled": true,
+ "requires": {
+ "brace-expansion": "1.1.8"
+ }
+ },
+ "minimist": {
+ "version": "0.0.8",
+ "bundled": true
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "bundled": true,
+ "requires": {
+ "minimist": "0.0.8"
+ }
+ },
+ "mute-stream": {
+ "version": "0.0.7",
+ "bundled": true
+ },
+ "ncp": {
+ "version": "1.0.1",
+ "bundled": true
+ },
+ "once": {
+ "version": "1.4.0",
+ "bundled": true,
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "bundled": true
+ },
+ "path-parse": {
+ "version": "1.0.5",
+ "bundled": true
+ },
+ "pkginfo": {
+ "version": "0.4.0",
+ "bundled": true
+ },
+ "prompt": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "colors": "1.1.2",
+ "pkginfo": "0.4.0",
+ "read": "1.0.7",
+ "revalidator": "0.1.8",
+ "utile": "0.3.0",
+ "winston": "2.1.1"
+ }
+ },
+ "read": {
+ "version": "1.0.7",
+ "bundled": true,
+ "requires": {
+ "mute-stream": "0.0.7"
+ }
+ },
+ "resolve": {
+ "version": "1.3.3",
+ "bundled": true,
+ "requires": {
+ "path-parse": "1.0.5"
+ }
+ },
+ "revalidator": {
+ "version": "0.1.8",
+ "bundled": true
+ },
+ "rimraf": {
+ "version": "2.6.1",
+ "bundled": true,
+ "requires": {
+ "glob": "7.1.2"
+ }
+ },
+ "semver": {
+ "version": "5.3.0",
+ "bundled": true
+ },
+ "stack-trace": {
+ "version": "0.0.10",
+ "bundled": true
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "bundled": true,
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "supports-color": {
+ "version": "2.0.0",
+ "bundled": true
+ },
+ "tns-core-modules": {
+ "version": "3.0.1",
+ "bundled": true,
+ "requires": {
+ "tns-core-modules-widgets": "3.0.1"
+ }
+ },
+ "tns-core-modules-widgets": {
+ "version": "3.0.1",
+ "bundled": true
+ },
+ "tns-platform-declarations": {
+ "version": "3.0.1",
+ "bundled": true
+ },
+ "tslib": {
+ "version": "1.7.1",
+ "bundled": true
+ },
+ "tslint": {
+ "version": "5.4.3",
+ "bundled": true,
+ "requires": {
+ "babel-code-frame": "6.22.0",
+ "colors": "1.1.2",
+ "commander": "2.9.0",
+ "diff": "3.2.0",
+ "glob": "7.1.2",
+ "minimatch": "3.0.4",
+ "resolve": "1.3.3",
+ "semver": "5.3.0",
+ "tslib": "1.7.1",
+ "tsutils": "2.4.0"
+ }
+ },
+ "tsutils": {
+ "version": "2.4.0",
+ "bundled": true
+ },
+ "typescript": {
+ "version": "2.3.4",
+ "bundled": true
+ },
+ "utile": {
+ "version": "0.3.0",
+ "bundled": true,
+ "requires": {
+ "async": "0.9.2",
+ "deep-equal": "0.2.2",
+ "i": "0.3.5",
+ "mkdirp": "0.5.1",
+ "ncp": "1.0.1",
+ "rimraf": "2.6.1"
+ }
+ },
+ "winston": {
+ "version": "2.1.1",
+ "bundled": true,
+ "requires": {
+ "async": "1.0.0",
+ "colors": "1.0.3",
+ "cycle": "1.0.3",
+ "eyes": "0.1.8",
+ "isstream": "0.1.2",
+ "pkginfo": "0.3.1",
+ "stack-trace": "0.0.10"
+ },
+ "dependencies": {
+ "async": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "colors": {
+ "version": "1.0.3",
+ "bundled": true
+ },
+ "pkginfo": {
+ "version": "0.3.1",
+ "bundled": true
+ }
+ }
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "bundled": true
+ }
+ }
+ },
+ "nativescript-dev-typescript": {
+ "version": "0.5.0",
+ "resolved": "https://npm.dev.mysns.pt/nativescript-dev-typescript/-/nativescript-dev-typescript-0.5.0.tgz",
+ "integrity": "sha1-EqOcRRN6Wh8/qxIhYZldinrOECU=",
+ "dev": true,
+ "requires": {
+ "nativescript-hook": "0.2.1"
+ }
+ },
+ "nativescript-hook": {
+ "version": "0.2.1",
+ "resolved": "https://npm.dev.mysns.pt/nativescript-hook/-/nativescript-hook-0.2.1.tgz",
+ "integrity": "sha1-eGIlBW2yD6SeeGRR3M1ktS44ZNk=",
+ "dev": true,
+ "requires": {
+ "glob": "6.0.4",
+ "mkdirp": "0.5.1"
+ },
+ "dependencies": {
+ "glob": {
+ "version": "6.0.4",
+ "resolved": "https://npm.dev.mysns.pt/glob/-/glob-6.0.4.tgz",
+ "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=",
+ "dev": true,
+ "requires": {
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.4",
+ "once": "1.4.0",
+ "path-is-absolute": "1.0.1"
+ }
+ }
+ }
+ },
+ "nativescript-theme-core": {
+ "version": "1.0.4",
+ "resolved": "https://npm.dev.mysns.pt/nativescript-theme-core/-/nativescript-theme-core-1.0.4.tgz",
+ "integrity": "sha1-zyiAx/vy/l9D4iNdMJdQeQgD7+E="
+ },
+ "nativescript-unit-test-runner": {
+ "version": "0.3.4",
+ "resolved": "https://npm.dev.mysns.pt/nativescript-unit-test-runner/-/nativescript-unit-test-runner-0.3.4.tgz",
+ "integrity": "sha1-9t5SPUcyNlWcoOQgLRLVIXmNaBE="
+ },
+ "negotiator": {
+ "version": "0.6.1",
+ "resolved": "https://npm.dev.mysns.pt/negotiator/-/negotiator-0.6.1.tgz",
+ "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=",
+ "dev": true
+ },
+ "normalize-path": {
+ "version": "2.1.1",
+ "resolved": "https://npm.dev.mysns.pt/normalize-path/-/normalize-path-2.1.1.tgz",
+ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
+ "dev": true,
+ "requires": {
+ "remove-trailing-separator": "1.0.2"
+ }
+ },
+ "object-assign": {
+ "version": "4.1.0",
+ "resolved": "https://npm.dev.mysns.pt/object-assign/-/object-assign-4.1.0.tgz",
+ "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A=",
+ "dev": true
+ },
+ "object-component": {
+ "version": "0.0.3",
+ "resolved": "https://npm.dev.mysns.pt/object-component/-/object-component-0.0.3.tgz",
+ "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=",
+ "dev": true
+ },
+ "object.omit": {
+ "version": "2.0.1",
+ "resolved": "https://npm.dev.mysns.pt/object.omit/-/object.omit-2.0.1.tgz",
+ "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=",
+ "dev": true,
+ "requires": {
+ "for-own": "0.1.5",
+ "is-extendable": "0.1.1"
+ }
+ },
+ "on-finished": {
+ "version": "2.3.0",
+ "resolved": "https://npm.dev.mysns.pt/on-finished/-/on-finished-2.3.0.tgz",
+ "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
+ "dev": true,
+ "requires": {
+ "ee-first": "1.1.1"
+ }
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "https://npm.dev.mysns.pt/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "dev": true,
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ },
+ "optimist": {
+ "version": "0.6.1",
+ "resolved": "https://npm.dev.mysns.pt/optimist/-/optimist-0.6.1.tgz",
+ "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=",
+ "dev": true,
+ "requires": {
+ "minimist": "0.0.10",
+ "wordwrap": "0.0.3"
+ }
+ },
+ "options": {
+ "version": "0.0.6",
+ "resolved": "https://npm.dev.mysns.pt/options/-/options-0.0.6.tgz",
+ "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=",
+ "dev": true
+ },
+ "os-tmpdir": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
+ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
+ "dev": true
+ },
+ "pako": {
+ "version": "1.0.5",
+ "resolved": "https://npm.dev.mysns.pt/pako/-/pako-1.0.5.tgz",
+ "integrity": "sha1-0iBd/ludqK95fnwWPbTR+E5GALw="
+ },
+ "parse-glob": {
+ "version": "3.0.4",
+ "resolved": "https://npm.dev.mysns.pt/parse-glob/-/parse-glob-3.0.4.tgz",
+ "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=",
+ "dev": true,
+ "requires": {
+ "glob-base": "0.3.0",
+ "is-dotfile": "1.0.3",
+ "is-extglob": "1.0.0",
+ "is-glob": "2.0.1"
+ }
+ },
+ "parsejson": {
+ "version": "0.0.3",
+ "resolved": "https://npm.dev.mysns.pt/parsejson/-/parsejson-0.0.3.tgz",
+ "integrity": "sha1-q343WfIJ7OmUN5c/fQ8fZK4OZKs=",
+ "dev": true,
+ "requires": {
+ "better-assert": "1.0.2"
+ }
+ },
+ "parseqs": {
+ "version": "0.0.5",
+ "resolved": "https://npm.dev.mysns.pt/parseqs/-/parseqs-0.0.5.tgz",
+ "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=",
+ "dev": true,
+ "requires": {
+ "better-assert": "1.0.2"
+ }
+ },
+ "parseuri": {
+ "version": "0.0.5",
+ "resolved": "https://npm.dev.mysns.pt/parseuri/-/parseuri-0.0.5.tgz",
+ "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=",
+ "dev": true,
+ "requires": {
+ "better-assert": "1.0.2"
+ }
+ },
+ "parseurl": {
+ "version": "1.3.1",
+ "resolved": "https://npm.dev.mysns.pt/parseurl/-/parseurl-1.3.1.tgz",
+ "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=",
+ "dev": true
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "https://npm.dev.mysns.pt/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
+ "dev": true
+ },
+ "preserve": {
+ "version": "0.2.0",
+ "resolved": "https://npm.dev.mysns.pt/preserve/-/preserve-0.2.0.tgz",
+ "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=",
+ "dev": true
+ },
+ "process-nextick-args": {
+ "version": "1.0.7",
+ "resolved": "https://npm.dev.mysns.pt/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
+ "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=",
+ "dev": true
+ },
+ "qjobs": {
+ "version": "1.1.5",
+ "resolved": "https://npm.dev.mysns.pt/qjobs/-/qjobs-1.1.5.tgz",
+ "integrity": "sha1-ZZ3p8s+NzCehSBJ28gU3cnI4LnM=",
+ "dev": true
+ },
+ "qs": {
+ "version": "6.4.0",
+ "resolved": "https://npm.dev.mysns.pt/qs/-/qs-6.4.0.tgz",
+ "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=",
+ "dev": true
+ },
+ "randomatic": {
+ "version": "1.1.7",
+ "resolved": "https://npm.dev.mysns.pt/randomatic/-/randomatic-1.1.7.tgz",
+ "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==",
+ "dev": true,
+ "requires": {
+ "is-number": "3.0.0",
+ "kind-of": "4.0.0"
+ },
+ "dependencies": {
+ "is-number": {
+ "version": "3.0.0",
+ "resolved": "https://npm.dev.mysns.pt/is-number/-/is-number-3.0.0.tgz",
+ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=",
+ "dev": true,
+ "requires": {
+ "kind-of": "3.2.2"
+ },
+ "dependencies": {
+ "kind-of": {
+ "version": "3.2.2",
+ "resolved": "https://npm.dev.mysns.pt/kind-of/-/kind-of-3.2.2.tgz",
+ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
+ "dev": true,
+ "requires": {
+ "is-buffer": "1.1.5"
+ }
+ }
+ }
+ },
+ "kind-of": {
+ "version": "4.0.0",
+ "resolved": "https://npm.dev.mysns.pt/kind-of/-/kind-of-4.0.0.tgz",
+ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=",
+ "dev": true,
+ "requires": {
+ "is-buffer": "1.1.5"
+ }
+ }
+ }
+ },
+ "range-parser": {
+ "version": "1.2.0",
+ "resolved": "https://npm.dev.mysns.pt/range-parser/-/range-parser-1.2.0.tgz",
+ "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=",
+ "dev": true
+ },
+ "raw-body": {
+ "version": "2.2.0",
+ "resolved": "https://npm.dev.mysns.pt/raw-body/-/raw-body-2.2.0.tgz",
+ "integrity": "sha1-mUl2z2pQlqQRYoQEkvC9xdbn+5Y=",
+ "dev": true,
+ "requires": {
+ "bytes": "2.4.0",
+ "iconv-lite": "0.4.15",
+ "unpipe": "1.0.0"
+ }
+ },
+ "readable-stream": {
+ "version": "2.3.3",
+ "resolved": "https://npm.dev.mysns.pt/readable-stream/-/readable-stream-2.3.3.tgz",
+ "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
+ "dev": true,
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "1.0.0",
+ "process-nextick-args": "1.0.7",
+ "safe-buffer": "5.1.1",
+ "string_decoder": "1.0.3",
+ "util-deprecate": "1.0.2"
+ }
+ },
+ "readdirp": {
+ "version": "2.1.0",
+ "resolved": "https://npm.dev.mysns.pt/readdirp/-/readdirp-2.1.0.tgz",
+ "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=",
+ "dev": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "minimatch": "3.0.4",
+ "readable-stream": "2.3.3",
+ "set-immediate-shim": "1.0.1"
+ }
+ },
+ "regenerator-runtime": {
+ "version": "0.10.5",
+ "resolved": "https://npm.dev.mysns.pt/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz",
+ "integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=",
+ "dev": true
+ },
+ "regex-cache": {
+ "version": "0.4.3",
+ "resolved": "https://npm.dev.mysns.pt/regex-cache/-/regex-cache-0.4.3.tgz",
+ "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=",
+ "dev": true,
+ "requires": {
+ "is-equal-shallow": "0.1.3",
+ "is-primitive": "2.0.0"
+ }
+ },
+ "remove-trailing-separator": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz",
+ "integrity": "sha1-abBi2XhyetFNxrVrpKt3L9jXBRE=",
+ "dev": true
+ },
+ "repeat-element": {
+ "version": "1.1.2",
+ "resolved": "https://npm.dev.mysns.pt/repeat-element/-/repeat-element-1.1.2.tgz",
+ "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=",
+ "dev": true
+ },
+ "repeat-string": {
+ "version": "1.6.1",
+ "resolved": "https://npm.dev.mysns.pt/repeat-string/-/repeat-string-1.6.1.tgz",
+ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=",
+ "dev": true
+ },
+ "requires-port": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/requires-port/-/requires-port-1.0.0.tgz",
+ "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=",
+ "dev": true
+ },
+ "rimraf": {
+ "version": "2.6.1",
+ "resolved": "https://npm.dev.mysns.pt/rimraf/-/rimraf-2.6.1.tgz",
+ "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
+ "dev": true,
+ "requires": {
+ "glob": "7.1.2"
+ }
+ },
+ "safe-buffer": {
+ "version": "5.1.1",
+ "resolved": "https://npm.dev.mysns.pt/safe-buffer/-/safe-buffer-5.1.1.tgz",
+ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
+ "dev": true
+ },
+ "semver": {
+ "version": "4.3.6",
+ "resolved": "https://npm.dev.mysns.pt/semver/-/semver-4.3.6.tgz",
+ "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=",
+ "dev": true
+ },
+ "set-immediate-shim": {
+ "version": "1.0.1",
+ "resolved": "https://npm.dev.mysns.pt/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz",
+ "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=",
+ "dev": true
+ },
+ "setprototypeof": {
+ "version": "1.0.3",
+ "resolved": "https://npm.dev.mysns.pt/setprototypeof/-/setprototypeof-1.0.3.tgz",
+ "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=",
+ "dev": true
+ },
+ "shelljs": {
+ "version": "0.5.3",
+ "resolved": "https://npm.dev.mysns.pt/shelljs/-/shelljs-0.5.3.tgz",
+ "integrity": "sha1-xUmCuZbHbvDB5rWfvcWCX1txMRM=",
+ "dev": true
+ },
+ "socket.io": {
+ "version": "1.7.3",
+ "resolved": "https://npm.dev.mysns.pt/socket.io/-/socket.io-1.7.3.tgz",
+ "integrity": "sha1-uK+cq6AJSeVo42nxMn6pvp6iRhs=",
+ "dev": true,
+ "requires": {
+ "debug": "2.3.3",
+ "engine.io": "1.8.3",
+ "has-binary": "0.1.7",
+ "object-assign": "4.1.0",
+ "socket.io-adapter": "0.5.0",
+ "socket.io-client": "1.7.3",
+ "socket.io-parser": "2.3.1"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.3.3",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.3.3.tgz",
+ "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=",
+ "dev": true,
+ "requires": {
+ "ms": "0.7.2"
+ }
+ },
+ "ms": {
+ "version": "0.7.2",
+ "resolved": "https://npm.dev.mysns.pt/ms/-/ms-0.7.2.tgz",
+ "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=",
+ "dev": true
+ }
+ }
+ },
+ "socket.io-adapter": {
+ "version": "0.5.0",
+ "resolved": "https://npm.dev.mysns.pt/socket.io-adapter/-/socket.io-adapter-0.5.0.tgz",
+ "integrity": "sha1-y21LuL7IHhB4uZZ3+c7QBGBmu4s=",
+ "dev": true,
+ "requires": {
+ "debug": "2.3.3",
+ "socket.io-parser": "2.3.1"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.3.3",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.3.3.tgz",
+ "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=",
+ "dev": true,
+ "requires": {
+ "ms": "0.7.2"
+ }
+ },
+ "ms": {
+ "version": "0.7.2",
+ "resolved": "https://npm.dev.mysns.pt/ms/-/ms-0.7.2.tgz",
+ "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=",
+ "dev": true
+ }
+ }
+ },
+ "socket.io-client": {
+ "version": "1.7.3",
+ "resolved": "https://npm.dev.mysns.pt/socket.io-client/-/socket.io-client-1.7.3.tgz",
+ "integrity": "sha1-sw6GqhDV7zVGYBwJzeR2Xjgdo3c=",
+ "dev": true,
+ "requires": {
+ "backo2": "1.0.2",
+ "component-bind": "1.0.0",
+ "component-emitter": "1.2.1",
+ "debug": "2.3.3",
+ "engine.io-client": "1.8.3",
+ "has-binary": "0.1.7",
+ "indexof": "0.0.1",
+ "object-component": "0.0.3",
+ "parseuri": "0.0.5",
+ "socket.io-parser": "2.3.1",
+ "to-array": "0.1.4"
+ },
+ "dependencies": {
+ "component-emitter": {
+ "version": "1.2.1",
+ "resolved": "https://npm.dev.mysns.pt/component-emitter/-/component-emitter-1.2.1.tgz",
+ "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=",
+ "dev": true
+ },
+ "debug": {
+ "version": "2.3.3",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.3.3.tgz",
+ "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=",
+ "dev": true,
+ "requires": {
+ "ms": "0.7.2"
+ }
+ },
+ "ms": {
+ "version": "0.7.2",
+ "resolved": "https://npm.dev.mysns.pt/ms/-/ms-0.7.2.tgz",
+ "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=",
+ "dev": true
+ }
+ }
+ },
+ "socket.io-parser": {
+ "version": "2.3.1",
+ "resolved": "https://npm.dev.mysns.pt/socket.io-parser/-/socket.io-parser-2.3.1.tgz",
+ "integrity": "sha1-3VMgJRA85Clpcya+/WQAX8/ltKA=",
+ "dev": true,
+ "requires": {
+ "component-emitter": "1.1.2",
+ "debug": "2.2.0",
+ "isarray": "0.0.1",
+ "json3": "3.3.2"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "2.2.0",
+ "resolved": "https://npm.dev.mysns.pt/debug/-/debug-2.2.0.tgz",
+ "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=",
+ "dev": true,
+ "requires": {
+ "ms": "0.7.1"
+ }
+ },
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://npm.dev.mysns.pt/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
+ "dev": true
+ },
+ "ms": {
+ "version": "0.7.1",
+ "resolved": "https://npm.dev.mysns.pt/ms/-/ms-0.7.1.tgz",
+ "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=",
+ "dev": true
+ }
+ }
+ },
+ "source-map": {
+ "version": "0.5.6",
+ "resolved": "https://npm.dev.mysns.pt/source-map/-/source-map-0.5.6.tgz",
+ "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=",
+ "dev": true
+ },
+ "statuses": {
+ "version": "1.3.1",
+ "resolved": "https://npm.dev.mysns.pt/statuses/-/statuses-1.3.1.tgz",
+ "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=",
+ "dev": true
+ },
+ "string_decoder": {
+ "version": "1.0.3",
+ "resolved": "https://npm.dev.mysns.pt/string_decoder/-/string_decoder-1.0.3.tgz",
+ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
+ "dev": true,
+ "requires": {
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "https://npm.dev.mysns.pt/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "supports-color": {
+ "version": "2.0.0",
+ "resolved": "https://npm.dev.mysns.pt/supports-color/-/supports-color-2.0.0.tgz",
+ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
+ "dev": true
+ },
+ "tmp": {
+ "version": "0.0.31",
+ "resolved": "https://npm.dev.mysns.pt/tmp/-/tmp-0.0.31.tgz",
+ "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=",
+ "dev": true,
+ "requires": {
+ "os-tmpdir": "1.0.2"
+ }
+ },
+ "tns-core-modules": {
+ "version": "3.1.0",
+ "resolved": "https://npm.dev.mysns.pt/tns-core-modules/-/tns-core-modules-3.1.0.tgz",
+ "integrity": "sha1-iSXsrhZWsytOMmVJjLI8EHjC9mc=",
+ "requires": {
+ "tns-core-modules-widgets": "3.1.0"
+ }
+ },
+ "tns-core-modules-widgets": {
+ "version": "3.1.0",
+ "resolved": "https://npm.dev.mysns.pt/tns-core-modules-widgets/-/tns-core-modules-widgets-3.1.0.tgz",
+ "integrity": "sha1-3pGlagyM+zhxxo1lGueAPyM/URk="
+ },
+ "to-array": {
+ "version": "0.1.4",
+ "resolved": "https://npm.dev.mysns.pt/to-array/-/to-array-0.1.4.tgz",
+ "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=",
+ "dev": true
+ },
+ "to-fast-properties": {
+ "version": "1.0.3",
+ "resolved": "https://npm.dev.mysns.pt/to-fast-properties/-/to-fast-properties-1.0.3.tgz",
+ "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=",
+ "dev": true
+ },
+ "type-is": {
+ "version": "1.6.15",
+ "resolved": "https://npm.dev.mysns.pt/type-is/-/type-is-1.6.15.tgz",
+ "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=",
+ "dev": true,
+ "requires": {
+ "media-typer": "0.3.0",
+ "mime-types": "2.1.16"
+ }
+ },
+ "typescript": {
+ "version": "2.4.2",
+ "resolved": "https://npm.dev.mysns.pt/typescript/-/typescript-2.4.2.tgz",
+ "integrity": "sha1-+DlfhdRZJ2BnyYiqQYN6j4KHCEQ=",
+ "dev": true
+ },
+ "ultron": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/ultron/-/ultron-1.0.2.tgz",
+ "integrity": "sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po=",
+ "dev": true
+ },
+ "unpipe": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/unpipe/-/unpipe-1.0.0.tgz",
+ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=",
+ "dev": true
+ },
+ "useragent": {
+ "version": "2.2.1",
+ "resolved": "https://npm.dev.mysns.pt/useragent/-/useragent-2.2.1.tgz",
+ "integrity": "sha1-z1k+9PLRdYdei7ZY6pLhik/QbY4=",
+ "dev": true,
+ "requires": {
+ "lru-cache": "2.2.4",
+ "tmp": "0.0.31"
+ }
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
+ "dev": true
+ },
+ "utils-merge": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/utils-merge/-/utils-merge-1.0.0.tgz",
+ "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=",
+ "dev": true
+ },
+ "void-elements": {
+ "version": "2.0.1",
+ "resolved": "https://npm.dev.mysns.pt/void-elements/-/void-elements-2.0.1.tgz",
+ "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=",
+ "dev": true
+ },
+ "wordwrap": {
+ "version": "0.0.3",
+ "resolved": "https://npm.dev.mysns.pt/wordwrap/-/wordwrap-0.0.3.tgz",
+ "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=",
+ "dev": true
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://npm.dev.mysns.pt/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
+ "dev": true
+ },
+ "ws": {
+ "version": "1.1.2",
+ "resolved": "https://npm.dev.mysns.pt/ws/-/ws-1.1.2.tgz",
+ "integrity": "sha1-iiRPoFJAHgjJiGz0SoUYnh/UBn8=",
+ "dev": true,
+ "requires": {
+ "options": "0.0.6",
+ "ultron": "1.0.2"
+ }
+ },
+ "wtf-8": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/wtf-8/-/wtf-8-1.0.0.tgz",
+ "integrity": "sha1-OS2LotDxw00e4tYw8V0O+2jhBIo=",
+ "dev": true
+ },
+ "xmlhttprequest-ssl": {
+ "version": "1.5.3",
+ "resolved": "https://npm.dev.mysns.pt/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz",
+ "integrity": "sha1-GFqIjATspGw+QHDZn3tJ3jUomS0=",
+ "dev": true
+ },
+ "yeast": {
+ "version": "0.1.2",
+ "resolved": "https://npm.dev.mysns.pt/yeast/-/yeast-0.1.2.tgz",
+ "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=",
+ "dev": true
+ }
+ }
+}
diff --git a/demo/package.json b/demo/package.json
index bd7016f..b5f003c 100644
--- a/demo/package.json
+++ b/demo/package.json
@@ -2,17 +2,19 @@
"nativescript": {
"id": "org.nativescript.demo",
"tns-ios": {
- "version": "3.0.1"
+ "version": "3.1.0"
},
"tns-android": {
- "version": "3.0.0"
+ "version": "3.1.1"
}
},
"dependencies": {
+ "@types/pako": "^1.0.0",
"nativescript-crypto": "../src",
"nativescript-theme-core": "^1.0.4",
"nativescript-unit-test-runner": "^0.3.4",
- "tns-core-modules": "^3.0.0"
+ "pako": "^1.0.5",
+ "tns-core-modules": "^3.1.0"
},
"devDependencies": {
"babel-traverse": "6.12.0",
@@ -24,7 +26,7 @@
"karma-jasmine": "^1.0.2",
"karma-nativescript-launcher": "^0.4.0",
"lazy": "1.0.11",
- "nativescript-dev-typescript": "^0.4.5",
+ "nativescript-dev-typescript": "^0.5.0",
"typescript": "^2.2.2"
}
}
diff --git a/demo/tsconfig.json b/demo/tsconfig.json
index 78128a2..fc0ce1b 100644
--- a/demo/tsconfig.json
+++ b/demo/tsconfig.json
@@ -19,7 +19,14 @@
"noImplicitAny": false,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
- "noFallthroughCasesInSwitch": true
+ "noFallthroughCasesInSwitch": true,
+ "baseUrl": ".",
+ "paths": {
+ "*": [
+ "./node_modules/tns-core-modules/*",
+ "./node_modules/*"
+ ]
+ }
},
"exclude": [
"node_modules",
diff --git a/publish/pack.sh b/publish/pack.sh
old mode 100644
new mode 100755
index 212f22f..425fac0
--- a/publish/pack.sh
+++ b/publish/pack.sh
@@ -7,7 +7,7 @@ ROOT_DIR=..;
PUBLISH=--publish
install(){
- npm i
+ node_modules/.bin/npm i
}
pack() {
@@ -37,11 +37,11 @@ pack() {
# create the package
cd "$PACK_DIR"
- npm pack ../"$TO_SOURCE_DIR"
+ ../node_modules/.bin/npm pack ../"$TO_SOURCE_DIR"
# delete source directory used to create the package
cd ..
node_modules/.bin/rimraf "$TO_SOURCE_DIR"
}
-install && pack
\ No newline at end of file
+install && pack
diff --git a/publish/package-lock.json b/publish/package-lock.json
new file mode 100644
index 0000000..a1da0e2
--- /dev/null
+++ b/publish/package-lock.json
@@ -0,0 +1,2240 @@
+{
+ "name": "nativescript-publish",
+ "version": "1.0.0",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "balanced-match": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+ "dev": true
+ },
+ "brace-expansion": {
+ "version": "1.1.8",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
+ "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
+ "dev": true,
+ "requires": {
+ "balanced-match": "1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+ "dev": true
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
+ "dev": true
+ },
+ "glob": {
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
+ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
+ "dev": true,
+ "requires": {
+ "fs.realpath": "1.0.0",
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.4",
+ "once": "1.4.0",
+ "path-is-absolute": "1.0.1"
+ }
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+ "dev": true,
+ "requires": {
+ "once": "1.4.0",
+ "wrappy": "1.0.2"
+ }
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
+ "dev": true
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "1.1.8"
+ }
+ },
+ "ncp": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz",
+ "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=",
+ "dev": true
+ },
+ "npm": {
+ "version": "4.6.1",
+ "resolved": "https://registry.npmjs.org/npm/-/npm-4.6.1.tgz",
+ "integrity": "sha1-+Osa0A3FilUUNjtBylNCgX8L1kY=",
+ "requires": {
+ "abbrev": "1.1.0",
+ "ansi-regex": "2.1.1",
+ "ansicolors": "0.3.2",
+ "ansistyles": "0.1.3",
+ "aproba": "1.1.1",
+ "archy": "1.0.0",
+ "asap": "2.0.5",
+ "bluebird": "3.5.0",
+ "call-limit": "1.1.0",
+ "chownr": "1.0.1",
+ "cmd-shim": "2.0.2",
+ "columnify": "1.5.4",
+ "config-chain": "1.1.11",
+ "debuglog": "1.0.1",
+ "dezalgo": "1.0.3",
+ "editor": "1.0.0",
+ "fs-vacuum": "1.2.10",
+ "fs-write-stream-atomic": "1.0.10",
+ "fstream": "1.0.11",
+ "fstream-npm": "1.2.0",
+ "glob": "7.1.1",
+ "graceful-fs": "4.1.11",
+ "has-unicode": "2.0.1",
+ "hosted-git-info": "2.4.2",
+ "iferr": "0.1.5",
+ "imurmurhash": "0.1.4",
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "ini": "1.3.4",
+ "init-package-json": "1.10.1",
+ "JSONStream": "1.3.1",
+ "lazy-property": "1.0.0",
+ "lockfile": "1.0.3",
+ "lodash._baseindexof": "3.1.0",
+ "lodash._baseuniq": "4.6.0",
+ "lodash._bindcallback": "3.0.1",
+ "lodash._cacheindexof": "3.0.2",
+ "lodash._createcache": "3.1.2",
+ "lodash._getnative": "3.9.1",
+ "lodash.clonedeep": "4.5.0",
+ "lodash.restparam": "3.6.1",
+ "lodash.union": "4.6.0",
+ "lodash.uniq": "4.5.0",
+ "lodash.without": "4.4.0",
+ "mississippi": "1.3.0",
+ "mkdirp": "0.5.1",
+ "move-concurrently": "1.0.1",
+ "node-gyp": "3.6.0",
+ "nopt": "4.0.1",
+ "normalize-git-url": "3.0.2",
+ "normalize-package-data": "2.3.8",
+ "npm-cache-filename": "1.0.2",
+ "npm-install-checks": "3.0.0",
+ "npm-package-arg": "4.2.1",
+ "npm-registry-client": "8.1.1",
+ "npm-user-validate": "0.1.5",
+ "npmlog": "4.0.2",
+ "once": "1.4.0",
+ "opener": "1.4.3",
+ "osenv": "0.1.4",
+ "path-is-inside": "1.0.2",
+ "read": "1.0.7",
+ "read-cmd-shim": "1.0.1",
+ "read-installed": "4.0.3",
+ "read-package-json": "2.0.5",
+ "read-package-tree": "5.1.5",
+ "readable-stream": "2.2.9",
+ "readdir-scoped-modules": "1.0.2",
+ "realize-package-specifier": "3.0.3",
+ "request": "2.81.0",
+ "retry": "0.10.1",
+ "rimraf": "2.6.1",
+ "semver": "5.3.0",
+ "sha": "2.0.1",
+ "slide": "1.1.6",
+ "sorted-object": "2.0.1",
+ "sorted-union-stream": "2.1.3",
+ "strip-ansi": "3.0.1",
+ "tar": "2.2.1",
+ "text-table": "0.2.0",
+ "uid-number": "0.0.6",
+ "umask": "1.1.0",
+ "unique-filename": "1.1.0",
+ "unpipe": "1.0.0",
+ "update-notifier": "2.1.0",
+ "uuid": "3.0.1",
+ "validate-npm-package-license": "3.0.1",
+ "validate-npm-package-name": "3.0.0",
+ "which": "1.2.14",
+ "wrappy": "1.0.2",
+ "write-file-atomic": "1.3.3"
+ },
+ "dependencies": {
+ "abbrev": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "ansi-regex": {
+ "version": "2.1.1",
+ "bundled": true
+ },
+ "ansicolors": {
+ "version": "0.3.2",
+ "bundled": true
+ },
+ "ansistyles": {
+ "version": "0.1.3",
+ "bundled": true
+ },
+ "aproba": {
+ "version": "1.1.1",
+ "bundled": true
+ },
+ "archy": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "asap": {
+ "version": "2.0.5",
+ "bundled": true
+ },
+ "bluebird": {
+ "version": "3.5.0",
+ "bundled": true
+ },
+ "call-limit": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "chownr": {
+ "version": "1.0.1",
+ "bundled": true
+ },
+ "cmd-shim": {
+ "version": "2.0.2",
+ "bundled": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "mkdirp": "0.5.1"
+ }
+ },
+ "columnify": {
+ "version": "1.5.4",
+ "bundled": true,
+ "requires": {
+ "strip-ansi": "3.0.1",
+ "wcwidth": "1.0.0"
+ },
+ "dependencies": {
+ "wcwidth": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "defaults": "1.0.3"
+ },
+ "dependencies": {
+ "defaults": {
+ "version": "1.0.3",
+ "bundled": true,
+ "requires": {
+ "clone": "1.0.2"
+ },
+ "dependencies": {
+ "clone": {
+ "version": "1.0.2",
+ "bundled": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "config-chain": {
+ "version": "1.1.11",
+ "bundled": true,
+ "requires": {
+ "ini": "1.3.4",
+ "proto-list": "1.2.4"
+ },
+ "dependencies": {
+ "proto-list": {
+ "version": "1.2.4",
+ "bundled": true
+ }
+ }
+ },
+ "debuglog": {
+ "version": "1.0.1",
+ "bundled": true
+ },
+ "dezalgo": {
+ "version": "1.0.3",
+ "bundled": true,
+ "requires": {
+ "asap": "2.0.5",
+ "wrappy": "1.0.2"
+ }
+ },
+ "editor": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "fs-vacuum": {
+ "version": "1.2.10",
+ "bundled": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "path-is-inside": "1.0.2",
+ "rimraf": "2.6.1"
+ }
+ },
+ "fs-write-stream-atomic": {
+ "version": "1.0.10",
+ "bundled": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "iferr": "0.1.5",
+ "imurmurhash": "0.1.4",
+ "readable-stream": "2.2.9"
+ }
+ },
+ "fstream": {
+ "version": "1.0.11",
+ "bundled": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "inherits": "2.0.3",
+ "mkdirp": "0.5.1",
+ "rimraf": "2.6.1"
+ }
+ },
+ "fstream-npm": {
+ "version": "1.2.0",
+ "bundled": true,
+ "requires": {
+ "fstream-ignore": "1.0.5",
+ "inherits": "2.0.3"
+ },
+ "dependencies": {
+ "fstream-ignore": {
+ "version": "1.0.5",
+ "bundled": true,
+ "requires": {
+ "fstream": "1.0.11",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.3"
+ },
+ "dependencies": {
+ "minimatch": {
+ "version": "3.0.3",
+ "bundled": true,
+ "requires": {
+ "brace-expansion": "1.1.6"
+ },
+ "dependencies": {
+ "brace-expansion": {
+ "version": "1.1.6",
+ "bundled": true,
+ "requires": {
+ "balanced-match": "0.4.2",
+ "concat-map": "0.0.1"
+ },
+ "dependencies": {
+ "balanced-match": {
+ "version": "0.4.2",
+ "bundled": true
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "glob": {
+ "version": "7.1.1",
+ "bundled": true,
+ "requires": {
+ "fs.realpath": "1.0.0",
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.3",
+ "once": "1.4.0",
+ "path-is-absolute": "1.0.1"
+ },
+ "dependencies": {
+ "fs.realpath": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "minimatch": {
+ "version": "3.0.3",
+ "bundled": true,
+ "requires": {
+ "brace-expansion": "1.1.6"
+ },
+ "dependencies": {
+ "brace-expansion": {
+ "version": "1.1.6",
+ "bundled": true,
+ "requires": {
+ "balanced-match": "0.4.2",
+ "concat-map": "0.0.1"
+ },
+ "dependencies": {
+ "balanced-match": {
+ "version": "0.4.2",
+ "bundled": true
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "bundled": true
+ }
+ }
+ },
+ "graceful-fs": {
+ "version": "4.1.11",
+ "bundled": true
+ },
+ "has-unicode": {
+ "version": "2.0.1",
+ "bundled": true
+ },
+ "hosted-git-info": {
+ "version": "2.4.2",
+ "bundled": true
+ },
+ "iferr": {
+ "version": "0.1.5",
+ "bundled": true
+ },
+ "imurmurhash": {
+ "version": "0.1.4",
+ "bundled": true
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "bundled": true,
+ "requires": {
+ "once": "1.4.0",
+ "wrappy": "1.0.2"
+ }
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "bundled": true
+ },
+ "ini": {
+ "version": "1.3.4",
+ "bundled": true
+ },
+ "init-package-json": {
+ "version": "1.10.1",
+ "bundled": true,
+ "requires": {
+ "glob": "7.1.1",
+ "npm-package-arg": "4.2.1",
+ "promzard": "0.3.0",
+ "read": "1.0.7",
+ "read-package-json": "2.0.5",
+ "semver": "5.3.0",
+ "validate-npm-package-license": "3.0.1",
+ "validate-npm-package-name": "3.0.0"
+ },
+ "dependencies": {
+ "promzard": {
+ "version": "0.3.0",
+ "bundled": true,
+ "requires": {
+ "read": "1.0.7"
+ }
+ }
+ }
+ },
+ "JSONStream": {
+ "version": "1.3.1",
+ "bundled": true,
+ "requires": {
+ "jsonparse": "1.3.0",
+ "through": "2.3.8"
+ },
+ "dependencies": {
+ "jsonparse": {
+ "version": "1.3.0",
+ "bundled": true
+ },
+ "through": {
+ "version": "2.3.8",
+ "bundled": true
+ }
+ }
+ },
+ "lazy-property": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "lockfile": {
+ "version": "1.0.3",
+ "bundled": true
+ },
+ "lodash._baseindexof": {
+ "version": "3.1.0",
+ "bundled": true
+ },
+ "lodash._baseuniq": {
+ "version": "4.6.0",
+ "bundled": true,
+ "requires": {
+ "lodash._createset": "4.0.3",
+ "lodash._root": "3.0.1"
+ },
+ "dependencies": {
+ "lodash._createset": {
+ "version": "4.0.3",
+ "bundled": true
+ },
+ "lodash._root": {
+ "version": "3.0.1",
+ "bundled": true
+ }
+ }
+ },
+ "lodash._bindcallback": {
+ "version": "3.0.1",
+ "bundled": true
+ },
+ "lodash._cacheindexof": {
+ "version": "3.0.2",
+ "bundled": true
+ },
+ "lodash._createcache": {
+ "version": "3.1.2",
+ "bundled": true,
+ "requires": {
+ "lodash._getnative": "3.9.1"
+ }
+ },
+ "lodash._getnative": {
+ "version": "3.9.1",
+ "bundled": true
+ },
+ "lodash.clonedeep": {
+ "version": "4.5.0",
+ "bundled": true
+ },
+ "lodash.restparam": {
+ "version": "3.6.1",
+ "bundled": true
+ },
+ "lodash.union": {
+ "version": "4.6.0",
+ "bundled": true
+ },
+ "lodash.uniq": {
+ "version": "4.5.0",
+ "bundled": true
+ },
+ "lodash.without": {
+ "version": "4.4.0",
+ "bundled": true
+ },
+ "mississippi": {
+ "version": "1.3.0",
+ "bundled": true,
+ "requires": {
+ "concat-stream": "1.6.0",
+ "duplexify": "3.5.0",
+ "end-of-stream": "1.1.0",
+ "flush-write-stream": "1.0.2",
+ "from2": "2.3.0",
+ "parallel-transform": "1.1.0",
+ "pump": "1.0.2",
+ "pumpify": "1.3.5",
+ "stream-each": "1.2.0",
+ "through2": "2.0.3"
+ },
+ "dependencies": {
+ "concat-stream": {
+ "version": "1.6.0",
+ "bundled": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "readable-stream": "2.2.9",
+ "typedarray": "0.0.6"
+ },
+ "dependencies": {
+ "typedarray": {
+ "version": "0.0.6",
+ "bundled": true
+ }
+ }
+ },
+ "duplexify": {
+ "version": "3.5.0",
+ "bundled": true,
+ "requires": {
+ "end-of-stream": "1.0.0",
+ "inherits": "2.0.3",
+ "readable-stream": "2.2.9",
+ "stream-shift": "1.0.0"
+ },
+ "dependencies": {
+ "end-of-stream": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "once": "1.3.3"
+ },
+ "dependencies": {
+ "once": {
+ "version": "1.3.3",
+ "bundled": true,
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ }
+ }
+ },
+ "stream-shift": {
+ "version": "1.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "end-of-stream": {
+ "version": "1.1.0",
+ "bundled": true,
+ "requires": {
+ "once": "1.3.3"
+ },
+ "dependencies": {
+ "once": {
+ "version": "1.3.3",
+ "bundled": true,
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ }
+ }
+ },
+ "flush-write-stream": {
+ "version": "1.0.2",
+ "bundled": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "readable-stream": "2.2.9"
+ }
+ },
+ "from2": {
+ "version": "2.3.0",
+ "bundled": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "readable-stream": "2.2.9"
+ }
+ },
+ "parallel-transform": {
+ "version": "1.1.0",
+ "bundled": true,
+ "requires": {
+ "cyclist": "0.2.2",
+ "inherits": "2.0.3",
+ "readable-stream": "2.2.9"
+ },
+ "dependencies": {
+ "cyclist": {
+ "version": "0.2.2",
+ "bundled": true
+ }
+ }
+ },
+ "pump": {
+ "version": "1.0.2",
+ "bundled": true,
+ "requires": {
+ "end-of-stream": "1.1.0",
+ "once": "1.4.0"
+ }
+ },
+ "pumpify": {
+ "version": "1.3.5",
+ "bundled": true,
+ "requires": {
+ "duplexify": "3.5.0",
+ "inherits": "2.0.3",
+ "pump": "1.0.2"
+ }
+ },
+ "stream-each": {
+ "version": "1.2.0",
+ "bundled": true,
+ "requires": {
+ "end-of-stream": "1.1.0",
+ "stream-shift": "1.0.0"
+ },
+ "dependencies": {
+ "stream-shift": {
+ "version": "1.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "through2": {
+ "version": "2.0.3",
+ "bundled": true,
+ "requires": {
+ "readable-stream": "2.2.9",
+ "xtend": "4.0.1"
+ },
+ "dependencies": {
+ "xtend": {
+ "version": "4.0.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "bundled": true,
+ "requires": {
+ "minimist": "0.0.8"
+ },
+ "dependencies": {
+ "minimist": {
+ "version": "0.0.8",
+ "bundled": true
+ }
+ }
+ },
+ "move-concurrently": {
+ "version": "1.0.1",
+ "bundled": true,
+ "requires": {
+ "aproba": "1.1.1",
+ "copy-concurrently": "1.0.3",
+ "fs-write-stream-atomic": "1.0.10",
+ "mkdirp": "0.5.1",
+ "rimraf": "2.6.1",
+ "run-queue": "1.0.3"
+ },
+ "dependencies": {
+ "copy-concurrently": {
+ "version": "1.0.3",
+ "bundled": true,
+ "requires": {
+ "aproba": "1.1.1",
+ "fs-write-stream-atomic": "1.0.10",
+ "iferr": "0.1.5",
+ "mkdirp": "0.5.1",
+ "rimraf": "2.6.1",
+ "run-queue": "1.0.3"
+ }
+ },
+ "run-queue": {
+ "version": "1.0.3",
+ "bundled": true,
+ "requires": {
+ "aproba": "1.1.1"
+ }
+ }
+ }
+ },
+ "node-gyp": {
+ "version": "3.6.0",
+ "bundled": true,
+ "requires": {
+ "fstream": "1.0.11",
+ "glob": "7.1.1",
+ "graceful-fs": "4.1.11",
+ "minimatch": "3.0.3",
+ "mkdirp": "0.5.1",
+ "nopt": "3.0.6",
+ "npmlog": "4.0.2",
+ "osenv": "0.1.4",
+ "request": "2.81.0",
+ "rimraf": "2.6.1",
+ "semver": "5.3.0",
+ "tar": "2.2.1",
+ "which": "1.2.14"
+ },
+ "dependencies": {
+ "minimatch": {
+ "version": "3.0.3",
+ "bundled": true,
+ "requires": {
+ "brace-expansion": "1.1.6"
+ },
+ "dependencies": {
+ "brace-expansion": {
+ "version": "1.1.6",
+ "bundled": true,
+ "requires": {
+ "balanced-match": "0.4.2",
+ "concat-map": "0.0.1"
+ },
+ "dependencies": {
+ "balanced-match": {
+ "version": "0.4.2",
+ "bundled": true
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "nopt": {
+ "version": "3.0.6",
+ "bundled": true,
+ "requires": {
+ "abbrev": "1.1.0"
+ }
+ }
+ }
+ },
+ "nopt": {
+ "version": "4.0.1",
+ "bundled": true,
+ "requires": {
+ "abbrev": "1.1.0",
+ "osenv": "0.1.4"
+ },
+ "dependencies": {
+ "osenv": {
+ "version": "0.1.4",
+ "bundled": true,
+ "requires": {
+ "os-homedir": "1.0.2",
+ "os-tmpdir": "1.0.2"
+ },
+ "dependencies": {
+ "os-homedir": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "os-tmpdir": {
+ "version": "1.0.2",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "normalize-git-url": {
+ "version": "3.0.2",
+ "bundled": true
+ },
+ "normalize-package-data": {
+ "version": "2.3.8",
+ "bundled": true,
+ "requires": {
+ "hosted-git-info": "2.4.2",
+ "is-builtin-module": "1.0.0",
+ "semver": "5.3.0",
+ "validate-npm-package-license": "3.0.1"
+ },
+ "dependencies": {
+ "is-builtin-module": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "builtin-modules": "1.1.1"
+ },
+ "dependencies": {
+ "builtin-modules": {
+ "version": "1.1.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "npm-cache-filename": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "npm-install-checks": {
+ "version": "3.0.0",
+ "bundled": true,
+ "requires": {
+ "semver": "5.3.0"
+ }
+ },
+ "npm-package-arg": {
+ "version": "4.2.1",
+ "bundled": true,
+ "requires": {
+ "hosted-git-info": "2.4.2",
+ "semver": "5.3.0"
+ }
+ },
+ "npm-registry-client": {
+ "version": "8.1.1",
+ "bundled": true,
+ "requires": {
+ "concat-stream": "1.6.0",
+ "graceful-fs": "4.1.11",
+ "normalize-package-data": "2.3.8",
+ "npm-package-arg": "4.2.1",
+ "npmlog": "4.0.2",
+ "once": "1.4.0",
+ "request": "2.81.0",
+ "retry": "0.10.1",
+ "semver": "5.3.0",
+ "slide": "1.1.6"
+ },
+ "dependencies": {
+ "concat-stream": {
+ "version": "1.6.0",
+ "bundled": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "readable-stream": "2.2.9",
+ "typedarray": "0.0.6"
+ },
+ "dependencies": {
+ "typedarray": {
+ "version": "0.0.6",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "npm-user-validate": {
+ "version": "0.1.5",
+ "bundled": true
+ },
+ "npmlog": {
+ "version": "4.0.2",
+ "bundled": true,
+ "requires": {
+ "are-we-there-yet": "1.1.4",
+ "console-control-strings": "1.1.0",
+ "gauge": "2.7.4",
+ "set-blocking": "2.0.0"
+ },
+ "dependencies": {
+ "are-we-there-yet": {
+ "version": "1.1.4",
+ "bundled": true,
+ "requires": {
+ "delegates": "1.0.0",
+ "readable-stream": "2.2.9"
+ },
+ "dependencies": {
+ "delegates": {
+ "version": "1.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "console-control-strings": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "gauge": {
+ "version": "2.7.4",
+ "bundled": true,
+ "requires": {
+ "aproba": "1.1.1",
+ "console-control-strings": "1.1.0",
+ "has-unicode": "2.0.1",
+ "object-assign": "4.1.1",
+ "signal-exit": "3.0.2",
+ "string-width": "1.0.2",
+ "strip-ansi": "3.0.1",
+ "wide-align": "1.1.0"
+ },
+ "dependencies": {
+ "object-assign": {
+ "version": "4.1.1",
+ "bundled": true
+ },
+ "signal-exit": {
+ "version": "3.0.2",
+ "bundled": true
+ },
+ "string-width": {
+ "version": "1.0.2",
+ "bundled": true,
+ "requires": {
+ "code-point-at": "1.1.0",
+ "is-fullwidth-code-point": "1.0.0",
+ "strip-ansi": "3.0.1"
+ },
+ "dependencies": {
+ "code-point-at": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "is-fullwidth-code-point": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "number-is-nan": "1.0.1"
+ },
+ "dependencies": {
+ "number-is-nan": {
+ "version": "1.0.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "wide-align": {
+ "version": "1.1.0",
+ "bundled": true,
+ "requires": {
+ "string-width": "1.0.2"
+ }
+ }
+ }
+ },
+ "set-blocking": {
+ "version": "2.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "once": {
+ "version": "1.4.0",
+ "bundled": true,
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ },
+ "opener": {
+ "version": "1.4.3",
+ "bundled": true
+ },
+ "osenv": {
+ "version": "0.1.4",
+ "bundled": true,
+ "requires": {
+ "os-homedir": "1.0.2",
+ "os-tmpdir": "1.0.2"
+ },
+ "dependencies": {
+ "os-homedir": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "os-tmpdir": {
+ "version": "1.0.2",
+ "bundled": true
+ }
+ }
+ },
+ "path-is-inside": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "read": {
+ "version": "1.0.7",
+ "bundled": true,
+ "requires": {
+ "mute-stream": "0.0.5"
+ },
+ "dependencies": {
+ "mute-stream": {
+ "version": "0.0.5",
+ "bundled": true
+ }
+ }
+ },
+ "read-cmd-shim": {
+ "version": "1.0.1",
+ "bundled": true,
+ "requires": {
+ "graceful-fs": "4.1.11"
+ }
+ },
+ "read-installed": {
+ "version": "4.0.3",
+ "bundled": true,
+ "requires": {
+ "debuglog": "1.0.1",
+ "graceful-fs": "4.1.11",
+ "read-package-json": "2.0.5",
+ "readdir-scoped-modules": "1.0.2",
+ "semver": "5.3.0",
+ "slide": "1.1.6",
+ "util-extend": "1.0.3"
+ },
+ "dependencies": {
+ "util-extend": {
+ "version": "1.0.3",
+ "bundled": true
+ }
+ }
+ },
+ "read-package-json": {
+ "version": "2.0.5",
+ "bundled": true,
+ "requires": {
+ "glob": "7.1.1",
+ "graceful-fs": "4.1.11",
+ "json-parse-helpfulerror": "1.0.3",
+ "normalize-package-data": "2.3.8"
+ },
+ "dependencies": {
+ "json-parse-helpfulerror": {
+ "version": "1.0.3",
+ "bundled": true,
+ "requires": {
+ "jju": "1.3.0"
+ },
+ "dependencies": {
+ "jju": {
+ "version": "1.3.0",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "read-package-tree": {
+ "version": "5.1.5",
+ "bundled": true,
+ "requires": {
+ "debuglog": "1.0.1",
+ "dezalgo": "1.0.3",
+ "once": "1.4.0",
+ "read-package-json": "2.0.5",
+ "readdir-scoped-modules": "1.0.2"
+ }
+ },
+ "readable-stream": {
+ "version": "2.2.9",
+ "bundled": true,
+ "requires": {
+ "buffer-shims": "1.0.0",
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "1.0.0",
+ "process-nextick-args": "1.0.7",
+ "string_decoder": "1.0.0",
+ "util-deprecate": "1.0.2"
+ },
+ "dependencies": {
+ "buffer-shims": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "process-nextick-args": {
+ "version": "1.0.7",
+ "bundled": true
+ },
+ "string_decoder": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "buffer-shims": "1.0.0"
+ }
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "bundled": true
+ }
+ }
+ },
+ "readdir-scoped-modules": {
+ "version": "1.0.2",
+ "bundled": true,
+ "requires": {
+ "debuglog": "1.0.1",
+ "dezalgo": "1.0.3",
+ "graceful-fs": "4.1.11",
+ "once": "1.4.0"
+ }
+ },
+ "realize-package-specifier": {
+ "version": "3.0.3",
+ "bundled": true,
+ "requires": {
+ "dezalgo": "1.0.3",
+ "npm-package-arg": "4.2.1"
+ }
+ },
+ "request": {
+ "version": "2.81.0",
+ "bundled": true,
+ "requires": {
+ "aws-sign2": "0.6.0",
+ "aws4": "1.6.0",
+ "caseless": "0.12.0",
+ "combined-stream": "1.0.5",
+ "extend": "3.0.0",
+ "forever-agent": "0.6.1",
+ "form-data": "2.1.2",
+ "har-validator": "4.2.1",
+ "hawk": "3.1.3",
+ "http-signature": "1.1.1",
+ "is-typedarray": "1.0.0",
+ "isstream": "0.1.2",
+ "json-stringify-safe": "5.0.1",
+ "mime-types": "2.1.14",
+ "oauth-sign": "0.8.2",
+ "performance-now": "0.2.0",
+ "qs": "6.4.0",
+ "safe-buffer": "5.0.1",
+ "stringstream": "0.0.5",
+ "tough-cookie": "2.3.2",
+ "tunnel-agent": "0.6.0",
+ "uuid": "3.0.1"
+ },
+ "dependencies": {
+ "aws-sign2": {
+ "version": "0.6.0",
+ "bundled": true
+ },
+ "aws4": {
+ "version": "1.6.0",
+ "bundled": true
+ },
+ "caseless": {
+ "version": "0.12.0",
+ "bundled": true
+ },
+ "combined-stream": {
+ "version": "1.0.5",
+ "bundled": true,
+ "requires": {
+ "delayed-stream": "1.0.0"
+ },
+ "dependencies": {
+ "delayed-stream": {
+ "version": "1.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "extend": {
+ "version": "3.0.0",
+ "bundled": true
+ },
+ "forever-agent": {
+ "version": "0.6.1",
+ "bundled": true
+ },
+ "form-data": {
+ "version": "2.1.2",
+ "bundled": true,
+ "requires": {
+ "asynckit": "0.4.0",
+ "combined-stream": "1.0.5",
+ "mime-types": "2.1.14"
+ },
+ "dependencies": {
+ "asynckit": {
+ "version": "0.4.0",
+ "bundled": true
+ }
+ }
+ },
+ "har-validator": {
+ "version": "4.2.1",
+ "bundled": true,
+ "requires": {
+ "ajv": "4.11.4",
+ "har-schema": "1.0.5"
+ },
+ "dependencies": {
+ "ajv": {
+ "version": "4.11.4",
+ "bundled": true,
+ "requires": {
+ "co": "4.6.0",
+ "json-stable-stringify": "1.0.1"
+ },
+ "dependencies": {
+ "co": {
+ "version": "4.6.0",
+ "bundled": true
+ },
+ "json-stable-stringify": {
+ "version": "1.0.1",
+ "bundled": true,
+ "requires": {
+ "jsonify": "0.0.0"
+ },
+ "dependencies": {
+ "jsonify": {
+ "version": "0.0.0",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "har-schema": {
+ "version": "1.0.5",
+ "bundled": true
+ }
+ }
+ },
+ "hawk": {
+ "version": "3.1.3",
+ "bundled": true,
+ "requires": {
+ "boom": "2.10.1",
+ "cryptiles": "2.0.5",
+ "hoek": "2.16.3",
+ "sntp": "1.0.9"
+ },
+ "dependencies": {
+ "boom": {
+ "version": "2.10.1",
+ "bundled": true,
+ "requires": {
+ "hoek": "2.16.3"
+ }
+ },
+ "cryptiles": {
+ "version": "2.0.5",
+ "bundled": true,
+ "requires": {
+ "boom": "2.10.1"
+ }
+ },
+ "hoek": {
+ "version": "2.16.3",
+ "bundled": true
+ },
+ "sntp": {
+ "version": "1.0.9",
+ "bundled": true,
+ "requires": {
+ "hoek": "2.16.3"
+ }
+ }
+ }
+ },
+ "http-signature": {
+ "version": "1.1.1",
+ "bundled": true,
+ "requires": {
+ "assert-plus": "0.2.0",
+ "jsprim": "1.3.1",
+ "sshpk": "1.11.0"
+ },
+ "dependencies": {
+ "assert-plus": {
+ "version": "0.2.0",
+ "bundled": true
+ },
+ "jsprim": {
+ "version": "1.3.1",
+ "bundled": true,
+ "requires": {
+ "extsprintf": "1.0.2",
+ "json-schema": "0.2.3",
+ "verror": "1.3.6"
+ },
+ "dependencies": {
+ "extsprintf": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "json-schema": {
+ "version": "0.2.3",
+ "bundled": true
+ },
+ "verror": {
+ "version": "1.3.6",
+ "bundled": true,
+ "requires": {
+ "extsprintf": "1.0.2"
+ }
+ }
+ }
+ },
+ "sshpk": {
+ "version": "1.11.0",
+ "bundled": true,
+ "requires": {
+ "asn1": "0.2.3",
+ "assert-plus": "1.0.0",
+ "bcrypt-pbkdf": "1.0.1",
+ "dashdash": "1.14.1",
+ "ecc-jsbn": "0.1.1",
+ "getpass": "0.1.6",
+ "jodid25519": "1.0.2",
+ "jsbn": "0.1.1",
+ "tweetnacl": "0.14.5"
+ },
+ "dependencies": {
+ "asn1": {
+ "version": "0.2.3",
+ "bundled": true
+ },
+ "assert-plus": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "bcrypt-pbkdf": {
+ "version": "1.0.1",
+ "bundled": true,
+ "optional": true,
+ "requires": {
+ "tweetnacl": "0.14.5"
+ }
+ },
+ "dashdash": {
+ "version": "1.14.1",
+ "bundled": true,
+ "requires": {
+ "assert-plus": "1.0.0"
+ }
+ },
+ "ecc-jsbn": {
+ "version": "0.1.1",
+ "bundled": true,
+ "optional": true,
+ "requires": {
+ "jsbn": "0.1.1"
+ }
+ },
+ "getpass": {
+ "version": "0.1.6",
+ "bundled": true,
+ "requires": {
+ "assert-plus": "1.0.0"
+ }
+ },
+ "jodid25519": {
+ "version": "1.0.2",
+ "bundled": true,
+ "optional": true,
+ "requires": {
+ "jsbn": "0.1.1"
+ }
+ },
+ "jsbn": {
+ "version": "0.1.1",
+ "bundled": true,
+ "optional": true
+ },
+ "tweetnacl": {
+ "version": "0.14.5",
+ "bundled": true,
+ "optional": true
+ }
+ }
+ }
+ }
+ },
+ "is-typedarray": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "isstream": {
+ "version": "0.1.2",
+ "bundled": true
+ },
+ "json-stringify-safe": {
+ "version": "5.0.1",
+ "bundled": true
+ },
+ "mime-types": {
+ "version": "2.1.14",
+ "bundled": true,
+ "requires": {
+ "mime-db": "1.26.0"
+ },
+ "dependencies": {
+ "mime-db": {
+ "version": "1.26.0",
+ "bundled": true
+ }
+ }
+ },
+ "oauth-sign": {
+ "version": "0.8.2",
+ "bundled": true
+ },
+ "performance-now": {
+ "version": "0.2.0",
+ "bundled": true
+ },
+ "qs": {
+ "version": "6.4.0",
+ "bundled": true
+ },
+ "safe-buffer": {
+ "version": "5.0.1",
+ "bundled": true
+ },
+ "stringstream": {
+ "version": "0.0.5",
+ "bundled": true
+ },
+ "tough-cookie": {
+ "version": "2.3.2",
+ "bundled": true,
+ "requires": {
+ "punycode": "1.4.1"
+ },
+ "dependencies": {
+ "punycode": {
+ "version": "1.4.1",
+ "bundled": true
+ }
+ }
+ },
+ "tunnel-agent": {
+ "version": "0.6.0",
+ "bundled": true,
+ "requires": {
+ "safe-buffer": "5.0.1"
+ }
+ }
+ }
+ },
+ "retry": {
+ "version": "0.10.1",
+ "bundled": true
+ },
+ "rimraf": {
+ "version": "2.6.1",
+ "bundled": true,
+ "requires": {
+ "glob": "7.1.1"
+ }
+ },
+ "semver": {
+ "version": "5.3.0",
+ "bundled": true
+ },
+ "sha": {
+ "version": "2.0.1",
+ "bundled": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "readable-stream": "2.2.9"
+ }
+ },
+ "slide": {
+ "version": "1.1.6",
+ "bundled": true
+ },
+ "sorted-object": {
+ "version": "2.0.1",
+ "bundled": true
+ },
+ "sorted-union-stream": {
+ "version": "2.1.3",
+ "bundled": true,
+ "requires": {
+ "from2": "1.3.0",
+ "stream-iterate": "1.1.1"
+ },
+ "dependencies": {
+ "from2": {
+ "version": "1.3.0",
+ "bundled": true,
+ "requires": {
+ "inherits": "2.0.3",
+ "readable-stream": "1.1.14"
+ },
+ "dependencies": {
+ "readable-stream": {
+ "version": "1.1.14",
+ "bundled": true,
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "0.0.1",
+ "string_decoder": "0.10.31"
+ },
+ "dependencies": {
+ "core-util-is": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "isarray": {
+ "version": "0.0.1",
+ "bundled": true
+ },
+ "string_decoder": {
+ "version": "0.10.31",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "stream-iterate": {
+ "version": "1.1.1",
+ "bundled": true
+ }
+ }
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "bundled": true,
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "tar": {
+ "version": "2.2.1",
+ "bundled": true,
+ "requires": {
+ "block-stream": "0.0.8",
+ "fstream": "1.0.11",
+ "inherits": "2.0.3"
+ },
+ "dependencies": {
+ "block-stream": {
+ "version": "0.0.8",
+ "bundled": true,
+ "requires": {
+ "inherits": "2.0.3"
+ }
+ }
+ }
+ },
+ "text-table": {
+ "version": "0.2.0",
+ "bundled": true
+ },
+ "uid-number": {
+ "version": "0.0.6",
+ "bundled": true
+ },
+ "umask": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "unique-filename": {
+ "version": "1.1.0",
+ "bundled": true,
+ "requires": {
+ "unique-slug": "2.0.0"
+ },
+ "dependencies": {
+ "unique-slug": {
+ "version": "2.0.0",
+ "bundled": true,
+ "requires": {
+ "imurmurhash": "0.1.4"
+ }
+ }
+ }
+ },
+ "unpipe": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "update-notifier": {
+ "version": "2.1.0",
+ "bundled": true,
+ "requires": {
+ "boxen": "1.0.0",
+ "chalk": "1.1.3",
+ "configstore": "3.0.0",
+ "is-npm": "1.0.0",
+ "latest-version": "3.0.0",
+ "lazy-req": "2.0.0",
+ "semver-diff": "2.1.0",
+ "xdg-basedir": "3.0.0"
+ },
+ "dependencies": {
+ "boxen": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "ansi-align": "1.1.0",
+ "camelcase": "4.0.0",
+ "chalk": "1.1.3",
+ "cli-boxes": "1.0.0",
+ "string-width": "2.0.0",
+ "term-size": "0.1.1",
+ "widest-line": "1.0.0"
+ },
+ "dependencies": {
+ "ansi-align": {
+ "version": "1.1.0",
+ "bundled": true,
+ "requires": {
+ "string-width": "1.0.2"
+ },
+ "dependencies": {
+ "string-width": {
+ "version": "1.0.2",
+ "bundled": true,
+ "requires": {
+ "code-point-at": "1.1.0",
+ "is-fullwidth-code-point": "1.0.0",
+ "strip-ansi": "3.0.1"
+ },
+ "dependencies": {
+ "code-point-at": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "is-fullwidth-code-point": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "number-is-nan": "1.0.1"
+ },
+ "dependencies": {
+ "number-is-nan": {
+ "version": "1.0.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "camelcase": {
+ "version": "4.0.0",
+ "bundled": true
+ },
+ "cli-boxes": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "string-width": {
+ "version": "2.0.0",
+ "bundled": true,
+ "requires": {
+ "is-fullwidth-code-point": "2.0.0",
+ "strip-ansi": "3.0.1"
+ },
+ "dependencies": {
+ "is-fullwidth-code-point": {
+ "version": "2.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "term-size": {
+ "version": "0.1.1",
+ "bundled": true,
+ "requires": {
+ "execa": "0.4.0"
+ },
+ "dependencies": {
+ "execa": {
+ "version": "0.4.0",
+ "bundled": true,
+ "requires": {
+ "cross-spawn-async": "2.2.5",
+ "is-stream": "1.1.0",
+ "npm-run-path": "1.0.0",
+ "object-assign": "4.1.1",
+ "path-key": "1.0.0",
+ "strip-eof": "1.0.0"
+ },
+ "dependencies": {
+ "cross-spawn-async": {
+ "version": "2.2.5",
+ "bundled": true,
+ "requires": {
+ "lru-cache": "4.0.2",
+ "which": "1.2.14"
+ },
+ "dependencies": {
+ "lru-cache": {
+ "version": "4.0.2",
+ "bundled": true,
+ "requires": {
+ "pseudomap": "1.0.2",
+ "yallist": "2.0.0"
+ },
+ "dependencies": {
+ "pseudomap": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "yallist": {
+ "version": "2.0.0",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "is-stream": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "npm-run-path": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "path-key": "1.0.0"
+ }
+ },
+ "object-assign": {
+ "version": "4.1.1",
+ "bundled": true
+ },
+ "path-key": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "strip-eof": {
+ "version": "1.0.0",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "widest-line": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "string-width": "1.0.2"
+ },
+ "dependencies": {
+ "string-width": {
+ "version": "1.0.2",
+ "bundled": true,
+ "requires": {
+ "code-point-at": "1.1.0",
+ "is-fullwidth-code-point": "1.0.0",
+ "strip-ansi": "3.0.1"
+ },
+ "dependencies": {
+ "code-point-at": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "is-fullwidth-code-point": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "number-is-nan": "1.0.1"
+ },
+ "dependencies": {
+ "number-is-nan": {
+ "version": "1.0.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "chalk": {
+ "version": "1.1.3",
+ "bundled": true,
+ "requires": {
+ "ansi-styles": "2.2.1",
+ "escape-string-regexp": "1.0.5",
+ "has-ansi": "2.0.0",
+ "strip-ansi": "3.0.1",
+ "supports-color": "2.0.0"
+ },
+ "dependencies": {
+ "ansi-styles": {
+ "version": "2.2.1",
+ "bundled": true
+ },
+ "escape-string-regexp": {
+ "version": "1.0.5",
+ "bundled": true
+ },
+ "has-ansi": {
+ "version": "2.0.0",
+ "bundled": true,
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "supports-color": {
+ "version": "2.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "configstore": {
+ "version": "3.0.0",
+ "bundled": true,
+ "requires": {
+ "dot-prop": "4.1.1",
+ "graceful-fs": "4.1.11",
+ "mkdirp": "0.5.1",
+ "unique-string": "1.0.0",
+ "write-file-atomic": "1.3.3",
+ "xdg-basedir": "3.0.0"
+ },
+ "dependencies": {
+ "dot-prop": {
+ "version": "4.1.1",
+ "bundled": true,
+ "requires": {
+ "is-obj": "1.0.1"
+ },
+ "dependencies": {
+ "is-obj": {
+ "version": "1.0.1",
+ "bundled": true
+ }
+ }
+ },
+ "unique-string": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "crypto-random-string": "1.0.0"
+ },
+ "dependencies": {
+ "crypto-random-string": {
+ "version": "1.0.0",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "is-npm": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "latest-version": {
+ "version": "3.0.0",
+ "bundled": true,
+ "requires": {
+ "package-json": "3.1.0"
+ },
+ "dependencies": {
+ "package-json": {
+ "version": "3.1.0",
+ "bundled": true,
+ "requires": {
+ "got": "6.7.1",
+ "registry-auth-token": "3.1.0",
+ "registry-url": "3.1.0",
+ "semver": "5.3.0"
+ },
+ "dependencies": {
+ "got": {
+ "version": "6.7.1",
+ "bundled": true,
+ "requires": {
+ "create-error-class": "3.0.2",
+ "duplexer3": "0.1.4",
+ "get-stream": "3.0.0",
+ "is-redirect": "1.0.0",
+ "is-retry-allowed": "1.1.0",
+ "is-stream": "1.1.0",
+ "lowercase-keys": "1.0.0",
+ "safe-buffer": "5.0.1",
+ "timed-out": "4.0.1",
+ "unzip-response": "2.0.1",
+ "url-parse-lax": "1.0.0"
+ },
+ "dependencies": {
+ "create-error-class": {
+ "version": "3.0.2",
+ "bundled": true,
+ "requires": {
+ "capture-stack-trace": "1.0.0"
+ },
+ "dependencies": {
+ "capture-stack-trace": {
+ "version": "1.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "duplexer3": {
+ "version": "0.1.4",
+ "bundled": true
+ },
+ "get-stream": {
+ "version": "3.0.0",
+ "bundled": true
+ },
+ "is-redirect": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "is-retry-allowed": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "is-stream": {
+ "version": "1.1.0",
+ "bundled": true
+ },
+ "lowercase-keys": {
+ "version": "1.0.0",
+ "bundled": true
+ },
+ "safe-buffer": {
+ "version": "5.0.1",
+ "bundled": true
+ },
+ "timed-out": {
+ "version": "4.0.1",
+ "bundled": true
+ },
+ "unzip-response": {
+ "version": "2.0.1",
+ "bundled": true
+ },
+ "url-parse-lax": {
+ "version": "1.0.0",
+ "bundled": true,
+ "requires": {
+ "prepend-http": "1.0.4"
+ },
+ "dependencies": {
+ "prepend-http": {
+ "version": "1.0.4",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "registry-auth-token": {
+ "version": "3.1.0",
+ "bundled": true,
+ "requires": {
+ "rc": "1.1.7"
+ },
+ "dependencies": {
+ "rc": {
+ "version": "1.1.7",
+ "bundled": true,
+ "requires": {
+ "deep-extend": "0.4.1",
+ "ini": "1.3.4",
+ "minimist": "1.2.0",
+ "strip-json-comments": "2.0.1"
+ },
+ "dependencies": {
+ "deep-extend": {
+ "version": "0.4.1",
+ "bundled": true
+ },
+ "minimist": {
+ "version": "1.2.0",
+ "bundled": true
+ },
+ "strip-json-comments": {
+ "version": "2.0.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "registry-url": {
+ "version": "3.1.0",
+ "bundled": true,
+ "requires": {
+ "rc": "1.1.7"
+ },
+ "dependencies": {
+ "rc": {
+ "version": "1.1.7",
+ "bundled": true,
+ "requires": {
+ "deep-extend": "0.4.1",
+ "ini": "1.3.4",
+ "minimist": "1.2.0",
+ "strip-json-comments": "2.0.1"
+ },
+ "dependencies": {
+ "deep-extend": {
+ "version": "0.4.1",
+ "bundled": true
+ },
+ "minimist": {
+ "version": "1.2.0",
+ "bundled": true
+ },
+ "strip-json-comments": {
+ "version": "2.0.1",
+ "bundled": true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "lazy-req": {
+ "version": "2.0.0",
+ "bundled": true
+ },
+ "semver-diff": {
+ "version": "2.1.0",
+ "bundled": true,
+ "requires": {
+ "semver": "5.3.0"
+ }
+ },
+ "xdg-basedir": {
+ "version": "3.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "uuid": {
+ "version": "3.0.1",
+ "bundled": true
+ },
+ "validate-npm-package-license": {
+ "version": "3.0.1",
+ "bundled": true,
+ "requires": {
+ "spdx-correct": "1.0.2",
+ "spdx-expression-parse": "1.0.2"
+ },
+ "dependencies": {
+ "spdx-correct": {
+ "version": "1.0.2",
+ "bundled": true,
+ "requires": {
+ "spdx-license-ids": "1.2.0"
+ },
+ "dependencies": {
+ "spdx-license-ids": {
+ "version": "1.2.0",
+ "bundled": true
+ }
+ }
+ },
+ "spdx-expression-parse": {
+ "version": "1.0.2",
+ "bundled": true,
+ "requires": {
+ "spdx-exceptions": "1.0.4",
+ "spdx-license-ids": "1.2.0"
+ },
+ "dependencies": {
+ "spdx-exceptions": {
+ "version": "1.0.4",
+ "bundled": true
+ },
+ "spdx-license-ids": {
+ "version": "1.2.0",
+ "bundled": true
+ }
+ }
+ }
+ }
+ },
+ "validate-npm-package-name": {
+ "version": "3.0.0",
+ "bundled": true,
+ "requires": {
+ "builtins": "1.0.3"
+ },
+ "dependencies": {
+ "builtins": {
+ "version": "1.0.3",
+ "bundled": true
+ }
+ }
+ },
+ "which": {
+ "version": "1.2.14",
+ "bundled": true,
+ "requires": {
+ "isexe": "2.0.0"
+ },
+ "dependencies": {
+ "isexe": {
+ "version": "2.0.0",
+ "bundled": true
+ }
+ }
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "bundled": true
+ },
+ "write-file-atomic": {
+ "version": "1.3.3",
+ "bundled": true,
+ "requires": {
+ "graceful-fs": "4.1.11",
+ "imurmurhash": "0.1.4",
+ "slide": "1.1.6"
+ }
+ }
+ }
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "dev": true,
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
+ "dev": true
+ },
+ "rimraf": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz",
+ "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
+ "dev": true,
+ "requires": {
+ "glob": "7.1.2"
+ }
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
+ "dev": true
+ }
+ }
+}
diff --git a/publish/package.json b/publish/package.json
index d5c28e9..74d91fb 100644
--- a/publish/package.json
+++ b/publish/package.json
@@ -5,5 +5,8 @@
"devDependencies": {
"ncp": "^2.0.0",
"rimraf": "^2.5.0"
+ },
+ "dependencies": {
+ "npm": "^4.6.1"
}
}
diff --git a/publish/publish.sh b/publish/publish.sh
old mode 100644
new mode 100755
index 8e72704..1e6c9d5
--- a/publish/publish.sh
+++ b/publish/publish.sh
@@ -5,7 +5,7 @@ PACK_DIR=package;
publish() {
cd $PACK_DIR
echo 'Publishing to npm...'
- npm publish *.tgz
+ ../node_modules/.bin/npm publish *.tgz
}
-./pack.sh && publish
\ No newline at end of file
+./pack.sh && publish
diff --git a/src/crypto.android.d.ts b/src/crypto.android.d.ts
index a3a2aaf..060288b 100644
--- a/src/crypto.android.d.ts
+++ b/src/crypto.android.d.ts
@@ -15,11 +15,13 @@ export declare class NSCrypto implements INSCryto {
};
secureSymetricAEADkeyLength(): number;
secureSymetricAEADnonceLength(): number;
- encryptSecureSymetricAEAD(key: string, plaint: string, aad: string, pnonce: string, alg?: string): {
+ encryptSecureSymetricAEAD(key: string, plainb: string, aad: string, pnonce: string, alg?: string): {
cipherb: string;
alg: string;
};
decryptSecureSymetricAEAD(key: string, cipherb: string, aad: string, pnonce: string, alg?: string): string;
+ private initSpongyCastle();
+ private hasServiceProvider(service, provider);
encryptAES256GCM(key: string, plaint: string, aad: string, iv: string, tagLength?: number): {
cipherb: string;
atag: string;
@@ -29,8 +31,11 @@ export declare class NSCrypto implements INSCryto {
decryptRSA(priv_key_pem: string, cipherb: string, padding: string): string;
signRSA(priv_key_pem: string, messageb: string, digest_type: string): string;
verifyRSA(pub_key_pem: string, messageb: string, signatureb: string, digest_type: string): boolean;
- deflate(input: string, alg?: string): string;
- inflate(input: string, alg?: string): string;
+ deflate(input: string): string;
+ inflate(input: string): string;
base64encode(input: string): string;
base64decode(input: string): string;
+ randomUUID(): string;
+ keyWrapAES(wrappingKey: string, key: string): string;
+ keyUnWrapAES(unwrappingKey: string, wrappedkey: string): string;
}
diff --git a/src/crypto.android.ts b/src/crypto.android.ts
index ad77241..07339b3 100644
--- a/src/crypto.android.ts
+++ b/src/crypto.android.ts
@@ -15,18 +15,11 @@ const ByteArrayInputStream = java.io.ByteArrayInputStream;
const Arrays = java.util.Arrays;
const System = java.lang.System;
-const DEFAULT_ENCRYPT_BUFFER_SIZE = 256;
-const SystemNativeCryptoLibrary =
- com.facebook.crypto.util.SystemNativeCryptoLibrary;
-const NativeGCMCipher = com.facebook.crypto.cipher.NativeGCMCipher;
-const NativeGCMCipherOutputStream =
- com.facebook.crypto.streams.NativeGCMCipherOutputStream;
-const NativeGCMCipherInputStream =
- com.facebook.crypto.streams.NativeGCMCipherInputStream;
-const FixedSizeByteArrayOutputStream =
- com.facebook.crypto.streams.FixedSizeByteArrayOutputStream;
-
const X509EncodedKeySpec = java.security.spec.X509EncodedKeySpec;
+const PKCS8EncodedKeySpec = java.security.spec.PKCS8EncodedKeySpec;
+const SecretKeySpec = javax.crypto.spec.SecretKeySpec;
+const cGCMspec: any = javax.crypto.spec;
+const GCMParameterSpec = cGCMspec.GCMParameterSpec;
const KeyFactory = java.security.KeyFactory;
const PrivateKey = java.security.PrivateKey;
const PublicKey = java.security.PublicKey;
@@ -45,6 +38,10 @@ export class NSCrypto implements INSCryto {
min: 768 * 1024 * 2,
max: 768 * 2048 * 2
}
+ },
+ argon2i: {
+ mem_limits: { min: 8192 * 308 * 2, max: 8192 * 436 * 2 },
+ ops_limits: { min: 4, max: 6 }
}
};
@@ -68,7 +65,7 @@ export class NSCrypto implements INSCryto {
if (Object.keys(this._hashTypeLibsodiumNamespace).indexOf(type) === -1) {
throw new Error(`hash type "${type}" not found!`);
}
- input = new java.lang.String(input).getBytes(StandardCharsets.UTF_8);
+ input = Base64.decode(input, Base64.DEFAULT);
Sodium.sodium_init();
let hash_libsodium_namespace = this._hashTypeLibsodiumNamespace[type];
let hash = Array.create(
@@ -106,7 +103,8 @@ export class NSCrypto implements INSCryto {
if (salt) {
_salt = Base64.decode(salt, Base64.DEFAULT);
}
- alg = alg || 'scryptsalsa208sha256';
+ alg = alg || 'argon2i';
+
if (!mem_limits) {
const diff =
this.crypto_pwhash_consts[alg].mem_limits.max -
@@ -124,6 +122,7 @@ export class NSCrypto implements INSCryto {
Sodium.randombytes_uniform(diff + 1); // randombytes_uniform upper_bound is (excluded)
}
+ const derived_key = Array.create('byte', key_size);
if (alg === 'scryptsalsa208sha256') {
if (!salt) {
_salt = Array.create(
@@ -132,7 +131,6 @@ export class NSCrypto implements INSCryto {
);
Sodium.randombytes_buf(_salt, _salt.length);
}
- let derived_key = Array.create('byte', key_size);
if (
Sodium.crypto_pwhash_scryptsalsa208sha256(
derived_key,
@@ -146,16 +144,35 @@ export class NSCrypto implements INSCryto {
) {
throw new Error('deriveSecureKey out of memory');
}
- return {
- key: Base64.encodeToString(derived_key, Base64.DEFAULT),
- salt: Base64.encodeToString(_salt, Base64.DEFAULT),
- ops_limits: ops_limits,
- mem_limits: mem_limits,
- alg: alg
- };
+ } else if (alg === 'argon2i') {
+ if (!salt) {
+ _salt = Array.create('byte', Sodium.crypto_pwhash_saltbytes());
+ Sodium.randombytes_buf(_salt, _salt.length);
+ }
+ if (
+ Sodium.crypto_pwhash(
+ derived_key,
+ key_size,
+ password,
+ password.length,
+ _salt,
+ ops_limits,
+ mem_limits,
+ Sodium.crypto_pwhash_alg_argon2i13()
+ ) !== 0
+ ) {
+ throw new Error('deriveSecureKey out of memory');
+ }
} else {
throw new Error(`deriveSecureKey algorithm "${alg}" not found`);
}
+ return {
+ key: Base64.encodeToString(derived_key, Base64.DEFAULT),
+ salt: Base64.encodeToString(_salt, Base64.DEFAULT),
+ ops_limits: ops_limits,
+ mem_limits: mem_limits,
+ alg: alg
+ };
}
secureSymetricAEADkeyLength(): number {
@@ -167,7 +184,7 @@ export class NSCrypto implements INSCryto {
encryptSecureSymetricAEAD(
key: string,
- plaint: string,
+ plainb: string,
aad: string,
pnonce: string,
alg?: string
@@ -182,24 +199,22 @@ export class NSCrypto implements INSCryto {
}
const key_bytes = Base64.decode(key, Base64.DEFAULT);
- const plaint_bytes = new java.lang.String(plaint).getBytes(
- StandardCharsets.UTF_8
- );
+ const plainb_bytes = Base64.decode(plainb, Base64.DEFAULT);
const cipherb = Array.create(
'byte',
- plaint_bytes.length + Sodium.crypto_aead_chacha20poly1305_ietf_abytes()
+ plainb_bytes.length + Sodium.crypto_aead_chacha20poly1305_ietf_abytes()
);
const clen_p = Array.create('int', 1);
- const ad_bytes = new java.lang.String(aad).getBytes(StandardCharsets.UTF_8);
+ const aad_bytes = Base64.decode(aad, Base64.DEFAULT);
const pnonce_bytes = Base64.decode(pnonce, Base64.DEFAULT);
Sodium.crypto_aead_chacha20poly1305_ietf_encrypt(
cipherb,
clen_p,
- plaint_bytes,
- plaint_bytes.length,
- ad_bytes,
- ad_bytes.length,
+ plainb_bytes,
+ plainb_bytes.length,
+ aad_bytes,
+ aad_bytes.length,
pnonce_bytes,
null,
key_bytes
@@ -229,7 +244,9 @@ export class NSCrypto implements INSCryto {
cipherb_bytes.length - Sodium.crypto_aead_chacha20poly1305_ietf_abytes()
);
const mlen_p = Array.create('int', 1);
- const ad_bytes = new java.lang.String(aad).getBytes(StandardCharsets.UTF_8);
+ const aad_bytes = new java.lang.String(aad).getBytes(
+ StandardCharsets.UTF_8
+ );
const pnonce_bytes = Base64.decode(pnonce, Base64.DEFAULT);
Sodium.crypto_aead_chacha20poly1305_ietf_decrypt(
@@ -237,13 +254,29 @@ export class NSCrypto implements INSCryto {
mlen_p,
cipherb_bytes,
cipherb_bytes.length,
- ad_bytes,
- ad_bytes.length,
+ aad_bytes,
+ aad_bytes.length,
pnonce_bytes,
null,
key_bytes
);
- return new java.lang.String(plaint_bytes, StandardCharsets.UTF_8);
+ return Base64.encodeToString(plaint_bytes, Base64.DEFAULT);
+ }
+
+ private initSpongyCastle() {
+ if (java.security.Security.getProvider('SC') == null) {
+ java.security.Security.addProvider(
+ new org.spongycastle.jce.provider.BouncyCastleProvider()
+ );
+ }
+ }
+
+ private hasServiceProvider(service: string, provider: string) {
+ const _provider = java.security.Security.getProvider(provider);
+ if (provider != null) {
+ if (_provider.getService('Cipher', service) != null) return true;
+ }
+ return false;
}
encryptAES256GCM(
@@ -256,44 +289,66 @@ export class NSCrypto implements INSCryto {
cipherb: string;
atag: string;
} {
- const cipher = new NativeGCMCipher(new SystemNativeCryptoLibrary());
-
const key_bytes = Base64.decode(key, Base64.DEFAULT);
- const plaint_bytes = new java.lang.String(plaint).getBytes(
- StandardCharsets.UTF_8
- );
- const aad_bytes = new java.lang.String(aad).getBytes(
- StandardCharsets.UTF_8
- );
- const iv_bytes = Base64.decode(key, Base64.DEFAULT);
-
- cipher.encryptInit(key_bytes, iv_bytes);
- cipher.updateAad(aad_bytes, aad_bytes.length);
+ const plaint_bytes = Base64.decode(plaint, Base64.DEFAULT);
+ const aad_bytes = Base64.decode(aad, Base64.DEFAULT);
+ const iv_bytes = Base64.decode(iv, Base64.DEFAULT);
+
+ const keyC = new SecretKeySpec(key_bytes, 'AES');
+ this.initSpongyCastle();
+ const cipher: any = Cipher.getInstance('AES/GCM/NoPadding', 'SC');
+ const spec = new GCMParameterSpec(tagLength, iv_bytes);
+ cipher.init(Cipher.ENCRYPT_MODE, keyC, spec);
+ cipher.updateAAD(aad_bytes);
+ let cipherb = cipher.doFinal(plaint_bytes);
- const enc_stream = new FixedSizeByteArrayOutputStream(
- plaint_bytes.length + tagLength
- );
- const cipher_stream = new NativeGCMCipherOutputStream(
- enc_stream,
- cipher,
- null,
- tagLength
- );
- cipher_stream.write(plaint_bytes);
- cipher_stream.close();
- let cipherb = enc_stream.getBytes();
// we will separate the authentication tag from the ciphertext array
const tagb = Arrays.copyOfRange(
cipherb,
- cipherb.length - tagLength - 1,
+ cipherb.length - tagLength / 8,
cipherb.length
);
- cipherb = Arrays.copyOfRange(cipherb, 0, cipherb.length - tagLength);
+ cipherb = Arrays.copyOfRange(cipherb, 0, cipherb.length - tagLength / 8);
return {
cipherb: Base64.encodeToString(cipherb, Base64.DEFAULT),
atag: Base64.encodeToString(tagb, Base64.DEFAULT)
};
+ // const cipher = new NativeGCMCipher(new SystemNativeCryptoLibrary());
+
+ // cipher.encryptInit(key_bytes, iv_bytes);
+ // cipher.updateAad(aad_bytes, aad_bytes.length);
+
+ // const buffer = Array.create('byte', cipher.getCipherBlockSize() + 256);
+ // const content_length = plaint_bytes.length; // + aad_bytes.length + 1024;
+ // const out_stream = new ByteArrayOutputStream(content_length);
+ // const times = Math.floor(content_length / buffer.length);
+ // const remainder = content_length % buffer.length;
+ // let offset = 0;
+
+ // for (let i = 0; i < times; ++i) {
+ // const written = cipher.update(
+ // plaint_bytes,
+ // offset,
+ // buffer.length,
+ // buffer,
+ // 0
+ // );
+ // out_stream.write(buffer, 0, written);
+ // offset += buffer.length;
+ // }
+ // if (remainder > 0) {
+ // const written = cipher.update(plaint_bytes, offset, remainder, buffer, 0);
+ // out_stream.write(buffer, 0, written);
+ // }
+
+ // const tag = Array.create('byte', tagLength / 8);
+ // cipher.encryptFinal(tag, tag.length);
+
+ // return {
+ // cipherb: Base64.encodeToString(out_stream.toByteArray(), Base64.DEFAULT),
+ // atag: Base64.encodeToString(tag, Base64.DEFAULT)
+ // };
}
decryptAES256GCM(
key: string,
@@ -302,21 +357,20 @@ export class NSCrypto implements INSCryto {
iv: string,
atag: string
): string {
- const cipher = new NativeGCMCipher(new SystemNativeCryptoLibrary());
-
const key_bytes = Base64.decode(key, Base64.DEFAULT);
const cipherb_bytes = Base64.decode(cipherb, Base64.DEFAULT);
- const iv_bytes = Base64.decode(key, Base64.DEFAULT);
+ const aad_bytes = Base64.decode(aad, Base64.DEFAULT);
+ const iv_bytes = Base64.decode(iv, Base64.DEFAULT);
const atag_bytes = Base64.decode(atag, Base64.DEFAULT);
- const aad_bytes = new java.lang.String(aad).getBytes(
- StandardCharsets.UTF_8
- );
-
- const cleart_bytes = Array.create('byte', cipherb_bytes.length);
+ const plainb_bytes = Array.create('byte', cipherb_bytes.length);
- cipher.decryptInit(key_bytes, iv_bytes);
- cipher.updateAad(aad_bytes, aad_bytes.length);
+ const keyC = new SecretKeySpec(key_bytes, 'AES');
+ this.initSpongyCastle();
+ const cipher: any = Cipher.getInstance('AES/GCM/NoPadding', 'SC');
+ const spec = new GCMParameterSpec(atag_bytes.length * 8, iv_bytes);
+ cipher.init(Cipher.DECRYPT_MODE, keyC, spec);
+ cipher.updateAAD(aad_bytes);
// we will concat the authentication tag to the ciphertext array
const cipherb_bytes_complete = Array.create(
@@ -338,14 +392,44 @@ export class NSCrypto implements INSCryto {
atag_bytes.length
);
- const dec_stream = new ByteArrayInputStream(cipherb_bytes_complete);
- const cipher_stream = new NativeGCMCipherInputStream(
- dec_stream,
- atag_bytes.length
- );
- cipher_stream.read(cleart_bytes);
- cipher_stream.close();
- return new java.lang.String(cleart_bytes, StandardCharsets.UTF_8);
+ let plaint_bytes = cipher.doFinal(cipherb_bytes_complete);
+
+ // const cipher = new NativeGCMCipher(new SystemNativeCryptoLibrary());
+
+ // cipher.decryptInit(key_bytes, iv_bytes);
+ // cipher.updateAad(aad_bytes, aad_bytes.length);
+
+ // const buffer = Array.create('byte', cipher.getCipherBlockSize() + 256);
+ // const content_length = cipherb_bytes.length; // + aad_bytes.length + 1024;
+ // const out_stream = new ByteArrayOutputStream(content_length);
+ // const times = Math.floor(content_length / buffer.length);
+ // const remainder = content_length % buffer.length;
+ // let offset = 0;
+ // for (let i = 0; i < times; ++i) {
+ // const written = cipher.update(
+ // cipherb_bytes,
+ // offset,
+ // buffer.length,
+ // buffer,
+ // 0
+ // );
+ // out_stream.write(buffer, 0, written);
+ // offset += buffer.length;
+ // }
+ // if (remainder > 0) {
+ // const written = cipher.update(
+ // cipherb_bytes,
+ // offset,
+ // remainder,
+ // buffer,
+ // 0
+ // );
+ // out_stream.write(buffer, 0, written);
+ // }
+
+ // cipher.decryptFinal(atag_bytes, atag_bytes.length);
+ // return Base64.encodeToString(out_stream.toByteArray(), Base64.DEFAULT);
+ return Base64.encodeToString(plaint_bytes, Base64.DEFAULT);
}
encryptRSA(pub_key_pem: string, plainb: string, padding: string): string {
@@ -361,10 +445,13 @@ export class NSCrypto implements INSCryto {
return Base64.encodeToString(encrypted, Base64.DEFAULT);
}
decryptRSA(priv_key_pem: string, cipherb: string, padding: string): string {
- priv_key_pem = priv_key_pem.replace('-----BEGIN PUBLIC KEY-----\n', '');
- priv_key_pem = priv_key_pem.replace('-----END PUBLIC KEY-----', '');
+ priv_key_pem = priv_key_pem.replace(
+ '-----BEGIN RSA PRIVATE KEY-----\n',
+ ''
+ );
+ priv_key_pem = priv_key_pem.replace('-----END RSA PRIVATE KEY-----', '');
let privateKeyBytes = Base64.decode(priv_key_pem, Base64.DEFAULT);
- let keySpec = new X509EncodedKeySpec(privateKeyBytes);
+ let keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
let keyFactory = KeyFactory.getInstance('RSA');
let privKey = keyFactory.generatePrivate(keySpec);
let cipher = Cipher.getInstance(this.rsaEncPaddingType[padding]); // or try with "RSA"
@@ -373,10 +460,13 @@ export class NSCrypto implements INSCryto {
return Base64.encodeToString(paintb, Base64.DEFAULT);
}
signRSA(priv_key_pem: string, messageb: string, digest_type: string): string {
- priv_key_pem = priv_key_pem.replace('-----BEGIN PUBLIC KEY-----\n', '');
- priv_key_pem = priv_key_pem.replace('-----END PUBLIC KEY-----', '');
+ priv_key_pem = priv_key_pem.replace(
+ '-----BEGIN RSA PRIVATE KEY-----\n',
+ ''
+ );
+ priv_key_pem = priv_key_pem.replace('-----END RSA PRIVATE KEY-----', '');
let privateKeyBytes = Base64.decode(priv_key_pem, Base64.DEFAULT);
- let keySpec = new X509EncodedKeySpec(privateKeyBytes);
+ let keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
let keyFactory = KeyFactory.getInstance('RSA');
let privKey = keyFactory.generatePrivate(keySpec);
let signature = Signature.getInstance(this.rsaSigDigestType[digest_type]);
@@ -403,18 +493,18 @@ export class NSCrypto implements INSCryto {
return signature.verify(Base64.decode(signatureb, Base64.DEFAULT));
}
- deflate(input: string, alg?: string): string {
- let data = new java.lang.String(input).getBytes(StandardCharsets.UTF_8);
+ deflate(input: string): string {
+ let data = Base64.decode(input, Base64.DEFAULT);
let output = Array.create('byte', data.length);
let compresser = new java.util.zip.Deflater();
- compresser.setInput(input);
+ compresser.setInput(data, 0, data.length);
compresser.finish();
let compressedDataLength = compresser.deflate(output);
compresser.end();
output = Arrays.copyOf(output, compressedDataLength);
return Base64.encodeToString(output, Base64.DEFAULT);
}
- inflate(input: string, alg?: string): string {
+ inflate(input: string): string {
let data = Base64.decode(input, Base64.DEFAULT);
let decompresser = new java.util.zip.Inflater();
decompresser.setInput(data, 0, data.length);
@@ -422,7 +512,7 @@ export class NSCrypto implements INSCryto {
let decompressedDataLength = decompresser.inflate(output);
decompresser.end();
output = Arrays.copyOf(output, decompressedDataLength);
- return new java.lang.String(output, StandardCharsets.UTF_8);
+ return Base64.encodeToString(output, Base64.DEFAULT);
}
base64encode(input: string): string {
@@ -434,4 +524,44 @@ export class NSCrypto implements INSCryto {
let data = Base64.decode(input, Base64.DEFAULT);
return new java.lang.String(data, StandardCharsets.UTF_8);
}
+
+ randomUUID(): string {
+ return java.util.UUID.randomUUID().toString();
+ }
+
+ keyWrapAES(wrappingKey: string, key: string): string {
+ const wrappingKeyData = Base64.decode(wrappingKey, Base64.DEFAULT);
+ const keyData = Base64.decode(key, Base64.DEFAULT);
+ let cipher;
+ if (this.hasServiceProvider('AESWrap', 'BC')) {
+ cipher = Cipher.getInstance('AESWrap', 'BC');
+ } else {
+ this.initSpongyCastle();
+ cipher = Cipher.getInstance('AESWrap', 'SC');
+ }
+ cipher.init(Cipher.WRAP_MODE, new SecretKeySpec(wrappingKeyData, 'AES'));
+ return Base64.encodeToString(
+ cipher.wrap(new SecretKeySpec(keyData, 'AES')),
+ Base64.DEFAULT
+ );
+ }
+ keyUnWrapAES(unwrappingKey: string, wrappedkey: string): string {
+ const unwrappingKeyData = Base64.decode(unwrappingKey, Base64.DEFAULT);
+ const wrappedkeyData = Base64.decode(wrappedkey, Base64.DEFAULT);
+ let cipher;
+ if (this.hasServiceProvider('AESWrap', 'BC')) {
+ cipher = Cipher.getInstance('AESWrap', 'BC');
+ } else {
+ this.initSpongyCastle();
+ cipher = Cipher.getInstance('AESWrap', 'SC');
+ }
+ cipher.init(
+ Cipher.UNWRAP_MODE,
+ new SecretKeySpec(unwrappingKeyData, 'AES')
+ );
+ return Base64.encodeToString(
+ cipher.unwrap(wrappedkeyData, 'AES', Cipher.SECRET_KEY).getEncoded(),
+ Base64.DEFAULT
+ );
+ }
}
diff --git a/src/crypto.common.d.ts b/src/crypto.common.d.ts
index 349816e..b0125c3 100644
--- a/src/crypto.common.d.ts
+++ b/src/crypto.common.d.ts
@@ -24,8 +24,11 @@ export interface INSCryto {
decryptRSA(priv_key_pem: string, cipherb: string, padding: string): string;
signRSA(priv_key_pem: string, messageb: string, digest_type: string): string;
verifyRSA(pub_key_pem: string, messageb: string, signatureb: string, digest_type: string): boolean;
- deflate(input: string, alg?: string): string;
- inflate(input: string, alg?: string): string;
+ deflate(input: string): string;
+ inflate(input: string): string;
base64encode(input: string): string;
base64decode(input: string): string;
+ randomUUID(): string;
+ keyWrapAES(wrappingKey: string, key: string): string;
+ keyUnWrapAES(unwrappingKey: string, wrappedkey: string): string;
}
diff --git a/src/crypto.common.ts b/src/crypto.common.ts
index c82f90c..fdae3d5 100644
--- a/src/crypto.common.ts
+++ b/src/crypto.common.ts
@@ -61,8 +61,11 @@ export interface INSCryto {
signatureb: string,
digest_type: string
): boolean;
- deflate(input: string, alg?: string): string;
- inflate(input: string, alg?: string): string;
+ deflate(input: string): string;
+ inflate(input: string): string;
base64encode(input: string): string;
base64decode(input: string): string;
+ randomUUID(): string;
+ keyWrapAES(wrappingKey: string, key: string): string;
+ keyUnWrapAES(unwrappingKey: string, wrappedkey: string): string;
}
diff --git a/src/crypto.ios.d.ts b/src/crypto.ios.d.ts
index 32ab8dd..ca73d55 100644
--- a/src/crypto.ios.d.ts
+++ b/src/crypto.ios.d.ts
@@ -1,9 +1,8 @@
import { INSCryto } from './crypto.common';
export declare class NSCrypto implements INSCryto {
private crypto_pwhash_consts;
- private hashTypeLibsodiumFn;
private rsaEncPaddingType;
- private rsaSigDigestType;
+ private digestType;
hash(input: string, type: string): string;
secureRandomBytes(length: number): string;
deriveSecureKey(password: string, key_size: number, salt?: string, ops_limits?: number, mem_limits?: number, alg?: string): {
@@ -15,12 +14,12 @@ export declare class NSCrypto implements INSCryto {
};
secureSymetricAEADkeyLength(): number;
secureSymetricAEADnonceLength(): number;
- encryptSecureSymetricAEAD(key: string, plaint: string, aad: string, pnonce: string, alg?: string): {
+ encryptSecureSymetricAEAD(key: string, plainb: string, aad: string, pnonce: string, alg?: string): {
cipherb: string;
alg: string;
};
decryptSecureSymetricAEAD(key: string, cipherb: string, aad: string, pnonce: string, alg?: string): string;
- encryptAES256GCM(key: string, plaint: string, aad: string, iv: string, tagLength?: number): {
+ encryptAES256GCM(key: string, plainb: string, aad: string, iv: string, tagLength?: number): {
cipherb: string;
atag: string;
};
@@ -33,4 +32,7 @@ export declare class NSCrypto implements INSCryto {
inflate(input: string, alg?: string): string;
base64encode(input: string): string;
base64decode(input: string): string;
+ randomUUID(): string;
+ keyWrapAES(wrappingKey: string, key: string): string;
+ keyUnWrapAES(unwrappingKey: string, wrappedkey: string): string;
}
diff --git a/src/crypto.ios.ts b/src/crypto.ios.ts
index 231321b..c703bb8 100644
--- a/src/crypto.ios.ts
+++ b/src/crypto.ios.ts
@@ -27,15 +27,28 @@ declare var crypto_aead_chacha20poly1305_ietf_npubbytes: any;
declare var IAGAesGcm: any;
declare var IAGCipheredData: any;
-declare var cipheredDataByAuthenticatedEncryptingPlainDataWithAdditionalAuthenticatedDataAuthenticationTagLengthInitializationVectorKeyError: any;
-declare var plainDataByAuthenticatedDecryptingCipheredDataWithAdditionalAuthenticatedDataInitializationVectorKeyError: any;
-
declare var ClearMessage: any;
declare var EncryptedMessage: any;
declare var PrivateKey: any;
declare var PublicKey: any;
declare var DigestType: any;
declare var Signature: any;
+declare var IAGAuthenticationTagLength128: any;
+
+declare var DataCompression: any;
+
+declare var SwKeyWrap: any;
+declare var SwCC: any;
+declare var SwCC_OpMode: any;
+declare var SwCC_Algorithm: any;
+declare var SwCC_AuthBlockMode: any;
+
+declare var SwRSA: any;
+declare var SwKeyConvert_PublicKey: any;
+declare var SwKeyConvert_PrivateKey: any;
+declare var SwRSA_AsymmetricPadding: any;
+declare var SwCC_DigestAlgorithm: any;
+declare var SwRSA_AsymmetricSAPadding: any;
const toBase64 = (input: interop.Pointer, length: number): string => {
const data = NSData.dataWithBytesLength(input, length);
@@ -58,67 +71,44 @@ const base64toBytes = (
export class NSCrypto implements INSCryto {
private crypto_pwhash_consts = {
scryptsalsa208sha256: {
- mem_limits: {
- min: 8192 * 7168,
- max: 8192 * 9126
- },
- ops_limits: {
- min: 768 * 512,
- max: 768 * 768
- }
+ mem_limits: { min: 8192 * 7168, max: 8192 * 9126 },
+ ops_limits: { min: 768 * 512, max: 768 * 768 }
},
argon2i: {
- mem_limits: {
- min: 8192 * 308,
- max: 8192 * 436
- },
- ops_limits: {
- min: 4,
- max: 6
- }
- }
- };
-
- private hashTypeLibsodiumFn = {
- sha256: {
- hashFn: crypto_hash_sha256,
- bytesFn: crypto_hash_sha256_bytes
- },
- sha512: {
- hashFn: crypto_hash_sha512,
- bytesFn: crypto_hash_sha512_bytes
+ mem_limits: { min: 8192 * 308, max: 8192 * 436 },
+ ops_limits: { min: 4, max: 6 }
}
};
private rsaEncPaddingType = {
- pkcs1: SecPadding.kSecPaddingPKCS1,
- oaep: SecPadding.kSecPaddingOAEP
+ pkcs1: SwRSA_AsymmetricPadding.Pkcs1,
+ oaep: SwRSA_AsymmetricPadding.Oaep
};
- private rsaSigDigestType = {
- sha1: DigestType.Sha1,
- sha256: DigestType.Sha256,
- sha512: DigestType.Sha512
+ private digestType = {
+ sha1: SwCC_DigestAlgorithm.Sha1,
+ sha256: SwCC_DigestAlgorithm.Sha256,
+ sha512: SwCC_DigestAlgorithm.Sha512
};
hash(input: string, type: string): string {
- if (Object.keys(this.hashTypeLibsodiumFn).indexOf(type) === -1) {
+ if (Object.keys(this.digestType).indexOf(type) === -1) {
throw new Error(`hash type "${type}" not found!`);
}
- sodium_init();
- let hash_libsodium_fns = this.hashTypeLibsodiumFn[type];
- let hash = interop.alloc(
- hash_libsodium_fns.bytesFn() * interop.sizeof(interop.types.unichar)
- );
- hash_libsodium_fns.hashFn(hash, input, input.length);
- return toBase64(hash, hash_libsodium_fns.bytesFn());
+ let inputData: NSData = new NSData({
+ base64EncodedString: input,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
+ });
+ return SwCC.digestAlg(
+ inputData,
+ this.digestType[type]
+ ).base64EncodedStringWithOptions(kNilOptions);
}
secureRandomBytes(length: number): string {
- sodium_init();
- let bytes = interop.alloc(length * interop.sizeof(interop.types.unichar));
- randombytes_buf(bytes, length);
- return toBase64(bytes, length);
+ return SwCC.generateRandom(length).base64EncodedStringWithOptions(
+ kNilOptions
+ );
}
deriveSecureKey(
@@ -147,23 +137,10 @@ export class NSCrypto implements INSCryto {
salt_data.getBytes(_salt);
}
alg = alg || 'argon2i';
-
- let crypto_pwhash_fn = crypto_pwhash_argon2i;
- let crypto_pwhash_saltbytes_fn = crypto_pwhash_argon2i_saltbytes;
-
- if (alg === 'scryptsalsa208sha256') {
- // conversion needed crypto_pwhash_scryptsalsa208sha256 dont have alg parameter
- crypto_pwhash_fn = function() {
- let new_args = [];
- for (let i = 0; i < arguments.length - 1; i++) {
- new_args.push(arguments[i]);
- }
- return crypto_pwhash_scryptsalsa208sha256(...new_args);
- };
- crypto_pwhash_saltbytes_fn = crypto_pwhash_scryptsalsa208sha256_saltbytes;
- } else if (alg !== 'argon2i') {
+ if (['argon2i', 'scryptsalsa208sha256'].indexOf(alg) === -1) {
throw new Error(`deriveSecureKey algorithm "${alg}" not found`);
}
+
if (!mem_limits) {
let diff =
this.crypto_pwhash_consts[alg].mem_limits.max -
@@ -182,7 +159,11 @@ export class NSCrypto implements INSCryto {
}
if (_salt_length === -1) {
- _salt_length = crypto_pwhash_saltbytes_fn();
+ if (alg === 'argon2i') {
+ _salt_length = crypto_pwhash_argon2i_saltbytes();
+ } else if (alg === 'argon2i') {
+ _salt_length = crypto_pwhash_scryptsalsa208sha256_saltbytes();
+ }
_salt = interop.alloc(
_salt_length * interop.sizeof(interop.types.unichar)
);
@@ -191,19 +172,36 @@ export class NSCrypto implements INSCryto {
let derived_key = interop.alloc(
key_size * interop.sizeof(interop.types.unichar)
);
- if (
- crypto_pwhash_fn(
- derived_key,
- key_size,
- password,
- password.length,
- _salt,
- ops_limits,
- mem_limits,
- crypto_pwhash_alg_argon2i13()
- ) !== 0
- ) {
- throw new Error('deriveSecureKey out of memory');
+
+ if (alg === 'argon2i') {
+ if (
+ crypto_pwhash_argon2i(
+ derived_key,
+ key_size,
+ password,
+ password.length,
+ _salt,
+ ops_limits,
+ mem_limits,
+ crypto_pwhash_alg_argon2i13()
+ ) !== 0
+ ) {
+ throw new Error('deriveSecureKey out of memory');
+ }
+ } else if (alg === 'scryptsalsa208sha256') {
+ if (
+ crypto_pwhash_scryptsalsa208sha256(
+ derived_key,
+ key_size,
+ password,
+ password.length,
+ _salt,
+ ops_limits,
+ mem_limits
+ ) !== 0
+ ) {
+ throw new Error('deriveSecureKey out of memory');
+ }
}
return {
key: toBase64(derived_key, key_size),
@@ -227,55 +225,57 @@ export class NSCrypto implements INSCryto {
}
encryptSecureSymetricAEAD(
key: string,
- plaint: string,
+ plainb: string,
aad: string,
pnonce: string,
alg?: string
): { cipherb: string; alg: string } {
- let ciphert;
+ let cipherb;
let cipherb_length = new interop.Reference();
+ let dataPlainb = base64toBytes(plainb);
+ let dataAAD = base64toBytes(aad);
if (
crypto_aead_aes256gcm_is_available() !== 0 &&
(alg === 'aes256gcm' || !alg)
) {
- ciphert = interop.alloc(
- (plaint.length + crypto_aead_aes256gcm_abytes()) *
+ cipherb = interop.alloc(
+ (dataPlainb.length + crypto_aead_aes256gcm_abytes()) *
interop.sizeof(interop.types.unichar)
);
crypto_aead_aes256gcm_encrypt(
- ciphert,
+ cipherb,
cipherb_length,
- plaint,
- plaint.length,
- aad,
- aad.length,
+ dataPlainb.bytes,
+ dataPlainb.length,
+ dataAAD.bytes,
+ dataAAD.length,
null,
base64toBytes(pnonce).bytes,
base64toBytes(key).bytes
);
return {
- cipherb: toBase64(ciphert, cipherb_length.value),
+ cipherb: toBase64(cipherb, cipherb_length.value),
alg: 'aes256gcm'
};
} else if (alg === 'chacha20poly1305_ietf' || !alg) {
- ciphert = interop.alloc(
- (plaint.length + crypto_aead_chacha20poly1305_ietf_abytes()) *
+ cipherb = interop.alloc(
+ (plainb.length + crypto_aead_chacha20poly1305_ietf_abytes()) *
interop.sizeof(interop.types.unichar)
);
crypto_aead_chacha20poly1305_ietf_encrypt(
- ciphert,
+ cipherb,
cipherb_length,
- plaint,
- plaint.length,
- aad,
- aad.length,
+ dataPlainb.bytes,
+ dataPlainb.length,
+ dataAAD.bytes,
+ dataAAD.length,
null,
base64toBytes(pnonce).bytes,
base64toBytes(key).bytes
);
return {
- cipherb: toBase64(ciphert, cipherb_length.value),
+ cipherb: toBase64(cipherb, cipherb_length.value),
alg: 'chacha20poly1305_ietf'
};
} else {
@@ -291,21 +291,21 @@ export class NSCrypto implements INSCryto {
pnonce: string,
alg?: string
): string {
- let plaint: interop.Pointer;
- let plaint_length = new interop.Reference();
+ let plainb: interop.Pointer;
+ let plainb_length = new interop.Reference();
if (
crypto_aead_aes256gcm_is_available() !== 0 &&
(alg === 'aes256gcm' || !alg)
) {
let cipherb_p = base64toBytes(cipherb);
- plaint = interop.alloc(
+ plainb = interop.alloc(
(cipherb_p.length - crypto_aead_chacha20poly1305_ietf_abytes()) *
interop.sizeof(interop.types.unichar)
);
crypto_aead_aes256gcm_decrypt(
- plaint,
- plaint_length,
+ plainb,
+ plainb_length,
cipherb_p,
cipherb_p.length,
aad,
@@ -315,12 +315,12 @@ export class NSCrypto implements INSCryto {
base64toBytes(key).bytes
);
} else if (alg === 'chacha20poly1305_ietf' || !alg) {
- plaint = interop.alloc(
+ plainb = interop.alloc(
cipherb.length * interop.sizeof(interop.types.unichar)
);
crypto_aead_chacha20poly1305_ietf_decrypt(
- plaint,
- plaint_length,
+ plainb,
+ plainb_length,
cipherb,
cipherb.length,
aad,
@@ -334,52 +334,38 @@ export class NSCrypto implements INSCryto {
`decryptSecureSymetricAEAD algorith ${alg} not found or is not available in this hardware`
);
}
- return new NSString({
- bytes: plaint,
- length: plaint_length.value,
- encoding: NSUTF8StringEncoding
- });
+ return toBase64(plainb, plainb_length.value);
}
encryptAES256GCM(
key: string,
- plaint: string,
+ plainb: string,
aad: string,
iv: string,
tagLength: number = 128
- ): {
- cipherb: string;
- atag: string;
- } {
- let plaintData: NSData = new NSString({
- UTF8String: plaint
- }).dataUsingEncoding(NSUTF8StringEncoding);
- let aadData: NSData = new NSString({
- UTF8String: aad
- }).dataUsingEncoding(NSUTF8StringEncoding);
- let ivData = new NSData({
- base64EncodedString: iv,
- options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
- });
- let keyData = new NSData({
- base64EncodedString: key,
- options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
- });
- let cipheredData = cipheredDataByAuthenticatedEncryptingPlainDataWithAdditionalAuthenticatedDataAuthenticationTagLengthInitializationVectorKeyError(
+ ): { cipherb: string; atag: string } {
+ let plaintData = new NSData({ base64Encoding: plainb });
+ let aadData = new NSData({ base64Encoding: aad });
+ let ivData = new NSData({ base64Encoding: iv });
+ let keyData = new NSData({ base64Encoding: key });
+
+ let res = SwCC.cryptAuthBlockModeAlgorithmDataADataKeyIvTagLengthTagError(
+ SwCC_OpMode.Encrypt,
+ SwCC_AuthBlockMode.Gcm,
+ SwCC_Algorithm.Aes,
plaintData,
aadData,
+ keyData,
ivData,
- keyData
+ tagLength / 8,
+ null
);
+
return {
- cipherb: toBase64(
- cipheredData.cipheredBuffer,
- cipheredData.cipheredBufferLength
- ),
- atag: toBase64(
- cipheredData.authenticationTag,
- cipheredData.authenticationTagLength
- )
+ cipherb: res
+ .valueForKey('data')
+ .base64EncodedStringWithOptions(kNilOptions),
+ atag: res.valueForKey('tag').base64EncodedStringWithOptions(kNilOptions)
};
}
decryptAES256GCM(
@@ -389,17 +375,18 @@ export class NSCrypto implements INSCryto {
iv: string,
atag: string
): string {
- let cipherb_p = base64toBytes(cipherb);
- let atag_p = base64toBytes(cipherb);
- let cipheredData = new IAGCipheredData({
- cipheredBuffer: cipherb_p.bytes,
- cipheredBufferLength: cipherb_p.length,
- authenticationTag: atag_p.bytes,
- authenticationTagLength: atag_p.length
+ let cipherbData: NSData = new NSData({
+ base64EncodedString: cipherb,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
+ });
+ let atagData: NSData = new NSData({
+ base64EncodedString: atag,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
+ });
+ let aadData: NSData = new NSData({
+ base64EncodedString: aad,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
});
- let aadData: NSData = new NSString({
- UTF8String: aad
- }).dataUsingEncoding(NSUTF8StringEncoding);
let ivData = new NSData({
base64EncodedString: iv,
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
@@ -409,133 +396,145 @@ export class NSCrypto implements INSCryto {
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
});
- let plaintData = plainDataByAuthenticatedDecryptingCipheredDataWithAdditionalAuthenticatedDataInitializationVectorKeyError(
- cipheredData,
+ let res = SwCC.cryptAuthBlockModeAlgorithmDataADataKeyIvTagLengthTagError(
+ SwCC_OpMode.Decrypt,
+ SwCC_AuthBlockMode.Gcm,
+ SwCC_Algorithm.Aes,
+ cipherbData,
aadData,
+ keyData,
ivData,
- keyData
+ atagData.length,
+ atagData
);
- return new NSString({
- data: plaintData,
- encoding: NSUTF8StringEncoding
- });
+ return res.valueForKey('data').base64EncodedStringWithOptions(kNilOptions);
}
encryptRSA(pub_key_pem: string, plainb: string, padding: string): string {
if (Object.keys(this.rsaEncPaddingType).indexOf(padding) === -1) {
throw new Error(`encryptRSA padding "${padding}" not found!`);
}
- let pubKey = new PublicKey({ pemEncoded: pub_key_pem });
- let clearMessage = new ClearMessage({
- base64Encoded: plainb
+ let plainbData: NSData = new NSData({
+ base64EncodedString: plainb,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
});
- let encryptedMessage = clearMessage.encryptedWithPaddingError(
- pubKey,
- SecPadding.kSecPaddingOAEP
- );
- return encryptedMessage.base64String;
+ const derKey = SwKeyConvert_PublicKey.pemToPKCS1DERError(pub_key_pem);
+ return SwRSA.encryptDerKeyTagPaddingDigestError(
+ plainbData,
+ derKey,
+ null,
+ this.rsaEncPaddingType[padding],
+ SwCC_DigestAlgorithm.Sha1
+ ).base64EncodedStringWithOptions(kNilOptions);
}
decryptRSA(priv_key_pem: string, cipherb: string, padding: string): string {
if (Object.keys(this.rsaEncPaddingType).indexOf(padding) === -1) {
throw new Error(`decryptRSA padding "${padding}" not found!`);
}
- let privKey = new PrivateKey({ pemEncoded: priv_key_pem });
- let encryptedMessage = new EncryptedMessage({
- base64Encoded: cipherb
+ let cipherbData: NSData = new NSData({
+ base64EncodedString: cipherb,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
});
- let clearMessage = encryptedMessage.decryptedWithPaddingError(
- privKey,
- SecPadding.kSecPaddingOAEP
- );
- return clearMessage.base64String;
+ const derKey = SwKeyConvert_PrivateKey.pemToPKCS1DERError(priv_key_pem);
+ return SwRSA.decryptDerKeyTagPaddingDigestError(
+ cipherbData,
+ derKey,
+ null,
+ this.rsaEncPaddingType[padding],
+ SwCC_DigestAlgorithm.Sha1
+ ).base64EncodedStringWithOptions(kNilOptions);
}
+
signRSA(priv_key_pem: string, messageb: string, digest_type: string): string {
- if (Object.keys(this.rsaSigDigestType).indexOf(digest_type) === -1) {
- throw new Error(`decryptRSA digest type "${digest_type}" not found!`);
+ if (Object.keys(this.digestType).indexOf(digest_type) === -1) {
+ throw new Error(`signRSA digest type "${digest_type}" not found!`);
}
- let privKey = new PrivateKey({ pemEncoded: priv_key_pem });
- let clearMessage = new ClearMessage({
- base64Encoded: messageb
+ let messagebData: NSData = new NSData({
+ base64EncodedString: messageb,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
});
- let signature = clearMessage.signedWithDigestTypeError(
- privKey,
- this.rsaSigDigestType[digest_type]
- );
- return signature.base64String;
+ const derKey = SwKeyConvert_PrivateKey.pemToPKCS1DERError(priv_key_pem);
+ return SwRSA.signDerKeyPaddingDigestSaltLenError(
+ messagebData,
+ derKey,
+ SwRSA_AsymmetricSAPadding.Pkcs15,
+ SwCC_DigestAlgorithm.Sha256,
+ 0,
+ null
+ ).base64EncodedStringWithOptions(kNilOptions);
+ // let privKey = new PrivateKey({ pemEncoded: priv_key_pem });
+ // let clearMessage = new ClearMessage({
+ // base64Encoded: messageb
+ // });
+ // let signature = clearMessage.signedWithDigestTypeError(
+ // privKey,
+ // this.rsaSigDigestType[digest_type]
+ // );
+ // return signature.base64String;
}
+
verifyRSA(
pub_key_pem: string,
messageb: string,
signatureb: string,
digest_type: string
): boolean {
- if (Object.keys(this.rsaSigDigestType).indexOf(digest_type) === -1) {
- throw new Error(`decryptRSA digest type "${digest_type}" not found!`);
+ if (Object.keys(this.digestType).indexOf(digest_type) === -1) {
+ throw new Error(`verifyRSA digest type "${digest_type}" not found!`);
}
- let pubKey = new PublicKey({ pemEncoded: pub_key_pem });
- let clearMessage = new ClearMessage({
- base64Encoded: messageb
+ let messagebData: NSData = new NSData({
+ base64EncodedString: messageb,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
});
- let signature = new Signature({
- base64Encoded: signatureb
+ let signaturebData: NSData = new NSData({
+ base64EncodedString: signatureb,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
});
- let verificationResult = clearMessage.verifyWithSignatureDigestTypeError(
- pubKey,
- signature,
- this.rsaSigDigestType[digest_type]
- );
- return verificationResult.isSuccessful;
+ const derKey = SwKeyConvert_PublicKey.pemToPKCS1DERError(pub_key_pem);
+ try {
+ return (
+ SwRSA.verifyDerKeyPaddingDigestSaltLenSignedDataError(
+ messagebData,
+ derKey,
+ SwRSA_AsymmetricSAPadding.Pkcs15,
+ SwCC_DigestAlgorithm.Sha256,
+ 0,
+ signaturebData,
+ null
+ ) == 1
+ );
+ } catch (err) {
+ return false;
+ }
+ // let pubKey = new PublicKey({ pemEncoded: pub_key_pem });
+ // let clearMessage = new ClearMessage({
+ // base64Encoded: messageb
+ // });
+ // let signature = new Signature({ base64Encoded: signatureb });
+ // let verificationResult = clearMessage.verifyWithSignatureDigestTypeError(
+ // pubKey,
+ // signature,
+ // this.rsaSigDigestType[digest_type]
+ // );
+ // return verificationResult.isSuccessful;
}
deflate(input: string, alg?: string): string {
- let _alg = compression_algorithm.COMPRESSION_ZLIB;
- if (alg === 'lzfse') {
- _alg = compression_algorithm.COMPRESSION_LZFSE;
- }
- let dest_buffer = interop.alloc(
- input.length * interop.sizeof(interop.types.unichar)
- );
- let dest_size = compression_encode_buffer(
- dest_buffer,
- input.length + 4096,
- input,
- input.length,
- null,
- _alg
- );
- return toBase64(dest_buffer, dest_size);
+ let data = new NSData({
+ base64EncodedString: input,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
+ });
+ let dc = new DataCompression({ data });
+ return dc.zip().base64EncodedStringWithOptions(kNilOptions);
}
inflate(input: string, alg?: string): string {
- let _alg = compression_algorithm.COMPRESSION_ZLIB;
- let ratio = 20;
- if (alg === 'lzfse') {
- _alg = compression_algorithm.COMPRESSION_LZFSE;
- }
-
let data = new NSData({
base64EncodedString: input,
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
});
- let src_buffer = interop.alloc(
- data.length * interop.sizeof(interop.types.unichar)
- );
- data.getBytes(src_buffer);
- let dest_buffer = interop.alloc(
- data.length * ratio * interop.sizeof(interop.types.unichar)
- );
- let dest_size = compression_decode_buffer(
- dest_buffer,
- data.length * ratio + 4096,
- src_buffer,
- input.length,
- null,
- _alg
- );
- let str = new NSString({
- bytes: dest_buffer,
- length: dest_size,
- encoding: NSUTF8StringEncoding
- });
- return str;
+ let dc = new DataCompression({ data });
+ return dc
+ .unzipWithSkipHeaderAndCheckSumValidation(true)
+ .base64EncodedStringWithOptions(kNilOptions);
}
base64encode(input: string): string {
@@ -544,6 +543,7 @@ export class NSCrypto implements INSCryto {
}).dataUsingEncoding(NSUTF8StringEncoding);
return plainData.base64EncodedStringWithOptions(kNilOptions);
}
+
base64decode(input: string): string {
let data = new NSData({
base64EncodedString: input,
@@ -554,4 +554,41 @@ export class NSCrypto implements INSCryto {
encoding: NSUTF8StringEncoding
});
}
+
+ randomUUID(): string {
+ return NSUUID.UUID().UUIDString;
+ }
+
+ keyWrapAES(wrappingKey: string, key: string): string {
+ let wrappingKeyData = new NSData({
+ base64EncodedString: wrappingKey,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
+ });
+ let keyData = new NSData({
+ base64EncodedString: key,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
+ });
+ return SwKeyWrap.SymmetricKeyWrapKekRawKeyError(
+ SwKeyWrap.rfc3394IV,
+ wrappingKeyData,
+ keyData,
+ null
+ ).base64EncodedStringWithOptions(kNilOptions);
+ }
+ keyUnWrapAES(unwrappingKey: string, wrappedkey: string): string {
+ let unwrappingKeyData = new NSData({
+ base64EncodedString: unwrappingKey,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
+ });
+ let wrappedData = new NSData({
+ base64EncodedString: wrappedkey,
+ options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters
+ });
+ return SwKeyWrap.SymmetricKeyUnwrapKekWrappedKeyError(
+ SwKeyWrap.rfc3394IV,
+ unwrappingKeyData,
+ wrappedData,
+ null
+ ).base64EncodedStringWithOptions(kNilOptions);
+ }
}
diff --git a/src/index.d.ts b/src/index.d.ts
index 8fab53a..d5974e4 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -25,10 +25,7 @@ export declare class NSCrypto implements INSCryto {
aad: string,
pnonce: string,
alg?: string
- ): {
- cipherb: string;
- alg: string;
- };
+ ): { cipherb: string; alg: string };
decryptSecureSymetricAEAD(
key: string,
cipherb: string,
@@ -42,10 +39,7 @@ export declare class NSCrypto implements INSCryto {
aad: string,
iv: string,
tagLength?: number
- ): {
- cipherb: string;
- atag: string;
- };
+ ): { cipherb: string; atag: string };
decryptAES256GCM(
key: string,
cipherb: string,
@@ -62,8 +56,11 @@ export declare class NSCrypto implements INSCryto {
signatureb: string,
digest_type: string
): boolean;
- deflate(input: string, alg?: string): string;
- inflate(input: string, alg?: string): string;
+ deflate(input: string): string;
+ inflate(input: string): string;
base64encode(input: string): string;
base64decode(input: string): string;
+ randomUUID(): string;
+ keyWrapAES(wrappingKey: string, key: string): string;
+ keyUnWrapAES(unwrappingKey: string, wrappedkey: string): string;
}
diff --git a/src/package-lock.json b/src/package-lock.json
index cb78d4f..aee9c7b 100644
--- a/src/package-lock.json
+++ b/src/package-lock.json
@@ -1,7 +1,8 @@
{
"name": "nativescript-crypto",
- "version": "1.0.0",
+ "version": "0.9.10",
"lockfileVersion": 1,
+ "requires": true,
"dependencies": {
"ansi-regex": {
"version": "https://npm.dev.mysns.pt/ansi-regex/-/ansi-regex-2.1.1.tgz",
@@ -21,7 +22,12 @@
"babel-code-frame": {
"version": "https://npm.dev.mysns.pt/babel-code-frame/-/babel-code-frame-6.22.0.tgz",
"integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "chalk": "https://npm.dev.mysns.pt/chalk/-/chalk-1.1.3.tgz",
+ "esutils": "https://npm.dev.mysns.pt/esutils/-/esutils-2.0.2.tgz",
+ "js-tokens": "https://npm.dev.mysns.pt/js-tokens/-/js-tokens-3.0.1.tgz"
+ }
},
"balanced-match": {
"version": "https://npm.dev.mysns.pt/balanced-match/-/balanced-match-1.0.0.tgz",
@@ -31,12 +37,23 @@
"brace-expansion": {
"version": "https://npm.dev.mysns.pt/brace-expansion/-/brace-expansion-1.1.8.tgz",
"integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "balanced-match": "https://npm.dev.mysns.pt/balanced-match/-/balanced-match-1.0.0.tgz",
+ "concat-map": "https://npm.dev.mysns.pt/concat-map/-/concat-map-0.0.1.tgz"
+ }
},
"chalk": {
"version": "https://npm.dev.mysns.pt/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "ansi-styles": "https://npm.dev.mysns.pt/ansi-styles/-/ansi-styles-2.2.1.tgz",
+ "escape-string-regexp": "https://npm.dev.mysns.pt/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
+ "has-ansi": "https://npm.dev.mysns.pt/has-ansi/-/has-ansi-2.0.0.tgz",
+ "strip-ansi": "https://npm.dev.mysns.pt/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "supports-color": "https://npm.dev.mysns.pt/supports-color/-/supports-color-2.0.0.tgz"
+ }
},
"colors": {
"version": "https://npm.dev.mysns.pt/colors/-/colors-1.1.2.tgz",
@@ -46,18 +63,111 @@
"commander": {
"version": "https://npm.dev.mysns.pt/commander/-/commander-2.9.0.tgz",
"integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "graceful-readlink": "https://npm.dev.mysns.pt/graceful-readlink/-/graceful-readlink-1.0.1.tgz"
+ }
},
"concat-map": {
"version": "https://npm.dev.mysns.pt/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
+ "concurrently": {
+ "version": "3.5.0",
+ "resolved": "https://npm.dev.mysns.pt/concurrently/-/concurrently-3.5.0.tgz",
+ "integrity": "sha1-jPG3cHppFqeKT/W3e7BN7FSzebI=",
+ "dev": true,
+ "requires": {
+ "chalk": "0.5.1",
+ "commander": "2.6.0",
+ "date-fns": "1.28.5",
+ "lodash": "4.17.4",
+ "rx": "2.3.24",
+ "spawn-command": "0.0.2-1",
+ "supports-color": "3.2.3",
+ "tree-kill": "1.1.0"
+ },
+ "dependencies": {
+ "ansi-regex": {
+ "version": "0.2.1",
+ "resolved": "https://npm.dev.mysns.pt/ansi-regex/-/ansi-regex-0.2.1.tgz",
+ "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=",
+ "dev": true
+ },
+ "ansi-styles": {
+ "version": "1.1.0",
+ "resolved": "https://npm.dev.mysns.pt/ansi-styles/-/ansi-styles-1.1.0.tgz",
+ "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=",
+ "dev": true
+ },
+ "chalk": {
+ "version": "0.5.1",
+ "resolved": "https://npm.dev.mysns.pt/chalk/-/chalk-0.5.1.tgz",
+ "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "1.1.0",
+ "escape-string-regexp": "https://npm.dev.mysns.pt/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
+ "has-ansi": "0.1.0",
+ "strip-ansi": "0.3.0",
+ "supports-color": "0.2.0"
+ },
+ "dependencies": {
+ "supports-color": {
+ "version": "0.2.0",
+ "resolved": "https://npm.dev.mysns.pt/supports-color/-/supports-color-0.2.0.tgz",
+ "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=",
+ "dev": true
+ }
+ }
+ },
+ "commander": {
+ "version": "2.6.0",
+ "resolved": "https://npm.dev.mysns.pt/commander/-/commander-2.6.0.tgz",
+ "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=",
+ "dev": true
+ },
+ "has-ansi": {
+ "version": "0.1.0",
+ "resolved": "https://npm.dev.mysns.pt/has-ansi/-/has-ansi-0.1.0.tgz",
+ "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "0.2.1"
+ }
+ },
+ "strip-ansi": {
+ "version": "0.3.0",
+ "resolved": "https://npm.dev.mysns.pt/strip-ansi/-/strip-ansi-0.3.0.tgz",
+ "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "0.2.1"
+ }
+ },
+ "supports-color": {
+ "version": "3.2.3",
+ "resolved": "https://npm.dev.mysns.pt/supports-color/-/supports-color-3.2.3.tgz",
+ "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=",
+ "dev": true,
+ "requires": {
+ "has-flag": "1.0.0"
+ }
+ }
+ }
+ },
"cycle": {
"version": "https://npm.dev.mysns.pt/cycle/-/cycle-1.0.3.tgz",
"integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI=",
"dev": true
},
+ "date-fns": {
+ "version": "1.28.5",
+ "resolved": "https://npm.dev.mysns.pt/date-fns/-/date-fns-1.28.5.tgz",
+ "integrity": "sha1-JXz8RdMi30XvVlhmWWfuhBzXP68=",
+ "dev": true
+ },
"deep-equal": {
"version": "https://npm.dev.mysns.pt/deep-equal/-/deep-equal-0.2.2.tgz",
"integrity": "sha1-hLdFiW80xoTpjyzg5Cq69Du6AX0=",
@@ -91,7 +201,15 @@
"glob": {
"version": "https://npm.dev.mysns.pt/glob/-/glob-7.1.2.tgz",
"integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "fs.realpath": "https://npm.dev.mysns.pt/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "inflight": "https://npm.dev.mysns.pt/inflight/-/inflight-1.0.6.tgz",
+ "inherits": "https://npm.dev.mysns.pt/inherits/-/inherits-2.0.3.tgz",
+ "minimatch": "https://npm.dev.mysns.pt/minimatch/-/minimatch-3.0.4.tgz",
+ "once": "https://npm.dev.mysns.pt/once/-/once-1.4.0.tgz",
+ "path-is-absolute": "https://npm.dev.mysns.pt/path-is-absolute/-/path-is-absolute-1.0.1.tgz"
+ }
},
"graceful-readlink": {
"version": "https://npm.dev.mysns.pt/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
@@ -101,6 +219,15 @@
"has-ansi": {
"version": "https://npm.dev.mysns.pt/has-ansi/-/has-ansi-2.0.0.tgz",
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "https://npm.dev.mysns.pt/ansi-regex/-/ansi-regex-2.1.1.tgz"
+ }
+ },
+ "has-flag": {
+ "version": "1.0.0",
+ "resolved": "https://npm.dev.mysns.pt/has-flag/-/has-flag-1.0.0.tgz",
+ "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=",
"dev": true
},
"i": {
@@ -111,7 +238,11 @@
"inflight": {
"version": "https://npm.dev.mysns.pt/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "once": "https://npm.dev.mysns.pt/once/-/once-1.4.0.tgz",
+ "wrappy": "https://npm.dev.mysns.pt/wrappy/-/wrappy-1.0.2.tgz"
+ }
},
"inherits": {
"version": "https://npm.dev.mysns.pt/inherits/-/inherits-2.0.3.tgz",
@@ -128,10 +259,19 @@
"integrity": "sha1-COnxMkhKLEWjCQfp3E1VZ7fxFNc=",
"dev": true
},
+ "lodash": {
+ "version": "4.17.4",
+ "resolved": "https://npm.dev.mysns.pt/lodash/-/lodash-4.17.4.tgz",
+ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=",
+ "dev": true
+ },
"minimatch": {
"version": "https://npm.dev.mysns.pt/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "brace-expansion": "https://npm.dev.mysns.pt/brace-expansion/-/brace-expansion-1.1.8.tgz"
+ }
},
"minimist": {
"version": "https://npm.dev.mysns.pt/minimist/-/minimist-0.0.8.tgz",
@@ -141,7 +281,10 @@
"mkdirp": {
"version": "https://npm.dev.mysns.pt/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "minimist": "https://npm.dev.mysns.pt/minimist/-/minimist-0.0.8.tgz"
+ }
},
"mute-stream": {
"version": "https://npm.dev.mysns.pt/mute-stream/-/mute-stream-0.0.7.tgz",
@@ -156,7 +299,10 @@
"once": {
"version": "https://npm.dev.mysns.pt/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "wrappy": "https://npm.dev.mysns.pt/wrappy/-/wrappy-1.0.2.tgz"
+ }
},
"path-is-absolute": {
"version": "https://npm.dev.mysns.pt/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
@@ -176,17 +322,31 @@
"prompt": {
"version": "https://npm.dev.mysns.pt/prompt/-/prompt-1.0.0.tgz",
"integrity": "sha1-jlcSPDlquYiJf7Mn/Trtw+c15P4=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "colors": "https://npm.dev.mysns.pt/colors/-/colors-1.1.2.tgz",
+ "pkginfo": "https://npm.dev.mysns.pt/pkginfo/-/pkginfo-0.4.0.tgz",
+ "read": "https://npm.dev.mysns.pt/read/-/read-1.0.7.tgz",
+ "revalidator": "https://npm.dev.mysns.pt/revalidator/-/revalidator-0.1.8.tgz",
+ "utile": "https://npm.dev.mysns.pt/utile/-/utile-0.3.0.tgz",
+ "winston": "https://npm.dev.mysns.pt/winston/-/winston-2.1.1.tgz"
+ }
},
"read": {
"version": "https://npm.dev.mysns.pt/read/-/read-1.0.7.tgz",
"integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "mute-stream": "https://npm.dev.mysns.pt/mute-stream/-/mute-stream-0.0.7.tgz"
+ }
},
"resolve": {
"version": "https://npm.dev.mysns.pt/resolve/-/resolve-1.3.3.tgz",
"integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "path-parse": "https://npm.dev.mysns.pt/path-parse/-/path-parse-1.0.5.tgz"
+ }
},
"revalidator": {
"version": "https://npm.dev.mysns.pt/revalidator/-/revalidator-0.1.8.tgz",
@@ -196,6 +356,15 @@
"rimraf": {
"version": "https://npm.dev.mysns.pt/rimraf/-/rimraf-2.6.1.tgz",
"integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
+ "dev": true,
+ "requires": {
+ "glob": "https://npm.dev.mysns.pt/glob/-/glob-7.1.2.tgz"
+ }
+ },
+ "rx": {
+ "version": "2.3.24",
+ "resolved": "https://npm.dev.mysns.pt/rx/-/rx-2.3.24.tgz",
+ "integrity": "sha1-FPlQpCF9fjXapxu8vljv9o6ksrc=",
"dev": true
},
"semver": {
@@ -203,6 +372,12 @@
"integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=",
"dev": true
},
+ "spawn-command": {
+ "version": "0.0.2-1",
+ "resolved": "https://npm.dev.mysns.pt/spawn-command/-/spawn-command-0.0.2-1.tgz",
+ "integrity": "sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A=",
+ "dev": true
+ },
"stack-trace": {
"version": "https://npm.dev.mysns.pt/stack-trace/-/stack-trace-0.0.10.tgz",
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=",
@@ -211,7 +386,10 @@
"strip-ansi": {
"version": "https://npm.dev.mysns.pt/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "ansi-regex": "https://npm.dev.mysns.pt/ansi-regex/-/ansi-regex-2.1.1.tgz"
+ }
},
"supports-color": {
"version": "https://npm.dev.mysns.pt/supports-color/-/supports-color-2.0.0.tgz",
@@ -221,7 +399,10 @@
"tns-core-modules": {
"version": "https://npm.dev.mysns.pt/tns-core-modules/-/tns-core-modules-3.0.1.tgz",
"integrity": "sha1-CM17csmOb1Y/u6U2ZopQwE3Rpf0=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "tns-core-modules-widgets": "https://npm.dev.mysns.pt/tns-core-modules-widgets/-/tns-core-modules-widgets-3.0.1.tgz"
+ }
},
"tns-core-modules-widgets": {
"version": "https://npm.dev.mysns.pt/tns-core-modules-widgets/-/tns-core-modules-widgets-3.0.1.tgz",
@@ -233,6 +414,12 @@
"integrity": "sha1-2IspuFa0JfupgKGhOp1XoG5OU+8=",
"dev": true
},
+ "tree-kill": {
+ "version": "1.1.0",
+ "resolved": "https://npm.dev.mysns.pt/tree-kill/-/tree-kill-1.1.0.tgz",
+ "integrity": "sha1-yWPc8DciiS7FnLpWnpQLcZVNFyk=",
+ "dev": true
+ },
"tslib": {
"version": "https://npm.dev.mysns.pt/tslib/-/tslib-1.7.1.tgz",
"integrity": "sha1-vIAEFkaRkjp5/oN4u+s9ogF1OOw=",
@@ -241,7 +428,19 @@
"tslint": {
"version": "https://npm.dev.mysns.pt/tslint/-/tslint-5.4.3.tgz",
"integrity": "sha1-dhyEArgONHt3M6BDkKdXslNYBGc=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "babel-code-frame": "https://npm.dev.mysns.pt/babel-code-frame/-/babel-code-frame-6.22.0.tgz",
+ "colors": "https://npm.dev.mysns.pt/colors/-/colors-1.1.2.tgz",
+ "commander": "https://npm.dev.mysns.pt/commander/-/commander-2.9.0.tgz",
+ "diff": "https://npm.dev.mysns.pt/diff/-/diff-3.2.0.tgz",
+ "glob": "https://npm.dev.mysns.pt/glob/-/glob-7.1.2.tgz",
+ "minimatch": "https://npm.dev.mysns.pt/minimatch/-/minimatch-3.0.4.tgz",
+ "resolve": "https://npm.dev.mysns.pt/resolve/-/resolve-1.3.3.tgz",
+ "semver": "https://npm.dev.mysns.pt/semver/-/semver-5.3.0.tgz",
+ "tslib": "https://npm.dev.mysns.pt/tslib/-/tslib-1.7.1.tgz",
+ "tsutils": "https://npm.dev.mysns.pt/tsutils/-/tsutils-2.4.0.tgz"
+ }
},
"tsutils": {
"version": "https://npm.dev.mysns.pt/tsutils/-/tsutils-2.4.0.tgz",
@@ -256,12 +455,29 @@
"utile": {
"version": "https://npm.dev.mysns.pt/utile/-/utile-0.3.0.tgz",
"integrity": "sha1-E1LDQOuCDk2N26A5pPv6oy7U7zo=",
- "dev": true
+ "dev": true,
+ "requires": {
+ "async": "https://npm.dev.mysns.pt/async/-/async-0.9.2.tgz",
+ "deep-equal": "https://npm.dev.mysns.pt/deep-equal/-/deep-equal-0.2.2.tgz",
+ "i": "https://npm.dev.mysns.pt/i/-/i-0.3.5.tgz",
+ "mkdirp": "https://npm.dev.mysns.pt/mkdirp/-/mkdirp-0.5.1.tgz",
+ "ncp": "https://npm.dev.mysns.pt/ncp/-/ncp-1.0.1.tgz",
+ "rimraf": "https://npm.dev.mysns.pt/rimraf/-/rimraf-2.6.1.tgz"
+ }
},
"winston": {
"version": "https://npm.dev.mysns.pt/winston/-/winston-2.1.1.tgz",
"integrity": "sha1-PJNJ0ZYgf9G9/51LxD73JRDjoS4=",
"dev": true,
+ "requires": {
+ "async": "https://npm.dev.mysns.pt/async/-/async-1.0.0.tgz",
+ "colors": "https://npm.dev.mysns.pt/colors/-/colors-1.0.3.tgz",
+ "cycle": "https://npm.dev.mysns.pt/cycle/-/cycle-1.0.3.tgz",
+ "eyes": "https://npm.dev.mysns.pt/eyes/-/eyes-0.1.8.tgz",
+ "isstream": "https://npm.dev.mysns.pt/isstream/-/isstream-0.1.2.tgz",
+ "pkginfo": "https://npm.dev.mysns.pt/pkginfo/-/pkginfo-0.3.1.tgz",
+ "stack-trace": "https://npm.dev.mysns.pt/stack-trace/-/stack-trace-0.0.10.tgz"
+ },
"dependencies": {
"async": {
"version": "https://npm.dev.mysns.pt/async/-/async-1.0.0.tgz",
diff --git a/src/package.json b/src/package.json
index d479884..2003511 100644
--- a/src/package.json
+++ b/src/package.json
@@ -1,57 +1,66 @@
{
- "name": "nativescript-crypto",
- "version": "1.0.0",
- "description": "Your awesome NativeScript plugin.",
- "main": "crypto",
- "typings": "index.d.ts",
- "nativescript": {
- "platforms": {
- "android": "3.0.0",
- "ios": "3.0.0"
- }
- },
- "scripts": {
- "tsc": "tsc -skipLibCheck",
- "postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src && npm run plugin.link",
- "test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch",
- "test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch",
- "tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\"",
- "plugin.link": "npm link && cd ../demo && npm link nativescript-crypto && cd ../src",
- "plugin.tscwatch": "npm run tsc -- -w",
- "demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios --syncAllFiles",
- "demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/tomvardasca/nativescript-crypto.git"
- },
- "keywords": [
- "NativeScript",
- "JavaScript",
- "Android",
- "iOS"
- ],
- "author": {
- "name": "Your Name",
- "email": "youremail@yourdomain.com"
- },
- "bugs": {
- "url": "https://github.com/tomvardasca/nativescript-crypto/issues"
- },
- "license": "Apache-2.0",
- "homepage": "https://github.com/tomvardasca/nativescript-crypto",
- "readmeFilename": "README.md",
- "peerDependencies": {
- "tns-core-modules": "^3.0.0"
- },
- "devDependencies": {
- "tns-core-modules": "^3.0.0",
- "tns-platform-declarations": "^3.0.0",
- "typescript": "^2.2.2",
- "prompt": "^1.0.0",
- "rimraf": "^2.5.0",
- "tslint": "^5.0.0"
- },
- "dependencies": {},
- "bootstrapper": "nativescript-plugin-seed"
+ "name": "nativescript-crypto",
+ "version": "0.9.11",
+ "description": "Cryptographic functions and utilities using libsodium and native RSA and AES-GCM.",
+ "main": "crypto",
+ "typings": "index.d.ts",
+ "nativescript": {
+ "platforms": {
+ "android": "3.0.0",
+ "ios": "3.0.0"
+ }
+ },
+ "scripts": {
+ "tsc": "tsc -skipLibCheck",
+ "postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src && npm run plugin.link",
+ "test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch",
+ "test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch",
+ "tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\"",
+ "plugin.link": "npm link && cd ../demo && npm link nativescript-crypto && cd ../src",
+ "plugin.tscwatch": "npm run tsc -- -w",
+ "demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios --syncAllFiles",
+ "demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles",
+ "w-demo.ios": "concurrently 'npm run demo.ios' 'npm run plugin.tscwatch'",
+ "w-demo.android": "concurrently 'npm run demo.android' 'npm run plugin.tscwatch'"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/tomvardasca/nativescript-crypto.git"
+ },
+ "keywords": [
+ "NativeScript",
+ "JavaScript",
+ "TypeScript",
+ "Crypto",
+ "Cryptography",
+ "libsodiun",
+ "RSA",
+ "AES",
+ "Android",
+ "iOS"
+ ],
+ "author": {
+ "name": "Tomé Vardasca",
+ "email": "tome@vardas.ca"
+ },
+ "bugs": {
+ "url": "https://github.com/tomvardasca/nativescript-crypto/issues"
+ },
+ "license": "Apache-2.0",
+ "homepage": "https://github.com/tomvardasca/nativescript-crypto",
+ "readmeFilename": "README.md",
+ "peerDependencies": {
+ "tns-core-modules": "^3.0.0"
+ },
+ "devDependencies": {
+ "concurrently": "^3.5.0",
+ "prompt": "^1.0.0",
+ "rimraf": "^2.5.0",
+ "tns-core-modules": "^3.0.0",
+ "tns-platform-declarations": "^3.0.0",
+ "tslint": "^5.0.0",
+ "typescript": "^2.2.2"
+ },
+ "dependencies": {},
+ "bootstrapper": "nativescript-plugin-seed"
}
diff --git a/src/platforms/android/include.gradle b/src/platforms/android/include.gradle
index 42fc6b1..3c2d241 100644
--- a/src/platforms/android/include.gradle
+++ b/src/platforms/android/include.gradle
@@ -1,9 +1,4 @@
/* Include.gradle configuration: http://docs.nativescript.org/plugins/plugins#includegradle-specification */
-repositories {
- mavenCentral()
- // jcenter()
-}
-
android {
productFlavors {
"nativescript-crypto" {
@@ -13,6 +8,8 @@ android {
}
dependencies {
- compile 'com.github.joshjdevl.libsodiumjni:libsodium-jni-aar:1.0.6@aar'
- compile 'com.facebook.conceal:conceal:1.1.3@aar'
+ // compile 'com.github.joshjdevl.libsodiumjni:libsodium-jni-aar:1.0.7-SNAPSHOT@aar'
+ compile 'com.madgag.spongycastle:core:1.56.0.0'
+ compile 'com.madgag.spongycastle:prov:1.56.0.0'
+
}
diff --git a/src/platforms/android/libs/libsodium-jni-aar-1.0.7.aar b/src/platforms/android/libs/libsodium-jni-aar-1.0.7.aar
new file mode 100644
index 0000000..94484ad
Binary files /dev/null and b/src/platforms/android/libs/libsodium-jni-aar-1.0.7.aar differ
diff --git a/src/platforms/ios/AesGcm.typing.txt b/src/platforms/ios/AesGcm.typing.txt
deleted file mode 100644
index ede77f8..0000000
--- a/src/platforms/ios/AesGcm.typing.txt
+++ /dev/null
@@ -1,133 +0,0 @@
-
-declare var AesGcmVersionNumber: number;
-
-declare var AesGcmVersionString: interop.Reference;
-
-declare class IAGAesComponents extends NSObject {
-
- static alloc(): IAGAesComponents; // inherited from NSObject
-
- static getCipheredBlockByUsingAESOnBlockWithKeyError(cipheredBlock: interop.Reference, block: interop.Reference, key: NSData): boolean;
-
- static new(): IAGAesComponents; // inherited from NSObject
-}
-
-declare class IAGAesGcm extends NSObject {
-
- static alloc(): IAGAesGcm; // inherited from NSObject
-
- static cipheredDataByAuthenticatedEncryptingPlainDataWithAdditionalAuthenticatedDataAuthenticationTagLengthInitializationVectorKeyError(plainData: NSData, aad: NSData, tagLength: IAGAuthenticationTagLength, iv: NSData, key: NSData): IAGCipheredData;
-
- static new(): IAGAesGcm; // inherited from NSObject
-
- static plainDataByAuthenticatedDecryptingCipheredDataWithAdditionalAuthenticatedDataInitializationVectorKeyError(cipheredData: IAGCipheredData, aad: NSData, iv: NSData, key: NSData): NSData;
-}
-
-declare const enum IAGAuthenticationTagLength {
-
- Length128 = 16,
-
- Length120 = 15,
-
- Length112 = 14,
-
- Length104 = 13,
-
- Length96 = 12
-}
-
-declare var IAGBitsInUChar: number;
-
-declare class IAGBitwiseComponents extends NSObject {
-
- static alloc(): IAGBitwiseComponents; // inherited from NSObject
-
- static getLeastSignificantBytesWithSizeInBufferWithSize(lsb: string, lsbSyze: number, buffer: string, bufferSize: number): void;
-
- static getMostSignificantBytesWithSizeInBufferWithSize(msb: string, msbSyze: number, buffer: string, bufferSize: number): void;
-
- static getSingleRightShiftedBlockWithBlock(shiftedBlock: interop.Reference, block: interop.Reference): void;
-
- static getXorBlockWithBlockAndBlock(buffer: interop.Reference, value1: interop.Reference, value2: interop.Reference): void;
-
- static getXorBufferWithBufferBufferBufferSize(buffer: string, value1: string, value2: string, bufferSize: number): void;
-
- static isLeastSignificantBitActivatedAtPositionInBlock(position: number, block: interop.Reference): boolean;
-
- static isMostSignificantBitActivatedAtPositionInBlock(position: number, block: interop.Reference): boolean;
-
- static new(): IAGBitwiseComponents; // inherited from NSObject
-}
-
-declare class IAGCipheredData extends NSObject {
-
- static alloc(): IAGCipheredData; // inherited from NSObject
-
- static new(): IAGCipheredData; // inherited from NSObject
-
- readonly authenticationTag: interop.Pointer | interop.Reference;
-
- readonly authenticationTagLength: IAGAuthenticationTagLength;
-
- readonly cipheredBuffer: interop.Pointer | interop.Reference;
-
- readonly cipheredBufferLength: number;
-
- constructor(o: { cipheredBuffer: interop.Pointer | interop.Reference; cipheredBufferLength: number; authenticationTag: interop.Pointer | interop.Reference; authenticationTagLength: IAGAuthenticationTagLength; });
-
- initWithCipheredBufferCipheredBufferLengthAuthenticationTagAuthenticationTagLength(cipheredBuffer: interop.Pointer | interop.Reference, cipheredBufferLength: number, authenticationTag: interop.Pointer | interop.Reference, authenticationTagLength: IAGAuthenticationTagLength): this;
-
- isEqualToCipheredData(object: IAGCipheredData): boolean;
-}
-
-declare const enum IAGErrorCode {
-
- AESFailed = 0,
-
- InputDataLengthNotSupported = 1,
-
- AuthenticationTagsNotIdentical = 2
-}
-
-declare var IAGErrorDomain: string;
-
-declare class IAGErrorFactory extends NSObject {
-
- static alloc(): IAGErrorFactory; // inherited from NSObject
-
- static errorAESFailed(): NSError;
-
- static errorAuthenticationTagsNotIdentical(): NSError;
-
- static errorInputDataLengthNotSupported(): NSError;
-
- static new(): IAGErrorFactory; // inherited from NSObject
-}
-
-declare class IAGGcmEndianness extends NSObject {
-
- static alloc(): IAGGcmEndianness; // inherited from NSObject
-
- static new(): IAGGcmEndianness; // inherited from NSObject
-
- static swapUInt32GcmToHost(arg: number): number;
-
- static swapUInt32HostToGcm(arg: number): number;
-
- static swapUInt64HostToGcm(arg: number): number;
-}
-
-declare class IAGGcmMathComponents extends NSObject {
-
- static alloc(): IAGGcmMathComponents; // inherited from NSObject
-
- static get32BitIncrementedBufferWithBufferSize(incBuffer: string, buffer: string, size: number): void;
-
- static getGCounterBufferWithBufferBufferSizeInitialCounterBlockKeyError(gcounterBuffer: string, buffer: string, bufferSize: number, icb: interop.Reference, key: NSData): boolean;
-
- static getGhashBlockWithBufferBufferSizeHashSubkey(ghashBlock: interop.Reference, buffer: string, bufferSize: number, hashSubkey: interop.Reference): void;
-
- static new(): IAGGcmMathComponents; // inherited from NSObject
-}
-
-declare var IAGMaxBitPositionInABlock: number;
diff --git a/src/platforms/ios/CryptoUtils.typings.txt b/src/platforms/ios/CryptoUtils.typings.txt
new file mode 100644
index 0000000..044c60a
--- /dev/null
+++ b/src/platforms/ios/CryptoUtils.typings.txt
@@ -0,0 +1,594 @@
+
+declare const enum CompressionAlgorithm {
+
+ ZLIB = 0,
+
+ LZFSE = 1,
+
+ LZMA = 2,
+
+ LZ4 = 3
+}
+
+declare var CryptoUtilsVersionNumber: number;
+
+declare var CryptoUtilsVersionString: interop.Reference;
+
+declare class DataCompression extends NSObject {
+
+ static alloc(): DataCompression; // inherited from NSObject
+
+ static new(): DataCompression; // inherited from NSObject
+
+ constructor(o: { data: NSData; });
+
+ adler32(): number;
+
+ compressWithAlgo(algo: compression_algorithm): NSData;
+
+ decompressWithAlgo(algo: compression_algorithm): NSData;
+
+ deflate(): NSData;
+
+ inflate(): NSData;
+
+ initWithData(data: NSData): this;
+
+ unzipWithSkipHeaderAndCheckSumValidation(skipHeaderAndCheckSumValidation: boolean): NSData;
+
+ zip(): NSData;
+}
+
+declare class SwCC extends NSObject {
+
+ static HMACAlgKey(data: NSData, alg: SwCC_HMACAlg, key: NSData): NSData;
+
+ static alloc(): SwCC; // inherited from NSObject
+
+ static available(): boolean;
+
+ static cryptAuthBlockModeAlgorithmDataADataKeyIvTagLengthTagError(opMode: SwCC_OpMode, blockMode: SwCC_AuthBlockMode, algorithm: SwCC_Algorithm, data: NSData, aData: NSData, key: NSData, iv: NSData, tagLength: number, tag: NSData): NSDictionary;
+
+ static cryptBlockModeAlgorithmPaddingDataKeyIvError(opMode: SwCC_OpMode, blockMode: SwCC_BlockMode, algorithm: SwCC_Algorithm, padding: SwCC_Padding, data: NSData, key: NSData, iv: NSData): NSData;
+
+ static cryptorAvailable(): boolean;
+
+ static digestAlg(data: NSData, alg: SwCC_DigestAlgorithm): NSData;
+
+ static digestAvailable(): boolean;
+
+ static generateRandom(size: number): NSData;
+
+ static hmacAvailable(): boolean;
+
+ static new(): SwCC; // inherited from NSObject
+
+ static randomAvailable(): boolean;
+}
+
+declare class SwCCM extends NSObject {
+
+ static alloc(): SwCCM; // inherited from NSObject
+
+ static available(): boolean;
+
+ static cryptAlgorithmDataKeyIvADataTagLengthError(opMode: SwCC_OpMode, algorithm: SwCC_Algorithm, data: NSData, key: NSData, iv: NSData, aData: NSData, tagLength: number): NSDictionary;
+
+ static new(): SwCCM; // inherited from NSObject
+}
+
+declare const enum SwCC_Algorithm {
+
+ Aes = 0,
+
+ Des = 1,
+
+ ThreeDES = 2,
+
+ Cast = 3,
+
+ Rc4 = 4,
+
+ Rc2 = 5,
+
+ Blowfish = 6
+}
+
+declare const enum SwCC_AuthBlockMode {
+
+ Gcm = 11,
+
+ Ccm = 12
+}
+
+declare const enum SwCC_BlockMode {
+
+ Ecb = 1,
+
+ Cbc = 2,
+
+ Cfb = 3,
+
+ Ctr = 4,
+
+ F8 = 5,
+
+ Lrw = 6,
+
+ Ofb = 7,
+
+ Xts = 8,
+
+ Rc4 = 9,
+
+ Cfb8 = 10
+}
+
+declare const enum SwCC_CCError {
+
+ ParamError = -4300,
+
+ BufferTooSmall = -4301,
+
+ MemoryFailure = -4302,
+
+ AlignmentError = -4303,
+
+ DecodeError = -4304,
+
+ Unimplemented = -4305,
+
+ Overflow = -4306,
+
+ RngFailure = -4307
+}
+
+declare const enum SwCC_DigestAlgorithm {
+
+ None = 0,
+
+ Md5 = 3,
+
+ Rmd128 = 4,
+
+ Rmd160 = 5,
+
+ Rmd256 = 6,
+
+ Rmd320 = 7,
+
+ Sha1 = 8,
+
+ Sha224 = 9,
+
+ Sha256 = 10,
+
+ Sha384 = 11,
+
+ Sha512 = 12
+}
+
+declare const enum SwCC_HMACAlg {
+
+ Sha1 = 0,
+
+ Md5 = 1,
+
+ Sha256 = 2,
+
+ Sha384 = 3,
+
+ Sha512 = 4,
+
+ Sha224 = 5
+}
+
+declare const enum SwCC_OpMode {
+
+ Encrypt = 0,
+
+ Decrypt = 1
+}
+
+declare const enum SwCC_Padding {
+
+ NoPadding = 0,
+
+ Pkcs7Padding = 1
+}
+
+declare class SwCMAC extends NSObject {
+
+ static AESCMACKey(data: NSData, key: NSData): NSData;
+
+ static alloc(): SwCMAC; // inherited from NSObject
+
+ static available(): boolean;
+
+ static new(): SwCMAC; // inherited from NSObject
+}
+
+declare class SwCRC extends NSObject {
+
+ static alloc(): SwCRC; // inherited from NSObject
+
+ static available(): boolean;
+
+ static new(): SwCRC; // inherited from NSObject
+}
+
+declare const enum SwCRC_Mode {
+
+ Crc8 = 10,
+
+ Crc8ICODE = 11,
+
+ Crc8ITU = 12,
+
+ Crc8ROHC = 13,
+
+ Crc8WCDMA = 14,
+
+ Crc16 = 20,
+
+ Crc16CCITTTrue = 21,
+
+ Crc16CCITTFalse = 22,
+
+ Crc16USB = 23,
+
+ Crc16XMODEM = 24,
+
+ Crc16DECTR = 25,
+
+ Crc16DECTX = 26,
+
+ Crc16ICODE = 27,
+
+ Crc16VERIFONE = 28,
+
+ Crc16A = 29,
+
+ Crc16B = 30,
+
+ Crc16Fletcher = 31,
+
+ Crc32Adler = 40,
+
+ Crc32 = 41,
+
+ Crc32CASTAGNOLI = 42,
+
+ Crc32BZIP2 = 43,
+
+ Crc32MPEG2 = 44,
+
+ Crc32POSIX = 45,
+
+ Crc32XFER = 46,
+
+ Crc64ECMA182 = 60
+}
+
+declare class SwDH extends NSObject {
+
+ static alloc(): SwDH; // inherited from NSObject
+
+ static available(): boolean;
+
+ static new(): SwDH; // inherited from NSObject
+}
+
+declare class SwDH_DH extends NSObject {
+
+ static alloc(): SwDH_DH; // inherited from NSObject
+
+ static new(): SwDH_DH; // inherited from NSObject
+
+ constructor(o: { dhParam: SwDH_DHParam; });
+
+ computeKeyError(peerKey: NSData): NSData;
+
+ generateKeyAndReturnError(): NSData;
+
+ initWithDhParamError(dhParam: SwDH_DHParam): this;
+}
+
+declare const enum SwDH_DHParam {
+
+ Rfc3526Group5 = 0
+}
+
+declare class SwEC extends NSObject {
+
+ static alloc(): SwEC; // inherited from NSObject
+
+ static available(): boolean;
+
+ static computeSharedSecretPublicKeyError(privateKey: NSData, publicKey: NSData): NSData;
+
+ static generateKeyPairError(keySize: number): NSDictionary;
+
+ static new(): SwEC; // inherited from NSObject
+
+ static signHashHashError(privateKey: NSData, hash: NSData): NSData;
+}
+
+declare class SwEC_generateKeyPairResult extends NSObject {
+
+ static alloc(): SwEC_generateKeyPairResult; // inherited from NSObject
+
+ static new(): SwEC_generateKeyPairResult; // inherited from NSObject
+
+ privDERKey: NSData;
+
+ pubDERKey: NSData;
+
+ constructor(o: { privDERKey: NSData; pubDERKey: NSData; });
+
+ initWithPrivDERKeyPubDERKey(privDERKey: NSData, pubDERKey: NSData): this;
+}
+
+declare class SwGCM extends NSObject {
+
+ static alloc(): SwGCM; // inherited from NSObject
+
+ static available(): boolean;
+
+ static cryptAlgorithmDataKeyIvADataTagLengthError(opMode: SwCC_OpMode, algorithm: SwCC_Algorithm, data: NSData, key: NSData, iv: NSData, aData: NSData, tagLength: number): NSDictionary;
+
+ static new(): SwGCM; // inherited from NSObject
+}
+
+declare class SwGCM_CCM_cryptResult extends NSObject {
+
+ static alloc(): SwGCM_CCM_cryptResult; // inherited from NSObject
+
+ static new(): SwGCM_CCM_cryptResult; // inherited from NSObject
+
+ result: NSData;
+
+ tag: NSData;
+
+ constructor(o: { result: NSData; tag: NSData; });
+
+ initWithResultTag(result: NSData, tag: NSData): this;
+}
+
+declare class SwKeyConvert_PrivateKey extends NSObject {
+
+ static alloc(): SwKeyConvert_PrivateKey; // inherited from NSObject
+
+ static decryptPEMPassphraseError(pemKey: string, passphrase: string): string;
+
+ static derToPKCS1PEM(derKey: NSData): string;
+
+ static encryptPEMPassphraseModeError(pemKey: string, passphrase: string, mode: SwPEM_EncryptedPrivateKey_EncMode): string;
+
+ static new(): SwKeyConvert_PrivateKey; // inherited from NSObject
+
+ static pemToPKCS1DERError(pemKey: string): NSData;
+}
+
+declare class SwKeyConvert_PublicKey extends NSObject {
+
+ static alloc(): SwKeyConvert_PublicKey; // inherited from NSObject
+
+ static derToPKCS1PEM(derKey: NSData): string;
+
+ static derToPKCS8PEM(derKey: NSData): string;
+
+ static new(): SwKeyConvert_PublicKey; // inherited from NSObject
+
+ static pemToPKCS1DERError(pemKey: string): NSData;
+}
+
+declare const enum SwKeyConvert_SecError {
+
+ InvalidKey = 0,
+
+ BadPassphrase = 1,
+
+ KeyNotEncrypted = 2
+}
+
+declare class SwKeyDerivation extends NSObject {
+
+ static PBKDF2SaltPrfRoundsError(password: string, salt: NSData, prf: SwKeyDerivation_PRFAlg, rounds: number): NSData;
+
+ static alloc(): SwKeyDerivation; // inherited from NSObject
+
+ static available(): boolean;
+
+ static new(): SwKeyDerivation; // inherited from NSObject
+}
+
+declare const enum SwKeyDerivation_PRFAlg {
+
+ Sha1 = 1,
+
+ Sha224 = 2,
+
+ Sha256 = 3,
+
+ Sha384 = 4,
+
+ Sha512 = 5
+}
+
+declare class SwKeyStore extends NSObject {
+
+ static alloc(): SwKeyStore; // inherited from NSObject
+
+ static delKeyError(keyTag: string): boolean;
+
+ static getKeyError(keyTag: string): string;
+
+ static new(): SwKeyStore; // inherited from NSObject
+
+ static upsertKeyKeyTagOptionsError(pemKey: string, keyTag: string, options: NSDictionary): boolean;
+}
+
+declare const enum SwKeyStore_SecError {
+
+ Unimplemented = -4,
+
+ Param = -50,
+
+ Allocate = -108,
+
+ NotAvailable = -25291,
+
+ AuthFailed = -25293,
+
+ DuplicateItem = -25299,
+
+ ItemNotFound = -25300,
+
+ InteractionNotAllowed = -25308,
+
+ Decode = -26275,
+
+ MissingEntitlement = -34018
+}
+
+declare class SwKeyWrap extends NSObject {
+
+ static SymmetricKeyUnwrapKekWrappedKeyError(iv: NSData, kek: NSData, wrappedKey: NSData): NSData;
+
+ static SymmetricKeyWrapKekRawKeyError(iv: NSData, kek: NSData, rawKey: NSData): NSData;
+
+ static alloc(): SwKeyWrap; // inherited from NSObject
+
+ static available(): boolean;
+
+ static new(): SwKeyWrap; // inherited from NSObject
+
+ static readonly rfc3394IV: NSData;
+}
+
+declare class SwPEM extends NSObject {
+
+ static alloc(): SwPEM; // inherited from NSObject
+
+ static new(): SwPEM; // inherited from NSObject
+}
+
+declare class SwPEM_EncryptedPrivateKey extends NSObject {
+
+ static alloc(): SwPEM_EncryptedPrivateKey; // inherited from NSObject
+
+ static new(): SwPEM_EncryptedPrivateKey; // inherited from NSObject
+
+ static toDERPassphraseError(pemKey: string, passphrase: string): NSData;
+
+ static toPEMPassphraseMode(derKey: NSData, passphrase: string, mode: SwPEM_EncryptedPrivateKey_EncMode): string;
+}
+
+declare const enum SwPEM_EncryptedPrivateKey_EncMode {
+
+ Aes128CBC = 0,
+
+ Aes256CBC = 1
+}
+
+declare class SwPEM_PrivateKey extends NSObject {
+
+ static alloc(): SwPEM_PrivateKey; // inherited from NSObject
+
+ static new(): SwPEM_PrivateKey; // inherited from NSObject
+
+ static toDERError(pemKey: string): NSData;
+
+ static toPEM(derKey: NSData): string;
+}
+
+declare class SwPEM_PublicKey extends NSObject {
+
+ static alloc(): SwPEM_PublicKey; // inherited from NSObject
+
+ static new(): SwPEM_PublicKey; // inherited from NSObject
+
+ static toDERError(pemKey: string): NSData;
+
+ static toPEM(derKey: NSData): string;
+}
+
+declare class SwPKCS8 extends NSObject {
+
+ static alloc(): SwPKCS8; // inherited from NSObject
+
+ static new(): SwPKCS8; // inherited from NSObject
+}
+
+declare class SwPKCS8_PrivateKey extends NSObject {
+
+ static alloc(): SwPKCS8_PrivateKey; // inherited from NSObject
+
+ static hasCorrectHeader(derKey: NSData): boolean;
+
+ static new(): SwPKCS8_PrivateKey; // inherited from NSObject
+
+ static stripHeaderIfAny(derKey: NSData): NSData;
+}
+
+declare class SwPKCS8_PublicKey extends NSObject {
+
+ static addHeader(derKey: NSData): NSData;
+
+ static alloc(): SwPKCS8_PublicKey; // inherited from NSObject
+
+ static hasCorrectHeader(derKey: NSData): boolean;
+
+ static new(): SwPKCS8_PublicKey; // inherited from NSObject
+
+ static stripHeaderIfAny(derKey: NSData): NSData;
+}
+
+declare class SwRSA extends NSObject {
+
+ static alloc(): SwRSA; // inherited from NSObject
+
+ static available(): boolean;
+
+ static decryptDerKeyTagPaddingDigestError(data: NSData, derKey: NSData, tag: NSData, padding: SwRSA_AsymmetricPadding, digest: SwCC_DigestAlgorithm): NSData;
+
+ static encryptDerKeyTagPaddingDigestError(data: NSData, derKey: NSData, tag: NSData, padding: SwRSA_AsymmetricPadding, digest: SwCC_DigestAlgorithm): NSData;
+
+ static generateKeyPairError(keySize: number): NSDictionary;
+
+ static new(): SwRSA; // inherited from NSObject
+
+ static signDerKeyPaddingDigestSaltLenError(message: NSData, derKey: NSData, padding: SwRSA_AsymmetricSAPadding, digest: SwCC_DigestAlgorithm, saltLen: number): NSData;
+
+ static verifyDerKeyPaddingDigestSaltLenSignedDataError(message: NSData, derKey: NSData, padding: SwRSA_AsymmetricSAPadding, digest: SwCC_DigestAlgorithm, saltLen: number, signedData: NSData): number;
+}
+
+declare const enum SwRSA_AsymmetricPadding {
+
+ Pkcs1 = 1001,
+
+ Oaep = 1002
+}
+
+declare const enum SwRSA_AsymmetricSAPadding {
+
+ Pkcs15 = 1001,
+
+ Pss = 1002
+}
+
+declare class SwRSA_generateKeyPairResult extends NSObject {
+
+ static alloc(): SwRSA_generateKeyPairResult; // inherited from NSObject
+
+ static new(): SwRSA_generateKeyPairResult; // inherited from NSObject
+
+ privDERKey: NSData;
+
+ pubDERKey: NSData;
+
+ constructor(o: { privDERKey: NSData; pubDERKey: NSData; });
+
+ initWithPrivDERKeyPubDERKey(privDERKey: NSData, pubDERKey: NSData): this;
+}
diff --git a/src/platforms/ios/CryptoUtils/.swift-version b/src/platforms/ios/CryptoUtils/.swift-version
new file mode 100644
index 0000000..9f55b2c
--- /dev/null
+++ b/src/platforms/ios/CryptoUtils/.swift-version
@@ -0,0 +1 @@
+3.0
diff --git a/src/platforms/ios/CryptoUtils/CryptoUtils.podspec b/src/platforms/ios/CryptoUtils/CryptoUtils.podspec
new file mode 100644
index 0000000..469992c
--- /dev/null
+++ b/src/platforms/ios/CryptoUtils/CryptoUtils.podspec
@@ -0,0 +1,18 @@
+
+Pod::Spec.new do |s|
+ s.name = "CryptoUtils"
+ s.version = "1.0.0"
+ s.summary = "Crypto Utils Data Compression and Crypto utilities"
+ s.authors = "Tomé Vardasca"
+ s.homepage = "https://github.com/tomvardasca/nativescript-crypto"
+ s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
+ s.source = { :git => "https://github.com/tomvardasca/nativescript-crypto.git", :tag => s.version }
+
+ s.ios.deployment_target = '9.0'
+ s.osx.deployment_target = '10.11'
+ s.tvos.deployment_target = '9.0'
+ s.watchos.deployment_target = '2.0'
+
+ s.source_files = '*.swift'
+ s.requires_arc = true
+end
diff --git a/src/platforms/ios/CryptoUtils/DataCompression.swift b/src/platforms/ios/CryptoUtils/DataCompression.swift
new file mode 100644
index 0000000..43fc487
--- /dev/null
+++ b/src/platforms/ios/CryptoUtils/DataCompression.swift
@@ -0,0 +1,213 @@
+///
+/// DataCompression
+///
+/// libcompression wrapper as an extension for the `Data` type
+/// (ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951)
+///
+/// Created by Markus Wanke, 2016/12/05
+///
+
+
+///
+/// Apache License, Version 2.0
+///
+/// Copyright 2016, Markus Wanke
+///
+/// Licensed under the Apache License, Version 2.0 (the "License");
+/// you may not use this file except in compliance with the License.
+/// You may obtain a copy of the License at
+///
+/// http://www.apache.org/licenses/LICENSE-2.0
+///
+/// Unless required by applicable law or agreed to in writing, software
+/// distributed under the License is distributed on an "AS IS" BASIS,
+/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+/// See the License for the specific language governing permissions and
+/// limitations under the License.
+///
+
+
+import Foundation
+import Compression
+
+@objc public class DataCompression: NSObject
+{
+ var data: Data;
+ public init(data: Data){
+ self.data = data;
+ }
+ /// Compresses the data.
+ /// - parameter withAlgorithm: Compression algorithm to use. See the `CompressionAlgorithm` type
+ /// - returns: compressed data
+ public func compress(algo: compression_algorithm) -> Data?
+ {
+ return self.data.withUnsafeBytes { (sourcePtr: UnsafePointer) -> Data? in
+ let config = (operation: COMPRESSION_STREAM_ENCODE, algorithm: algo)
+ return self.perform(config, source: sourcePtr, sourceSize: self.data.count)
+ }
+ }
+
+ /// Decompresses the data.
+ /// - parameter withAlgorithm: Compression algorithm to use. See the `CompressionAlgorithm` type
+ /// - returns: decompressed data
+ public func decompress(algo: compression_algorithm) -> Data?
+ {
+ return self.data.withUnsafeBytes { (sourcePtr: UnsafePointer) -> Data? in
+ let config = (operation: COMPRESSION_STREAM_DECODE, algorithm: algo)
+ return self.perform(config, source: sourcePtr, sourceSize: self.data.count)
+ }
+ }
+
+ /// Please consider the [libcompression documentation](https://developer.apple.com/reference/compression/1665429-data_compression)
+ /// for further details. Short info:
+ /// ZLIB : Fast with a very solid compression rate. There is a reason it is used everywhere.
+ /// LZFSE : Apples proprietary compression algorithm. Claims to compress as good as ZLIB but 2 to 3 times faster.
+ /// LZMA : Horribly slow. Compression as well as decompression. Normally you will regret choosing LZMA.
+ /// LZ4 : Fast, but depending on the data the compression rate can be really bad. Which is often the case.
+ @objc public enum CompressionAlgorithm : Int
+ {
+ case ZLIB
+ case LZFSE
+ case LZMA
+ case LZ4
+ }
+
+ /// Compresses the data using the zlib deflate algorithm.
+ /// - returns: raw deflated data according to [RFC-1951](https://tools.ietf.org/html/rfc1951).
+ /// - note: Fixed at compression level 5 (best trade off between speed and time)
+ public func deflate() -> Data?
+ {
+ return self.data.withUnsafeBytes { (sourcePtr: UnsafePointer) -> Data? in
+ let config = (operation: COMPRESSION_STREAM_ENCODE, algorithm: COMPRESSION_ZLIB)
+ return self.perform(config, source: sourcePtr, sourceSize: self.data.count)
+ }
+ }
+
+ /// Deompresses the data using the zlib deflate algorithm. Self is expected to be a raw deflate
+ /// stream according to [RFC-1951](https://tools.ietf.org/html/rfc1951).
+ /// - returns: uncompressed data
+ public func inflate() -> Data?
+ {
+ return self.data.withUnsafeBytes { (sourcePtr: UnsafePointer) -> Data? in
+ let config = (operation: COMPRESSION_STREAM_DECODE, algorithm: COMPRESSION_ZLIB)
+ return self.perform(config, source: sourcePtr, sourceSize: self.data.count)
+ }
+ }
+
+ /// Compresses the data using the zlib deflate algorithm.
+ /// - returns: zlib deflated data according to [RFC-1950](https://tools.ietf.org/html/rfc1950)
+ /// - note: Fixed at compression level 5 (best trade off between speed and time)
+ public func zip() -> Data?
+ {
+ var res = Data(bytes: [0x78, 0x5e])
+
+ guard let deflated = self.deflate() else { return nil }
+ res.append(deflated)
+
+ var adler = self.adler32().bigEndian
+ res.append(Data(bytes: &adler, count: MemoryLayout.size))
+
+ return res
+ }
+
+ /// Deompresses the data using the zlib deflate algorithm. Self is expected to be a zlib deflate
+ /// stream according to [RFC-1950](https://tools.ietf.org/html/rfc1950).
+ /// - returns: uncompressed data
+ public func unzip(skipHeaderAndCheckSumValidation: Bool = false) -> Data?
+ {
+ // 2 byte header + 4 byte adler32 checksum
+ let overhead = 6
+ guard self.data.count > overhead else { return nil }
+
+ let header: UInt16 = data.withUnsafeBytes { (ptr: UnsafePointer) -> UInt16 in
+ return ptr.pointee.bigEndian
+ }
+
+ // check for the deflate stream bit
+ guard skipHeaderAndCheckSumValidation || header >> 8 & 0b1111 == 0b1000 else { return nil }
+ // check the header checksum
+ guard skipHeaderAndCheckSumValidation || header % 31 == 0 else { return nil }
+
+ let cresult: Data? = self.data.withUnsafeBytes { (ptr: UnsafePointer) -> Data? in
+ let source = ptr.advanced(by: 2)
+ let config = (operation: COMPRESSION_STREAM_DECODE, algorithm: COMPRESSION_ZLIB)
+ return self.perform(config, source: source, sourceSize: self.data.count - overhead)
+ }
+
+ guard let inflated = cresult else { return nil }
+
+ if skipHeaderAndCheckSumValidation { return inflated }
+
+ let cksum: UInt32 = self.data.withUnsafeBytes { (bytePtr: UnsafePointer) -> UInt32 in
+ let last = bytePtr.advanced(by: self.data.count - 4)
+ return last.withMemoryRebound(to: UInt32.self, capacity: 1) { (intPtr) -> UInt32 in
+ return intPtr.pointee.bigEndian
+ }
+ }
+
+ return cksum == DataCompression(data: inflated).adler32() ? inflated : nil
+ }
+
+ /// Rudimentary implementation of the adler32 checksum.
+ /// - returns: adler32 checksum (4 byte)
+ public func adler32() -> UInt32
+ {
+ var s1: UInt32 = 1
+ var s2: UInt32 = 0
+ let prime: UInt32 = 65521
+
+ for byte in self.data {
+ s1 += UInt32(byte)
+ if s1 >= prime { s1 = s1 % prime }
+ s2 += s1
+ if s2 >= prime { s2 = s2 % prime }
+ }
+
+ return (s2 << 16) | s1
+ }
+
+ private func perform(_ config: Config, source: UnsafePointer, sourceSize: Int) -> Data?
+ {
+ guard config.operation == COMPRESSION_STREAM_ENCODE || sourceSize > 0 else { return nil }
+
+ let streamBase = UnsafeMutablePointer.allocate(capacity: 1)
+ defer { streamBase.deallocate(capacity: 1) }
+ var stream = streamBase.pointee
+
+ let status = compression_stream_init(&stream, config.operation, config.algorithm)
+ guard status != COMPRESSION_STATUS_ERROR else { return nil }
+ defer { compression_stream_destroy(&stream) }
+
+ let bufferSize = Swift.max( Swift.min(sourceSize, 64 * 1024), 64)
+ let buffer = UnsafeMutablePointer.allocate(capacity: bufferSize)
+ defer { buffer.deallocate(capacity: bufferSize) }
+
+ stream.dst_ptr = buffer
+ stream.dst_size = bufferSize
+ stream.src_ptr = source
+ stream.src_size = sourceSize
+
+ var res = Data()
+ let flags: Int32 = Int32(COMPRESSION_STREAM_FINALIZE.rawValue)
+
+ while true {
+ switch compression_stream_process(&stream, flags) {
+ case COMPRESSION_STATUS_OK:
+ guard stream.dst_size == 0 else { return nil }
+ res.append(buffer, count: stream.dst_ptr - buffer)
+ stream.dst_ptr = buffer
+ stream.dst_size = bufferSize
+
+ case COMPRESSION_STATUS_END:
+ res.append(buffer, count: stream.dst_ptr - buffer)
+ return res
+
+ default:
+ return nil
+ }
+ }
+ }
+}
+
+
+fileprivate typealias Config = (operation: compression_stream_operation, algorithm: compression_algorithm)
diff --git a/src/platforms/ios/CryptoUtils/LICENSE b/src/platforms/ios/CryptoUtils/LICENSE
new file mode 100644
index 0000000..8dada3e
--- /dev/null
+++ b/src/platforms/ios/CryptoUtils/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/src/platforms/ios/CryptoUtils/SwCrypto.swift b/src/platforms/ios/CryptoUtils/SwCrypto.swift
new file mode 100644
index 0000000..c4dd292
--- /dev/null
+++ b/src/platforms/ios/CryptoUtils/SwCrypto.swift
@@ -0,0 +1,2162 @@
+import Foundation
+
+// https://github.com/soyersoyer/SwCrypt/blob/master/SwCrypt/SwCrypt.swift
+
+@objc open class SwKeyStore: NSObject {
+
+ @objc(SwKeyStore_SecError) public enum SecError: OSStatus, Error {
+ case unimplemented = -4
+ case param = -50
+ case allocate = -108
+ case notAvailable = -25291
+ case authFailed = -25293
+ case duplicateItem = -25299
+ case itemNotFound = -25300
+ case interactionNotAllowed = -25308
+ case decode = -26275
+ case missingEntitlement = -34018
+
+ public static var debugLevel = 1
+
+ init(_ status: OSStatus, function: String = #function, file: String = #file, line: Int = #line) {
+ self = SecError(rawValue: status)!
+ if SecError.debugLevel > 0 {
+ print("\(file):\(line): [\(function)] \(self._domain): \(self) (\(self.rawValue))")
+ }
+ }
+ init(_ type: SecError, function: String = #function, file: String = #file, line: Int = #line) {
+ self = type
+ if SecError.debugLevel > 0 {
+ print("\(file):\(line): [\(function)] \(self._domain): \(self) (\(self.rawValue))")
+ }
+ }
+ }
+
+ public static func upsertKey(_ pemKey: String, keyTag: String,
+ options: [NSString : AnyObject] = [:]) throws {
+ let pemKeyAsData = pemKey.data(using: String.Encoding.utf8)!
+
+ var parameters: [NSString : AnyObject] = [
+ kSecClass: kSecClassKey,
+ kSecAttrKeyType: kSecAttrKeyTypeRSA,
+ kSecAttrIsPermanent: true as AnyObject,
+ kSecAttrApplicationTag: keyTag as AnyObject,
+ kSecValueData: pemKeyAsData as AnyObject
+ ]
+ options.forEach { k, v in
+ parameters[k] = v
+ }
+
+ var status = SecItemAdd(parameters as CFDictionary, nil)
+ if status == errSecDuplicateItem {
+ try delKey(keyTag)
+ status = SecItemAdd(parameters as CFDictionary, nil)
+ }
+ guard status == errSecSuccess else { throw SecError(status) }
+ }
+
+ public static func getKey(_ keyTag: String) throws -> String {
+ let parameters: [NSString : AnyObject] = [
+ kSecClass : kSecClassKey,
+ kSecAttrKeyType : kSecAttrKeyTypeRSA,
+ kSecAttrApplicationTag : keyTag as AnyObject,
+ kSecReturnData : true as AnyObject
+ ]
+ var data: AnyObject?
+ let status = SecItemCopyMatching(parameters as CFDictionary, &data)
+ guard status == errSecSuccess else { throw SecError(status) }
+
+ guard let pemKeyAsData = data as? Data else {
+ throw SecError(.decode)
+ }
+ guard let result = String(data: pemKeyAsData, encoding: String.Encoding.utf8) else {
+ throw SecError(.decode)
+ }
+ return result
+ }
+
+ public static func delKey(_ keyTag: String) throws {
+ let parameters: [NSString : AnyObject] = [
+ kSecClass : kSecClassKey,
+ kSecAttrApplicationTag: keyTag as AnyObject
+ ]
+ let status = SecItemDelete(parameters as CFDictionary)
+ guard status == errSecSuccess else { throw SecError(status) }
+ }
+}
+
+@objc public enum SwKeyConvert_SecError: Int, Error {
+ case invalidKey
+ case badPassphrase
+ case keyNotEncrypted
+
+ public static var debugLevel = 1
+
+ init(_ type: SwKeyConvert_SecError, function: String = #function, file: String = #file, line: Int = #line) {
+ self = type
+ if SwKeyConvert_SecError.debugLevel > 0 {
+ print("\(file):\(line): [\(function)] \(self._domain): \(self)")
+ }
+ }
+}
+
+
+
+ @objc open class SwKeyConvert_PrivateKey: NSObject {
+
+ public static func pemToPKCS1DER(_ pemKey: String) throws -> Data {
+ guard let derKey = try? PEM.PrivateKey.toDER(pemKey) else {
+ throw SwKeyConvert_SecError(.invalidKey)
+ }
+ guard let pkcs1DERKey = PKCS8.PrivateKey.stripHeaderIfAny(derKey) else {
+ throw SwKeyConvert_SecError(.invalidKey)
+ }
+ return pkcs1DERKey
+ }
+
+ public static func derToPKCS1PEM(_ derKey: Data) -> String {
+ return PEM.PrivateKey.toPEM(derKey)
+ }
+
+ public typealias EncMode = PEM.EncryptedPrivateKey.EncMode
+
+ public static func encryptPEM(_ pemKey: String, passphrase: String,
+ mode: EncMode) throws -> String {
+ do {
+ let derKey = try PEM.PrivateKey.toDER(pemKey)
+ return PEM.EncryptedPrivateKey.toPEM(derKey, passphrase: passphrase, mode: mode)
+ } catch {
+ throw SwKeyConvert_SecError(.invalidKey)
+ }
+ }
+
+ public static func decryptPEM(_ pemKey: String, passphrase: String) throws -> String {
+ do {
+ let derKey = try PEM.EncryptedPrivateKey.toDER(pemKey, passphrase: passphrase)
+ return PEM.PrivateKey.toPEM(derKey)
+ } catch PEM.SwError.badPassphrase {
+ throw SwKeyConvert_SecError(.badPassphrase)
+ } catch PEM.SwError.keyNotEncrypted {
+ throw SwKeyConvert_SecError(.keyNotEncrypted)
+ } catch {
+ throw SwKeyConvert_SecError(.invalidKey)
+ }
+ }
+}
+
+@objc open class SwKeyConvert_PublicKey: NSObject {
+
+ public static func pemToPKCS1DER(_ pemKey: String) throws -> Data {
+ guard let derKey = try? PEM.PublicKey.toDER(pemKey) else {
+ throw SwKeyConvert_SecError(.invalidKey)
+ }
+ guard let pkcs1DERKey = PKCS8.PublicKey.stripHeaderIfAny(derKey) else {
+ throw SwKeyConvert_SecError(.invalidKey)
+ }
+ return pkcs1DERKey
+ }
+
+ public static func derToPKCS1PEM(_ derKey: Data) -> String {
+ return PEM.PublicKey.toPEM(derKey)
+ }
+
+ public static func derToPKCS8PEM(_ derKey: Data) -> String {
+ let pkcs8Key = PKCS8.PublicKey.addHeader(derKey)
+ return PEM.PublicKey.toPEM(pkcs8Key)
+ }
+
+}
+
+@objc(SwPKCS8) open class PKCS8: NSObject {
+
+ @objc(SwPKCS8_PrivateKey) open class PrivateKey: NSObject {
+
+ //https://lapo.it/asn1js/
+ public static func getPKCS1DEROffset(_ derKey: Data) -> Int? {
+ let bytes = derKey.bytesView
+
+ var offset = 0
+ guard bytes.length > offset else { return nil }
+ guard bytes[offset] == 0x30 else { return nil }
+
+ offset += 1
+
+ guard bytes.length > offset else { return nil }
+ if bytes[offset] > 0x80 {
+ offset += Int(bytes[offset]) - 0x80
+ }
+ offset += 1
+
+ guard bytes.length > offset else { return nil }
+ guard bytes[offset] == 0x02 else { return nil }
+
+ offset += 3
+
+ //without PKCS8 header
+ guard bytes.length > offset else { return nil }
+ if bytes[offset] == 0x02 {
+ return 0
+ }
+
+ let OID: [UInt8] = [0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+ 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00]
+
+ guard bytes.length > offset + OID.count else { return nil }
+ let slice = derKey.bytesViewRange(NSRange(location: offset, length: OID.count))
+
+ guard OID.elementsEqual(slice) else { return nil }
+
+ offset += OID.count
+
+ guard bytes.length > offset else { return nil }
+ guard bytes[offset] == 0x04 else { return nil }
+
+ offset += 1
+
+ guard bytes.length > offset else { return nil }
+ if bytes[offset] > 0x80 {
+ offset += Int(bytes[offset]) - 0x80
+ }
+ offset += 1
+
+ guard bytes.length > offset else { return nil }
+ guard bytes[offset] == 0x30 else { return nil }
+
+ return offset
+ }
+
+ public static func stripHeaderIfAny(_ derKey: Data) -> Data? {
+ guard let offset = getPKCS1DEROffset(derKey) else {
+ return nil
+ }
+ return derKey.subdata(in: offset.. Bool {
+ return getPKCS1DEROffset(derKey) != nil
+ }
+
+ }
+
+ @objc(SwPKCS8_PublicKey) open class PublicKey: NSObject {
+
+ public static func addHeader(_ derKey: Data) -> Data {
+ var result = Data()
+
+ let encodingLength: Int = encodedOctets(derKey.count + 1).count
+ let OID: [UInt8] = [0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+ 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00]
+
+ var builder: [UInt8] = []
+
+ // ASN.1 SEQUENCE
+ builder.append(0x30)
+
+ // Overall size, made of OID + bitstring encoding + actual key
+ let size = OID.count + 2 + encodingLength + derKey.count
+ let encodedSize = encodedOctets(size)
+ builder.append(contentsOf: encodedSize)
+ result.append(builder, count: builder.count)
+ result.append(OID, count: OID.count)
+ builder.removeAll(keepingCapacity: false)
+
+ builder.append(0x03)
+ builder.append(contentsOf: encodedOctets(derKey.count + 1))
+ builder.append(0x00)
+ result.append(builder, count: builder.count)
+
+ // Actual key bytes
+ result.append(derKey)
+
+ return result
+ }
+
+ //https://lapo.it/asn1js/
+ public static func getPKCS1DEROffset(_ derKey: Data) -> Int? {
+ let bytes = derKey.bytesView
+
+ var offset = 0
+ guard bytes.length > offset else { return nil }
+ guard bytes[offset] == 0x30 else { return nil }
+
+ offset += 1
+
+ guard bytes.length > offset else { return nil }
+ if bytes[offset] > 0x80 {
+ offset += Int(bytes[offset]) - 0x80
+ }
+ offset += 1
+
+ //without PKCS8 header
+ guard bytes.length > offset else { return nil }
+ if bytes[offset] == 0x02 {
+ return 0
+ }
+
+ let OID: [UInt8] = [0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+ 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00]
+
+ guard bytes.length > offset + OID.count else { return nil }
+ let slice = derKey.bytesViewRange(NSRange(location: offset, length: OID.count))
+
+ guard OID.elementsEqual(slice) else { return nil }
+ offset += OID.count
+
+ // Type
+ guard bytes.length > offset else { return nil }
+ guard bytes[offset] == 0x03 else { return nil }
+
+ offset += 1
+
+ guard bytes.length > offset else { return nil }
+ if bytes[offset] > 0x80 {
+ offset += Int(bytes[offset]) - 0x80
+ }
+ offset += 1
+
+ // Contents should be separated by a null from the header
+ guard bytes.length > offset else { return nil }
+ guard bytes[offset] == 0x00 else { return nil }
+
+ offset += 1
+ guard bytes.length > offset else { return nil }
+
+ return offset
+ }
+
+ public static func stripHeaderIfAny(_ derKey: Data) -> Data? {
+ guard let offset = getPKCS1DEROffset(derKey) else {
+ return nil
+ }
+ return derKey.subdata(in: offset.. Bool {
+ return getPKCS1DEROffset(derKey) != nil
+ }
+
+ fileprivate static func encodedOctets(_ int: Int) -> [UInt8] {
+ // Short form
+ if int < 128 {
+ return [UInt8(int)]
+ }
+
+ // Long form
+ let i = (int / 256) + 1
+ var len = int
+ var result: [UInt8] = [UInt8(i + 0x80)]
+
+ for _ in 0..> 8
+ }
+
+ return result
+ }
+ }
+}
+
+@objc(SwPEM) open class PEM: NSObject {
+
+ public enum SwError: Error {
+ case parse(String)
+ case badPassphrase
+ case keyNotEncrypted
+
+ public static var debugLevel = 1
+
+ init(_ type: SwError, function: String = #function, file: String = #file, line: Int = #line) {
+ self = type
+ if SwError.debugLevel > 0 {
+ print("\(file):\(line): [\(function)] \(self._domain): \(self)")
+ }
+ }
+ }
+
+ @objc(SwPEM_PrivateKey) open class PrivateKey: NSObject {
+
+ public static func toDER(_ pemKey: String) throws -> Data {
+ guard let strippedKey = stripHeader(pemKey) else {
+ throw SwError(.parse("header"))
+ }
+ guard let data = PEM.base64Decode(strippedKey) else {
+ throw SwError(.parse("base64decode"))
+ }
+ return data
+ }
+
+ public static func toPEM(_ derKey: Data) -> String {
+ let base64 = PEM.base64Encode(derKey)
+ return addRSAHeader(base64)
+ }
+
+ fileprivate static let prefix = "-----BEGIN PRIVATE KEY-----\n"
+ fileprivate static let suffix = "\n-----END PRIVATE KEY-----"
+ fileprivate static let rsaPrefix = "-----BEGIN RSA PRIVATE KEY-----\n"
+ fileprivate static let rsaSuffix = "\n-----END RSA PRIVATE KEY-----"
+
+ fileprivate static func addHeader(_ base64: String) -> String {
+ return prefix + base64 + suffix
+ }
+
+ fileprivate static func addRSAHeader(_ base64: String) -> String {
+ return rsaPrefix + base64 + rsaSuffix
+ }
+
+ fileprivate static func stripHeader(_ pemKey: String) -> String? {
+ return PEM.stripHeaderFooter(pemKey, header: prefix, footer: suffix) ??
+ PEM.stripHeaderFooter(pemKey, header: rsaPrefix, footer: rsaSuffix)
+ }
+ }
+
+ @objc(SwPEM_PublicKey) open class PublicKey: NSObject {
+
+ public static func toDER(_ pemKey: String) throws -> Data {
+ guard let strippedKey = stripHeader(pemKey) else {
+ throw SwError(.parse("header"))
+ }
+ guard let data = PEM.base64Decode(strippedKey) else {
+ throw SwError(.parse("base64decode"))
+ }
+ return data
+ }
+
+ public static func toPEM(_ derKey: Data) -> String {
+ let base64 = PEM.base64Encode(derKey)
+ return addHeader(base64)
+ }
+
+ fileprivate static let pemPrefix = "-----BEGIN PUBLIC KEY-----\n"
+ fileprivate static let pemSuffix = "\n-----END PUBLIC KEY-----"
+
+ fileprivate static func addHeader(_ base64: String) -> String {
+ return pemPrefix + base64 + pemSuffix
+ }
+
+ fileprivate static func stripHeader(_ pemKey: String) -> String? {
+ return PEM.stripHeaderFooter(pemKey, header: pemPrefix, footer: pemSuffix)
+ }
+ }
+
+ @objc(SwPEM_EncryptedPrivateKey) open class EncryptedPrivateKey: NSObject {
+
+ @objc(SwPEM_EncryptedPrivateKey_EncMode) public enum EncMode: Int {
+ case aes128CBC, aes256CBC
+ }
+
+ public static func toDER(_ pemKey: String, passphrase: String) throws -> Data {
+ guard let strippedKey = PrivateKey.stripHeader(pemKey) else {
+ throw SwError(.parse("header"))
+ }
+ guard let mode = getEncMode(strippedKey) else {
+ throw SwError(.keyNotEncrypted)
+ }
+ guard let iv = getIV(strippedKey) else {
+ throw SwError(.parse("iv"))
+ }
+ let aesKey = getAESKey(mode, passphrase: passphrase, iv: iv)
+ let base64Data = strippedKey.substring(
+ from: strippedKey.index(strippedKey.startIndex, offsetBy:aesHeaderLength))
+ guard let data = PEM.base64Decode(base64Data) else {
+ throw SwError(.parse("base64decode"))
+ }
+ guard let decrypted = try? decryptKey(data, key: aesKey, iv: iv) else {
+ throw SwError(.badPassphrase)
+ }
+ guard PKCS8.PrivateKey.hasCorrectHeader(decrypted) else {
+ throw SwError(.badPassphrase)
+ }
+ return decrypted
+ }
+
+ public static func toPEM(_ derKey: Data, passphrase: String, mode: EncMode) -> String {
+ let iv = CC.generateRandom(16)
+ let aesKey = getAESKey(mode, passphrase: passphrase, iv: iv)
+ let encrypted = encryptKey(derKey, key: aesKey, iv: iv)
+ let encryptedDERKey = addEncryptHeader(encrypted, iv: iv, mode: mode)
+ return PrivateKey.addRSAHeader(encryptedDERKey)
+ }
+
+ fileprivate static let aes128CBCInfo = "Proc-Type: 4,ENCRYPTED\nDEK-Info: AES-128-CBC,"
+ fileprivate static let aes256CBCInfo = "Proc-Type: 4,ENCRYPTED\nDEK-Info: AES-256-CBC,"
+ fileprivate static let aesInfoLength = aes128CBCInfo.characters.count
+ fileprivate static let aesIVInHexLength = 32
+ fileprivate static let aesHeaderLength = aesInfoLength + aesIVInHexLength
+
+ fileprivate static func addEncryptHeader(_ key: Data, iv: Data, mode: EncMode) -> String {
+ return getHeader(mode) + iv.hexadecimalString() + "\n\n" + PEM.base64Encode(key)
+ }
+
+ fileprivate static func getHeader(_ mode: EncMode) -> String {
+ switch mode {
+ case .aes128CBC: return aes128CBCInfo
+ case .aes256CBC: return aes256CBCInfo
+ }
+ }
+
+ fileprivate static func getEncMode(_ strippedKey: String) -> EncMode? {
+ if strippedKey.hasPrefix(aes128CBCInfo) {
+ return .aes128CBC
+ }
+ if strippedKey.hasPrefix(aes256CBCInfo) {
+ return .aes256CBC
+ }
+ return nil
+ }
+
+ fileprivate static func getIV(_ strippedKey: String) -> Data? {
+ let ivInHex = strippedKey.substring(
+ with: strippedKey.index(strippedKey.startIndex,
+ offsetBy:aesInfoLength) ..< strippedKey.index(strippedKey.startIndex,
+ offsetBy:aesHeaderLength))
+ return ivInHex.dataFromHexadecimalString()
+ }
+
+ fileprivate static func getAESKey(_ mode: EncMode, passphrase: String, iv: Data) -> Data {
+ switch mode {
+ case .aes128CBC: return getAES128Key(passphrase, iv: iv)
+ case .aes256CBC: return getAES256Key(passphrase, iv: iv)
+ }
+ }
+
+ fileprivate static func getAES128Key(_ passphrase: String, iv: Data) -> Data {
+ //128bit_Key = MD5(Passphrase + Salt)
+ let pass = passphrase.data(using: String.Encoding.utf8)!
+ let salt = iv.subdata(in: 0..<8)
+
+ var key = pass
+ key.append(salt)
+ return CC.digest(key, alg: .md5)
+ }
+
+ fileprivate static func getAES256Key(_ passphrase: String, iv: Data) -> Data {
+ //128bit_Key = MD5(Passphrase + Salt)
+ //256bit_Key = 128bit_Key + MD5(128bit_Key + Passphrase + Salt)
+ let pass = passphrase.data(using: String.Encoding.utf8)!
+ let salt = iv.subdata(in: 0 ..< 8)
+
+ var first = pass
+ first.append(salt)
+ let aes128Key = CC.digest(first, alg: .md5)
+
+ var sec = aes128Key
+ sec.append(pass)
+ sec.append(salt)
+
+ var aes256Key = aes128Key
+ aes256Key.append(CC.digest(sec, alg: .md5))
+ return aes256Key
+ }
+
+ fileprivate static func encryptKey(_ data: Data, key: Data, iv: Data) -> Data {
+ return try! CC.crypt(
+ .encrypt, blockMode: .cbc, algorithm: .aes, padding: .pkcs7Padding,
+ data: data, key: key, iv: iv)
+ }
+
+ fileprivate static func decryptKey(_ data: Data, key: Data, iv: Data) throws -> Data {
+ return try CC.crypt(
+ .decrypt, blockMode: .cbc, algorithm: .aes, padding: .pkcs7Padding,
+ data: data, key: key, iv: iv)
+ }
+
+ }
+
+ fileprivate static func stripHeaderFooter(_ data: String, header: String, footer: String) -> String? {
+ guard data.hasPrefix(header) else {
+ return nil
+ }
+ guard let r = data.range(of: footer) else {
+ return nil
+ }
+ return data.substring(with: header.endIndex.. Data? {
+ return Data(base64Encoded: base64Data, options: [.ignoreUnknownCharacters])
+ }
+
+ fileprivate static func base64Encode(_ key: Data) -> String {
+ return key.base64EncodedString(
+ options: [.lineLength64Characters, .endLineWithLineFeed])
+ }
+
+}
+
+
+@objc open class SwRSA: NSObject {
+
+ public typealias CCAsymmetricPadding = UInt32
+
+ @objc(SwRSA_AsymmetricPadding) public enum AsymmetricPadding: CCAsymmetricPadding {
+ case pkcs1 = 1001
+ case oaep = 1002
+ }
+
+ @objc(SwRSA_AsymmetricSAPadding) public enum AsymmetricSAPadding: UInt32 {
+ case pkcs15 = 1001
+ case pss = 1002
+ }
+
+ @objc open class SwRSA_generateKeyPairResult: NSObject {
+ @objc public var privDERKey: Data;
+ @objc public var pubDERKey: Data;
+ @objc public init(privDERKey: Data, pubDERKey: Data) {
+ self.privDERKey = privDERKey;
+ self.pubDERKey = pubDERKey;
+ }
+ }
+
+ public static func generateKeyPair(_ keySize: Int = 4096) throws -> NSDictionary {
+ var privateKey: CCRSACryptorRef? = nil
+ var publicKey: CCRSACryptorRef? = nil
+ let status = CCRSACryptorGeneratePair!(
+ keySize,
+ 65537,
+ &publicKey,
+ &privateKey)
+ guard status == noErr else { throw CCError(status) }
+
+ defer {
+ CCRSACryptorRelease!(privateKey!)
+ CCRSACryptorRelease!(publicKey!)
+ }
+
+ let privDERKey = try exportToDERKey(privateKey!)
+ let pubDERKey = try exportToDERKey(publicKey!)
+
+ return NSDictionary.init(dictionary: [ "privDERKey": privDERKey, "pubDERKey": pubDERKey ])
+ }
+
+ public static func encrypt(_ data: Data, derKey: Data, tag: Data?, padding: AsymmetricPadding,
+ digest: CC.DigestAlgorithm) throws -> Data {
+ let key = try importFromDERKey(derKey)
+ defer { CCRSACryptorRelease!(key) }
+
+ var bufferSize = getKeySize(key)
+ var buffer = Data(count: bufferSize)
+ let tag_bytes: UnsafeRawPointer? = tag != nil ? (tag! as NSData).bytes : nil;
+ let tag_count: Int = tag != nil ? tag!.count : 0;
+ let status = buffer.withUnsafeMutableBytes {
+ (bufferBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCRSACryptorEncrypt!(
+ key,
+ padding.rawValue,
+ (data as NSData).bytes,
+ data.count,
+ bufferBytes,
+ &bufferSize,
+ tag_bytes, tag_count,
+ digest.rawValue)
+ }
+ guard status == noErr else { throw CCError(status) }
+
+ buffer.count = bufferSize
+
+ return buffer
+ }
+
+
+ public static func decrypt(_ data: Data, derKey: Data, tag: Data?, padding: AsymmetricPadding,
+ digest: CC.DigestAlgorithm) throws -> Data {
+ let key = try importFromDERKey(derKey)
+ defer { CCRSACryptorRelease!(key) }
+
+ let blockSize = getKeySize(key)
+
+ var bufferSize = blockSize
+ var buffer = Data(count: bufferSize)
+ let tag_bytes = tag != nil ? (tag! as NSData).bytes : nil;
+ let tag_count = tag != nil ? tag!.count : 0;
+ let status = buffer.withUnsafeMutableBytes {
+ (bufferBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCRSACryptorDecrypt!(
+ key,
+ padding.rawValue,
+ (data as NSData).bytes,
+ bufferSize,
+ bufferBytes,
+ &bufferSize,
+ tag_bytes, tag_count,
+ digest.rawValue)
+ }
+ guard status == noErr else { throw CCError(status) }
+ buffer.count = bufferSize
+
+ return buffer;
+ }
+
+ fileprivate static func importFromDERKey(_ derKey: Data) throws -> CCRSACryptorRef {
+ var key: CCRSACryptorRef? = nil
+ let status = CCRSACryptorImport!(
+ (derKey as NSData).bytes,
+ derKey.count,
+ &key)
+ guard status == noErr else { throw CCError(status) }
+
+ return key!
+ }
+
+ fileprivate static func exportToDERKey(_ key: CCRSACryptorRef) throws -> Data {
+ var derKeyLength = 8192
+ var derKey = Data(count: derKeyLength)
+ let status = derKey.withUnsafeMutableBytes {
+ (derKeyBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCRSACryptorExport!(key, derKeyBytes, &derKeyLength)
+ }
+ guard status == noErr else { throw CCError(status) }
+
+ derKey.count = derKeyLength
+ return derKey
+ }
+
+ fileprivate static func getKeyType(_ key: CCRSACryptorRef) -> KeyType {
+ return KeyType(rawValue: CCRSAGetKeyType!(key))!
+ }
+
+ fileprivate static func getKeySize(_ key: CCRSACryptorRef) -> Int {
+ return Int(CCRSAGetKeySize!(key)/8)
+ }
+
+ @objc public static func sign(_ message: Data, derKey: Data, padding: AsymmetricSAPadding,
+ digest: CC.DigestAlgorithm, saltLen: Int) throws -> Data {
+ let key = try importFromDERKey(derKey)
+ defer { CCRSACryptorRelease!(key) }
+ guard getKeyType(key) == .privateKey else { throw CCError(.paramError) }
+
+ let keySize = getKeySize(key)
+
+ switch padding {
+ case .pkcs15:
+ let hash = CC.digest(message, alg: digest)
+ var signedDataLength = keySize
+ var signedData = Data(count:signedDataLength)
+ let status = signedData.withUnsafeMutableBytes({
+ (signedDataBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCRSACryptorSign!(
+ key,
+ AsymmetricPadding.pkcs1.rawValue,
+ (hash as NSData).bytes, hash.count,
+ digest.rawValue, 0 /*unused*/,
+ signedDataBytes, &signedDataLength)
+ })
+ guard status == noErr else { throw CCError(status) }
+
+ signedData.count = signedDataLength
+ return signedData
+ case .pss:
+ let encMessage = try add_pss_padding(
+ digest,
+ saltLength: saltLen,
+ keyLength: keySize,
+ message: message)
+ return try crypt(encMessage, key: key)
+ }
+ }
+
+ @objc public static func verify(_ message: Data, derKey: Data, padding: AsymmetricSAPadding,
+ digest: CC.DigestAlgorithm, saltLen: Int,
+ signedData: Data) throws -> NSNumber {
+ let key = try importFromDERKey(derKey)
+ defer { CCRSACryptorRelease!(key) }
+ guard getKeyType(key) == .publicKey else { throw CCError(.paramError) }
+
+ let keySize = getKeySize(key)
+
+ switch padding {
+ case .pkcs15:
+ let hash = CC.digest(message, alg: digest)
+ let status = CCRSACryptorVerify!(
+ key,
+ padding.rawValue,
+ (hash as NSData).bytes, hash.count,
+ digest.rawValue, 0 /*unused*/,
+ (signedData as NSData).bytes, signedData.count)
+ let kCCNotVerified: CCCryptorStatus = -4306
+ if status == kCCNotVerified {
+ return 0
+ }
+ guard status == noErr else { throw CCError(status) }
+ return 1
+ case .pss:
+ let encoded = try crypt(signedData, key:key)
+ return try verify_pss_padding(
+ digest,
+ saltLength: saltLen,
+ keyLength: keySize,
+ message: message,
+ encMessage: encoded) == true ? 1 :0
+ }
+ }
+
+ fileprivate static func crypt(_ data: Data, key: CCRSACryptorRef) throws -> Data {
+ var outLength = data.count
+ var out = Data(count: outLength)
+ let status = out.withUnsafeMutableBytes { (outBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCRSACryptorCrypt!(
+ key,
+ (data as NSData).bytes, data.count,
+ outBytes, &outLength)
+ }
+ guard status == noErr else { throw CCError(status) }
+ out.count = outLength
+
+ return out
+ }
+
+ fileprivate static func mgf1(_ digest: CC.DigestAlgorithm,
+ seed: Data, maskLength: Int) -> Data {
+ var tseed = seed
+ tseed.append(contentsOf: [0,0,0,0] as [UInt8])
+
+ var interval = maskLength / digest.length
+ if maskLength % digest.length != 0 {
+ interval += 1
+ }
+
+ func pack(_ n: Int) -> [UInt8] {
+ return [
+ UInt8(n>>24 & 0xff),
+ UInt8(n>>16 & 0xff),
+ UInt8(n>>8 & 0xff),
+ UInt8(n>>0 & 0xff)
+ ]
+ }
+
+ var mask = Data()
+ for counter in 0 ..< interval {
+ tseed.replaceSubrange((tseed.count - 4) ..< tseed.count, with: pack(counter))
+ mask.append(CC.digest(tseed, alg: digest))
+ }
+ mask.count = maskLength
+ return mask
+ }
+
+ fileprivate static func xorData(_ data1: Data, _ data2: Data) -> Data {
+ precondition(data1.count == data2.count)
+
+ var ret = Data(count: data1.count)
+ ret.withUnsafeMutableBytes { (r: UnsafeMutablePointer) -> Void in
+ let bytes1 = (data1 as NSData).bytes.bindMemory(to: UInt8.self, capacity: data1.count)
+ let bytes2 = (data2 as NSData).bytes.bindMemory(to: UInt8.self, capacity: data2.count)
+ for i in 0 ..< ret.count {
+ r[i] = bytes1[i] ^ bytes2[i]
+ }
+ }
+ return ret
+ }
+
+ fileprivate static func add_pss_padding(_ digest: CC.DigestAlgorithm,
+ saltLength: Int,
+ keyLength: Int,
+ message: Data) throws -> Data {
+
+ if keyLength < 16 || saltLength < 0 {
+ throw CCError(.paramError)
+ }
+
+ // The maximal bit size of a non-negative integer is one less than the bit
+ // size of the key since the first bit is used to store sign
+ let emBits = keyLength * 8 - 1
+ var emLength = emBits / 8
+ if emBits % 8 != 0 {
+ emLength += 1
+ }
+
+ let hash = CC.digest(message, alg: digest)
+
+ if emLength < hash.count + saltLength + 2 {
+ throw CCError(.paramError)
+ }
+
+ let salt = CC.generateRandom(saltLength)
+
+ var mPrime = Data(count: 8)
+ mPrime.append(hash)
+ mPrime.append(salt)
+ let mPrimeHash = CC.digest(mPrime, alg: digest)
+
+ let padding = Data(count: emLength - saltLength - hash.count - 2)
+ var db = padding
+ db.append([0x01] as [UInt8], count: 1)
+ db.append(salt)
+ let dbMask = mgf1(digest, seed: mPrimeHash, maskLength: emLength - hash.count - 1)
+ var maskedDB = xorData(db, dbMask)
+
+ let zeroBits = 8 * emLength - emBits
+ maskedDB.withUnsafeMutableBytes { (mMaskedDb: UnsafeMutablePointer) -> Void in
+ mMaskedDb[0] &= UInt8(0xff >> zeroBits)
+ }
+
+ var ret = maskedDB
+ ret.append(mPrimeHash)
+ ret.append([0xBC] as [UInt8], count: 1)
+ return ret
+ }
+
+ fileprivate static func verify_pss_padding(_ digest: CC.DigestAlgorithm,
+ saltLength: Int, keyLength: Int,
+ message: Data, encMessage: Data) throws -> Bool {
+ if keyLength < 16 || saltLength < 0 {
+ throw CCError(.paramError)
+ }
+
+ guard encMessage.count > 0 else {
+ return false
+ }
+
+ let emBits = keyLength * 8 - 1
+ var emLength = emBits / 8
+ if emBits % 8 != 0 {
+ emLength += 1
+ }
+
+ let hash = CC.digest(message, alg: digest)
+
+ if emLength < hash.count + saltLength + 2 {
+ return false
+ }
+ if encMessage.bytesView[encMessage.count-1] != 0xBC {
+ return false
+ }
+ let zeroBits = 8 * emLength - emBits
+ let zeroBitsM = 8 - zeroBits
+ let maskedDBLength = emLength - hash.count - 1
+ let maskedDB = encMessage.subdata(in: 0..> zeroBitsM != 0 {
+ return false
+ }
+ let mPrimeHash = encMessage.subdata(in: maskedDBLength ..< maskedDBLength + hash.count)
+ let dbMask = mgf1(digest, seed: mPrimeHash, maskLength: emLength - hash.count - 1)
+ var db = xorData(maskedDB, dbMask)
+ db.withUnsafeMutableBytes { (mDb: UnsafeMutablePointer) -> Void in
+ mDb[0] &= UInt8(0xff >> zeroBits)
+ }
+
+ let zeroLength = emLength - hash.count - saltLength - 2
+ let zeroString = Data(count:zeroLength)
+ if db.subdata(in: 0 ..< zeroLength) != zeroString {
+ return false
+ }
+ if db.bytesView[zeroLength] != 0x01 {
+ return false
+ }
+ let salt = db.subdata(in: (db.count - saltLength) ..< db.count)
+ var mPrime = Data(count:8)
+ mPrime.append(hash)
+ mPrime.append(salt)
+ let mPrimeHash2 = CC.digest(mPrime, alg: digest)
+ if mPrimeHash != mPrimeHash2 {
+ return false
+ }
+ return true
+ }
+
+
+ public static func available() -> Bool {
+ return CCRSACryptorGeneratePair != nil &&
+ CCRSACryptorRelease != nil &&
+ CCRSAGetKeyType != nil &&
+ CCRSAGetKeySize != nil &&
+ CCRSACryptorEncrypt != nil &&
+ CCRSACryptorDecrypt != nil &&
+ CCRSACryptorExport != nil &&
+ CCRSACryptorImport != nil &&
+ CCRSACryptorSign != nil &&
+ CCRSACryptorVerify != nil &&
+ CCRSACryptorCrypt != nil
+ }
+
+ fileprivate typealias CCRSACryptorRef = UnsafeRawPointer
+ fileprivate typealias CCRSAKeyType = UInt32
+ fileprivate enum KeyType: CCRSAKeyType {
+ case publicKey = 0, privateKey
+ case blankPublicKey = 97, blankPrivateKey
+ case badKey = 99
+ }
+
+ fileprivate static let dl = dlopen("/usr/lib/system/libcommonCrypto.dylib", RTLD_NOW)
+
+ fileprivate typealias CCRSACryptorGeneratePairT = @convention(c) (
+ _ keySize: Int,
+ _ e: UInt32,
+ _ publicKey: UnsafeMutablePointer,
+ _ privateKey: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCRSACryptorGeneratePair: CCRSACryptorGeneratePairT? =
+ getFunc(dl!, f: "CCRSACryptorGeneratePair")
+
+ fileprivate typealias CCRSACryptorReleaseT = @convention(c) (CCRSACryptorRef) -> Void
+ fileprivate static let CCRSACryptorRelease: CCRSACryptorReleaseT? =
+ getFunc(dl!, f: "CCRSACryptorRelease")
+
+ fileprivate typealias CCRSAGetKeyTypeT = @convention(c) (CCRSACryptorRef) -> CCRSAKeyType
+ fileprivate static let CCRSAGetKeyType: CCRSAGetKeyTypeT? = getFunc(dl!, f: "CCRSAGetKeyType")
+
+ fileprivate typealias CCRSAGetKeySizeT = @convention(c) (CCRSACryptorRef) -> Int32
+ fileprivate static let CCRSAGetKeySize: CCRSAGetKeySizeT? = getFunc(dl!, f: "CCRSAGetKeySize")
+
+ fileprivate typealias CCRSACryptorEncryptT = @convention(c) (
+ _ publicKey: CCRSACryptorRef,
+ _ padding: CCAsymmetricPadding,
+ _ plainText: UnsafeRawPointer,
+ _ plainTextLen: Int,
+ _ cipherText: UnsafeMutableRawPointer,
+ _ cipherTextLen: UnsafeMutablePointer,
+ _ tagData: UnsafeRawPointer?,
+ _ tagDataLen: Int,
+ _ digestType: CC.CCDigestAlgorithm) -> CCCryptorStatus
+ fileprivate static let CCRSACryptorEncrypt: CCRSACryptorEncryptT? =
+ getFunc(dl!, f: "CCRSACryptorEncrypt")
+
+ fileprivate typealias CCRSACryptorDecryptT = @convention (c) (
+ _ privateKey: CCRSACryptorRef,
+ _ padding: CCAsymmetricPadding,
+ _ cipherText: UnsafeRawPointer,
+ _ cipherTextLen: Int,
+ _ plainText: UnsafeMutableRawPointer,
+ _ plainTextLen: UnsafeMutablePointer,
+ _ tagData: UnsafeRawPointer?,
+ _ tagDataLen: Int,
+ _ digestType: CC.CCDigestAlgorithm) -> CCCryptorStatus
+ fileprivate static let CCRSACryptorDecrypt: CCRSACryptorDecryptT? =
+ getFunc(dl!, f: "CCRSACryptorDecrypt")
+
+ fileprivate typealias CCRSACryptorExportT = @convention(c) (
+ _ key: CCRSACryptorRef,
+ _ out: UnsafeMutableRawPointer,
+ _ outLen: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCRSACryptorExport: CCRSACryptorExportT? =
+ getFunc(dl!, f: "CCRSACryptorExport")
+
+ fileprivate typealias CCRSACryptorImportT = @convention(c) (
+ _ keyPackage: UnsafeRawPointer,
+ _ keyPackageLen: Int,
+ _ key: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCRSACryptorImport: CCRSACryptorImportT? =
+ getFunc(dl!, f: "CCRSACryptorImport")
+
+ fileprivate typealias CCRSACryptorSignT = @convention(c) (
+ _ privateKey: CCRSACryptorRef,
+ _ padding: CCAsymmetricPadding,
+ _ hashToSign: UnsafeRawPointer,
+ _ hashSignLen: size_t,
+ _ digestType: CC.CCDigestAlgorithm,
+ _ saltLen: size_t,
+ _ signedData: UnsafeMutableRawPointer,
+ _ signedDataLen: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCRSACryptorSign: CCRSACryptorSignT? =
+ getFunc(dl!, f: "CCRSACryptorSign")
+
+ fileprivate typealias CCRSACryptorVerifyT = @convention(c) (
+ _ publicKey: CCRSACryptorRef,
+ _ padding: CCAsymmetricPadding,
+ _ hash: UnsafeRawPointer,
+ _ hashLen: size_t,
+ _ digestType: CC.CCDigestAlgorithm,
+ _ saltLen: size_t,
+ _ signedData: UnsafeRawPointer,
+ _ signedDataLen: size_t) -> CCCryptorStatus
+ fileprivate static let CCRSACryptorVerify: CCRSACryptorVerifyT? =
+ getFunc(dl!, f: "CCRSACryptorVerify")
+
+ fileprivate typealias CCRSACryptorCryptT = @convention(c) (
+ _ rsaKey: CCRSACryptorRef,
+ _ data: UnsafeRawPointer, _ dataLength: size_t,
+ _ out: UnsafeMutableRawPointer,
+ _ outLength: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCRSACryptorCrypt: CCRSACryptorCryptT? =
+ getFunc(dl!, f: "CCRSACryptorCrypt")
+}
+
+
+public typealias CCCryptorStatus = Int32
+@objc(SwCC_CCError) public enum CCError: CCCryptorStatus, Error {
+ case paramError = -4300
+ case bufferTooSmall = -4301
+ case memoryFailure = -4302
+ case alignmentError = -4303
+ case decodeError = -4304
+ case unimplemented = -4305
+ case overflow = -4306
+ case rngFailure = -4307
+
+ public static var debugLevel = 1
+
+ init(_ status: CCCryptorStatus, function: String = #function,
+ file: String = #file, line: Int = #line) {
+ self = CCError(rawValue: status)!
+ if CCError.debugLevel > 0 {
+ print("\(file):\(line): [\(function)] \(self._domain): \(self) (\(self.rawValue))")
+ }
+ }
+ init(_ type: CCError, function: String = #function, file: String = #file, line: Int = #line) {
+ self = type
+ if CCError.debugLevel > 0 {
+ print("\(file):\(line): [\(function)] \(self._domain): \(self) (\(self.rawValue))")
+ }
+ }
+}
+
+@objc(SwCC) open class CC: NSObject {
+
+ public static func generateRandom(_ size: Int) -> Data {
+ var data = Data(count: size)
+ data.withUnsafeMutableBytes { (dataBytes: UnsafeMutablePointer) -> Void in
+ _ = CCRandomGenerateBytes!(dataBytes, size)
+ }
+ return data
+ }
+
+ public typealias CCDigestAlgorithm = UInt32
+ @objc(SwCC_DigestAlgorithm) public enum DigestAlgorithm: CCDigestAlgorithm {
+ case none = 0
+ case md5 = 3
+ case rmd128 = 4, rmd160 = 5, rmd256 = 6, rmd320 = 7
+ case sha1 = 8
+ case sha224 = 9, sha256 = 10, sha384 = 11, sha512 = 12
+
+ var length: Int {
+ return CCDigestGetOutputSize!(self.rawValue)
+ }
+ }
+
+ public static func digest(_ data: Data, alg: DigestAlgorithm) -> Data {
+ var output = Data(count: alg.length)
+ output.withUnsafeMutableBytes { (outputBytes: UnsafeMutablePointer) -> Void in
+ _ = CCDigest!(alg.rawValue,
+ (data as NSData).bytes,
+ data.count,
+ outputBytes)
+ }
+ return output
+ }
+
+ public typealias CCHmacAlgorithm = UInt32
+ @objc(SwCC_HMACAlg) public enum HMACAlg: CCHmacAlgorithm {
+ case sha1, md5, sha256, sha384, sha512, sha224
+
+ var digestLength: Int {
+ switch self {
+ case .sha1: return 20
+ case .md5: return 16
+ case .sha256: return 32
+ case .sha384: return 48
+ case .sha512: return 64
+ case .sha224: return 28
+ }
+ }
+ }
+
+ public static func HMAC(_ data: Data, alg: HMACAlg, key: Data) -> Data {
+ var buffer = Data(count: alg.digestLength)
+ buffer.withUnsafeMutableBytes { (bufferBytes: UnsafeMutablePointer) -> Void in
+ CCHmac!(alg.rawValue,
+ (key as NSData).bytes, key.count,
+ (data as NSData).bytes, data.count,
+ bufferBytes)
+ }
+ return buffer
+ }
+
+ public typealias CCOperation = UInt32
+ @objc(SwCC_OpMode) public enum OpMode: CCOperation {
+ case encrypt = 0, decrypt
+ }
+
+ public typealias CCMode = UInt32
+ @objc(SwCC_BlockMode) public enum BlockMode: CCMode {
+ case ecb = 1, cbc, cfb, ctr, f8, lrw, ofb, xts, rc4, cfb8
+ var needIV: Bool {
+ switch self {
+ case .cbc, .cfb, .ctr, .ofb, .cfb8: return true
+ default: return false
+ }
+ }
+ }
+
+ @objc(SwCC_AuthBlockMode) public enum AuthBlockMode: CCMode {
+ case gcm = 11, ccm
+ }
+
+ public typealias CCAlgorithm = UInt32
+ @objc(SwCC_Algorithm) public enum Algorithm: CCAlgorithm {
+ case aes = 0, des, threeDES, cast, rc4, rc2, blowfish
+
+ var blockSize: Int? {
+ switch self {
+ case .aes: return 16
+ case .des: return 8
+ case .threeDES: return 8
+ case .cast: return 8
+ case .rc2: return 8
+ case .blowfish: return 8
+ default: return nil
+ }
+ }
+ }
+
+ public typealias CCPadding = UInt32
+ @objc(SwCC_Padding) public enum Padding: CCPadding {
+ case noPadding = 0, pkcs7Padding
+ }
+
+
+ public static func crypt(_ opMode: OpMode, blockMode: BlockMode,
+ algorithm: Algorithm, padding: Padding,
+ data: Data, key: Data, iv: Data) throws -> Data {
+ if blockMode.needIV {
+ guard iv.count == algorithm.blockSize else { throw CCError(.paramError) }
+ }
+
+ var cryptor: CCCryptorRef? = nil
+ var status = CCCryptorCreateWithMode!(
+ opMode.rawValue, blockMode.rawValue,
+ algorithm.rawValue, padding.rawValue,
+ (iv as NSData).bytes, (key as NSData).bytes, key.count,
+ nil, 0, 0,
+ CCModeOptions(), &cryptor)
+ guard status == noErr else { throw CCError(status) }
+
+ defer { _ = CCCryptorRelease!(cryptor!) }
+
+ let needed = CCCryptorGetOutputLength!(cryptor!, data.count, true)
+ var result = Data(count: needed)
+ var updateLen: size_t = 0
+ status = result.withUnsafeMutableBytes({ (resultBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCCryptorUpdate!(
+ cryptor!,
+ (data as NSData).bytes, data.count,
+ resultBytes, result.count,
+ &updateLen)
+ })
+ guard status == noErr else { throw CCError(status) }
+
+
+ var finalLen: size_t = 0
+ status = result.withUnsafeMutableBytes({ (resultBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCCryptorFinal!(
+ cryptor!,
+ resultBytes + updateLen,
+ result.count - updateLen,
+ &finalLen)
+ })
+ guard status == noErr else { throw CCError(status) }
+
+
+ result.count = updateLen + finalLen
+ return result
+ }
+
+ //The same behaviour as in the CCM pdf
+ //http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf
+ public static func cryptAuth(_ opMode: OpMode, blockMode: AuthBlockMode, algorithm: Algorithm,
+ data: Data, aData: Data,
+ key: Data, iv: Data, tagLength: Int, tag: Data?) throws -> NSDictionary {
+ let cryptFun = blockMode == .gcm ? GCM.crypt : CCM.crypt
+ if opMode == .encrypt {
+ let cryptResult = try cryptFun(opMode, algorithm, data,
+ key, iv, aData, tagLength)
+ let cipher = cryptResult["result"] as! Data;
+ let tag = cryptResult["tag"] as! Data;
+ var result = cipher
+ result.append(tag)
+ return NSDictionary.init(dictionary: [ "data": cipher, "tag": tag, "all": result ])
+ } else {
+ // let cipher = data.subdata(in: 0..<(data.count - tagLength))
+ var _tag = tag;
+ if(_tag == nil) {
+ _tag = data.subdata(in: (data.count - tagLength).. Bool {
+ return CCDigest != nil &&
+ CCDigestGetOutputSize != nil
+ }
+
+ public static func randomAvailable() -> Bool {
+ return CCRandomGenerateBytes != nil
+ }
+
+ public static func hmacAvailable() -> Bool {
+ return CCHmac != nil
+ }
+
+ public static func cryptorAvailable() -> Bool {
+ return CCCryptorCreateWithMode != nil &&
+ CCCryptorGetOutputLength != nil &&
+ CCCryptorUpdate != nil &&
+ CCCryptorFinal != nil &&
+ CCCryptorRelease != nil
+ }
+
+ public static func available() -> Bool {
+ return digestAvailable() &&
+ randomAvailable() &&
+ hmacAvailable() &&
+ cryptorAvailable() &&
+ KeyDerivation.available() &&
+ KeyWrap.available() &&
+ DH.available() &&
+ EC.available() &&
+ CRC.available() &&
+ CMAC.available() &&
+ GCM.available() &&
+ CCM.available()
+ }
+
+ fileprivate typealias CCCryptorRef = UnsafeRawPointer
+ fileprivate typealias CCRNGStatus = CCCryptorStatus
+ fileprivate typealias CC_LONG = UInt32
+ fileprivate typealias CCModeOptions = UInt32
+
+ fileprivate typealias CCRandomGenerateBytesT = @convention(c) (
+ _ bytes: UnsafeMutableRawPointer,
+ _ count: size_t) -> CCRNGStatus
+ fileprivate typealias CCDigestGetOutputSizeT = @convention(c) (
+ _ algorithm: CCDigestAlgorithm) -> size_t
+ fileprivate typealias CCDigestT = @convention(c) (
+ _ algorithm: CCDigestAlgorithm,
+ _ data: UnsafeRawPointer,
+ _ dataLen: size_t,
+ _ output: UnsafeMutableRawPointer) -> CInt
+
+ fileprivate typealias CCHmacT = @convention(c) (
+ _ algorithm: CCHmacAlgorithm,
+ _ key: UnsafeRawPointer,
+ _ keyLength: Int,
+ _ data: UnsafeRawPointer,
+ _ dataLength: Int,
+ _ macOut: UnsafeMutableRawPointer) -> Void
+ fileprivate typealias CCCryptorCreateWithModeT = @convention(c)(
+ _ op: CCOperation,
+ _ mode: CCMode,
+ _ alg: CCAlgorithm,
+ _ padding: CCPadding,
+ _ iv: UnsafeRawPointer?,
+ _ key: UnsafeRawPointer, _ keyLength: Int,
+ _ tweak: UnsafeRawPointer?, _ tweakLength: Int,
+ _ numRounds: Int32, _ options: CCModeOptions,
+ _ cryptorRef: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate typealias CCCryptorGetOutputLengthT = @convention(c)(
+ _ cryptorRef: CCCryptorRef,
+ _ inputLength: size_t,
+ _ final: Bool) -> size_t
+ fileprivate typealias CCCryptorUpdateT = @convention(c)(
+ _ cryptorRef: CCCryptorRef,
+ _ dataIn: UnsafeRawPointer,
+ _ dataInLength: Int,
+ _ dataOut: UnsafeMutableRawPointer,
+ _ dataOutAvailable: Int,
+ _ dataOutMoved: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate typealias CCCryptorFinalT = @convention(c)(
+ _ cryptorRef: CCCryptorRef,
+ _ dataOut: UnsafeMutableRawPointer,
+ _ dataOutAvailable: Int,
+ _ dataOutMoved: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate typealias CCCryptorReleaseT = @convention(c)
+ (_ cryptorRef: CCCryptorRef) -> CCCryptorStatus
+
+
+ fileprivate static let dl = dlopen("/usr/lib/system/libcommonCrypto.dylib", RTLD_NOW)
+ fileprivate static let CCRandomGenerateBytes: CCRandomGenerateBytesT? =
+ getFunc(dl!, f: "CCRandomGenerateBytes")
+ fileprivate static let CCDigestGetOutputSize: CCDigestGetOutputSizeT? =
+ getFunc(dl!, f: "CCDigestGetOutputSize")
+ fileprivate static let CCDigest: CCDigestT? = getFunc(dl!, f: "CCDigest")
+ fileprivate static let CCHmac: CCHmacT? = getFunc(dl!, f: "CCHmac")
+ fileprivate static let CCCryptorCreateWithMode: CCCryptorCreateWithModeT? =
+ getFunc(dl!, f: "CCCryptorCreateWithMode")
+ fileprivate static let CCCryptorGetOutputLength: CCCryptorGetOutputLengthT? =
+ getFunc(dl!, f: "CCCryptorGetOutputLength")
+ fileprivate static let CCCryptorUpdate: CCCryptorUpdateT? =
+ getFunc(dl!, f: "CCCryptorUpdate")
+ fileprivate static let CCCryptorFinal: CCCryptorFinalT? =
+ getFunc(dl!, f: "CCCryptorFinal")
+ fileprivate static let CCCryptorRelease: CCCryptorReleaseT? =
+ getFunc(dl!, f: "CCCryptorRelease")
+
+ @objc open class SwGCM_CCM_cryptResult: NSObject {
+ @objc public var result: Data;
+ @objc public var tag: Data;
+ @objc public init(result: Data, tag: Data) {
+ self.result = result;
+ self.tag = tag;
+ }
+ }
+
+ @objc(SwGCM) open class GCM: NSObject {
+
+
+ public static func crypt(_ opMode: OpMode, algorithm: Algorithm, data: Data,
+ key: Data, iv: Data,
+ aData: Data, tagLength: Int) throws -> NSDictionary {
+ var result = Data(count: data.count)
+ var tagLength_ = tagLength
+ var tag = Data(count: tagLength)
+ let status = result.withUnsafeMutableBytes {
+ (resultBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return tag.withUnsafeMutableBytes({ (tagBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCCryptorGCM!(opMode.rawValue, algorithm.rawValue,
+ (key as NSData).bytes, key.count, (iv as NSData).bytes, iv.count,
+ (aData as NSData).bytes, aData.count,
+ (data as NSData).bytes, data.count,
+ resultBytes, tagBytes, &tagLength_)
+ })
+ }
+ guard status == noErr else { throw CCError(status) }
+
+ tag.count = tagLength_
+ return NSDictionary.init(dictionary: ["result": result, "tag": tag])
+ }
+
+ public static func available() -> Bool {
+ if CCCryptorGCM != nil {
+ return true
+ }
+ return false
+ }
+
+ fileprivate typealias CCCryptorGCMT = @convention(c) (_ op: CCOperation, _ alg: CCAlgorithm,
+ _ key: UnsafeRawPointer, _ keyLength: Int,
+ _ iv: UnsafeRawPointer, _ ivLen: Int,
+ _ aData: UnsafeRawPointer, _ aDataLen: Int,
+ _ dataIn: UnsafeRawPointer, _ dataInLength: Int,
+ _ dataOut: UnsafeMutableRawPointer,
+ _ tag: UnsafeRawPointer, _ tagLength: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCCryptorGCM: CCCryptorGCMT? = getFunc(dl!, f: "CCCryptorGCM")
+
+ }
+
+ @objc(SwCCM) open class CCM: NSObject {
+
+ public static func crypt(_ opMode: OpMode, algorithm: Algorithm, data: Data,
+ key: Data, iv: Data,
+ aData: Data, tagLength: Int) throws -> NSDictionary {
+ var cryptor: CCCryptorRef? = nil
+ var status = CCCryptorCreateWithMode!(
+ opMode.rawValue, AuthBlockMode.ccm.rawValue,
+ algorithm.rawValue, Padding.noPadding.rawValue,
+ nil, (key as NSData).bytes, key.count, nil, 0,
+ 0, CCModeOptions(), &cryptor)
+ guard status == noErr else { throw CCError(status) }
+ defer { _ = CCCryptorRelease!(cryptor!) }
+
+ status = CCCryptorAddParameter!(cryptor!,
+ Parameter.dataSize.rawValue, nil, data.count)
+ guard status == noErr else { throw CCError(status) }
+
+ status = CCCryptorAddParameter!(cryptor!,
+ Parameter.macSize.rawValue, nil, tagLength)
+ guard status == noErr else { throw CCError(status) }
+
+ status = CCCryptorAddParameter!(cryptor!,
+ Parameter.iv.rawValue, (iv as NSData).bytes, iv.count)
+ guard status == noErr else { throw CCError(status) }
+
+ status = CCCryptorAddParameter!(cryptor!,
+ Parameter.authData.rawValue, (aData as NSData).bytes, aData.count)
+ guard status == noErr else { throw CCError(status) }
+
+ var result = Data(count: data.count)
+
+ var updateLen: size_t = 0
+ status = result.withUnsafeMutableBytes({ (resultBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCCryptorUpdate!(
+ cryptor!, (data as NSData).bytes, data.count,
+ resultBytes, result.count,
+ &updateLen)
+ })
+ guard status == noErr else { throw CCError(status) }
+
+ var finalLen: size_t = 0
+ status = result.withUnsafeMutableBytes({ (resultBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCCryptorFinal!(cryptor!, resultBytes + updateLen,
+ result.count - updateLen,
+ &finalLen)
+ })
+ guard status == noErr else { throw CCError(status) }
+
+ result.count = updateLen + finalLen
+
+ var tagLength_ = tagLength
+ var tag = Data(count: tagLength)
+ status = tag.withUnsafeMutableBytes({ (tagBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCCryptorGetParameter!(cryptor!, Parameter.authTag.rawValue,
+ tagBytes, &tagLength_)
+ })
+ guard status == noErr else { throw CCError(status) }
+
+ tag.count = tagLength_
+
+ return NSDictionary.init(dictionary: ["result": result, "tag": tag])
+ }
+
+ public static func available() -> Bool {
+ if CCCryptorAddParameter != nil &&
+ CCCryptorGetParameter != nil {
+ return true
+ }
+ return false
+ }
+
+ fileprivate typealias CCParameter = UInt32
+ fileprivate enum Parameter: CCParameter {
+ case iv, authData, macSize, dataSize, authTag
+ }
+ fileprivate typealias CCCryptorAddParameterT = @convention(c) (_ cryptorRef: CCCryptorRef,
+ _ parameter: CCParameter,
+ _ data: UnsafeRawPointer?, _ dataLength: size_t) -> CCCryptorStatus
+ fileprivate static let CCCryptorAddParameter: CCCryptorAddParameterT? =
+ getFunc(dl!, f: "CCCryptorAddParameter")
+
+ fileprivate typealias CCCryptorGetParameterT = @convention(c) (_ cryptorRef: CCCryptorRef,
+ _ parameter: CCParameter,
+ _ data: UnsafeRawPointer, _ dataLength: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCCryptorGetParameter: CCCryptorGetParameterT? =
+ getFunc(dl!, f: "CCCryptorGetParameter")
+ }
+
+ @objc(SwDH) open class DH: NSObject {
+
+ @objc(SwDH_DHParam) public enum DHParam: Int {
+ case rfc3526Group5
+ }
+
+ //this is stateful in CommonCrypto too, sry
+ @objc(SwDH_DH) open class DH: NSObject {
+ fileprivate var ref: CCDHRef? = nil
+
+ public init(dhParam: DHParam) throws {
+ ref = CCDHCreate!(kCCDHRFC3526Group5!)
+ guard ref != nil else {
+ throw CCError(.paramError)
+ }
+ }
+
+ public func generateKey() throws -> Data {
+ var outputLength = 8192
+ var output = Data(count: outputLength)
+ let status = output.withUnsafeMutableBytes { (outputBytes: UnsafeMutablePointer) -> CInt in
+ return CCDHGenerateKey!(ref!, outputBytes, &outputLength)
+ }
+ output.count = outputLength
+ guard status != -1 else {
+ throw CCError(.paramError)
+ }
+ return output
+ }
+
+ public func computeKey(_ peerKey: Data) throws -> Data {
+ var sharedKeyLength = 8192
+ var sharedKey = Data(count: sharedKeyLength)
+ let status = sharedKey.withUnsafeMutableBytes { (sharedKeyBytes: UnsafeMutablePointer) -> CInt in
+ return CCDHComputeKey!(
+ sharedKeyBytes, &sharedKeyLength,
+ (peerKey as NSData).bytes, peerKey.count,
+ ref!)
+ }
+ sharedKey.count = sharedKeyLength
+ guard status == 0 else {
+ throw CCError(.paramError)
+ }
+ return sharedKey
+ }
+
+ deinit {
+ if ref != nil {
+ CCDHRelease!(ref!)
+ }
+ }
+ }
+
+
+ public static func available() -> Bool {
+ return CCDHCreate != nil &&
+ CCDHRelease != nil &&
+ CCDHGenerateKey != nil &&
+ CCDHComputeKey != nil
+ }
+
+ fileprivate typealias CCDHParameters = UnsafeRawPointer
+ fileprivate typealias CCDHRef = UnsafeRawPointer
+
+ fileprivate typealias kCCDHRFC3526Group5TM = UnsafePointer
+ fileprivate static let kCCDHRFC3526Group5M: kCCDHRFC3526Group5TM? =
+ getFunc(dl!, f: "kCCDHRFC3526Group5")
+ fileprivate static let kCCDHRFC3526Group5 = kCCDHRFC3526Group5M?.pointee
+
+ fileprivate typealias CCDHCreateT = @convention(c) (
+ _ dhParameter: CCDHParameters) -> CCDHRef
+ fileprivate static let CCDHCreate: CCDHCreateT? = getFunc(dl!, f: "CCDHCreate")
+
+ fileprivate typealias CCDHReleaseT = @convention(c) (
+ _ ref: CCDHRef) -> Void
+ fileprivate static let CCDHRelease: CCDHReleaseT? = getFunc(dl!, f: "CCDHRelease")
+
+ fileprivate typealias CCDHGenerateKeyT = @convention(c) (
+ _ ref: CCDHRef,
+ _ output: UnsafeMutableRawPointer, _ outputLength: UnsafeMutablePointer) -> CInt
+ fileprivate static let CCDHGenerateKey: CCDHGenerateKeyT? = getFunc(dl!, f: "CCDHGenerateKey")
+
+ fileprivate typealias CCDHComputeKeyT = @convention(c) (
+ _ sharedKey: UnsafeMutableRawPointer, _ sharedKeyLen: UnsafeMutablePointer,
+ _ peerPubKey: UnsafeRawPointer, _ peerPubKeyLen: size_t,
+ _ ref: CCDHRef) -> CInt
+ fileprivate static let CCDHComputeKey: CCDHComputeKeyT? = getFunc(dl!, f: "CCDHComputeKey")
+ }
+
+ @objc(SwEC) open class EC: NSObject {
+
+ @objc open class SwEC_generateKeyPairResult: NSObject {
+ @objc public var privDERKey: Data;
+ @objc public var pubDERKey: Data;
+ @objc public init(privDERKey: Data, pubDERKey: Data) {
+ self.privDERKey = privDERKey;
+ self.pubDERKey = pubDERKey;
+ }
+ }
+
+
+ public static func generateKeyPair(_ keySize: Int) throws -> NSDictionary {
+ var privKey: CCECCryptorRef? = nil
+ var pubKey: CCECCryptorRef? = nil
+ let status = CCECCryptorGeneratePair!(
+ keySize,
+ &pubKey,
+ &privKey)
+ guard status == noErr else { throw CCError(status) }
+
+ defer {
+ CCECCryptorRelease!(privKey!)
+ CCECCryptorRelease!(pubKey!)
+ }
+
+ let privDERKey = try exportKey(privKey!, format: .importKeyBinary, type: .keyPrivate)
+ let pubDERKey = try exportKey(pubKey!, format: .importKeyBinary, type: .keyPublic)
+ return NSDictionary.init(dictionary: [ "privDERKey": privDERKey, "pubDERKey": pubDERKey ])
+ }
+
+ public static func signHash(_ privateKey: Data, hash: Data) throws -> Data {
+ let privKey = try importKey(privateKey, format: .importKeyBinary, keyType: .keyPrivate)
+ defer { CCECCryptorRelease!(privKey) }
+
+ var signedDataLength = 4096
+ var signedData = Data(count:signedDataLength)
+ let status = signedData.withUnsafeMutableBytes {
+ (signedDataBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCECCryptorSignHash!(
+ privKey,
+ (hash as NSData).bytes, hash.count,
+ signedDataBytes, &signedDataLength)
+ }
+ guard status == noErr else { throw CCError(status) }
+
+ signedData.count = signedDataLength
+ return signedData
+ }
+
+ public static func verifyHash(_ publicKey: Data,
+ hash: Data,
+ signedData: Data) throws -> Bool {
+ let pubKey = try importKey(publicKey, format: .importKeyBinary, keyType: .keyPublic)
+ defer { CCECCryptorRelease!(pubKey) }
+
+ var valid: UInt32 = 0
+ let status = CCECCryptorVerifyHash!(
+ pubKey,
+ (hash as NSData).bytes, hash.count,
+ (signedData as NSData).bytes, signedData.count,
+ &valid)
+ guard status == noErr else { throw CCError(status) }
+
+ return valid != 0
+ }
+
+ public static func computeSharedSecret(_ privateKey: Data,
+ publicKey: Data) throws -> Data {
+ let privKey = try importKey(privateKey, format: .importKeyBinary, keyType: .keyPrivate)
+ let pubKey = try importKey(publicKey, format: .importKeyBinary, keyType: .keyPublic)
+ defer {
+ CCECCryptorRelease!(privKey)
+ CCECCryptorRelease!(pubKey)
+ }
+
+ var outSize = 8192
+ var result = Data(count:outSize)
+ let status = result.withUnsafeMutableBytes {
+ (resultBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCECCryptorComputeSharedSecret!(privKey, pubKey, resultBytes, &outSize)
+ }
+ guard status == noErr else { throw CCError(status) }
+
+ result.count = outSize
+ return result
+ }
+
+ fileprivate static func importKey(_ key: Data, format: KeyExternalFormat,
+ keyType: KeyType) throws -> CCECCryptorRef {
+ var impKey: CCECCryptorRef? = nil
+ let status = CCECCryptorImportKey!(format.rawValue,
+ (key as NSData).bytes, key.count,
+ keyType.rawValue, &impKey)
+ guard status == noErr else { throw CCError(status) }
+
+ return impKey!
+ }
+
+ fileprivate static func exportKey(_ key: CCECCryptorRef, format: KeyExternalFormat,
+ type: KeyType) throws -> Data {
+ var expKeyLength = 8192
+ var expKey = Data(count:expKeyLength)
+ let status = expKey.withUnsafeMutableBytes {
+ (expKeyBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCECCryptorExportKey!(
+ format.rawValue,
+ expKeyBytes,
+ &expKeyLength,
+ type.rawValue,
+ key)
+ }
+ guard status == noErr else { throw CCError(status) }
+
+ expKey.count = expKeyLength
+ return expKey
+ }
+
+ public static func available() -> Bool {
+ return CCECCryptorGeneratePair != nil &&
+ CCECCryptorImportKey != nil &&
+ CCECCryptorExportKey != nil &&
+ CCECCryptorRelease != nil &&
+ CCECCryptorSignHash != nil &&
+ CCECCryptorVerifyHash != nil &&
+ CCECCryptorComputeSharedSecret != nil
+ }
+
+ fileprivate enum KeyType: CCECKeyType {
+ case keyPublic = 0, keyPrivate
+ case blankPublicKey = 97, blankPrivateKey
+ case badKey = 99
+ }
+ fileprivate typealias CCECKeyType = UInt32
+
+ fileprivate typealias CCECKeyExternalFormat = UInt32
+ fileprivate enum KeyExternalFormat: CCECKeyExternalFormat {
+ case importKeyBinary = 0, importKeyDER
+ }
+
+ fileprivate typealias CCECCryptorRef = UnsafeRawPointer
+ fileprivate typealias CCECCryptorGeneratePairT = @convention(c) (
+ _ keySize: size_t ,
+ _ publicKey: UnsafeMutablePointer,
+ _ privateKey: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCECCryptorGeneratePair: CCECCryptorGeneratePairT? =
+ getFunc(dl!, f: "CCECCryptorGeneratePair")
+
+ fileprivate typealias CCECCryptorImportKeyT = @convention(c) (
+ _ format: CCECKeyExternalFormat,
+ _ keyPackage: UnsafeRawPointer, _ keyPackageLen: size_t,
+ _ keyType: CCECKeyType, _ key: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCECCryptorImportKey: CCECCryptorImportKeyT? =
+ getFunc(dl!, f: "CCECCryptorImportKey")
+
+ fileprivate typealias CCECCryptorExportKeyT = @convention(c) (
+ _ format: CCECKeyExternalFormat,
+ _ keyPackage: UnsafeRawPointer,
+ _ keyPackageLen: UnsafePointer,
+ _ keyType: CCECKeyType, _ key: CCECCryptorRef) -> CCCryptorStatus
+ fileprivate static let CCECCryptorExportKey: CCECCryptorExportKeyT? =
+ getFunc(dl!, f: "CCECCryptorExportKey")
+
+ fileprivate typealias CCECCryptorReleaseT = @convention(c) (
+ _ key: CCECCryptorRef) -> Void
+ fileprivate static let CCECCryptorRelease: CCECCryptorReleaseT? =
+ getFunc(dl!, f: "CCECCryptorRelease")
+
+ fileprivate typealias CCECCryptorSignHashT = @convention(c)(
+ _ privateKey: CCECCryptorRef,
+ _ hashToSign: UnsafeRawPointer,
+ _ hashSignLen: size_t,
+ _ signedData: UnsafeMutableRawPointer,
+ _ signedDataLen: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCECCryptorSignHash: CCECCryptorSignHashT? =
+ getFunc(dl!, f: "CCECCryptorSignHash")
+
+ fileprivate typealias CCECCryptorVerifyHashT = @convention(c)(
+ _ publicKey: CCECCryptorRef,
+ _ hash: UnsafeRawPointer, _ hashLen: size_t,
+ _ signedData: UnsafeRawPointer, _ signedDataLen: size_t,
+ _ valid: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCECCryptorVerifyHash: CCECCryptorVerifyHashT? =
+ getFunc(dl!, f: "CCECCryptorVerifyHash")
+
+ fileprivate typealias CCECCryptorComputeSharedSecretT = @convention(c)(
+ _ privateKey: CCECCryptorRef,
+ _ publicKey: CCECCryptorRef,
+ _ out: UnsafeMutableRawPointer,
+ _ outLen: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CCECCryptorComputeSharedSecret: CCECCryptorComputeSharedSecretT? =
+ getFunc(dl!, f: "CCECCryptorComputeSharedSecret")
+ }
+
+ @objc(SwCRC) open class CRC: NSObject {
+
+ public typealias CNcrc = UInt32
+ @objc(SwCRC_Mode) public enum Mode: CNcrc {
+ case crc8 = 10,
+ crc8ICODE = 11,
+ crc8ITU = 12,
+ crc8ROHC = 13,
+ crc8WCDMA = 14,
+ crc16 = 20,
+ crc16CCITTTrue = 21,
+ crc16CCITTFalse = 22,
+ crc16USB = 23,
+ crc16XMODEM = 24,
+ crc16DECTR = 25,
+ crc16DECTX = 26,
+ crc16ICODE = 27,
+ crc16VERIFONE = 28,
+ crc16A = 29,
+ crc16B = 30,
+ crc16Fletcher = 31,
+ crc32Adler = 40,
+ crc32 = 41,
+ crc32CASTAGNOLI = 42,
+ crc32BZIP2 = 43,
+ crc32MPEG2 = 44,
+ crc32POSIX = 45,
+ crc32XFER = 46,
+ crc64ECMA182 = 60
+ }
+
+ public static func crc(_ input: Data, mode: Mode) throws -> UInt64 {
+ var result: UInt64 = 0
+ let status = CNCRC!(
+ mode.rawValue,
+ (input as NSData).bytes, input.count,
+ &result)
+ guard status == noErr else {
+ throw CCError(status)
+ }
+ return result
+ }
+
+ public static func available() -> Bool {
+ return CNCRC != nil
+ }
+
+ fileprivate typealias CNCRCT = @convention(c) (
+ _ algorithm: CNcrc,
+ _ input: UnsafeRawPointer, _ inputLen: size_t,
+ _ result: UnsafeMutablePointer) -> CCCryptorStatus
+ fileprivate static let CNCRC: CNCRCT? = getFunc(dl!, f: "CNCRC")
+ }
+
+ @objc(SwCMAC) open class CMAC: NSObject {
+
+ public static func AESCMAC(_ data: Data, key: Data) -> Data {
+ var result = Data(count: 16)
+ result.withUnsafeMutableBytes { (resultBytes: UnsafeMutablePointer) -> Void in
+ CCAESCmac!((key as NSData).bytes,
+ (data as NSData).bytes, data.count,
+ resultBytes)
+ }
+ return result
+ }
+
+ public static func available() -> Bool {
+ return CCAESCmac != nil
+ }
+
+ fileprivate typealias CCAESCmacT = @convention(c) (
+ _ key: UnsafeRawPointer,
+ _ data: UnsafeRawPointer, _ dataLen: size_t,
+ _ macOut: UnsafeMutableRawPointer) -> Void
+ fileprivate static let CCAESCmac: CCAESCmacT? = getFunc(dl!, f: "CCAESCmac")
+ }
+
+ @objc(SwKeyDerivation) open class KeyDerivation: NSObject {
+
+ public typealias CCPseudoRandomAlgorithm = UInt32
+ @objc(SwKeyDerivation_PRFAlg) public enum PRFAlg: CCPseudoRandomAlgorithm {
+ case sha1 = 1, sha224, sha256, sha384, sha512
+ var cc: CC.HMACAlg {
+ switch self {
+ case .sha1: return .sha1
+ case .sha224: return .sha224
+ case .sha256: return .sha256
+ case .sha384: return .sha384
+ case .sha512: return .sha512
+ }
+ }
+ }
+
+ public static func PBKDF2(_ password: String, salt: Data,
+ prf: PRFAlg, rounds: UInt32) throws -> Data {
+
+ var result = Data(count:prf.cc.digestLength)
+ let passwData = password.data(using: String.Encoding.utf8)!
+ let status = result.withUnsafeMutableBytes {
+ (passwDataBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCKeyDerivationPBKDF!(PBKDFAlgorithm.pbkdf2.rawValue,
+ (passwData as NSData).bytes, passwData.count,
+ (salt as NSData).bytes, salt.count,
+ prf.rawValue, rounds,
+ passwDataBytes, result.count)
+ }
+ guard status == noErr else { throw CCError(status) }
+
+ return result
+ }
+
+ public static func available() -> Bool {
+ return CCKeyDerivationPBKDF != nil
+ }
+
+ fileprivate typealias CCPBKDFAlgorithm = UInt32
+ fileprivate enum PBKDFAlgorithm: CCPBKDFAlgorithm {
+ case pbkdf2 = 2
+ }
+
+ fileprivate typealias CCKeyDerivationPBKDFT = @convention(c) (
+ _ algorithm: CCPBKDFAlgorithm,
+ _ password: UnsafeRawPointer, _ passwordLen: size_t,
+ _ salt: UnsafeRawPointer, _ saltLen: size_t,
+ _ prf: CCPseudoRandomAlgorithm, _ rounds: uint,
+ _ derivedKey: UnsafeMutableRawPointer, _ derivedKeyLen: size_t) -> CCCryptorStatus
+ fileprivate static let CCKeyDerivationPBKDF: CCKeyDerivationPBKDFT? =
+ getFunc(dl!, f: "CCKeyDerivationPBKDF")
+ }
+
+}
+
+@objc(SwKeyWrap) public class KeyWrap: NSObject {
+
+ fileprivate static let dl = dlopen("/usr/lib/system/libcommonCrypto.dylib", RTLD_NOW)
+
+ fileprivate static let rfc3394IVData: [UInt8] = [0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6]
+ public static let rfc3394IV = Data(bytes: UnsafePointer(rfc3394IVData), count:rfc3394IVData.count)
+
+ public static func SymmetricKeyWrap(_ iv: Data,
+ kek: Data,
+ rawKey: Data) throws -> Data {
+ let alg = WrapAlg.aes.rawValue
+ var wrappedKeyLength = CCSymmetricWrappedSize!(alg, rawKey.count)
+ var wrappedKey = Data(count:wrappedKeyLength)
+ let status = wrappedKey.withUnsafeMutableBytes {
+ (wrappedKeyBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCSymmetricKeyWrap!(
+ alg,
+ (iv as NSData).bytes, iv.count,
+ (kek as NSData).bytes, kek.count,
+ (rawKey as NSData).bytes, rawKey.count,
+ wrappedKeyBytes, &wrappedKeyLength)
+ }
+ guard status == noErr else { throw CCError(status) }
+
+ wrappedKey.count = wrappedKeyLength
+ return wrappedKey
+ }
+
+ public static func SymmetricKeyUnwrap(_ iv: Data,
+ kek: Data,
+ wrappedKey: Data) throws -> Data {
+ let alg = WrapAlg.aes.rawValue
+ var rawKeyLength = CCSymmetricUnwrappedSize!(alg, wrappedKey.count)
+ var rawKey = Data(count:rawKeyLength)
+ let status = rawKey.withUnsafeMutableBytes {
+ (rawKeyBytes: UnsafeMutablePointer) -> CCCryptorStatus in
+ return CCSymmetricKeyUnwrap!(
+ alg,
+ (iv as NSData).bytes, iv.count,
+ (kek as NSData).bytes, kek.count,
+ (wrappedKey as NSData).bytes, wrappedKey.count,
+ rawKeyBytes, &rawKeyLength)
+ }
+ guard status == noErr else { throw CCError(status) }
+
+ rawKey.count = rawKeyLength
+ return rawKey
+ }
+
+ public static func available() -> Bool {
+ return CCSymmetricKeyWrap != nil &&
+ CCSymmetricKeyUnwrap != nil &&
+ CCSymmetricWrappedSize != nil &&
+ CCSymmetricUnwrappedSize != nil
+ }
+
+ fileprivate enum WrapAlg: CCWrappingAlgorithm {
+ case aes = 1
+ }
+ fileprivate typealias CCWrappingAlgorithm = UInt32
+
+ fileprivate typealias CCSymmetricKeyWrapT = @convention(c) (
+ _ algorithm: CCWrappingAlgorithm,
+ _ iv: UnsafeRawPointer, _ ivLen: size_t,
+ _ kek: UnsafeRawPointer, _ kekLen: size_t,
+ _ rawKey: UnsafeRawPointer, _ rawKeyLen: size_t,
+ _ wrappedKey: UnsafeMutableRawPointer,
+ _ wrappedKeyLen: UnsafePointer) -> CCCryptorStatus
+ fileprivate static let CCSymmetricKeyWrap: CCSymmetricKeyWrapT? = getFunc(dl!, f: "CCSymmetricKeyWrap")
+
+ fileprivate typealias CCSymmetricKeyUnwrapT = @convention(c) (
+ _ algorithm: CCWrappingAlgorithm,
+ _ iv: UnsafeRawPointer, _ ivLen: size_t,
+ _ kek: UnsafeRawPointer, _ kekLen: size_t,
+ _ wrappedKey: UnsafeRawPointer, _ wrappedKeyLen: size_t,
+ _ rawKey: UnsafeMutableRawPointer,
+ _ rawKeyLen: UnsafePointer) -> CCCryptorStatus
+ fileprivate static let CCSymmetricKeyUnwrap: CCSymmetricKeyUnwrapT? =
+ getFunc(dl!, f: "CCSymmetricKeyUnwrap")
+
+ fileprivate typealias CCSymmetricWrappedSizeT = @convention(c) (
+ _ algorithm: CCWrappingAlgorithm,
+ _ rawKeyLen: size_t) -> size_t
+ fileprivate static let CCSymmetricWrappedSize: CCSymmetricWrappedSizeT? =
+ getFunc(dl!, f: "CCSymmetricWrappedSize")
+
+ fileprivate typealias CCSymmetricUnwrappedSizeT = @convention(c) (
+ _ algorithm: CCWrappingAlgorithm,
+ _ wrappedKeyLen: size_t) -> size_t
+ fileprivate static let CCSymmetricUnwrappedSize: CCSymmetricUnwrappedSizeT? =
+ getFunc(dl!, f: "CCSymmetricUnwrappedSize")
+
+}
+
+private func getFunc(_ from: UnsafeMutableRawPointer, f: String) -> T? {
+ let sym = dlsym(from, f)
+ guard sym != nil else {
+ return nil
+ }
+ return unsafeBitCast(sym, to: T.self)
+}
+
+extension Data {
+ /// Create hexadecimal string representation of Data object.
+ ///
+ /// - returns: String representation of this Data object.
+
+ public func hexadecimalString() -> String {
+ var hexstr = String()
+ self.withUnsafeBytes { (data: UnsafePointer) -> Void in
+ for i in UnsafeBufferPointer(start: data, count: count) {
+ hexstr += String(format: "%02X", i)
+ }
+ }
+ return hexstr
+ }
+
+ public func arrayOfBytes() -> [UInt8] {
+ let count = self.count / MemoryLayout.size
+ var bytesArray = [UInt8](repeating: 0, count: count)
+ (self as NSData).getBytes(&bytesArray, length:count * MemoryLayout.size)
+ return bytesArray
+ }
+
+ fileprivate var bytesView: BytesView { return BytesView(self) }
+
+ fileprivate func bytesViewRange(_ range: NSRange) -> BytesView {
+ return BytesView(self, range: range)
+ }
+
+ fileprivate struct BytesView: Collection {
+ // The view retains the Data. That's on purpose.
+ // Data doesn't retain the view, so there's no loop.
+ let data: Data
+ init(_ data: Data) {
+ self.data = data
+ self.startIndex = 0
+ self.endIndex = data.count
+ }
+
+ init(_ data: Data, range: NSRange ) {
+ self.data = data
+ self.startIndex = range.location
+ self.endIndex = range.location + range.length
+ }
+
+ subscript (position: Int) -> UInt8 {
+ var value: UInt8 = 0
+ data.withUnsafeBytes { (dataBytes: UnsafePointer) -> Void in
+ value = UnsafeBufferPointer(start: dataBytes, count: data.count)[position]
+ }
+ return value
+ }
+ subscript (bounds: Range) -> Data {
+ return data.subdata(in: bounds)
+ }
+ fileprivate func formIndex(after i: inout Int) {
+ i += 1
+ }
+ fileprivate func index(after i: Int) -> Int {
+ return i + 1
+ }
+ var startIndex: Int
+ var endIndex: Int
+ var length: Int { return endIndex - startIndex }
+ }
+}
+
+extension String {
+
+ /// Create Data from hexadecimal string representation
+ ///
+ /// This takes a hexadecimal representation and creates a Data object. Note, if the string has
+ /// any spaces, those are removed. Also if the string started with a '<' or ended with a '>',
+ /// those are removed, too. This does no validation of the string to ensure it's a valid
+ /// hexadecimal string
+ ///
+ /// The use of `strtoul` inspired by Martin R at http://stackoverflow.com/a/26284562/1271826
+ ///
+ /// - returns: Data represented by this hexadecimal string.
+ /// Returns nil if string contains characters outside the 0-9 and a-f range.
+
+ public func dataFromHexadecimalString() -> Data? {
+ let trimmedString = self.trimmingCharacters(
+ in: CharacterSet(charactersIn: "<> ")).replacingOccurrences(
+ of: " ", with: "")
+
+ // make sure the cleaned up string consists solely of hex digits,
+ // and that we have even number of them
+
+ let regex = try! NSRegularExpression(pattern: "^[0-9a-f]*$", options: .caseInsensitive)
+
+ let found = regex.firstMatch(in: trimmedString, options: [],
+ range: NSRange(location: 0,
+ length: trimmedString.characters.count))
+ guard found != nil &&
+ found?.range.location != NSNotFound &&
+ trimmedString.characters.count % 2 == 0 else {
+ return nil
+ }
+
+ // everything ok, so now let's build Data
+
+ var data = Data(capacity: trimmedString.characters.count / 2)
+ var index: String.Index? = trimmedString.startIndex
+
+ while let i = index {
+ let byteString = trimmedString.substring(with: i ..< trimmedString.index(i, offsetBy: 2))
+ let num = UInt8(byteString.withCString { strtoul($0, nil, 16) })
+ data.append([num] as [UInt8], count: 1)
+
+ index = trimmedString.index(i, offsetBy: 2, limitedBy: trimmedString.endIndex)
+ if index == trimmedString.endIndex { break }
+ }
+
+ return data
+ }
+}
diff --git a/src/platforms/ios/Podfile b/src/platforms/ios/Podfile
index b63166d..48ef660 100644
--- a/src/platforms/ios/Podfile
+++ b/src/platforms/ios/Podfile
@@ -1,8 +1,8 @@
-platform :ios, '8.3'
+platform :ios, '9.0'
pod 'libsodium', '~> 1.0.12'
-pod 'AesGcm', '~> 0.1'
-pod 'SwiftyRSA/ObjC'
+pod 'SwiftyRSA/ObjC', '~> 1.2.0'
+pod 'CryptoUtils', :path => '../../node_modules/nativescript-crypto/platforms/ios/CryptoUtils'
post_install do |installer|
installer.pods_project.targets.each do |target|
diff --git a/src/platforms/ios/SwiftyRSA.typings.txt b/src/platforms/ios/SwiftyRSA.typings.txt
deleted file mode 100644
index b139818..0000000
--- a/src/platforms/ios/SwiftyRSA.typings.txt
+++ /dev/null
@@ -1,183 +0,0 @@
-
-declare class ClearMessage extends NSObject {
-
- static alloc(): ClearMessage; // inherited from NSObject
-
- static new(): ClearMessage; // inherited from NSObject
-
- readonly base64String: string;
-
- readonly data: NSData;
-
- constructor(o: { base64Encoded: string; });
-
- constructor(o: { data: NSData; });
-
- constructor(o: { string: string; using: number; });
-
- encryptedWithPaddingError(key: PublicKey, padding: SecPadding): EncryptedMessage;
-
- initWithBase64EncodedError(base64String: string): this;
-
- initWithData(data: NSData): this;
-
- initWithStringUsingError(string: string, rawEncoding: number): this;
-
- signedWithDigestTypeError(key: PrivateKey, digestType: DigestType): Signature;
-
- verifyWithSignatureDigestTypeError(key: PublicKey, signature: Signature, digestType: DigestType): VerificationResult;
-}
-
-declare const enum DigestType {
-
- Sha1 = 0,
-
- Sha224 = 1,
-
- Sha256 = 2,
-
- Sha384 = 3,
-
- Sha512 = 4
-}
-
-declare class EncryptedMessage extends NSObject {
-
- static alloc(): EncryptedMessage; // inherited from NSObject
-
- static new(): EncryptedMessage; // inherited from NSObject
-
- readonly base64String: string;
-
- readonly data: NSData;
-
- constructor(o: { base64Encoded: string; });
-
- constructor(o: { data: NSData; });
-
- decryptedWithPaddingError(key: PrivateKey, padding: SecPadding): ClearMessage;
-
- initWithBase64EncodedError(base64String: string): this;
-
- initWithData(data: NSData): this;
-}
-
-declare class PrivateKey extends NSObject {
-
- static alloc(): PrivateKey; // inherited from NSObject
-
- static new(): PrivateKey; // inherited from NSObject
-
- readonly originalData: NSData;
-
- readonly reference: any;
-
- constructor(o: { base64Encoded: string; });
-
- constructor(o: { data: NSData; });
-
- constructor(o: { derNamed: string; in: NSBundle; });
-
- constructor(o: { pemEncoded: string; });
-
- constructor(o: { pemNamed: string; in: NSBundle; });
-
- constructor(o: { reference: any; });
-
- base64StringAndReturnError(): string;
-
- dataAndReturnError(): NSData;
-
- initWithBase64EncodedError(base64String: string): this;
-
- initWithDataError(data: NSData): this;
-
- initWithDerNamedInError(derName: string, bundle: NSBundle): this;
-
- initWithPemEncodedError(pemString: string): this;
-
- initWithPemNamedInError(pemName: string, bundle: NSBundle): this;
-
- initWithReferenceError(reference: any): this;
-
- pemStringAndReturnError(): string;
-}
-
-declare class PublicKey extends NSObject {
-
- static alloc(): PublicKey; // inherited from NSObject
-
- static new(): PublicKey; // inherited from NSObject
-
- static publicKeysWithPemEncoded(pemString: string): NSArray;
-
- readonly originalData: NSData;
-
- readonly reference: any;
-
- constructor(o: { base64Encoded: string; });
-
- constructor(o: { data: NSData; });
-
- constructor(o: { derNamed: string; in: NSBundle; });
-
- constructor(o: { pemEncoded: string; });
-
- constructor(o: { pemNamed: string; in: NSBundle; });
-
- constructor(o: { reference: any; });
-
- base64StringAndReturnError(): string;
-
- dataAndReturnError(): NSData;
-
- initWithBase64EncodedError(base64String: string): this;
-
- initWithDataError(data: NSData): this;
-
- initWithDerNamedInError(derName: string, bundle: NSBundle): this;
-
- initWithPemEncodedError(pemString: string): this;
-
- initWithPemNamedInError(pemName: string, bundle: NSBundle): this;
-
- initWithReferenceError(reference: any): this;
-
- pemStringAndReturnError(): string;
-}
-
-declare class Signature extends NSObject {
-
- static alloc(): Signature; // inherited from NSObject
-
- static new(): Signature; // inherited from NSObject
-
- readonly base64String: string;
-
- readonly data: NSData;
-
- constructor(o: { base64Encoded: string; });
-
- constructor(o: { data: NSData; });
-
- initWithBase64EncodedError(base64String: string): this;
-
- initWithData(data: NSData): this;
-}
-
-declare var SwiftyRSAVersionNumber: number;
-
-declare var SwiftyRSAVersionNumberVar: number;
-
-declare var SwiftyRSAVersionString: interop.Reference;
-
-declare var SwiftyRSAVersionStringVar: interop.Reference;
-
-declare class VerificationResult extends NSObject {
-
- static alloc(): VerificationResult; // inherited from NSObject
-
- static new(): VerificationResult; // inherited from NSObject
-
- readonly isSuccessful: boolean;
-}
diff --git a/src/platforms/ios/build.xcconfig b/src/platforms/ios/build.xcconfig
index e69de29..ecae5f4 100644
--- a/src/platforms/ios/build.xcconfig
+++ b/src/platforms/ios/build.xcconfig
@@ -0,0 +1 @@
+EMBEDDED_CONTENT_CONTAINS_SWIFT = YES