-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
51 lines (43 loc) · 1.36 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Copyright (c) 2015 ASPECTRON Inc.
// All Rights Reserved.
//
// This file is part of IrisCrypt (https://github.com/aspectron/iris-crypt) project.
//
// Distributed under the MIT software license, see the accompanying
// file LICENSE
//
var crypt = require('../');
var path = require('path');
console.log('crypt exports:', crypt);
var password = process.argv[2] || 'password';
var serial = +process.argv[3] || 1234;
var filename = process.argv[4] || 'test.pkg';
var auth = crypt.generateAuth(password, serial);
console.log('');
console.log('generated auth for serial %s: %s', serial, auth);
crypt.package(auth, filename, {
'm1': path.join(__dirname, 'module1.js'),
'm2': path.join(__dirname, 'module2.js'),
'm3': path.join(__dirname, 'module3'),
});
console.log('');
console.log('created package %s', filename);
var pkg = crypt.load(auth, filename);
console.log('');
console.log('loaded package %s:', filename, pkg);
console.log('package %s serial:', filename, pkg.serial);
console.log('package %s names:', filename, pkg.names);
console.log('');
m1 = pkg.require('m1');
console.log('m1 exports:', m1);
console.log('m1.f():', m1.f());
console.log('');
m2 = pkg.require('m2');
console.log('m2 exports:', m2);
console.log('m2.f():', m2.f());
console.log('');
m3 = pkg.require('m3');
console.log('m3 exports:', m3);
console.log('m3.f():', m3.f());
console.log('m3.g():', m3.g());