You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by za...@apache.org on 2015/04/01 16:22:28 UTC
[01/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Repository: cordova-firefoxos
Updated Branches:
refs/heads/master 94cae29b0 -> d46b4430b
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pkcs12.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pkcs12.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pkcs12.js
new file mode 100644
index 0000000..bbf1eea
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pkcs12.js
@@ -0,0 +1,650 @@
+(function() {
+
+function Tests(ASSERT, FORGE) {
+ var forge = FORGE();
+ var PKCS12 = forge.pkcs12;
+ var ASN1 = forge.asn1;
+ var PKI = forge.pki;
+ var UTIL = forge.util;
+
+ var _data;
+ describe('pkcs12', function() {
+ it('should create certificate-only p12', function() {
+ var p12Asn = PKCS12.toPkcs12Asn1(null, _data.certificate, null, {
+ useMac: false,
+ generateLocalKeyId: false
+ });
+ var p12Der = ASN1.toDer(p12Asn).getBytes();
+
+ /* The generated PKCS#12 file lacks a MAC, therefore pass -nomacver to
+ OpenSSL: openssl pkcs12 -nomacver -nodes -in pkcs12_certonly.p12 */
+ ASSERT.equal(p12Der, UTIL.decode64(_data.p12certonly));
+ });
+
+ it('should create key-only p12', function() {
+ var privateKey = PKI.privateKeyFromPem(_data.privateKey);
+ var p12Asn = PKCS12.toPkcs12Asn1(privateKey, null, null, {
+ useMac: false,
+ generateLocalKeyId: false
+ });
+ var p12Der = ASN1.toDer(p12Asn).getBytes();
+
+ /* The generated PKCS#12 file lacks a MAC, therefore pass -nomacver to
+ OpenSSL: openssl pkcs12 -nomacver -nodes -in pkcs12_keyonly.p12 */
+ ASSERT.equal(p12Der, UTIL.decode64(_data.p12keyonly));
+ });
+
+ it('should create encrypted-key-only p12', function() {
+ /* Note we need to mock the PRNG, since the PKCS#12 file uses encryption
+ which otherwise would differ each time due to the randomized IV. */
+ var oldRandomGenerate = forge.random.generate;
+ forge.random.generate = function(num) {
+ return UTIL.createBuffer().fillWithByte(0, num).getBytes();
+ };
+
+ var privateKey = PKI.privateKeyFromPem(_data.privateKey);
+ var p12Asn = PKCS12.toPkcs12Asn1(privateKey, null, 'nopass', {
+ useMac: false,
+ generateLocalKeyId: false
+ });
+ var p12Der = ASN1.toDer(p12Asn).getBytes();
+
+ // restore old random function
+ forge.random.generate = oldRandomGenerate;
+
+ /* The generated PKCS#12 file lacks a MAC, therefore pass -nomacver to
+ OpenSSL: openssl pkcs12 -nomacver -in pkcs12_enckeyonly.p12 */
+ ASSERT.equal(p12Der, UTIL.decode64(_data.p12enckeyonly));
+ });
+
+ it('should import certificate-only p12', function() {
+ var p12Der = UTIL.decode64(_data.p12certonly);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1);
+ ASSERT.equal(p12.version, 3);
+
+ // PKCS#12 PFX has exactly one SafeContents; it is not encrypted
+ ASSERT.equal(p12.safeContents.length, 1);
+ ASSERT.equal(p12.safeContents[0].encrypted, false);
+
+ // SafeContents has one SafeBag which has one CertBag with the cert
+ ASSERT.equal(p12.safeContents[0].safeBags.length, 1);
+ ASSERT.equal(p12.safeContents[0].safeBags[0].type, PKI.oids.certBag);
+
+ // check cert's serial number
+ ASSERT.equal(
+ p12.safeContents[0].safeBags[0].cert.serialNumber,
+ '00d4541c40d835e2f3');
+ });
+
+ it('should import key-only p12', function() {
+ var p12Der = UTIL.decode64(_data.p12keyonly);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1);
+ ASSERT.equal(p12.version, 3);
+
+ // PKCS#12 PFX has exactly one SafeContents; it is not encrypted
+ ASSERT.equal(p12.safeContents.length, 1);
+ ASSERT.equal(p12.safeContents[0].encrypted, false);
+
+ // SafeContents has one SafeBag which has one KeyBag with the key
+ ASSERT.equal(p12.safeContents[0].safeBags.length, 1);
+ ASSERT.equal(p12.safeContents[0].safeBags[0].type, PKI.oids.keyBag);
+
+ // compare the key from the PFX by comparing both primes
+ var expected = PKI.privateKeyFromPem(_data.privateKey);
+ ASSERT.deepEqual(p12.safeContents[0].safeBags[0].key.p, expected.p);
+ ASSERT.deepEqual(p12.safeContents[0].safeBags[0].key.q, expected.q);
+ });
+
+ it('should import encrypted-key-only p12', function() {
+ var p12Der = UTIL.decode64(_data.p12enckeyonly);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1, 'nopass');
+ ASSERT.equal(p12.version, 3);
+
+ // PKCS#12 PFX has exactly one SafeContents; it is *not* encrypted,
+ // only the key itself is encrypted (shrouded)
+ ASSERT.equal(p12.safeContents.length, 1);
+ ASSERT.equal(p12.safeContents[0].encrypted, false);
+
+ // SafeContents has one SafeBag which has one shrouded KeyBag with the key
+ ASSERT.equal(p12.safeContents[0].safeBags.length, 1);
+ ASSERT.equal(
+ p12.safeContents[0].safeBags[0].type, PKI.oids.pkcs8ShroudedKeyBag);
+
+ // compare the key from the PFX by comparing both primes
+ var expected = PKI.privateKeyFromPem(_data.privateKey);
+ ASSERT.deepEqual(p12.safeContents[0].safeBags[0].key.p, expected.p);
+ ASSERT.deepEqual(p12.safeContents[0].safeBags[0].key.q, expected.q);
+ });
+
+ it('should import an encrypted-key-only p12', function() {
+ var p12Der = UTIL.decode64(_data.p12enckeyonly);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1, 'nopass');
+ ASSERT.equal(p12.version, 3);
+
+ // PKCS#12 PFX has exactly one SafeContents; it is *not* encrypted,
+ // only the key itself is encrypted (shrouded)
+ ASSERT.equal(p12.safeContents.length, 1);
+ ASSERT.equal(p12.safeContents[0].encrypted, false);
+
+ // SafeContents has one SafeBag which has one shrouded KeyBag with the key
+ ASSERT.equal(p12.safeContents[0].safeBags.length, 1);
+ ASSERT.equal(
+ p12.safeContents[0].safeBags[0].type, PKI.oids.pkcs8ShroudedKeyBag);
+
+ // compare the key from the PFX by comparing both primes
+ var expected = PKI.privateKeyFromPem(_data.privateKey);
+ ASSERT.deepEqual(p12.safeContents[0].safeBags[0].key.p, expected.p);
+ ASSERT.deepEqual(p12.safeContents[0].safeBags[0].key.q, expected.q);
+ });
+
+ it('should import an encrypted p12 with keys and certificates', function() {
+ var p12Der = UTIL.decode64(_data.p12encmixed);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1, '123456');
+ ASSERT.equal(p12.version, 3);
+
+ // PKCS#12 PFX has two SafeContents; first is *not* encrypted but
+ // contains two shrouded keys, second is encrypted and has six
+ // certificates
+ ASSERT.equal(p12.safeContents.length, 2);
+
+ ASSERT.equal(p12.safeContents[0].encrypted, false);
+ ASSERT.equal(p12.safeContents[0].safeBags.length, 2);
+ ASSERT.equal(p12.safeContents[0].safeBags[0].type, PKI.oids.pkcs8ShroudedKeyBag);
+ ASSERT.equal(p12.safeContents[0].safeBags[0].attributes.friendlyName.length, 1);
+ ASSERT.equal(p12.safeContents[0].safeBags[0].attributes.friendlyName[0], 'encryptionkey');
+ ASSERT.equal(p12.safeContents[0].safeBags[0].attributes.localKeyId.length, 1);
+ ASSERT.equal(p12.safeContents[0].safeBags[0].attributes.localKeyId[0], 'Time 1311855238964');
+
+ ASSERT.equal(p12.safeContents[0].safeBags[1].type, PKI.oids.pkcs8ShroudedKeyBag);
+ ASSERT.equal(p12.safeContents[0].safeBags[1].attributes.friendlyName.length, 1);
+ ASSERT.equal(p12.safeContents[0].safeBags[1].attributes.friendlyName[0], 'signaturekey');
+ ASSERT.equal(p12.safeContents[0].safeBags[1].attributes.localKeyId.length, 1);
+ ASSERT.equal(p12.safeContents[0].safeBags[1].attributes.localKeyId[0], 'Time 1311855238863');
+
+ ASSERT.equal(p12.safeContents[1].encrypted, true);
+ ASSERT.equal(p12.safeContents[1].safeBags.length, 6);
+
+ ASSERT.equal(p12.safeContents[1].safeBags[0].type, PKI.oids.certBag);
+ ASSERT.equal(p12.safeContents[1].safeBags[0].attributes.friendlyName.length, 1);
+ ASSERT.equal(p12.safeContents[1].safeBags[0].attributes.friendlyName[0], 'CN=1002753325,2.5.4.5=#130b3130303237353333323543');
+ ASSERT.equal(p12.safeContents[1].safeBags[0].attributes.localKeyId.length, 1);
+ ASSERT.equal(p12.safeContents[1].safeBags[0].attributes.localKeyId[0], 'Time 1311855238964');
+
+ ASSERT.equal(p12.safeContents[1].safeBags[1].type, PKI.oids.certBag);
+ ASSERT.equal(p12.safeContents[1].safeBags[1].attributes.friendlyName.length, 1);
+ ASSERT.equal(p12.safeContents[1].safeBags[1].attributes.friendlyName[0], 'CN=ElsterSoftTestCA,OU=CA,O=Elster,C=DE');
+
+ ASSERT.equal(p12.safeContents[1].safeBags[2].type, PKI.oids.certBag);
+ ASSERT.equal(p12.safeContents[1].safeBags[2].attributes.friendlyName.length, 1);
+ ASSERT.equal(p12.safeContents[1].safeBags[2].attributes.friendlyName[0], 'CN=ElsterRootCA,OU=RootCA,O=Elster,C=DE');
+
+ ASSERT.equal(p12.safeContents[1].safeBags[3].type, PKI.oids.certBag);
+ ASSERT.equal(p12.safeContents[1].safeBags[3].attributes.friendlyName.length, 1);
+ ASSERT.equal(p12.safeContents[1].safeBags[3].attributes.friendlyName[0], 'CN=1002753325,2.5.4.5=#130b3130303237353333323541');
+ ASSERT.equal(p12.safeContents[1].safeBags[3].attributes.localKeyId.length, 1);
+ ASSERT.equal(p12.safeContents[1].safeBags[3].attributes.localKeyId[0], 'Time 1311855238863');
+
+ ASSERT.equal(p12.safeContents[1].safeBags[4].type, PKI.oids.certBag);
+ ASSERT.equal(p12.safeContents[1].safeBags[4].attributes.friendlyName.length, 1);
+ ASSERT.equal(p12.safeContents[1].safeBags[4].attributes.friendlyName[0], 'CN=ElsterSoftTestCA,OU=CA,O=Elster,C=DE');
+
+ ASSERT.equal(p12.safeContents[1].safeBags[5].type, PKI.oids.certBag);
+ ASSERT.equal(p12.safeContents[1].safeBags[5].attributes.friendlyName.length, 1);
+ ASSERT.equal(p12.safeContents[1].safeBags[5].attributes.friendlyName[0], 'CN=ElsterRootCA,OU=RootCA,O=Elster,C=DE');
+ });
+
+ it('should get bags by friendly name', function() {
+ var p12Der = UTIL.decode64(_data.p12encmixed);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1, '123456');
+ var bags = p12.getBags({friendlyName: 'signaturekey'});
+
+ ASSERT.equal(bags.friendlyName.length, 1);
+ ASSERT.equal(bags.friendlyName[0].attributes.friendlyName[0], 'signaturekey');
+ });
+
+ it('should get cert bags by friendly name', function() {
+ var p12Der = UTIL.decode64(_data.p12encmixed);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1, '123456');
+ var bags = p12.getBags({
+ friendlyName: 'CN=1002753325,2.5.4.5=#130b3130303237353333323543',
+ bagType: PKI.oids.certBag
+ });
+
+ ASSERT.equal(bags.friendlyName.length, 1);
+ ASSERT.equal(bags.friendlyName[0].attributes.friendlyName[0], 'CN=1002753325,2.5.4.5=#130b3130303237353333323543');
+ });
+
+ it('should get all cert bags', function() {
+ var p12Der = UTIL.decode64(_data.p12encmixed);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1, '123456');
+ var bags = p12.getBags({
+ bagType: PKI.oids.certBag
+ });
+
+ ASSERT.equal(bags[PKI.oids.certBag].length, 6);
+ for(var i = 0; i < bags[PKI.oids.certBag].length; ++i) {
+ ASSERT.equal(bags[PKI.oids.certBag][i].type, PKI.oids.certBag);
+ }
+ });
+
+ it('should get bags by local key ID', function() {
+ var p12Der = UTIL.decode64(_data.p12encmixed);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1, '123456');
+ var bags = p12.getBags({localKeyId: 'Time 1311855238863'});
+
+ ASSERT.equal(bags.localKeyId.length, 2);
+ ASSERT.equal(bags.localKeyId[0].attributes.localKeyId[0], 'Time 1311855238863');
+ ASSERT.equal(bags.localKeyId[1].attributes.localKeyId[0], 'Time 1311855238863');
+ });
+
+ it('should get cert bags by local key ID', function() {
+ var p12Der = UTIL.decode64(_data.p12encmixed);
+ var p12Asn1 = ASN1.fromDer(p12Der);
+ var p12 = PKCS12.pkcs12FromAsn1(p12Asn1, '123456');
+ var bags = p12.getBags({
+ localKeyId: 'Time 1311855238863',
+ bagType: PKI.oids.certBag
+ });
+
+ ASSERT.equal(bags.localKeyId.length, 1);
+ ASSERT.equal(bags.localKeyId[0].attributes.localKeyId[0], 'Time 1311855238863');
+ ASSERT.equal(bags.localKeyId[0].type, PKI.oids.certBag);
+ });
+
+ it('should generate a PKCS#12 mac key', function() {
+ var salt = 'A15D6AA8F8DAFC352F9EE1C192F09966EB85D17B';
+ salt = UTIL.createBuffer(UTIL.hexToBytes(salt));
+ var expected = '03e46727268575c6ebd6bff828d0d09b0c914201263ca543';
+ var key = PKCS12.generateKey('123456', salt, 1, 1024, 24);
+ ASSERT.equal(key.toHex(), expected);
+ });
+ });
+
+ _data = {
+ certificate: '-----BEGIN CERTIFICATE-----\r\n' +
+ 'MIIDtDCCApwCCQDUVBxA2DXi8zANBgkqhkiG9w0BAQUFADCBmzELMAkGA1UEBhMC\r\n' +
+ 'REUxEjAQBgNVBAgMCUZyYW5jb25pYTEQMA4GA1UEBwwHQW5zYmFjaDEVMBMGA1UE\r\n' +
+ 'CgwMU3RlZmFuIFNpZWdsMRIwEAYDVQQLDAlHZWllcmxlaW4xFjAUBgNVBAMMDUdl\r\n' +
+ 'aWVybGVpbiBERVYxIzAhBgkqhkiG9w0BCQEWFHN0ZXNpZUBicm9rZW5waXBlLmRl\r\n' +
+ 'MB4XDTEyMDMxODIyNTc0M1oXDTEzMDMxODIyNTc0M1owgZsxCzAJBgNVBAYTAkRF\r\n' +
+ 'MRIwEAYDVQQIDAlGcmFuY29uaWExEDAOBgNVBAcMB0Fuc2JhY2gxFTATBgNVBAoM\r\n' +
+ 'DFN0ZWZhbiBTaWVnbDESMBAGA1UECwwJR2VpZXJsZWluMRYwFAYDVQQDDA1HZWll\r\n' +
+ 'cmxlaW4gREVWMSMwIQYJKoZIhvcNAQkBFhRzdGVzaWVAYnJva2VucGlwZS5kZTCC\r\n' +
+ 'ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMsAbQ4fWevHqP1K1y/ewpMS\r\n' +
+ '3vYovBto7IsKBq0v3NmC2kPf3NhyaSKfjOOS5uAPONLffLck+iGdOLLFia6OSpM6\r\n' +
+ '0tyQIV9lHoRh7fOEYORab0Z+aBUZcEGT9yotBOraX1YbKc5f9XO+80eG4XYvb5ua\r\n' +
+ '1NHrxWqe4w2p3zGJCKO+wHpvGkbKz0nfu36jwWz5aihfHi9hp/xs8mfH86mIKiD7\r\n' +
+ 'f2X2KeZ1PK9RvppA0X3lLb2VLOqMt+FHWicyZ/wjhQZ4oW55ln2yYJUQ+adlgaYn\r\n' +
+ 'PrtnsxmbTxM+99oF0F2/HmGrNs8nLZSva1Vy+hmjmWz6/O8ZxhiIj7oBRqYcAocC\r\n' +
+ 'AwEAATANBgkqhkiG9w0BAQUFAAOCAQEAvfvtu31GFBO5+mFjPAoR4BlzKq/H3EPO\r\n' +
+ 'qS8cm/TjHgDRALwSnwKYCFs/bXqE4iOTD6otV4TusX3EPbqL2vzZQEcZn6paU/oZ\r\n' +
+ 'ZVXwQqMqY5tf2teQiNxqxNmSIEPRHOr2QVBVIx2YF4Po89KGUqJ9u/3/10lDqRwp\r\n' +
+ 'sReijr5UKv5aygEcnwcW8+Ne4rTx934UDsutKG20dr5trZfWQRVS9fS9CFwJehEX\r\n' +
+ 'HAMUc/0++80NhfQthmWZWlWM1R3dr4TrIPtWdn5z0MtGeDvqBk7HjGrhcVS6kAsy\r\n' +
+ 'Z9y/lfLPjBuxlQAHztEJCWgI4TW3/RLhgfg2gI1noM2n84Cdmisfkg==\r\n' +
+ '-----END CERTIFICATE-----\r\n',
+ privateKey: '-----BEGIN RSA PRIVATE KEY-----\r\n' +
+ 'MIIEowIBAAKCAQEAywBtDh9Z68eo/UrXL97CkxLe9ii8G2jsiwoGrS/c2YLaQ9/c\r\n' +
+ '2HJpIp+M45Lm4A840t98tyT6IZ04ssWJro5KkzrS3JAhX2UehGHt84Rg5FpvRn5o\r\n' +
+ 'FRlwQZP3Ki0E6tpfVhspzl/1c77zR4bhdi9vm5rU0evFap7jDanfMYkIo77Aem8a\r\n' +
+ 'RsrPSd+7fqPBbPlqKF8eL2Gn/GzyZ8fzqYgqIPt/ZfYp5nU8r1G+mkDRfeUtvZUs\r\n' +
+ '6oy34UdaJzJn/COFBnihbnmWfbJglRD5p2WBpic+u2ezGZtPEz732gXQXb8eYas2\r\n' +
+ 'zyctlK9rVXL6GaOZbPr87xnGGIiPugFGphwChwIDAQABAoIBAAjMA+3QvfzRsikH\r\n' +
+ 'zTtt09C7yJ2yNjSZ32ZHEPMAV/m1CfBXCyL2EkhF0b0q6IZdIoFA3g6xs4UxYvuc\r\n' +
+ 'Q9Mkp2ap7elQ9aFEqIXkGIOtAOXkZV4QrEH90DeHSfax7LygqfD5TF59Gg3iAHjh\r\n' +
+ 'B3Qvqg58LyzJosx0BjLZYaqr3Yv67GkqyflpF/roPGdClHpahAi5PBkHiNhNTAUU\r\n' +
+ 'LJRGvMegXGZkUKgGMAiGCk0N96OZwrinMKO6YKGdtgwVWC2wbJY0trElaiwXozSt\r\n' +
+ 'NmP6KTQp94C7rcVO6v1lZiOfhBe5Kc8QHUU+GYydgdjqm6Rdow/yLHOALAVtXSeb\r\n' +
+ 'U+tPfcECgYEA6Qi+qF+gtPincEDBxRtoKwAlRkALt8kly8bYiGcUmd116k/5bmPw\r\n' +
+ 'd0tBUOQbqRa1obYC88goOVzp9LInAcBSSrexhVaPAF4nrkwYXMOq+76MiH17WUfQ\r\n' +
+ 'MgVM2IB48PBjNk1s3Crj6j1cxxkctqmCnVaI9HlU2PPZ3xjaklfv/NsCgYEA3wH8\r\n' +
+ 'mehUhiAp7vuhd+hfomFw74cqgHC9v0saiYGckpMafh9MJGc4U5GrN1kYeb/CFkSx\r\n' +
+ '1hOytD3YBKoaKKoYagaMQcjxf6HnEF0f/5OiQkUQpWmgC9lNnE4XTWjnwqaTS5L9\r\n' +
+ 'D+H50SiI3VjHymGXTRJeKpAIwV74AxxrnVofqsUCgYAwmL1B2adm9g/c7fQ6yatg\r\n' +
+ 'hEhBrSuEaTMzmsUfNPfr2m4zrffjWH4WMqBtYRSPn4fDMHTPJ+eThtfXSqutxtCi\r\n' +
+ 'ekpP9ywdNIVr6LyP49Ita6Bc+mYVyU8Wj1pmL+yIumjGM0FHbL5Y4/EMKCV/xjvR\r\n' +
+ '2fD3orHaCIhf6QvzxtjqTwKBgFm6UemXKlMhI94tTsWRMNGEBU3LA9XUBvSuAkpr\r\n' +
+ 'ZRUwrQssCpXnFinBxbMqXQe3mR8emrM5D8En1P/jdU0BS3t1kP9zG4AwI2lZHuPV\r\n' +
+ 'ggbKBS2Y9zVtRKXsYcHawM13+nIA/WNjmAGJHrB45UJPy/HNvye+9lbfoEiYKdCR\r\n' +
+ 'D4bFAoGBAIm9jcZkIwLa9kLAWH995YYYSGRY4KC29XZr2io2mog+BAjhFt1sqebt\r\n' +
+ 'R8sRHNiIP2mcUECMOcaS+tcayi+8KTHWxIEed9qDmFu6XBbePfe/L6yxPSagcixH\r\n' +
+ 'BK0KuK/fgTPvZCmIs8hUIC+AxhXKnqn4fIWoO54xLsALc0gEjs2d\r\n' +
+ '-----END RSA PRIVATE KEY-----\r\n',
+ p12certonly:
+ 'MIIEHgIBAzCCBBcGCSqGSIb3DQEHAaCCBAgEggQEMIIEADCCA/wGCSqGSIb3DQEH\r\n' +
+ 'AaCCA+0EggPpMIID5TCCA+EGCyqGSIb3DQEMCgEDoIID0DCCA8wGCiqGSIb3DQEJ\r\n' +
+ 'FgGgggO8BIIDuDCCA7QwggKcAgkA1FQcQNg14vMwDQYJKoZIhvcNAQEFBQAwgZsx\r\n' +
+ 'CzAJBgNVBAYTAkRFMRIwEAYDVQQIDAlGcmFuY29uaWExEDAOBgNVBAcMB0Fuc2Jh\r\n' +
+ 'Y2gxFTATBgNVBAoMDFN0ZWZhbiBTaWVnbDESMBAGA1UECwwJR2VpZXJsZWluMRYw\r\n' +
+ 'FAYDVQQDDA1HZWllcmxlaW4gREVWMSMwIQYJKoZIhvcNAQkBFhRzdGVzaWVAYnJv\r\n' +
+ 'a2VucGlwZS5kZTAeFw0xMjAzMTgyMjU3NDNaFw0xMzAzMTgyMjU3NDNaMIGbMQsw\r\n' +
+ 'CQYDVQQGEwJERTESMBAGA1UECAwJRnJhbmNvbmlhMRAwDgYDVQQHDAdBbnNiYWNo\r\n' +
+ 'MRUwEwYDVQQKDAxTdGVmYW4gU2llZ2wxEjAQBgNVBAsMCUdlaWVybGVpbjEWMBQG\r\n' +
+ 'A1UEAwwNR2VpZXJsZWluIERFVjEjMCEGCSqGSIb3DQEJARYUc3Rlc2llQGJyb2tl\r\n' +
+ 'bnBpcGUuZGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLAG0OH1nr\r\n' +
+ 'x6j9Stcv3sKTEt72KLwbaOyLCgatL9zZgtpD39zYcmkin4zjkubgDzjS33y3JPoh\r\n' +
+ 'nTiyxYmujkqTOtLckCFfZR6EYe3zhGDkWm9GfmgVGXBBk/cqLQTq2l9WGynOX/Vz\r\n' +
+ 'vvNHhuF2L2+bmtTR68VqnuMNqd8xiQijvsB6bxpGys9J37t+o8Fs+WooXx4vYaf8\r\n' +
+ 'bPJnx/OpiCog+39l9inmdTyvUb6aQNF95S29lSzqjLfhR1onMmf8I4UGeKFueZZ9\r\n' +
+ 'smCVEPmnZYGmJz67Z7MZm08TPvfaBdBdvx5hqzbPJy2Ur2tVcvoZo5ls+vzvGcYY\r\n' +
+ 'iI+6AUamHAKHAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAL377bt9RhQTufphYzwK\r\n' +
+ 'EeAZcyqvx9xDzqkvHJv04x4A0QC8Ep8CmAhbP216hOIjkw+qLVeE7rF9xD26i9r8\r\n' +
+ '2UBHGZ+qWlP6GWVV8EKjKmObX9rXkIjcasTZkiBD0Rzq9kFQVSMdmBeD6PPShlKi\r\n' +
+ 'fbv9/9dJQ6kcKbEXoo6+VCr+WsoBHJ8HFvPjXuK08fd+FA7LrShttHa+ba2X1kEV\r\n' +
+ 'UvX0vQhcCXoRFxwDFHP9PvvNDYX0LYZlmVpVjNUd3a+E6yD7VnZ+c9DLRng76gZO\r\n' +
+ 'x4xq4XFUupALMmfcv5Xyz4wbsZUAB87RCQloCOE1t/0S4YH4NoCNZ6DNp/OAnZor\r\n' +
+ 'H5I=',
+ p12enckeyonly:
+ 'MIIFcQIBAzCCBWoGCSqGSIb3DQEHAaCCBVsEggVXMIIFUzCCBU8GCSqGSIb3DQEH\r\n' +
+ 'AaCCBUAEggU8MIIFODCCBTQGCyqGSIb3DQEMCgECoIIFIzCCBR8wSQYJKoZIhvcN\r\n' +
+ 'AQUNMDwwGwYJKoZIhvcNAQUMMA4ECAAAAAAAAAAAAgIIADAdBglghkgBZQMEAQIE\r\n' +
+ 'EAAAAAAAAAAAAAAAAAAAAAAEggTQQHIbPs0naCmJGgmtvFNmUlv9sHkm2A/vWHjY\r\n' +
+ 'B8UavyYUz3IMtDCWZBoWHWp/izLDroCSxkabxyzqlSbYdGug1QY9y9RP6TjP6uaw\r\n' +
+ 'SFurDe7beTRB3d8Oe2AMEmUQtaPE/zQI52aWse8RNh5P1I1wQEzVvk8/hf2eLdLQ\r\n' +
+ 'cxUb0flz65Nkr4tVPsAmXfbepiyPm+lISi7syNfO6d7424CsGYXD3VCtDxbS5r0m\r\n' +
+ 'L7OIkMfr7JhkvlrcdgrBY5r8/67MtfaJrMe0FR90UJd6ST++2FyhbilSz2BI6Twu\r\n' +
+ 'wNICvkbThwY/LLxOCPKm4AgEj/81pYy6z2eWG59pD8fju4IOJUt3AGoPZoCQrbmD\r\n' +
+ 'MDahpYgey6bo8ti9H08HhvP9keOgI2HUCQoObL0c2GF+fv6m/EJ59hpH9qeryfT4\r\n' +
+ 'HAzSfd4h0YszF32a23+dGEgXAA492m00lZ/uM5nTF0RIQsqj5BJSxEEBpYequF4A\r\n' +
+ 'MNCsjKl90HPSIndNSUfgN0us8FtmrzBNbmIATFE9juKHWag3p751ertsGv6e/Ofm\r\n' +
+ 'xAhgF21j8ZhwXKjsVY4uYVFYLWkCLSD4gF8/ijWg873XZKzjPuy8w3SAAcya8vaQ\r\n' +
+ 'buzzk5zgN0g5T+JxCAdP50FH68rVG2dhfY1BDFe8xY6mxSfs/wUj5EVD9jdqlYpu\r\n' +
+ '/o3IFtdksSra8eOwO2F/kw69x11wZaYpZaRzbIM2x1pDARkAtnbdvdSEXMOT7htA\r\n' +
+ 'OYAJiZuhW0czOgumGGhIO8TBxwMh3/WjkUdlJ1JNhl6M+JHlmIKerCuP6kCLJsAp\r\n' +
+ '+RyRRp6pKa4t09G5rjAjCUiPqkCKRSf40ijhn+lLhj8ZHKLDyw4FCMo6NvQvFsDp\r\n' +
+ 'dbCbbHzWGZXEspT56jGbuju1DQCiy+uVKYhigU1PvRXrxpCHKcv65iqnwPRgGE6X\r\n' +
+ 'dPSGfjsLDbATvSrVv1DvJNTH9wyCSQt/eqBXFWkQeFEqKXij0atkdHL6GXRo57PX\r\n' +
+ 'KZgeul2Xxd2J5SYNCUJf8IL4UOfHRMB4GaGGt9LTpPq2bI9fju1vVE4BjL1gSYIi\r\n' +
+ 'cvynjH7mpzVwq+Cxj4uCo8aZQKWB0BI7c4cDaFmKPIFD47QFZUNgYCv9WfNljOe/\r\n' +
+ '+CqRbxNFUsXCR4hEoYmdn0EEI2b1F6Hkz/dDrLH33My4Gp14N8MVkASWtecxvbfa\r\n' +
+ 'xkj5SiC5NZQ2TZtt3DX508BPFSqJRjb83I7qhNjWxqFUxS1ma9PF/AQzUgNLw+Gz\r\n' +
+ 't5fpB3hD+33fWE8y4RbiUsBU+O56qaN9luOZLa/eVwo+I9F1LgXsS29iv6LvHO5m\r\n' +
+ '+IfzHM+FROS1XhzM+t8rxTK7VmBHqmPrKcjtnYXZh0eA9YIhTEeRdlEO8q4dsKFv\r\n' +
+ 'sbQZ3+65DW6pbDbe/3CGqf43w5vbTvhsRSYqC9ojKjnUtoJ8gY+b7GPNUVsgxQCh\r\n' +
+ 'jfqqZoVmhBihTO5hgeHJf+ilCbw5cPCEXobAxMfdPaasBV5xDBcvDDl7Sv16feYk\r\n' +
+ 'OZJ6bm9wRkqbQUsWYMgYLCfs/FDe1kfkSeS8JYlmFIkHZL6K3LqkULnqPfQdnlMp\r\n' +
+ '1PYGlPTdp+6XcqNBVORyXkOXF7PyrOw7vRefEuGcBvZ4TT0jmHE3KxKEvJwbVsne\r\n' +
+ 'H4/s3xo=',
+ p12keyonly:
+ 'MIIFEAIBAzCCBQkGCSqGSIb3DQEHAaCCBPoEggT2MIIE8jCCBO4GCSqGSIb3DQEH\r\n' +
+ 'AaCCBN8EggTbMIIE1zCCBNMGCyqGSIb3DQEMCgEBoIIEwjCCBL4CAQAwDQYJKoZI\r\n' +
+ 'hvcNAQEBBQAEggSoMIIEpAIBAAKCAQEAywBtDh9Z68eo/UrXL97CkxLe9ii8G2js\r\n' +
+ 'iwoGrS/c2YLaQ9/c2HJpIp+M45Lm4A840t98tyT6IZ04ssWJro5KkzrS3JAhX2Ue\r\n' +
+ 'hGHt84Rg5FpvRn5oFRlwQZP3Ki0E6tpfVhspzl/1c77zR4bhdi9vm5rU0evFap7j\r\n' +
+ 'DanfMYkIo77Aem8aRsrPSd+7fqPBbPlqKF8eL2Gn/GzyZ8fzqYgqIPt/ZfYp5nU8\r\n' +
+ 'r1G+mkDRfeUtvZUs6oy34UdaJzJn/COFBnihbnmWfbJglRD5p2WBpic+u2ezGZtP\r\n' +
+ 'Ez732gXQXb8eYas2zyctlK9rVXL6GaOZbPr87xnGGIiPugFGphwChwIDAQABAoIB\r\n' +
+ 'AQAIzAPt0L380bIpB807bdPQu8idsjY0md9mRxDzAFf5tQnwVwsi9hJIRdG9KuiG\r\n' +
+ 'XSKBQN4OsbOFMWL7nEPTJKdmqe3pUPWhRKiF5BiDrQDl5GVeEKxB/dA3h0n2sey8\r\n' +
+ 'oKnw+UxefRoN4gB44Qd0L6oOfC8syaLMdAYy2WGqq92L+uxpKsn5aRf66DxnQpR6\r\n' +
+ 'WoQIuTwZB4jYTUwFFCyURrzHoFxmZFCoBjAIhgpNDfejmcK4pzCjumChnbYMFVgt\r\n' +
+ 'sGyWNLaxJWosF6M0rTZj+ik0KfeAu63FTur9ZWYjn4QXuSnPEB1FPhmMnYHY6puk\r\n' +
+ 'XaMP8ixzgCwFbV0nm1PrT33BAoGBAOkIvqhfoLT4p3BAwcUbaCsAJUZAC7fJJcvG\r\n' +
+ '2IhnFJnddepP+W5j8HdLQVDkG6kWtaG2AvPIKDlc6fSyJwHAUkq3sYVWjwBeJ65M\r\n' +
+ 'GFzDqvu+jIh9e1lH0DIFTNiAePDwYzZNbNwq4+o9XMcZHLapgp1WiPR5VNjz2d8Y\r\n' +
+ '2pJX7/zbAoGBAN8B/JnoVIYgKe77oXfoX6JhcO+HKoBwvb9LGomBnJKTGn4fTCRn\r\n' +
+ 'OFORqzdZGHm/whZEsdYTsrQ92ASqGiiqGGoGjEHI8X+h5xBdH/+TokJFEKVpoAvZ\r\n' +
+ 'TZxOF01o58Kmk0uS/Q/h+dEoiN1Yx8phl00SXiqQCMFe+AMca51aH6rFAoGAMJi9\r\n' +
+ 'QdmnZvYP3O30OsmrYIRIQa0rhGkzM5rFHzT369puM63341h+FjKgbWEUj5+HwzB0\r\n' +
+ 'zyfnk4bX10qrrcbQonpKT/csHTSFa+i8j+PSLWugXPpmFclPFo9aZi/siLpoxjNB\r\n' +
+ 'R2y+WOPxDCglf8Y70dnw96Kx2giIX+kL88bY6k8CgYBZulHplypTISPeLU7FkTDR\r\n' +
+ 'hAVNywPV1Ab0rgJKa2UVMK0LLAqV5xYpwcWzKl0Ht5kfHpqzOQ/BJ9T/43VNAUt7\r\n' +
+ 'dZD/cxuAMCNpWR7j1YIGygUtmPc1bUSl7GHB2sDNd/pyAP1jY5gBiR6weOVCT8vx\r\n' +
+ 'zb8nvvZW36BImCnQkQ+GxQKBgQCJvY3GZCMC2vZCwFh/feWGGEhkWOCgtvV2a9oq\r\n' +
+ 'NpqIPgQI4RbdbKnm7UfLERzYiD9pnFBAjDnGkvrXGsovvCkx1sSBHnfag5hbulwW\r\n' +
+ '3j33vy+ssT0moHIsRwStCriv34Ez72QpiLPIVCAvgMYVyp6p+HyFqDueMS7AC3NI\r\n' +
+ 'BI7NnQ==',
+ p12encmixed:
+ 'MIIpiwIBAzCCKUUGCSqGSIb3DQEHAaCCKTYEgikyMIIpLjCCCtMGCSqGSIb3DQEH\r\n' +
+ 'AaCCCsQEggrAMIIKvDCCBVsGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcN\r\n' +
+ 'AQwBAzAaBBShXWqo+Nr8NS+e4cGS8Jlm64XRewICBAAEggTIMtqzJpmSCGAYKTj8\r\n' +
+ '1t3U0mGNAErZt0UA2EP9dcGvyG+0W+PMorwwduveGz5ymdqh+8mdbGOTTGKqLVmB\r\n' +
+ '9vR2826foDSgjB+x+fSX9UtSvf9xwF0J6VGPt64RP4J3c+5ntd/gleJCpeBW/div\r\n' +
+ 'ieeSRAJ0JX/JthDvO1VyzBOb8w5lakK/mCvLpcbUMIMnF6M/TT1rreqtl8GSx9+n\r\n' +
+ '+ne4tBWCUYAZfYHuKd2tCpT+lpP8pmZ7BYEvgyWPmYkNTkbPMAct1nJcN3L89Rt0\r\n' +
+ 'Yw2fg58pvzY0WlHK3H5rB4J7835jTnZLAYz2sjnlDXndwXtiH9AU3X3KQpSDHrkd\r\n' +
+ 'ypBQfPHVwB7f+UiKYx5KYNjT1ph2y4DoBV6e4tnQs4KjixtKnom/9ipqOwjP2o6+\r\n' +
+ '4rkZf3I+g8ZrTQygbmQBCfdduNwnhImf7XJezK2RoW9/b9WoSPGSuzsVmt7h+hYs\r\n' +
+ 'hGGx5mdk+iJTmst5MrdNx4byKLW+ThrFJ+eqUwm/d+ODQolu+gckOTyaUvNfjYy7\r\n' +
+ 'JYi7wnzKAiOyNHwoP+Efpwb+eDffDyg0u/SuEc3qulWr61hfvjihK7w9Vo21kW3r\r\n' +
+ 'a6vSL6mS9XBJjvJFdf5sEMiNTUxR7Zw4AsKUysgyiXRFM2hkxuwImFozyK+Er4OJ\r\n' +
+ 'ydi3NpzcAL2+a8JzB35QztRxnypn/v/bWIyt89fW1mrstkCwvNRBaYnI4AGDN0C7\r\n' +
+ 'jw5aYbOcdg3PbV69+5i4RCRkN2GU6LTovSaBvfBWxrJHav8pfinLhduOckwrWckx\r\n' +
+ 'O38vc0fSuTUQaXgL8fXofX6L0139l9fN2MfndI8+39JOlzXNCsldpX+Nt2PI2Awm\r\n' +
+ 'AgKEpLA3jbjazqvOmZUBxh0RVozzVu+JTbGWvkalEcmyncCuKSFZkMlP3SNrn4PS\r\n' +
+ 'tpHlohTPBPHpxgJce0O6ylxgUZkUsSDatE0joWW/YJ+us0bqeGej5OLvmI9/L9iH\r\n' +
+ '2jCFIN79WVG06GsNuiKON12KPL4J/B4rv9bguQHdcPGJcVXtKv1Uzscpy1uQcqZc\r\n' +
+ 'qVzl+Om4fbb0mg+vRXi9FQu//U35yK95NjF6KyniVF0riZWA6bb8dO4YdO4q9IYZ\r\n' +
+ 'OFeoLQ/Zl4Zg58ytsUsqoFW6yK7itGUAV1y4BPME4pqkQAI5EVgaFnng9Gdcq9hN\r\n' +
+ '3VHHJLUiCjMLCmWrzt5dTgNCLrvF60bDnM5w9VAkR1xvNzYL/ui0j5A5fbpFc7jz\r\n' +
+ '1JcwFilP9qD94MPBOoPRNJNRxDl1bigdBtR50VTo7tNt48sSZHdVWPGMaqjDndRg\r\n' +
+ 'ur3EJeQVMUvVf/5L9hDaZdqxJ9x6Va+5f4a4Or3ttOCb1qCawqutx6IcOc26EAVy\r\n' +
+ 'nQ47UXQ2j/AjDoG+T8u34+TQsiVyC5X96TezAfPk5Vp8KUBjhBy15Z0YlnxXw4Up\r\n' +
+ 'KzFPMfWOLTiElbJGaLtD7MXrXMQcdK9S2d/MR01zM8QuLwDH4OJfSJ53mlgsFmRG\r\n' +
+ 'x7L+nZS7961GpoGHIZRRWvi7yejNpzxBUN7rIERgUqVQeh3lLDeDz8XKT83Hzd5R\r\n' +
+ '4AufZHsVg4K1xHxczD1NVoc2O/GM40vyPiK2ms1mQPiTckyF1jrsfKYDwbkzE3yi\r\n' +
+ 'tJXp7Wlc5IHVQqULMU4wKQYJKoZIhvcNAQkUMRweGgBlAG4AYwByAHkAcAB0AGkA\r\n' +
+ 'bwBuAGsAZQB5MCEGCSqGSIb3DQEJFTEUBBJUaW1lIDEzMTE4NTUyMzg5NjQwggVZ\r\n' +
+ 'BgsqhkiG9w0BDAoBAqCCBPowggT2MCgGCiqGSIb3DQEMAQMwGgQUVHez67zL2YSj\r\n' +
+ 'TqMZjS54S+FO+3wCAgQABIIEyDFgx9KJvdvBoednovcwUJeTWhvvMl6owrJ2FhVY\r\n' +
+ 'FjahfYv7vLAKUeQiqnepRcATUzSHJgDDKlnW+0UDSGUqUoabbJhAqtHqrHFevGS2\r\n' +
+ 'YpPNCfi7C2XTm4+F1MNmlmZhsM8gIY+2lmVpjRm+DvymKBzRuEw81xcF+RFDdOTX\r\n' +
+ '/ka6l5leRoFWTbfTnpIxA5QBVvEH52UkDw3hcrmVIct0v60IseiOqiL/4IpbpjmF\r\n' +
+ '3/rQdinE2sckujcEJD8edu1zbZzZ7KIbklWpPvcMRqCQSgrTuW1/lBuyVH3cvoFp\r\n' +
+ 'FtaAw60f6X1ezKmiwA0nYIwahGVmyG4iektxO76zzBPkhL5HPD8BuJX+TRE9hYrZ\r\n' +
+ 'tk161/hKFznWpPEC5ferEEEQi0vB2In1uz7L9LkpmC/to1k8MI1A/0yhY5xXUh4H\r\n' +
+ 'hmp50OEsBnaXjDqPgtZeukqObjKbOSS4zL1WZ5vohJWQdF+C04d93MZoieUSz0yr\r\n' +
+ '1vSQ/JIr51NRKdffCgoZSFayv5vzFyTu9FKlUBgGEUMEzBdZ200v5ho7fHXWp1gW\r\n' +
+ 'TyZK1pdVAC6tnKIgfSdkG7txHUDru120G7AdFXoFeRo7zalxGiGx5RIn3b/qfmyO\r\n' +
+ 'MxcJX9wpFck9IcnN8L/S7hbxt9yAINshOyEM0rUXz0fjVZfcckKLso87YXCGJ7+X\r\n' +
+ '6HYe8bs7/uID7Yz7svD1iwnBlEPQInENZBEPuj6dtMYhMXXMHrY5nwNkXBGQioET\r\n' +
+ 'O6xLjigPX7AUSuCCIRuoHGfo54HxV5uCon2/ibDuhTr46FrTKxQl2xv3M6VoWF/+\r\n' +
+ '0vLiCGKDa/aT5dZhdZ9OqC56mr6dFf8fSntMBBBxtUmcLVySa33G5UCInSrnTgu0\r\n' +
+ 'fY8XGgud/V++xs5lr6jxFQjTdc0ec4muRBOflAvxGq/KKmhbO6h2sa9Ldmr9EABY\r\n' +
+ 'jRaMz63WvObklE1m1IajjiceVXNLwJCwf37J7HKp1836WiWl/psIRSpsV0gdeb7y\r\n' +
+ 'kEx54sEkbwtu8TNga6PbWUzwVEamFSGkAIxAnCCBj7W0okoLw+z1+FAby2lnMSSP\r\n' +
+ 'F9g6aEEACt0h7fgOb6AEi9NCqfrpiZADwW1E0FRYOf8sIy/z6NPQGft3aIlUG9DA\r\n' +
+ 'EZAm5IdZ0umQLMqeG30ZkC88W+ERhdIpVpwuHevdRyDwwN6SZ2+AZd5it1EOCLrC\r\n' +
+ '8CSWXyCNaSkPyoPzE0CpeayyhxYkQNg2KiLEOsOOOmSFpQx+R4QQjJL+chuX8T/D\r\n' +
+ 'rxrgUgnPWPTDRI5iTexcCBlPdMbeyxfpwIWU0ZZsQxK1eBdizIzw/2JTSyHYVZuq\r\n' +
+ 'nhznMaQHH0oA2PGqZw0y7Vu9iRzGU3RrEBBdGnZIwdz9agBc6BxqtLQ5tLKNLCBS\r\n' +
+ 'BZjrCbWe9yBarQOFOpVPiczt/oJju/d5jC9Sj1QDppjLTiajZlcoY+mHGqcbzoe4\r\n' +
+ 'wVN9+ZetkrGk4zDc8MPYMbHIxLR58P3noVZ6s84h1rhA8lKCg9vvG0jffcuveIRu\r\n' +
+ 'AosyBT0v0qVRUWMIXJKpJSivKPykbQm6J+bAoK8+l3yCJ0AWpDcw5Wo5XqV/t4px\r\n' +
+ 'xr95ikcr1+ANBRxa/TAl4oYuoqhlkx7Q8i/XCSudpXrswWcfR5ipc0tBzDFMMCcG\r\n' +
+ 'CSqGSIb3DQEJFDEaHhgAcwBpAGcAbgBhAHQAdQByAGUAawBlAHkwIQYJKoZIhvcN\r\n' +
+ 'AQkVMRQEElRpbWUgMTMxMTg1NTIzODg2MzCCHlMGCSqGSIb3DQEHBqCCHkQwgh5A\r\n' +
+ 'AgEAMIIeOQYJKoZIhvcNAQcBMCgGCiqGSIb3DQEMAQYwGgQUQmWgPDEzodyfX1/t\r\n' +
+ '0lON23fzMeUCAgQAgIIeAAxfoaegDbtpKNtbR/bKgGGecS1491HJMR22X5mHI5EV\r\n' +
+ 'UxPyuyM2bHky/U1eGix06P0ExQMV5kh/Eb+6vRLn+l0pTci53Ps2ITKFXvmqZ5Zx\r\n' +
+ 'yjFtU3LCzN/qh5rFsLpPLdFn4oNrBveXWNPJrIj3Sf93To2GkLFQQ2aINNHe76k3\r\n' +
+ 'O4jp6Kz4DKFrnyrY/fDDhHuGnkvHXBXPO+413PIV4Jgmv1zULkB94WpcJ35gsBGV\r\n' +
+ '3Njt7F0X10ZE3VN/tXlEPjaSv5k4zpG5Pe18Q4LnrPSN+XLfFLRnnYJiDlQkvO91\r\n' +
+ 'AOxqlAkUq4jAGbTBUeSt+8P5HaliAPDJA43/tEWrb7fX68VpIblm4Y38AIoZOL8u\r\n' +
+ 'uafg3WctcD9cy2rP6e0kblkcG4DLrwp/EezeXDxbOsdViiLU5SL1/RhO/0cqB2zw\r\n' +
+ '2scYLc6nJkxzC3iyzhukyn4834SAj+reJMzyiy9VviGQlDz4HFC+P9kYKOqbdW9N\r\n' +
+ 'YYLYluHWjnNzE1enaYSPNPuR1U9UhSN/wKVwmdXsLRK0+ee7xpryxpTeUNAwacGR\r\n' +
+ 'R7uWiXVBj+xQ2AG5qmW4fe1wxrZIL5bD1Z98ss3YLyUESUIv3K6MxkXZdp+gXv97\r\n' +
+ 'jN6j2r536fGpA6jWehjsjk03tL5Zjv4i0PZLUFj16T1uXMzmaKplVd1HYY6bhBl6\r\n' +
+ '7lJerTtrGnPpybAeVn5KFsct0HchWIOkAeqOy3tIqi3R1msIrtR5FviFCgFYS5sV\r\n' +
+ 'ly+T+rNdjQM4FrRk6y/IcCqoQTE6By8cYafRH58X07ix1+k5IFlrTbPrA8w1qQ6T\r\n' +
+ 'wI5ww0hf4aE3W7brXMlmLYBfwfkTWLH/yDQsXBLsma0y1G7Ixn0BLuo6FBm3ayC2\r\n' +
+ 'LEkN+iB+zEeC54oHE450Bhv1TOS80PrLzDW7wL789adWKXHgMmug9sT67gBbaFeU\r\n' +
+ 'u3Z8VTISGxmbrEJQAMEoLuQiujHSfpPb5zK02+A363r+bLt1VbIs5jrYMvaB7qrk\r\n' +
+ '7nVJbVYlPscGwUQUEq4YbCjlg77rhY6d61LIcguG5snF2JTnR74Gu72JpqkrrtA9\r\n' +
+ 'QHQ/njBnmIenXkqCzwcjyqiKUmPXazC/un7Hl3ZUp7BbbvfCJ1VNqtQJTdyS6kZ0\r\n' +
+ 'ZIURy6R4uenoOw9BJfTzLEi+on3af1XXavb8apGlTVCxs8hL4F2IR1A3bkB8fMHv\r\n' +
+ '5oie2te80GKp+B+r0VrEdOLy6BkLgEfuwrpcsIjz+6z83UhfMhgKAcXYJVUC/mmf\r\n' +
+ 'xO4hZ3AHKLCgVql8D4NoYPanQYEKx2sEoTDsCzsoh+E6OYhe4CiSBYwB4s5fKX1w\r\n' +
+ '5LVz7crf8Pg+WfffeP8Y/tDOiShz4luB7YVzw+sAy9Xil5+KmPO11yeDwIe3bdvu\r\n' +
+ 'SeTAgzZ4lx7aZUpQ2cGaswo5Ix3Q7z2WkooYxCi4+XVw+BhRO0pVuyQB04v5rr1W\r\n' +
+ 'EFlDAsC+RVcUw8gyM+tSxm5vqP7H6oEJT00tBYNAX/9ztDpoX4i2276s+6Iszz8B\r\n' +
+ 'kqqTfasb41xzUdFf1PpSzqVGKDi4lAftfedn4JFuQHhcI4MhtxwwecKUL3uHXWiW\r\n' +
+ '3o++dAjO7ybfBm3j0WIKGVwxfON5KnVetSOofc3ZahSklUqEuyaQ/X93FT4amYMJ\r\n' +
+ 'U7NwbLmrCuYe19/+0lt0ySSSBPNNJcV8r+/P0m4gR7athre9aSn/gU2rRrpYfXUS\r\n' +
+ 'SIskLLPn26naLqLW5eEqF9KBg77pGXoXA4guavjUtxEeDCL0ncqAPlhNlRc7NTw5\r\n' +
+ 'MGy65ozntamlGrAWK96fMesmF81ZFHyBH4XImDkIvEr62hmJUJuTh3lBhIGAmqwo\r\n' +
+ 'jcYdAkibrZh3RmhYNzuSAPoBOd959fOwb9SVltDea49XAopKTodL6FPX4UQbCuES\r\n' +
+ 'oml4ZBvRs+ykU+q1to+0QdoY8x0vzkEL1cOOEcbAQebK3kw3GmNZSi6+dzh+gC3C\r\n' +
+ 'xrt53S6VrPlO5kpvlMjUjd5LDTIa05Kz+pIXVXUJSY5zNEWtQ54ne3TIHoqpT8oB\r\n' +
+ '8aQ+AnUKznf3Q5S3hQSA0P/zeIcbLwUvDGwk5GI+X38vNm6zbg+fhLwKi0E87fGE\r\n' +
+ '4ZM1w+D5Cfzl6AOP8QTnM9Az/g7z+nlslfh1uS4O87WNnETXyFqOKuMK5MsAYBmg\r\n' +
+ 'mctsteL7lHbOcmATAX0MjGfewqvh3uVm18xg3S8RHbsQ42IC6NGDS7YfYI/ePrGu\r\n' +
+ 'hdaTeUJuQVm8vSseL5vTeINLbWG7znV4avDgFDx6V+lL77relJ6dQQkRoCf/SNc4\r\n' +
+ 'r3v2I1Dd7I77+AT/uBZ3laKsqQcUhcjhEb2iLzjWpZNnO54VhqILwVD8AU8QMQpu\r\n' +
+ 'bjMxDXNKY9nhDWZtCoSEcbmvReo5dYXLCAjUokd2utwT8xTj+D7MADWKLTIfUO4H\r\n' +
+ '/OKq26mKCZq/6xgoLzXpiQeDxBfojJA4HWvZTmPlqH2VzIihKNFgP3QD1TH/nPCp\r\n' +
+ 'LP0SULTuszYNMTbOOmPj8sYK57dVJUJc2/TiUr1rbxSEEnBL/y4BBUmWxESzNJuO\r\n' +
+ 'ohJcR8rnyeklB5tnB5KzYuJqb5Do8PX7h7sGKZWOX0JAQkyq6QNSpJPR3PQ4tTSo\r\n' +
+ 'vt2pn/+3Uj+9uEvMpYroJEaOMKW3kGL+PUxLg5xMmOWR86jGqHmfY/zx/sx0eiYL\r\n' +
+ 'xXlD7KzaNuBLKGnTv/7fK7OzNc9bmS+pIeru8jtPIm6i6u+mQ/byIehjIPYxR1m/\r\n' +
+ 'WBu7LJv4LALDHUh93Fnr92sdWkiV9yU5m5dMIgWzcT2Qis148p+y+w1teqJEnYsN\r\n' +
+ '7Ea1cRRbG/HXB4EmOuwI9oDU5so4gYqQKwv0YvL1P93AzxN0v5iA8g9JIcWD8jun\r\n' +
+ 'CeyV90HiPa/shqk/xMbwQTypfFK0kGSPPeCJNBeAmLlM4RoTdGHY7pSoYyuRaRZj\r\n' +
+ 'TgBfHT4WxQA5Wttp/rLlbJbyt0vabH15gyjE0WpYOItPh11ONchShJXh5/6zEyDS\r\n' +
+ 'Nyn6TjFLmoDqHRSIxNraYQd2q7e11v9CJX0eoqljjst0LAWPFZ7X4m+kSQtoTdzt\r\n' +
+ 'tuiPqkBY8wFokG/Mo0mDKwfTT1ZYSdygJZr8ZrNF+hXmBJN9mm4/0S+hN4Vtx/wm\r\n' +
+ 'KKWeUOysbqOl3r0EHhh0Mugo2ApTABBDwzoLy7UDXfmJT8T7M0hh+ZT1Pja+G1YL\r\n' +
+ '/HrGHx8eAQQj0c4hyqePC86jgSh3iIkaBJFgEpytfJAnRZ/qr50YK5G7J6R2EjrL\r\n' +
+ '8IGcABSimIidvn0gQ0fBB//LR3con+KjugsA8cTC/cTwfSoyWr9K9FhjpmQ0rxUZ\r\n' +
+ 'uE12auhTB2dNdCoOwai97jREVngGaL5GTqUqowNeUUXbedhQI5sRKphrRoinYjJ1\r\n' +
+ 'uPuJDLVEsur2pkenLZLZn4l0Srgq1KAOBuZzqqDT6adxfQn3eKN6H0XHja9HMYU5\r\n' +
+ 'eXNDEZyT+W6Xg4HcHtiH751LF62SR74GR1HiU3B1XXryXpxyBMGbzdypIDRR6PZb\r\n' +
+ '4o6na3Kx8nyYztI6KZ1Y4PukFqsYuCjFqjJDf9KtFM9eJyedSlsYGd2XDVMUpIlC\r\n' +
+ 'NQ9VbRk+hDoH+J74upvX3cbASGkjmuu6sIKdt+quV2vdbyCKukayeWBXVP8bCW4Z\r\n' +
+ 'ft0UIf8QIPmkP6GQ3F2qn/SjJI7WhrdGh04tpC0QuMdRLzJnd+R/tjA/QisCWxAW\r\n' +
+ '3WETPDphJMTqKHAUx/86VDSGV013uCrOkTXvuGJLOTl3mdbEj2+0+DLOE2APBsJc\r\n' +
+ 'O0Lt5P0Oouigbj+wSVz20Fg7QhXO8Wep7S0krHAXJv3FdV0Cdn6MXaxeCBOfY4Rf\r\n' +
+ 'MDUmN/xaiMk2mz7dfDRhg8OADNacg60RylM9jEQ1UclXNlzEBUseY7x3R7qqyeXz\r\n' +
+ '8zDQeCXj+PHFBm48fEvKhP5sqHNNZsB5cy53y6nVwM2Nb9XBOmVajX2kUSgQE3GQ\r\n' +
+ 'HdCZE45Gx9FNP+tG6fYRnOx33ABnJdYwcN4s7xNwBXlTFp2t4CLWPDjwXUSBPudh\r\n' +
+ '2Hy/IzXic86kMmpl09WvPY89eFQ9o1laR4y7M5vnx+GMpCGkxmYZBbOZIGESVoy0\r\n' +
+ '70R7mkVJDFpPQg8FONTNzJki4ggZ2osWBy9fHbE1DvM+MqZe+4zpikjeMwoqmsK4\r\n' +
+ 'flvcaautoiwLChpiG0/tjMw13JLPMW3ZMwQDfZXYta2ngT35X2iKcgZTykNSeVJe\r\n' +
+ 'bB+ABC1Q9+R9/xlmlrBIUzzZHjNWr2FqDfDvbIIhURYmOqojtncOCttvEg2BUKSU\r\n' +
+ 'DdHwTay9R34YmeM6GjzjAcJWY5PJUy+kYnD5Drkp0CNL3LSxoCuQEMqudFz/fMU/\r\n' +
+ 'C3PogT6Ncnkr1FVu4uvs3ujG2ufu2YaGrLcYw2/N1yOZJWnnz07goD94VtyojMNc\r\n' +
+ 'WTmKni3mHDobNYwHWiRW+g1vxptOH+u5efUlDuz9nnn6cOnqR73Xuht3wDOpyn/N\r\n' +
+ 'VfvhZLRa3xeTTVHFqQFU+oqPjTV9H6y58zWpGhu8HOvsBcMmU/FQS6mfK7ebPGGi\r\n' +
+ 'jboKbwLpHYFewi01tYgfqwn6hMMrzYPjJY1tsYJ8NIAsmRHkG70t70PVeTQ8cJoC\r\n' +
+ 'Fm2IFDsZV/iTDdrBqvRcyBo0XmONAQQKr7rk/90eM4fd8nxGm/cAp/67NotSWQHa\r\n' +
+ 'ZFdxhOPSBr6VBiS8SAfF1rIra8funxtQ5Yk04FPjsVotkm2nkMt4gntoM2b3w23Q\r\n' +
+ 'GBaNcyPikhkQ8UC80Fbz6UzyLBKbZqCDI/GSa1A4BSvp0vy1pndHzrynyytF4t80\r\n' +
+ 'r3I7e0M0SEHWYJFGmQ9szh3cXePvk0p5KJIu1BzPH6AoIK0dNRXQXAINnsxmpkeJ\r\n' +
+ '7pAkz0rIVxZ4SyH4TrZcXxnVJ0Gte9kd/95XSEZDyvT9Arhs/0jHzotxaua6wpK3\r\n' +
+ 'JFF4BEmRPE7U3PsPJQN1fm6mqOdmaCE0UrnLhaMf8uMzYOoXVV8A5eRIDtgJ3X8V\r\n' +
+ 'k6UkNbDt8mVlctLdkNM9tKkClaF4JnvyYYX16HS5sAJiZnM8vW46nh4KsYIVRqAf\r\n' +
+ 'DaAeJzxRTSInaW52tuDqrBPVnl5XiAKbrved1fOUSSorI+SptHzaHcIH20h2DuSJ\r\n' +
+ 'ryQnLseZ+F3sb7wdAUtQb6eMNvu7L3s1vBxKqKKlwAVuZEqQI/GT/5WAB34iul3U\r\n' +
+ 'hAZZX0xKfweRp27xLRyUiqGFAsOaoDIwRiDhVKJZVCwIa3dSKCW8jvmC+EaeSyKG\r\n' +
+ 'Wx7gGnJm9XovdI1hi/zHM60ABejiMnDeAACcvsCJqKXE/9YDFQF+yW30OSZ2AOUL\r\n' +
+ 'UWnyD493R347W2oPzV1HbYLd//2gIQFFeMDv0AWfJGv4K0JkZ/pGpaPAoee6Pd1C\r\n' +
+ 'OjcxbWhvbEwXDtVRFztCjgNd/rp4t+YQ9QbMczK3HplpMyYjIs0WdTU3gNWqmTEf\r\n' +
+ 'guOokh7tqlOHQso0gg3ax65vc2k9V2yLJz2CDkVkATKpJOjV4sNWGPnB4129xact\r\n' +
+ 'p9JfGDAWniAE4cYW/etNTXhNWJTzkSlb5Ad5JPPQ4p/lB97Xr/Krwjp1o3h2JTgC\r\n' +
+ 'IBfqb9g7WQ/B8EL0AwnoHxPDTdXAHOCiUr0y1M1w36thr56AVR97/R02k2XI3dxv\r\n' +
+ 'oS/bCgNtFFSao2O7uANqtU/SMHMl0BrR8dk+4924Wu0m06iNDZB8NU0jU5bqxcW6\r\n' +
+ 'wzf/rjqwIndehfpH7MkeCk6rM0JiVku/EKoCfg9DOAA2rLIiyWO2+mm5UWiT60a0\r\n' +
+ 'kmGwwrAxduugMnfVdb5fI8F+IyXYCH8Iwi6qpFvSLm4F/++0WP6pD1Xov6cRu9Eq\r\n' +
+ 'nQ4FcCFQJ62ymKlZ0+qZ1ywftKTRwNNlPfZezkqJm17sDI02AUAjGotxrSdDfca5\r\n' +
+ 'ViRxq+HJiQGVCUo4fEl4iMzSWaBLeQr9nSijB76dyq1e89NMXS0L3Uo6B7gbKm2i\r\n' +
+ 'AjRTUEN2LIGM7TiRC4kZRRMrgVcBBDAtuyY/sMDZ6bUageLXlAPSGZ+VY/a+usok\r\n' +
+ 'pxP+U88X7mkxuvvPIG7yKaxymdB993pRaVvLuPVcZRDmXIFrTSP5wxejRQpIvwNR\r\n' +
+ 'UeYwGQs1gAuM3l6N7trX99j6WBzZr09YRVPgehh5N3s/omrEMDMcExlmAdVOYNij\r\n' +
+ 'UN5NOZgPZrHTev4BtZa53FKttvGT9Ly9iLtle218tQyJRK7UQ/APZJzidpcy3p/x\r\n' +
+ 'U9AgXG9+horGLG4/HAmpZh4VH+8wXpiUxsC2rXLb0cAoFg03gStLvqXU93UU6KSn\r\n' +
+ 'xC0FYZZAqeFDdKbk4IMirklafEu+j45I+57RiCr7mpOyDI4o5FItWMzSxFo06ciw\r\n' +
+ 'aUT4eQf+pUFrBz0yUvgJArh3+VZdRhd8vycuxrYgfp9q4H1n2hOEOi/eeQCuJH36\r\n' +
+ 'RnAkToyRYwCepD3di2tf5FL2cW2DPMj69o7dIUHEn76SKVtgwmv5Q86rBWTecAn1\r\n' +
+ 'qkUXMst6qxyZCqHMsrQ0Bf7lcB9nSTvPXHzbJjLg0QRYi4qZzU46Vmo5bLw0l8R/\r\n' +
+ '66Wyv+OIastQdCB6S1JtRnE2zvR7nRA/TgfmbJBklgEUY9KeyRzh1Vkp7aykuMXV\r\n' +
+ '9bsND+1swzKgqTGxCyMMqIP6OQsr9AVlO4MsR8XCTOY4F/dTaCRHWXC/uvtuar/y\r\n' +
+ '8vFQeaUPSR10+XGxYb7tnaaBqdVy9MMuwz7Y3jYgvbfxku6aXJMyWFBRqCRskOZa\r\n' +
+ 'GQOMmb0j9QH/bl6goHBfCJjSSU+vkVytQf7ZtWyD+k4+R3X+nQEex0Eb+2nfzh3i\r\n' +
+ 'ZHSO7cqRz12/B8CmQ75L8suRcRrqINMdAZfmARp5s0UtmHYKbOcrxd4l625rUwTJ\r\n' +
+ 't0vih8+BK6k1F6oT1kCR6ZyfIHhh8dn22SYJAQFW3+WZsaPjLgkh0ihcyfhLfKMC\r\n' +
+ 'K3YvF/dt9rQDorwNwp5+xiuGUrwk7SLbc7wmNCFiD5nER3AhUSuGzQLfZzjeqYgK\r\n' +
+ 'Wge2QCPwtwzaHNp51c5QMvKqQfsg12P81qs3Jl/j+xKpzLh2vLYlnq8OuFd3lR6x\r\n' +
+ 'q0Rya6j4o+AqW/v1CJBRhS0qXTW/bHvPm8uU16Uw9W4AGPnISbLQh5sfOKkKgNN/\r\n' +
+ 'jTogehgId2rZ1VfhW7n9xvPkk2NEt+YmXHn7EuPri6GXPIDhaLWLaSpa8PYW+jxx\r\n' +
+ 'T0CDjYQkT/Q/TfuX3yzGHXKhMInKxjqihd1RQ2OIBLBF8/1UFNLM82XntXt2TJXK\r\n' +
+ 'kUQYAIJxH23h9ZBH2K3T2gNjOqLmiqE0C4QEW8xNO75TWiYm8j+sX2LmdYmXZP8C\r\n' +
+ 'iMlyE2shMVriN3t457D8S5a1aEvATDFxM4YL5k5OsZ6HrQ6PrnzZfrWXh5OxoxAU\r\n' +
+ '+FCXxpRi6lwY3yNi3kUteexRLZGrEz2FRPemDLsevShRqnsy/0OA/05TA6JxLVpd\r\n' +
+ 'Dd7ZWUBcIJZ7lQKMzfCAdWR20J7ngEuiUksQDo5h9/727aO/fbVh+aLVYY1EF+0p\r\n' +
+ '8gbM3/hyoGd8pujWqU1U7jLQACAp5zsy7xvnbiXYl42SaF1PFUP5aZrAPBcj0Fru\r\n' +
+ 't8SnPjys2JE172lCkQQOBglanklkpRiBDWYxG8josUyASo7EzddOneLNoMNl8+ZO\r\n' +
+ 'ZZYN6BRIioChYDsrrPZiootTU5DYC8a0/AcDsV6PQ48SlInCKtuAOi8nHJDVUzBI\r\n' +
+ 'QkDd13kAeIFEMOJUV17xh7eLpbe10bv1B8zUiMbvBTzWPXZHEbuNlWiGy960J4t3\r\n' +
+ 'x6NGEAfIjYg9+aMCf7uiEWd48s+nrKWymn7Ewg7llyMfK2Vsa9PVMilopGx42y51\r\n' +
+ 'HMIzSV4TjOxSAJmXFZs55w57Rqjx3+LP9P7Ilpde4Lh35hD6yX5hZW+gnQs+B/j8\r\n' +
+ 'DkBDeIYtMSz4tHqiK6rBUD/KnNUYYmOOGUi/bPyS4TH0ycbSFp1xx+rS/86Uh8YK\r\n' +
+ 'wSOVkKvL2VhGE5G0RSSvYLUkEPcjA8K+EaHf8aCWpnGmpr3rT7F00JFhmH/kDXcU\r\n' +
+ 'rtatu8Lniqm0sIV84nVEqHF9Vgz1D2d2/VYfLWlMDM5Mb8IWVUi8fjNFQf32bTCZ\r\n' +
+ 'ZYTNUSushCwwpo2R8akkURsev+zstIzw73MGldj2AJ6y/0h51Z4dpQuJbwsKIw4g\r\n' +
+ '5MH42cM4PwiQ7hpqDeGLoyfeAMRFnme/HZCsgBCv247KXdpuYolORXBwjiqhlXYl\r\n' +
+ '6W5aUXp7H+Idz+ahq+nEdsGR57lX1dCC731i8x7/0fl7LEAPGCgr3A0UqTesBKqV\r\n' +
+ '5iq03xmxLhXEyv5QJVPCmG2067Wuoi9hMbXWb/IuX6TV2GACuZ54x9ftWtrPtZ7J\r\n' +
+ 'bJEst/IK1SvODlNpk3Z8jcx8YFS7RzjrI3CuVrn45HXF5yHlzwiyBnaFiuBXaDFk\r\n' +
+ 'kFGnTIxDrDfBsxCN7v3snuf+eW41SaXv8BHAvi4A+cv5vpSduEGY+aZWdgLDsnxw\r\n' +
+ '+zU5GUhNuT28YKEYzyTnMTdo/QL1KZkFqRDqANeRK3V24OaxHt6sbxYuRLGphytc\r\n' +
+ 'uUnB6ICpHgwASejiJY/hWhm5PLI3jxdXAa7XOg7asESz1yo7FrJIwW7UlnNBOneA\r\n' +
+ 'yuYFdB0usNx+E63hsw+TJ9Sg0+t+mG2+Fr1hE2qEahF2BrrB9LW0xuTXmAeW2qHp\r\n' +
+ 'cOVLJigo9QsEy3Y/sPuDJC0z9MnsKefglpSZyGBxkpKtVN7ePHl/hmMBRD6W1aZ0\r\n' +
+ '8bdl0Ljj6SoT9DB8qqyUX3Km/5xSWguvp2hMa1s/J+dJAzOOGx9P94QOgggrImOR\r\n' +
+ 'yhMa/3i5qA9QPzT0ivMtQwS5HaGL6Hjv6jkmK1FzfCoOE8d6+9AuhvvbfZs3c0Wf\r\n' +
+ '31F5e09s6fPqXTk3Dw6TsiED+NjtTTywPEaNgjldpPjZPBpAl6pNx/i9KghBmaCG\r\n' +
+ 'LDsvFJ/BqZf1qYFKE47Ozf8jQ4b+ZgU37awZAKERnoEvPdJ3gv5H+pyjbYbacLG4\r\n' +
+ '2jF/pRzhiF0eRBuqY/5DrgMe1dkI9TNvBFzsX4YFOxZWca/kc26JhCajuH8MaTyW\r\n' +
+ 'LzOeIg6QKane6HBBxRvoOBMIa40oBhffbOi5FKukKUFS3xlPL3EwdS/aZK61vCR2\r\n' +
+ 'NPS7Y/d2vk80aNVRZAm2FBcmBWF6q7A825S7HqwM1izmlmqC6yWYXGofP8PuYfww\r\n' +
+ 'eWW5rm+3URjcRM54K5Ob7rfKu3q7zUwUAB6R7YM9pgeDbaARyE7mB0MmpB+3UqO8\r\n' +
+ 'F5heKtELqIskZGAiCKxGPKERoHPItKTV77ZCZ+ql0FjlJSrXVZ1P/9i/BiwdYmij\r\n' +
+ 'vhjCEtDcHWPXXIra6Hf5hTIUJ7conZ9ldGhHliV6Rso7ST1FGIsqrgYDyt1/+Vo4\r\n' +
+ 'hNBaUhWOHh65EKRblCW04v71KyaL8ms7Pevgcz4NZFtUwv3v2qI+OqdWBFFbc9Lr\r\n' +
+ 'cfiyt5XbZeUD4GiI5/wDVk0b07ev7xyoedeB7GvXgmb13D1vCtHYubeDyI+V7zlM\r\n' +
+ 'GXPvCkIPhj34fK6vhtHJIfHL3+8vf6emd7h4Ziakod9G0HYJTKbugpCmi6ejW8G9\r\n' +
+ 'X5Kzrn9c8HD7bNCUtwNFV0unoZUN3ReVAOLNn2N0LUfHBrlq/XwseHovUbzSomYT\r\n' +
+ 'Xtr/w+tiLSMSRLsJzAu0LJHgNtYPsPIavpim0OLTPg7JBmnzWoyEFCXcLvjNry6c\r\n' +
+ 'yCgA4RgfmBcJzXS1Uyf/TUM9IFoeTbGo9dIziygUdWXxrUzx2Uyak53xZXEX82cB\r\n' +
+ 'kC/v1+VCq668xgthc9pEEHIsqxKuRCUXj53xYThI5gSJke3XYrCdk3R8rh8FdkkQ\r\n' +
+ 'E/4WFpZ8kqraFXSYlfYvGHYd31cbJoSxjTIISd5US85KaOH2n3HN0d017xfwaSqS\r\n' +
+ 'I1l1iutPvcc+wxydp7On+uQAP4GiV1uPmuN0s0lu81j7ye9nS+fjxlXiukHQu1mF\r\n' +
+ 'c5IdEASgborfk+mrVpl/hpeLJH4LZIGPaZgr3KDBZPDMgqDCXBphL+GjJYPXyW7I\r\n' +
+ 't3QRCKMTNHCO7E3e7eet7k2ADSjrN1eZuzo7FxCU6cv+oCQUWPzaRYWb6gzr2QV4\r\n' +
+ 'snvwM2sGc0Mkg1QnJAzT6zrtfVZ2uh2VwkN93u8KxwiiCRn53rHn46uW1djNHmIe\r\n' +
+ '4E2vS4IWoCmy59lGxV6UEfsjEGxC+pDv33xX69aDf8vN6VON8B4ooHwdg+GMe2Us\r\n' +
+ 'N7sQkhf1ykdR0tmJnG8yr0DfGfxbcJArEv8wcZh89M0oOY7iKx/hq4n4DSVHLmDg\r\n' +
+ 'obV4S2+c5aRrVFWQiw+/OjA9MCEwCQYFKw4DAhoFAAQUXolDwewLkmOH6dGcPdhJ\r\n' +
+ 'JeUrAz0EFHRZbCAQ2bUo5B8DAFM8VJLi/+A2AgIEAA=='
+ };
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/forge'
+ ], function(FORGE) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ FORGE
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/forge'));
+}
+
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[14/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/http.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/http.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/http.js
new file mode 100644
index 0000000..fa01aed
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/http.js
@@ -0,0 +1,1369 @@
+/**
+ * HTTP client-side implementation that uses forge.net sockets.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc. All rights reserved.
+ */
+(function() {
+
+// define http namespace
+var http = {};
+
+// logging category
+var cat = 'forge.http';
+
+// add array of clients to debug storage
+if(forge.debug) {
+ forge.debug.set('forge.http', 'clients', []);
+}
+
+// normalizes an http header field name
+var _normalize = function(name) {
+ return name.toLowerCase().replace(/(^.)|(-.)/g,
+ function(a){return a.toUpperCase();});
+};
+
+/**
+ * Gets the local storage ID for the given client.
+ *
+ * @param client the client to get the local storage ID for.
+ *
+ * @return the local storage ID to use.
+ */
+var _getStorageId = function(client) {
+ // TODO: include browser in ID to avoid sharing cookies between
+ // browsers (if this is undesirable)
+ // navigator.userAgent
+ return 'forge.http.' +
+ client.url.scheme + '.' +
+ client.url.host + '.' +
+ client.url.port;
+};
+
+/**
+ * Loads persistent cookies from disk for the given client.
+ *
+ * @param client the client.
+ */
+var _loadCookies = function(client) {
+ if(client.persistCookies) {
+ try {
+ var cookies = forge.util.getItem(
+ client.socketPool.flashApi,
+ _getStorageId(client), 'cookies');
+ client.cookies = cookies || {};
+ } catch(ex) {
+ // no flash storage available, just silently fail
+ // TODO: i assume we want this logged somewhere or
+ // should it actually generate an error
+ //forge.log.error(cat, ex);
+ }
+ }
+};
+
+/**
+ * Saves persistent cookies on disk for the given client.
+ *
+ * @param client the client.
+ */
+var _saveCookies = function(client) {
+ if(client.persistCookies) {
+ try {
+ forge.util.setItem(
+ client.socketPool.flashApi,
+ _getStorageId(client), 'cookies', client.cookies);
+ } catch(ex) {
+ // no flash storage available, just silently fail
+ // TODO: i assume we want this logged somewhere or
+ // should it actually generate an error
+ //forge.log.error(cat, ex);
+ }
+ }
+
+ // FIXME: remove me
+ _loadCookies(client);
+};
+
+/**
+ * Clears persistent cookies on disk for the given client.
+ *
+ * @param client the client.
+ */
+var _clearCookies = function(client) {
+ if(client.persistCookies) {
+ try {
+ // only thing stored is 'cookies', so clear whole storage
+ forge.util.clearItems(
+ client.socketPool.flashApi,
+ _getStorageId(client));
+ } catch(ex) {
+ // no flash storage available, just silently fail
+ // TODO: i assume we want this logged somewhere or
+ // should it actually generate an error
+ //forge.log.error(cat, ex);
+ }
+ }
+};
+
+/**
+ * Connects and sends a request.
+ *
+ * @param client the http client.
+ * @param socket the socket to use.
+ */
+var _doRequest = function(client, socket) {
+ if(socket.isConnected()) {
+ // already connected
+ socket.options.request.connectTime = +new Date();
+ socket.connected({
+ type: 'connect',
+ id: socket.id
+ });
+ } else {
+ // connect
+ socket.options.request.connectTime = +new Date();
+ socket.connect({
+ host: client.url.host,
+ port: client.url.port,
+ policyPort: client.policyPort,
+ policyUrl: client.policyUrl
+ });
+ }
+};
+
+/**
+ * Handles the next request or marks a socket as idle.
+ *
+ * @param client the http client.
+ * @param socket the socket.
+ */
+var _handleNextRequest = function(client, socket) {
+ // clear buffer
+ socket.buffer.clear();
+
+ // get pending request
+ var pending = null;
+ while(pending === null && client.requests.length > 0) {
+ pending = client.requests.shift();
+ if(pending.request.aborted) {
+ pending = null;
+ }
+ }
+
+ // mark socket idle if no pending requests
+ if(pending === null) {
+ if(socket.options !== null) {
+ socket.options = null;
+ }
+ client.idle.push(socket);
+ } else {
+ // handle pending request, allow 1 retry
+ socket.retries = 1;
+ socket.options = pending;
+ _doRequest(client, socket);
+ }
+};
+
+/**
+ * Sets up a socket for use with an http client.
+ *
+ * @param client the parent http client.
+ * @param socket the socket to set up.
+ * @param tlsOptions if the socket must use TLS, the TLS options.
+ */
+var _initSocket = function(client, socket, tlsOptions) {
+ // no socket options yet
+ socket.options = null;
+
+ // set up handlers
+ socket.connected = function(e) {
+ // socket primed by caching TLS session, handle next request
+ if(socket.options === null) {
+ _handleNextRequest(client, socket);
+ } else {
+ // socket in use
+ var request = socket.options.request;
+ request.connectTime = +new Date() - request.connectTime;
+ e.socket = socket;
+ socket.options.connected(e);
+ if(request.aborted) {
+ socket.close();
+ } else {
+ var out = request.toString();
+ if(request.body) {
+ out += request.body;
+ }
+ request.time = +new Date();
+ socket.send(out);
+ request.time = +new Date() - request.time;
+ socket.options.response.time = +new Date();
+ socket.sending = true;
+ }
+ }
+ };
+ socket.closed = function(e) {
+ if(socket.sending) {
+ socket.sending = false;
+ if(socket.retries > 0) {
+ --socket.retries;
+ _doRequest(client, socket);
+ } else {
+ // error, closed during send
+ socket.error({
+ id: socket.id,
+ type: 'ioError',
+ message: 'Connection closed during send. Broken pipe.',
+ bytesAvailable: 0
+ });
+ }
+ } else {
+ // handle unspecified content-length transfer
+ var response = socket.options.response;
+ if(response.readBodyUntilClose) {
+ response.time = +new Date() - response.time;
+ response.bodyReceived = true;
+ socket.options.bodyReady({
+ request: socket.options.request,
+ response: response,
+ socket: socket
+ });
+ }
+ socket.options.closed(e);
+ _handleNextRequest(client, socket);
+ }
+ };
+ socket.data = function(e) {
+ socket.sending = false;
+ var request = socket.options.request;
+ if(request.aborted) {
+ socket.close();
+ } else {
+ // receive all bytes available
+ var response = socket.options.response;
+ var bytes = socket.receive(e.bytesAvailable);
+ if(bytes !== null) {
+ // receive header and then body
+ socket.buffer.putBytes(bytes);
+ if(!response.headerReceived) {
+ response.readHeader(socket.buffer);
+ if(response.headerReceived) {
+ socket.options.headerReady({
+ request: socket.options.request,
+ response: response,
+ socket: socket
+ });
+ }
+ }
+ if(response.headerReceived && !response.bodyReceived) {
+ response.readBody(socket.buffer);
+ }
+ if(response.bodyReceived) {
+ socket.options.bodyReady({
+ request: socket.options.request,
+ response: response,
+ socket: socket
+ });
+ // close connection if requested or by default on http/1.0
+ var value = response.getField('Connection') || '';
+ if(value.indexOf('close') != -1 ||
+ (response.version === 'HTTP/1.0' &&
+ response.getField('Keep-Alive') === null)) {
+ socket.close();
+ } else {
+ _handleNextRequest(client, socket);
+ }
+ }
+ }
+ }
+ };
+ socket.error = function(e) {
+ // do error callback, include request
+ socket.options.error({
+ type: e.type,
+ message: e.message,
+ request: socket.options.request,
+ response: socket.options.response,
+ socket: socket
+ });
+ socket.close();
+ };
+
+ // wrap socket for TLS
+ if(tlsOptions) {
+ socket = forge.tls.wrapSocket({
+ sessionId: null,
+ sessionCache: {},
+ caStore: tlsOptions.caStore,
+ cipherSuites: tlsOptions.cipherSuites,
+ socket: socket,
+ virtualHost: tlsOptions.virtualHost,
+ verify: tlsOptions.verify,
+ getCertificate: tlsOptions.getCertificate,
+ getPrivateKey: tlsOptions.getPrivateKey,
+ getSignature: tlsOptions.getSignature,
+ deflate: tlsOptions.deflate || null,
+ inflate: tlsOptions.inflate || null
+ });
+
+ socket.options = null;
+ socket.buffer = forge.util.createBuffer();
+ client.sockets.push(socket);
+ if(tlsOptions.prime) {
+ // prime socket by connecting and caching TLS session, will do
+ // next request from there
+ socket.connect({
+ host: client.url.host,
+ port: client.url.port,
+ policyPort: client.policyPort,
+ policyUrl: client.policyUrl
+ });
+ } else {
+ // do not prime socket, just add as idle
+ client.idle.push(socket);
+ }
+ } else {
+ // no need to prime non-TLS sockets
+ socket.buffer = forge.util.createBuffer();
+ client.sockets.push(socket);
+ client.idle.push(socket);
+ }
+};
+
+/**
+ * Checks to see if the given cookie has expired. If the cookie's max-age
+ * plus its created time is less than the time now, it has expired, unless
+ * its max-age is set to -1 which indicates it will never expire.
+ *
+ * @param cookie the cookie to check.
+ *
+ * @return true if it has expired, false if not.
+ */
+var _hasCookieExpired = function(cookie) {
+ var rval = false;
+
+ if(cookie.maxAge !== -1) {
+ var now = _getUtcTime(new Date());
+ var expires = cookie.created + cookie.maxAge;
+ if(expires <= now) {
+ rval = true;
+ }
+ }
+
+ return rval;
+};
+
+/**
+ * Adds cookies in the given client to the given request.
+ *
+ * @param client the client.
+ * @param request the request.
+ */
+var _writeCookies = function(client, request) {
+ var expired = [];
+ var url = client.url;
+ var cookies = client.cookies;
+ for(var name in cookies) {
+ // get cookie paths
+ var paths = cookies[name];
+ for(var p in paths) {
+ var cookie = paths[p];
+ if(_hasCookieExpired(cookie)) {
+ // store for clean up
+ expired.push(cookie);
+ } else if(request.path.indexOf(cookie.path) === 0) {
+ // path or path's ancestor must match cookie.path
+ request.addCookie(cookie);
+ }
+ }
+ }
+
+ // clean up expired cookies
+ for(var i = 0; i < expired.length; ++i) {
+ var cookie = expired[i];
+ client.removeCookie(cookie.name, cookie.path);
+ }
+};
+
+/**
+ * Gets cookies from the given response and adds the to the given client.
+ *
+ * @param client the client.
+ * @param response the response.
+ */
+var _readCookies = function(client, response) {
+ var cookies = response.getCookies();
+ for(var i = 0; i < cookies.length; ++i) {
+ try {
+ client.setCookie(cookies[i]);
+ } catch(ex) {
+ // ignore failure to add other-domain, etc. cookies
+ }
+ }
+};
+
+/**
+ * Creates an http client that uses forge.net sockets as a backend and
+ * forge.tls for security.
+ *
+ * @param options:
+ * url: the url to connect to (scheme://host:port).
+ * socketPool: the flash socket pool to use.
+ * policyPort: the flash policy port to use (if other than the
+ * socket pool default), use 0 for flash default.
+ * policyUrl: the flash policy file URL to use (if provided will
+ * be used instead of a policy port).
+ * connections: number of connections to use to handle requests.
+ * caCerts: an array of certificates to trust for TLS, certs may
+ * be PEM-formatted or cert objects produced via forge.pki.
+ * cipherSuites: an optional array of cipher suites to use,
+ * see forge.tls.CipherSuites.
+ * virtualHost: the virtual server name to use in a TLS SNI
+ * extension, if not provided the url host will be used.
+ * verify: a custom TLS certificate verify callback to use.
+ * getCertificate: an optional callback used to get a client-side
+ * certificate (see forge.tls for details).
+ * getPrivateKey: an optional callback used to get a client-side
+ * private key (see forge.tls for details).
+ * getSignature: an optional callback used to get a client-side
+ * signature (see forge.tls for details).
+ * persistCookies: true to use persistent cookies via flash local
+ * storage, false to only keep cookies in javascript.
+ * primeTlsSockets: true to immediately connect TLS sockets on
+ * their creation so that they will cache TLS sessions for reuse.
+ *
+ * @return the client.
+ */
+http.createClient = function(options) {
+ // create CA store to share with all TLS connections
+ var caStore = null;
+ if(options.caCerts) {
+ caStore = forge.pki.createCaStore(options.caCerts);
+ }
+
+ // get scheme, host, and port from url
+ options.url = (options.url ||
+ window.location.protocol + '//' + window.location.host);
+ var url = http.parseUrl(options.url);
+ if(!url) {
+ var error = new Error('Invalid url.');
+ error.details = {url: options.url};
+ throw error;
+ }
+
+ // default to 1 connection
+ options.connections = options.connections || 1;
+
+ // create client
+ var sp = options.socketPool;
+ var client = {
+ // url
+ url: url,
+ // socket pool
+ socketPool: sp,
+ // the policy port to use
+ policyPort: options.policyPort,
+ // policy url to use
+ policyUrl: options.policyUrl,
+ // queue of requests to service
+ requests: [],
+ // all sockets
+ sockets: [],
+ // idle sockets
+ idle: [],
+ // whether or not the connections are secure
+ secure: (url.scheme === 'https'),
+ // cookie jar (key'd off of name and then path, there is only 1 domain
+ // and one setting for secure per client so name+path is unique)
+ cookies: {},
+ // default to flash storage of cookies
+ persistCookies: (typeof(options.persistCookies) === 'undefined') ?
+ true : options.persistCookies
+ };
+
+ // add client to debug storage
+ if(forge.debug) {
+ forge.debug.get('forge.http', 'clients').push(client);
+ }
+
+ // load cookies from disk
+ _loadCookies(client);
+
+ /**
+ * A default certificate verify function that checks a certificate common
+ * name against the client's URL host.
+ *
+ * @param c the TLS connection.
+ * @param verified true if cert is verified, otherwise alert number.
+ * @param depth the chain depth.
+ * @param certs the cert chain.
+ *
+ * @return true if verified and the common name matches the host, error
+ * otherwise.
+ */
+ var _defaultCertificateVerify = function(c, verified, depth, certs) {
+ if(depth === 0 && verified === true) {
+ // compare common name to url host
+ var cn = certs[depth].subject.getField('CN');
+ if(cn === null || client.url.host !== cn.value) {
+ verified = {
+ message: 'Certificate common name does not match url host.'
+ };
+ }
+ }
+ return verified;
+ };
+
+ // determine if TLS is used
+ var tlsOptions = null;
+ if(client.secure) {
+ tlsOptions = {
+ caStore: caStore,
+ cipherSuites: options.cipherSuites || null,
+ virtualHost: options.virtualHost || url.host,
+ verify: options.verify || _defaultCertificateVerify,
+ getCertificate: options.getCertificate || null,
+ getPrivateKey: options.getPrivateKey || null,
+ getSignature: options.getSignature || null,
+ prime: options.primeTlsSockets || false
+ };
+
+ // if socket pool uses a flash api, then add deflate support to TLS
+ if(sp.flashApi !== null) {
+ tlsOptions.deflate = function(bytes) {
+ // strip 2 byte zlib header and 4 byte trailer
+ return forge.util.deflate(sp.flashApi, bytes, true);
+ };
+ tlsOptions.inflate = function(bytes) {
+ return forge.util.inflate(sp.flashApi, bytes, true);
+ };
+ }
+ }
+
+ // create and initialize sockets
+ for(var i = 0; i < options.connections; ++i) {
+ _initSocket(client, sp.createSocket(), tlsOptions);
+ }
+
+ /**
+ * Sends a request. A method 'abort' will be set on the request that
+ * can be called to attempt to abort the request.
+ *
+ * @param options:
+ * request: the request to send.
+ * connected: a callback for when the connection is open.
+ * closed: a callback for when the connection is closed.
+ * headerReady: a callback for when the response header arrives.
+ * bodyReady: a callback for when the response body arrives.
+ * error: a callback for if an error occurs.
+ */
+ client.send = function(options) {
+ // add host header if not set
+ if(options.request.getField('Host') === null) {
+ options.request.setField('Host', client.url.fullHost);
+ }
+
+ // set default dummy handlers
+ var opts = {};
+ opts.request = options.request;
+ opts.connected = options.connected || function(){};
+ opts.closed = options.close || function(){};
+ opts.headerReady = function(e) {
+ // read cookies
+ _readCookies(client, e.response);
+ if(options.headerReady) {
+ options.headerReady(e);
+ }
+ };
+ opts.bodyReady = options.bodyReady || function(){};
+ opts.error = options.error || function(){};
+
+ // create response
+ opts.response = http.createResponse();
+ opts.response.time = 0;
+ opts.response.flashApi = client.socketPool.flashApi;
+ opts.request.flashApi = client.socketPool.flashApi;
+
+ // create abort function
+ opts.request.abort = function() {
+ // set aborted, clear handlers
+ opts.request.aborted = true;
+ opts.connected = function(){};
+ opts.closed = function(){};
+ opts.headerReady = function(){};
+ opts.bodyReady = function(){};
+ opts.error = function(){};
+ };
+
+ // add cookies to request
+ _writeCookies(client, opts.request);
+
+ // queue request options if there are no idle sockets
+ if(client.idle.length === 0) {
+ client.requests.push(opts);
+ } else {
+ // use an idle socket, prefer an idle *connected* socket first
+ var socket = null;
+ var len = client.idle.length;
+ for(var i = 0; socket === null && i < len; ++i) {
+ socket = client.idle[i];
+ if(socket.isConnected()) {
+ client.idle.splice(i, 1);
+ } else {
+ socket = null;
+ }
+ }
+ // no connected socket available, get unconnected socket
+ if(socket === null) {
+ socket = client.idle.pop();
+ }
+ socket.options = opts;
+ _doRequest(client, socket);
+ }
+ };
+
+ /**
+ * Destroys this client.
+ */
+ client.destroy = function() {
+ // clear pending requests, close and destroy sockets
+ client.requests = [];
+ for(var i = 0; i < client.sockets.length; ++i) {
+ client.sockets[i].close();
+ client.sockets[i].destroy();
+ }
+ client.socketPool = null;
+ client.sockets = [];
+ client.idle = [];
+ };
+
+ /**
+ * Sets a cookie for use with all connections made by this client. Any
+ * cookie with the same name will be replaced. If the cookie's value
+ * is undefined, null, or the blank string, the cookie will be removed.
+ *
+ * If the cookie's domain doesn't match this client's url host or the
+ * cookie's secure flag doesn't match this client's url scheme, then
+ * setting the cookie will fail with an exception.
+ *
+ * @param cookie the cookie with parameters:
+ * name: the name of the cookie.
+ * value: the value of the cookie.
+ * comment: an optional comment string.
+ * maxAge: the age of the cookie in seconds relative to created time.
+ * secure: true if the cookie must be sent over a secure protocol.
+ * httpOnly: true to restrict access to the cookie from javascript
+ * (inaffective since the cookies are stored in javascript).
+ * path: the path for the cookie.
+ * domain: optional domain the cookie belongs to (must start with dot).
+ * version: optional version of the cookie.
+ * created: creation time, in UTC seconds, of the cookie.
+ */
+ client.setCookie = function(cookie) {
+ var rval;
+ if(typeof(cookie.name) !== 'undefined') {
+ if(cookie.value === null || typeof(cookie.value) === 'undefined' ||
+ cookie.value === '') {
+ // remove cookie
+ rval = client.removeCookie(cookie.name, cookie.path);
+ } else {
+ // set cookie defaults
+ cookie.comment = cookie.comment || '';
+ cookie.maxAge = cookie.maxAge || 0;
+ cookie.secure = (typeof(cookie.secure) === 'undefined') ?
+ true : cookie.secure;
+ cookie.httpOnly = cookie.httpOnly || true;
+ cookie.path = cookie.path || '/';
+ cookie.domain = cookie.domain || null;
+ cookie.version = cookie.version || null;
+ cookie.created = _getUtcTime(new Date());
+
+ // do secure check
+ if(cookie.secure !== client.secure) {
+ var error = new Error('Http client url scheme is incompatible ' +
+ 'with cookie secure flag.');
+ error.url = client.url;
+ error.cookie = cookie;
+ throw error;
+ }
+ // make sure url host is within cookie.domain
+ if(!http.withinCookieDomain(client.url, cookie)) {
+ var error = new Error('Http client url scheme is incompatible ' +
+ 'with cookie secure flag.');
+ error.url = client.url;
+ error.cookie = cookie;
+ throw error;
+ }
+
+ // add new cookie
+ if(!(cookie.name in client.cookies)) {
+ client.cookies[cookie.name] = {};
+ }
+ client.cookies[cookie.name][cookie.path] = cookie;
+ rval = true;
+
+ // save cookies
+ _saveCookies(client);
+ }
+ }
+
+ return rval;
+ };
+
+ /**
+ * Gets a cookie by its name.
+ *
+ * @param name the name of the cookie to retrieve.
+ * @param path an optional path for the cookie (if there are multiple
+ * cookies with the same name but different paths).
+ *
+ * @return the cookie or null if not found.
+ */
+ client.getCookie = function(name, path) {
+ var rval = null;
+ if(name in client.cookies) {
+ var paths = client.cookies[name];
+
+ // get path-specific cookie
+ if(path) {
+ if(path in paths) {
+ rval = paths[path];
+ }
+ } else {
+ // get first cookie
+ for(var p in paths) {
+ rval = paths[p];
+ break;
+ }
+ }
+ }
+ return rval;
+ };
+
+ /**
+ * Removes a cookie.
+ *
+ * @param name the name of the cookie to remove.
+ * @param path an optional path for the cookie (if there are multiple
+ * cookies with the same name but different paths).
+ *
+ * @return true if a cookie was removed, false if not.
+ */
+ client.removeCookie = function(name, path) {
+ var rval = false;
+ if(name in client.cookies) {
+ // delete the specific path
+ if(path) {
+ var paths = client.cookies[name];
+ if(path in paths) {
+ rval = true;
+ delete client.cookies[name][path];
+ // clean up entry if empty
+ var empty = true;
+ for(var i in client.cookies[name]) {
+ empty = false;
+ break;
+ }
+ if(empty) {
+ delete client.cookies[name];
+ }
+ }
+ } else {
+ // delete all cookies with the given name
+ rval = true;
+ delete client.cookies[name];
+ }
+ }
+ if(rval) {
+ // save cookies
+ _saveCookies(client);
+ }
+ return rval;
+ };
+
+ /**
+ * Clears all cookies stored in this client.
+ */
+ client.clearCookies = function() {
+ client.cookies = {};
+ _clearCookies(client);
+ };
+
+ if(forge.log) {
+ forge.log.debug('forge.http', 'created client', options);
+ }
+
+ return client;
+};
+
+/**
+ * Trims the whitespace off of the beginning and end of a string.
+ *
+ * @param str the string to trim.
+ *
+ * @return the trimmed string.
+ */
+var _trimString = function(str) {
+ return str.replace(/^\s*/, '').replace(/\s*$/, '');
+};
+
+/**
+ * Creates an http header object.
+ *
+ * @return the http header object.
+ */
+var _createHeader = function() {
+ var header = {
+ fields: {},
+ setField: function(name, value) {
+ // normalize field name, trim value
+ header.fields[_normalize(name)] = [_trimString('' + value)];
+ },
+ appendField: function(name, value) {
+ name = _normalize(name);
+ if(!(name in header.fields)) {
+ header.fields[name] = [];
+ }
+ header.fields[name].push(_trimString('' + value));
+ },
+ getField: function(name, index) {
+ var rval = null;
+ name = _normalize(name);
+ if(name in header.fields) {
+ index = index || 0;
+ rval = header.fields[name][index];
+ }
+ return rval;
+ }
+ };
+ return header;
+};
+
+/**
+ * Gets the time in utc seconds given a date.
+ *
+ * @param d the date to use.
+ *
+ * @return the time in utc seconds.
+ */
+var _getUtcTime = function(d) {
+ var utc = +d + d.getTimezoneOffset() * 60000;
+ return Math.floor(+new Date() / 1000);
+};
+
+/**
+ * Creates an http request.
+ *
+ * @param options:
+ * version: the version.
+ * method: the method.
+ * path: the path.
+ * body: the body.
+ * headers: custom header fields to add,
+ * eg: [{'Content-Length': 0}].
+ *
+ * @return the http request.
+ */
+http.createRequest = function(options) {
+ options = options || {};
+ var request = _createHeader();
+ request.version = options.version || 'HTTP/1.1';
+ request.method = options.method || null;
+ request.path = options.path || null;
+ request.body = options.body || null;
+ request.bodyDeflated = false;
+ request.flashApi = null;
+
+ // add custom headers
+ var headers = options.headers || [];
+ if(!forge.util.isArray(headers)) {
+ headers = [headers];
+ }
+ for(var i = 0; i < headers.length; ++i) {
+ for(var name in headers[i]) {
+ request.appendField(name, headers[i][name]);
+ }
+ }
+
+ /**
+ * Adds a cookie to the request 'Cookie' header.
+ *
+ * @param cookie a cookie to add.
+ */
+ request.addCookie = function(cookie) {
+ var value = '';
+ var field = request.getField('Cookie');
+ if(field !== null) {
+ // separate cookies by semi-colons
+ value = field + '; ';
+ }
+
+ // get current time in utc seconds
+ var now = _getUtcTime(new Date());
+
+ // output cookie name and value
+ value += cookie.name + '=' + cookie.value;
+ request.setField('Cookie', value);
+ };
+
+ /**
+ * Converts an http request into a string that can be sent as an
+ * HTTP request. Does not include any data.
+ *
+ * @return the string representation of the request.
+ */
+ request.toString = function() {
+ /* Sample request header:
+ GET /some/path/?query HTTP/1.1
+ Host: www.someurl.com
+ Connection: close
+ Accept-Encoding: deflate
+ Accept: image/gif, text/html
+ User-Agent: Mozilla 4.0
+ */
+
+ // set default headers
+ if(request.getField('User-Agent') === null) {
+ request.setField('User-Agent', 'forge.http 1.0');
+ }
+ if(request.getField('Accept') === null) {
+ request.setField('Accept', '*/*');
+ }
+ if(request.getField('Connection') === null) {
+ request.setField('Connection', 'keep-alive');
+ request.setField('Keep-Alive', '115');
+ }
+
+ // add Accept-Encoding if not specified
+ if(request.flashApi !== null &&
+ request.getField('Accept-Encoding') === null) {
+ request.setField('Accept-Encoding', 'deflate');
+ }
+
+ // if the body isn't null, deflate it if its larger than 100 bytes
+ if(request.flashApi !== null && request.body !== null &&
+ request.getField('Content-Encoding') === null &&
+ !request.bodyDeflated && request.body.length > 100) {
+ // use flash to compress data
+ request.body = forge.util.deflate(request.flashApi, request.body);
+ request.bodyDeflated = true;
+ request.setField('Content-Encoding', 'deflate');
+ request.setField('Content-Length', request.body.length);
+ } else if(request.body !== null) {
+ // set content length for body
+ request.setField('Content-Length', request.body.length);
+ }
+
+ // build start line
+ var rval =
+ request.method.toUpperCase() + ' ' + request.path + ' ' +
+ request.version + '\r\n';
+
+ // add each header
+ for(var name in request.fields) {
+ var fields = request.fields[name];
+ for(var i = 0; i < fields.length; ++i) {
+ rval += name + ': ' + fields[i] + '\r\n';
+ }
+ }
+ // final terminating CRLF
+ rval += '\r\n';
+
+ return rval;
+ };
+
+ return request;
+};
+
+/**
+ * Creates an empty http response header.
+ *
+ * @return the empty http response header.
+ */
+http.createResponse = function() {
+ // private vars
+ var _first = true;
+ var _chunkSize = 0;
+ var _chunksFinished = false;
+
+ // create response
+ var response = _createHeader();
+ response.version = null;
+ response.code = 0;
+ response.message = null;
+ response.body = null;
+ response.headerReceived = false;
+ response.bodyReceived = false;
+ response.flashApi = null;
+
+ /**
+ * Reads a line that ends in CRLF from a byte buffer.
+ *
+ * @param b the byte buffer.
+ *
+ * @return the line or null if none was found.
+ */
+ var _readCrlf = function(b) {
+ var line = null;
+ var i = b.data.indexOf('\r\n', b.read);
+ if(i != -1) {
+ // read line, skip CRLF
+ line = b.getBytes(i - b.read);
+ b.getBytes(2);
+ }
+ return line;
+ };
+
+ /**
+ * Parses a header field and appends it to the response.
+ *
+ * @param line the header field line.
+ */
+ var _parseHeader = function(line) {
+ var tmp = line.indexOf(':');
+ var name = line.substring(0, tmp++);
+ response.appendField(
+ name, (tmp < line.length) ? line.substring(tmp) : '');
+ };
+
+ /**
+ * Reads an http response header from a buffer of bytes.
+ *
+ * @param b the byte buffer to parse the header from.
+ *
+ * @return true if the whole header was read, false if not.
+ */
+ response.readHeader = function(b) {
+ // read header lines (each ends in CRLF)
+ var line = '';
+ while(!response.headerReceived && line !== null) {
+ line = _readCrlf(b);
+ if(line !== null) {
+ // parse first line
+ if(_first) {
+ _first = false;
+ var tmp = line.split(' ');
+ if(tmp.length >= 3) {
+ response.version = tmp[0];
+ response.code = parseInt(tmp[1], 10);
+ response.message = tmp.slice(2).join(' ');
+ } else {
+ // invalid header
+ var error = new Error('Invalid http response header.');
+ error.details = {'line': line};
+ throw error;
+ }
+ } else if(line.length === 0) {
+ // handle final line, end of header
+ response.headerReceived = true;
+ } else {
+ _parseHeader(line);
+ }
+ }
+ }
+
+ return response.headerReceived;
+ };
+
+ /**
+ * Reads some chunked http response entity-body from the given buffer of
+ * bytes.
+ *
+ * @param b the byte buffer to read from.
+ *
+ * @return true if the whole body was read, false if not.
+ */
+ var _readChunkedBody = function(b) {
+ /* Chunked transfer-encoding sends data in a series of chunks,
+ followed by a set of 0-N http trailers.
+ The format is as follows:
+
+ chunk-size (in hex) CRLF
+ chunk data (with "chunk-size" many bytes) CRLF
+ ... (N many chunks)
+ chunk-size (of 0 indicating the last chunk) CRLF
+ N many http trailers followed by CRLF
+ blank line + CRLF (terminates the trailers)
+
+ If there are no http trailers, then after the chunk-size of 0,
+ there is still a single CRLF (indicating the blank line + CRLF
+ that terminates the trailers). In other words, you always terminate
+ the trailers with blank line + CRLF, regardless of 0-N trailers. */
+
+ /* From RFC-2616, section 3.6.1, here is the pseudo-code for
+ implementing chunked transfer-encoding:
+
+ length := 0
+ read chunk-size, chunk-extension (if any) and CRLF
+ while (chunk-size > 0) {
+ read chunk-data and CRLF
+ append chunk-data to entity-body
+ length := length + chunk-size
+ read chunk-size and CRLF
+ }
+ read entity-header
+ while (entity-header not empty) {
+ append entity-header to existing header fields
+ read entity-header
+ }
+ Content-Length := length
+ Remove "chunked" from Transfer-Encoding
+ */
+
+ var line = '';
+ while(line !== null && b.length() > 0) {
+ // if in the process of reading a chunk
+ if(_chunkSize > 0) {
+ // if there are not enough bytes to read chunk and its
+ // trailing CRLF, we must wait for more data to be received
+ if(_chunkSize + 2 > b.length()) {
+ break;
+ }
+
+ // read chunk data, skip CRLF
+ response.body += b.getBytes(_chunkSize);
+ b.getBytes(2);
+ _chunkSize = 0;
+ } else if(!_chunksFinished) {
+ // more chunks, read next chunk-size line
+ line = _readCrlf(b);
+ if(line !== null) {
+ // parse chunk-size (ignore any chunk extension)
+ _chunkSize = parseInt(line.split(';', 1)[0], 16);
+ _chunksFinished = (_chunkSize === 0);
+ }
+ } else {
+ // chunks finished, read next trailer
+ line = _readCrlf(b);
+ while(line !== null) {
+ if(line.length > 0) {
+ // parse trailer
+ _parseHeader(line);
+ // read next trailer
+ line = _readCrlf(b);
+ } else {
+ // body received
+ response.bodyReceived = true;
+ line = null;
+ }
+ }
+ }
+ }
+
+ return response.bodyReceived;
+ };
+
+ /**
+ * Reads an http response body from a buffer of bytes.
+ *
+ * @param b the byte buffer to read from.
+ *
+ * @return true if the whole body was read, false if not.
+ */
+ response.readBody = function(b) {
+ var contentLength = response.getField('Content-Length');
+ var transferEncoding = response.getField('Transfer-Encoding');
+ if(contentLength !== null) {
+ contentLength = parseInt(contentLength);
+ }
+
+ // read specified length
+ if(contentLength !== null && contentLength >= 0) {
+ response.body = response.body || '';
+ response.body += b.getBytes(contentLength);
+ response.bodyReceived = (response.body.length === contentLength);
+ } else if(transferEncoding !== null) {
+ // read chunked encoding
+ if(transferEncoding.indexOf('chunked') != -1) {
+ response.body = response.body || '';
+ _readChunkedBody(b);
+ } else {
+ var error = new Error('Unknown Transfer-Encoding.');
+ error.details = {'transferEncoding': transferEncoding};
+ throw error;
+ }
+ } else if((contentLength !== null && contentLength < 0) ||
+ (contentLength === null &&
+ response.getField('Content-Type') !== null)) {
+ // read all data in the buffer
+ response.body = response.body || '';
+ response.body += b.getBytes();
+ response.readBodyUntilClose = true;
+ } else {
+ // no body
+ response.body = null;
+ response.bodyReceived = true;
+ }
+
+ if(response.bodyReceived) {
+ response.time = +new Date() - response.time;
+ }
+
+ if(response.flashApi !== null &&
+ response.bodyReceived && response.body !== null &&
+ response.getField('Content-Encoding') === 'deflate') {
+ // inflate using flash api
+ response.body = forge.util.inflate(
+ response.flashApi, response.body);
+ }
+
+ return response.bodyReceived;
+ };
+
+ /**
+ * Parses an array of cookies from the 'Set-Cookie' field, if present.
+ *
+ * @return the array of cookies.
+ */
+ response.getCookies = function() {
+ var rval = [];
+
+ // get Set-Cookie field
+ if('Set-Cookie' in response.fields) {
+ var field = response.fields['Set-Cookie'];
+
+ // get current local time in seconds
+ var now = +new Date() / 1000;
+
+ // regex for parsing 'name1=value1; name2=value2; name3'
+ var regex = /\s*([^=]*)=?([^;]*)(;|$)/g;
+
+ // examples:
+ // Set-Cookie: cookie1_name=cookie1_value; max-age=0; path=/
+ // Set-Cookie: c2=v2; expires=Thu, 21-Aug-2008 23:47:25 GMT; path=/
+ for(var i = 0; i < field.length; ++i) {
+ var fv = field[i];
+ var m;
+ regex.lastIndex = 0;
+ var first = true;
+ var cookie = {};
+ do {
+ m = regex.exec(fv);
+ if(m !== null) {
+ var name = _trimString(m[1]);
+ var value = _trimString(m[2]);
+
+ // cookie_name=value
+ if(first) {
+ cookie.name = name;
+ cookie.value = value;
+ first = false;
+ } else {
+ // property_name=value
+ name = name.toLowerCase();
+ switch(name) {
+ case 'expires':
+ // replace hyphens w/spaces so date will parse
+ value = value.replace(/-/g, ' ');
+ var secs = Date.parse(value) / 1000;
+ cookie.maxAge = Math.max(0, secs - now);
+ break;
+ case 'max-age':
+ cookie.maxAge = parseInt(value, 10);
+ break;
+ case 'secure':
+ cookie.secure = true;
+ break;
+ case 'httponly':
+ cookie.httpOnly = true;
+ break;
+ default:
+ if(name !== '') {
+ cookie[name] = value;
+ }
+ }
+ }
+ }
+ } while(m !== null && m[0] !== '');
+ rval.push(cookie);
+ }
+ }
+
+ return rval;
+ };
+
+ /**
+ * Converts an http response into a string that can be sent as an
+ * HTTP response. Does not include any data.
+ *
+ * @return the string representation of the response.
+ */
+ response.toString = function() {
+ /* Sample response header:
+ HTTP/1.0 200 OK
+ Host: www.someurl.com
+ Connection: close
+ */
+
+ // build start line
+ var rval =
+ response.version + ' ' + response.code + ' ' + response.message + '\r\n';
+
+ // add each header
+ for(var name in response.fields) {
+ var fields = response.fields[name];
+ for(var i = 0; i < fields.length; ++i) {
+ rval += name + ': ' + fields[i] + '\r\n';
+ }
+ }
+ // final terminating CRLF
+ rval += '\r\n';
+
+ return rval;
+ };
+
+ return response;
+};
+
+/**
+ * Parses the scheme, host, and port from an http(s) url.
+ *
+ * @param str the url string.
+ *
+ * @return the parsed url object or null if the url is invalid.
+ */
+http.parseUrl = forge.util.parseUrl;
+
+/**
+ * Returns true if the given url is within the given cookie's domain.
+ *
+ * @param url the url to check.
+ * @param cookie the cookie or cookie domain to check.
+ */
+http.withinCookieDomain = function(url, cookie) {
+ var rval = false;
+
+ // cookie may be null, a cookie object, or a domain string
+ var domain = (cookie === null || typeof cookie === 'string') ?
+ cookie : cookie.domain;
+
+ // any domain will do
+ if(domain === null) {
+ rval = true;
+ } else if(domain.charAt(0) === '.') {
+ // ensure domain starts with a '.'
+ // parse URL as necessary
+ if(typeof url === 'string') {
+ url = http.parseUrl(url);
+ }
+
+ // add '.' to front of URL host to match against domain
+ var host = '.' + url.host;
+
+ // if the host ends with domain then it falls within it
+ var idx = host.lastIndexOf(domain);
+ if(idx !== -1 && (idx + domain.length === host.length)) {
+ rval = true;
+ }
+ }
+
+ return rval;
+};
+
+// public access to http namespace
+if(typeof forge === 'undefined') {
+ forge = {};
+}
+forge.http = http;
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/jsbn.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/jsbn.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/jsbn.js
new file mode 100644
index 0000000..29a1509
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/jsbn.js
@@ -0,0 +1,1321 @@
+// Copyright (c) 2005 Tom Wu
+// All Rights Reserved.
+// See "LICENSE" for details.
+
+// Basic JavaScript BN library - subset useful for RSA encryption.
+
+/*
+Licensing (LICENSE)
+-------------------
+
+This software is covered under the following copyright:
+*/
+/*
+ * Copyright (c) 2003-2005 Tom Wu
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following condition applies:
+ *
+ * All redistributions must retain an intact copy of this copyright notice
+ * and disclaimer.
+ */
+/*
+Address all questions regarding this license to:
+
+ Tom Wu
+ tjw@cs.Stanford.EDU
+*/
+
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// Bits per digit
+var dbits;
+
+// JavaScript engine analysis
+var canary = 0xdeadbeefcafe;
+var j_lm = ((canary&0xffffff)==0xefcafe);
+
+// (public) Constructor
+function BigInteger(a,b,c) {
+ this.data = [];
+ if(a != null)
+ if("number" == typeof a) this.fromNumber(a,b,c);
+ else if(b == null && "string" != typeof a) this.fromString(a,256);
+ else this.fromString(a,b);
+}
+
+// return new, unset BigInteger
+function nbi() { return new BigInteger(null); }
+
+// am: Compute w_j += (x*this_i), propagate carries,
+// c is initial carry, returns final carry.
+// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
+// We need to select the fastest one that works in this environment.
+
+// am1: use a single mult and divide to get the high bits,
+// max digit bits should be 26 because
+// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
+function am1(i,x,w,j,c,n) {
+ while(--n >= 0) {
+ var v = x*this.data[i++]+w.data[j]+c;
+ c = Math.floor(v/0x4000000);
+ w.data[j++] = v&0x3ffffff;
+ }
+ return c;
+}
+// am2 avoids a big mult-and-extract completely.
+// Max digit bits should be <= 30 because we do bitwise ops
+// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
+function am2(i,x,w,j,c,n) {
+ var xl = x&0x7fff, xh = x>>15;
+ while(--n >= 0) {
+ var l = this.data[i]&0x7fff;
+ var h = this.data[i++]>>15;
+ var m = xh*l+h*xl;
+ l = xl*l+((m&0x7fff)<<15)+w.data[j]+(c&0x3fffffff);
+ c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
+ w.data[j++] = l&0x3fffffff;
+ }
+ return c;
+}
+// Alternately, set max digit bits to 28 since some
+// browsers slow down when dealing with 32-bit numbers.
+function am3(i,x,w,j,c,n) {
+ var xl = x&0x3fff, xh = x>>14;
+ while(--n >= 0) {
+ var l = this.data[i]&0x3fff;
+ var h = this.data[i++]>>14;
+ var m = xh*l+h*xl;
+ l = xl*l+((m&0x3fff)<<14)+w.data[j]+c;
+ c = (l>>28)+(m>>14)+xh*h;
+ w.data[j++] = l&0xfffffff;
+ }
+ return c;
+}
+
+// node.js (no browser)
+if(typeof(navigator) === 'undefined')
+{
+ BigInteger.prototype.am = am3;
+ dbits = 28;
+} else if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
+ BigInteger.prototype.am = am2;
+ dbits = 30;
+} else if(j_lm && (navigator.appName != "Netscape")) {
+ BigInteger.prototype.am = am1;
+ dbits = 26;
+} else { // Mozilla/Netscape seems to prefer am3
+ BigInteger.prototype.am = am3;
+ dbits = 28;
+}
+
+BigInteger.prototype.DB = dbits;
+BigInteger.prototype.DM = ((1<<dbits)-1);
+BigInteger.prototype.DV = (1<<dbits);
+
+var BI_FP = 52;
+BigInteger.prototype.FV = Math.pow(2,BI_FP);
+BigInteger.prototype.F1 = BI_FP-dbits;
+BigInteger.prototype.F2 = 2*dbits-BI_FP;
+
+// Digit conversions
+var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
+var BI_RC = new Array();
+var rr,vv;
+rr = "0".charCodeAt(0);
+for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
+rr = "a".charCodeAt(0);
+for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
+rr = "A".charCodeAt(0);
+for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
+
+function int2char(n) { return BI_RM.charAt(n); }
+function intAt(s,i) {
+ var c = BI_RC[s.charCodeAt(i)];
+ return (c==null)?-1:c;
+}
+
+// (protected) copy this to r
+function bnpCopyTo(r) {
+ for(var i = this.t-1; i >= 0; --i) r.data[i] = this.data[i];
+ r.t = this.t;
+ r.s = this.s;
+}
+
+// (protected) set from integer value x, -DV <= x < DV
+function bnpFromInt(x) {
+ this.t = 1;
+ this.s = (x<0)?-1:0;
+ if(x > 0) this.data[0] = x;
+ else if(x < -1) this.data[0] = x+this.DV;
+ else this.t = 0;
+}
+
+// return bigint initialized to value
+function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
+
+// (protected) set from string and radix
+function bnpFromString(s,b) {
+ var k;
+ if(b == 16) k = 4;
+ else if(b == 8) k = 3;
+ else if(b == 256) k = 8; // byte array
+ else if(b == 2) k = 1;
+ else if(b == 32) k = 5;
+ else if(b == 4) k = 2;
+ else { this.fromRadix(s,b); return; }
+ this.t = 0;
+ this.s = 0;
+ var i = s.length, mi = false, sh = 0;
+ while(--i >= 0) {
+ var x = (k==8)?s[i]&0xff:intAt(s,i);
+ if(x < 0) {
+ if(s.charAt(i) == "-") mi = true;
+ continue;
+ }
+ mi = false;
+ if(sh == 0)
+ this.data[this.t++] = x;
+ else if(sh+k > this.DB) {
+ this.data[this.t-1] |= (x&((1<<(this.DB-sh))-1))<<sh;
+ this.data[this.t++] = (x>>(this.DB-sh));
+ } else
+ this.data[this.t-1] |= x<<sh;
+ sh += k;
+ if(sh >= this.DB) sh -= this.DB;
+ }
+ if(k == 8 && (s[0]&0x80) != 0) {
+ this.s = -1;
+ if(sh > 0) this.data[this.t-1] |= ((1<<(this.DB-sh))-1)<<sh;
+ }
+ this.clamp();
+ if(mi) BigInteger.ZERO.subTo(this,this);
+}
+
+// (protected) clamp off excess high words
+function bnpClamp() {
+ var c = this.s&this.DM;
+ while(this.t > 0 && this.data[this.t-1] == c) --this.t;
+}
+
+// (public) return string representation in given radix
+function bnToString(b) {
+ if(this.s < 0) return "-"+this.negate().toString(b);
+ var k;
+ if(b == 16) k = 4;
+ else if(b == 8) k = 3;
+ else if(b == 2) k = 1;
+ else if(b == 32) k = 5;
+ else if(b == 4) k = 2;
+ else return this.toRadix(b);
+ var km = (1<<k)-1, d, m = false, r = "", i = this.t;
+ var p = this.DB-(i*this.DB)%k;
+ if(i-- > 0) {
+ if(p < this.DB && (d = this.data[i]>>p) > 0) { m = true; r = int2char(d); }
+ while(i >= 0) {
+ if(p < k) {
+ d = (this.data[i]&((1<<p)-1))<<(k-p);
+ d |= this.data[--i]>>(p+=this.DB-k);
+ } else {
+ d = (this.data[i]>>(p-=k))&km;
+ if(p <= 0) { p += this.DB; --i; }
+ }
+ if(d > 0) m = true;
+ if(m) r += int2char(d);
+ }
+ }
+ return m?r:"0";
+}
+
+// (public) -this
+function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
+
+// (public) |this|
+function bnAbs() { return (this.s<0)?this.negate():this; }
+
+// (public) return + if this > a, - if this < a, 0 if equal
+function bnCompareTo(a) {
+ var r = this.s-a.s;
+ if(r != 0) return r;
+ var i = this.t;
+ r = i-a.t;
+ if(r != 0) return (this.s<0)?-r:r;
+ while(--i >= 0) if((r=this.data[i]-a.data[i]) != 0) return r;
+ return 0;
+}
+
+// returns bit length of the integer x
+function nbits(x) {
+ var r = 1, t;
+ if((t=x>>>16) != 0) { x = t; r += 16; }
+ if((t=x>>8) != 0) { x = t; r += 8; }
+ if((t=x>>4) != 0) { x = t; r += 4; }
+ if((t=x>>2) != 0) { x = t; r += 2; }
+ if((t=x>>1) != 0) { x = t; r += 1; }
+ return r;
+}
+
+// (public) return the number of bits in "this"
+function bnBitLength() {
+ if(this.t <= 0) return 0;
+ return this.DB*(this.t-1)+nbits(this.data[this.t-1]^(this.s&this.DM));
+}
+
+// (protected) r = this << n*DB
+function bnpDLShiftTo(n,r) {
+ var i;
+ for(i = this.t-1; i >= 0; --i) r.data[i+n] = this.data[i];
+ for(i = n-1; i >= 0; --i) r.data[i] = 0;
+ r.t = this.t+n;
+ r.s = this.s;
+}
+
+// (protected) r = this >> n*DB
+function bnpDRShiftTo(n,r) {
+ for(var i = n; i < this.t; ++i) r.data[i-n] = this.data[i];
+ r.t = Math.max(this.t-n,0);
+ r.s = this.s;
+}
+
+// (protected) r = this << n
+function bnpLShiftTo(n,r) {
+ var bs = n%this.DB;
+ var cbs = this.DB-bs;
+ var bm = (1<<cbs)-1;
+ var ds = Math.floor(n/this.DB), c = (this.s<<bs)&this.DM, i;
+ for(i = this.t-1; i >= 0; --i) {
+ r.data[i+ds+1] = (this.data[i]>>cbs)|c;
+ c = (this.data[i]&bm)<<bs;
+ }
+ for(i = ds-1; i >= 0; --i) r.data[i] = 0;
+ r.data[ds] = c;
+ r.t = this.t+ds+1;
+ r.s = this.s;
+ r.clamp();
+}
+
+// (protected) r = this >> n
+function bnpRShiftTo(n,r) {
+ r.s = this.s;
+ var ds = Math.floor(n/this.DB);
+ if(ds >= this.t) { r.t = 0; return; }
+ var bs = n%this.DB;
+ var cbs = this.DB-bs;
+ var bm = (1<<bs)-1;
+ r.data[0] = this.data[ds]>>bs;
+ for(var i = ds+1; i < this.t; ++i) {
+ r.data[i-ds-1] |= (this.data[i]&bm)<<cbs;
+ r.data[i-ds] = this.data[i]>>bs;
+ }
+ if(bs > 0) r.data[this.t-ds-1] |= (this.s&bm)<<cbs;
+ r.t = this.t-ds;
+ r.clamp();
+}
+
+// (protected) r = this - a
+function bnpSubTo(a,r) {
+ var i = 0, c = 0, m = Math.min(a.t,this.t);
+ while(i < m) {
+ c += this.data[i]-a.data[i];
+ r.data[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ if(a.t < this.t) {
+ c -= a.s;
+ while(i < this.t) {
+ c += this.data[i];
+ r.data[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ c += this.s;
+ } else {
+ c += this.s;
+ while(i < a.t) {
+ c -= a.data[i];
+ r.data[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ c -= a.s;
+ }
+ r.s = (c<0)?-1:0;
+ if(c < -1) r.data[i++] = this.DV+c;
+ else if(c > 0) r.data[i++] = c;
+ r.t = i;
+ r.clamp();
+}
+
+// (protected) r = this * a, r != this,a (HAC 14.12)
+// "this" should be the larger one if appropriate.
+function bnpMultiplyTo(a,r) {
+ var x = this.abs(), y = a.abs();
+ var i = x.t;
+ r.t = i+y.t;
+ while(--i >= 0) r.data[i] = 0;
+ for(i = 0; i < y.t; ++i) r.data[i+x.t] = x.am(0,y.data[i],r,i,0,x.t);
+ r.s = 0;
+ r.clamp();
+ if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
+}
+
+// (protected) r = this^2, r != this (HAC 14.16)
+function bnpSquareTo(r) {
+ var x = this.abs();
+ var i = r.t = 2*x.t;
+ while(--i >= 0) r.data[i] = 0;
+ for(i = 0; i < x.t-1; ++i) {
+ var c = x.am(i,x.data[i],r,2*i,0,1);
+ if((r.data[i+x.t]+=x.am(i+1,2*x.data[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
+ r.data[i+x.t] -= x.DV;
+ r.data[i+x.t+1] = 1;
+ }
+ }
+ if(r.t > 0) r.data[r.t-1] += x.am(i,x.data[i],r,2*i,0,1);
+ r.s = 0;
+ r.clamp();
+}
+
+// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
+// r != q, this != m. q or r may be null.
+function bnpDivRemTo(m,q,r) {
+ var pm = m.abs();
+ if(pm.t <= 0) return;
+ var pt = this.abs();
+ if(pt.t < pm.t) {
+ if(q != null) q.fromInt(0);
+ if(r != null) this.copyTo(r);
+ return;
+ }
+ if(r == null) r = nbi();
+ var y = nbi(), ts = this.s, ms = m.s;
+ var nsh = this.DB-nbits(pm.data[pm.t-1]); // normalize modulus
+ if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } else { pm.copyTo(y); pt.copyTo(r); }
+ var ys = y.t;
+ var y0 = y.data[ys-1];
+ if(y0 == 0) return;
+ var yt = y0*(1<<this.F1)+((ys>1)?y.data[ys-2]>>this.F2:0);
+ var d1 = this.FV/yt, d2 = (1<<this.F1)/yt, e = 1<<this.F2;
+ var i = r.t, j = i-ys, t = (q==null)?nbi():q;
+ y.dlShiftTo(j,t);
+ if(r.compareTo(t) >= 0) {
+ r.data[r.t++] = 1;
+ r.subTo(t,r);
+ }
+ BigInteger.ONE.dlShiftTo(ys,t);
+ t.subTo(y,y); // "negative" y so we can replace sub with am later
+ while(y.t < ys) y.data[y.t++] = 0;
+ while(--j >= 0) {
+ // Estimate quotient digit
+ var qd = (r.data[--i]==y0)?this.DM:Math.floor(r.data[i]*d1+(r.data[i-1]+e)*d2);
+ if((r.data[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
+ y.dlShiftTo(j,t);
+ r.subTo(t,r);
+ while(r.data[i] < --qd) r.subTo(t,r);
+ }
+ }
+ if(q != null) {
+ r.drShiftTo(ys,q);
+ if(ts != ms) BigInteger.ZERO.subTo(q,q);
+ }
+ r.t = ys;
+ r.clamp();
+ if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
+ if(ts < 0) BigInteger.ZERO.subTo(r,r);
+}
+
+// (public) this mod a
+function bnMod(a) {
+ var r = nbi();
+ this.abs().divRemTo(a,null,r);
+ if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
+ return r;
+}
+
+// Modular reduction using "classic" algorithm
+function Classic(m) { this.m = m; }
+function cConvert(x) {
+ if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
+ else return x;
+}
+function cRevert(x) { return x; }
+function cReduce(x) { x.divRemTo(this.m,null,x); }
+function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
+function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
+
+Classic.prototype.convert = cConvert;
+Classic.prototype.revert = cRevert;
+Classic.prototype.reduce = cReduce;
+Classic.prototype.mulTo = cMulTo;
+Classic.prototype.sqrTo = cSqrTo;
+
+// (protected) return "-1/this % 2^DB"; useful for Mont. reduction
+// justification:
+// xy == 1 (mod m)
+// xy = 1+km
+// xy(2-xy) = (1+km)(1-km)
+// x[y(2-xy)] = 1-k^2m^2
+// x[y(2-xy)] == 1 (mod m^2)
+// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
+// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
+// JS multiply "overflows" differently from C/C++, so care is needed here.
+function bnpInvDigit() {
+ if(this.t < 1) return 0;
+ var x = this.data[0];
+ if((x&1) == 0) return 0;
+ var y = x&3; // y == 1/x mod 2^2
+ y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
+ y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
+ y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
+ // last step - calculate inverse mod DV directly;
+ // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
+ y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
+ // we really want the negative inverse, and -DV < y < DV
+ return (y>0)?this.DV-y:-y;
+}
+
+// Montgomery reduction
+function Montgomery(m) {
+ this.m = m;
+ this.mp = m.invDigit();
+ this.mpl = this.mp&0x7fff;
+ this.mph = this.mp>>15;
+ this.um = (1<<(m.DB-15))-1;
+ this.mt2 = 2*m.t;
+}
+
+// xR mod m
+function montConvert(x) {
+ var r = nbi();
+ x.abs().dlShiftTo(this.m.t,r);
+ r.divRemTo(this.m,null,r);
+ if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
+ return r;
+}
+
+// x/R mod m
+function montRevert(x) {
+ var r = nbi();
+ x.copyTo(r);
+ this.reduce(r);
+ return r;
+}
+
+// x = x/R mod m (HAC 14.32)
+function montReduce(x) {
+ while(x.t <= this.mt2) // pad x so am has enough room later
+ x.data[x.t++] = 0;
+ for(var i = 0; i < this.m.t; ++i) {
+ // faster way of calculating u0 = x.data[i]*mp mod DV
+ var j = x.data[i]&0x7fff;
+ var u0 = (j*this.mpl+(((j*this.mph+(x.data[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
+ // use am to combine the multiply-shift-add into one call
+ j = i+this.m.t;
+ x.data[j] += this.m.am(0,u0,x,i,0,this.m.t);
+ // propagate carry
+ while(x.data[j] >= x.DV) { x.data[j] -= x.DV; x.data[++j]++; }
+ }
+ x.clamp();
+ x.drShiftTo(this.m.t,x);
+ if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
+}
+
+// r = "x^2/R mod m"; x != r
+function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
+
+// r = "xy/R mod m"; x,y != r
+function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
+
+Montgomery.prototype.convert = montConvert;
+Montgomery.prototype.revert = montRevert;
+Montgomery.prototype.reduce = montReduce;
+Montgomery.prototype.mulTo = montMulTo;
+Montgomery.prototype.sqrTo = montSqrTo;
+
+// (protected) true iff this is even
+function bnpIsEven() { return ((this.t>0)?(this.data[0]&1):this.s) == 0; }
+
+// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
+function bnpExp(e,z) {
+ if(e > 0xffffffff || e < 1) return BigInteger.ONE;
+ var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
+ g.copyTo(r);
+ while(--i >= 0) {
+ z.sqrTo(r,r2);
+ if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
+ else { var t = r; r = r2; r2 = t; }
+ }
+ return z.revert(r);
+}
+
+// (public) this^e % m, 0 <= e < 2^32
+function bnModPowInt(e,m) {
+ var z;
+ if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
+ return this.exp(e,z);
+}
+
+// protected
+BigInteger.prototype.copyTo = bnpCopyTo;
+BigInteger.prototype.fromInt = bnpFromInt;
+BigInteger.prototype.fromString = bnpFromString;
+BigInteger.prototype.clamp = bnpClamp;
+BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
+BigInteger.prototype.drShiftTo = bnpDRShiftTo;
+BigInteger.prototype.lShiftTo = bnpLShiftTo;
+BigInteger.prototype.rShiftTo = bnpRShiftTo;
+BigInteger.prototype.subTo = bnpSubTo;
+BigInteger.prototype.multiplyTo = bnpMultiplyTo;
+BigInteger.prototype.squareTo = bnpSquareTo;
+BigInteger.prototype.divRemTo = bnpDivRemTo;
+BigInteger.prototype.invDigit = bnpInvDigit;
+BigInteger.prototype.isEven = bnpIsEven;
+BigInteger.prototype.exp = bnpExp;
+
+// public
+BigInteger.prototype.toString = bnToString;
+BigInteger.prototype.negate = bnNegate;
+BigInteger.prototype.abs = bnAbs;
+BigInteger.prototype.compareTo = bnCompareTo;
+BigInteger.prototype.bitLength = bnBitLength;
+BigInteger.prototype.mod = bnMod;
+BigInteger.prototype.modPowInt = bnModPowInt;
+
+// "constants"
+BigInteger.ZERO = nbv(0);
+BigInteger.ONE = nbv(1);
+
+// jsbn2 lib
+
+//Copyright (c) 2005-2009 Tom Wu
+//All Rights Reserved.
+//See "LICENSE" for details (See jsbn.js for LICENSE).
+
+//Extended JavaScript BN functions, required for RSA private ops.
+
+//Version 1.1: new BigInteger("0", 10) returns "proper" zero
+
+//(public)
+function bnClone() { var r = nbi(); this.copyTo(r); return r; }
+
+//(public) return value as integer
+function bnIntValue() {
+if(this.s < 0) {
+ if(this.t == 1) return this.data[0]-this.DV;
+ else if(this.t == 0) return -1;
+} else if(this.t == 1) return this.data[0];
+else if(this.t == 0) return 0;
+// assumes 16 < DB < 32
+return ((this.data[1]&((1<<(32-this.DB))-1))<<this.DB)|this.data[0];
+}
+
+//(public) return value as byte
+function bnByteValue() { return (this.t==0)?this.s:(this.data[0]<<24)>>24; }
+
+//(public) return value as short (assumes DB>=16)
+function bnShortValue() { return (this.t==0)?this.s:(this.data[0]<<16)>>16; }
+
+//(protected) return x s.t. r^x < DV
+function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
+
+//(public) 0 if this == 0, 1 if this > 0
+function bnSigNum() {
+if(this.s < 0) return -1;
+else if(this.t <= 0 || (this.t == 1 && this.data[0] <= 0)) return 0;
+else return 1;
+}
+
+//(protected) convert to radix string
+function bnpToRadix(b) {
+if(b == null) b = 10;
+if(this.signum() == 0 || b < 2 || b > 36) return "0";
+var cs = this.chunkSize(b);
+var a = Math.pow(b,cs);
+var d = nbv(a), y = nbi(), z = nbi(), r = "";
+this.divRemTo(d,y,z);
+while(y.signum() > 0) {
+ r = (a+z.intValue()).toString(b).substr(1) + r;
+ y.divRemTo(d,y,z);
+}
+return z.intValue().toString(b) + r;
+}
+
+//(protected) convert from radix string
+function bnpFromRadix(s,b) {
+this.fromInt(0);
+if(b == null) b = 10;
+var cs = this.chunkSize(b);
+var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
+for(var i = 0; i < s.length; ++i) {
+ var x = intAt(s,i);
+ if(x < 0) {
+ if(s.charAt(i) == "-" && this.signum() == 0) mi = true;
+ continue;
+ }
+ w = b*w+x;
+ if(++j >= cs) {
+ this.dMultiply(d);
+ this.dAddOffset(w,0);
+ j = 0;
+ w = 0;
+ }
+}
+if(j > 0) {
+ this.dMultiply(Math.pow(b,j));
+ this.dAddOffset(w,0);
+}
+if(mi) BigInteger.ZERO.subTo(this,this);
+}
+
+//(protected) alternate constructor
+function bnpFromNumber(a,b,c) {
+if("number" == typeof b) {
+ // new BigInteger(int,int,RNG)
+ if(a < 2) this.fromInt(1);
+ else {
+ this.fromNumber(a,c);
+ if(!this.testBit(a-1)) // force MSB set
+ this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);
+ if(this.isEven()) this.dAddOffset(1,0); // force odd
+ while(!this.isProbablePrime(b)) {
+ this.dAddOffset(2,0);
+ if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this);
+ }
+ }
+} else {
+ // new BigInteger(int,RNG)
+ var x = new Array(), t = a&7;
+ x.length = (a>>3)+1;
+ b.nextBytes(x);
+ if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
+ this.fromString(x,256);
+}
+}
+
+//(public) convert to bigendian byte array
+function bnToByteArray() {
+var i = this.t, r = new Array();
+r[0] = this.s;
+var p = this.DB-(i*this.DB)%8, d, k = 0;
+if(i-- > 0) {
+ if(p < this.DB && (d = this.data[i]>>p) != (this.s&this.DM)>>p)
+ r[k++] = d|(this.s<<(this.DB-p));
+ while(i >= 0) {
+ if(p < 8) {
+ d = (this.data[i]&((1<<p)-1))<<(8-p);
+ d |= this.data[--i]>>(p+=this.DB-8);
+ } else {
+ d = (this.data[i]>>(p-=8))&0xff;
+ if(p <= 0) { p += this.DB; --i; }
+ }
+ if((d&0x80) != 0) d |= -256;
+ if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
+ if(k > 0 || d != this.s) r[k++] = d;
+ }
+}
+return r;
+}
+
+function bnEquals(a) { return(this.compareTo(a)==0); }
+function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
+function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
+
+//(protected) r = this op a (bitwise)
+function bnpBitwiseTo(a,op,r) {
+var i, f, m = Math.min(a.t,this.t);
+for(i = 0; i < m; ++i) r.data[i] = op(this.data[i],a.data[i]);
+if(a.t < this.t) {
+ f = a.s&this.DM;
+ for(i = m; i < this.t; ++i) r.data[i] = op(this.data[i],f);
+ r.t = this.t;
+} else {
+ f = this.s&this.DM;
+ for(i = m; i < a.t; ++i) r.data[i] = op(f,a.data[i]);
+ r.t = a.t;
+}
+r.s = op(this.s,a.s);
+r.clamp();
+}
+
+//(public) this & a
+function op_and(x,y) { return x&y; }
+function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
+
+//(public) this | a
+function op_or(x,y) { return x|y; }
+function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
+
+//(public) this ^ a
+function op_xor(x,y) { return x^y; }
+function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
+
+//(public) this & ~a
+function op_andnot(x,y) { return x&~y; }
+function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
+
+//(public) ~this
+function bnNot() {
+var r = nbi();
+for(var i = 0; i < this.t; ++i) r.data[i] = this.DM&~this.data[i];
+r.t = this.t;
+r.s = ~this.s;
+return r;
+}
+
+//(public) this << n
+function bnShiftLeft(n) {
+var r = nbi();
+if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
+return r;
+}
+
+//(public) this >> n
+function bnShiftRight(n) {
+var r = nbi();
+if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
+return r;
+}
+
+//return index of lowest 1-bit in x, x < 2^31
+function lbit(x) {
+if(x == 0) return -1;
+var r = 0;
+if((x&0xffff) == 0) { x >>= 16; r += 16; }
+if((x&0xff) == 0) { x >>= 8; r += 8; }
+if((x&0xf) == 0) { x >>= 4; r += 4; }
+if((x&3) == 0) { x >>= 2; r += 2; }
+if((x&1) == 0) ++r;
+return r;
+}
+
+//(public) returns index of lowest 1-bit (or -1 if none)
+function bnGetLowestSetBit() {
+for(var i = 0; i < this.t; ++i)
+ if(this.data[i] != 0) return i*this.DB+lbit(this.data[i]);
+if(this.s < 0) return this.t*this.DB;
+return -1;
+}
+
+//return number of 1 bits in x
+function cbit(x) {
+var r = 0;
+while(x != 0) { x &= x-1; ++r; }
+return r;
+}
+
+//(public) return number of set bits
+function bnBitCount() {
+var r = 0, x = this.s&this.DM;
+for(var i = 0; i < this.t; ++i) r += cbit(this.data[i]^x);
+return r;
+}
+
+//(public) true iff nth bit is set
+function bnTestBit(n) {
+var j = Math.floor(n/this.DB);
+if(j >= this.t) return(this.s!=0);
+return((this.data[j]&(1<<(n%this.DB)))!=0);
+}
+
+//(protected) this op (1<<n)
+function bnpChangeBit(n,op) {
+var r = BigInteger.ONE.shiftLeft(n);
+this.bitwiseTo(r,op,r);
+return r;
+}
+
+//(public) this | (1<<n)
+function bnSetBit(n) { return this.changeBit(n,op_or); }
+
+//(public) this & ~(1<<n)
+function bnClearBit(n) { return this.changeBit(n,op_andnot); }
+
+//(public) this ^ (1<<n)
+function bnFlipBit(n) { return this.changeBit(n,op_xor); }
+
+//(protected) r = this + a
+function bnpAddTo(a,r) {
+var i = 0, c = 0, m = Math.min(a.t,this.t);
+while(i < m) {
+ c += this.data[i]+a.data[i];
+ r.data[i++] = c&this.DM;
+ c >>= this.DB;
+}
+if(a.t < this.t) {
+ c += a.s;
+ while(i < this.t) {
+ c += this.data[i];
+ r.data[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ c += this.s;
+} else {
+ c += this.s;
+ while(i < a.t) {
+ c += a.data[i];
+ r.data[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ c += a.s;
+}
+r.s = (c<0)?-1:0;
+if(c > 0) r.data[i++] = c;
+else if(c < -1) r.data[i++] = this.DV+c;
+r.t = i;
+r.clamp();
+}
+
+//(public) this + a
+function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
+
+//(public) this - a
+function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
+
+//(public) this * a
+function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
+
+//(public) this / a
+function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
+
+//(public) this % a
+function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
+
+//(public) [this/a,this%a]
+function bnDivideAndRemainder(a) {
+var q = nbi(), r = nbi();
+this.divRemTo(a,q,r);
+return new Array(q,r);
+}
+
+//(protected) this *= n, this >= 0, 1 < n < DV
+function bnpDMultiply(n) {
+this.data[this.t] = this.am(0,n-1,this,0,0,this.t);
+++this.t;
+this.clamp();
+}
+
+//(protected) this += n << w words, this >= 0
+function bnpDAddOffset(n,w) {
+if(n == 0) return;
+while(this.t <= w) this.data[this.t++] = 0;
+this.data[w] += n;
+while(this.data[w] >= this.DV) {
+ this.data[w] -= this.DV;
+ if(++w >= this.t) this.data[this.t++] = 0;
+ ++this.data[w];
+}
+}
+
+//A "null" reducer
+function NullExp() {}
+function nNop(x) { return x; }
+function nMulTo(x,y,r) { x.multiplyTo(y,r); }
+function nSqrTo(x,r) { x.squareTo(r); }
+
+NullExp.prototype.convert = nNop;
+NullExp.prototype.revert = nNop;
+NullExp.prototype.mulTo = nMulTo;
+NullExp.prototype.sqrTo = nSqrTo;
+
+//(public) this^e
+function bnPow(e) { return this.exp(e,new NullExp()); }
+
+//(protected) r = lower n words of "this * a", a.t <= n
+//"this" should be the larger one if appropriate.
+function bnpMultiplyLowerTo(a,n,r) {
+var i = Math.min(this.t+a.t,n);
+r.s = 0; // assumes a,this >= 0
+r.t = i;
+while(i > 0) r.data[--i] = 0;
+var j;
+for(j = r.t-this.t; i < j; ++i) r.data[i+this.t] = this.am(0,a.data[i],r,i,0,this.t);
+for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a.data[i],r,i,0,n-i);
+r.clamp();
+}
+
+//(protected) r = "this * a" without lower n words, n > 0
+//"this" should be the larger one if appropriate.
+function bnpMultiplyUpperTo(a,n,r) {
+--n;
+var i = r.t = this.t+a.t-n;
+r.s = 0; // assumes a,this >= 0
+while(--i >= 0) r.data[i] = 0;
+for(i = Math.max(n-this.t,0); i < a.t; ++i)
+ r.data[this.t+i-n] = this.am(n-i,a.data[i],r,0,0,this.t+i-n);
+r.clamp();
+r.drShiftTo(1,r);
+}
+
+//Barrett modular reduction
+function Barrett(m) {
+// setup Barrett
+this.r2 = nbi();
+this.q3 = nbi();
+BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
+this.mu = this.r2.divide(m);
+this.m = m;
+}
+
+function barrettConvert(x) {
+if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
+else if(x.compareTo(this.m) < 0) return x;
+else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
+}
+
+function barrettRevert(x) { return x; }
+
+//x = x mod m (HAC 14.42)
+function barrettReduce(x) {
+x.drShiftTo(this.m.t-1,this.r2);
+if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); }
+this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);
+this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);
+while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1);
+x.subTo(this.r2,x);
+while(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
+}
+
+//r = x^2 mod m; x != r
+function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
+
+//r = x*y mod m; x,y != r
+function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
+
+Barrett.prototype.convert = barrettConvert;
+Barrett.prototype.revert = barrettRevert;
+Barrett.prototype.reduce = barrettReduce;
+Barrett.prototype.mulTo = barrettMulTo;
+Barrett.prototype.sqrTo = barrettSqrTo;
+
+//(public) this^e % m (HAC 14.85)
+function bnModPow(e,m) {
+var i = e.bitLength(), k, r = nbv(1), z;
+if(i <= 0) return r;
+else if(i < 18) k = 1;
+else if(i < 48) k = 3;
+else if(i < 144) k = 4;
+else if(i < 768) k = 5;
+else k = 6;
+if(i < 8)
+ z = new Classic(m);
+else if(m.isEven())
+ z = new Barrett(m);
+else
+ z = new Montgomery(m);
+
+// precomputation
+var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
+g[1] = z.convert(this);
+if(k > 1) {
+ var g2 = nbi();
+ z.sqrTo(g[1],g2);
+ while(n <= km) {
+ g[n] = nbi();
+ z.mulTo(g2,g[n-2],g[n]);
+ n += 2;
+ }
+}
+
+var j = e.t-1, w, is1 = true, r2 = nbi(), t;
+i = nbits(e.data[j])-1;
+while(j >= 0) {
+ if(i >= k1) w = (e.data[j]>>(i-k1))&km;
+ else {
+ w = (e.data[j]&((1<<(i+1))-1))<<(k1-i);
+ if(j > 0) w |= e.data[j-1]>>(this.DB+i-k1);
+ }
+
+ n = k;
+ while((w&1) == 0) { w >>= 1; --n; }
+ if((i -= n) < 0) { i += this.DB; --j; }
+ if(is1) { // ret == 1, don't bother squaring or multiplying it
+ g[w].copyTo(r);
+ is1 = false;
+ } else {
+ while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
+ if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
+ z.mulTo(r2,g[w],r);
+ }
+
+ while(j >= 0 && (e.data[j]&(1<<i)) == 0) {
+ z.sqrTo(r,r2); t = r; r = r2; r2 = t;
+ if(--i < 0) { i = this.DB-1; --j; }
+ }
+}
+return z.revert(r);
+}
+
+//(public) gcd(this,a) (HAC 14.54)
+function bnGCD(a) {
+var x = (this.s<0)?this.negate():this.clone();
+var y = (a.s<0)?a.negate():a.clone();
+if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
+var i = x.getLowestSetBit(), g = y.getLowestSetBit();
+if(g < 0) return x;
+if(i < g) g = i;
+if(g > 0) {
+ x.rShiftTo(g,x);
+ y.rShiftTo(g,y);
+}
+while(x.signum() > 0) {
+ if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
+ if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
+ if(x.compareTo(y) >= 0) {
+ x.subTo(y,x);
+ x.rShiftTo(1,x);
+ } else {
+ y.subTo(x,y);
+ y.rShiftTo(1,y);
+ }
+}
+if(g > 0) y.lShiftTo(g,y);
+return y;
+}
+
+//(protected) this % n, n < 2^26
+function bnpModInt(n) {
+if(n <= 0) return 0;
+var d = this.DV%n, r = (this.s<0)?n-1:0;
+if(this.t > 0)
+ if(d == 0) r = this.data[0]%n;
+ else for(var i = this.t-1; i >= 0; --i) r = (d*r+this.data[i])%n;
+return r;
+}
+
+//(public) 1/this % m (HAC 14.61)
+function bnModInverse(m) {
+var ac = m.isEven();
+if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
+var u = m.clone(), v = this.clone();
+var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
+while(u.signum() != 0) {
+ while(u.isEven()) {
+ u.rShiftTo(1,u);
+ if(ac) {
+ if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
+ a.rShiftTo(1,a);
+ } else if(!b.isEven()) b.subTo(m,b);
+ b.rShiftTo(1,b);
+ }
+ while(v.isEven()) {
+ v.rShiftTo(1,v);
+ if(ac) {
+ if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
+ c.rShiftTo(1,c);
+ } else if(!d.isEven()) d.subTo(m,d);
+ d.rShiftTo(1,d);
+ }
+ if(u.compareTo(v) >= 0) {
+ u.subTo(v,u);
+ if(ac) a.subTo(c,a);
+ b.subTo(d,b);
+ } else {
+ v.subTo(u,v);
+ if(ac) c.subTo(a,c);
+ d.subTo(b,d);
+ }
+}
+if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
+if(d.compareTo(m) >= 0) return d.subtract(m);
+if(d.signum() < 0) d.addTo(m,d); else return d;
+if(d.signum() < 0) return d.add(m); else return d;
+}
+
+var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509];
+var lplim = (1<<26)/lowprimes[lowprimes.length-1];
+
+//(public) test primality with certainty >= 1-.5^t
+function bnIsProbablePrime(t) {
+var i, x = this.abs();
+if(x.t == 1 && x.data[0] <= lowprimes[lowprimes.length-1]) {
+ for(i = 0; i < lowprimes.length; ++i)
+ if(x.data[0] == lowprimes[i]) return true;
+ return false;
+}
+if(x.isEven()) return false;
+i = 1;
+while(i < lowprimes.length) {
+ var m = lowprimes[i], j = i+1;
+ while(j < lowprimes.length && m < lplim) m *= lowprimes[j++];
+ m = x.modInt(m);
+ while(i < j) if(m%lowprimes[i++] == 0) return false;
+}
+return x.millerRabin(t);
+}
+
+//(protected) true if probably prime (HAC 4.24, Miller-Rabin)
+function bnpMillerRabin(t) {
+var n1 = this.subtract(BigInteger.ONE);
+var k = n1.getLowestSetBit();
+if(k <= 0) return false;
+var r = n1.shiftRight(k);
+var prng = bnGetPrng();
+var a;
+for(var i = 0; i < t; ++i) {
+ // select witness 'a' at random from between 1 and n1
+ do {
+ a = new BigInteger(this.bitLength(), prng);
+ }
+ while(a.compareTo(BigInteger.ONE) <= 0 || a.compareTo(n1) >= 0);
+ var y = a.modPow(r,this);
+ if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
+ var j = 1;
+ while(j++ < k && y.compareTo(n1) != 0) {
+ y = y.modPowInt(2,this);
+ if(y.compareTo(BigInteger.ONE) == 0) return false;
+ }
+ if(y.compareTo(n1) != 0) return false;
+ }
+}
+return true;
+}
+
+// get pseudo random number generator
+function bnGetPrng() {
+ // create prng with api that matches BigInteger secure random
+ return {
+ // x is an array to fill with bytes
+ nextBytes: function(x) {
+ for(var i = 0; i < x.length; ++i) {
+ x[i] = Math.floor(Math.random() * 0xFF);
+ }
+ }
+ };
+}
+
+//protected
+BigInteger.prototype.chunkSize = bnpChunkSize;
+BigInteger.prototype.toRadix = bnpToRadix;
+BigInteger.prototype.fromRadix = bnpFromRadix;
+BigInteger.prototype.fromNumber = bnpFromNumber;
+BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
+BigInteger.prototype.changeBit = bnpChangeBit;
+BigInteger.prototype.addTo = bnpAddTo;
+BigInteger.prototype.dMultiply = bnpDMultiply;
+BigInteger.prototype.dAddOffset = bnpDAddOffset;
+BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
+BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
+BigInteger.prototype.modInt = bnpModInt;
+BigInteger.prototype.millerRabin = bnpMillerRabin;
+
+//public
+BigInteger.prototype.clone = bnClone;
+BigInteger.prototype.intValue = bnIntValue;
+BigInteger.prototype.byteValue = bnByteValue;
+BigInteger.prototype.shortValue = bnShortValue;
+BigInteger.prototype.signum = bnSigNum;
+BigInteger.prototype.toByteArray = bnToByteArray;
+BigInteger.prototype.equals = bnEquals;
+BigInteger.prototype.min = bnMin;
+BigInteger.prototype.max = bnMax;
+BigInteger.prototype.and = bnAnd;
+BigInteger.prototype.or = bnOr;
+BigInteger.prototype.xor = bnXor;
+BigInteger.prototype.andNot = bnAndNot;
+BigInteger.prototype.not = bnNot;
+BigInteger.prototype.shiftLeft = bnShiftLeft;
+BigInteger.prototype.shiftRight = bnShiftRight;
+BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
+BigInteger.prototype.bitCount = bnBitCount;
+BigInteger.prototype.testBit = bnTestBit;
+BigInteger.prototype.setBit = bnSetBit;
+BigInteger.prototype.clearBit = bnClearBit;
+BigInteger.prototype.flipBit = bnFlipBit;
+BigInteger.prototype.add = bnAdd;
+BigInteger.prototype.subtract = bnSubtract;
+BigInteger.prototype.multiply = bnMultiply;
+BigInteger.prototype.divide = bnDivide;
+BigInteger.prototype.remainder = bnRemainder;
+BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
+BigInteger.prototype.modPow = bnModPow;
+BigInteger.prototype.modInverse = bnModInverse;
+BigInteger.prototype.pow = bnPow;
+BigInteger.prototype.gcd = bnGCD;
+BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
+
+//BigInteger interfaces not implemented in jsbn:
+
+//BigInteger(int signum, byte[] magnitude)
+//double doubleValue()
+//float floatValue()
+//int hashCode()
+//long longValue()
+//static BigInteger valueOf(long val)
+
+forge.jsbn = forge.jsbn || {};
+forge.jsbn.BigInteger = BigInteger;
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'jsbn';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/kem.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/kem.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/kem.js
new file mode 100644
index 0000000..7ac7851
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/kem.js
@@ -0,0 +1,221 @@
+/**
+ * Javascript implementation of RSA-KEM.
+ *
+ * @author Lautaro Cozzani Rodriguez
+ * @author Dave Longley
+ *
+ * Copyright (c) 2014 Lautaro Cozzani <la...@scytl.com>
+ * Copyright (c) 2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+forge.kem = forge.kem || {};
+
+var BigInteger = forge.jsbn.BigInteger;
+
+/**
+ * The API for the RSA Key Encapsulation Mechanism (RSA-KEM) from ISO 18033-2.
+ */
+forge.kem.rsa = {};
+
+/**
+ * Creates an RSA KEM API object for generating a secret asymmetric key.
+ *
+ * The symmetric key may be generated via a call to 'encrypt', which will
+ * produce a ciphertext to be transmitted to the recipient and a key to be
+ * kept secret. The ciphertext is a parameter to be passed to 'decrypt' which
+ * will produce the same secret key for the recipient to use to decrypt a
+ * message that was encrypted with the secret key.
+ *
+ * @param kdf the KDF API to use (eg: new forge.kem.kdf1()).
+ * @param options the options to use.
+ * [prng] a custom crypto-secure pseudo-random number generator to use,
+ * that must define "getBytesSync".
+ */
+forge.kem.rsa.create = function(kdf, options) {
+ options = options || {};
+ var prng = options.prng || forge.random;
+
+ var kem = {};
+
+ /**
+ * Generates a secret key and its encapsulation.
+ *
+ * @param publicKey the RSA public key to encrypt with.
+ * @param keyLength the length, in bytes, of the secret key to generate.
+ *
+ * @return an object with:
+ * encapsulation: the ciphertext for generating the secret key, as a
+ * binary-encoded string of bytes.
+ * key: the secret key to use for encrypting a message.
+ */
+ kem.encrypt = function(publicKey, keyLength) {
+ // generate a random r where 1 > r > n
+ var byteLength = Math.ceil(publicKey.n.bitLength() / 8);
+ var r;
+ do {
+ r = new BigInteger(
+ forge.util.bytesToHex(prng.getBytesSync(byteLength)),
+ 16).mod(publicKey.n);
+ } while(r.equals(BigInteger.ZERO));
+
+ // prepend r with zeros
+ r = forge.util.hexToBytes(r.toString(16));
+ var zeros = byteLength - r.length;
+ if(zeros > 0) {
+ r = forge.util.fillString(String.fromCharCode(0), zeros) + r;
+ }
+
+ // encrypt the random
+ var encapsulation = publicKey.encrypt(r, 'NONE');
+
+ // generate the secret key
+ var key = kdf.generate(r, keyLength);
+
+ return {encapsulation: encapsulation, key: key};
+ };
+
+ /**
+ * Decrypts an encapsulated secret key.
+ *
+ * @param privateKey the RSA private key to decrypt with.
+ * @param encapsulation the ciphertext for generating the secret key, as
+ * a binary-encoded string of bytes.
+ * @param keyLength the length, in bytes, of the secret key to generate.
+ *
+ * @return the secret key as a binary-encoded string of bytes.
+ */
+ kem.decrypt = function(privateKey, encapsulation, keyLength) {
+ // decrypt the encapsulation and generate the secret key
+ var r = privateKey.decrypt(encapsulation, 'NONE');
+ return kdf.generate(r, keyLength);
+ };
+
+ return kem;
+};
+
+// TODO: add forge.kem.kdf.create('KDF1', {md: ..., ...}) API?
+
+/**
+ * Creates a key derivation API object that implements KDF1 per ISO 18033-2.
+ *
+ * @param md the hash API to use.
+ * @param [digestLength] an optional digest length that must be positive and
+ * less than or equal to md.digestLength.
+ *
+ * @return a KDF1 API object.
+ */
+forge.kem.kdf1 = function(md, digestLength) {
+ _createKDF(this, md, 0, digestLength || md.digestLength);
+};
+
+/**
+ * Creates a key derivation API object that implements KDF2 per ISO 18033-2.
+ *
+ * @param md the hash API to use.
+ * @param [digestLength] an optional digest length that must be positive and
+ * less than or equal to md.digestLength.
+ *
+ * @return a KDF2 API object.
+ */
+forge.kem.kdf2 = function(md, digestLength) {
+ _createKDF(this, md, 1, digestLength || md.digestLength);
+};
+
+/**
+ * Creates a KDF1 or KDF2 API object.
+ *
+ * @param md the hash API to use.
+ * @param counterStart the starting index for the counter.
+ * @param digestLength the digest length to use.
+ *
+ * @return the KDF API object.
+ */
+function _createKDF(kdf, md, counterStart, digestLength) {
+ /**
+ * Generate a key of the specified length.
+ *
+ * @param x the binary-encoded byte string to generate a key from.
+ * @param length the number of bytes to generate (the size of the key).
+ *
+ * @return the key as a binary-encoded string.
+ */
+ kdf.generate = function(x, length) {
+ var key = new forge.util.ByteBuffer();
+
+ // run counter from counterStart to ceil(length / Hash.len)
+ var k = Math.ceil(length / digestLength) + counterStart;
+
+ var c = new forge.util.ByteBuffer();
+ for(var i = counterStart; i < k; ++i) {
+ // I2OSP(i, 4): convert counter to an octet string of 4 octets
+ c.putInt32(i);
+
+ // digest 'x' and the counter and add the result to the key
+ md.start();
+ md.update(x + c.getBytes());
+ var hash = md.digest();
+ key.putBytes(hash.getBytes(digestLength));
+ }
+
+ // truncate to the correct key length
+ key.truncate(key.length() - length);
+ return key.getBytes();
+ };
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'kem';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util','./random','./jsbn'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[50/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/.release.json
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/.release.json b/node_modules/es6-promise/.release.json
new file mode 100644
index 0000000..dee8cbc
--- /dev/null
+++ b/node_modules/es6-promise/.release.json
@@ -0,0 +1,17 @@
+{
+ "non-interactive": true,
+ "dry-run": false,
+ "verbose": false,
+ "force": false,
+ "pkgFiles": ["package.json", "bower.json"],
+ "increment": "patch",
+ "commitMessage": "Release %s",
+ "tagName": "%s",
+ "tagAnnotation": "Release %s",
+ "buildCommand": "npm run-script build-all",
+ "distRepo": "git@github.com:components/rsvp.js.git",
+ "distStageDir": "tmp/stage",
+ "distBase": "dist",
+ "distFiles": ["**/*", "../package.json", "../bower.json"],
+ "publish": false
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/Brocfile.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/Brocfile.js b/node_modules/es6-promise/Brocfile.js
new file mode 100644
index 0000000..d34f458
--- /dev/null
+++ b/node_modules/es6-promise/Brocfile.js
@@ -0,0 +1,75 @@
+/* jshint node:true, undef:true, unused:true */
+var AMDFormatter = require('es6-module-transpiler-amd-formatter');
+var closureCompiler = require('broccoli-closure-compiler');
+var compileModules = require('broccoli-compile-modules');
+var mergeTrees = require('broccoli-merge-trees');
+var moveFile = require('broccoli-file-mover');
+var es3Recast = require('broccoli-es3-safe-recast');
+var concat = require('broccoli-concat');
+var replace = require('broccoli-string-replace');
+var calculateVersion = require('./lib/calculateVersion');
+var path = require('path');
+var trees = [];
+var env = process.env.EMBER_ENV || 'development';
+
+var bundle = compileModules('lib', {
+ inputFiles: ['es6-promise.umd.js'],
+ output: '/es6-promise.js',
+ formatter: 'bundle',
+});
+
+trees.push(bundle);
+trees.push(compileModules('lib', {
+ inputFiles: ['**/*.js'],
+ output: '/amd/',
+ formatter: new AMDFormatter()
+}));
+
+if (env === 'production') {
+ trees.push(closureCompiler(moveFile(bundle, {
+ srcFile: 'es6-promise.js',
+ destFile: 'es6-promise.min.js'
+ }), {
+ compilation_level: 'ADVANCED_OPTIMIZATIONS',
+ externs: ['node'],
+ }));
+}
+
+var distTree = mergeTrees(trees.concat('config'));
+var distTrees = [];
+
+distTrees.push(concat(distTree, {
+ inputFiles: [
+ 'versionTemplate.txt',
+ 'es6-promise.js'
+ ],
+ outputFile: '/es6-promise.js'
+}));
+
+if (env === 'production') {
+ distTrees.push(concat(distTree, {
+ inputFiles: [
+ 'versionTemplate.txt',
+ 'es6-promise.min.js'
+ ],
+ outputFile: '/es6-promise.min.js'
+ }));
+}
+
+if (env !== 'development') {
+ distTrees = distTrees.map(es3Recast);
+}
+
+distTree = mergeTrees(distTrees);
+var distTree = replace(distTree, {
+ files: [
+ 'es6-promise.js',
+ 'es6-promise.min.js'
+ ],
+ pattern: {
+ match: /VERSION_PLACEHOLDER_STRING/g,
+ replacement: calculateVersion()
+ }
+});
+
+module.exports = distTree;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/CHANGELOG.md b/node_modules/es6-promise/CHANGELOG.md
new file mode 100644
index 0000000..e06b496
--- /dev/null
+++ b/node_modules/es6-promise/CHANGELOG.md
@@ -0,0 +1,9 @@
+# Master
+
+# 2.0.0
+
+* re-sync with RSVP. Many large performance improvements and bugfixes.
+
+# 1.0.0
+
+* first subset of RSVP
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/LICENSE b/node_modules/es6-promise/LICENSE
new file mode 100644
index 0000000..954ec59
--- /dev/null
+++ b/node_modules/es6-promise/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/README.md
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/README.md b/node_modules/es6-promise/README.md
new file mode 100644
index 0000000..b974ce4
--- /dev/null
+++ b/node_modules/es6-promise/README.md
@@ -0,0 +1,58 @@
+# ES6-Promise (subset of [rsvp.js](https://github.com/tildeio/rsvp.js))
+
+This is a polyfill of the [ES6 Promise](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-constructor). The implementation is a subset of [rsvp.js](https://github.com/tildeio/rsvp.js), if you're wanting extra features and more debugging options, check out the [full library](https://github.com/tildeio/rsvp.js).
+
+For API details and how to use promises, see the <a href="http://www.html5rocks.com/en/tutorials/es6/promises/">JavaScript Promises HTML5Rocks article</a>.
+
+## Downloads
+
+* [es6-promise](https://es6-promises.s3.amazonaws.com/es6-promise-2.0.1.js)
+* [es6-promise-min](https://es6-promises.s3.amazonaws.com/es6-promise-2.0.1.min.js) (~2.2k gzipped)
+
+## Node.js
+
+To install:
+
+```sh
+npm install es6-promise
+```
+
+To use:
+
+```js
+var Promise = require('es6-promise').Promise;
+```
+
+## Usage in IE<9
+
+`catch` is a reserved word in IE<9, meaning `promise.catch(func)` throws a syntax error. To work around this, you can use a string to access the property as shown in the following example.
+
+However, please remember that such technique is already provided by most common minifiers, making the resulting code safe for old browsers and production:
+
+```js
+promise['catch'](function(err) {
+ // ...
+});
+```
+
+Or use `.then` instead:
+
+```js
+promise.then(undefined, function(err) {
+ // ...
+});
+```
+
+## Auto-polyfill
+
+To polyfill the global environment (either in Node or in the browser via CommonJS) use the following code snippet:
+
+```js
+require('es6-promise').polyfill();
+```
+
+Notice that we don't assign the result of `polyfill()` to any variable. The `polyfill()` method will patch the global environment (in this case to the `Promise` name) when called.
+
+## Building & Testing
+
+* `npm run build-all && npm test` - Run Mocha tests through Node and PhantomJS.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/bin/publish_to_s3.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/bin/publish_to_s3.js b/node_modules/es6-promise/bin/publish_to_s3.js
new file mode 100755
index 0000000..7daf49a
--- /dev/null
+++ b/node_modules/es6-promise/bin/publish_to_s3.js
@@ -0,0 +1,28 @@
+#!/usr/bin/env node
+
+// To invoke this from the commandline you need the following to env vars to exist:
+//
+// S3_BUCKET_NAME
+// TRAVIS_BRANCH
+// TRAVIS_TAG
+// TRAVIS_COMMIT
+// S3_SECRET_ACCESS_KEY
+// S3_ACCESS_KEY_ID
+//
+// Once you have those you execute with the following:
+//
+// ```sh
+// ./bin/publish_to_s3.js
+// ```
+var S3Publisher = require('ember-publisher');
+var configPath = require('path').join(__dirname, '../config/s3ProjectConfig.js');
+publisher = new S3Publisher({ projectConfigPath: configPath });
+
+// Always use wildcard section of project config.
+// This is useful when the including library does not
+// require channels (like in ember.js / ember-data).
+publisher.currentBranch = function() {
+ return (process.env.TRAVIS_BRANCH === 'master') ? 'wildcard' : 'no-op';
+};
+publisher.publish();
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/bower.json
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/bower.json b/node_modules/es6-promise/bower.json
new file mode 100644
index 0000000..84ec5ad
--- /dev/null
+++ b/node_modules/es6-promise/bower.json
@@ -0,0 +1,29 @@
+{
+ "name": "es6-promise",
+ "namespace": "Promise",
+ "version": "2.0.1",
+ "description": "A polyfill for ES6-style Promises, tracking rsvp",
+ "authors": [
+ "Stefan Penner <st...@gmail.com>"
+ ],
+ "main": "dist/es6-promise.js",
+ "keywords": [
+ "promise"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jakearchibald/ES6-Promises.git"
+ },
+ "bugs": {
+ "url": "https://github.com/jakearchibald/ES6-Promises/issues"
+ },
+ "license": "MIT",
+ "ignore": [
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests",
+ "vendor",
+ "tasks"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/config/s3ProjectConfig.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/config/s3ProjectConfig.js b/node_modules/es6-promise/config/s3ProjectConfig.js
new file mode 100644
index 0000000..5f3349a
--- /dev/null
+++ b/node_modules/es6-promise/config/s3ProjectConfig.js
@@ -0,0 +1,26 @@
+/*
+ * Using wildcard because es6-promise does not currently have a
+ * channel system in place.
+ */
+module.exports = function(revision,tag,date){
+ return {
+ 'es6-promise.js':
+ { contentType: 'text/javascript',
+ destinations: {
+ wildcard: [
+ 'es6-promise-latest.js',
+ 'es6-promise-' + revision + '.js'
+ ]
+ }
+ },
+ 'es6-promise.min.js':
+ { contentType: 'text/javascript',
+ destinations: {
+ wildcard: [
+ 'es6-promise-latest.min.js',
+ 'es6-promise-' + revision + '.min.js'
+ ]
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/config/versionTemplate.txt
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/config/versionTemplate.txt b/node_modules/es6-promise/config/versionTemplate.txt
new file mode 100644
index 0000000..999a5fc
--- /dev/null
+++ b/node_modules/es6-promise/config/versionTemplate.txt
@@ -0,0 +1,7 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version VERSION_PLACEHOLDER_STRING
+ */
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/dist/es6-promise.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/dist/es6-promise.js b/node_modules/es6-promise/dist/es6-promise.js
new file mode 100644
index 0000000..30a6d81
--- /dev/null
+++ b/node_modules/es6-promise/dist/es6-promise.js
@@ -0,0 +1,960 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version 2.0.1
+ */
+
+(function() {
+ "use strict";
+
+ function $$utils$$objectOrFunction(x) {
+ return typeof x === 'function' || (typeof x === 'object' && x !== null);
+ }
+
+ function $$utils$$isFunction(x) {
+ return typeof x === 'function';
+ }
+
+ function $$utils$$isMaybeThenable(x) {
+ return typeof x === 'object' && x !== null;
+ }
+
+ var $$utils$$_isArray;
+
+ if (!Array.isArray) {
+ $$utils$$_isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+ } else {
+ $$utils$$_isArray = Array.isArray;
+ }
+
+ var $$utils$$isArray = $$utils$$_isArray;
+ var $$utils$$now = Date.now || function() { return new Date().getTime(); };
+ function $$utils$$F() { }
+
+ var $$utils$$o_create = (Object.create || function (o) {
+ if (arguments.length > 1) {
+ throw new Error('Second argument not supported');
+ }
+ if (typeof o !== 'object') {
+ throw new TypeError('Argument must be an object');
+ }
+ $$utils$$F.prototype = o;
+ return new $$utils$$F();
+ });
+
+ var $$asap$$len = 0;
+
+ var $$asap$$default = function asap(callback, arg) {
+ $$asap$$queue[$$asap$$len] = callback;
+ $$asap$$queue[$$asap$$len + 1] = arg;
+ $$asap$$len += 2;
+ if ($$asap$$len === 2) {
+ // If len is 1, that means that we need to schedule an async flush.
+ // If additional callbacks are queued before the queue is flushed, they
+ // will be processed by this flush that we are scheduling.
+ $$asap$$scheduleFlush();
+ }
+ };
+
+ var $$asap$$browserGlobal = (typeof window !== 'undefined') ? window : {};
+ var $$asap$$BrowserMutationObserver = $$asap$$browserGlobal.MutationObserver || $$asap$$browserGlobal.WebKitMutationObserver;
+
+ // test for web worker but not in IE10
+ var $$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
+ typeof importScripts !== 'undefined' &&
+ typeof MessageChannel !== 'undefined';
+
+ // node
+ function $$asap$$useNextTick() {
+ return function() {
+ process.nextTick($$asap$$flush);
+ };
+ }
+
+ function $$asap$$useMutationObserver() {
+ var iterations = 0;
+ var observer = new $$asap$$BrowserMutationObserver($$asap$$flush);
+ var node = document.createTextNode('');
+ observer.observe(node, { characterData: true });
+
+ return function() {
+ node.data = (iterations = ++iterations % 2);
+ };
+ }
+
+ // web worker
+ function $$asap$$useMessageChannel() {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = $$asap$$flush;
+ return function () {
+ channel.port2.postMessage(0);
+ };
+ }
+
+ function $$asap$$useSetTimeout() {
+ return function() {
+ setTimeout($$asap$$flush, 1);
+ };
+ }
+
+ var $$asap$$queue = new Array(1000);
+
+ function $$asap$$flush() {
+ for (var i = 0; i < $$asap$$len; i+=2) {
+ var callback = $$asap$$queue[i];
+ var arg = $$asap$$queue[i+1];
+
+ callback(arg);
+
+ $$asap$$queue[i] = undefined;
+ $$asap$$queue[i+1] = undefined;
+ }
+
+ $$asap$$len = 0;
+ }
+
+ var $$asap$$scheduleFlush;
+
+ // Decide what async method to use to triggering processing of queued callbacks:
+ if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
+ $$asap$$scheduleFlush = $$asap$$useNextTick();
+ } else if ($$asap$$BrowserMutationObserver) {
+ $$asap$$scheduleFlush = $$asap$$useMutationObserver();
+ } else if ($$asap$$isWorker) {
+ $$asap$$scheduleFlush = $$asap$$useMessageChannel();
+ } else {
+ $$asap$$scheduleFlush = $$asap$$useSetTimeout();
+ }
+
+ function $$$internal$$noop() {}
+ var $$$internal$$PENDING = void 0;
+ var $$$internal$$FULFILLED = 1;
+ var $$$internal$$REJECTED = 2;
+ var $$$internal$$GET_THEN_ERROR = new $$$internal$$ErrorObject();
+
+ function $$$internal$$selfFullfillment() {
+ return new TypeError("You cannot resolve a promise with itself");
+ }
+
+ function $$$internal$$cannotReturnOwn() {
+ return new TypeError('A promises callback cannot return that same promise.')
+ }
+
+ function $$$internal$$getThen(promise) {
+ try {
+ return promise.then;
+ } catch(error) {
+ $$$internal$$GET_THEN_ERROR.error = error;
+ return $$$internal$$GET_THEN_ERROR;
+ }
+ }
+
+ function $$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
+ try {
+ then.call(value, fulfillmentHandler, rejectionHandler);
+ } catch(e) {
+ return e;
+ }
+ }
+
+ function $$$internal$$handleForeignThenable(promise, thenable, then) {
+ $$asap$$default(function(promise) {
+ var sealed = false;
+ var error = $$$internal$$tryThen(then, thenable, function(value) {
+ if (sealed) { return; }
+ sealed = true;
+ if (thenable !== value) {
+ $$$internal$$resolve(promise, value);
+ } else {
+ $$$internal$$fulfill(promise, value);
+ }
+ }, function(reason) {
+ if (sealed) { return; }
+ sealed = true;
+
+ $$$internal$$reject(promise, reason);
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
+
+ if (!sealed && error) {
+ sealed = true;
+ $$$internal$$reject(promise, error);
+ }
+ }, promise);
+ }
+
+ function $$$internal$$handleOwnThenable(promise, thenable) {
+ if (thenable._state === $$$internal$$FULFILLED) {
+ $$$internal$$fulfill(promise, thenable._result);
+ } else if (promise._state === $$$internal$$REJECTED) {
+ $$$internal$$reject(promise, thenable._result);
+ } else {
+ $$$internal$$subscribe(thenable, undefined, function(value) {
+ $$$internal$$resolve(promise, value);
+ }, function(reason) {
+ $$$internal$$reject(promise, reason);
+ });
+ }
+ }
+
+ function $$$internal$$handleMaybeThenable(promise, maybeThenable) {
+ if (maybeThenable.constructor === promise.constructor) {
+ $$$internal$$handleOwnThenable(promise, maybeThenable);
+ } else {
+ var then = $$$internal$$getThen(maybeThenable);
+
+ if (then === $$$internal$$GET_THEN_ERROR) {
+ $$$internal$$reject(promise, $$$internal$$GET_THEN_ERROR.error);
+ } else if (then === undefined) {
+ $$$internal$$fulfill(promise, maybeThenable);
+ } else if ($$utils$$isFunction(then)) {
+ $$$internal$$handleForeignThenable(promise, maybeThenable, then);
+ } else {
+ $$$internal$$fulfill(promise, maybeThenable);
+ }
+ }
+ }
+
+ function $$$internal$$resolve(promise, value) {
+ if (promise === value) {
+ $$$internal$$reject(promise, $$$internal$$selfFullfillment());
+ } else if ($$utils$$objectOrFunction(value)) {
+ $$$internal$$handleMaybeThenable(promise, value);
+ } else {
+ $$$internal$$fulfill(promise, value);
+ }
+ }
+
+ function $$$internal$$publishRejection(promise) {
+ if (promise._onerror) {
+ promise._onerror(promise._result);
+ }
+
+ $$$internal$$publish(promise);
+ }
+
+ function $$$internal$$fulfill(promise, value) {
+ if (promise._state !== $$$internal$$PENDING) { return; }
+
+ promise._result = value;
+ promise._state = $$$internal$$FULFILLED;
+
+ if (promise._subscribers.length === 0) {
+ } else {
+ $$asap$$default($$$internal$$publish, promise);
+ }
+ }
+
+ function $$$internal$$reject(promise, reason) {
+ if (promise._state !== $$$internal$$PENDING) { return; }
+ promise._state = $$$internal$$REJECTED;
+ promise._result = reason;
+
+ $$asap$$default($$$internal$$publishRejection, promise);
+ }
+
+ function $$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
+
+ parent._onerror = null;
+
+ subscribers[length] = child;
+ subscribers[length + $$$internal$$FULFILLED] = onFulfillment;
+ subscribers[length + $$$internal$$REJECTED] = onRejection;
+
+ if (length === 0 && parent._state) {
+ $$asap$$default($$$internal$$publish, parent);
+ }
+ }
+
+ function $$$internal$$publish(promise) {
+ var subscribers = promise._subscribers;
+ var settled = promise._state;
+
+ if (subscribers.length === 0) { return; }
+
+ var child, callback, detail = promise._result;
+
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
+
+ if (child) {
+ $$$internal$$invokeCallback(settled, child, callback, detail);
+ } else {
+ callback(detail);
+ }
+ }
+
+ promise._subscribers.length = 0;
+ }
+
+ function $$$internal$$ErrorObject() {
+ this.error = null;
+ }
+
+ var $$$internal$$TRY_CATCH_ERROR = new $$$internal$$ErrorObject();
+
+ function $$$internal$$tryCatch(callback, detail) {
+ try {
+ return callback(detail);
+ } catch(e) {
+ $$$internal$$TRY_CATCH_ERROR.error = e;
+ return $$$internal$$TRY_CATCH_ERROR;
+ }
+ }
+
+ function $$$internal$$invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = $$utils$$isFunction(callback),
+ value, error, succeeded, failed;
+
+ if (hasCallback) {
+ value = $$$internal$$tryCatch(callback, detail);
+
+ if (value === $$$internal$$TRY_CATCH_ERROR) {
+ failed = true;
+ error = value.error;
+ value = null;
+ } else {
+ succeeded = true;
+ }
+
+ if (promise === value) {
+ $$$internal$$reject(promise, $$$internal$$cannotReturnOwn());
+ return;
+ }
+
+ } else {
+ value = detail;
+ succeeded = true;
+ }
+
+ if (promise._state !== $$$internal$$PENDING) {
+ // noop
+ } else if (hasCallback && succeeded) {
+ $$$internal$$resolve(promise, value);
+ } else if (failed) {
+ $$$internal$$reject(promise, error);
+ } else if (settled === $$$internal$$FULFILLED) {
+ $$$internal$$fulfill(promise, value);
+ } else if (settled === $$$internal$$REJECTED) {
+ $$$internal$$reject(promise, value);
+ }
+ }
+
+ function $$$internal$$initializePromise(promise, resolver) {
+ try {
+ resolver(function resolvePromise(value){
+ $$$internal$$resolve(promise, value);
+ }, function rejectPromise(reason) {
+ $$$internal$$reject(promise, reason);
+ });
+ } catch(e) {
+ $$$internal$$reject(promise, e);
+ }
+ }
+
+ function $$$enumerator$$makeSettledResult(state, position, value) {
+ if (state === $$$internal$$FULFILLED) {
+ return {
+ state: 'fulfilled',
+ value: value
+ };
+ } else {
+ return {
+ state: 'rejected',
+ reason: value
+ };
+ }
+ }
+
+ function $$$enumerator$$Enumerator(Constructor, input, abortOnReject, label) {
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor($$$internal$$noop, label);
+ this._abortOnReject = abortOnReject;
+
+ if (this._validateInput(input)) {
+ this._input = input;
+ this.length = input.length;
+ this._remaining = input.length;
+
+ this._init();
+
+ if (this.length === 0) {
+ $$$internal$$fulfill(this.promise, this._result);
+ } else {
+ this.length = this.length || 0;
+ this._enumerate();
+ if (this._remaining === 0) {
+ $$$internal$$fulfill(this.promise, this._result);
+ }
+ }
+ } else {
+ $$$internal$$reject(this.promise, this._validationError());
+ }
+ }
+
+ $$$enumerator$$Enumerator.prototype._validateInput = function(input) {
+ return $$utils$$isArray(input);
+ };
+
+ $$$enumerator$$Enumerator.prototype._validationError = function() {
+ return new Error('Array Methods must be provided an Array');
+ };
+
+ $$$enumerator$$Enumerator.prototype._init = function() {
+ this._result = new Array(this.length);
+ };
+
+ var $$$enumerator$$default = $$$enumerator$$Enumerator;
+
+ $$$enumerator$$Enumerator.prototype._enumerate = function() {
+ var length = this.length;
+ var promise = this.promise;
+ var input = this._input;
+
+ for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) {
+ this._eachEntry(input[i], i);
+ }
+ };
+
+ $$$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
+ var c = this._instanceConstructor;
+ if ($$utils$$isMaybeThenable(entry)) {
+ if (entry.constructor === c && entry._state !== $$$internal$$PENDING) {
+ entry._onerror = null;
+ this._settledAt(entry._state, i, entry._result);
+ } else {
+ this._willSettleAt(c.resolve(entry), i);
+ }
+ } else {
+ this._remaining--;
+ this._result[i] = this._makeResult($$$internal$$FULFILLED, i, entry);
+ }
+ };
+
+ $$$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
+ var promise = this.promise;
+
+ if (promise._state === $$$internal$$PENDING) {
+ this._remaining--;
+
+ if (this._abortOnReject && state === $$$internal$$REJECTED) {
+ $$$internal$$reject(promise, value);
+ } else {
+ this._result[i] = this._makeResult(state, i, value);
+ }
+ }
+
+ if (this._remaining === 0) {
+ $$$internal$$fulfill(promise, this._result);
+ }
+ };
+
+ $$$enumerator$$Enumerator.prototype._makeResult = function(state, i, value) {
+ return value;
+ };
+
+ $$$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
+ var enumerator = this;
+
+ $$$internal$$subscribe(promise, undefined, function(value) {
+ enumerator._settledAt($$$internal$$FULFILLED, i, value);
+ }, function(reason) {
+ enumerator._settledAt($$$internal$$REJECTED, i, reason);
+ });
+ };
+
+ var $$promise$all$$default = function all(entries, label) {
+ return new $$$enumerator$$default(this, entries, true /* abort on reject */, label).promise;
+ };
+
+ var $$promise$race$$default = function race(entries, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ var promise = new Constructor($$$internal$$noop, label);
+
+ if (!$$utils$$isArray(entries)) {
+ $$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
+ return promise;
+ }
+
+ var length = entries.length;
+
+ function onFulfillment(value) {
+ $$$internal$$resolve(promise, value);
+ }
+
+ function onRejection(reason) {
+ $$$internal$$reject(promise, reason);
+ }
+
+ for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) {
+ $$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
+ }
+
+ return promise;
+ };
+
+ var $$promise$resolve$$default = function resolve(object, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
+
+ var promise = new Constructor($$$internal$$noop, label);
+ $$$internal$$resolve(promise, object);
+ return promise;
+ };
+
+ var $$promise$reject$$default = function reject(reason, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor($$$internal$$noop, label);
+ $$$internal$$reject(promise, reason);
+ return promise;
+ };
+
+ var $$es6$promise$promise$$counter = 0;
+
+ function $$es6$promise$promise$$needsResolver() {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+ }
+
+ function $$es6$promise$promise$$needsNew() {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
+ }
+
+ var $$es6$promise$promise$$default = $$es6$promise$promise$$Promise;
+
+ /**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise’s eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable.
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ }
+ }
+ };
+ });
+ }
+
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class Promise
+ @param {function} resolver
+ Useful for tooling.
+ @constructor
+ */
+ function $$es6$promise$promise$$Promise(resolver) {
+ this._id = $$es6$promise$promise$$counter++;
+ this._state = undefined;
+ this._result = undefined;
+ this._subscribers = [];
+
+ if ($$$internal$$noop !== resolver) {
+ if (!$$utils$$isFunction(resolver)) {
+ $$es6$promise$promise$$needsResolver();
+ }
+
+ if (!(this instanceof $$es6$promise$promise$$Promise)) {
+ $$es6$promise$promise$$needsNew();
+ }
+
+ $$$internal$$initializePromise(this, resolver);
+ }
+ }
+
+ $$es6$promise$promise$$Promise.all = $$promise$all$$default;
+ $$es6$promise$promise$$Promise.race = $$promise$race$$default;
+ $$es6$promise$promise$$Promise.resolve = $$promise$resolve$$default;
+ $$es6$promise$promise$$Promise.reject = $$promise$reject$$default;
+
+ $$es6$promise$promise$$Promise.prototype = {
+ constructor: $$es6$promise$promise$$Promise,
+
+ /**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, 'downstream'
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return 'default name';
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `'default name'`
+ });
+
+ findUser().then(function (user) {
+ throw new Error('Found user, but still unhappy');
+ }, function (reason) {
+ throw new Error('`findUser` rejected and we're unhappy');
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException('Upstream error');
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var result;
+
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+ }
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfilled
+ @param {Function} onRejected
+ Useful for tooling.
+ @return {Promise}
+ */
+ then: function(onFulfillment, onRejection) {
+ var parent = this;
+ var state = parent._state;
+
+ if (state === $$$internal$$FULFILLED && !onFulfillment || state === $$$internal$$REJECTED && !onRejection) {
+ return this;
+ }
+
+ var child = new this.constructor($$$internal$$noop);
+ var result = parent._result;
+
+ if (state) {
+ var callback = arguments[state - 1];
+ $$asap$$default(function(){
+ $$$internal$$invokeCallback(state, child, callback, result);
+ });
+ } else {
+ $$$internal$$subscribe(parent, child, onFulfillment, onRejection);
+ }
+
+ return child;
+ },
+
+ /**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error('couldn't find that author');
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ Useful for tooling.
+ @return {Promise}
+ */
+ 'catch': function(onRejection) {
+ return this.then(null, onRejection);
+ }
+ };
+
+ var $$es6$promise$polyfill$$default = function polyfill() {
+ var local;
+
+ if (typeof global !== 'undefined') {
+ local = global;
+ } else if (typeof window !== 'undefined' && window.document) {
+ local = window;
+ } else {
+ local = self;
+ }
+
+ var es6PromiseSupport =
+ "Promise" in local &&
+ // Some of these methods are missing from
+ // Firefox/Chrome experimental implementations
+ "resolve" in local.Promise &&
+ "reject" in local.Promise &&
+ "all" in local.Promise &&
+ "race" in local.Promise &&
+ // Older version of the spec had a resolver object
+ // as the arg rather than a function
+ (function() {
+ var resolve;
+ new local.Promise(function(r) { resolve = r; });
+ return $$utils$$isFunction(resolve);
+ }());
+
+ if (!es6PromiseSupport) {
+ local.Promise = $$es6$promise$promise$$default;
+ }
+ };
+
+ var es6$promise$umd$$ES6Promise = {
+ 'Promise': $$es6$promise$promise$$default,
+ 'polyfill': $$es6$promise$polyfill$$default
+ };
+
+ /* global define:true module:true window: true */
+ if (typeof define === 'function' && define['amd']) {
+ define(function() { return es6$promise$umd$$ES6Promise; });
+ } else if (typeof module !== 'undefined' && module['exports']) {
+ module['exports'] = es6$promise$umd$$ES6Promise;
+ } else if (typeof this !== 'undefined') {
+ this['ES6Promise'] = es6$promise$umd$$ES6Promise;
+ }
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/dist/es6-promise.min.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/dist/es6-promise.min.js b/node_modules/es6-promise/dist/es6-promise.min.js
new file mode 100644
index 0000000..6e0c99f
--- /dev/null
+++ b/node_modules/es6-promise/dist/es6-promise.min.js
@@ -0,0 +1,18 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version 2.0.1
+ */
+
+(function(){function r(a,b){n[l]=a;n[l+1]=b;l+=2;2===l&&A()}function s(a){return"function"===typeof a}function F(){return function(){process.nextTick(t)}}function G(){var a=0,b=new B(t),c=document.createTextNode("");b.observe(c,{characterData:!0});return function(){c.data=a=++a%2}}function H(){var a=new MessageChannel;a.port1.onmessage=t;return function(){a.port2.postMessage(0)}}function I(){return function(){setTimeout(t,1)}}function t(){for(var a=0;a<l;a+=2)(0,n[a])(n[a+1]),n[a]=void 0,n[a+1]=void 0;
+l=0}function p(){}function J(a,b,c,d){try{a.call(b,c,d)}catch(e){return e}}function K(a,b,c){r(function(a){var e=!1,f=J(c,b,function(c){e||(e=!0,b!==c?q(a,c):m(a,c))},function(b){e||(e=!0,g(a,b))});!e&&f&&(e=!0,g(a,f))},a)}function L(a,b){1===b.a?m(a,b.b):2===a.a?g(a,b.b):u(b,void 0,function(b){q(a,b)},function(b){g(a,b)})}function q(a,b){if(a===b)g(a,new TypeError("You cannot resolve a promise with itself"));else if("function"===typeof b||"object"===typeof b&&null!==b)if(b.constructor===a.constructor)L(a,
+b);else{var c;try{c=b.then}catch(d){v.error=d,c=v}c===v?g(a,v.error):void 0===c?m(a,b):s(c)?K(a,b,c):m(a,b)}else m(a,b)}function M(a){a.f&&a.f(a.b);x(a)}function m(a,b){void 0===a.a&&(a.b=b,a.a=1,0!==a.e.length&&r(x,a))}function g(a,b){void 0===a.a&&(a.a=2,a.b=b,r(M,a))}function u(a,b,c,d){var e=a.e,f=e.length;a.f=null;e[f]=b;e[f+1]=c;e[f+2]=d;0===f&&a.a&&r(x,a)}function x(a){var b=a.e,c=a.a;if(0!==b.length){for(var d,e,f=a.b,g=0;g<b.length;g+=3)d=b[g],e=b[g+c],d?C(c,d,e,f):e(f);a.e.length=0}}function D(){this.error=
+null}function C(a,b,c,d){var e=s(c),f,k,h,l;if(e){try{f=c(d)}catch(n){y.error=n,f=y}f===y?(l=!0,k=f.error,f=null):h=!0;if(b===f){g(b,new TypeError("A promises callback cannot return that same promise."));return}}else f=d,h=!0;void 0===b.a&&(e&&h?q(b,f):l?g(b,k):1===a?m(b,f):2===a&&g(b,f))}function N(a,b){try{b(function(b){q(a,b)},function(b){g(a,b)})}catch(c){g(a,c)}}function k(a,b,c,d){this.n=a;this.c=new a(p,d);this.i=c;this.o(b)?(this.m=b,this.d=this.length=b.length,this.l(),0===this.length?m(this.c,
+this.b):(this.length=this.length||0,this.k(),0===this.d&&m(this.c,this.b))):g(this.c,this.p())}function h(a){O++;this.b=this.a=void 0;this.e=[];if(p!==a){if(!s(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof h))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");N(this,a)}}var E=Array.isArray?Array.isArray:function(a){return"[object Array]"===
+Object.prototype.toString.call(a)},l=0,w="undefined"!==typeof window?window:{},B=w.MutationObserver||w.WebKitMutationObserver,w="undefined"!==typeof Uint8ClampedArray&&"undefined"!==typeof importScripts&&"undefined"!==typeof MessageChannel,n=Array(1E3),A;A="undefined"!==typeof process&&"[object process]"==={}.toString.call(process)?F():B?G():w?H():I();var v=new D,y=new D;k.prototype.o=function(a){return E(a)};k.prototype.p=function(){return Error("Array Methods must be provided an Array")};k.prototype.l=
+function(){this.b=Array(this.length)};k.prototype.k=function(){for(var a=this.length,b=this.c,c=this.m,d=0;void 0===b.a&&d<a;d++)this.j(c[d],d)};k.prototype.j=function(a,b){var c=this.n;"object"===typeof a&&null!==a?a.constructor===c&&void 0!==a.a?(a.f=null,this.g(a.a,b,a.b)):this.q(c.resolve(a),b):(this.d--,this.b[b]=this.h(a))};k.prototype.g=function(a,b,c){var d=this.c;void 0===d.a&&(this.d--,this.i&&2===a?g(d,c):this.b[b]=this.h(c));0===this.d&&m(d,this.b)};k.prototype.h=function(a){return a};
+k.prototype.q=function(a,b){var c=this;u(a,void 0,function(a){c.g(1,b,a)},function(a){c.g(2,b,a)})};var O=0;h.all=function(a,b){return(new k(this,a,!0,b)).c};h.race=function(a,b){function c(a){q(e,a)}function d(a){g(e,a)}var e=new this(p,b);if(!E(a))return (g(e,new TypeError("You must pass an array to race.")), e);for(var f=a.length,h=0;void 0===e.a&&h<f;h++)u(this.resolve(a[h]),void 0,c,d);return e};h.resolve=function(a,b){if(a&&"object"===typeof a&&a.constructor===this)return a;var c=new this(p,b);
+q(c,a);return c};h.reject=function(a,b){var c=new this(p,b);g(c,a);return c};h.prototype={constructor:h,then:function(a,b){var c=this.a;if(1===c&&!a||2===c&&!b)return this;var d=new this.constructor(p),e=this.b;if(c){var f=arguments[c-1];r(function(){C(c,d,f,e)})}else u(this,d,a,b);return d},"catch":function(a){return this.then(null,a)}};var z={Promise:h,polyfill:function(){var a;a="undefined"!==typeof global?global:"undefined"!==typeof window&&window.document?window:self;"Promise"in a&&"resolve"in
+a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;new a.Promise(function(a){b=a});return s(b)}()||(a.Promise=h)}};"function"===typeof define&&define.amd?define(function(){return z}):"undefined"!==typeof module&&module.exports?module.exports=z:"undefined"!==typeof this&&(this.ES6Promise=z)}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/calculateVersion.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/calculateVersion.js b/node_modules/es6-promise/lib/calculateVersion.js
new file mode 100644
index 0000000..018e364
--- /dev/null
+++ b/node_modules/es6-promise/lib/calculateVersion.js
@@ -0,0 +1,36 @@
+'use strict';
+
+var fs = require('fs');
+var path = require('path');
+
+module.exports = function () {
+ var packageVersion = require('../package.json').version;
+ var output = [packageVersion];
+ var gitPath = path.join(__dirname,'..','.git');
+ var headFilePath = path.join(gitPath, 'HEAD');
+
+ if (packageVersion.indexOf('+') > -1) {
+ try {
+ if (fs.existsSync(headFilePath)) {
+ var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'});
+ var branchName = headFile.split('/').slice(-1)[0].trim();
+ var refPath = headFile.split(' ')[1];
+ var branchSHA;
+
+ if (refPath) {
+ var branchPath = path.join(gitPath, refPath.trim());
+ branchSHA = fs.readFileSync(branchPath);
+ } else {
+ branchSHA = branchName;
+ }
+
+ output.push(branchSHA.slice(0,10));
+ }
+ } catch (err) {
+ console.error(err.stack);
+ }
+ return output.join('.');
+ } else {
+ return packageVersion;
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise.umd.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise.umd.js b/node_modules/es6-promise/lib/es6-promise.umd.js
new file mode 100644
index 0000000..cd01553
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise.umd.js
@@ -0,0 +1,16 @@
+import Promise from './es6-promise/promise';
+import polyfill from './es6-promise/polyfill';
+
+var ES6Promise = {
+ 'Promise': Promise,
+ 'polyfill': polyfill
+};
+
+/* global define:true module:true window: true */
+if (typeof define === 'function' && define['amd']) {
+ define(function() { return ES6Promise; });
+} else if (typeof module !== 'undefined' && module['exports']) {
+ module['exports'] = ES6Promise;
+} else if (typeof this !== 'undefined') {
+ this['ES6Promise'] = ES6Promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/-internal.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/-internal.js b/node_modules/es6-promise/lib/es6-promise/-internal.js
new file mode 100644
index 0000000..afef22e
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/-internal.js
@@ -0,0 +1,251 @@
+import {
+ objectOrFunction,
+ isFunction
+} from './utils';
+
+import asap from './asap';
+
+function noop() {}
+
+var PENDING = void 0;
+var FULFILLED = 1;
+var REJECTED = 2;
+
+var GET_THEN_ERROR = new ErrorObject();
+
+function selfFullfillment() {
+ return new TypeError("You cannot resolve a promise with itself");
+}
+
+function cannotReturnOwn() {
+ return new TypeError('A promises callback cannot return that same promise.')
+}
+
+function getThen(promise) {
+ try {
+ return promise.then;
+ } catch(error) {
+ GET_THEN_ERROR.error = error;
+ return GET_THEN_ERROR;
+ }
+}
+
+function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
+ try {
+ then.call(value, fulfillmentHandler, rejectionHandler);
+ } catch(e) {
+ return e;
+ }
+}
+
+function handleForeignThenable(promise, thenable, then) {
+ asap(function(promise) {
+ var sealed = false;
+ var error = tryThen(then, thenable, function(value) {
+ if (sealed) { return; }
+ sealed = true;
+ if (thenable !== value) {
+ resolve(promise, value);
+ } else {
+ fulfill(promise, value);
+ }
+ }, function(reason) {
+ if (sealed) { return; }
+ sealed = true;
+
+ reject(promise, reason);
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
+
+ if (!sealed && error) {
+ sealed = true;
+ reject(promise, error);
+ }
+ }, promise);
+}
+
+function handleOwnThenable(promise, thenable) {
+ if (thenable._state === FULFILLED) {
+ fulfill(promise, thenable._result);
+ } else if (promise._state === REJECTED) {
+ reject(promise, thenable._result);
+ } else {
+ subscribe(thenable, undefined, function(value) {
+ resolve(promise, value);
+ }, function(reason) {
+ reject(promise, reason);
+ });
+ }
+}
+
+function handleMaybeThenable(promise, maybeThenable) {
+ if (maybeThenable.constructor === promise.constructor) {
+ handleOwnThenable(promise, maybeThenable);
+ } else {
+ var then = getThen(maybeThenable);
+
+ if (then === GET_THEN_ERROR) {
+ reject(promise, GET_THEN_ERROR.error);
+ } else if (then === undefined) {
+ fulfill(promise, maybeThenable);
+ } else if (isFunction(then)) {
+ handleForeignThenable(promise, maybeThenable, then);
+ } else {
+ fulfill(promise, maybeThenable);
+ }
+ }
+}
+
+function resolve(promise, value) {
+ if (promise === value) {
+ reject(promise, selfFullfillment());
+ } else if (objectOrFunction(value)) {
+ handleMaybeThenable(promise, value);
+ } else {
+ fulfill(promise, value);
+ }
+}
+
+function publishRejection(promise) {
+ if (promise._onerror) {
+ promise._onerror(promise._result);
+ }
+
+ publish(promise);
+}
+
+function fulfill(promise, value) {
+ if (promise._state !== PENDING) { return; }
+
+ promise._result = value;
+ promise._state = FULFILLED;
+
+ if (promise._subscribers.length === 0) {
+ } else {
+ asap(publish, promise);
+ }
+}
+
+function reject(promise, reason) {
+ if (promise._state !== PENDING) { return; }
+ promise._state = REJECTED;
+ promise._result = reason;
+
+ asap(publishRejection, promise);
+}
+
+function subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
+
+ parent._onerror = null;
+
+ subscribers[length] = child;
+ subscribers[length + FULFILLED] = onFulfillment;
+ subscribers[length + REJECTED] = onRejection;
+
+ if (length === 0 && parent._state) {
+ asap(publish, parent);
+ }
+}
+
+function publish(promise) {
+ var subscribers = promise._subscribers;
+ var settled = promise._state;
+
+ if (subscribers.length === 0) { return; }
+
+ var child, callback, detail = promise._result;
+
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
+
+ if (child) {
+ invokeCallback(settled, child, callback, detail);
+ } else {
+ callback(detail);
+ }
+ }
+
+ promise._subscribers.length = 0;
+}
+
+function ErrorObject() {
+ this.error = null;
+}
+
+var TRY_CATCH_ERROR = new ErrorObject();
+
+function tryCatch(callback, detail) {
+ try {
+ return callback(detail);
+ } catch(e) {
+ TRY_CATCH_ERROR.error = e;
+ return TRY_CATCH_ERROR;
+ }
+}
+
+function invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = isFunction(callback),
+ value, error, succeeded, failed;
+
+ if (hasCallback) {
+ value = tryCatch(callback, detail);
+
+ if (value === TRY_CATCH_ERROR) {
+ failed = true;
+ error = value.error;
+ value = null;
+ } else {
+ succeeded = true;
+ }
+
+ if (promise === value) {
+ reject(promise, cannotReturnOwn());
+ return;
+ }
+
+ } else {
+ value = detail;
+ succeeded = true;
+ }
+
+ if (promise._state !== PENDING) {
+ // noop
+ } else if (hasCallback && succeeded) {
+ resolve(promise, value);
+ } else if (failed) {
+ reject(promise, error);
+ } else if (settled === FULFILLED) {
+ fulfill(promise, value);
+ } else if (settled === REJECTED) {
+ reject(promise, value);
+ }
+}
+
+function initializePromise(promise, resolver) {
+ try {
+ resolver(function resolvePromise(value){
+ resolve(promise, value);
+ }, function rejectPromise(reason) {
+ reject(promise, reason);
+ });
+ } catch(e) {
+ reject(promise, e);
+ }
+}
+
+export {
+ noop,
+ resolve,
+ reject,
+ fulfill,
+ subscribe,
+ publish,
+ publishRejection,
+ initializePromise,
+ invokeCallback,
+ FULFILLED,
+ REJECTED,
+ PENDING
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/asap.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/asap.js b/node_modules/es6-promise/lib/es6-promise/asap.js
new file mode 100644
index 0000000..4872589
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/asap.js
@@ -0,0 +1,82 @@
+var len = 0;
+
+export default function asap(callback, arg) {
+ queue[len] = callback;
+ queue[len + 1] = arg;
+ len += 2;
+ if (len === 2) {
+ // If len is 1, that means that we need to schedule an async flush.
+ // If additional callbacks are queued before the queue is flushed, they
+ // will be processed by this flush that we are scheduling.
+ scheduleFlush();
+ }
+}
+
+var browserGlobal = (typeof window !== 'undefined') ? window : {};
+var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
+
+// test for web worker but not in IE10
+var isWorker = typeof Uint8ClampedArray !== 'undefined' &&
+ typeof importScripts !== 'undefined' &&
+ typeof MessageChannel !== 'undefined';
+
+// node
+function useNextTick() {
+ return function() {
+ process.nextTick(flush);
+ };
+}
+
+function useMutationObserver() {
+ var iterations = 0;
+ var observer = new BrowserMutationObserver(flush);
+ var node = document.createTextNode('');
+ observer.observe(node, { characterData: true });
+
+ return function() {
+ node.data = (iterations = ++iterations % 2);
+ };
+}
+
+// web worker
+function useMessageChannel() {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = flush;
+ return function () {
+ channel.port2.postMessage(0);
+ };
+}
+
+function useSetTimeout() {
+ return function() {
+ setTimeout(flush, 1);
+ };
+}
+
+var queue = new Array(1000);
+function flush() {
+ for (var i = 0; i < len; i+=2) {
+ var callback = queue[i];
+ var arg = queue[i+1];
+
+ callback(arg);
+
+ queue[i] = undefined;
+ queue[i+1] = undefined;
+ }
+
+ len = 0;
+}
+
+var scheduleFlush;
+
+// Decide what async method to use to triggering processing of queued callbacks:
+if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
+ scheduleFlush = useNextTick();
+} else if (BrowserMutationObserver) {
+ scheduleFlush = useMutationObserver();
+} else if (isWorker) {
+ scheduleFlush = useMessageChannel();
+} else {
+ scheduleFlush = useSetTimeout();
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/enumerator.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/enumerator.js b/node_modules/es6-promise/lib/es6-promise/enumerator.js
new file mode 100644
index 0000000..7d3f803
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/enumerator.js
@@ -0,0 +1,125 @@
+import {
+ isArray,
+ isMaybeThenable
+} from './utils';
+
+import {
+ noop,
+ reject,
+ fulfill,
+ subscribe,
+ FULFILLED,
+ REJECTED,
+ PENDING
+} from './-internal';
+
+export function makeSettledResult(state, position, value) {
+ if (state === FULFILLED) {
+ return {
+ state: 'fulfilled',
+ value: value
+ };
+ } else {
+ return {
+ state: 'rejected',
+ reason: value
+ };
+ }
+}
+
+function Enumerator(Constructor, input, abortOnReject, label) {
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor(noop, label);
+ this._abortOnReject = abortOnReject;
+
+ if (this._validateInput(input)) {
+ this._input = input;
+ this.length = input.length;
+ this._remaining = input.length;
+
+ this._init();
+
+ if (this.length === 0) {
+ fulfill(this.promise, this._result);
+ } else {
+ this.length = this.length || 0;
+ this._enumerate();
+ if (this._remaining === 0) {
+ fulfill(this.promise, this._result);
+ }
+ }
+ } else {
+ reject(this.promise, this._validationError());
+ }
+}
+
+Enumerator.prototype._validateInput = function(input) {
+ return isArray(input);
+};
+
+Enumerator.prototype._validationError = function() {
+ return new Error('Array Methods must be provided an Array');
+};
+
+Enumerator.prototype._init = function() {
+ this._result = new Array(this.length);
+};
+
+export default Enumerator;
+
+Enumerator.prototype._enumerate = function() {
+ var length = this.length;
+ var promise = this.promise;
+ var input = this._input;
+
+ for (var i = 0; promise._state === PENDING && i < length; i++) {
+ this._eachEntry(input[i], i);
+ }
+};
+
+Enumerator.prototype._eachEntry = function(entry, i) {
+ var c = this._instanceConstructor;
+ if (isMaybeThenable(entry)) {
+ if (entry.constructor === c && entry._state !== PENDING) {
+ entry._onerror = null;
+ this._settledAt(entry._state, i, entry._result);
+ } else {
+ this._willSettleAt(c.resolve(entry), i);
+ }
+ } else {
+ this._remaining--;
+ this._result[i] = this._makeResult(FULFILLED, i, entry);
+ }
+};
+
+Enumerator.prototype._settledAt = function(state, i, value) {
+ var promise = this.promise;
+
+ if (promise._state === PENDING) {
+ this._remaining--;
+
+ if (this._abortOnReject && state === REJECTED) {
+ reject(promise, value);
+ } else {
+ this._result[i] = this._makeResult(state, i, value);
+ }
+ }
+
+ if (this._remaining === 0) {
+ fulfill(promise, this._result);
+ }
+};
+
+Enumerator.prototype._makeResult = function(state, i, value) {
+ return value;
+};
+
+Enumerator.prototype._willSettleAt = function(promise, i) {
+ var enumerator = this;
+
+ subscribe(promise, undefined, function(value) {
+ enumerator._settledAt(FULFILLED, i, value);
+ }, function(reason) {
+ enumerator._settledAt(REJECTED, i, reason);
+ });
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/polyfill.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/polyfill.js b/node_modules/es6-promise/lib/es6-promise/polyfill.js
new file mode 100644
index 0000000..e5b0165
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/polyfill.js
@@ -0,0 +1,35 @@
+/*global self*/
+import { default as RSVPPromise } from "./promise";
+import { isFunction } from "./utils";
+
+export default function polyfill() {
+ var local;
+
+ if (typeof global !== 'undefined') {
+ local = global;
+ } else if (typeof window !== 'undefined' && window.document) {
+ local = window;
+ } else {
+ local = self;
+ }
+
+ var es6PromiseSupport =
+ "Promise" in local &&
+ // Some of these methods are missing from
+ // Firefox/Chrome experimental implementations
+ "resolve" in local.Promise &&
+ "reject" in local.Promise &&
+ "all" in local.Promise &&
+ "race" in local.Promise &&
+ // Older version of the spec had a resolver object
+ // as the arg rather than a function
+ (function() {
+ var resolve;
+ new local.Promise(function(r) { resolve = r; });
+ return isFunction(resolve);
+ }());
+
+ if (!es6PromiseSupport) {
+ local.Promise = RSVPPromise;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/promise.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/promise.js b/node_modules/es6-promise/lib/es6-promise/promise.js
new file mode 100644
index 0000000..5e865a7
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/promise.js
@@ -0,0 +1,409 @@
+import {
+ isFunction,
+ now
+} from './utils';
+
+import {
+ noop,
+ subscribe,
+ initializePromise,
+ invokeCallback,
+ FULFILLED,
+ REJECTED
+} from './-internal';
+
+import asap from './asap';
+
+import all from './promise/all';
+import race from './promise/race';
+import Resolve from './promise/resolve';
+import Reject from './promise/reject';
+
+var counter = 0;
+
+function needsResolver() {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+}
+
+function needsNew() {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
+}
+
+export default Promise;
+/**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise’s eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable.
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ }
+ }
+ };
+ });
+ }
+
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class Promise
+ @param {function} resolver
+ Useful for tooling.
+ @constructor
+*/
+function Promise(resolver) {
+ this._id = counter++;
+ this._state = undefined;
+ this._result = undefined;
+ this._subscribers = [];
+
+ if (noop !== resolver) {
+ if (!isFunction(resolver)) {
+ needsResolver();
+ }
+
+ if (!(this instanceof Promise)) {
+ needsNew();
+ }
+
+ initializePromise(this, resolver);
+ }
+}
+
+Promise.all = all;
+Promise.race = race;
+Promise.resolve = Resolve;
+Promise.reject = Reject;
+
+Promise.prototype = {
+ constructor: Promise,
+
+/**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, 'downstream'
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return 'default name';
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `'default name'`
+ });
+
+ findUser().then(function (user) {
+ throw new Error('Found user, but still unhappy');
+ }, function (reason) {
+ throw new Error('`findUser` rejected and we're unhappy');
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException('Upstream error');
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var result;
+
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+ }
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfilled
+ @param {Function} onRejected
+ Useful for tooling.
+ @return {Promise}
+*/
+ then: function(onFulfillment, onRejection) {
+ var parent = this;
+ var state = parent._state;
+
+ if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) {
+ return this;
+ }
+
+ var child = new this.constructor(noop);
+ var result = parent._result;
+
+ if (state) {
+ var callback = arguments[state - 1];
+ asap(function(){
+ invokeCallback(state, child, callback, result);
+ });
+ } else {
+ subscribe(parent, child, onFulfillment, onRejection);
+ }
+
+ return child;
+ },
+
+/**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error('couldn't find that author');
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ Useful for tooling.
+ @return {Promise}
+*/
+ 'catch': function(onRejection) {
+ return this.then(null, onRejection);
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/promise/all.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/promise/all.js b/node_modules/es6-promise/lib/es6-promise/promise/all.js
new file mode 100644
index 0000000..8db7e71
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/promise/all.js
@@ -0,0 +1,52 @@
+import Enumerator from '../enumerator';
+
+/**
+ `Promise.all` accepts an array of promises, and returns a new promise which
+ is fulfilled with an array of fulfillment values for the passed promises, or
+ rejected with the reason of the first passed promise to be rejected. It casts all
+ elements of the passed iterable to promises as it runs this algorithm.
+
+ Example:
+
+ ```javascript
+ var promise1 = resolve(1);
+ var promise2 = resolve(2);
+ var promise3 = resolve(3);
+ var promises = [ promise1, promise2, promise3 ];
+
+ Promise.all(promises).then(function(array){
+ // The array here would be [ 1, 2, 3 ];
+ });
+ ```
+
+ If any of the `promises` given to `all` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promises's
+ rejection handler. For example:
+
+ Example:
+
+ ```javascript
+ var promise1 = resolve(1);
+ var promise2 = reject(new Error("2"));
+ var promise3 = reject(new Error("3"));
+ var promises = [ promise1, promise2, promise3 ];
+
+ Promise.all(promises).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(error) {
+ // error.message === "2"
+ });
+ ```
+
+ @method all
+ @static
+ @param {Array} entries array of promises
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled when all `promises` have been
+ fulfilled, or rejected if any of them become rejected.
+ @static
+*/
+export default function all(entries, label) {
+ return new Enumerator(this, entries, true /* abort on reject */, label).promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/promise/race.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/promise/race.js b/node_modules/es6-promise/lib/es6-promise/promise/race.js
new file mode 100644
index 0000000..7daa28a
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/promise/race.js
@@ -0,0 +1,105 @@
+import {
+ isArray
+} from "../utils";
+
+import {
+ noop,
+ resolve,
+ reject,
+ subscribe,
+ PENDING
+} from '../-internal';
+
+/**
+ `Promise.race` returns a new promise which is settled in the same way as the
+ first passed promise to settle.
+
+ Example:
+
+ ```javascript
+ var promise1 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 2');
+ }, 100);
+ });
+
+ Promise.race([promise1, promise2]).then(function(result){
+ // result === 'promise 2' because it was resolved before promise1
+ // was resolved.
+ });
+ ```
+
+ `Promise.race` is deterministic in that only the state of the first
+ settled promise matters. For example, even if other promises given to the
+ `promises` array argument are resolved, but the first settled promise has
+ become rejected before the other promises became fulfilled, the returned
+ promise will become rejected:
+
+ ```javascript
+ var promise1 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ reject(new Error('promise 2'));
+ }, 100);
+ });
+
+ Promise.race([promise1, promise2]).then(function(result){
+ // Code here never runs
+ }, function(reason){
+ // reason.message === 'promise 2' because promise 2 became rejected before
+ // promise 1 became fulfilled
+ });
+ ```
+
+ An example real-world use case is implementing timeouts:
+
+ ```javascript
+ Promise.race([ajax('foo.json'), timeout(5000)])
+ ```
+
+ @method race
+ @static
+ @param {Array} promises array of promises to observe
+ @param {String} label optional string for describing the promise returned.
+ Useful for tooling.
+ @return {Promise} a promise which settles in the same way as the first passed
+ promise to settle.
+*/
+export default function race(entries, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ var promise = new Constructor(noop, label);
+
+ if (!isArray(entries)) {
+ reject(promise, new TypeError('You must pass an array to race.'));
+ return promise;
+ }
+
+ var length = entries.length;
+
+ function onFulfillment(value) {
+ resolve(promise, value);
+ }
+
+ function onRejection(reason) {
+ reject(promise, reason);
+ }
+
+ for (var i = 0; promise._state === PENDING && i < length; i++) {
+ subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
+ }
+
+ return promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/promise/reject.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/promise/reject.js b/node_modules/es6-promise/lib/es6-promise/promise/reject.js
new file mode 100644
index 0000000..518eff7
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/promise/reject.js
@@ -0,0 +1,47 @@
+import {
+ noop,
+ reject as _reject
+} from '../-internal';
+
+/**
+ `Promise.reject` returns a promise rejected with the passed `reason`.
+ It is shorthand for the following:
+
+ ```javascript
+ var promise = new Promise(function(resolve, reject){
+ reject(new Error('WHOOPS'));
+ });
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = Promise.reject(new Error('WHOOPS'));
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ @method reject
+ @static
+ @param {Any} reason value that the returned promise will be rejected with.
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise rejected with the given `reason`.
+*/
+export default function reject(reason, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor(noop, label);
+ _reject(promise, reason);
+ return promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/promise/resolve.js b/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
new file mode 100644
index 0000000..1b3c533
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
@@ -0,0 +1,49 @@
+import {
+ noop,
+ resolve as _resolve
+} from '../-internal';
+
+/**
+ `Promise.resolve` returns a promise that will become resolved with the
+ passed `value`. It is shorthand for the following:
+
+ ```javascript
+ var promise = new Promise(function(resolve, reject){
+ resolve(1);
+ });
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = Promise.resolve(1);
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ @method resolve
+ @static
+ @param {Any} value value that the returned promise will be resolved with
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise that will become fulfilled with the given
+ `value`
+*/
+export default function resolve(object, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
+
+ var promise = new Constructor(noop, label);
+ _resolve(promise, object);
+ return promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/lib/es6-promise/utils.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/lib/es6-promise/utils.js b/node_modules/es6-promise/lib/es6-promise/utils.js
new file mode 100644
index 0000000..6b49bbf
--- /dev/null
+++ b/node_modules/es6-promise/lib/es6-promise/utils.js
@@ -0,0 +1,39 @@
+export function objectOrFunction(x) {
+ return typeof x === 'function' || (typeof x === 'object' && x !== null);
+}
+
+export function isFunction(x) {
+ return typeof x === 'function';
+}
+
+export function isMaybeThenable(x) {
+ return typeof x === 'object' && x !== null;
+}
+
+var _isArray;
+if (!Array.isArray) {
+ _isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+} else {
+ _isArray = Array.isArray;
+}
+
+export var isArray = _isArray;
+
+// Date.now is not available in browsers < IE9
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
+export var now = Date.now || function() { return new Date().getTime(); };
+
+function F() { }
+
+export var o_create = (Object.create || function (o) {
+ if (arguments.length > 1) {
+ throw new Error('Second argument not supported');
+ }
+ if (typeof o !== 'object') {
+ throw new TypeError('Argument must be an object');
+ }
+ F.prototype = o;
+ return new F();
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/package.json
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/package.json b/node_modules/es6-promise/package.json
new file mode 100644
index 0000000..fabdc88
--- /dev/null
+++ b/node_modules/es6-promise/package.json
@@ -0,0 +1,81 @@
+{
+ "name": "es6-promise",
+ "namespace": "es6-promise",
+ "version": "2.0.1",
+ "description": "A lightweight library that provides tools for organizing asynchronous code",
+ "main": "dist/es6-promise.js",
+ "directories": {
+ "lib": "lib"
+ },
+ "devDependencies": {
+ "bower": "^1.3.9",
+ "brfs": "0.0.8",
+ "broccoli-closure-compiler": "^0.2.0",
+ "broccoli-compile-modules": "git+https://github.com/eventualbuddha/broccoli-compile-modules",
+ "broccoli-concat": "0.0.7",
+ "broccoli-es3-safe-recast": "0.0.8",
+ "broccoli-file-mover": "^0.4.0",
+ "broccoli-jshint": "^0.5.1",
+ "broccoli-merge-trees": "^0.1.4",
+ "broccoli-static-compiler": "^0.1.4",
+ "broccoli-string-replace": "0.0.1",
+ "browserify": "^4.2.0",
+ "ember-cli": "0.0.40",
+ "ember-publisher": "0.0.7",
+ "es6-module-transpiler-amd-formatter": "0.0.1",
+ "express": "^4.5.0",
+ "jshint": "~0.9.1",
+ "mkdirp": "^0.5.0",
+ "mocha": "^1.20.1",
+ "promises-aplus-tests": "git://github.com/stefanpenner/promises-tests.git",
+ "release-it": "0.0.10",
+ "testem": "^0.6.17",
+ "json3": "^3.3.2"
+ },
+ "scripts": {
+ "test": "testem ci -R dot",
+ "test-server": "testem",
+ "lint": "jshint lib",
+ "prepublish": "ember build --environment production",
+ "aplus": "browserify test/main.js",
+ "build-all": "ember build --environment production && browserify ./test/main.js -o tmp/test-bundle.js",
+ "dry-run-release": "ember build --environment production && release-it --dry-run --non-interactive"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jakearchibald/ES6-Promises.git"
+ },
+ "bugs": {
+ "url": "https://github.com/jakearchibald/ES6-Promises/issues"
+ },
+ "keywords": [
+ "promises",
+ "futures"
+ ],
+ "author": {
+ "name": "Yehuda Katz, Tom Dale, Stefan Penner and contributors",
+ "url": "Conversion to ES6 API by Jake Archibald"
+ },
+ "license": "MIT",
+ "homepage": "https://github.com/jakearchibald/ES6-Promises",
+ "_id": "es6-promise@2.0.1",
+ "dist": {
+ "shasum": "ccc4963e679f0ca9fb187c777b9e583d3c7573c2",
+ "tarball": "http://registry.npmjs.org/es6-promise/-/es6-promise-2.0.1.tgz"
+ },
+ "_from": "es6-promise@",
+ "_npmVersion": "1.3.24",
+ "_npmUser": {
+ "name": "jaffathecake",
+ "email": "jaffathecake@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "jaffathecake",
+ "email": "jaffathecake@gmail.com"
+ }
+ ],
+ "_shasum": "ccc4963e679f0ca9fb187c777b9e583d3c7573c2",
+ "_resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-2.0.1.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/server/.jshintrc
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/server/.jshintrc b/node_modules/es6-promise/server/.jshintrc
new file mode 100644
index 0000000..c1f2978
--- /dev/null
+++ b/node_modules/es6-promise/server/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "node": true
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/server/index.js
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/server/index.js b/node_modules/es6-promise/server/index.js
new file mode 100644
index 0000000..8a54d36
--- /dev/null
+++ b/node_modules/es6-promise/server/index.js
@@ -0,0 +1,6 @@
+module.exports = function(app) {
+ app.use(require('express').static(__dirname + '/../'));
+ app.get('/', function(req, res) {
+ res.redirect('/test/');
+ })
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/es6-promise/testem.json
----------------------------------------------------------------------
diff --git a/node_modules/es6-promise/testem.json b/node_modules/es6-promise/testem.json
new file mode 100644
index 0000000..7494912
--- /dev/null
+++ b/node_modules/es6-promise/testem.json
@@ -0,0 +1,11 @@
+{
+ "test_page": "test/index.html",
+ "parallel": 5,
+ "before_tests": "npm run build-all",
+ "launchers": {
+ "Mocha": {
+ "command": "./node_modules/.bin/mocha test/main.js"
+ }
+ },
+ "launch_in_ci": ["PhantomJS", "Mocha"]
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/.npmignore b/node_modules/node-firefox-connect/.npmignore
new file mode 100644
index 0000000..b0e3907
--- /dev/null
+++ b/node_modules/node-firefox-connect/.npmignore
@@ -0,0 +1,3 @@
+node_modules
+npm-debug.log
+.DS_Store
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/LICENSE b/node_modules/node-firefox-connect/LICENSE
new file mode 100644
index 0000000..23564e2
--- /dev/null
+++ b/node_modules/node-firefox-connect/LICENSE
@@ -0,0 +1,10 @@
+Copyright 2014-2015 Mozilla
+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.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[40/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.js
new file mode 100644
index 0000000..50059b7
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.js
@@ -0,0 +1,522 @@
+/*! Copyright (c) 2011, Lloyd Hilaiel, ISC License */
+/*
+ * This is the JSONSelect reference implementation, in javascript.
+ */
+(function(exports) {
+
+ var // localize references
+ toString = Object.prototype.toString;
+
+ function jsonParse(str) {
+ try {
+ if(JSON && JSON.parse){
+ return JSON.parse(str);
+ }
+ return (new Function("return " + str))();
+ } catch(e) {
+ te("ijs");
+ }
+ }
+
+ // emitted error codes.
+ var errorCodes = {
+ "bop": "binary operator expected",
+ "ee": "expression expected",
+ "epex": "closing paren expected ')'",
+ "ijs": "invalid json string",
+ "mcp": "missing closing paren",
+ "mepf": "malformed expression in pseudo-function",
+ "mexp": "multiple expressions not allowed",
+ "mpc": "multiple pseudo classes (:xxx) not allowed",
+ "nmi": "multiple ids not allowed",
+ "pex": "opening paren expected '('",
+ "se": "selector expected",
+ "sex": "string expected",
+ "sra": "string required after '.'",
+ "uc": "unrecognized char",
+ "ucp": "unexpected closing paren",
+ "ujs": "unclosed json string",
+ "upc": "unrecognized pseudo class"
+ };
+
+ // throw an error message
+ function te(ec) {
+ throw new Error(errorCodes[ec]);
+ }
+
+ // THE LEXER
+ var toks = {
+ psc: 1, // pseudo class
+ psf: 2, // pseudo class function
+ typ: 3, // type
+ str: 4, // string
+ ide: 5 // identifiers (or "classes", stuff after a dot)
+ };
+
+ // The primary lexing regular expression in jsonselect
+ var pat = new RegExp(
+ "^(?:" +
+ // (1) whitespace
+ "([\\r\\n\\t\\ ]+)|" +
+ // (2) one-char ops
+ "([~*,>\\)\\(])|" +
+ // (3) types names
+ "(string|boolean|null|array|object|number)|" +
+ // (4) pseudo classes
+ "(:(?:root|first-child|last-child|only-child))|" +
+ // (5) pseudo functions
+ "(:(?:nth-child|nth-last-child|has|expr|val|contains))|" +
+ // (6) bogusly named pseudo something or others
+ "(:\\w+)|" +
+ // (7 & 8) identifiers and JSON strings
+ "(?:(\\.)?(\\\"(?:[^\\\\]|\\\\[^\\\"])*\\\"))|" +
+ // (8) bogus JSON strings missing a trailing quote
+ "(\\\")|" +
+ // (9) identifiers (unquoted)
+ "\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*)" +
+ ")"
+ );
+
+ // A regular expression for matching "nth expressions" (see grammar, what :nth-child() eats)
+ var nthPat = /^\s*\(\s*(?:([+\-]?)([0-9]*)n\s*(?:([+\-])\s*([0-9]))?|(odd|even)|([+\-]?[0-9]+))\s*\)/;
+ function lex(str, off) {
+ if (!off) off = 0;
+ var m = pat.exec(str.substr(off));
+ if (!m) return undefined;
+ off+=m[0].length;
+ var a;
+ if (m[1]) a = [off, " "];
+ else if (m[2]) a = [off, m[0]];
+ else if (m[3]) a = [off, toks.typ, m[0]];
+ else if (m[4]) a = [off, toks.psc, m[0]];
+ else if (m[5]) a = [off, toks.psf, m[0]];
+ else if (m[6]) te("upc");
+ else if (m[8]) a = [off, m[7] ? toks.ide : toks.str, jsonParse(m[8])];
+ else if (m[9]) te("ujs");
+ else if (m[10]) a = [off, toks.ide, m[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")];
+ return a;
+ }
+
+ // THE EXPRESSION SUBSYSTEM
+
+ var exprPat = new RegExp(
+ // skip and don't capture leading whitespace
+ "^\\s*(?:" +
+ // (1) simple vals
+ "(true|false|null)|" +
+ // (2) numbers
+ "(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|" +
+ // (3) strings
+ "(\"(?:[^\\]|\\[^\"])*\")|" +
+ // (4) the 'x' value placeholder
+ "(x)|" +
+ // (5) binops
+ "(&&|\\|\\||[\\$\\^<>!\\*]=|[=+\\-*/%<>])|" +
+ // (6) parens
+ "([\\(\\)])" +
+ ")"
+ );
+
+ function is(o, t) { return typeof o === t; }
+ var operators = {
+ '*': [ 9, function(lhs, rhs) { return lhs * rhs; } ],
+ '/': [ 9, function(lhs, rhs) { return lhs / rhs; } ],
+ '%': [ 9, function(lhs, rhs) { return lhs % rhs; } ],
+ '+': [ 7, function(lhs, rhs) { return lhs + rhs; } ],
+ '-': [ 7, function(lhs, rhs) { return lhs - rhs; } ],
+ '<=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs <= rhs; } ],
+ '>=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs >= rhs; } ],
+ '$=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.lastIndexOf(rhs) === lhs.length - rhs.length; } ],
+ '^=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) === 0; } ],
+ '*=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) !== -1; } ],
+ '>': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs > rhs; } ],
+ '<': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs < rhs; } ],
+ '=': [ 3, function(lhs, rhs) { return lhs === rhs; } ],
+ '!=': [ 3, function(lhs, rhs) { return lhs !== rhs; } ],
+ '&&': [ 2, function(lhs, rhs) { return lhs && rhs; } ],
+ '||': [ 1, function(lhs, rhs) { return lhs || rhs; } ]
+ };
+
+ function exprLex(str, off) {
+ var v, m = exprPat.exec(str.substr(off));
+ if (m) {
+ off += m[0].length;
+ v = m[1] || m[2] || m[3] || m[5] || m[6];
+ if (m[1] || m[2] || m[3]) return [off, 0, jsonParse(v)];
+ else if (m[4]) return [off, 0, undefined];
+ return [off, v];
+ }
+ }
+
+ function exprParse2(str, off) {
+ if (!off) off = 0;
+ // first we expect a value or a '('
+ var l = exprLex(str, off),
+ lhs;
+ if (l && l[1] === '(') {
+ lhs = exprParse2(str, l[0]);
+ var p = exprLex(str, lhs[0]);
+ if (!p || p[1] !== ')') te('epex');
+ off = p[0];
+ lhs = [ '(', lhs[1] ];
+ } else if (!l || (l[1] && l[1] != 'x')) {
+ te("ee");
+ } else {
+ lhs = ((l[1] === 'x') ? undefined : l[2]);
+ off = l[0];
+ }
+
+ // now we expect a binary operator or a ')'
+ var op = exprLex(str, off);
+ if (!op || op[1] == ')') return [off, lhs];
+ else if (op[1] == 'x' || !op[1]) {
+ te('bop');
+ }
+
+ // tail recursion to fetch the rhs expression
+ var rhs = exprParse2(str, op[0]);
+ off = rhs[0];
+ rhs = rhs[1];
+
+ // and now precedence! how shall we put everything together?
+ var v;
+ if (typeof rhs !== 'object' || rhs[0] === '(' || operators[op[1]][0] < operators[rhs[1]][0] ) {
+ v = [lhs, op[1], rhs];
+ }
+ else {
+ v = rhs;
+ while (typeof rhs[0] === 'object' && rhs[0][0] != '(' && operators[op[1]][0] >= operators[rhs[0][1]][0]) {
+ rhs = rhs[0];
+ }
+ rhs[0] = [lhs, op[1], rhs[0]];
+ }
+ return [off, v];
+ }
+
+ function exprParse(str, off) {
+ function deparen(v) {
+ if (typeof v !== 'object' || v === null) return v;
+ else if (v[0] === '(') return deparen(v[1]);
+ else return [deparen(v[0]), v[1], deparen(v[2])];
+ }
+ var e = exprParse2(str, off ? off : 0);
+ return [e[0], deparen(e[1])];
+ }
+
+ function exprEval(expr, x) {
+ if (expr === undefined) return x;
+ else if (expr === null || typeof expr !== 'object') {
+ return expr;
+ }
+ var lhs = exprEval(expr[0], x),
+ rhs = exprEval(expr[2], x);
+ return operators[expr[1]][1](lhs, rhs);
+ }
+
+ // THE PARSER
+
+ function parse(str, off, nested, hints) {
+ if (!nested) hints = {};
+
+ var a = [], am, readParen;
+ if (!off) off = 0;
+
+ while (true) {
+ var s = parse_selector(str, off, hints);
+ a.push(s[1]);
+ s = lex(str, off = s[0]);
+ if (s && s[1] === " ") s = lex(str, off = s[0]);
+ if (!s) break;
+ // now we've parsed a selector, and have something else...
+ if (s[1] === ">" || s[1] === "~") {
+ if (s[1] === "~") hints.usesSiblingOp = true;
+ a.push(s[1]);
+ off = s[0];
+ } else if (s[1] === ",") {
+ if (am === undefined) am = [ ",", a ];
+ else am.push(a);
+ a = [];
+ off = s[0];
+ } else if (s[1] === ")") {
+ if (!nested) te("ucp");
+ readParen = 1;
+ off = s[0];
+ break;
+ }
+ }
+ if (nested && !readParen) te("mcp");
+ if (am) am.push(a);
+ var rv;
+ if (!nested && hints.usesSiblingOp) {
+ rv = normalize(am ? am : a);
+ } else {
+ rv = am ? am : a;
+ }
+ return [off, rv];
+ }
+
+ function normalizeOne(sel) {
+ var sels = [], s;
+ for (var i = 0; i < sel.length; i++) {
+ if (sel[i] === '~') {
+ // `A ~ B` maps to `:has(:root > A) > B`
+ // `Z A ~ B` maps to `Z :has(:root > A) > B, Z:has(:root > A) > B`
+ // This first clause, takes care of the first case, and the first half of the latter case.
+ if (i < 2 || sel[i-2] != '>') {
+ s = sel.slice(0,i-1);
+ s = s.concat([{has:[[{pc: ":root"}, ">", sel[i-1]]]}, ">"]);
+ s = s.concat(sel.slice(i+1));
+ sels.push(s);
+ }
+ // here we take care of the second half of above:
+ // (`Z A ~ B` maps to `Z :has(:root > A) > B, Z :has(:root > A) > B`)
+ // and a new case:
+ // Z > A ~ B maps to Z:has(:root > A) > B
+ if (i > 1) {
+ var at = sel[i-2] === '>' ? i-3 : i-2;
+ s = sel.slice(0,at);
+ var z = {};
+ for (var k in sel[at]) if (sel[at].hasOwnProperty(k)) z[k] = sel[at][k];
+ if (!z.has) z.has = [];
+ z.has.push([{pc: ":root"}, ">", sel[i-1]]);
+ s = s.concat(z, '>', sel.slice(i+1));
+ sels.push(s);
+ }
+ break;
+ }
+ }
+ if (i == sel.length) return sel;
+ return sels.length > 1 ? [','].concat(sels) : sels[0];
+ }
+
+ function normalize(sels) {
+ if (sels[0] === ',') {
+ var r = [","];
+ for (var i = i; i < sels.length; i++) {
+ var s = normalizeOne(s[i]);
+ r = r.concat(s[0] === "," ? s.slice(1) : s);
+ }
+ return r;
+ } else {
+ return normalizeOne(sels);
+ }
+ }
+
+ function parse_selector(str, off, hints) {
+ var soff = off;
+ var s = { };
+ var l = lex(str, off);
+ // skip space
+ if (l && l[1] === " ") { soff = off = l[0]; l = lex(str, off); }
+ if (l && l[1] === toks.typ) {
+ s.type = l[2];
+ l = lex(str, (off = l[0]));
+ } else if (l && l[1] === "*") {
+ // don't bother representing the universal sel, '*' in the
+ // parse tree, cause it's the default
+ l = lex(str, (off = l[0]));
+ }
+
+ // now support either an id or a pc
+ while (true) {
+ if (l === undefined) {
+ break;
+ } else if (l[1] === toks.ide) {
+ if (s.id) te("nmi");
+ s.id = l[2];
+ } else if (l[1] === toks.psc) {
+ if (s.pc || s.pf) te("mpc");
+ // collapse first-child and last-child into nth-child expressions
+ if (l[2] === ":first-child") {
+ s.pf = ":nth-child";
+ s.a = 0;
+ s.b = 1;
+ } else if (l[2] === ":last-child") {
+ s.pf = ":nth-last-child";
+ s.a = 0;
+ s.b = 1;
+ } else {
+ s.pc = l[2];
+ }
+ } else if (l[1] === toks.psf) {
+ if (l[2] === ":val" || l[2] === ":contains") {
+ s.expr = [ undefined, l[2] === ":val" ? "=" : "*=", undefined];
+ // any amount of whitespace, followed by paren, string, paren
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== "(") te("pex");
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== toks.str) te("sex");
+ s.expr[2] = l[2];
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== ")") te("epex");
+ } else if (l[2] === ":has") {
+ // any amount of whitespace, followed by paren
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== "(") te("pex");
+ var h = parse(str, l[0], true);
+ l[0] = h[0];
+ if (!s.has) s.has = [];
+ s.has.push(h[1]);
+ } else if (l[2] === ":expr") {
+ if (s.expr) te("mexp");
+ var e = exprParse(str, l[0]);
+ l[0] = e[0];
+ s.expr = e[1];
+ } else {
+ if (s.pc || s.pf ) te("mpc");
+ s.pf = l[2];
+ var m = nthPat.exec(str.substr(l[0]));
+ if (!m) te("mepf");
+ if (m[5]) {
+ s.a = 2;
+ s.b = (m[5] === "odd") ? 1 : 0;
+ } else if (m[6]) {
+ s.a = 0;
+ s.b = parseInt(m[6], 10);
+ } else {
+ s.a = parseInt((m[1] ? m[1] : "+") + (m[2] ? m[2] : "1"),10);
+ s.b = m[3] ? parseInt(m[3] + m[4],10) : 0;
+ }
+ l[0] += m[0].length;
+ }
+ } else {
+ break;
+ }
+ l = lex(str, (off = l[0]));
+ }
+
+ // now if we didn't actually parse anything it's an error
+ if (soff === off) te("se");
+
+ return [off, s];
+ }
+
+ // THE EVALUATOR
+
+ function isArray(o) {
+ return Array.isArray ? Array.isArray(o) :
+ toString.call(o) === "[object Array]";
+ }
+
+ function mytypeof(o) {
+ if (o === null) return "null";
+ var to = typeof o;
+ if (to === "object" && isArray(o)) to = "array";
+ return to;
+ }
+
+ function mn(node, sel, id, num, tot) {
+ var sels = [];
+ var cs = (sel[0] === ">") ? sel[1] : sel[0];
+ var m = true, mod;
+ if (cs.type) m = m && (cs.type === mytypeof(node));
+ if (cs.id) m = m && (cs.id === id);
+ if (m && cs.pf) {
+ if (cs.pf === ":nth-last-child") num = tot - num;
+ else num++;
+ if (cs.a === 0) {
+ m = cs.b === num;
+ } else {
+ mod = ((num - cs.b) % cs.a);
+
+ m = (!mod && ((num*cs.a + cs.b) >= 0));
+ }
+ }
+ if (m && cs.has) {
+ // perhaps we should augment forEach to handle a return value
+ // that indicates "client cancels traversal"?
+ var bail = function() { throw 42; };
+ for (var i = 0; i < cs.has.length; i++) {
+ try {
+ forEach(cs.has[i], node, bail);
+ } catch (e) {
+ if (e === 42) continue;
+ }
+ m = false;
+ break;
+ }
+ }
+ if (m && cs.expr) {
+ m = exprEval(cs.expr, node);
+ }
+ // should we repeat this selector for descendants?
+ if (sel[0] !== ">" && sel[0].pc !== ":root") sels.push(sel);
+
+ if (m) {
+ // is there a fragment that we should pass down?
+ if (sel[0] === ">") { if (sel.length > 2) { m = false; sels.push(sel.slice(2)); } }
+ else if (sel.length > 1) { m = false; sels.push(sel.slice(1)); }
+ }
+
+ return [m, sels];
+ }
+
+ function forEach(sel, obj, fun, id, num, tot) {
+ var a = (sel[0] === ",") ? sel.slice(1) : [sel],
+ a0 = [],
+ call = false,
+ i = 0, j = 0, k, x;
+ for (i = 0; i < a.length; i++) {
+ x = mn(obj, a[i], id, num, tot);
+ if (x[0]) {
+ call = true;
+ }
+ for (j = 0; j < x[1].length; j++) {
+ a0.push(x[1][j]);
+ }
+ }
+ if (a0.length && typeof obj === "object") {
+ if (a0.length >= 1) {
+ a0.unshift(",");
+ }
+ if (isArray(obj)) {
+ for (i = 0; i < obj.length; i++) {
+ forEach(a0, obj[i], fun, undefined, i, obj.length);
+ }
+ } else {
+ for (k in obj) {
+ if (obj.hasOwnProperty(k)) {
+ forEach(a0, obj[k], fun, k);
+ }
+ }
+ }
+ }
+ if (call && fun) {
+ fun(obj);
+ }
+ }
+
+ function match(sel, obj) {
+ var a = [];
+ forEach(sel, obj, function(x) {
+ a.push(x);
+ });
+ return a;
+ }
+
+ function compile(sel) {
+ return {
+ sel: parse(sel)[1],
+ match: function(obj){
+ return match(this.sel, obj);
+ },
+ forEach: function(obj, fun) {
+ return forEach(this.sel, obj, fun);
+ }
+ };
+ }
+
+ exports._lex = lex;
+ exports._parse = parse;
+ exports.match = function (sel, obj) {
+ return compile(sel).match(obj);
+ };
+ exports.forEach = function(sel, obj, fun) {
+ return compile(sel).forEach(obj, fun);
+ };
+ exports.compile = compile;
+})(typeof exports === "undefined" ? (window.JSONSelect = {}) : exports);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.min.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.min.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.min.js
new file mode 100644
index 0000000..ec5015f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.min.js
@@ -0,0 +1 @@
+(function(a){function z(a){return{sel:q(a)[1],match:function(a){return y(this.sel,a)},forEach:function(a,b){return x(this.sel,a,b)}}}function y(a,b){var c=[];x(a,b,function(a){c.push(a)});return c}function x(a,b,c,d,e,f){var g=a[0]===","?a.slice(1):[a],h=[],i=!1,j=0,k=0,l,m;for(j=0;j<g.length;j++){m=w(b,g[j],d,e,f),m[0]&&(i=!0);for(k=0;k<m[1].length;k++)h.push(m[1][k])}if(h.length&&typeof b=="object"){h.length>=1&&h.unshift(",");if(u(b))for(j=0;j<b.length;j++)x(h,b[j],c,undefined,j,b.length);else for(l in b)b.hasOwnProperty(l)&&x(h,b[l],c,l)}i&&c&&c(b)}function w(a,b,c,d,e){var f=[],g=b[0]===">"?b[1]:b[0],h=!0,i;g.type&&(h=h&&g.type===v(a)),g.id&&(h=h&&g.id===c),h&&g.pf&&(g.pf===":nth-last-child"?d=e-d:d++,g.a===0?h=g.b===d:(i=(d-g.b)%g.a,h=!i&&d*g.a+g.b>=0));if(h&&g.has){var j=function(){throw 42};for(var k=0;k<g.has.length;k++){try{x(g.has[k],a,j)}catch(l){if(l===42)continue}h=!1;break}}h&&g.expr&&(h=p(g.expr,a)),b[0]!==">"&&b[0].pc!==":root"&&f.push(b),h&&(b[0]===">"?b.length>2&&
(h=!1,f.push(b.slice(2))):b.length>1&&(h=!1,f.push(b.slice(1))));return[h,f]}function v(a){if(a===null)return"null";var b=typeof a;b==="object"&&u(a)&&(b="array");return b}function u(a){return Array.isArray?Array.isArray(a):b.call(a)==="[object Array]"}function t(a,b,c){var d=b,g={},j=i(a,b);j&&j[1]===" "&&(d=b=j[0],j=i(a,b)),j&&j[1]===f.typ?(g.type=j[2],j=i(a,b=j[0])):j&&j[1]==="*"&&(j=i(a,b=j[0]));for(;;){if(j===undefined)break;if(j[1]===f.ide)g.id&&e("nmi"),g.id=j[2];else if(j[1]===f.psc)(g.pc||g.pf)&&e("mpc"),j[2]===":first-child"?(g.pf=":nth-child",g.a=0,g.b=1):j[2]===":last-child"?(g.pf=":nth-last-child",g.a=0,g.b=1):g.pc=j[2];else{if(j[1]!==f.psf)break;if(j[2]===":val"||j[2]===":contains")g.expr=[undefined,j[2]===":val"?"=":"*=",undefined],j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0])),(!j||j[1]!=="(")&&e("pex"),j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0])),(!j||j[1]!==f.str)&&e("sex"),g.expr[2]=j[2],j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0])),(!j||j[1]!==")")&&e("epex");else i
f(j[2]===":has"){j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0])),(!j||j[1]!=="(")&&e("pex");var k=q(a,j[0],!0);j[0]=k[0],g.has||(g.has=[]),g.has.push(k[1])}else if(j[2]===":expr"){g.expr&&e("mexp");var l=o(a,j[0]);j[0]=l[0],g.expr=l[1]}else{(g.pc||g.pf)&&e("mpc"),g.pf=j[2];var m=h.exec(a.substr(j[0]));m||e("mepf"),m[5]?(g.a=2,g.b=m[5]==="odd"?1:0):m[6]?(g.a=0,g.b=parseInt(m[6],10)):(g.a=parseInt((m[1]?m[1]:"+")+(m[2]?m[2]:"1"),10),g.b=m[3]?parseInt(m[3]+m[4],10):0),j[0]+=m[0].length}}j=i(a,b=j[0])}d===b&&e("se");return[b,g]}function s(a){if(a[0]===","){var b=[","];for(var c=c;c<a.length;c++){var d=r(d[c]);b=b.concat(d[0]===","?d.slice(1):d)}return b}return r(a)}function r(a){var b=[],c;for(var d=0;d<a.length;d++)if(a[d]==="~"){if(d<2||a[d-2]!=">")c=a.slice(0,d-1),c=c.concat([{has:[[{pc:":root"},">",a[d-1]]]},">"]),c=c.concat(a.slice(d+1)),b.push(c);if(d>1){var e=a[d-2]===">"?d-3:d-2;c=a.slice(0,e);var f={};for(var g in a[e])a[e].hasOwnProperty(g)&&(f[g]=a[e][g]);f.has||(f.has=[]),f.has
.push([{pc:":root"},">",a[d-1]]),c=c.concat(f,">",a.slice(d+1)),b.push(c)}break}if(d==a.length)return a;return b.length>1?[","].concat(b):b[0]}function q(a,b,c,d){c||(d={});var f=[],g,h;b||(b=0);for(;;){var j=t(a,b,d);f.push(j[1]),j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0]));if(!j)break;if(j[1]===">"||j[1]==="~")j[1]==="~"&&(d.usesSiblingOp=!0),f.push(j[1]),b=j[0];else if(j[1]===",")g===undefined?g=[",",f]:g.push(f),f=[],b=j[0];else if(j[1]===")"){c||e("ucp"),h=1,b=j[0];break}}c&&!h&&e("mcp"),g&&g.push(f);var k;!c&&d.usesSiblingOp?k=s(g?g:f):k=g?g:f;return[b,k]}function p(a,b){if(a===undefined)return b;if(a===null||typeof a!="object")return a;var c=p(a[0],b),d=p(a[2],b);return l[a[1]][1](c,d)}function o(a,b){function c(a){return typeof a!="object"||a===null?a:a[0]==="("?c(a[1]):[c(a[0]),a[1],c(a[2])]}var d=n(a,b?b:0);return[d[0],c(d[1])]}function n(a,b){b||(b=0);var c=m(a,b),d;if(c&&c[1]==="("){d=n(a,c[0]);var f=m(a,d[0]);(!f||f[1]!==")")&&e("epex"),b=f[0],d=["(",d[1]]}else!c||c[1]&
&c[1]!="x"?e("ee"):(d=c[1]==="x"?undefined:c[2],b=c[0]);var g=m(a,b);if(!g||g[1]==")")return[b,d];(g[1]=="x"||!g[1])&&e("bop");var h=n(a,g[0]);b=h[0],h=h[1];var i;if(typeof h!="object"||h[0]==="("||l[g[1]][0]<l[h[1]][0])i=[d,g[1],h];else{i=h;while(typeof h[0]=="object"&&h[0][0]!="("&&l[g[1]][0]>=l[h[0][1]][0])h=h[0];h[0]=[d,g[1],h[0]]}return[b,i]}function m(a,b){var d,e=j.exec(a.substr(b));if(e){b+=e[0].length,d=e[1]||e[2]||e[3]||e[5]||e[6];if(e[1]||e[2]||e[3])return[b,0,c(d)];if(e[4])return[b,0,undefined];return[b,d]}}function k(a,b){return typeof a===b}function i(a,b){b||(b=0);var d=g.exec(a.substr(b));if(!d)return undefined;b+=d[0].length;var h;d[1]?h=[b," "]:d[2]?h=[b,d[0]]:d[3]?h=[b,f.typ,d[0]]:d[4]?h=[b,f.psc,d[0]]:d[5]?h=[b,f.psf,d[0]]:d[6]?e("upc"):d[8]?h=[b,d[7]?f.ide:f.str,c(d[8])]:d[9]?e("ujs"):d[10]&&(h=[b,f.ide,d[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")]);return h}function e(a){throw new Error(d[a])}function c(a){try{if(JSON&&JSON.parse)return JSON.parse(a);return(ne
w Function("return "+a))()}catch(b){e("ijs")}}var b=Object.prototype.toString,d={bop:"binary operator expected",ee:"expression expected",epex:"closing paren expected ')'",ijs:"invalid json string",mcp:"missing closing paren",mepf:"malformed expression in pseudo-function",mexp:"multiple expressions not allowed",mpc:"multiple pseudo classes (:xxx) not allowed",nmi:"multiple ids not allowed",pex:"opening paren expected '('",se:"selector expected",sex:"string expected",sra:"string required after '.'",uc:"unrecognized char",ucp:"unexpected closing paren",ujs:"unclosed json string",upc:"unrecognized pseudo class"},f={psc:1,psf:2,typ:3,str:4,ide:5},g=new RegExp('^(?:([\\r\\n\\t\\ ]+)|([~*,>\\)\\(])|(string|boolean|null|array|object|number)|(:(?:root|first-child|last-child|only-child))|(:(?:nth-child|nth-last-child|has|expr|val|contains))|(:\\w+)|(?:(\\.)?(\\"(?:[^\\\\]|\\\\[^\\"])*\\"))|(\\")|\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:
\\\\[^\\r\\n\\f0-9a-fA-F]))*))'),h=/^\s*\(\s*(?:([+\-]?)([0-9]*)n\s*(?:([+\-])\s*([0-9]))?|(odd|even)|([+\-]?[0-9]+))\s*\)/,j=new RegExp('^\\s*(?:(true|false|null)|(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|("(?:[^\\]|\\[^"])*")|(x)|(&&|\\|\\||[\\$\\^<>!\\*]=|[=+\\-*/%<>])|([\\(\\)]))'),l={"*":[9,function(a,b){return a*b}],"/":[9,function(a,b){return a/b}],"%":[9,function(a,b){return a%b}],"+":[7,function(a,b){return a+b}],"-":[7,function(a,b){return a-b}],"<=":[5,function(a,b){return k(a,"number")&&k(b,"number")&&a<=b}],">=":[5,function(a,b){return k(a,"number")&&k(b,"number")&&a>=b}],"$=":[5,function(a,b){return k(a,"string")&&k(b,"string")&&a.lastIndexOf(b)===a.length-b.length}],"^=":[5,function(a,b){return k(a,"string")&&k(b,"string")&&a.indexOf(b)===0}],"*=":[5,function(a,b){return k(a,"string")&&k(b,"string")&&a.indexOf(b)!==-1}],">":[5,function(a,b){return k(a,"number")&&k(b,"number")&&a>b}],"<":[5,function(a,b){return k(a,"number")&&k(b,"number")&&a<b}],"=":[3,function(a,b){re
turn a===b}],"!=":[3,function(a,b){return a!==b}],"&&":[2,function(a,b){return a&&b}],"||":[1,function(a,b){return a||b}]};a._lex=i,a._parse=q,a.match=function(a,b){return z(a).match(b)},a.forEach=function(a,b,c){return z(a).forEach(b,c)},a.compile=z})(typeof exports=="undefined"?window.JSONSelect={}:exports)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.min.js.gz
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.min.js.gz b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.min.js.gz
new file mode 100644
index 0000000..4eb9b37
Binary files /dev/null and b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/dist/jsonselect.min.js.gz differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/jsonselect.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/jsonselect.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/jsonselect.js
new file mode 100644
index 0000000..f0611ea
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/jsonselect.js
@@ -0,0 +1,522 @@
+/*! Copyright (c) 2011, Lloyd Hilaiel, ISC License */
+/*
+ * This is the JSONSelect reference implementation, in javascript.
+ */
+(function(exports) {
+
+ var // localize references
+ toString = Object.prototype.toString;
+
+ function jsonParse(str) {
+ try {
+ if(JSON && JSON.parse){
+ return JSON.parse(str);
+ }
+ return (new Function("return " + str))();
+ } catch(e) {
+ te("ijs", e.message);
+ }
+ }
+
+ // emitted error codes.
+ var errorCodes = {
+ "bop": "binary operator expected",
+ "ee": "expression expected",
+ "epex": "closing paren expected ')'",
+ "ijs": "invalid json string",
+ "mcp": "missing closing paren",
+ "mepf": "malformed expression in pseudo-function",
+ "mexp": "multiple expressions not allowed",
+ "mpc": "multiple pseudo classes (:xxx) not allowed",
+ "nmi": "multiple ids not allowed",
+ "pex": "opening paren expected '('",
+ "se": "selector expected",
+ "sex": "string expected",
+ "sra": "string required after '.'",
+ "uc": "unrecognized char",
+ "ucp": "unexpected closing paren",
+ "ujs": "unclosed json string",
+ "upc": "unrecognized pseudo class"
+ };
+
+ // throw an error message
+ function te(ec, context) {
+ throw new Error(errorCodes[ec] + ( context && " in '" + context + "'"));
+ }
+
+ // THE LEXER
+ var toks = {
+ psc: 1, // pseudo class
+ psf: 2, // pseudo class function
+ typ: 3, // type
+ str: 4, // string
+ ide: 5 // identifiers (or "classes", stuff after a dot)
+ };
+
+ // The primary lexing regular expression in jsonselect
+ var pat = new RegExp(
+ "^(?:" +
+ // (1) whitespace
+ "([\\r\\n\\t\\ ]+)|" +
+ // (2) one-char ops
+ "([~*,>\\)\\(])|" +
+ // (3) types names
+ "(string|boolean|null|array|object|number)|" +
+ // (4) pseudo classes
+ "(:(?:root|first-child|last-child|only-child))|" +
+ // (5) pseudo functions
+ "(:(?:nth-child|nth-last-child|has|expr|val|contains))|" +
+ // (6) bogusly named pseudo something or others
+ "(:\\w+)|" +
+ // (7 & 8) identifiers and JSON strings
+ "(?:(\\.)?(\\\"(?:[^\\\\\\\"]|\\\\[^\\\"])*\\\"))|" +
+ // (8) bogus JSON strings missing a trailing quote
+ "(\\\")|" +
+ // (9) identifiers (unquoted)
+ "\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*)" +
+ ")"
+ );
+
+ // A regular expression for matching "nth expressions" (see grammar, what :nth-child() eats)
+ var nthPat = /^\s*\(\s*(?:([+\-]?)([0-9]*)n\s*(?:([+\-])\s*([0-9]))?|(odd|even)|([+\-]?[0-9]+))\s*\)/;
+ function lex(str, off) {
+ if (!off) off = 0;
+ var m = pat.exec(str.substr(off));
+ if (!m) return undefined;
+ off+=m[0].length;
+ var a;
+ if (m[1]) a = [off, " "];
+ else if (m[2]) a = [off, m[0]];
+ else if (m[3]) a = [off, toks.typ, m[0]];
+ else if (m[4]) a = [off, toks.psc, m[0]];
+ else if (m[5]) a = [off, toks.psf, m[0]];
+ else if (m[6]) te("upc", str);
+ else if (m[8]) a = [off, m[7] ? toks.ide : toks.str, jsonParse(m[8])];
+ else if (m[9]) te("ujs", str);
+ else if (m[10]) a = [off, toks.ide, m[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")];
+ return a;
+ }
+
+ // THE EXPRESSION SUBSYSTEM
+
+ var exprPat = new RegExp(
+ // skip and don't capture leading whitespace
+ "^\\s*(?:" +
+ // (1) simple vals
+ "(true|false|null)|" +
+ // (2) numbers
+ "(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|" +
+ // (3) strings
+ "(\"(?:[^\\]|\\[^\"])*\")|" +
+ // (4) the 'x' value placeholder
+ "(x)|" +
+ // (5) binops
+ "(&&|\\|\\||[\\$\\^<>!\\*]=|[=+\\-*/%<>])|" +
+ // (6) parens
+ "([\\(\\)])" +
+ ")"
+ );
+
+ function is(o, t) { return typeof o === t; }
+ var operators = {
+ '*': [ 9, function(lhs, rhs) { return lhs * rhs; } ],
+ '/': [ 9, function(lhs, rhs) { return lhs / rhs; } ],
+ '%': [ 9, function(lhs, rhs) { return lhs % rhs; } ],
+ '+': [ 7, function(lhs, rhs) { return lhs + rhs; } ],
+ '-': [ 7, function(lhs, rhs) { return lhs - rhs; } ],
+ '<=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs <= rhs; } ],
+ '>=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs >= rhs; } ],
+ '$=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.lastIndexOf(rhs) === lhs.length - rhs.length; } ],
+ '^=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) === 0; } ],
+ '*=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) !== -1; } ],
+ '>': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs > rhs; } ],
+ '<': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs < rhs; } ],
+ '=': [ 3, function(lhs, rhs) { return lhs === rhs; } ],
+ '!=': [ 3, function(lhs, rhs) { return lhs !== rhs; } ],
+ '&&': [ 2, function(lhs, rhs) { return lhs && rhs; } ],
+ '||': [ 1, function(lhs, rhs) { return lhs || rhs; } ]
+ };
+
+ function exprLex(str, off) {
+ var v, m = exprPat.exec(str.substr(off));
+ if (m) {
+ off += m[0].length;
+ v = m[1] || m[2] || m[3] || m[5] || m[6];
+ if (m[1] || m[2] || m[3]) return [off, 0, jsonParse(v)];
+ else if (m[4]) return [off, 0, undefined];
+ return [off, v];
+ }
+ }
+
+ function exprParse2(str, off) {
+ if (!off) off = 0;
+ // first we expect a value or a '('
+ var l = exprLex(str, off),
+ lhs;
+ if (l && l[1] === '(') {
+ lhs = exprParse2(str, l[0]);
+ var p = exprLex(str, lhs[0]);
+ if (!p || p[1] !== ')') te('epex', str);
+ off = p[0];
+ lhs = [ '(', lhs[1] ];
+ } else if (!l || (l[1] && l[1] != 'x')) {
+ te("ee", str + " - " + ( l[1] && l[1] ));
+ } else {
+ lhs = ((l[1] === 'x') ? undefined : l[2]);
+ off = l[0];
+ }
+
+ // now we expect a binary operator or a ')'
+ var op = exprLex(str, off);
+ if (!op || op[1] == ')') return [off, lhs];
+ else if (op[1] == 'x' || !op[1]) {
+ te('bop', str + " - " + ( op[1] && op[1] ));
+ }
+
+ // tail recursion to fetch the rhs expression
+ var rhs = exprParse2(str, op[0]);
+ off = rhs[0];
+ rhs = rhs[1];
+
+ // and now precedence! how shall we put everything together?
+ var v;
+ if (typeof rhs !== 'object' || rhs[0] === '(' || operators[op[1]][0] < operators[rhs[1]][0] ) {
+ v = [lhs, op[1], rhs];
+ }
+ else {
+ v = rhs;
+ while (typeof rhs[0] === 'object' && rhs[0][0] != '(' && operators[op[1]][0] >= operators[rhs[0][1]][0]) {
+ rhs = rhs[0];
+ }
+ rhs[0] = [lhs, op[1], rhs[0]];
+ }
+ return [off, v];
+ }
+
+ function exprParse(str, off) {
+ function deparen(v) {
+ if (typeof v !== 'object' || v === null) return v;
+ else if (v[0] === '(') return deparen(v[1]);
+ else return [deparen(v[0]), v[1], deparen(v[2])];
+ }
+ var e = exprParse2(str, off ? off : 0);
+ return [e[0], deparen(e[1])];
+ }
+
+ function exprEval(expr, x) {
+ if (expr === undefined) return x;
+ else if (expr === null || typeof expr !== 'object') {
+ return expr;
+ }
+ var lhs = exprEval(expr[0], x),
+ rhs = exprEval(expr[2], x);
+ return operators[expr[1]][1](lhs, rhs);
+ }
+
+ // THE PARSER
+
+ function parse(str, off, nested, hints) {
+ if (!nested) hints = {};
+
+ var a = [], am, readParen;
+ if (!off) off = 0;
+
+ while (true) {
+ var s = parse_selector(str, off, hints);
+ a.push(s[1]);
+ s = lex(str, off = s[0]);
+ if (s && s[1] === " ") s = lex(str, off = s[0]);
+ if (!s) break;
+ // now we've parsed a selector, and have something else...
+ if (s[1] === ">" || s[1] === "~") {
+ if (s[1] === "~") hints.usesSiblingOp = true;
+ a.push(s[1]);
+ off = s[0];
+ } else if (s[1] === ",") {
+ if (am === undefined) am = [ ",", a ];
+ else am.push(a);
+ a = [];
+ off = s[0];
+ } else if (s[1] === ")") {
+ if (!nested) te("ucp", s[1]);
+ readParen = 1;
+ off = s[0];
+ break;
+ }
+ }
+ if (nested && !readParen) te("mcp", str);
+ if (am) am.push(a);
+ var rv;
+ if (!nested && hints.usesSiblingOp) {
+ rv = normalize(am ? am : a);
+ } else {
+ rv = am ? am : a;
+ }
+ return [off, rv];
+ }
+
+ function normalizeOne(sel) {
+ var sels = [], s;
+ for (var i = 0; i < sel.length; i++) {
+ if (sel[i] === '~') {
+ // `A ~ B` maps to `:has(:root > A) > B`
+ // `Z A ~ B` maps to `Z :has(:root > A) > B, Z:has(:root > A) > B`
+ // This first clause, takes care of the first case, and the first half of the latter case.
+ if (i < 2 || sel[i-2] != '>') {
+ s = sel.slice(0,i-1);
+ s = s.concat([{has:[[{pc: ":root"}, ">", sel[i-1]]]}, ">"]);
+ s = s.concat(sel.slice(i+1));
+ sels.push(s);
+ }
+ // here we take care of the second half of above:
+ // (`Z A ~ B` maps to `Z :has(:root > A) > B, Z :has(:root > A) > B`)
+ // and a new case:
+ // Z > A ~ B maps to Z:has(:root > A) > B
+ if (i > 1) {
+ var at = sel[i-2] === '>' ? i-3 : i-2;
+ s = sel.slice(0,at);
+ var z = {};
+ for (var k in sel[at]) if (sel[at].hasOwnProperty(k)) z[k] = sel[at][k];
+ if (!z.has) z.has = [];
+ z.has.push([{pc: ":root"}, ">", sel[i-1]]);
+ s = s.concat(z, '>', sel.slice(i+1));
+ sels.push(s);
+ }
+ break;
+ }
+ }
+ if (i == sel.length) return sel;
+ return sels.length > 1 ? [','].concat(sels) : sels[0];
+ }
+
+ function normalize(sels) {
+ if (sels[0] === ',') {
+ var r = [","];
+ for (var i = i; i < sels.length; i++) {
+ var s = normalizeOne(s[i]);
+ r = r.concat(s[0] === "," ? s.slice(1) : s);
+ }
+ return r;
+ } else {
+ return normalizeOne(sels);
+ }
+ }
+
+ function parse_selector(str, off, hints) {
+ var soff = off;
+ var s = { };
+ var l = lex(str, off);
+ // skip space
+ if (l && l[1] === " ") { soff = off = l[0]; l = lex(str, off); }
+ if (l && l[1] === toks.typ) {
+ s.type = l[2];
+ l = lex(str, (off = l[0]));
+ } else if (l && l[1] === "*") {
+ // don't bother representing the universal sel, '*' in the
+ // parse tree, cause it's the default
+ l = lex(str, (off = l[0]));
+ }
+
+ // now support either an id or a pc
+ while (true) {
+ if (l === undefined) {
+ break;
+ } else if (l[1] === toks.ide) {
+ if (s.id) te("nmi", l[1]);
+ s.id = l[2];
+ } else if (l[1] === toks.psc) {
+ if (s.pc || s.pf) te("mpc", l[1]);
+ // collapse first-child and last-child into nth-child expressions
+ if (l[2] === ":first-child") {
+ s.pf = ":nth-child";
+ s.a = 0;
+ s.b = 1;
+ } else if (l[2] === ":last-child") {
+ s.pf = ":nth-last-child";
+ s.a = 0;
+ s.b = 1;
+ } else {
+ s.pc = l[2];
+ }
+ } else if (l[1] === toks.psf) {
+ if (l[2] === ":val" || l[2] === ":contains") {
+ s.expr = [ undefined, l[2] === ":val" ? "=" : "*=", undefined];
+ // any amount of whitespace, followed by paren, string, paren
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== "(") te("pex", str);
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== toks.str) te("sex", str);
+ s.expr[2] = l[2];
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== ")") te("epex", str);
+ } else if (l[2] === ":has") {
+ // any amount of whitespace, followed by paren
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== "(") te("pex", str);
+ var h = parse(str, l[0], true);
+ l[0] = h[0];
+ if (!s.has) s.has = [];
+ s.has.push(h[1]);
+ } else if (l[2] === ":expr") {
+ if (s.expr) te("mexp", str);
+ var e = exprParse(str, l[0]);
+ l[0] = e[0];
+ s.expr = e[1];
+ } else {
+ if (s.pc || s.pf ) te("mpc", str);
+ s.pf = l[2];
+ var m = nthPat.exec(str.substr(l[0]));
+ if (!m) te("mepf", str);
+ if (m[5]) {
+ s.a = 2;
+ s.b = (m[5] === "odd") ? 1 : 0;
+ } else if (m[6]) {
+ s.a = 0;
+ s.b = parseInt(m[6], 10);
+ } else {
+ s.a = parseInt((m[1] ? m[1] : "+") + (m[2] ? m[2] : "1"),10);
+ s.b = m[3] ? parseInt(m[3] + m[4],10) : 0;
+ }
+ l[0] += m[0].length;
+ }
+ } else {
+ break;
+ }
+ l = lex(str, (off = l[0]));
+ }
+
+ // now if we didn't actually parse anything it's an error
+ if (soff === off) te("se", str);
+
+ return [off, s];
+ }
+
+ // THE EVALUATOR
+
+ function isArray(o) {
+ return Array.isArray ? Array.isArray(o) :
+ toString.call(o) === "[object Array]";
+ }
+
+ function mytypeof(o) {
+ if (o === null) return "null";
+ var to = typeof o;
+ if (to === "object" && isArray(o)) to = "array";
+ return to;
+ }
+
+ function mn(node, sel, id, num, tot) {
+ var sels = [];
+ var cs = (sel[0] === ">") ? sel[1] : sel[0];
+ var m = true, mod;
+ if (cs.type) m = m && (cs.type === mytypeof(node));
+ if (cs.id) m = m && (cs.id === id);
+ if (m && cs.pf) {
+ if (cs.pf === ":nth-last-child") num = tot - num;
+ else num++;
+ if (cs.a === 0) {
+ m = cs.b === num;
+ } else {
+ mod = ((num - cs.b) % cs.a);
+
+ m = (!mod && ((num*cs.a + cs.b) >= 0));
+ }
+ }
+ if (m && cs.has) {
+ // perhaps we should augment forEach to handle a return value
+ // that indicates "client cancels traversal"?
+ var bail = function() { throw 42; };
+ for (var i = 0; i < cs.has.length; i++) {
+ try {
+ forEach(cs.has[i], node, bail);
+ } catch (e) {
+ if (e === 42) continue;
+ }
+ m = false;
+ break;
+ }
+ }
+ if (m && cs.expr) {
+ m = exprEval(cs.expr, node);
+ }
+ // should we repeat this selector for descendants?
+ if (sel[0] !== ">" && sel[0].pc !== ":root") sels.push(sel);
+
+ if (m) {
+ // is there a fragment that we should pass down?
+ if (sel[0] === ">") { if (sel.length > 2) { m = false; sels.push(sel.slice(2)); } }
+ else if (sel.length > 1) { m = false; sels.push(sel.slice(1)); }
+ }
+
+ return [m, sels];
+ }
+
+ function forEach(sel, obj, fun, id, num, tot) {
+ var a = (sel[0] === ",") ? sel.slice(1) : [sel],
+ a0 = [],
+ call = false,
+ i = 0, j = 0, k, x;
+ for (i = 0; i < a.length; i++) {
+ x = mn(obj, a[i], id, num, tot);
+ if (x[0]) {
+ call = true;
+ }
+ for (j = 0; j < x[1].length; j++) {
+ a0.push(x[1][j]);
+ }
+ }
+ if (a0.length && typeof obj === "object") {
+ if (a0.length >= 1) {
+ a0.unshift(",");
+ }
+ if (isArray(obj)) {
+ for (i = 0; i < obj.length; i++) {
+ forEach(a0, obj[i], fun, undefined, i, obj.length);
+ }
+ } else {
+ for (k in obj) {
+ if (obj.hasOwnProperty(k)) {
+ forEach(a0, obj[k], fun, k);
+ }
+ }
+ }
+ }
+ if (call && fun) {
+ fun(obj);
+ }
+ }
+
+ function match(sel, obj) {
+ var a = [];
+ forEach(sel, obj, function(x) {
+ a.push(x);
+ });
+ return a;
+ }
+
+ function compile(sel) {
+ return {
+ sel: parse(sel)[1],
+ match: function(obj){
+ return match(this.sel, obj);
+ },
+ forEach: function(obj, fun) {
+ return forEach(this.sel, obj, fun);
+ }
+ };
+ }
+
+ exports._lex = lex;
+ exports._parse = parse;
+ exports.match = function (sel, obj) {
+ return compile(sel).match(obj);
+ };
+ exports.forEach = function(sel, obj, fun) {
+ return compile(sel).forEach(obj, fun);
+ };
+ exports.compile = compile;
+})(typeof exports === "undefined" ? (window.JSONSelect = {}) : exports);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/conformance_tests.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/conformance_tests.html b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/conformance_tests.html
new file mode 100644
index 0000000..a53dfd0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/conformance_tests.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title> JSONSelect conformance tests </title>
+ <link href='css/style.css' type='text/css' rel='stylesheet'>
+</head>
+<body>
+These are the the official JSONQuery conformance tests. <button id="runit">run tests</button>
+<div id="tests">
+</div>
+</body>
+<script src="../jsonselect.js"></script>
+<script src="js/jquery-1.6.1.min.js"></script>
+<script src="js/conf_tests.js"></script>
+</html>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/css/style.css
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/css/style.css b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/css/style.css
new file mode 100644
index 0000000..f62cc9d
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/css/style.css
@@ -0,0 +1,43 @@
+pre {
+ color: #ddd;
+ background-color: #333;
+ padding: 1em;
+ border-radius: 1em;
+ -moz-border-radius: 1em;
+ -webkit-border-radius: 1em;
+}
+
+pre.selector {
+ text-align: center;
+ padding: .5em;
+ cursor: pointer;
+}
+
+pre.document {
+ max-height: 150px;
+ overflow: auto;
+}
+
+pre.success {
+ background-color: #363;
+}
+
+pre.failure {
+ background-color: #633;
+}
+
+table {
+ width: 100%;
+}
+
+table td {
+ width: 50%;
+}
+
+table pre {
+ height: 100%;
+}
+
+h1,h2 {
+ text-align: center;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/conf_tests.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/conf_tests.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/conf_tests.js
new file mode 100644
index 0000000..42711ea
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/conf_tests.js
@@ -0,0 +1,77 @@
+$(document).ready(function() {
+ var tests = {};
+
+ $("#runit").click(function() {
+ for (var k in tests) {
+ var obj = JSON.parse($("." + k + "_document").text());
+ for (var i = 0; i < tests[k].length; i++) {
+ var n = tests[k][i];
+ var cl = k + "_" + n;
+ var b = $("." + cl + "_output.before");
+ var a = $("." + cl + "_output.after");
+ var s = $("." + cl + "_selector.selector");
+ try {
+ a.text("");
+ JSONSelect.forEach(s.text(), obj, function(m) {
+ a.text($.trim(a.text() + "\n" + JSON.stringify(m, null, " ")));
+ });
+ } catch(e) {
+ a.text("Error: " + e);
+ }
+ if (a.text() === b.text()) s.addClass("success").removeClass("failure");
+ else s.addClass("failure").removeClass("success");
+ }
+ }
+ });
+
+ function fetchFile(p, c) {
+ $.get(p, function (data) {
+ $("." + c).text($.trim(data));
+ });
+ }
+
+ function renderTests() {
+ function setClickToggle(cTarget, node) {
+ cTarget.click(function() { node.toggle("medium"); });
+ }
+
+ var c = $("<div/>");
+ for (var k in tests) {
+ c.append($("<h1/>").text("document: " + k));
+ var cl = k + "_document";
+ c.append($("<pre/>").addClass(cl).addClass("document").text("loading document..."));
+ fetchFile("tests/" + k + ".json", cl);
+ for (var i = 0; i < tests[k].length; i++) {
+ var n = tests[k][i];
+ var cl = k + "_" + n + "_selector";
+ var s = $("<pre/>").addClass(cl).addClass("selector").text("loading selector...");
+ c.append(s);
+ fetchFile("tests/" + k + "_" + n + ".selector", cl);
+ cl = k + "_" + n + "_output";
+ var t = $("<table/>").append($("<tr/>").append(
+ $("<td/>").append($("<pre/>").addClass(cl).addClass("before").text("loading output..."))).append(
+ $("<td/>").append($("<pre/>").addClass(cl).addClass("after").text("... test output ..."))));
+
+ c.append(t);
+ t.hide();
+ setClickToggle(s, t);
+ fetchFile("tests/" + k + "_" + n + ".output", cl + ".before");
+ }
+ }
+ c.appendTo($("#tests"));
+ }
+
+ $.get("tests/alltests.txt", function (data) {
+ var lines = data.split("\n");
+ for (var i = 0; i < lines.length; i++) {
+ var f = $.trim(lines[i]);
+ if (f.length == 0) continue;
+ var m = /^([A-Za-z]+)_(.+)\.selector$/.exec(f);
+ if (m) {
+ if (!tests.hasOwnProperty(m[1])) tests[m[1]] = [];
+ tests[m[1]].push(m[2]);
+ }
+ }
+ renderTests();
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/doctest.css
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/doctest.css b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/doctest.css
new file mode 100644
index 0000000..7403feb
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/doctest.css
@@ -0,0 +1,69 @@
+pre {
+ overflow: auto;
+}
+
+pre.doctest {
+ border-left: 3px solid #99f;
+ padding-left: 1em;
+}
+
+pre.output {
+ border-left: 3px solid #9f9;
+ padding-left: 1em;
+}
+
+.doctest-example-prompt {
+ color: #333;
+}
+
+.doctest-success {
+ color: #060;
+}
+
+.doctest-failure {
+ color: #600;
+}
+
+.doctest-example-detail {
+ color: #060;
+ font-weight: bold;
+}
+
+a.doctest-failure-link {
+ text-decoration: none;
+}
+
+a.doctest-failure-link:hover {
+ text-decoration: underline;
+}
+
+.doctest-example:target {
+ border-left: 3px solid #f00;
+}
+
+div.test:target {
+ border: 3px solid #ff0;
+}
+
+div.test {
+ border: 1px solid #999;
+ margin-bottom: 1em;
+}
+
+div.test .test-id {
+ position: relative;
+ float: right;
+ background-color: #000;
+ color: #bbb;
+ padding: 3px;
+}
+
+div.test .test-id a:link,
+div.test .test-id a:visited {
+ color: #bbb;
+ text-decoration: none;
+}
+
+div.test .test-id a:hover {
+ text-decoration: underline;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[32/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/dist/es6-promise.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/dist/es6-promise.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/dist/es6-promise.js
new file mode 100644
index 0000000..30a6d81
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/dist/es6-promise.js
@@ -0,0 +1,960 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version 2.0.1
+ */
+
+(function() {
+ "use strict";
+
+ function $$utils$$objectOrFunction(x) {
+ return typeof x === 'function' || (typeof x === 'object' && x !== null);
+ }
+
+ function $$utils$$isFunction(x) {
+ return typeof x === 'function';
+ }
+
+ function $$utils$$isMaybeThenable(x) {
+ return typeof x === 'object' && x !== null;
+ }
+
+ var $$utils$$_isArray;
+
+ if (!Array.isArray) {
+ $$utils$$_isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+ } else {
+ $$utils$$_isArray = Array.isArray;
+ }
+
+ var $$utils$$isArray = $$utils$$_isArray;
+ var $$utils$$now = Date.now || function() { return new Date().getTime(); };
+ function $$utils$$F() { }
+
+ var $$utils$$o_create = (Object.create || function (o) {
+ if (arguments.length > 1) {
+ throw new Error('Second argument not supported');
+ }
+ if (typeof o !== 'object') {
+ throw new TypeError('Argument must be an object');
+ }
+ $$utils$$F.prototype = o;
+ return new $$utils$$F();
+ });
+
+ var $$asap$$len = 0;
+
+ var $$asap$$default = function asap(callback, arg) {
+ $$asap$$queue[$$asap$$len] = callback;
+ $$asap$$queue[$$asap$$len + 1] = arg;
+ $$asap$$len += 2;
+ if ($$asap$$len === 2) {
+ // If len is 1, that means that we need to schedule an async flush.
+ // If additional callbacks are queued before the queue is flushed, they
+ // will be processed by this flush that we are scheduling.
+ $$asap$$scheduleFlush();
+ }
+ };
+
+ var $$asap$$browserGlobal = (typeof window !== 'undefined') ? window : {};
+ var $$asap$$BrowserMutationObserver = $$asap$$browserGlobal.MutationObserver || $$asap$$browserGlobal.WebKitMutationObserver;
+
+ // test for web worker but not in IE10
+ var $$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
+ typeof importScripts !== 'undefined' &&
+ typeof MessageChannel !== 'undefined';
+
+ // node
+ function $$asap$$useNextTick() {
+ return function() {
+ process.nextTick($$asap$$flush);
+ };
+ }
+
+ function $$asap$$useMutationObserver() {
+ var iterations = 0;
+ var observer = new $$asap$$BrowserMutationObserver($$asap$$flush);
+ var node = document.createTextNode('');
+ observer.observe(node, { characterData: true });
+
+ return function() {
+ node.data = (iterations = ++iterations % 2);
+ };
+ }
+
+ // web worker
+ function $$asap$$useMessageChannel() {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = $$asap$$flush;
+ return function () {
+ channel.port2.postMessage(0);
+ };
+ }
+
+ function $$asap$$useSetTimeout() {
+ return function() {
+ setTimeout($$asap$$flush, 1);
+ };
+ }
+
+ var $$asap$$queue = new Array(1000);
+
+ function $$asap$$flush() {
+ for (var i = 0; i < $$asap$$len; i+=2) {
+ var callback = $$asap$$queue[i];
+ var arg = $$asap$$queue[i+1];
+
+ callback(arg);
+
+ $$asap$$queue[i] = undefined;
+ $$asap$$queue[i+1] = undefined;
+ }
+
+ $$asap$$len = 0;
+ }
+
+ var $$asap$$scheduleFlush;
+
+ // Decide what async method to use to triggering processing of queued callbacks:
+ if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
+ $$asap$$scheduleFlush = $$asap$$useNextTick();
+ } else if ($$asap$$BrowserMutationObserver) {
+ $$asap$$scheduleFlush = $$asap$$useMutationObserver();
+ } else if ($$asap$$isWorker) {
+ $$asap$$scheduleFlush = $$asap$$useMessageChannel();
+ } else {
+ $$asap$$scheduleFlush = $$asap$$useSetTimeout();
+ }
+
+ function $$$internal$$noop() {}
+ var $$$internal$$PENDING = void 0;
+ var $$$internal$$FULFILLED = 1;
+ var $$$internal$$REJECTED = 2;
+ var $$$internal$$GET_THEN_ERROR = new $$$internal$$ErrorObject();
+
+ function $$$internal$$selfFullfillment() {
+ return new TypeError("You cannot resolve a promise with itself");
+ }
+
+ function $$$internal$$cannotReturnOwn() {
+ return new TypeError('A promises callback cannot return that same promise.')
+ }
+
+ function $$$internal$$getThen(promise) {
+ try {
+ return promise.then;
+ } catch(error) {
+ $$$internal$$GET_THEN_ERROR.error = error;
+ return $$$internal$$GET_THEN_ERROR;
+ }
+ }
+
+ function $$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
+ try {
+ then.call(value, fulfillmentHandler, rejectionHandler);
+ } catch(e) {
+ return e;
+ }
+ }
+
+ function $$$internal$$handleForeignThenable(promise, thenable, then) {
+ $$asap$$default(function(promise) {
+ var sealed = false;
+ var error = $$$internal$$tryThen(then, thenable, function(value) {
+ if (sealed) { return; }
+ sealed = true;
+ if (thenable !== value) {
+ $$$internal$$resolve(promise, value);
+ } else {
+ $$$internal$$fulfill(promise, value);
+ }
+ }, function(reason) {
+ if (sealed) { return; }
+ sealed = true;
+
+ $$$internal$$reject(promise, reason);
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
+
+ if (!sealed && error) {
+ sealed = true;
+ $$$internal$$reject(promise, error);
+ }
+ }, promise);
+ }
+
+ function $$$internal$$handleOwnThenable(promise, thenable) {
+ if (thenable._state === $$$internal$$FULFILLED) {
+ $$$internal$$fulfill(promise, thenable._result);
+ } else if (promise._state === $$$internal$$REJECTED) {
+ $$$internal$$reject(promise, thenable._result);
+ } else {
+ $$$internal$$subscribe(thenable, undefined, function(value) {
+ $$$internal$$resolve(promise, value);
+ }, function(reason) {
+ $$$internal$$reject(promise, reason);
+ });
+ }
+ }
+
+ function $$$internal$$handleMaybeThenable(promise, maybeThenable) {
+ if (maybeThenable.constructor === promise.constructor) {
+ $$$internal$$handleOwnThenable(promise, maybeThenable);
+ } else {
+ var then = $$$internal$$getThen(maybeThenable);
+
+ if (then === $$$internal$$GET_THEN_ERROR) {
+ $$$internal$$reject(promise, $$$internal$$GET_THEN_ERROR.error);
+ } else if (then === undefined) {
+ $$$internal$$fulfill(promise, maybeThenable);
+ } else if ($$utils$$isFunction(then)) {
+ $$$internal$$handleForeignThenable(promise, maybeThenable, then);
+ } else {
+ $$$internal$$fulfill(promise, maybeThenable);
+ }
+ }
+ }
+
+ function $$$internal$$resolve(promise, value) {
+ if (promise === value) {
+ $$$internal$$reject(promise, $$$internal$$selfFullfillment());
+ } else if ($$utils$$objectOrFunction(value)) {
+ $$$internal$$handleMaybeThenable(promise, value);
+ } else {
+ $$$internal$$fulfill(promise, value);
+ }
+ }
+
+ function $$$internal$$publishRejection(promise) {
+ if (promise._onerror) {
+ promise._onerror(promise._result);
+ }
+
+ $$$internal$$publish(promise);
+ }
+
+ function $$$internal$$fulfill(promise, value) {
+ if (promise._state !== $$$internal$$PENDING) { return; }
+
+ promise._result = value;
+ promise._state = $$$internal$$FULFILLED;
+
+ if (promise._subscribers.length === 0) {
+ } else {
+ $$asap$$default($$$internal$$publish, promise);
+ }
+ }
+
+ function $$$internal$$reject(promise, reason) {
+ if (promise._state !== $$$internal$$PENDING) { return; }
+ promise._state = $$$internal$$REJECTED;
+ promise._result = reason;
+
+ $$asap$$default($$$internal$$publishRejection, promise);
+ }
+
+ function $$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
+
+ parent._onerror = null;
+
+ subscribers[length] = child;
+ subscribers[length + $$$internal$$FULFILLED] = onFulfillment;
+ subscribers[length + $$$internal$$REJECTED] = onRejection;
+
+ if (length === 0 && parent._state) {
+ $$asap$$default($$$internal$$publish, parent);
+ }
+ }
+
+ function $$$internal$$publish(promise) {
+ var subscribers = promise._subscribers;
+ var settled = promise._state;
+
+ if (subscribers.length === 0) { return; }
+
+ var child, callback, detail = promise._result;
+
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
+
+ if (child) {
+ $$$internal$$invokeCallback(settled, child, callback, detail);
+ } else {
+ callback(detail);
+ }
+ }
+
+ promise._subscribers.length = 0;
+ }
+
+ function $$$internal$$ErrorObject() {
+ this.error = null;
+ }
+
+ var $$$internal$$TRY_CATCH_ERROR = new $$$internal$$ErrorObject();
+
+ function $$$internal$$tryCatch(callback, detail) {
+ try {
+ return callback(detail);
+ } catch(e) {
+ $$$internal$$TRY_CATCH_ERROR.error = e;
+ return $$$internal$$TRY_CATCH_ERROR;
+ }
+ }
+
+ function $$$internal$$invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = $$utils$$isFunction(callback),
+ value, error, succeeded, failed;
+
+ if (hasCallback) {
+ value = $$$internal$$tryCatch(callback, detail);
+
+ if (value === $$$internal$$TRY_CATCH_ERROR) {
+ failed = true;
+ error = value.error;
+ value = null;
+ } else {
+ succeeded = true;
+ }
+
+ if (promise === value) {
+ $$$internal$$reject(promise, $$$internal$$cannotReturnOwn());
+ return;
+ }
+
+ } else {
+ value = detail;
+ succeeded = true;
+ }
+
+ if (promise._state !== $$$internal$$PENDING) {
+ // noop
+ } else if (hasCallback && succeeded) {
+ $$$internal$$resolve(promise, value);
+ } else if (failed) {
+ $$$internal$$reject(promise, error);
+ } else if (settled === $$$internal$$FULFILLED) {
+ $$$internal$$fulfill(promise, value);
+ } else if (settled === $$$internal$$REJECTED) {
+ $$$internal$$reject(promise, value);
+ }
+ }
+
+ function $$$internal$$initializePromise(promise, resolver) {
+ try {
+ resolver(function resolvePromise(value){
+ $$$internal$$resolve(promise, value);
+ }, function rejectPromise(reason) {
+ $$$internal$$reject(promise, reason);
+ });
+ } catch(e) {
+ $$$internal$$reject(promise, e);
+ }
+ }
+
+ function $$$enumerator$$makeSettledResult(state, position, value) {
+ if (state === $$$internal$$FULFILLED) {
+ return {
+ state: 'fulfilled',
+ value: value
+ };
+ } else {
+ return {
+ state: 'rejected',
+ reason: value
+ };
+ }
+ }
+
+ function $$$enumerator$$Enumerator(Constructor, input, abortOnReject, label) {
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor($$$internal$$noop, label);
+ this._abortOnReject = abortOnReject;
+
+ if (this._validateInput(input)) {
+ this._input = input;
+ this.length = input.length;
+ this._remaining = input.length;
+
+ this._init();
+
+ if (this.length === 0) {
+ $$$internal$$fulfill(this.promise, this._result);
+ } else {
+ this.length = this.length || 0;
+ this._enumerate();
+ if (this._remaining === 0) {
+ $$$internal$$fulfill(this.promise, this._result);
+ }
+ }
+ } else {
+ $$$internal$$reject(this.promise, this._validationError());
+ }
+ }
+
+ $$$enumerator$$Enumerator.prototype._validateInput = function(input) {
+ return $$utils$$isArray(input);
+ };
+
+ $$$enumerator$$Enumerator.prototype._validationError = function() {
+ return new Error('Array Methods must be provided an Array');
+ };
+
+ $$$enumerator$$Enumerator.prototype._init = function() {
+ this._result = new Array(this.length);
+ };
+
+ var $$$enumerator$$default = $$$enumerator$$Enumerator;
+
+ $$$enumerator$$Enumerator.prototype._enumerate = function() {
+ var length = this.length;
+ var promise = this.promise;
+ var input = this._input;
+
+ for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) {
+ this._eachEntry(input[i], i);
+ }
+ };
+
+ $$$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
+ var c = this._instanceConstructor;
+ if ($$utils$$isMaybeThenable(entry)) {
+ if (entry.constructor === c && entry._state !== $$$internal$$PENDING) {
+ entry._onerror = null;
+ this._settledAt(entry._state, i, entry._result);
+ } else {
+ this._willSettleAt(c.resolve(entry), i);
+ }
+ } else {
+ this._remaining--;
+ this._result[i] = this._makeResult($$$internal$$FULFILLED, i, entry);
+ }
+ };
+
+ $$$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
+ var promise = this.promise;
+
+ if (promise._state === $$$internal$$PENDING) {
+ this._remaining--;
+
+ if (this._abortOnReject && state === $$$internal$$REJECTED) {
+ $$$internal$$reject(promise, value);
+ } else {
+ this._result[i] = this._makeResult(state, i, value);
+ }
+ }
+
+ if (this._remaining === 0) {
+ $$$internal$$fulfill(promise, this._result);
+ }
+ };
+
+ $$$enumerator$$Enumerator.prototype._makeResult = function(state, i, value) {
+ return value;
+ };
+
+ $$$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
+ var enumerator = this;
+
+ $$$internal$$subscribe(promise, undefined, function(value) {
+ enumerator._settledAt($$$internal$$FULFILLED, i, value);
+ }, function(reason) {
+ enumerator._settledAt($$$internal$$REJECTED, i, reason);
+ });
+ };
+
+ var $$promise$all$$default = function all(entries, label) {
+ return new $$$enumerator$$default(this, entries, true /* abort on reject */, label).promise;
+ };
+
+ var $$promise$race$$default = function race(entries, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ var promise = new Constructor($$$internal$$noop, label);
+
+ if (!$$utils$$isArray(entries)) {
+ $$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
+ return promise;
+ }
+
+ var length = entries.length;
+
+ function onFulfillment(value) {
+ $$$internal$$resolve(promise, value);
+ }
+
+ function onRejection(reason) {
+ $$$internal$$reject(promise, reason);
+ }
+
+ for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) {
+ $$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
+ }
+
+ return promise;
+ };
+
+ var $$promise$resolve$$default = function resolve(object, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
+
+ var promise = new Constructor($$$internal$$noop, label);
+ $$$internal$$resolve(promise, object);
+ return promise;
+ };
+
+ var $$promise$reject$$default = function reject(reason, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor($$$internal$$noop, label);
+ $$$internal$$reject(promise, reason);
+ return promise;
+ };
+
+ var $$es6$promise$promise$$counter = 0;
+
+ function $$es6$promise$promise$$needsResolver() {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+ }
+
+ function $$es6$promise$promise$$needsNew() {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
+ }
+
+ var $$es6$promise$promise$$default = $$es6$promise$promise$$Promise;
+
+ /**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise’s eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable.
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ }
+ }
+ };
+ });
+ }
+
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class Promise
+ @param {function} resolver
+ Useful for tooling.
+ @constructor
+ */
+ function $$es6$promise$promise$$Promise(resolver) {
+ this._id = $$es6$promise$promise$$counter++;
+ this._state = undefined;
+ this._result = undefined;
+ this._subscribers = [];
+
+ if ($$$internal$$noop !== resolver) {
+ if (!$$utils$$isFunction(resolver)) {
+ $$es6$promise$promise$$needsResolver();
+ }
+
+ if (!(this instanceof $$es6$promise$promise$$Promise)) {
+ $$es6$promise$promise$$needsNew();
+ }
+
+ $$$internal$$initializePromise(this, resolver);
+ }
+ }
+
+ $$es6$promise$promise$$Promise.all = $$promise$all$$default;
+ $$es6$promise$promise$$Promise.race = $$promise$race$$default;
+ $$es6$promise$promise$$Promise.resolve = $$promise$resolve$$default;
+ $$es6$promise$promise$$Promise.reject = $$promise$reject$$default;
+
+ $$es6$promise$promise$$Promise.prototype = {
+ constructor: $$es6$promise$promise$$Promise,
+
+ /**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, 'downstream'
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return 'default name';
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `'default name'`
+ });
+
+ findUser().then(function (user) {
+ throw new Error('Found user, but still unhappy');
+ }, function (reason) {
+ throw new Error('`findUser` rejected and we're unhappy');
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException('Upstream error');
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var result;
+
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+ }
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfilled
+ @param {Function} onRejected
+ Useful for tooling.
+ @return {Promise}
+ */
+ then: function(onFulfillment, onRejection) {
+ var parent = this;
+ var state = parent._state;
+
+ if (state === $$$internal$$FULFILLED && !onFulfillment || state === $$$internal$$REJECTED && !onRejection) {
+ return this;
+ }
+
+ var child = new this.constructor($$$internal$$noop);
+ var result = parent._result;
+
+ if (state) {
+ var callback = arguments[state - 1];
+ $$asap$$default(function(){
+ $$$internal$$invokeCallback(state, child, callback, result);
+ });
+ } else {
+ $$$internal$$subscribe(parent, child, onFulfillment, onRejection);
+ }
+
+ return child;
+ },
+
+ /**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error('couldn't find that author');
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ Useful for tooling.
+ @return {Promise}
+ */
+ 'catch': function(onRejection) {
+ return this.then(null, onRejection);
+ }
+ };
+
+ var $$es6$promise$polyfill$$default = function polyfill() {
+ var local;
+
+ if (typeof global !== 'undefined') {
+ local = global;
+ } else if (typeof window !== 'undefined' && window.document) {
+ local = window;
+ } else {
+ local = self;
+ }
+
+ var es6PromiseSupport =
+ "Promise" in local &&
+ // Some of these methods are missing from
+ // Firefox/Chrome experimental implementations
+ "resolve" in local.Promise &&
+ "reject" in local.Promise &&
+ "all" in local.Promise &&
+ "race" in local.Promise &&
+ // Older version of the spec had a resolver object
+ // as the arg rather than a function
+ (function() {
+ var resolve;
+ new local.Promise(function(r) { resolve = r; });
+ return $$utils$$isFunction(resolve);
+ }());
+
+ if (!es6PromiseSupport) {
+ local.Promise = $$es6$promise$promise$$default;
+ }
+ };
+
+ var es6$promise$umd$$ES6Promise = {
+ 'Promise': $$es6$promise$promise$$default,
+ 'polyfill': $$es6$promise$polyfill$$default
+ };
+
+ /* global define:true module:true window: true */
+ if (typeof define === 'function' && define['amd']) {
+ define(function() { return es6$promise$umd$$ES6Promise; });
+ } else if (typeof module !== 'undefined' && module['exports']) {
+ module['exports'] = es6$promise$umd$$ES6Promise;
+ } else if (typeof this !== 'undefined') {
+ this['ES6Promise'] = es6$promise$umd$$ES6Promise;
+ }
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/dist/es6-promise.min.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/dist/es6-promise.min.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/dist/es6-promise.min.js
new file mode 100644
index 0000000..6e0c99f
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/dist/es6-promise.min.js
@@ -0,0 +1,18 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version 2.0.1
+ */
+
+(function(){function r(a,b){n[l]=a;n[l+1]=b;l+=2;2===l&&A()}function s(a){return"function"===typeof a}function F(){return function(){process.nextTick(t)}}function G(){var a=0,b=new B(t),c=document.createTextNode("");b.observe(c,{characterData:!0});return function(){c.data=a=++a%2}}function H(){var a=new MessageChannel;a.port1.onmessage=t;return function(){a.port2.postMessage(0)}}function I(){return function(){setTimeout(t,1)}}function t(){for(var a=0;a<l;a+=2)(0,n[a])(n[a+1]),n[a]=void 0,n[a+1]=void 0;
+l=0}function p(){}function J(a,b,c,d){try{a.call(b,c,d)}catch(e){return e}}function K(a,b,c){r(function(a){var e=!1,f=J(c,b,function(c){e||(e=!0,b!==c?q(a,c):m(a,c))},function(b){e||(e=!0,g(a,b))});!e&&f&&(e=!0,g(a,f))},a)}function L(a,b){1===b.a?m(a,b.b):2===a.a?g(a,b.b):u(b,void 0,function(b){q(a,b)},function(b){g(a,b)})}function q(a,b){if(a===b)g(a,new TypeError("You cannot resolve a promise with itself"));else if("function"===typeof b||"object"===typeof b&&null!==b)if(b.constructor===a.constructor)L(a,
+b);else{var c;try{c=b.then}catch(d){v.error=d,c=v}c===v?g(a,v.error):void 0===c?m(a,b):s(c)?K(a,b,c):m(a,b)}else m(a,b)}function M(a){a.f&&a.f(a.b);x(a)}function m(a,b){void 0===a.a&&(a.b=b,a.a=1,0!==a.e.length&&r(x,a))}function g(a,b){void 0===a.a&&(a.a=2,a.b=b,r(M,a))}function u(a,b,c,d){var e=a.e,f=e.length;a.f=null;e[f]=b;e[f+1]=c;e[f+2]=d;0===f&&a.a&&r(x,a)}function x(a){var b=a.e,c=a.a;if(0!==b.length){for(var d,e,f=a.b,g=0;g<b.length;g+=3)d=b[g],e=b[g+c],d?C(c,d,e,f):e(f);a.e.length=0}}function D(){this.error=
+null}function C(a,b,c,d){var e=s(c),f,k,h,l;if(e){try{f=c(d)}catch(n){y.error=n,f=y}f===y?(l=!0,k=f.error,f=null):h=!0;if(b===f){g(b,new TypeError("A promises callback cannot return that same promise."));return}}else f=d,h=!0;void 0===b.a&&(e&&h?q(b,f):l?g(b,k):1===a?m(b,f):2===a&&g(b,f))}function N(a,b){try{b(function(b){q(a,b)},function(b){g(a,b)})}catch(c){g(a,c)}}function k(a,b,c,d){this.n=a;this.c=new a(p,d);this.i=c;this.o(b)?(this.m=b,this.d=this.length=b.length,this.l(),0===this.length?m(this.c,
+this.b):(this.length=this.length||0,this.k(),0===this.d&&m(this.c,this.b))):g(this.c,this.p())}function h(a){O++;this.b=this.a=void 0;this.e=[];if(p!==a){if(!s(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof h))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");N(this,a)}}var E=Array.isArray?Array.isArray:function(a){return"[object Array]"===
+Object.prototype.toString.call(a)},l=0,w="undefined"!==typeof window?window:{},B=w.MutationObserver||w.WebKitMutationObserver,w="undefined"!==typeof Uint8ClampedArray&&"undefined"!==typeof importScripts&&"undefined"!==typeof MessageChannel,n=Array(1E3),A;A="undefined"!==typeof process&&"[object process]"==={}.toString.call(process)?F():B?G():w?H():I();var v=new D,y=new D;k.prototype.o=function(a){return E(a)};k.prototype.p=function(){return Error("Array Methods must be provided an Array")};k.prototype.l=
+function(){this.b=Array(this.length)};k.prototype.k=function(){for(var a=this.length,b=this.c,c=this.m,d=0;void 0===b.a&&d<a;d++)this.j(c[d],d)};k.prototype.j=function(a,b){var c=this.n;"object"===typeof a&&null!==a?a.constructor===c&&void 0!==a.a?(a.f=null,this.g(a.a,b,a.b)):this.q(c.resolve(a),b):(this.d--,this.b[b]=this.h(a))};k.prototype.g=function(a,b,c){var d=this.c;void 0===d.a&&(this.d--,this.i&&2===a?g(d,c):this.b[b]=this.h(c));0===this.d&&m(d,this.b)};k.prototype.h=function(a){return a};
+k.prototype.q=function(a,b){var c=this;u(a,void 0,function(a){c.g(1,b,a)},function(a){c.g(2,b,a)})};var O=0;h.all=function(a,b){return(new k(this,a,!0,b)).c};h.race=function(a,b){function c(a){q(e,a)}function d(a){g(e,a)}var e=new this(p,b);if(!E(a))return (g(e,new TypeError("You must pass an array to race.")), e);for(var f=a.length,h=0;void 0===e.a&&h<f;h++)u(this.resolve(a[h]),void 0,c,d);return e};h.resolve=function(a,b){if(a&&"object"===typeof a&&a.constructor===this)return a;var c=new this(p,b);
+q(c,a);return c};h.reject=function(a,b){var c=new this(p,b);g(c,a);return c};h.prototype={constructor:h,then:function(a,b){var c=this.a;if(1===c&&!a||2===c&&!b)return this;var d=new this.constructor(p),e=this.b;if(c){var f=arguments[c-1];r(function(){C(c,d,f,e)})}else u(this,d,a,b);return d},"catch":function(a){return this.then(null,a)}};var z={Promise:h,polyfill:function(){var a;a="undefined"!==typeof global?global:"undefined"!==typeof window&&window.document?window:self;"Promise"in a&&"resolve"in
+a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;new a.Promise(function(a){b=a});return s(b)}()||(a.Promise=h)}};"function"===typeof define&&define.amd?define(function(){return z}):"undefined"!==typeof module&&module.exports?module.exports=z:"undefined"!==typeof this&&(this.ES6Promise=z)}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/calculateVersion.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/calculateVersion.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/calculateVersion.js
new file mode 100644
index 0000000..018e364
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/calculateVersion.js
@@ -0,0 +1,36 @@
+'use strict';
+
+var fs = require('fs');
+var path = require('path');
+
+module.exports = function () {
+ var packageVersion = require('../package.json').version;
+ var output = [packageVersion];
+ var gitPath = path.join(__dirname,'..','.git');
+ var headFilePath = path.join(gitPath, 'HEAD');
+
+ if (packageVersion.indexOf('+') > -1) {
+ try {
+ if (fs.existsSync(headFilePath)) {
+ var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'});
+ var branchName = headFile.split('/').slice(-1)[0].trim();
+ var refPath = headFile.split(' ')[1];
+ var branchSHA;
+
+ if (refPath) {
+ var branchPath = path.join(gitPath, refPath.trim());
+ branchSHA = fs.readFileSync(branchPath);
+ } else {
+ branchSHA = branchName;
+ }
+
+ output.push(branchSHA.slice(0,10));
+ }
+ } catch (err) {
+ console.error(err.stack);
+ }
+ return output.join('.');
+ } else {
+ return packageVersion;
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise.umd.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise.umd.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise.umd.js
new file mode 100644
index 0000000..cd01553
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise.umd.js
@@ -0,0 +1,16 @@
+import Promise from './es6-promise/promise';
+import polyfill from './es6-promise/polyfill';
+
+var ES6Promise = {
+ 'Promise': Promise,
+ 'polyfill': polyfill
+};
+
+/* global define:true module:true window: true */
+if (typeof define === 'function' && define['amd']) {
+ define(function() { return ES6Promise; });
+} else if (typeof module !== 'undefined' && module['exports']) {
+ module['exports'] = ES6Promise;
+} else if (typeof this !== 'undefined') {
+ this['ES6Promise'] = ES6Promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/-internal.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/-internal.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/-internal.js
new file mode 100644
index 0000000..afef22e
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/-internal.js
@@ -0,0 +1,251 @@
+import {
+ objectOrFunction,
+ isFunction
+} from './utils';
+
+import asap from './asap';
+
+function noop() {}
+
+var PENDING = void 0;
+var FULFILLED = 1;
+var REJECTED = 2;
+
+var GET_THEN_ERROR = new ErrorObject();
+
+function selfFullfillment() {
+ return new TypeError("You cannot resolve a promise with itself");
+}
+
+function cannotReturnOwn() {
+ return new TypeError('A promises callback cannot return that same promise.')
+}
+
+function getThen(promise) {
+ try {
+ return promise.then;
+ } catch(error) {
+ GET_THEN_ERROR.error = error;
+ return GET_THEN_ERROR;
+ }
+}
+
+function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
+ try {
+ then.call(value, fulfillmentHandler, rejectionHandler);
+ } catch(e) {
+ return e;
+ }
+}
+
+function handleForeignThenable(promise, thenable, then) {
+ asap(function(promise) {
+ var sealed = false;
+ var error = tryThen(then, thenable, function(value) {
+ if (sealed) { return; }
+ sealed = true;
+ if (thenable !== value) {
+ resolve(promise, value);
+ } else {
+ fulfill(promise, value);
+ }
+ }, function(reason) {
+ if (sealed) { return; }
+ sealed = true;
+
+ reject(promise, reason);
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
+
+ if (!sealed && error) {
+ sealed = true;
+ reject(promise, error);
+ }
+ }, promise);
+}
+
+function handleOwnThenable(promise, thenable) {
+ if (thenable._state === FULFILLED) {
+ fulfill(promise, thenable._result);
+ } else if (promise._state === REJECTED) {
+ reject(promise, thenable._result);
+ } else {
+ subscribe(thenable, undefined, function(value) {
+ resolve(promise, value);
+ }, function(reason) {
+ reject(promise, reason);
+ });
+ }
+}
+
+function handleMaybeThenable(promise, maybeThenable) {
+ if (maybeThenable.constructor === promise.constructor) {
+ handleOwnThenable(promise, maybeThenable);
+ } else {
+ var then = getThen(maybeThenable);
+
+ if (then === GET_THEN_ERROR) {
+ reject(promise, GET_THEN_ERROR.error);
+ } else if (then === undefined) {
+ fulfill(promise, maybeThenable);
+ } else if (isFunction(then)) {
+ handleForeignThenable(promise, maybeThenable, then);
+ } else {
+ fulfill(promise, maybeThenable);
+ }
+ }
+}
+
+function resolve(promise, value) {
+ if (promise === value) {
+ reject(promise, selfFullfillment());
+ } else if (objectOrFunction(value)) {
+ handleMaybeThenable(promise, value);
+ } else {
+ fulfill(promise, value);
+ }
+}
+
+function publishRejection(promise) {
+ if (promise._onerror) {
+ promise._onerror(promise._result);
+ }
+
+ publish(promise);
+}
+
+function fulfill(promise, value) {
+ if (promise._state !== PENDING) { return; }
+
+ promise._result = value;
+ promise._state = FULFILLED;
+
+ if (promise._subscribers.length === 0) {
+ } else {
+ asap(publish, promise);
+ }
+}
+
+function reject(promise, reason) {
+ if (promise._state !== PENDING) { return; }
+ promise._state = REJECTED;
+ promise._result = reason;
+
+ asap(publishRejection, promise);
+}
+
+function subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
+
+ parent._onerror = null;
+
+ subscribers[length] = child;
+ subscribers[length + FULFILLED] = onFulfillment;
+ subscribers[length + REJECTED] = onRejection;
+
+ if (length === 0 && parent._state) {
+ asap(publish, parent);
+ }
+}
+
+function publish(promise) {
+ var subscribers = promise._subscribers;
+ var settled = promise._state;
+
+ if (subscribers.length === 0) { return; }
+
+ var child, callback, detail = promise._result;
+
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
+
+ if (child) {
+ invokeCallback(settled, child, callback, detail);
+ } else {
+ callback(detail);
+ }
+ }
+
+ promise._subscribers.length = 0;
+}
+
+function ErrorObject() {
+ this.error = null;
+}
+
+var TRY_CATCH_ERROR = new ErrorObject();
+
+function tryCatch(callback, detail) {
+ try {
+ return callback(detail);
+ } catch(e) {
+ TRY_CATCH_ERROR.error = e;
+ return TRY_CATCH_ERROR;
+ }
+}
+
+function invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = isFunction(callback),
+ value, error, succeeded, failed;
+
+ if (hasCallback) {
+ value = tryCatch(callback, detail);
+
+ if (value === TRY_CATCH_ERROR) {
+ failed = true;
+ error = value.error;
+ value = null;
+ } else {
+ succeeded = true;
+ }
+
+ if (promise === value) {
+ reject(promise, cannotReturnOwn());
+ return;
+ }
+
+ } else {
+ value = detail;
+ succeeded = true;
+ }
+
+ if (promise._state !== PENDING) {
+ // noop
+ } else if (hasCallback && succeeded) {
+ resolve(promise, value);
+ } else if (failed) {
+ reject(promise, error);
+ } else if (settled === FULFILLED) {
+ fulfill(promise, value);
+ } else if (settled === REJECTED) {
+ reject(promise, value);
+ }
+}
+
+function initializePromise(promise, resolver) {
+ try {
+ resolver(function resolvePromise(value){
+ resolve(promise, value);
+ }, function rejectPromise(reason) {
+ reject(promise, reason);
+ });
+ } catch(e) {
+ reject(promise, e);
+ }
+}
+
+export {
+ noop,
+ resolve,
+ reject,
+ fulfill,
+ subscribe,
+ publish,
+ publishRejection,
+ initializePromise,
+ invokeCallback,
+ FULFILLED,
+ REJECTED,
+ PENDING
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/asap.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/asap.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/asap.js
new file mode 100644
index 0000000..4872589
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/asap.js
@@ -0,0 +1,82 @@
+var len = 0;
+
+export default function asap(callback, arg) {
+ queue[len] = callback;
+ queue[len + 1] = arg;
+ len += 2;
+ if (len === 2) {
+ // If len is 1, that means that we need to schedule an async flush.
+ // If additional callbacks are queued before the queue is flushed, they
+ // will be processed by this flush that we are scheduling.
+ scheduleFlush();
+ }
+}
+
+var browserGlobal = (typeof window !== 'undefined') ? window : {};
+var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
+
+// test for web worker but not in IE10
+var isWorker = typeof Uint8ClampedArray !== 'undefined' &&
+ typeof importScripts !== 'undefined' &&
+ typeof MessageChannel !== 'undefined';
+
+// node
+function useNextTick() {
+ return function() {
+ process.nextTick(flush);
+ };
+}
+
+function useMutationObserver() {
+ var iterations = 0;
+ var observer = new BrowserMutationObserver(flush);
+ var node = document.createTextNode('');
+ observer.observe(node, { characterData: true });
+
+ return function() {
+ node.data = (iterations = ++iterations % 2);
+ };
+}
+
+// web worker
+function useMessageChannel() {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = flush;
+ return function () {
+ channel.port2.postMessage(0);
+ };
+}
+
+function useSetTimeout() {
+ return function() {
+ setTimeout(flush, 1);
+ };
+}
+
+var queue = new Array(1000);
+function flush() {
+ for (var i = 0; i < len; i+=2) {
+ var callback = queue[i];
+ var arg = queue[i+1];
+
+ callback(arg);
+
+ queue[i] = undefined;
+ queue[i+1] = undefined;
+ }
+
+ len = 0;
+}
+
+var scheduleFlush;
+
+// Decide what async method to use to triggering processing of queued callbacks:
+if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
+ scheduleFlush = useNextTick();
+} else if (BrowserMutationObserver) {
+ scheduleFlush = useMutationObserver();
+} else if (isWorker) {
+ scheduleFlush = useMessageChannel();
+} else {
+ scheduleFlush = useSetTimeout();
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/enumerator.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/enumerator.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/enumerator.js
new file mode 100644
index 0000000..7d3f803
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/enumerator.js
@@ -0,0 +1,125 @@
+import {
+ isArray,
+ isMaybeThenable
+} from './utils';
+
+import {
+ noop,
+ reject,
+ fulfill,
+ subscribe,
+ FULFILLED,
+ REJECTED,
+ PENDING
+} from './-internal';
+
+export function makeSettledResult(state, position, value) {
+ if (state === FULFILLED) {
+ return {
+ state: 'fulfilled',
+ value: value
+ };
+ } else {
+ return {
+ state: 'rejected',
+ reason: value
+ };
+ }
+}
+
+function Enumerator(Constructor, input, abortOnReject, label) {
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor(noop, label);
+ this._abortOnReject = abortOnReject;
+
+ if (this._validateInput(input)) {
+ this._input = input;
+ this.length = input.length;
+ this._remaining = input.length;
+
+ this._init();
+
+ if (this.length === 0) {
+ fulfill(this.promise, this._result);
+ } else {
+ this.length = this.length || 0;
+ this._enumerate();
+ if (this._remaining === 0) {
+ fulfill(this.promise, this._result);
+ }
+ }
+ } else {
+ reject(this.promise, this._validationError());
+ }
+}
+
+Enumerator.prototype._validateInput = function(input) {
+ return isArray(input);
+};
+
+Enumerator.prototype._validationError = function() {
+ return new Error('Array Methods must be provided an Array');
+};
+
+Enumerator.prototype._init = function() {
+ this._result = new Array(this.length);
+};
+
+export default Enumerator;
+
+Enumerator.prototype._enumerate = function() {
+ var length = this.length;
+ var promise = this.promise;
+ var input = this._input;
+
+ for (var i = 0; promise._state === PENDING && i < length; i++) {
+ this._eachEntry(input[i], i);
+ }
+};
+
+Enumerator.prototype._eachEntry = function(entry, i) {
+ var c = this._instanceConstructor;
+ if (isMaybeThenable(entry)) {
+ if (entry.constructor === c && entry._state !== PENDING) {
+ entry._onerror = null;
+ this._settledAt(entry._state, i, entry._result);
+ } else {
+ this._willSettleAt(c.resolve(entry), i);
+ }
+ } else {
+ this._remaining--;
+ this._result[i] = this._makeResult(FULFILLED, i, entry);
+ }
+};
+
+Enumerator.prototype._settledAt = function(state, i, value) {
+ var promise = this.promise;
+
+ if (promise._state === PENDING) {
+ this._remaining--;
+
+ if (this._abortOnReject && state === REJECTED) {
+ reject(promise, value);
+ } else {
+ this._result[i] = this._makeResult(state, i, value);
+ }
+ }
+
+ if (this._remaining === 0) {
+ fulfill(promise, this._result);
+ }
+};
+
+Enumerator.prototype._makeResult = function(state, i, value) {
+ return value;
+};
+
+Enumerator.prototype._willSettleAt = function(promise, i) {
+ var enumerator = this;
+
+ subscribe(promise, undefined, function(value) {
+ enumerator._settledAt(FULFILLED, i, value);
+ }, function(reason) {
+ enumerator._settledAt(REJECTED, i, reason);
+ });
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/polyfill.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/polyfill.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/polyfill.js
new file mode 100644
index 0000000..e5b0165
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/polyfill.js
@@ -0,0 +1,35 @@
+/*global self*/
+import { default as RSVPPromise } from "./promise";
+import { isFunction } from "./utils";
+
+export default function polyfill() {
+ var local;
+
+ if (typeof global !== 'undefined') {
+ local = global;
+ } else if (typeof window !== 'undefined' && window.document) {
+ local = window;
+ } else {
+ local = self;
+ }
+
+ var es6PromiseSupport =
+ "Promise" in local &&
+ // Some of these methods are missing from
+ // Firefox/Chrome experimental implementations
+ "resolve" in local.Promise &&
+ "reject" in local.Promise &&
+ "all" in local.Promise &&
+ "race" in local.Promise &&
+ // Older version of the spec had a resolver object
+ // as the arg rather than a function
+ (function() {
+ var resolve;
+ new local.Promise(function(r) { resolve = r; });
+ return isFunction(resolve);
+ }());
+
+ if (!es6PromiseSupport) {
+ local.Promise = RSVPPromise;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise.js
new file mode 100644
index 0000000..5e865a7
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise.js
@@ -0,0 +1,409 @@
+import {
+ isFunction,
+ now
+} from './utils';
+
+import {
+ noop,
+ subscribe,
+ initializePromise,
+ invokeCallback,
+ FULFILLED,
+ REJECTED
+} from './-internal';
+
+import asap from './asap';
+
+import all from './promise/all';
+import race from './promise/race';
+import Resolve from './promise/resolve';
+import Reject from './promise/reject';
+
+var counter = 0;
+
+function needsResolver() {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+}
+
+function needsNew() {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
+}
+
+export default Promise;
+/**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise’s eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable.
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ }
+ }
+ };
+ });
+ }
+
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class Promise
+ @param {function} resolver
+ Useful for tooling.
+ @constructor
+*/
+function Promise(resolver) {
+ this._id = counter++;
+ this._state = undefined;
+ this._result = undefined;
+ this._subscribers = [];
+
+ if (noop !== resolver) {
+ if (!isFunction(resolver)) {
+ needsResolver();
+ }
+
+ if (!(this instanceof Promise)) {
+ needsNew();
+ }
+
+ initializePromise(this, resolver);
+ }
+}
+
+Promise.all = all;
+Promise.race = race;
+Promise.resolve = Resolve;
+Promise.reject = Reject;
+
+Promise.prototype = {
+ constructor: Promise,
+
+/**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, 'downstream'
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return 'default name';
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `'default name'`
+ });
+
+ findUser().then(function (user) {
+ throw new Error('Found user, but still unhappy');
+ }, function (reason) {
+ throw new Error('`findUser` rejected and we're unhappy');
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException('Upstream error');
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var result;
+
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+ }
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfilled
+ @param {Function} onRejected
+ Useful for tooling.
+ @return {Promise}
+*/
+ then: function(onFulfillment, onRejection) {
+ var parent = this;
+ var state = parent._state;
+
+ if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) {
+ return this;
+ }
+
+ var child = new this.constructor(noop);
+ var result = parent._result;
+
+ if (state) {
+ var callback = arguments[state - 1];
+ asap(function(){
+ invokeCallback(state, child, callback, result);
+ });
+ } else {
+ subscribe(parent, child, onFulfillment, onRejection);
+ }
+
+ return child;
+ },
+
+/**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error('couldn't find that author');
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ Useful for tooling.
+ @return {Promise}
+*/
+ 'catch': function(onRejection) {
+ return this.then(null, onRejection);
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/all.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/all.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/all.js
new file mode 100644
index 0000000..8db7e71
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/all.js
@@ -0,0 +1,52 @@
+import Enumerator from '../enumerator';
+
+/**
+ `Promise.all` accepts an array of promises, and returns a new promise which
+ is fulfilled with an array of fulfillment values for the passed promises, or
+ rejected with the reason of the first passed promise to be rejected. It casts all
+ elements of the passed iterable to promises as it runs this algorithm.
+
+ Example:
+
+ ```javascript
+ var promise1 = resolve(1);
+ var promise2 = resolve(2);
+ var promise3 = resolve(3);
+ var promises = [ promise1, promise2, promise3 ];
+
+ Promise.all(promises).then(function(array){
+ // The array here would be [ 1, 2, 3 ];
+ });
+ ```
+
+ If any of the `promises` given to `all` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promises's
+ rejection handler. For example:
+
+ Example:
+
+ ```javascript
+ var promise1 = resolve(1);
+ var promise2 = reject(new Error("2"));
+ var promise3 = reject(new Error("3"));
+ var promises = [ promise1, promise2, promise3 ];
+
+ Promise.all(promises).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(error) {
+ // error.message === "2"
+ });
+ ```
+
+ @method all
+ @static
+ @param {Array} entries array of promises
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled when all `promises` have been
+ fulfilled, or rejected if any of them become rejected.
+ @static
+*/
+export default function all(entries, label) {
+ return new Enumerator(this, entries, true /* abort on reject */, label).promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/race.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/race.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/race.js
new file mode 100644
index 0000000..7daa28a
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/race.js
@@ -0,0 +1,105 @@
+import {
+ isArray
+} from "../utils";
+
+import {
+ noop,
+ resolve,
+ reject,
+ subscribe,
+ PENDING
+} from '../-internal';
+
+/**
+ `Promise.race` returns a new promise which is settled in the same way as the
+ first passed promise to settle.
+
+ Example:
+
+ ```javascript
+ var promise1 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 2');
+ }, 100);
+ });
+
+ Promise.race([promise1, promise2]).then(function(result){
+ // result === 'promise 2' because it was resolved before promise1
+ // was resolved.
+ });
+ ```
+
+ `Promise.race` is deterministic in that only the state of the first
+ settled promise matters. For example, even if other promises given to the
+ `promises` array argument are resolved, but the first settled promise has
+ become rejected before the other promises became fulfilled, the returned
+ promise will become rejected:
+
+ ```javascript
+ var promise1 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ reject(new Error('promise 2'));
+ }, 100);
+ });
+
+ Promise.race([promise1, promise2]).then(function(result){
+ // Code here never runs
+ }, function(reason){
+ // reason.message === 'promise 2' because promise 2 became rejected before
+ // promise 1 became fulfilled
+ });
+ ```
+
+ An example real-world use case is implementing timeouts:
+
+ ```javascript
+ Promise.race([ajax('foo.json'), timeout(5000)])
+ ```
+
+ @method race
+ @static
+ @param {Array} promises array of promises to observe
+ @param {String} label optional string for describing the promise returned.
+ Useful for tooling.
+ @return {Promise} a promise which settles in the same way as the first passed
+ promise to settle.
+*/
+export default function race(entries, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ var promise = new Constructor(noop, label);
+
+ if (!isArray(entries)) {
+ reject(promise, new TypeError('You must pass an array to race.'));
+ return promise;
+ }
+
+ var length = entries.length;
+
+ function onFulfillment(value) {
+ resolve(promise, value);
+ }
+
+ function onRejection(reason) {
+ reject(promise, reason);
+ }
+
+ for (var i = 0; promise._state === PENDING && i < length; i++) {
+ subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
+ }
+
+ return promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/reject.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/reject.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/reject.js
new file mode 100644
index 0000000..518eff7
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/reject.js
@@ -0,0 +1,47 @@
+import {
+ noop,
+ reject as _reject
+} from '../-internal';
+
+/**
+ `Promise.reject` returns a promise rejected with the passed `reason`.
+ It is shorthand for the following:
+
+ ```javascript
+ var promise = new Promise(function(resolve, reject){
+ reject(new Error('WHOOPS'));
+ });
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = Promise.reject(new Error('WHOOPS'));
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ @method reject
+ @static
+ @param {Any} reason value that the returned promise will be rejected with.
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise rejected with the given `reason`.
+*/
+export default function reject(reason, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor(noop, label);
+ _reject(promise, reason);
+ return promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/resolve.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
new file mode 100644
index 0000000..1b3c533
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
@@ -0,0 +1,49 @@
+import {
+ noop,
+ resolve as _resolve
+} from '../-internal';
+
+/**
+ `Promise.resolve` returns a promise that will become resolved with the
+ passed `value`. It is shorthand for the following:
+
+ ```javascript
+ var promise = new Promise(function(resolve, reject){
+ resolve(1);
+ });
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = Promise.resolve(1);
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ @method resolve
+ @static
+ @param {Any} value value that the returned promise will be resolved with
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise that will become fulfilled with the given
+ `value`
+*/
+export default function resolve(object, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
+
+ var promise = new Constructor(noop, label);
+ _resolve(promise, object);
+ return promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/utils.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/utils.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/utils.js
new file mode 100644
index 0000000..6b49bbf
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/lib/es6-promise/utils.js
@@ -0,0 +1,39 @@
+export function objectOrFunction(x) {
+ return typeof x === 'function' || (typeof x === 'object' && x !== null);
+}
+
+export function isFunction(x) {
+ return typeof x === 'function';
+}
+
+export function isMaybeThenable(x) {
+ return typeof x === 'object' && x !== null;
+}
+
+var _isArray;
+if (!Array.isArray) {
+ _isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+} else {
+ _isArray = Array.isArray;
+}
+
+export var isArray = _isArray;
+
+// Date.now is not available in browsers < IE9
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
+export var now = Date.now || function() { return new Date().getTime(); };
+
+function F() { }
+
+export var o_create = (Object.create || function (o) {
+ if (arguments.length > 1) {
+ throw new Error('Second argument not supported');
+ }
+ if (typeof o !== 'object') {
+ throw new TypeError('Argument must be an object');
+ }
+ F.prototype = o;
+ return new F();
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/package.json b/node_modules/node-firefox-find-app/node_modules/es6-promise/package.json
new file mode 100644
index 0000000..28494ce
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/package.json
@@ -0,0 +1,81 @@
+{
+ "name": "es6-promise",
+ "namespace": "es6-promise",
+ "version": "2.0.1",
+ "description": "A lightweight library that provides tools for organizing asynchronous code",
+ "main": "dist/es6-promise.js",
+ "directories": {
+ "lib": "lib"
+ },
+ "devDependencies": {
+ "bower": "^1.3.9",
+ "brfs": "0.0.8",
+ "broccoli-closure-compiler": "^0.2.0",
+ "broccoli-compile-modules": "git+https://github.com/eventualbuddha/broccoli-compile-modules",
+ "broccoli-concat": "0.0.7",
+ "broccoli-es3-safe-recast": "0.0.8",
+ "broccoli-file-mover": "^0.4.0",
+ "broccoli-jshint": "^0.5.1",
+ "broccoli-merge-trees": "^0.1.4",
+ "broccoli-static-compiler": "^0.1.4",
+ "broccoli-string-replace": "0.0.1",
+ "browserify": "^4.2.0",
+ "ember-cli": "0.0.40",
+ "ember-publisher": "0.0.7",
+ "es6-module-transpiler-amd-formatter": "0.0.1",
+ "express": "^4.5.0",
+ "jshint": "~0.9.1",
+ "mkdirp": "^0.5.0",
+ "mocha": "^1.20.1",
+ "promises-aplus-tests": "git://github.com/stefanpenner/promises-tests.git",
+ "release-it": "0.0.10",
+ "testem": "^0.6.17",
+ "json3": "^3.3.2"
+ },
+ "scripts": {
+ "test": "testem ci -R dot",
+ "test-server": "testem",
+ "lint": "jshint lib",
+ "prepublish": "ember build --environment production",
+ "aplus": "browserify test/main.js",
+ "build-all": "ember build --environment production && browserify ./test/main.js -o tmp/test-bundle.js",
+ "dry-run-release": "ember build --environment production && release-it --dry-run --non-interactive"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jakearchibald/ES6-Promises.git"
+ },
+ "bugs": {
+ "url": "https://github.com/jakearchibald/ES6-Promises/issues"
+ },
+ "keywords": [
+ "promises",
+ "futures"
+ ],
+ "author": {
+ "name": "Yehuda Katz, Tom Dale, Stefan Penner and contributors",
+ "url": "Conversion to ES6 API by Jake Archibald"
+ },
+ "license": "MIT",
+ "homepage": "https://github.com/jakearchibald/ES6-Promises",
+ "_id": "es6-promise@2.0.1",
+ "dist": {
+ "shasum": "ccc4963e679f0ca9fb187c777b9e583d3c7573c2",
+ "tarball": "http://registry.npmjs.org/es6-promise/-/es6-promise-2.0.1.tgz"
+ },
+ "_from": "es6-promise@^2.0.1",
+ "_npmVersion": "1.3.24",
+ "_npmUser": {
+ "name": "jaffathecake",
+ "email": "jaffathecake@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "jaffathecake",
+ "email": "jaffathecake@gmail.com"
+ }
+ ],
+ "_shasum": "ccc4963e679f0ca9fb187c777b9e583d3c7573c2",
+ "_resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-2.0.1.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/server/.jshintrc
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/server/.jshintrc b/node_modules/node-firefox-find-app/node_modules/es6-promise/server/.jshintrc
new file mode 100644
index 0000000..c1f2978
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/server/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "node": true
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/server/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/server/index.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/server/index.js
new file mode 100644
index 0000000..8a54d36
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/server/index.js
@@ -0,0 +1,6 @@
+module.exports = function(app) {
+ app.use(require('express').static(__dirname + '/../'));
+ app.get('/', function(req, res) {
+ res.redirect('/test/');
+ })
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/testem.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/testem.json b/node_modules/node-firefox-find-app/node_modules/es6-promise/testem.json
new file mode 100644
index 0000000..7494912
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/testem.json
@@ -0,0 +1,11 @@
+{
+ "test_page": "test/index.html",
+ "parallel": 5,
+ "before_tests": "npm run build-all",
+ "launchers": {
+ "Mocha": {
+ "command": "./node_modules/.bin/mocha test/main.js"
+ }
+ },
+ "launch_in_ci": ["PhantomJS", "Mocha"]
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/package.json b/node_modules/node-firefox-find-app/package.json
new file mode 100644
index 0000000..c062705
--- /dev/null
+++ b/node_modules/node-firefox-find-app/package.json
@@ -0,0 +1,64 @@
+{
+ "name": "node-firefox-find-app",
+ "version": "1.0.0",
+ "description": "Find an installed app on a runtime",
+ "main": "index.js",
+ "scripts": {
+ "gulp": "gulp",
+ "test": "gulp test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/mozilla/node-firefox-find-app.git"
+ },
+ "author": {
+ "name": "Mozilla",
+ "url": "https://mozilla.org/"
+ },
+ "license": "Apache 2",
+ "bugs": {
+ "url": "https://github.com/mozilla/node-firefox-find-app/issues"
+ },
+ "homepage": "https://github.com/mozilla/node-firefox-find-app",
+ "dependencies": {
+ "es6-promise": "^2.0.1"
+ },
+ "keywords": [
+ "apps",
+ "webapps",
+ "b2g",
+ "firefoxos",
+ "fxos",
+ "firefox os"
+ ],
+ "devDependencies": {
+ "gulp": "^3.8.10",
+ "node-firefox-build-tools": "^0.1.0",
+ "node-firefox-connect": "^1.0.0",
+ "node-firefox-start-simulator": "^1.1.0",
+ "should": "^4.0.4"
+ },
+ "gitHead": "9105b904630df908fedb72e354088e17d09f49ea",
+ "_id": "node-firefox-find-app@1.0.0",
+ "_shasum": "c6fa1693e59bd9af77cdf812d8f9bdd943a4b30e",
+ "_from": "node-firefox-find-app@",
+ "_npmVersion": "2.1.6",
+ "_nodeVersion": "0.10.33",
+ "_npmUser": {
+ "name": "sole",
+ "email": "listas@soledadpenades.com"
+ },
+ "maintainers": [
+ {
+ "name": "sole",
+ "email": "listas@soledadpenades.com"
+ }
+ ],
+ "dist": {
+ "shasum": "c6fa1693e59bd9af77cdf812d8f9bdd943a4b30e",
+ "tarball": "http://registry.npmjs.org/node-firefox-find-app/-/node-firefox-find-app-1.0.0.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/node-firefox-find-app/-/node-firefox-find-app-1.0.0.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/sampleapp/build/app.zip
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/sampleapp/build/app.zip b/node_modules/node-firefox-find-app/test/sampleapp/build/app.zip
new file mode 100644
index 0000000..fdbe68a
Binary files /dev/null and b/node_modules/node-firefox-find-app/test/sampleapp/build/app.zip differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/sampleapp/fake.webapp
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/sampleapp/fake.webapp b/node_modules/node-firefox-find-app/test/sampleapp/fake.webapp
new file mode 100644
index 0000000..7627607
--- /dev/null
+++ b/node_modules/node-firefox-find-app/test/sampleapp/fake.webapp
@@ -0,0 +1,22 @@
+{
+ "version": "0.1.0",
+ "name": "fxos-deploy-sample-fake",
+ "description": "Sample app",
+ "launch_path": "/index.html",
+ "icons": {
+ "16": "/icons/icon16x16.png",
+ "48": "/icons/icon48x48.png",
+ "60": "/icons/icon60x60.png",
+ "128": "/icons/icon128x128.png"
+ },
+ "developer": {
+ "name": "Your name",
+ "url": "http://example.com"
+ },
+ "type": "privileged",
+ "permissions": {},
+ "installs_allowed_from": [
+ "*"
+ ],
+ "default_locale": "en"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/sampleapp/icons/icon.svg
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/sampleapp/icons/icon.svg b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon.svg
new file mode 100644
index 0000000..834968c
--- /dev/null
+++ b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon.svg
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="128px"
+ height="128px"
+ viewBox="0 0 128 128"
+ version="1.1"
+ id="svg2"
+ inkscape:version="0.48.2 r9819"
+ sodipodi:docname="icon.svg">
+ <metadata
+ id="metadata14">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1142"
+ inkscape:window-height="849"
+ id="namedview12"
+ showgrid="false"
+ inkscape:zoom="1.84375"
+ inkscape:cx="-32.542373"
+ inkscape:cy="64"
+ inkscape:window-x="672"
+ inkscape:window-y="146"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="Page-1" />
+ <!-- Generator: Sketch 3.0.2 (7799) - http://www.bohemiancoding.com/sketch -->
+ <title
+ id="title4">empty</title>
+ <description
+ id="description6">Created with Sketch.</description>
+ <defs
+ id="defs8">
+ <linearGradient
+ id="linearGradient3761">
+ <stop
+ style="stop-color:#4e748b;stop-opacity:1;"
+ offset="0"
+ id="stop3763" />
+ <stop
+ style="stop-color:#393e3f;stop-opacity:1;"
+ offset="1"
+ id="stop3765" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3761"
+ id="linearGradient3767"
+ x1="129.66949"
+ y1="65.8983"
+ x2="129.66949"
+ y2="188.59828"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <path
+ sodipodi:type="arc"
+ style="fill:url(#linearGradient3767);fill-opacity:1;fill-rule:evenodd;stroke:none"
+ id="path2991"
+ sodipodi:cx="129.35593"
+ sodipodi:cy="128.27118"
+ sodipodi:rx="63.18644"
+ sodipodi:ry="63.18644"
+ d="m 192.54237,128.27118 a 63.18644,63.18644 0 1 1 -126.372883,0 63.18644,63.18644 0 1 1 126.372883,0 z"
+ transform="translate(-65.355927,-64.271179)" />
+ <g
+ id="Page-1"
+ sketch:type="MSPage"
+ transform="matrix(0.9,0,0,0.9,6.4,6.4)"
+ style="fill:none;stroke:none">
+ <circle
+ id="empty"
+ sketch:type="MSShapeGroup"
+ cx="64"
+ cy="64"
+ r="58"
+ sodipodi:cx="64"
+ sodipodi:cy="64"
+ sodipodi:rx="58"
+ sodipodi:ry="58"
+ style="stroke:#bcc6c5;stroke-width:11;stroke-linecap:round;stroke-dasharray:20, 20;fill:none;fill-opacity:1"
+ d="M 122,64 C 122,96.032515 96.032515,122 64,122 31.967485,122 6,96.032515 6,64 6,31.967485 31.967485,6 64,6 c 32.032515,0 58,25.967485 58,58 z" />
+ </g>
+</svg>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/sampleapp/icons/icon128x128.png
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/sampleapp/icons/icon128x128.png b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon128x128.png
new file mode 100644
index 0000000..7c672c5
Binary files /dev/null and b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon128x128.png differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/sampleapp/icons/icon16x16.png
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/sampleapp/icons/icon16x16.png b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon16x16.png
new file mode 100644
index 0000000..abf254e
Binary files /dev/null and b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon16x16.png differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/sampleapp/icons/icon48x48.png
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/sampleapp/icons/icon48x48.png b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon48x48.png
new file mode 100644
index 0000000..451655b
Binary files /dev/null and b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon48x48.png differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/sampleapp/icons/icon60x60.png
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/sampleapp/icons/icon60x60.png b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon60x60.png
new file mode 100644
index 0000000..c7d4115
Binary files /dev/null and b/node_modules/node-firefox-find-app/test/sampleapp/icons/icon60x60.png differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/sampleapp/index.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/sampleapp/index.html b/node_modules/node-firefox-find-app/test/sampleapp/index.html
new file mode 100644
index 0000000..2c9d1a3
--- /dev/null
+++ b/node_modules/node-firefox-find-app/test/sampleapp/index.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Sample app</title>
+ <meta name="description" content="A privileged app stub">
+ <meta name="viewport" content="width=device-width">
+ </head>
+ <body>
+ Sample app
+ </body>
+</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[26/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/package.json
new file mode 100644
index 0000000..5648629
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "async",
+ "description": "Higher-order functions and common patterns for asynchronous code",
+ "main": "./lib/async",
+ "author": {
+ "name": "Caolan McMahon"
+ },
+ "version": "0.2.10",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/caolan/async.git"
+ },
+ "bugs": {
+ "url": "https://github.com/caolan/async/issues"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/caolan/async/raw/master/LICENSE"
+ }
+ ],
+ "devDependencies": {
+ "nodeunit": ">0.0.0",
+ "uglify-js": "1.2.x",
+ "nodelint": ">0.0.0"
+ },
+ "jam": {
+ "main": "lib/async.js",
+ "include": [
+ "lib/async.js",
+ "README.md",
+ "LICENSE"
+ ]
+ },
+ "scripts": {
+ "test": "nodeunit test/test-async.js"
+ },
+ "readme": "# Async.js\n\nAsync is a utility module which provides straight-forward, powerful functions\nfor working with asynchronous JavaScript. Although originally designed for\nuse with [node.js](http://nodejs.org), it can also be used directly in the\nbrowser. Also supports [component](https://github.com/component/component).\n\nAsync provides around 20 functions that include the usual 'functional'\nsuspects (map, reduce, filter, each…) as well as some common patterns\nfor asynchronous control flow (parallel, series, waterfall…). All these\nfunctions assume you follow the node.js convention of providing a single\ncallback as the last argument of your async function.\n\n\n## Quick Examples\n\n```javascript\nasync.map(['file1','file2','file3'], fs.stat, function(err, results){\n // results is now an array of stats for each file\n});\n\nasync.filter(['file1','file2','file3'], fs.exists, function(results){\n // results now equals an array of the existing files\n});\n\nas
ync.parallel([\n function(){ ... },\n function(){ ... }\n], callback);\n\nasync.series([\n function(){ ... },\n function(){ ... }\n]);\n```\n\nThere are many more functions available so take a look at the docs below for a\nfull list. This module aims to be comprehensive, so if you feel anything is\nmissing please create a GitHub issue for it.\n\n## Common Pitfalls\n\n### Binding a context to an iterator\n\nThis section is really about bind, not about async. If you are wondering how to\nmake async execute your iterators in a given context, or are confused as to why\na method of another library isn't working as an iterator, study this example:\n\n```js\n// Here is a simple object with an (unnecessarily roundabout) squaring method\nvar AsyncSquaringLibrary = {\n squareExponent: 2,\n square: function(number, callback){ \n var result = Math.pow(number, this.squareExponent);\n setTimeout(function(){\n callback(null, result);\n }, 200);\n }\n};\n\nasync.map([1,
2, 3], AsyncSquaringLibrary.square, function(err, result){\n // result is [NaN, NaN, NaN]\n // This fails because the `this.squareExponent` expression in the square\n // function is not evaluated in the context of AsyncSquaringLibrary, and is\n // therefore undefined.\n});\n\nasync.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result){\n // result is [1, 4, 9]\n // With the help of bind we can attach a context to the iterator before\n // passing it to async. Now the square function will be executed in its \n // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent`\n // will be as expected.\n});\n```\n\n## Download\n\nThe source is available for download from\n[GitHub](http://github.com/caolan/async).\nAlternatively, you can install using Node Package Manager (npm):\n\n npm install async\n\n__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 29.6kb Uncompressed\n\n## In the Bro
wser\n\nSo far it's been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. Usage:\n\n```html\n<script type=\"text/javascript\" src=\"async.js\"></script>\n<script type=\"text/javascript\">\n\n async.map(data, asyncProcess, function(err, results){\n alert(results);\n });\n\n</script>\n```\n\n## Documentation\n\n### Collections\n\n* [each](#each)\n* [eachSeries](#eachSeries)\n* [eachLimit](#eachLimit)\n* [map](#map)\n* [mapSeries](#mapSeries)\n* [mapLimit](#mapLimit)\n* [filter](#filter)\n* [filterSeries](#filterSeries)\n* [reject](#reject)\n* [rejectSeries](#rejectSeries)\n* [reduce](#reduce)\n* [reduceRight](#reduceRight)\n* [detect](#detect)\n* [detectSeries](#detectSeries)\n* [sortBy](#sortBy)\n* [some](#some)\n* [every](#every)\n* [concat](#concat)\n* [concatSeries](#concatSeries)\n\n### Control Flow\n\n* [series](#series)\n* [parallel](#parallel)\n* [parallelLimit](#parallellimittasks-limit-callback)\n* [whilst](#whilst)\n* [doWhilst](#doWhilst)\n* [until](#until)\n* [do
Until](#doUntil)\n* [forever](#forever)\n* [waterfall](#waterfall)\n* [compose](#compose)\n* [applyEach](#applyEach)\n* [applyEachSeries](#applyEachSeries)\n* [queue](#queue)\n* [cargo](#cargo)\n* [auto](#auto)\n* [iterator](#iterator)\n* [apply](#apply)\n* [nextTick](#nextTick)\n* [times](#times)\n* [timesSeries](#timesSeries)\n\n### Utils\n\n* [memoize](#memoize)\n* [unmemoize](#unmemoize)\n* [log](#log)\n* [dir](#dir)\n* [noConflict](#noConflict)\n\n\n## Collections\n\n<a name=\"forEach\" />\n<a name=\"each\" />\n### each(arr, iterator, callback)\n\nApplies an iterator function to each item in an array, in parallel.\nThe iterator is called with an item from the list and a callback for when it\nhas finished. If the iterator passes an error to this callback, the main\ncallback for the each function is immediately called with the error.\n\nNote, that since this function applies the iterator to each item in parallel\nthere is no guarantee that the iterator functions will complete in
order.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback(err) which must be called once it has \n completed. If no error has occured, the callback should be run without \n arguments or with an explicit null argument.\n* callback(err) - A callback which is called after all the iterator functions\n have finished, or an error has occurred.\n\n__Example__\n\n```js\n// assuming openFiles is an array of file names and saveFile is a function\n// to save the modified contents of that file:\n\nasync.each(openFiles, saveFile, function(err){\n // if any of the saves produced an error, err would equal that error\n});\n```\n\n---------------------------------------\n\n<a name=\"forEachSeries\" />\n<a name=\"eachSeries\" />\n### eachSeries(arr, iterator, callback)\n\nThe same as each only the iterator is applied to each item in the array in\nseries. The next iterator is only
called once the current one has completed\nprocessing. This means the iterator functions will complete in order.\n\n\n---------------------------------------\n\n<a name=\"forEachLimit\" />\n<a name=\"eachLimit\" />\n### eachLimit(arr, limit, iterator, callback)\n\nThe same as each only no more than \"limit\" iterators will be simultaneously \nrunning at any time.\n\nNote that the items are not processed in batches, so there is no guarantee that\n the first \"limit\" iterator functions will complete before any others are \nstarted.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* limit - The maximum number of iterators to run at any time.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback(err) which must be called once it has \n completed. If no error has occured, the callback should be run without \n arguments or with an explicit null argument.\n* callback(err) - A callback which is called after all the iterat
or functions\n have finished, or an error has occurred.\n\n__Example__\n\n```js\n// Assume documents is an array of JSON objects and requestApi is a\n// function that interacts with a rate-limited REST api.\n\nasync.eachLimit(documents, 20, requestApi, function(err){\n // if any of the saves produced an error, err would equal that error\n});\n```\n\n---------------------------------------\n\n<a name=\"map\" />\n### map(arr, iterator, callback)\n\nProduces a new array of values by mapping each value in the given array through\nthe iterator function. The iterator is called with an item from the array and a\ncallback for when it has finished processing. The callback takes 2 arguments, \nan error and the transformed item from the array. If the iterator passes an\nerror to this callback, the main callback for the map function is immediately\ncalled with the error.\n\nNote, that since this function applies the iterator to each item in parallel\nthere is no guarantee that the iterator
functions will complete in order, however\nthe results array will be in the same order as the original array.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback(err, transformed) which must be called once \n it has completed with an error (which can be null) and a transformed item.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has occurred. Results is an array of the\n transformed items from the original array.\n\n__Example__\n\n```js\nasync.map(['file1','file2','file3'], fs.stat, function(err, results){\n // results is now an array of stats for each file\n});\n```\n\n---------------------------------------\n\n<a name=\"mapSeries\" />\n### mapSeries(arr, iterator, callback)\n\nThe same as map only the iterator is applied to each item in the array in\nseries. The next iterator is only called o
nce the current one has completed\nprocessing. The results array will be in the same order as the original.\n\n\n---------------------------------------\n\n<a name=\"mapLimit\" />\n### mapLimit(arr, limit, iterator, callback)\n\nThe same as map only no more than \"limit\" iterators will be simultaneously \nrunning at any time.\n\nNote that the items are not processed in batches, so there is no guarantee that\n the first \"limit\" iterator functions will complete before any others are \nstarted.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* limit - The maximum number of iterators to run at any time.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback(err, transformed) which must be called once \n it has completed with an error (which can be null) and a transformed item.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has occurred. Results is
an array of the\n transformed items from the original array.\n\n__Example__\n\n```js\nasync.mapLimit(['file1','file2','file3'], 1, fs.stat, function(err, results){\n // results is now an array of stats for each file\n});\n```\n\n---------------------------------------\n\n<a name=\"filter\" />\n### filter(arr, iterator, callback)\n\n__Alias:__ select\n\nReturns a new array of all the values which pass an async truth test.\n_The callback for each iterator call only accepts a single argument of true or\nfalse, it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like fs.exists. This operation is\nperformed in parallel, but the results array will be in the same order as the\noriginal.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback(truthValue) which must be called with a \n boolean argument once it has c
ompleted.\n* callback(results) - A callback which is called after all the iterator\n functions have finished.\n\n__Example__\n\n```js\nasync.filter(['file1','file2','file3'], fs.exists, function(results){\n // results now equals an array of the existing files\n});\n```\n\n---------------------------------------\n\n<a name=\"filterSeries\" />\n### filterSeries(arr, iterator, callback)\n\n__alias:__ selectSeries\n\nThe same as filter only the iterator is applied to each item in the array in\nseries. The next iterator is only called once the current one has completed\nprocessing. The results array will be in the same order as the original.\n\n---------------------------------------\n\n<a name=\"reject\" />\n### reject(arr, iterator, callback)\n\nThe opposite of filter. Removes values that pass an async truth test.\n\n---------------------------------------\n\n<a name=\"rejectSeries\" />\n### rejectSeries(arr, iterator, callback)\n\nThe same as reject, only the iterator is applied t
o each item in the array\nin series.\n\n\n---------------------------------------\n\n<a name=\"reduce\" />\n### reduce(arr, memo, iterator, callback)\n\n__aliases:__ inject, foldl\n\nReduces a list of values into a single value using an async iterator to return\neach successive step. Memo is the initial state of the reduction. This\nfunction only operates in series. For performance reasons, it may make sense to\nsplit a call to this function into a parallel map, then use the normal\nArray.prototype.reduce on the results. This function is for situations where\neach step in the reduction needs to be async, if you can get the data before\nreducing it then it's probably a good idea to do so.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* memo - The initial state of the reduction.\n* iterator(memo, item, callback) - A function applied to each item in the\n array to produce the next step in the reduction. The iterator is passed a\n callback(err, reduction) which accepts an opt
ional error as its first \n argument, and the state of the reduction as the second. If an error is \n passed to the callback, the reduction is stopped and the main callback is \n immediately called with the error.\n* callback(err, result) - A callback which is called after all the iterator\n functions have finished. Result is the reduced value.\n\n__Example__\n\n```js\nasync.reduce([1,2,3], 0, function(memo, item, callback){\n // pointless async:\n process.nextTick(function(){\n callback(null, memo + item)\n });\n}, function(err, result){\n // result is now equal to the last value of memo, which is 6\n});\n```\n\n---------------------------------------\n\n<a name=\"reduceRight\" />\n### reduceRight(arr, memo, iterator, callback)\n\n__Alias:__ foldr\n\nSame as reduce, only operates on the items in the array in reverse order.\n\n\n---------------------------------------\n\n<a name=\"detect\" />\n### detect(arr, iterator, callback)\n\nReturns the first value in a
list that passes an async truth test. The\niterator is applied in parallel, meaning the first iterator to return true will\nfire the detect callback with that result. That means the result might not be\nthe first item in the original array (in terms of order) that passes the test.\n\nIf order within the original array is important then look at detectSeries.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback(truthValue) which must be called with a \n boolean argument once it has completed.\n* callback(result) - A callback which is called as soon as any iterator returns\n true, or after all the iterator functions have finished. Result will be\n the first item in the array that passes the truth test (iterator) or the\n value undefined if none passed.\n\n__Example__\n\n```js\nasync.detect(['file1','file2','file3'], fs.exists, function(result){\n // result now eq
uals the first file in the list that exists\n});\n```\n\n---------------------------------------\n\n<a name=\"detectSeries\" />\n### detectSeries(arr, iterator, callback)\n\nThe same as detect, only the iterator is applied to each item in the array\nin series. This means the result is always the first in the original array (in\nterms of array order) that passes the truth test.\n\n\n---------------------------------------\n\n<a name=\"sortBy\" />\n### sortBy(arr, iterator, callback)\n\nSorts a list by the results of running each value through an async iterator.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback(err, sortValue) which must be called once it\n has completed with an error (which can be null) and a value to use as the sort\n criteria.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has
occurred. Results is the items from\n the original array sorted by the values returned by the iterator calls.\n\n__Example__\n\n```js\nasync.sortBy(['file1','file2','file3'], function(file, callback){\n fs.stat(file, function(err, stats){\n callback(err, stats.mtime);\n });\n}, function(err, results){\n // results is now the original array of files sorted by\n // modified date\n});\n```\n\n---------------------------------------\n\n<a name=\"some\" />\n### some(arr, iterator, callback)\n\n__Alias:__ any\n\nReturns true if at least one element in the array satisfies an async test.\n_The callback for each iterator call only accepts a single argument of true or\nfalse, it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like fs.exists. Once any iterator\ncall returns true, the main callback is immediately called.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth tes
t to apply to each item in the array.\n The iterator is passed a callback(truthValue) which must be called with a \n boolean argument once it has completed.\n* callback(result) - A callback which is called as soon as any iterator returns\n true, or after all the iterator functions have finished. Result will be\n either true or false depending on the values of the async tests.\n\n__Example__\n\n```js\nasync.some(['file1','file2','file3'], fs.exists, function(result){\n // if result is true then at least one of the files exists\n});\n```\n\n---------------------------------------\n\n<a name=\"every\" />\n### every(arr, iterator, callback)\n\n__Alias:__ all\n\nReturns true if every element in the array satisfies an async test.\n_The callback for each iterator call only accepts a single argument of true or\nfalse, it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like fs.exists.\n\n__Arguments__\n\n* arr - An array to
iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback(truthValue) which must be called with a \n boolean argument once it has completed.\n* callback(result) - A callback which is called after all the iterator\n functions have finished. Result will be either true or false depending on\n the values of the async tests.\n\n__Example__\n\n```js\nasync.every(['file1','file2','file3'], fs.exists, function(result){\n // if result is true then every file exists\n});\n```\n\n---------------------------------------\n\n<a name=\"concat\" />\n### concat(arr, iterator, callback)\n\nApplies an iterator to each item in a list, concatenating the results. Returns the\nconcatenated list. The iterators are called in parallel, and the results are\nconcatenated as they return. There is no guarantee that the results array will\nbe returned in the original order of the arguments passed to the iterator function.\n\n__Arguments
__\n\n* arr - An array to iterate over\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback(err, results) which must be called once it \n has completed with an error (which can be null) and an array of results.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has occurred. Results is an array containing\n the concatenated results of the iterator function.\n\n__Example__\n\n```js\nasync.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){\n // files is now a list of filenames that exist in the 3 directories\n});\n```\n\n---------------------------------------\n\n<a name=\"concatSeries\" />\n### concatSeries(arr, iterator, callback)\n\nSame as async.concat, but executes in series instead of parallel.\n\n\n## Control Flow\n\n<a name=\"series\" />\n### series(tasks, [callback])\n\nRun an array of functions in series, each one running once the
previous\nfunction has completed. If any functions in the series pass an error to its\ncallback, no more functions are run and the callback for the series is\nimmediately called with the value of the error. Once the tasks have completed,\nthe results are passed to the final callback as an array.\n\nIt is also possible to use an object instead of an array. Each property will be\nrun as a function and the results will be passed to the final callback as an object\ninstead of an array. This can be a more readable way of handling results from\nasync.series.\n\n\n__Arguments__\n\n* tasks - An array or object containing functions to run, each function is passed\n a callback(err, result) it must call on completion with an error (which can\n be null) and an optional result value.\n* callback(err, results) - An optional callback to run once all the functions\n have completed. This function gets a results array (or object) containing all \n the result arguments passed to the task callback
s.\n\n__Example__\n\n```js\nasync.series([\n function(callback){\n // do some stuff ...\n callback(null, 'one');\n },\n function(callback){\n // do some more stuff ...\n callback(null, 'two');\n }\n],\n// optional callback\nfunction(err, results){\n // results is now equal to ['one', 'two']\n});\n\n\n// an example using an object instead of an array\nasync.series({\n one: function(callback){\n setTimeout(function(){\n callback(null, 1);\n }, 200);\n },\n two: function(callback){\n setTimeout(function(){\n callback(null, 2);\n }, 100);\n }\n},\nfunction(err, results) {\n // results is now equal to: {one: 1, two: 2}\n});\n```\n\n---------------------------------------\n\n<a name=\"parallel\" />\n### parallel(tasks, [callback])\n\nRun an array of functions in parallel, without waiting until the previous\nfunction has completed. If any of the functions pass an error to its\ncallba
ck, the main callback is immediately called with the value of the error.\nOnce the tasks have completed, the results are passed to the final callback as an\narray.\n\nIt is also possible to use an object instead of an array. Each property will be\nrun as a function and the results will be passed to the final callback as an object\ninstead of an array. This can be a more readable way of handling results from\nasync.parallel.\n\n\n__Arguments__\n\n* tasks - An array or object containing functions to run, each function is passed \n a callback(err, result) it must call on completion with an error (which can\n be null) and an optional result value.\n* callback(err, results) - An optional callback to run once all the functions\n have completed. This function gets a results array (or object) containing all \n the result arguments passed to the task callbacks.\n\n__Example__\n\n```js\nasync.parallel([\n function(callback){\n setTimeout(function(){\n callback(null, '
one');\n }, 200);\n },\n function(callback){\n setTimeout(function(){\n callback(null, 'two');\n }, 100);\n }\n],\n// optional callback\nfunction(err, results){\n // the results array will equal ['one','two'] even though\n // the second function had a shorter timeout.\n});\n\n\n// an example using an object instead of an array\nasync.parallel({\n one: function(callback){\n setTimeout(function(){\n callback(null, 1);\n }, 200);\n },\n two: function(callback){\n setTimeout(function(){\n callback(null, 2);\n }, 100);\n }\n},\nfunction(err, results) {\n // results is now equals to: {one: 1, two: 2}\n});\n```\n\n---------------------------------------\n\n<a name=\"parallel\" />\n### parallelLimit(tasks, limit, [callback])\n\nThe same as parallel only the tasks are executed in parallel with a maximum of \"limit\" \ntasks executing at any time.\n\nNote that the tasks are not exec
uted in batches, so there is no guarantee that \nthe first \"limit\" tasks will complete before any others are started.\n\n__Arguments__\n\n* tasks - An array or object containing functions to run, each function is passed \n a callback(err, result) it must call on completion with an error (which can\n be null) and an optional result value.\n* limit - The maximum number of tasks to run at any time.\n* callback(err, results) - An optional callback to run once all the functions\n have completed. This function gets a results array (or object) containing all \n the result arguments passed to the task callbacks.\n\n---------------------------------------\n\n<a name=\"whilst\" />\n### whilst(test, fn, callback)\n\nRepeatedly call fn, while test returns true. Calls the callback when stopped,\nor an error occurs.\n\n__Arguments__\n\n* test() - synchronous truth test to perform before each execution of fn.\n* fn(callback) - A function to call each time the test passes. The function is\n
passed a callback(err) which must be called once it has completed with an \n optional error argument.\n* callback(err) - A callback which is called after the test fails and repeated\n execution of fn has stopped.\n\n__Example__\n\n```js\nvar count = 0;\n\nasync.whilst(\n function () { return count < 5; },\n function (callback) {\n count++;\n setTimeout(callback, 1000);\n },\n function (err) {\n // 5 seconds have passed\n }\n);\n```\n\n---------------------------------------\n\n<a name=\"doWhilst\" />\n### doWhilst(fn, test, callback)\n\nThe post check version of whilst. To reflect the difference in the order of operations `test` and `fn` arguments are switched. `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.\n\n---------------------------------------\n\n<a name=\"until\" />\n### until(test, fn, callback)\n\nRepeatedly call fn, until test returns true. Calls the callback when stopped,\nor an error occurs.\n\nThe inverse
of async.whilst.\n\n---------------------------------------\n\n<a name=\"doUntil\" />\n### doUntil(fn, test, callback)\n\nLike doWhilst except the test is inverted. Note the argument ordering differs from `until`.\n\n---------------------------------------\n\n<a name=\"forever\" />\n### forever(fn, callback)\n\nCalls the asynchronous function 'fn' repeatedly, in series, indefinitely.\nIf an error is passed to fn's callback then 'callback' is called with the\nerror, otherwise it will never be called.\n\n---------------------------------------\n\n<a name=\"waterfall\" />\n### waterfall(tasks, [callback])\n\nRuns an array of functions in series, each passing their results to the next in\nthe array. However, if any of the functions pass an error to the callback, the\nnext function is not executed and the main callback is immediately called with\nthe error.\n\n__Arguments__\n\n* tasks - An array of functions to run, each function is passed a \n callback(err, result1, result2, ...) it m
ust call on completion. The first\n argument is an error (which can be null) and any further arguments will be \n passed as arguments in order to the next task.\n* callback(err, [results]) - An optional callback to run once all the functions\n have completed. This will be passed the results of the last task's callback.\n\n\n\n__Example__\n\n```js\nasync.waterfall([\n function(callback){\n callback(null, 'one', 'two');\n },\n function(arg1, arg2, callback){\n callback(null, 'three');\n },\n function(arg1, callback){\n // arg1 now equals 'three'\n callback(null, 'done');\n }\n], function (err, result) {\n // result now equals 'done' \n});\n```\n\n---------------------------------------\n<a name=\"compose\" />\n### compose(fn1, fn2...)\n\nCreates a function which is a composition of the passed asynchronous\nfunctions. Each function consumes the return value of the function that\nfollows. Composing functions f(), g() and h() would pr
oduce the result of\nf(g(h())), only this version uses callbacks to obtain the return values.\n\nEach function is executed with the `this` binding of the composed function.\n\n__Arguments__\n\n* functions... - the asynchronous functions to compose\n\n\n__Example__\n\n```js\nfunction add1(n, callback) {\n setTimeout(function () {\n callback(null, n + 1);\n }, 10);\n}\n\nfunction mul3(n, callback) {\n setTimeout(function () {\n callback(null, n * 3);\n }, 10);\n}\n\nvar add1mul3 = async.compose(mul3, add1);\n\nadd1mul3(4, function (err, result) {\n // result now equals 15\n});\n```\n\n---------------------------------------\n<a name=\"applyEach\" />\n### applyEach(fns, args..., callback)\n\nApplies the provided arguments to each function in the array, calling the\ncallback after all functions have completed. If you only provide the first\nargument then it will return a function which lets you pass in the\narguments as if it were a single function call.\n\n_
_Arguments__\n\n* fns - the asynchronous functions to all call with the same arguments\n* args... - any number of separate arguments to pass to the function\n* callback - the final argument should be the callback, called when all\n functions have completed processing\n\n\n__Example__\n\n```js\nasync.applyEach([enableSearch, updateSchema], 'bucket', callback);\n\n// partial application example:\nasync.each(\n buckets,\n async.applyEach([enableSearch, updateSchema]),\n callback\n);\n```\n\n---------------------------------------\n\n<a name=\"applyEachSeries\" />\n### applyEachSeries(arr, iterator, callback)\n\nThe same as applyEach only the functions are applied in series.\n\n---------------------------------------\n\n<a name=\"queue\" />\n### queue(worker, concurrency)\n\nCreates a queue object with the specified concurrency. Tasks added to the\nqueue will be processed in parallel (up to the concurrency limit). If all\nworkers are in progress, the task is queued until one i
s available. Once\na worker has completed a task, the task's callback is called.\n\n__Arguments__\n\n* worker(task, callback) - An asynchronous function for processing a queued\n task, which must call its callback(err) argument when finished, with an \n optional error as an argument.\n* concurrency - An integer for determining how many worker functions should be\n run in parallel.\n\n__Queue objects__\n\nThe queue object returned by this function has the following properties and\nmethods:\n\n* length() - a function returning the number of items waiting to be processed.\n* concurrency - an integer for determining how many worker functions should be\n run in parallel. This property can be changed after a queue is created to\n alter the concurrency on-the-fly.\n* push(task, [callback]) - add a new task to the queue, the callback is called\n once the worker has finished processing the task.\n instead of a single task, an array of tasks can be submitted. the respective callback is
used for every task in the list.\n* unshift(task, [callback]) - add a new task to the front of the queue.\n* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued\n* empty - a callback that is called when the last item from the queue is given to a worker\n* drain - a callback that is called when the last item from the queue has returned from the worker\n\n__Example__\n\n```js\n// create a queue object with concurrency 2\n\nvar q = async.queue(function (task, callback) {\n console.log('hello ' + task.name);\n callback();\n}, 2);\n\n\n// assign a callback\nq.drain = function() {\n console.log('all items have been processed');\n}\n\n// add some items to the queue\n\nq.push({name: 'foo'}, function (err) {\n console.log('finished processing foo');\n});\nq.push({name: 'bar'}, function (err) {\n console.log('finished processing bar');\n});\n\n// add some items to the queue (batch-wise)\n\nq.push([{name: 'baz'},{nam
e: 'bay'},{name: 'bax'}], function (err) {\n console.log('finished processing bar');\n});\n\n// add some items to the front of the queue\n\nq.unshift({name: 'bar'}, function (err) {\n console.log('finished processing bar');\n});\n```\n\n---------------------------------------\n\n<a name=\"cargo\" />\n### cargo(worker, [payload])\n\nCreates a cargo object with the specified payload. Tasks added to the\ncargo will be processed altogether (up to the payload limit). If the\nworker is in progress, the task is queued until it is available. Once\nthe worker has completed some tasks, each callback of those tasks is called.\n\n__Arguments__\n\n* worker(tasks, callback) - An asynchronous function for processing an array of\n queued tasks, which must call its callback(err) argument when finished, with \n an optional error as an argument.\n* payload - An optional integer for determining how many tasks should be\n processed per round; if omitted, the default is unlimited.\n\n__Cargo obj
ects__\n\nThe cargo object returned by this function has the following properties and\nmethods:\n\n* length() - a function returning the number of items waiting to be processed.\n* payload - an integer for determining how many tasks should be\n process per round. This property can be changed after a cargo is created to\n alter the payload on-the-fly.\n* push(task, [callback]) - add a new task to the queue, the callback is called\n once the worker has finished processing the task.\n instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.\n* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued\n* empty - a callback that is called when the last item from the queue is given to a worker\n* drain - a callback that is called when the last item from the queue has returned from the worker\n\n__Example__\n\n```js\n// create a cargo object with payload 2\n\nvar car
go = async.cargo(function (tasks, callback) {\n for(var i=0; i<tasks.length; i++){\n console.log('hello ' + tasks[i].name);\n }\n callback();\n}, 2);\n\n\n// add some items\n\ncargo.push({name: 'foo'}, function (err) {\n console.log('finished processing foo');\n});\ncargo.push({name: 'bar'}, function (err) {\n console.log('finished processing bar');\n});\ncargo.push({name: 'baz'}, function (err) {\n console.log('finished processing baz');\n});\n```\n\n---------------------------------------\n\n<a name=\"auto\" />\n### auto(tasks, [callback])\n\nDetermines the best order for running functions based on their requirements.\nEach function can optionally depend on other functions being completed first,\nand each function is run as soon as its requirements are satisfied. If any of\nthe functions pass an error to their callback, that function will not complete\n(so any other functions depending on it will not run) and the main callback\nwill be called immediately wit
h the error. Functions also receive an object\ncontaining the results of functions which have completed so far.\n\nNote, all functions are called with a results object as a second argument, \nso it is unsafe to pass functions in the tasks object which cannot handle the\nextra argument. For example, this snippet of code:\n\n```js\nasync.auto({\n readData: async.apply(fs.readFile, 'data.txt', 'utf-8')\n}, callback);\n```\n\nwill have the effect of calling readFile with the results object as the last\nargument, which will fail:\n\n```js\nfs.readFile('data.txt', 'utf-8', cb, {});\n```\n\nInstead, wrap the call to readFile in a function which does not forward the \nresults object:\n\n```js\nasync.auto({\n readData: function(cb, results){\n fs.readFile('data.txt', 'utf-8', cb);\n }\n}, callback);\n```\n\n__Arguments__\n\n* tasks - An object literal containing named functions or an array of\n requirements, with the function itself the last item in the array. The key\n used for each
function or array is used when specifying requirements. The \n function receives two arguments: (1) a callback(err, result) which must be \n called when finished, passing an error (which can be null) and the result of \n the function's execution, and (2) a results object, containing the results of\n the previously executed functions.\n* callback(err, results) - An optional callback which is called when all the\n tasks have been completed. The callback will receive an error as an argument\n if any tasks pass an error to their callback. Results will always be passed\n\tbut if an error occurred, no other tasks will be performed, and the results\n\tobject will only contain partial results.\n \n\n__Example__\n\n```js\nasync.auto({\n get_data: function(callback){\n // async code to get some data\n },\n make_folder: function(callback){\n // async code to create a directory to store a file in\n // this is run at the same time as getting the data\n },
\n write_file: ['get_data', 'make_folder', function(callback){\n // once there is some data and the directory exists,\n // write the data to a file in the directory\n callback(null, filename);\n }],\n email_link: ['write_file', function(callback, results){\n // once the file is written let's email a link to it...\n // results.write_file contains the filename returned by write_file.\n }]\n});\n```\n\nThis is a fairly trivial example, but to do this using the basic parallel and\nseries functions would look like this:\n\n```js\nasync.parallel([\n function(callback){\n // async code to get some data\n },\n function(callback){\n // async code to create a directory to store a file in\n // this is run at the same time as getting the data\n }\n],\nfunction(err, results){\n async.series([\n function(callback){\n // once there is some data and the directory exists,\n // write the da
ta to a file in the directory\n },\n function(callback){\n // once the file is written let's email a link to it...\n }\n ]);\n});\n```\n\nFor a complicated series of async tasks using the auto function makes adding\nnew tasks much easier and makes the code more readable.\n\n\n---------------------------------------\n\n<a name=\"iterator\" />\n### iterator(tasks)\n\nCreates an iterator function which calls the next function in the array,\nreturning a continuation to call the next one after that. It's also possible to\n'peek' the next iterator by doing iterator.next().\n\nThis function is used internally by the async module but can be useful when\nyou want to manually control the flow of functions in series.\n\n__Arguments__\n\n* tasks - An array of functions to run.\n\n__Example__\n\n```js\nvar iterator = async.iterator([\n function(){ sys.p('one'); },\n function(){ sys.p('two'); },\n function(){ sys.p('three'); }\n]);\n\nnode> var iterator
2 = iterator();\n'one'\nnode> var iterator3 = iterator2();\n'two'\nnode> iterator3();\n'three'\nnode> var nextfn = iterator2.next();\nnode> nextfn();\n'three'\n```\n\n---------------------------------------\n\n<a name=\"apply\" />\n### apply(function, arguments..)\n\nCreates a continuation function with some arguments already applied, a useful\nshorthand when combined with other control flow functions. Any arguments\npassed to the returned function are added to the arguments originally passed\nto apply.\n\n__Arguments__\n\n* function - The function you want to eventually apply all arguments to.\n* arguments... - Any number of arguments to automatically apply when the\n continuation is called.\n\n__Example__\n\n```js\n// using apply\n\nasync.parallel([\n async.apply(fs.writeFile, 'testfile1', 'test1'),\n async.apply(fs.writeFile, 'testfile2', 'test2'),\n]);\n\n\n// the same process without using apply\n\nasync.parallel([\n function(callback){\n fs.writeFile('testfile
1', 'test1', callback);\n },\n function(callback){\n fs.writeFile('testfile2', 'test2', callback);\n }\n]);\n```\n\nIt's possible to pass any number of additional arguments when calling the\ncontinuation:\n\n```js\nnode> var fn = async.apply(sys.puts, 'one');\nnode> fn('two', 'three');\none\ntwo\nthree\n```\n\n---------------------------------------\n\n<a name=\"nextTick\" />\n### nextTick(callback)\n\nCalls the callback on a later loop around the event loop. In node.js this just\ncalls process.nextTick, in the browser it falls back to setImmediate(callback)\nif available, otherwise setTimeout(callback, 0), which means other higher priority\nevents may precede the execution of the callback.\n\nThis is used internally for browser-compatibility purposes.\n\n__Arguments__\n\n* callback - The function to call on a later loop around the event loop.\n\n__Example__\n\n```js\nvar call_order = [];\nasync.nextTick(function(){\n call_order.push('two');\n // call_order now
equals ['one','two']\n});\ncall_order.push('one')\n```\n\n<a name=\"times\" />\n### times(n, callback)\n\nCalls the callback n times and accumulates results in the same manner\nyou would use with async.map.\n\n__Arguments__\n\n* n - The number of times to run the function.\n* callback - The function to call n times.\n\n__Example__\n\n```js\n// Pretend this is some complicated async factory\nvar createUser = function(id, callback) {\n callback(null, {\n id: 'user' + id\n })\n}\n// generate 5 users\nasync.times(5, function(n, next){\n createUser(n, function(err, user) {\n next(err, user)\n })\n}, function(err, users) {\n // we should now have 5 users\n});\n```\n\n<a name=\"timesSeries\" />\n### timesSeries(n, callback)\n\nThe same as times only the iterator is applied to each item in the array in\nseries. The next iterator is only called once the current one has completed\nprocessing. The results array will be in the same order as the original.\n\n\n## Utils\n\n<a na
me=\"memoize\" />\n### memoize(fn, [hasher])\n\nCaches the results of an async function. When creating a hash to store function\nresults against, the callback is omitted from the hash and an optional hash\nfunction can be used.\n\nThe cache of results is exposed as the `memo` property of the function returned\nby `memoize`.\n\n__Arguments__\n\n* fn - the function you to proxy and cache results from.\n* hasher - an optional function for generating a custom hash for storing\n results, it has all the arguments applied to it apart from the callback, and\n must be synchronous.\n\n__Example__\n\n```js\nvar slow_fn = function (name, callback) {\n // do something\n callback(null, result);\n};\nvar fn = async.memoize(slow_fn);\n\n// fn can now be used as if it were slow_fn\nfn('some name', function () {\n // callback\n});\n```\n\n<a name=\"unmemoize\" />\n### unmemoize(fn)\n\nUndoes a memoized function, reverting it to the original, unmemoized\nform. Comes handy in tests.\n\n__Arg
uments__\n\n* fn - the memoized function\n\n<a name=\"log\" />\n### log(function, arguments)\n\nLogs the result of an async function to the console. Only works in node.js or\nin browsers that support console.log and console.error (such as FF and Chrome).\nIf multiple arguments are returned from the async function, console.log is\ncalled on each argument in order.\n\n__Arguments__\n\n* function - The function you want to eventually apply all arguments to.\n* arguments... - Any number of arguments to apply to the function.\n\n__Example__\n\n```js\nvar hello = function(name, callback){\n setTimeout(function(){\n callback(null, 'hello ' + name);\n }, 1000);\n};\n```\n```js\nnode> async.log(hello, 'world');\n'hello world'\n```\n\n---------------------------------------\n\n<a name=\"dir\" />\n### dir(function, arguments)\n\nLogs the result of an async function to the console using console.dir to\ndisplay the properties of the resulting object. Only works in node.js or\nin bro
wsers that support console.dir and console.error (such as FF and Chrome).\nIf multiple arguments are returned from the async function, console.dir is\ncalled on each argument in order.\n\n__Arguments__\n\n* function - The function you want to eventually apply all arguments to.\n* arguments... - Any number of arguments to apply to the function.\n\n__Example__\n\n```js\nvar hello = function(name, callback){\n setTimeout(function(){\n callback(null, {hello: name});\n }, 1000);\n};\n```\n```js\nnode> async.dir(hello, 'world');\n{hello: 'world'}\n```\n\n---------------------------------------\n\n<a name=\"noConflict\" />\n### noConflict()\n\nChanges the value of async back to its original value, returning a reference to the\nasync object.\n",
+ "readmeFilename": "README.md",
+ "homepage": "https://github.com/caolan/async",
+ "_id": "async@0.2.10",
+ "_shasum": "b6bbe0b0674b9d719708ca38de8c237cb526c3d1",
+ "_from": "async@~0.2.9",
+ "_resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/package.json
new file mode 100644
index 0000000..473485c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/package.json
@@ -0,0 +1,79 @@
+{
+ "name": "adbkit-monkey",
+ "version": "1.0.1",
+ "description": "A Node.js interface to the Android monkey tool.",
+ "keywords": [
+ "adb",
+ "adbkit",
+ "monkey",
+ "monkeyrunner"
+ ],
+ "bugs": {
+ "url": "https://github.com/CyberAgent/adbkit-monkey/issues"
+ },
+ "license": "Apache-2.0",
+ "author": {
+ "name": "CyberAgent, Inc.",
+ "email": "npm@cyberagent.co.jp",
+ "url": "http://www.cyberagent.co.jp/"
+ },
+ "main": "./index",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/CyberAgent/adbkit-monkey.git"
+ },
+ "scripts": {
+ "postpublish": "grunt clean",
+ "prepublish": "grunt coffee",
+ "test": "grunt test"
+ },
+ "dependencies": {
+ "async": "~0.2.9"
+ },
+ "devDependencies": {
+ "chai": "~1.8.1",
+ "coffee-script": "~1.6.3",
+ "grunt": "~0.4.1",
+ "grunt-cli": "~0.1.11",
+ "grunt-coffeelint": "~0.0.7",
+ "grunt-contrib-clean": "~0.5.0",
+ "grunt-contrib-coffee": "~0.7.0",
+ "grunt-contrib-watch": "~0.5.3",
+ "grunt-exec": "~0.4.2",
+ "grunt-jsonlint": "~1.0.2",
+ "grunt-notify": "~0.2.16",
+ "mocha": "~1.14.0",
+ "sinon": "~1.7.3",
+ "sinon-chai": "~2.4.0"
+ },
+ "engines": {
+ "node": ">= 0.10.4"
+ },
+ "readme": "# adbkit-monkey\n\n**adbkit-monkey** provides a [Node.js][nodejs] interface for working with the Android [`monkey` tool][monkey-site]. Albeit undocumented, they monkey program can be started in TCP mode with the `--port` argument. In this mode, it accepts a [range of commands][monkey-proto] that can be used to interact with the UI in a non-random manner. This mode is also used internally by the [`monkeyrunner` tool][monkeyrunner-site], although the documentation claims no relation to the monkey tool.\n\n## Getting started\n\nInstall via NPM:\n\n```bash\nnpm install --save adbkit-monkey\n```\n\nNote that while adbkit-monkey is written in CoffeeScript, it is compiled to JavaScript before publishing to NPM, which means that you are not required to use CoffeeScript.\n\n### Examples\n\nThe following examples assume that monkey is already running (via `adb shell monkey --port 1080`) and a port forwarding (`adb forward tcp:1080 tcp:1080`) has been set up.\n\n#### Press the hom
e button\n\n```javascript\nvar assert = require('assert');\nvar monkey = require('adbkit-monkey');\n\nvar client = monkey.connect({ port: 1080 });\n\nclient.press(3 /* KEYCODE_HOME */, function(err) {\n assert.ifError(err);\n console.log('Pressed home button');\n client.end();\n});\n```\n\n#### Drag out the notification bar\n\n```javascript\nvar assert = require('assert');\nvar monkey = require('adbkit-monkey');\n\nvar client = monkey.connect({ port: 1080 });\n\nclient.multi()\n .touchDown(100, 0)\n .sleep(5)\n .touchMove(100, 20)\n .sleep(5)\n .touchMove(100, 40)\n .sleep(5)\n .touchMove(100, 60)\n .sleep(5)\n .touchMove(100, 80)\n .sleep(5)\n .touchMove(100, 100)\n .sleep(5)\n .touchUp(100, 100)\n .sleep(5)\n .execute(function(err) {\n assert.ifError(err);\n console.log('Dragged out the notification bar');\n client.end();\n });\n```\n\n#### Get display size\n\n```javascript\nvar assert = require('assert');\nvar monkey = require('adbkit-monkey');\n\nvar
client = monkey.connect({ port: 1080 });\n\nclient.getDisplayWidth(function(err, width) {\n assert.ifError(err);\n client.getDisplayHeight(function(err, height) {\n assert.ifError(err);\n console.log('Display size is %dx%d', width, height);\n client.end();\n });\n});\n```\n\n#### Type text\n\nNote that you should manually focus a text field first.\n\n```javascript\nvar assert = require('assert');\nvar monkey = require('adbkit-monkey');\n\nvar client = monkey.connect({ port: 1080 });\n\nclient.type('hello monkey!', function(err) {\n assert.ifError(err);\n console.log('Said hello to monkey');\n client.end();\n});\n```\n\n## API\n\n### Monkey\n\n#### monkey.connect(options)\n\nUses [Net.connect()][node-net] to open a new TCP connection to monkey. Useful when combined with `adb forward`.\n\n* **options** Any options [`Net.connect()`][node-net] accepts.\n* Returns: A new monkey `Client` instance.\n\n#### monkey.connectStream(stream)\n\nAttaches a monkey client to an existi
ng monkey protocol stream.\n\n* **stream** The monkey protocol [`Stream`][node-stream].\n* Returns: A new monkey `Client` instance.\n\n### Client\n\nImplements `Api`. See below for details.\n\n#### Events\n\nThe following events are available:\n\n* **error** **(err)** Emitted when an error occurs.\n * **err** An `Error`.\n* **end** Emitted when the stream ends.\n* **finish** Emitted when the stream finishes.\n\n#### client.end()\n\nEnds the underlying stream/connection.\n\n* Returns: The `Client` instance.\n\n#### client.multi()\n\nReturns a new API wrapper that buffers commands for simultaneous delivery instead of sending them individually. When used with `api.sleep()`, allows simple gestures to be executed.\n\n* Returns: A new `Multi` instance. See `Multi` below.\n\n#### client.send(command, callback)\n\nSends a raw protocol command to monkey.\n\n* **command** The command to send. When `String`, a single command is sent. When `Array`, a series of commands is sent at once.\n* **
callback(err, value, command)** Called when monkey responds to the command. If multiple commands were sent, the callback will be called once for each command.\n * **err** `null` when successful, `Error` otherwise.\n * **value** The response value, if any.\n * **command** The command the response is for.\n* Returns: The `Client` instance.\n\n### Api\n\nThe monkey API implemented by `Client` and `Multi`.\n\n#### api.done(callback)\n\nCloses the current monkey session and allows a new session to connect.\n\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.flipClose(callback)\n\nSimulates closing the keyboard.\n\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.flipOpen(callback)\n\nSimulates opening the keyboard.\n\n* **callback(err)** Called when
monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.get(name, callback)\n\nGets the value of a variable. Use `api.list()` to retrieve a list of supported variables.\n\n* **name** The name of the variable.\n* **callback(err, value)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n * **value** The value of the variable.\n* Returns: The `Api` implementation instance.\n\n#### api.getAmCurrentAction(callback)\n\nAlias for `api.get('am.current.action', callback)`.\n\n#### api.getAmCurrentCategories(callback)\n\nAlias for `api.get('am.current.categories', callback)`.\n\n#### api.getAmCurrentCompClass(callback)\n\nAlias for `api.get('am.current.comp.class', callback)`.\n\n#### api.getAmCurrentCompPackage(callback)\n\nAlias for `api.get('am.current.comp.package', callback)`.\n\n#### api.getCurrentData(callback)\n\nAlias for `api.get('am.current.data', callback)`.\n\n
#### api.getAmCurrentPackage(callback)\n\nAlias for `api.get('am.current.package', callback)`.\n\n#### api.getBuildBoard(callback)\n\nAlias for `api.get('build.board', callback)`.\n\n#### api.getBuildBrand(callback)\n\nAlias for `api.get('build.brand', callback)`.\n\n#### api.getBuildCpuAbi(callback)\n\nAlias for `api.get('build.cpu_abi', callback)`.\n\n#### api.getBuildDevice(callback)\n\nAlias for `api.get('build.device', callback)`.\n\n#### api.getBuildDisplay(callback)\n\nAlias for `api.get('build.display', callback)`.\n\n#### api.getBuildFingerprint(callback)\n\nAlias for `api.get('build.fingerprint', callback)`.\n\n#### api.getBuildHost(callback)\n\nAlias for `api.get('build.host', callback)`.\n\n#### api.getBuildId(callback)\n\nAlias for `api.get('build.id', callback)`.\n\n#### api.getBuildManufacturer(callback)\n\nAlias for `api.get('build.manufacturer', callback)`.\n\n#### api.getBuildModel(callback)\n\nAlias for `api.get('build.model', callback)`.\n\n#### api.getBuildProdu
ct(callback)\n\nAlias for `api.get('build.product', callback)`.\n\n#### api.getBuildTags(callback)\n\nAlias for `api.get('build.tags', callback)`.\n\n#### api.getBuildType(callback)\n\nAlias for `api.get('build.type', callback)`.\n\n#### api.getBuildUser(callback)\n\nAlias for `api.get('build.user', callback)`.\n\n#### api.getBuildVersionCodename(callback)\n\nAlias for `api.get('build.version.codename', callback)`.\n\n#### api.getBuildVersionIncremental(callback)\n\nAlias for `api.get('build.version.incremental', callback)`.\n\n#### api.getBuildVersionRelease(callback)\n\nAlias for `api.get('build.version.release', callback)`.\n\n#### api.getBuildVersionSdk(callback)\n\nAlias for `api.get('build.version.sdk', callback)`.\n\n#### api.getClockMillis(callback)\n\nAlias for `api.get('clock.millis', callback)`.\n\n#### api.getClockRealtime(callback)\n\nAlias for `api.get('clock.realtime', callback)`.\n\n#### api.getClockUptime(callback)\n\nAlias for `api.get('clock.uptime', callback)`.\n
\n#### api.getDisplayDensity(callback)\n\nAlias for `api.get('display.density', callback)`.\n\n#### api.getDisplayHeight(callback)\n\nAlias for `api.get('display.height', callback)`. Note that the height may exclude any virtual home button row.\n\n#### api.getDisplayWidth(callback)\n\nAlias for `api.get('display.width', callback)`.\n\n#### api.keyDown(keyCode, callback)\n\nSends a key down event. Should be coupled with `api.keyUp()`. Note that `api.press()` performs the two events automatically.\n\n* **keyCode** The [key code][android-keycodes]. All monkeys support numeric keycodes, and some support automatic conversion from key names to key codes (e.g. `'home'` to `KEYCODE_HOME`). This will not work for number keys however. The most portable method is to simply use numeric key codes.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.keyUp(keyCode, callback)\n\nSends
a key up event. Should be coupled with `api.keyDown()`. Note that `api.press()` performs the two events automatically.\n\n* **keyCode** See `api.keyDown()`.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.list(callback)\n\nLists supported variables.\n\n* **callback(err, vars)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n * **vars** An array of supported variable names, to be used with `api.get()`.\n* Returns: The `Api` implementation instance.\n\n#### api.press(keyCode, callback)\n\nSends a key press event.\n\n* **keyCode** See `api.keyDown()`.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.quit(callback)\n\nCloses the current monkey session and quits monkey.\n\n* **callback(err)** Called when monkey
responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.sleep(ms, callback)\n\nSleeps for the given duration. Can be useful for simulating gestures.\n\n* **ms** How many milliseconds to sleep for.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.tap(x, y, callback)\n\nTaps the given coordinates.\n\n* **x** The x coordinate.\n* **y** The y coordinate.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.touchDown(x, y, callback)\n\nSends a touch down event on the given coordinates.\n\n* **x** The x coordinate.\n* **y** The y coordinate.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instanc
e.\n\n#### api.touchMove(x, y, callback)\n\nSends a touch move event on the given coordinates.\n\n* **x** The x coordinate.\n* **y** The y coordinate.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.touchUp(x, y, callback)\n\nSends a touch up event on the given coordinates.\n\n* **x** The x coordinate.\n* **y** The y coordinate.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.trackball(x, y, callback)\n\nSends a trackball event on the given coordinates.\n\n* **x** The x coordinate.\n* **y** The y coordinate.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.type(text, callback)\n\nTypes the given text.\n\n* **text** A text `String`. N
ote that only characters for which [key codes][android-keycodes] exist can be entered. Also note that any IME in use may or may not transform the text.\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n#### api.wake(callback)\n\nWakes the device from sleep and allows user input.\n\n* **callback(err)** Called when monkey responds.\n * **err** `null` when successful, `Error` otherwise.\n* Returns: The `Api` implementation instance.\n\n### Multi\n\nBuffers `Api` commands and delivers them simultaneously for greater control over timing.\n\nImplements all `Api` methods, but without the last `callback` parameter.\n\n#### multi.execute(callback)\n\nSends all buffered commands.\n\n* **callback(err, values)** Called when monkey has responded to all commands (i.e. just once at the end).\n * **err** `null` when successful, `Error` otherwise.\n * **values** An array of all respon
se values, identical to individual `Api` responses.\n\n## More information\n\n* [Monkey][monkey-site]\n - [Source code][monkey-source]\n - [Protocol][monkey-proto]\n* [Monkeyrunner][monkeyrunner-site]\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nSee [LICENSE](LICENSE).\n\nCopyright © CyberAgent, Inc. All Rights Reserved.\n\n[nodejs]: <http://nodejs.org/>\n[monkey-site]: <http://developer.android.com/tools/help/monkey.html>\n[monkey-source]: <https://github.com/android/platform_development/blob/master/cmds/monkey/>\n[monkey-proto]: <https://github.com/android/platform_development/blob/master/cmds/monkey/README.NETWORK.txt>\n[monkeyrunner-site]: <http://developer.android.com/tools/help/monkeyrunner_concepts.html>\n[node-net]: <http://nodejs.org/api/net.html>\n[node-stream]: <http://nodejs.org/api/stream.html>\n[android-keycodes]: <http://developer.android.com/reference/android/view/KeyEvent.html>\n",
+ "readmeFilename": "README.md",
+ "homepage": "https://github.com/CyberAgent/adbkit-monkey",
+ "_id": "adbkit-monkey@1.0.1",
+ "dist": {
+ "shasum": "f291be701a2efc567a63fc7aa6afcded31430be1",
+ "tarball": "http://registry.npmjs.org/adbkit-monkey/-/adbkit-monkey-1.0.1.tgz"
+ },
+ "_from": "adbkit-monkey@~1.0.1",
+ "_npmVersion": "1.3.14",
+ "_npmUser": {
+ "name": "sorccu",
+ "email": "simo@shoqolate.com"
+ },
+ "maintainers": [
+ {
+ "name": "sorccu",
+ "email": "simo@shoqolate.com"
+ },
+ {
+ "name": "cyberagent",
+ "email": "npm@cyberagent.co.jp"
+ }
+ ],
+ "directories": {},
+ "_shasum": "f291be701a2efc567a63fc7aa6afcded31430be1",
+ "_resolved": "https://registry.npmjs.org/adbkit-monkey/-/adbkit-monkey-1.0.1.tgz"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/.npmignore b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/.npmignore
new file mode 100644
index 0000000..36ee3f7
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/.npmignore
@@ -0,0 +1,30 @@
+node_modules/*
+todo.txt
+npm-debug.log
+test/*
+benchmark/*
+browser/*
+src/*
+async
+sync
+mixed
+bench.json
+js/browser
+js/browser/*
+js/debug
+js/debug/*
+reader.js
+read.txt
+bench
+.editorconfig
+.jshintrc
+ast_passes.js
+mocharun.js
+throwaway.js
+throwaway.html
+bluebird.sublime-workspace
+bluebird.sublime-project
+changelog.js
+.travis.yml
+sauce_connect.log
+bump.js
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[03/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pbkdf2.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pbkdf2.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pbkdf2.js
new file mode 100644
index 0000000..0b53e27
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pbkdf2.js
@@ -0,0 +1,123 @@
+(function() {
+
+function Tests(ASSERT, PBKDF2, MD, UTIL) {
+ describe('pbkdf2', function() {
+ it('should derive a password with hmac-sha-1 c=1', function() {
+ var dkHex = UTIL.bytesToHex(PBKDF2('password', 'salt', 1, 20));
+ ASSERT.equal(dkHex, '0c60c80f961f0e71f3a9b524af6012062fe037a6');
+ });
+
+ it('should derive a password with hmac-sha-1 c=2', function() {
+ var dkHex = UTIL.bytesToHex(PBKDF2('password', 'salt', 2, 20));
+ ASSERT.equal(dkHex, 'ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957');
+ });
+
+ it('should derive a password with hmac-sha-1 c=5 keylen=8', function() {
+ var salt = UTIL.hexToBytes('1234567878563412');
+ var dkHex = UTIL.bytesToHex(PBKDF2('password', salt, 5, 8));
+ ASSERT.equal(dkHex, 'd1daa78615f287e6');
+ });
+
+ it('should derive a password with hmac-sha-1 c=4096', function() {
+ // Note: might be too slow on old browsers
+ var dkHex = UTIL.bytesToHex(PBKDF2('password', 'salt', 4096, 20));
+ ASSERT.equal(dkHex, '4b007901b765489abead49d926f721d065a429c1');
+ });
+
+ /*
+ it('should derive a password with hmac-sha-1 c=16777216', function() {
+ // Note: too slow
+ var dkHex = UTIL.bytesToHex(PBKDF2('password', 'salt', 16777216, 20));
+ ASSERT.equal(dkHex, 'eefe3d61cd4da4e4e9945b3d6ba2158c2634e984');
+ });*/
+
+ it('should derive a password with hmac-sha-256 c=1000', function() {
+ // Note: might be too slow on old browsers
+ var salt = '4bcda0d1c689fe465c5b8a817f0ddf3d';
+ var md = MD.sha256.create();
+ var dkHex = UTIL.bytesToHex(PBKDF2('password', salt, 1000, 48, md));
+ ASSERT.equal(dkHex, '9da8a5f4ae605f35e82e5beac5f362df15c4255d88f738d641466a4107f9970238e768e72af29ac89a1b16ff277b31d2');
+ });
+
+ it('should asynchronously derive a password with hmac-sha-1 c=1', function(done) {
+ PBKDF2('password', 'salt', 1, 20, function(err, dk) {
+ var dkHex = UTIL.bytesToHex(dk);
+ ASSERT.equal(dkHex, '0c60c80f961f0e71f3a9b524af6012062fe037a6');
+ done();
+ });
+ });
+
+ it('should asynchronously derive a password with hmac-sha-1 c=2', function(done) {
+ PBKDF2('password', 'salt', 2, 20, function(err, dk) {
+ var dkHex = UTIL.bytesToHex(dk);
+ ASSERT.equal(dkHex, 'ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957');
+ done();
+ });
+ });
+
+ it('should asynchronously derive a password with hmac-sha-1 c=5 keylen=8', function(done) {
+ var salt = UTIL.hexToBytes('1234567878563412');
+ PBKDF2('password', salt, 5, 8, function(err, dk) {
+ var dkHex = UTIL.bytesToHex(dk);
+ ASSERT.equal(dkHex, 'd1daa78615f287e6');
+ done();
+ });
+ });
+
+ it('should asynchronously derive a password with hmac-sha-1 c=4096', function(done) {
+ // Note: might be too slow on old browsers
+ PBKDF2('password', 'salt', 4096, 20, function(err, dk) {
+ var dkHex = UTIL.bytesToHex(dk);
+ ASSERT.equal(dkHex, '4b007901b765489abead49d926f721d065a429c1');
+ done();
+ });
+ });
+
+ /*
+ it('should asynchronously derive a password with hmac-sha-1 c=16777216', function(done) {
+ // Note: too slow
+ PBKDF2('password', 'salt', 16777216, 20, function(err, dk) {
+ var dkHex = UTIL.bytesToHex(dk);
+ ASSERT.equal(dkHex, 'eefe3d61cd4da4e4e9945b3d6ba2158c2634e984');
+ done();
+ });
+ });*/
+
+ it('should asynchronously derive a password with hmac-sha-256 c=1000', function(done) {
+ // Note: might be too slow on old browsers
+ var salt = '4bcda0d1c689fe465c5b8a817f0ddf3d';
+ var md = MD.sha256.create();
+ PBKDF2('password', salt, 1000, 48, md, function(err, dk) {
+ var dkHex = UTIL.bytesToHex(dk);
+ ASSERT.equal(dkHex, '9da8a5f4ae605f35e82e5beac5f362df15c4255d88f738d641466a4107f9970238e768e72af29ac89a1b16ff277b31d2');
+ done();
+ });
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/pbkdf2',
+ 'forge/md',
+ 'forge/util'
+ ], function(PBKDF2, MD, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ PBKDF2(),
+ MD(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/pbkdf2')(),
+ require('../../js/md')(),
+ require('../../js/util')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pem.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pem.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pem.js
new file mode 100644
index 0000000..6b405cb
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pem.js
@@ -0,0 +1,104 @@
+(function() {
+
+function Tests(ASSERT, PEM) {
+ var _input = '-----BEGIN PRIVACY-ENHANCED MESSAGE-----\r\n' +
+ 'Proc-Type: 4,ENCRYPTED\r\n' +
+ 'Content-Domain: RFC822\r\n' +
+ 'DEK-Info: DES-CBC,F8143EDE5960C597\r\n' +
+ 'Originator-ID-Symmetric: linn@zendia.enet.dec.com,,\r\n' +
+ 'Recipient-ID-Symmetric: linn@zendia.enet.dec.com,ptf-kmc,3\r\n' +
+ 'Key-Info: DES-ECB,RSA-MD2,9FD3AAD2F2691B9A,\r\n' +
+ ' B70665BB9BF7CBCDA60195DB94F727D3\r\n' +
+ 'Recipient-ID-Symmetric: pem-dev@tis.com,ptf-kmc,4\r\n' +
+ 'Key-Info: DES-ECB,RSA-MD2,161A3F75DC82EF26,\r\n' +
+ ' E2EF532C65CBCFF79F83A2658132DB47\r\n' +
+ '\r\n' +
+ 'LLrHB0eJzyhP+/fSStdW8okeEnv47jxe7SJ/iN72ohNcUk2jHEUSoH1nvNSIWL9M\r\n' +
+ '8tEjmF/zxB+bATMtPjCUWbz8Lr9wloXIkjHUlBLpvXR0UrUzYbkNpk0agV2IzUpk\r\n' +
+ 'J6UiRRGcDSvzrsoK+oNvqu6z7Xs5Xfz5rDqUcMlK1Z6720dcBWGGsDLpTpSCnpot\r\n' +
+ 'dXd/H5LMDWnonNvPCwQUHg==\r\n' +
+ '-----END PRIVACY-ENHANCED MESSAGE-----\r\n' +
+ '-----BEGIN PRIVACY-ENHANCED MESSAGE-----\r\n' +
+ 'Proc-Type: 4,ENCRYPTED\r\n' +
+ 'Content-Domain: RFC822\r\n' +
+ 'DEK-Info: DES-CBC,BFF968AA74691AC1\r\n' +
+ 'Originator-Certificate:\r\n' +
+ ' MIIBlTCCAScCAWUwDQYJKoZIhvcNAQECBQAwUTELMAkGA1UEBhMCVVMxIDAeBgNV\r\n' +
+ ' BAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMQ8wDQYDVQQLEwZCZXRhIDExDzAN\r\n' +
+ ' BgNVBAsTBk5PVEFSWTAeFw05MTA5MDQxODM4MTdaFw05MzA5MDMxODM4MTZaMEUx\r\n' +
+ ' CzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEU\r\n' +
+ ' MBIGA1UEAxMLVGVzdCBVc2VyIDEwWTAKBgRVCAEBAgICAANLADBIAkEAwHZHl7i+\r\n' +
+ ' yJcqDtjJCowzTdBJrdAiLAnSC+CnnjOJELyuQiBgkGrgIh3j8/x0fM+YrsyF1u3F\r\n' +
+ ' LZPVtzlndhYFJQIDAQABMA0GCSqGSIb3DQEBAgUAA1kACKr0PqphJYw1j+YPtcIq\r\n' +
+ ' iWlFPuN5jJ79Khfg7ASFxskYkEMjRNZV/HZDZQEhtVaU7Jxfzs2wfX5byMp2X3U/\r\n' +
+ ' 5XUXGx7qusDgHQGs7Jk9W8CW1fuSWUgN4w==\r\n' +
+ 'Key-Info: RSA,\r\n' +
+ ' I3rRIGXUGWAF8js5wCzRTkdhO34PTHdRZY9Tuvm03M+NM7fx6qc5udixps2Lng0+\r\n' +
+ ' wGrtiUm/ovtKdinz6ZQ/aQ==\r\n' +
+ 'Issuer-Certificate:\r\n' +
+ ' MIIB3DCCAUgCAQowDQYJKoZIhvcNAQECBQAwTzELMAkGA1UEBhMCVVMxIDAeBgNV\r\n' +
+ ' BAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMQ8wDQYDVQQLEwZCZXRhIDExDTAL\r\n' +
+ ' BgNVBAsTBFRMQ0EwHhcNOTEwOTAxMDgwMDAwWhcNOTIwOTAxMDc1OTU5WjBRMQsw\r\n' +
+ ' CQYDVQQGEwJVUzEgMB4GA1UEChMXUlNBIERhdGEgU2VjdXJpdHksIEluYy4xDzAN\r\n' +
+ ' BgNVBAsTBkJldGEgMTEPMA0GA1UECxMGTk9UQVJZMHAwCgYEVQgBAQICArwDYgAw\r\n' +
+ ' XwJYCsnp6lQCxYykNlODwutF/jMJ3kL+3PjYyHOwk+/9rLg6X65B/LD4bJHtO5XW\r\n' +
+ ' cqAz/7R7XhjYCm0PcqbdzoACZtIlETrKrcJiDYoP+DkZ8k1gCk7hQHpbIwIDAQAB\r\n' +
+ ' MA0GCSqGSIb3DQEBAgUAA38AAICPv4f9Gx/tY4+p+4DB7MV+tKZnvBoy8zgoMGOx\r\n' +
+ ' dD2jMZ/3HsyWKWgSF0eH/AJB3qr9zosG47pyMnTf3aSy2nBO7CMxpUWRBcXUpE+x\r\n' +
+ ' EREZd9++32ofGBIXaialnOgVUn0OzSYgugiQ077nJLDUj0hQehCizEs5wUJ35a5h\r\n' +
+ 'MIC-Info: RSA-MD5,RSA,\r\n' +
+ ' UdFJR8u/TIGhfH65ieewe2lOW4tooa3vZCvVNGBZirf/7nrgzWDABz8w9NsXSexv\r\n' +
+ ' AjRFbHoNPzBuxwmOAFeA0HJszL4yBvhG\r\n' +
+ 'Recipient-ID-Asymmetric:\r\n' +
+ ' MFExCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5j\r\n' +
+ ' LjEPMA0GA1UECxMGQmV0YSAxMQ8wDQYDVQQLEwZOT1RBUlk=,66\r\n' +
+ 'Key-Info: RSA,\r\n' +
+ ' O6BS1ww9CTyHPtS3bMLD+L0hejdvX6Qv1HK2ds2sQPEaXhX8EhvVphHYTjwekdWv\r\n' +
+ ' 7x0Z3Jx2vTAhOYHMcqqCjA==\r\n' +
+ '\r\n' +
+ 'qeWlj/YJ2Uf5ng9yznPbtD0mYloSwIuV9FRYx+gzY+8iXd/NQrXHfi6/MhPfPF3d\r\n' +
+ 'jIqCJAxvld2xgqQimUzoS1a4r7kQQ5c/Iua4LqKeq3ciFzEv/MbZhA==\r\n' +
+ '-----END PRIVACY-ENHANCED MESSAGE-----\r\n' +
+ '-----BEGIN RSA PRIVATE KEY-----\r\n' +
+ 'MIIBPAIBAAJBALjXU+IdHkSkdBscgXf+EBoa55ruAIsU50uDFjFBkp+rWFt5AOGF\r\n' +
+ '9xL1/HNIby5M64BCw021nJTZKEOmXKdmzYsCAwEAAQJBAApyYRNOgf9vLAC8Q7T8\r\n' +
+ 'bvyKuLxQ50b1D319EywFgLv1Yn0s/F9F+Rew6c04Q0pIqmuOGUM7z94ul/y5OlNJ\r\n' +
+ '2cECIQDveEW1ib2+787l7Y0tMeDzf/HQl4MAWdcxXWOeUFK+7QIhAMWZsukutEn9\r\n' +
+ '9/yqFMt8bL/dclfNn1IAgUL4+dMJ7zdXAiEAhaxGhVKxN28XuCOFhe/s2R/XdQ/O\r\n' +
+ 'UZjU1bqCzDGcLvUCIGYmxu71Tg7SVFkyM/3eHPozKOFrU2m5CRnuTHhlMl2RAiEA\r\n' +
+ '0vhM5TEmmNWz0anPVabqDj9TA0z5MsDJQcn5NmO9xnw=\r\n' +
+ '-----END RSA PRIVATE KEY-----\r\n';
+
+ describe('pem', function() {
+ it('should decode and re-encode PEM messages', function() {
+ var msgs = PEM.decode(_input);
+
+ var output = '';
+ for(var i = 0; i < msgs.length; ++i) {
+ output += PEM.encode(msgs[i]);
+ }
+
+ ASSERT.equal(output, _input);
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/pem'
+ ], function(PEM) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ PEM()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/pem')());
+}
+
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[34/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/timeline.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/timeline.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/timeline.js
new file mode 100644
index 0000000..59799a0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/timeline.js
@@ -0,0 +1 @@
+module.exports = [{"bug":{"history":[{"changes":[{"removed":"","added":"gmealer@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/gmealer@mozilla.com","name":"gmealer@mozilla.com"},"change_time":"2011-07-19T22:35:56Z"},{"changes":[{"removed":"NEW","added":"RESOLVED","field_name":"status"},{"removed":"","added":"WONTFIX","field_name":"resolution"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/fayearthur+bugs@gmail.com","name":"fayearthur+bugs@gmail.com"},"change_time":"2011-07-19T22:24:59Z"},{"changes":[{"removed":"","added":"fayearthur+bugs@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/fayearthur+bugs@gmail.com","name":"fayearthur+bugs@gmail.com"},"change_time":"2011-07-13T19:49:06Z"},{"changes":[{"removed":"","added":"hskupin@gmail.com, stomlinson@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":
"hskupin@gmail.com"},"change_time":"2011-07-13T19:11:32Z"},{"changes":[{"removed":"","added":"ctalbert@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-13T18:43:17Z"}],"summary":"Adding isNumber, isFunction, isString, isArray and isObject to assert.js","last_change_time":"2011-07-19T22:35:56Z","comments":[{"is_private":false,"creator":{"real_name":"Geo Mealer [:geo]","name":"gmealer"},"text":"","id":5600392,"creation_time":"2011-07-19T22:35:56Z"},{"is_private":false,"creator":{"real_name":"Heather Arthur [:harth]","name":"fayearthur+bugs"},"text":"","id":5600359,"creation_time":"2011-07-19T22:24:59Z"},{"is_private":false,"creator":{"real_name":"Heather Arthur [:harth]","name":"fayearthur+bugs"},"text":"","id":5589849,"creation_time":"2011-07-13T20:24:38Z"},{"is_private":false,"creator":{"real_name":"Shane Tomlinson","name":"stomlinson"},"text":"","id":5589791,"cr
eation_time":"2011-07-13T19:59:43Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5589782,"creation_time":"2011-07-13T19:56:44Z"},{"is_private":false,"creator":{"real_name":"Heather Arthur [:harth]","name":"fayearthur+bugs"},"text":"","id":5589758,"creation_time":"2011-07-13T19:49:06Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5589591,"creation_time":"2011-07-13T18:42:07Z"}],"id":671367},"events":[{"time":"2011-07-19T22:35:56Z","changeset":{"changes":[{"removed":"","added":"gmealer@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/gmealer@mozilla.com","name":"gmealer@mozilla.com"},"change_time":"2011-07-19T22:35:56Z"}},{"time":"2011-07-19T22:35:56Z","comment":{"is_private":false,"creator":{"real_name":"Geo Mealer [:geo]","name":"gmealer"},"text":"","id":5600392,"creation_time":"2011-07-19T22:35:56Z"}},{"time":"2011-07-19
T22:24:59Z","changeset":{"changes":[{"removed":"NEW","added":"RESOLVED","field_name":"status"},{"removed":"","added":"WONTFIX","field_name":"resolution"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/fayearthur+bugs@gmail.com","name":"fayearthur+bugs@gmail.com"},"change_time":"2011-07-19T22:24:59Z"}},{"time":"2011-07-19T22:24:59Z","comment":{"is_private":false,"creator":{"real_name":"Heather Arthur [:harth]","name":"fayearthur+bugs"},"text":"","id":5600359,"creation_time":"2011-07-19T22:24:59Z"}}]},{"bug":{"history":[{"changes":[{"removed":"","added":"ctalbert@mozilla.com, fayearthur+bugs@gmail.com, jhammel@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T20:22:11Z"}],"summary":"mozmill \"--profile\" option not working with relative path","last_change_time":"2011-07-19T20:46:19Z","comments":[{"is_private":false,"creator":{"real_name":"Jeff H
ammel [:jhammel]","name":"jhammel"},"text":"","id":5600020,"creation_time":"2011-07-19T20:46:19Z"},{"is_private":false,"creator":{"real_name":"Marc-Aurèle DARCHE","name":"mozdev"},"text":"","id":5599999,"creation_time":"2011-07-19T20:39:07Z"},{"is_private":false,"creator":{"real_name":"Marc-Aurèle DARCHE","name":"mozdev"},"text":"","id":5599848,"creation_time":"2011-07-19T19:29:35Z"}],"id":672605},"events":[{"time":"2011-07-19T20:46:19Z","comment":{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5600020,"creation_time":"2011-07-19T20:46:19Z"}},{"time":"2011-07-19T20:39:07Z","comment":{"is_private":false,"creator":{"real_name":"Marc-Aurèle DARCHE","name":"mozdev"},"text":"","id":5599999,"creation_time":"2011-07-19T20:39:07Z"}},{"time":"2011-07-19T20:22:11Z","changeset":{"changes":[{"removed":"","added":"ctalbert@mozilla.com, fayearthur+bugs@gmail.com, jhammel@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugz
illa.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T20:22:11Z"}},{"time":"2011-07-19T19:29:35Z","comment":{"is_private":false,"creator":{"real_name":"Marc-Aurèle DARCHE","name":"mozdev"},"text":"","id":5599848,"creation_time":"2011-07-19T19:29:35Z"}}]},{"bug":{"history":[{"changes":[{"removed":"","added":"ehsan@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ehsan@mozilla.com","name":"ehsan@mozilla.com"},"change_time":"2011-07-19T20:37:46Z"},{"changes":[{"removed":"","added":"fayearthur+bugs@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-07-19T17:37:11Z"},{"changes":[{"removed":"","added":"ctalbert@mozilla.com, jhammel@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"
},"change_time":"2011-07-19T17:35:58Z"},{"changes":[{"removed":"","added":"ted.mielczarek@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ted.mielczarek@gmail.com","name":"ted.mielczarek@gmail.com"},"change_time":"2011-07-18T12:00:25Z"},{"changes":[{"removed":"","added":"bmo@edmorley.co.uk","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/bmo@edmorley.co.uk","name":"bmo@edmorley.co.uk"},"change_time":"2011-07-17T11:20:51Z"},{"changes":[{"removed":"","added":"bzbarsky@mit.edu","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/bzbarsky@mit.edu","name":"bzbarsky@mit.edu"},"change_time":"2011-07-14T03:29:52Z"},{"changes":[{"removed":"","added":"dmandelin@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/dmandelin@mozilla.com","name":"dmandelin@mozilla.com"},"change_time":"2011-07-14T00:27:21Z"},{"changes":[{"removed":"","added
":"kairo@kairo.at","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/kairo@kairo.at","name":"kairo@kairo.at"},"change_time":"2011-07-14T00:04:16Z"},{"changes":[{"removed":"","added":"gavin.sharp@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/gavin.sharp@gmail.com","name":"gavin.sharp@gmail.com"},"change_time":"2011-07-13T23:17:24Z"},{"changes":[{"removed":"","added":"anygregor@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/anygregor@gmail.com","name":"anygregor@gmail.com"},"change_time":"2011-07-13T19:57:34Z"},{"changes":[{"removed":"","added":"luke@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/luke@mozilla.com","name":"luke@mozilla.com"},"change_time":"2011-07-13T18:53:42Z"},{"changes":[{"removed":"","added":"sphink@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9
/user/sphink@gmail.com","name":"sphink@gmail.com"},"change_time":"2011-07-13T18:23:30Z"},{"changes":[{"removed":"","added":"davemgarrett@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/davemgarrett@gmail.com","name":"davemgarrett@gmail.com"},"change_time":"2011-07-13T18:21:27Z"},{"changes":[{"removed":"","added":"khuey@kylehuey.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/khuey@kylehuey.com","name":"khuey@kylehuey.com"},"change_time":"2011-07-13T18:21:08Z"}],"summary":"Split chrome into multiple compartments for better accounting of JS memory used by chrome code (and add-ons)","last_change_time":"2011-07-19T20:37:46Z","comments":[{"is_private":false,"creator":{"real_name":"Ehsan Akhgari [:ehsan]","name":"ehsan"},"text":"","id":5599990,"creation_time":"2011-07-19T20:37:46Z"},{"is_private":false,"creator":{"real_name":"Gregor Wagner","name":"anygregor"},"text":"","id":5589947,"creation_time":"20
11-07-13T21:04:28Z"},{"is_private":false,"creator":{"real_name":"Andreas Gal :gal","name":"gal"},"text":"","id":5589879,"creation_time":"2011-07-13T20:39:32Z"},{"is_private":false,"creator":{"real_name":"Gregor Wagner","name":"anygregor"},"text":"","id":5589812,"creation_time":"2011-07-13T20:07:18Z"},{"is_private":false,"creator":{"real_name":"Luke Wagner [:luke]","name":"luke"},"text":"","id":5589801,"creation_time":"2011-07-13T20:03:36Z"},{"is_private":false,"creator":{"real_name":"Gregor Wagner","name":"anygregor"},"text":"","id":5589787,"creation_time":"2011-07-13T19:57:34Z"},{"is_private":false,"creator":{"real_name":"Ehsan Akhgari [:ehsan]","name":"ehsan"},"text":"","id":5589485,"creation_time":"2011-07-13T18:15:17Z"}],"id":671352},"events":[{"time":"2011-07-19T20:37:46Z","changeset":{"changes":[{"removed":"","added":"ehsan@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ehsan@mozilla.com","name":"ehsan@mozilla.com"},"change_tim
e":"2011-07-19T20:37:46Z"}},{"time":"2011-07-19T20:37:46Z","comment":{"is_private":false,"creator":{"real_name":"Ehsan Akhgari [:ehsan]","name":"ehsan"},"text":"","id":5599990,"creation_time":"2011-07-19T20:37:46Z"}},{"time":"2011-07-19T17:37:11Z","changeset":{"changes":[{"removed":"","added":"fayearthur+bugs@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-07-19T17:37:11Z"}},{"time":"2011-07-19T17:35:58Z","changeset":{"changes":[{"removed":"","added":"ctalbert@mozilla.com, jhammel@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-07-19T17:35:58Z"}},{"time":"2011-07-18T12:00:25Z","changeset":{"changes":[{"removed":"","added":"ted.mielczarek@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ted.mielczarek
@gmail.com","name":"ted.mielczarek@gmail.com"},"change_time":"2011-07-18T12:00:25Z"}}]},{"bug":{"history":[{"changes":[{"attachment_id":"546836","removed":"text/x-python","added":"text/plain","field_name":"attachment.content_type"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T18:28:25Z"},{"changes":[{"removed":"","added":"ctalbert@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-07-19T17:58:20Z"}],"summary":"mozprofile should set permissions for profiles","last_change_time":"2011-07-19T18:28:25Z","comments":[{"is_private":false,"creator":{"real_name":"Joel Maher (:jmaher)","name":"jmaher"},"text":"","id":5599602,"creation_time":"2011-07-19T18:15:26Z"},{"is_private":false,"creator":{"real_name":"Joel Maher (:jmaher)","name":"jmaher"},"text":"","id":5599285,"creation_tim
e":"2011-07-19T16:21:34Z"},{"is_private":false,"creator":{"real_name":"Joel Maher (:jmaher)","name":"jmaher"},"text":"","id":5554367,"creation_time":"2011-06-24T17:41:38Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5552758,"creation_time":"2011-06-23T23:26:21Z"}],"id":666791},"events":[{"time":"2011-07-19T18:28:25Z","changeset":{"changes":[{"attachment_id":"546836","removed":"text/x-python","added":"text/plain","field_name":"attachment.content_type"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T18:28:25Z"}},{"time":"2011-07-19T18:15:26Z","comment":{"is_private":false,"creator":{"real_name":"Joel Maher (:jmaher)","name":"jmaher"},"text":"","id":5599602,"creation_time":"2011-07-19T18:15:26Z"}},{"time":"2011-07-19T17:58:20Z","changeset":{"changes":[{"removed":"","added":"ctalbert@mozilla.com","field_name":"cc"}],"changer":{"ref":"ht
tps://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-07-19T17:58:20Z"}},{"time":"2011-07-19T16:21:34Z","comment":{"is_private":false,"creator":{"real_name":"Joel Maher (:jmaher)","name":"jmaher"},"text":"","id":5599285,"creation_time":"2011-07-19T16:21:34Z"}}]},{"bug":{"history":[{"changes":[{"removed":"NEW","added":"RESOLVED","field_name":"status"},{"removed":"","added":"FIXED","field_name":"resolution"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T17:57:44Z"},{"changes":[{"removed":"nobody@mozilla.org","added":"jhammel@mozilla.com","field_name":"assigned_to"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T15:39:01Z"},{"changes":[{"removed":"[mozmill-2.0?]","added":"[mozmill-2.0+]","field_name":"whiteboard"}],"changer":{"ref":"htt
ps://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T04:24:09Z"},{"changes":[{"attachment_id":"545960","removed":"review?(ctalbert@mozilla.com)","added":"review+","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-07-18T22:04:12Z"},{"changes":[{"attachment_id":"545960","removed":"","added":"review?(ctalbert@mozilla.com)","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-14T18:16:53Z"},{"changes":[{"removed":"","added":"ctalbert@mozilla.com, fayearthur+bugs@gmail.com","field_name":"cc"},{"removed":"","added":"[mozmill-2.0?]","field_name":"whiteboard"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-13T21:37:01Z"}],
"summary":"mutt processhandler and mozprocess processhandler: to merge?","last_change_time":"2011-07-19T17:57:44Z","comments":[{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5599538,"creation_time":"2011-07-19T17:57:44Z"},{"is_private":false,"creator":{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":5597782,"creation_time":"2011-07-18T22:04:12Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5591772,"creation_time":"2011-07-14T18:16:53Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5590023,"creation_time":"2011-07-13T21:35:42Z"}],"id":671420},"events":[{"time":"2011-07-19T17:57:44Z","changeset":{"changes":[{"removed":"NEW","added":"RESOLVED","field_name":"status"},{"removed":"","added":"FIXED","field_name":"resolution"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@
mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T17:57:44Z"}},{"time":"2011-07-19T17:57:44Z","comment":{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5599538,"creation_time":"2011-07-19T17:57:44Z"}},{"time":"2011-07-19T15:39:01Z","changeset":{"changes":[{"removed":"nobody@mozilla.org","added":"jhammel@mozilla.com","field_name":"assigned_to"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T15:39:01Z"}},{"time":"2011-07-19T04:24:09Z","changeset":{"changes":[{"removed":"[mozmill-2.0?]","added":"[mozmill-2.0+]","field_name":"whiteboard"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-07-19T04:24:09Z"}},{"time":"2011-07-18T22:04:12Z","changeset":{"changes":[{"attachment_id":"545960","removed":"review?(ctalbert@mozilla.com)","added":"re
view+","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-07-18T22:04:12Z"}},{"time":"2011-07-18T22:04:12Z","comment":{"is_private":false,"creator":{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":5597782,"creation_time":"2011-07-18T22:04:12Z"}}]},{"bug":{"history":[{"changes":[{"attachment_id":"546171","removed":"review?(fayearthur+bugs@gmail.com)","added":"review+","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/fayearthur+bugs@gmail.com","name":"fayearthur+bugs@gmail.com"},"change_time":"2011-07-19T17:42:04Z"},{"changes":[{"attachment_id":"546171","removed":"","added":"review?(fayearthur+bugs@gmail.com), feedback?(halbersa@gmail.com)","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-07-15T16:21:21Z"},{"chan
ges":[{"attachment_id":"545775","removed":"review?(fayearthur+bugs@gmail.com)","added":"review+","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/fayearthur+bugs@gmail.com","name":"fayearthur+bugs@gmail.com"},"change_time":"2011-07-14T19:40:03Z"},{"changes":[{"attachment_id":"545771","removed":"0","added":"1","field_name":"attachment.is_obsolete"},{"attachment_id":"545771","removed":"review?(fayearthur+bugs@gmail.com)","added":"","field_name":"flag"},{"attachment_id":"545775","removed":"","added":"review?(fayearthur+bugs@gmail.com)","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-07-13T23:19:12Z"},{"changes":[{"attachment_id":"545771","removed":"","added":"review?(fayearthur+bugs@gmail.com)","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-0
7-13T23:14:09Z"},{"changes":[{"attachment_id":"535258","removed":"0","added":"1","field_name":"attachment.is_obsolete"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-07-13T23:12:37Z"},{"changes":[{"removed":"","added":"661408","field_name":"blocks"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-06-28T23:56:05Z"},{"changes":[{"attachment_id":"535258","removed":"feedback?(hskupin@gmail.com)","added":"feedback-","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-05-26T07:48:02Z"},{"changes":[{"attachment_id":"535258","removed":"","added":"feedback?(hskupin@gmail.com)","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_
time":"2011-05-26T02:57:15Z"},{"changes":[{"removed":"","added":"halbersa@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-05-26T02:48:33Z"},{"changes":[{"removed":"waitForPageLoad() fails if the document owner is not a tab but an HTMLDocument","added":"waitForPageLoad() fails if the document owner is not a tab but an HTMLDocument (add support for iframes)","field_name":"summary"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-05-25T23:56:38Z"},{"changes":[{"attachment_id":"534720","removed":"review?(ctalbert@mozilla.com)","added":"review+","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-05-25T23:50:33Z"},{"changes":[{"removed":"","added":"fayearthur+bugs@gmail.com","field_
name":"cc"},{"removed":"[mozmill-1.5.4+]","added":"[mozmill-1.5.4+][mozmill-2.0+]","field_name":"whiteboard"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-05-25T12:08:34Z"},{"changes":[{"removed":"","added":"ctalbert@mozilla.com","field_name":"cc"},{"removed":"[mozmill-1.5.4?]","added":"[mozmill-1.5.4+]","field_name":"whiteboard"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-05-24T21:25:21Z"},{"changes":[{"attachment_id":"534714","removed":"0","added":"1","field_name":"attachment.is_obsolete"},{"attachment_id":"534714","removed":"review?(ctalbert@mozilla.com)","added":"","field_name":"flag"},{"attachment_id":"534720","removed":"","added":"review?(ctalbert@mozilla.com)","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"chang
e_time":"2011-05-24T11:15:13Z"},{"changes":[{"attachment_id":"534445","removed":"0","added":"1","field_name":"attachment.is_obsolete"},{"attachment_id":"534714","removed":"","added":"review?(ctalbert@mozilla.com)","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-05-24T10:59:06Z"},{"changes":[{"removed":"waitForPageLoad() fails for Discovery Pane with 'Specified tab hasn't been found.'","added":"waitForPageLoad() fails if the document owner is not a tab but an HTMLDocument","field_name":"summary"},{"removed":"","added":"in-testsuite?","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-05-24T10:53:16Z"},{"changes":[{"removed":"waitForPageLoad() fails for iFrames with 'Specified tab hasn't been found.'","added":"waitForPageLoad() fails for Discovery Pane with 'Specified tab hasn't be
en found.'","field_name":"summary"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-05-24T00:22:33Z"},{"changes":[{"removed":"","added":"[mozmill-1.5.4?]","field_name":"whiteboard"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-05-23T21:33:23Z"},{"changes":[{"removed":"","added":"regression","field_name":"keywords"},{"removed":"NEW","added":"ASSIGNED","field_name":"status"},{"removed":"x86_64","added":"All","field_name":"platform"},{"removed":"","added":"604878","field_name":"blocks"},{"removed":"nobody@mozilla.org","added":"hskupin@gmail.com","field_name":"assigned_to"},{"removed":"waitForPageLoad() does not handle iframes","added":"waitForPageLoad() fails for iFrames with 'Specified tab hasn't been found.'","field_name":"summary"},{"removed":"Linux","added":"All","field_name":"op_sys"}],"changer":{"ref":"https://a
pi-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-05-23T15:59:53Z"},{"changes":[{"removed":"","added":"alex.lakatos@softvision.ro, hskupin@gmail.com, vlad.maniac@softvision.ro","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/vlad.maniac@softvision.ro","name":"vlad.maniac@softvision.ro"},"change_time":"2011-05-23T15:24:49Z"}],"summary":"waitForPageLoad() fails if the document owner is not a tab but an HTMLDocument (add support for iframes)","last_change_time":"2011-07-19T17:42:04Z","comments":[{"is_private":false,"creator":{"real_name":"Heather Arthur [:harth]","name":"fayearthur+bugs"},"text":"","id":5599498,"creation_time":"2011-07-19T17:42:04Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5593624,"creation_time":"2011-07-15T16:21:21Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","i
d":5592472,"creation_time":"2011-07-14T22:38:58Z"},{"is_private":false,"creator":{"real_name":"Heather Arthur [:harth]","name":"fayearthur+bugs"},"text":"","id":5591961,"creation_time":"2011-07-14T19:40:03Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5590242,"creation_time":"2011-07-13T23:19:12Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5590234,"creation_time":"2011-07-13T23:14:09Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5590231,"creation_time":"2011-07-13T23:12:37Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5494401,"creation_time":"2011-05-26T07:48:02Z"},{"is_private":false,"creator":{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":5494130,"creation_time":"2011-05-26T02:58:56Z"},{"is_private":false,"creator"
:{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":5494127,"creation_time":"2011-05-26T02:57:15Z"},{"is_private":false,"creator":{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":5493838,"creation_time":"2011-05-25T23:50:33Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5491980,"creation_time":"2011-05-25T12:08:34Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5488829,"creation_time":"2011-05-24T11:18:12Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5488828,"creation_time":"2011-05-24T11:15:13Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5488811,"creation_time":"2011-05-24T10:59:06Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5488807,"
creation_time":"2011-05-24T10:53:16Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5488698,"creation_time":"2011-05-24T09:37:36Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5488122,"creation_time":"2011-05-24T00:22:33Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5487989,"creation_time":"2011-05-23T23:17:41Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5487883,"creation_time":"2011-05-23T22:39:31Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5487655,"creation_time":"2011-05-23T21:33:23Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5486617,"creation_time":"2011-05-23T15:59:53Z"},{"is_private":false,"creator":{"real_name":"Maniac V
lad Florin (:vladmaniac)","name":"vlad.maniac"},"text":"","id":5486535,"creation_time":"2011-05-23T15:23:48Z"}],"id":659000},"events":[{"time":"2011-07-19T17:42:04Z","changeset":{"changes":[{"attachment_id":"546171","removed":"review?(fayearthur+bugs@gmail.com)","added":"review+","field_name":"flag"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/fayearthur+bugs@gmail.com","name":"fayearthur+bugs@gmail.com"},"change_time":"2011-07-19T17:42:04Z"}},{"time":"2011-07-19T17:42:04Z","comment":{"is_private":false,"creator":{"real_name":"Heather Arthur [:harth]","name":"fayearthur+bugs"},"text":"","id":5599498,"creation_time":"2011-07-19T17:42:04Z"}}]},{"bug":{"history":[],"summary":"QA Companion marked incompatible for Firefox versions higher than 6.*.","last_change_time":"2011-07-18T23:00:06Z","comments":[{"is_private":false,"creator":{"real_name":"Al Billings [:abillings]","name":"abillings"},"text":"","id":5597976,"creation_time":"2011-07-18T23:00:06Z"}],"id":672393},"
events":[{"time":"2011-07-18T23:00:06Z","comment":{"is_private":false,"creator":{"real_name":"Al Billings [:abillings]","name":"abillings"},"text":"","id":5597976,"creation_time":"2011-07-18T23:00:06Z"}}]},{"bug":{"history":[{"changes":[{"removed":"","added":"khuey@kylehuey.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/khuey@kylehuey.com","name":"khuey@kylehuey.com"},"change_time":"2011-07-18T20:35:37Z"},{"changes":[{"removed":"","added":"kairo@kairo.at","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/kairo@kairo.at","name":"kairo@kairo.at"},"change_time":"2010-04-05T16:18:55Z"},{"changes":[{"removed":"","added":"mook.moz+mozbz@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mook@songbirdnest.com","name":"mook@songbirdnest.com"},"change_time":"2010-03-16T21:34:23Z"},{"changes":[{"removed":"","added":"harthur@cmu.edu","field_name":"cc"}],"changer":{"ref":"http
s://api-dev.bugzilla.mozilla.org/0.9/user/fayearthur+bugs@gmail.com","name":"fayearthur+bugs@gmail.com"},"change_time":"2010-03-16T04:31:00Z"},{"changes":[{"removed":"","added":"ted.mielczarek@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ted.mielczarek@gmail.com","name":"ted.mielczarek@gmail.com"},"change_time":"2010-03-15T23:52:39Z"},{"changes":[{"removed":"","added":"552533","field_name":"depends_on"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/dwitte@gmail.com","name":"dwitte@gmail.com"},"change_time":"2010-03-15T22:02:20Z"},{"changes":[{"removed":"","added":"447581","field_name":"blocks"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/dietrich@mozilla.com","name":"dietrich@mozilla.com"},"change_time":"2010-03-02T23:57:25Z"},{"changes":[{"removed":"412531","added":"","field_name":"blocks"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/dietrich@mozilla.com","name":"dietrich@
mozilla.com"},"change_time":"2009-12-11T02:49:08Z"},{"changes":[{"removed":"","added":"Pidgeot18@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/Pidgeot18@gmail.com","name":"Pidgeot18@gmail.com"},"change_time":"2009-10-26T14:47:22Z"},{"changes":[{"removed":"js-ctypes","added":"js-ctypes","field_name":"component"},{"removed":"Trunk","added":"unspecified","field_name":"version"},{"removed":"Other Applications","added":"Core","field_name":"product"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mozillamarcia.knous@gmail.com","name":"mozillamarcia.knous@gmail.com"},"change_time":"2009-10-02T10:17:18Z"},{"changes":[{"removed":"","added":"jwalden+bmo@mit.edu","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jwalden+bmo@mit.edu","name":"jwalden+bmo@mit.edu"},"change_time":"2009-08-17T19:11:28Z"},{"changes":[{"removed":"","added":"ajvincent@gmail.com","field_name":"cc"}],"changer":{"ref":"ht
tps://api-dev.bugzilla.mozilla.org/0.9/user/ajvincent@gmail.com","name":"ajvincent@gmail.com"},"change_time":"2009-08-13T00:28:01Z"},{"changes":[{"removed":"","added":"benjamin@smedbergs.us","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/benjamin@smedbergs.us","name":"benjamin@smedbergs.us"},"change_time":"2009-07-23T03:14:04Z"},{"changes":[{"removed":"","added":"highmind63@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/highmind63@gmail.com","name":"highmind63@gmail.com"},"change_time":"2009-07-23T01:02:51Z"},{"changes":[{"removed":"","added":"shaver@mozilla.org","field_name":"cc"},{"removed":"JavaScript Engine","added":"js-ctypes","field_name":"component"},{"removed":"general@js.bugs","added":"nobody@mozilla.org","field_name":"assigned_to"},{"removed":"Core","added":"Other Applications","field_name":"product"},{"removed":"add a pinvoke-like method to js","added":"Support C++ calling from JSctypes",
"field_name":"summary"},{"removed":"general@spidermonkey.bugs","added":"js-ctypes@otherapps.bugs","field_name":"qa_contact"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/shaver@mozilla.org","name":"shaver@mozilla.org"},"change_time":"2009-07-23T00:55:48Z"},{"changes":[{"removed":"","added":"ryanvm@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ryanvm@gmail.com","name":"ryanvm@gmail.com"},"change_time":"2009-07-23T00:34:18Z"},{"changes":[{"removed":"","added":"412531","field_name":"blocks"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/dietrich@mozilla.com","name":"dietrich@mozilla.com"},"change_time":"2009-07-23T00:06:41Z"},{"changes":[{"removed":"","added":"dvander@alliedmods.net","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/dvander@alliedmods.net","name":"dvander@alliedmods.net"},"change_time":"2009-07-23T00:03:46Z"},{"changes":[{"removed":"","added":"dietr
ich@mozilla.com, mark.finkle@gmail.com","field_name":"cc"},{"removed":"","added":"[ts][tsnap]","field_name":"whiteboard"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/dietrich@mozilla.com","name":"dietrich@mozilla.com"},"change_time":"2009-07-22T23:58:23Z"}],"summary":"Support C++ calling from JSctypes","last_change_time":"2011-07-18T20:35:37Z","comments":[{"is_private":false,"creator":{"real_name":"Ted Mielczarek [:ted, :luser]","name":"ted.mielczarek"},"text":"","id":4586274,"creation_time":"2010-03-15T23:52:39Z"},{"is_private":false,"creator":{"real_name":"Dan Witte (:dwitte)","name":"dwitte"},"text":"","id":4586028,"creation_time":"2010-03-15T22:21:21Z"},{"is_private":false,"creator":{"real_name":"Dan Witte (:dwitte)","name":"dwitte"},"text":"","id":4586006,"creation_time":"2010-03-15T22:11:11Z"},{"is_private":false,"creator":{"real_name":"Joshua Cranmer [:jcranmer]","name":"Pidgeot18"},"text":"","id":4364260,"creation_time":"2009-10-26T18:33:21Z"},{"is_priva
te":false,"creator":{"real_name":"Dan Witte (:dwitte)","name":"dwitte"},"text":"","id":4364119,"creation_time":"2009-10-26T17:27:05Z"},{"is_private":false,"creator":{"real_name":"Joshua Cranmer [:jcranmer]","name":"Pidgeot18"},"text":"","id":4363794,"creation_time":"2009-10-26T14:47:22Z"},{"is_private":false,"creator":{"real_name":"Benjamin Smedberg [:bsmedberg]","name":"benjamin"},"text":"","id":4211892,"creation_time":"2009-07-23T03:14:04Z"},{"is_private":false,"creator":{"real_name":"Mike Shaver (:shaver)","name":"shaver"},"text":"","id":4211710,"creation_time":"2009-07-23T00:56:10Z"},{"is_private":false,"creator":{"real_name":"Taras Glek (:taras)","name":"tglek"},"text":"","id":4211707,"creation_time":"2009-07-23T00:54:06Z"},{"is_private":false,"creator":{"real_name":"Mike Shaver (:shaver)","name":"shaver"},"text":"","id":4211677,"creation_time":"2009-07-23T00:42:01Z"},{"is_private":false,"creator":{"real_name":"Taras Glek (:taras)","name":"tglek"},"text":"","id":4211672,"creati
on_time":"2009-07-23T00:40:10Z"},{"is_private":false,"creator":{"real_name":"Mike Shaver (:shaver)","name":"shaver"},"text":"","id":4211668,"creation_time":"2009-07-23T00:38:34Z"},{"is_private":false,"creator":{"real_name":"Taras Glek (:taras)","name":"tglek"},"text":"","id":4211665,"creation_time":"2009-07-23T00:36:58Z"},{"is_private":false,"creator":{"real_name":"Mike Shaver (:shaver)","name":"shaver"},"text":"","id":4211660,"creation_time":"2009-07-23T00:34:27Z"},{"is_private":false,"creator":{"real_name":"Taras Glek (:taras)","name":"tglek"},"text":"","id":4211624,"creation_time":"2009-07-23T00:15:38Z"},{"is_private":false,"creator":{"real_name":"Mike Shaver (:shaver)","name":"shaver"},"text":"","id":4211608,"creation_time":"2009-07-23T00:08:16Z"},{"is_private":false,"creator":{"real_name":"Taras Glek (:taras)","name":"tglek"},"text":"","id":4211586,"creation_time":"2009-07-22T23:57:14Z"}],"id":505907},"events":[{"time":"2011-07-18T20:35:37Z","changeset":{"changes":[{"removed":"
","added":"khuey@kylehuey.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/khuey@kylehuey.com","name":"khuey@kylehuey.com"},"change_time":"2011-07-18T20:35:37Z"}}]},{"bug":{"history":[{"changes":[{"removed":"","added":"bmo@edmorley.co.uk","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/bmo@edmorley.co.uk","name":"bmo@edmorley.co.uk"},"change_time":"2011-07-10T14:30:39Z"},{"changes":[{"removed":"","added":"bear@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/bear@mozilla.com","name":"bear@mozilla.com"},"change_time":"2011-07-07T21:21:56Z"},{"changes":[{"removed":"","added":"ctalbert@mozilla.com, fayearthur+bugs@gmail.com, sliu@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-07-07T21:19:46Z"},{"changes":[{"removed":"","added":"armenzg@mozilla
.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/armenzg@mozilla.com","name":"armenzg@mozilla.com"},"change_time":"2011-07-07T17:04:41Z"}],"summary":"Publish Build Faster metrics","last_change_time":"2011-07-18T20:25:40Z","comments":[{"is_private":false,"creator":{"real_name":"Chris AtLee [:catlee]","name":"catlee"},"text":"","id":5597430,"creation_time":"2011-07-18T20:25:40Z"},{"is_private":false,"creator":{"real_name":"Sam Liu","name":"sliu"},"text":"","id":5597428,"creation_time":"2011-07-18T20:24:35Z"},{"is_private":false,"creator":{"real_name":"Chris AtLee [:catlee]","name":"catlee"},"text":"","id":5597393,"creation_time":"2011-07-18T20:10:45Z"},{"is_private":false,"creator":{"real_name":"Sam Liu","name":"sliu"},"text":"","id":5589839,"creation_time":"2011-07-13T20:20:49Z"},{"is_private":false,"creator":{"real_name":"Chris AtLee [:catlee]","name":"catlee"},"text":"","id":5582189,"creation_time":"2011-07-09T01:25:21Z"},{"is_private":false
,"creator":{"real_name":"Sam Liu","name":"sliu"},"text":"","id":5581446,"creation_time":"2011-07-08T18:25:33Z"},{"is_private":false,"creator":{"real_name":"Armen Zambrano G. [:armenzg] - Release Engineer","name":"armenzg"},"text":"","id":5580728,"creation_time":"2011-07-08T12:36:01Z"},{"is_private":false,"creator":{"real_name":"Chris AtLee [:catlee]","name":"catlee"},"text":"","id":5580206,"creation_time":"2011-07-08T03:21:41Z"},{"is_private":false,"creator":{"real_name":"Sam Liu","name":"sliu"},"text":"","id":5579985,"creation_time":"2011-07-08T00:01:37Z"},{"is_private":false,"creator":{"real_name":"Chris AtLee [:catlee]","name":"catlee"},"text":"","id":5579980,"creation_time":"2011-07-07T23:57:48Z"},{"is_private":false,"creator":{"real_name":"Sam Liu","name":"sliu"},"text":"","id":5579965,"creation_time":"2011-07-07T23:51:02Z"},{"is_private":false,"creator":{"real_name":"Chris AtLee [:catlee]","name":"catlee"},"text":"","id":5579631,"creation_time":"2011-07-07T21:32:17Z"},{"is_pri
vate":false,"creator":{"real_name":"Mike Taylor [:bear]","name":"bear"},"text":"","id":5579612,"creation_time":"2011-07-07T21:21:56Z"},{"is_private":false,"creator":{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":5579605,"creation_time":"2011-07-07T21:19:46Z"},{"is_private":false,"creator":{"real_name":"Chris AtLee [:catlee]","name":"catlee"},"text":"","id":5578932,"creation_time":"2011-07-07T17:02:45Z"}],"id":669930},"events":[{"time":"2011-07-18T20:25:40Z","comment":{"is_private":false,"creator":{"real_name":"Chris AtLee [:catlee]","name":"catlee"},"text":"","id":5597430,"creation_time":"2011-07-18T20:25:40Z"}},{"time":"2011-07-18T20:24:35Z","comment":{"is_private":false,"creator":{"real_name":"Sam Liu","name":"sliu"},"text":"","id":5597428,"creation_time":"2011-07-18T20:24:35Z"}},{"time":"2011-07-18T20:10:45Z","comment":{"is_private":false,"creator":{"real_name":"Chris AtLee [:catlee]","name":"catlee"},"text":"","id":5597393,"creation_time":"2011-07-1
8T20:10:45Z"}}]},{"bug":{"history":[{"changes":[{"removed":"","added":"jwatt@jwatt.org","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jwatt@jwatt.org","name":"jwatt@jwatt.org"},"change_time":"2011-07-18T12:06:33Z"},{"changes":[{"removed":"","added":"taku.eof@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/taku.eof@gmail.com","name":"taku.eof@gmail.com"},"change_time":"2011-06-27T04:50:23Z"},{"changes":[{"removed":"","added":"jeff@stikman.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jeff@stikman.com","name":"jeff@stikman.com"},"change_time":"2011-05-30T15:15:06Z"},{"changes":[{"removed":"","added":"spencerselander@yahoo.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/spencerselander@yahoo.com","name":"spencerselander@yahoo.com"},"change_time":"2011-05-18T07:58:37Z"},{"changes":[{"removed":"VanillaMozilla@hotmail.com"
,"added":"","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/VanillaMozilla@hotmail.com","name":"VanillaMozilla@hotmail.com"},"change_time":"2011-05-17T02:57:17Z"},{"changes":[{"removed":"","added":"mcdavis941.bugs@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mcdavis941.bugs@gmail.com","name":"mcdavis941.bugs@gmail.com"},"change_time":"2011-05-16T21:08:18Z"},{"changes":[{"removed":"beltzner@mozilla.com","added":"","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mbeltzner@gmail.com","name":"mbeltzner@gmail.com"},"change_time":"2011-04-02T00:17:26Z"},{"changes":[{"removed":"","added":"cbaker@customsoftwareconsult.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/cbaker@customsoftwareconsult.com","name":"cbaker@customsoftwareconsult.com"},"change_time":"2011-03-28T14:08:35Z"},{"changes":[{"removed":"","added":"SGrage@gmx.net","f
ield_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/SGrage@gmx.net","name":"SGrage@gmx.net"},"change_time":"2011-03-28T10:13:51Z"},{"changes":[{"removed":"","added":"dewmigg@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/dewmigg@gmail.com","name":"dewmigg@gmail.com"},"change_time":"2011-03-13T21:34:21Z"},{"changes":[{"removed":"","added":"ulysse@email.it","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/euryalus.0@gmail.com","name":"euryalus.0@gmail.com"},"change_time":"2011-03-13T12:14:04Z"},{"changes":[{"removed":"","added":"heraldo99@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/heraldo99@gmail.com","name":"heraldo99@gmail.com"},"change_time":"2011-03-13T11:36:08Z"},{"changes":[{"removed":"","added":"pardal@gmx.de","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/pardal@gmx.de","name":"
pardal@gmx.de"},"change_time":"2011-03-13T02:48:03Z"},{"changes":[{"removed":"","added":"terrell.kelley@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/terrell.kelley@gmail.com","name":"terrell.kelley@gmail.com"},"change_time":"2011-01-31T11:46:28Z"},{"changes":[{"removed":"","added":"kiuzeppe@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/kiuzeppe@gmail.com","name":"kiuzeppe@gmail.com"},"change_time":"2011-01-20T22:13:01Z"},{"changes":[{"removed":"","added":"saneyuki.snyk@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/saneyuki.s.snyk@gmail.com","name":"saneyuki.s.snyk@gmail.com"},"change_time":"2011-01-11T09:25:01Z"},{"changes":[{"removed":"","added":"stephen.donner@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/stephen.donner@gmail.com","name":"stephen.donner@gmail.com"},"change_time":"2011-01
-04T21:07:17Z"},{"changes":[{"removed":"","added":"prog_when_resolved_notification@bluebottle.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/prog_when_resolved_notification@bluebottle.com","name":"prog_when_resolved_notification@bluebottle.com"},"change_time":"2011-01-02T18:11:00Z"},{"changes":[{"removed":"jmjeffery@embarqmail.com","added":"","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jmjeffery@embarqmail.com","name":"jmjeffery@embarqmail.com"},"change_time":"2010-12-14T18:17:14Z"},{"changes":[{"removed":"","added":"colmeiro@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/colmeiro@gmail.com","name":"colmeiro@gmail.com"},"change_time":"2010-12-10T23:46:15Z"},{"changes":[{"removed":"","added":"willyaranda@mozilla-hispano.org","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/willyaranda@mozilla-hispano.org","name":"willyara
nda@mozilla-hispano.org"},"change_time":"2010-12-10T22:34:30Z"},{"changes":[{"removed":"","added":"dale.bugzilla@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/dale.bugzilla@gmail.com","name":"dale.bugzilla@gmail.com"},"change_time":"2010-12-10T00:50:10Z"},{"changes":[{"removed":"","added":"sabret00the@yahoo.co.uk","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/sabret00the@yahoo.co.uk","name":"sabret00the@yahoo.co.uk"},"change_time":"2010-12-09T17:01:15Z"},{"changes":[{"removed":"","added":"daveryeo@telus.net","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/daveryeo@telus.net","name":"daveryeo@telus.net"},"change_time":"2010-12-09T04:46:59Z"},{"changes":[{"removed":"","added":"bugspam.Callek@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/bugspam.Callek@gmail.com","name":"bugspam.Callek@gmail.com"},"change_time":"2010
-12-09T01:05:37Z"},{"changes":[{"removed":"","added":"mcepl@redhat.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mcepl@redhat.com","name":"mcepl@redhat.com"},"change_time":"2010-12-08T23:55:49Z"},{"changes":[{"removed":"","added":"tymerkaev@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/tymerkaev@gmail.com","name":"tymerkaev@gmail.com"},"change_time":"2010-11-29T10:19:49Z"},{"changes":[{"removed":"","added":"kwierso@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/kwierso@gmail.com","name":"kwierso@gmail.com"},"change_time":"2010-11-29T05:42:05Z"},{"changes":[{"removed":"","added":"mtanalin@yandex.ru","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mtanalin@yandex.ru","name":"mtanalin@yandex.ru"},"change_time":"2010-11-15T22:33:18Z"},{"changes":[{"removed":"","added":"briks.si@gmail.com","field_name":"cc"}],"chan
ger":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/briks.si@gmail.com","name":"briks.si@gmail.com"},"change_time":"2010-11-15T20:45:37Z"},{"changes":[{"removed":"","added":"mozdiav@aeons.lv","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mozdiav@aeons.lv","name":"mozdiav@aeons.lv"},"change_time":"2010-11-12T20:25:54Z"},{"changes":[{"removed":"","added":"soufian.j@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/soufian.j@gmail.com","name":"soufian.j@gmail.com"},"change_time":"2010-11-12T16:43:16Z"},{"changes":[{"removed":"","added":"jmjeffery@embarqmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jmjeffery@embarqmail.com","name":"jmjeffery@embarqmail.com"},"change_time":"2010-11-12T12:59:58Z"},{"changes":[{"removed":"","added":"markc@qsiuk.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/markc@qsiuk.com","name
":"markc@qsiuk.com"},"change_time":"2010-11-12T12:14:42Z"},{"changes":[{"removed":"","added":"thibaut.bethune@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/thibaut.bethune@gmail.com","name":"thibaut.bethune@gmail.com"},"change_time":"2010-11-11T22:54:55Z"},{"changes":[{"removed":"","added":"gmontagu@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/gmontagu@gmail.com","name":"gmontagu@gmail.com"},"change_time":"2010-11-11T22:45:52Z"},{"changes":[{"removed":"","added":"KenSaunders@AccessFirefox.org","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/KenSaunders@AccessFirefox.org","name":"KenSaunders@AccessFirefox.org"},"change_time":"2010-11-11T19:26:57Z"},{"changes":[{"removed":"","added":"lists@eitanadler.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/lists@eitanadler.com","name":"lists@eitanadler.com"},"change_time
":"2010-11-11T18:07:05Z"},{"changes":[{"removed":"","added":"geekshadow@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/geekshadow@gmail.com","name":"geekshadow@gmail.com"},"change_time":"2010-10-20T09:22:55Z"},{"changes":[{"removed":"","added":"webmaster@keryx.se","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/webmaster@keryx.se","name":"webmaster@keryx.se"},"change_time":"2010-10-20T09:06:57Z"},{"changes":[{"removed":"","added":"bugzilla@zirro.se","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/bugzilla@zirro.se","name":"bugzilla@zirro.se"},"change_time":"2010-10-20T09:03:47Z"},{"changes":[{"removed":"","added":"supernova00@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/supernova00@gmail.com","name":"supernova00@gmail.com"},"change_time":"2010-10-19T21:35:02Z"},{"changes":[{"removed":"","added":"beltzner@mozilla.com
, dtownsend@mozilla.com, jgriffin@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jgriffin@mozilla.com","name":"jgriffin@mozilla.com"},"change_time":"2010-10-08T22:07:52Z"},{"changes":[{"removed":"","added":"gavin.sharp@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/gavin.sharp@gmail.com","name":"gavin.sharp@gmail.com"},"change_time":"2010-09-24T18:44:50Z"},{"changes":[{"removed":"","added":"omarb.public@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/omarb.public@gmail.com","name":"omarb.public@gmail.com"},"change_time":"2010-09-06T18:12:39Z"},{"changes":[{"removed":"","added":"David.Vo2+bmo@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/auscompgeek@sumovolunteers.org","name":"auscompgeek@sumovolunteers.org"},"change_time":"2010-09-03T02:57:43Z"},{"changes":[{"removed":"","added":"mcs@pearlcre
scent.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mcs@pearlcrescent.com","name":"mcs@pearlcrescent.com"},"change_time":"2010-09-02T02:33:22Z"},{"changes":[{"removed":"","added":"archaeopteryx@coole-files.de","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/archaeopteryx@coole-files.de","name":"archaeopteryx@coole-files.de"},"change_time":"2010-09-01T09:17:01Z"},{"changes":[{"removed":"","added":"antoine.mechelynck@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/antoine.mechelynck@gmail.com","name":"antoine.mechelynck@gmail.com"},"change_time":"2010-09-01T03:05:29Z"},{"changes":[{"removed":"","added":"m-wada@japan.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/m-wada@japan.com","name":"m-wada@japan.com"},"change_time":"2010-08-31T09:53:39Z"},{"changes":[{"removed":"","added":"bugzilla@standard8.plus.com, ludovic@mozil
lamessaging.com, vseerror@lehigh.edu","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ludovic@mozilla.com","name":"ludovic@mozilla.com"},"change_time":"2010-08-31T06:10:50Z"},{"changes":[{"removed":"","added":"grenavitar@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/grenavitar@gmail.com","name":"grenavitar@gmail.com"},"change_time":"2010-08-31T03:59:31Z"},{"changes":[{"removed":"","added":"jorge@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jorge@mozilla.com","name":"jorge@mozilla.com"},"change_time":"2010-08-30T18:18:56Z"},{"changes":[{"removed":"","added":"ehsan@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ehsan@mozilla.com","name":"ehsan@mozilla.com"},"change_time":"2010-08-30T18:09:28Z"},{"changes":[{"removed":"","added":"tyler.downer@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api
-dev.bugzilla.mozilla.org/0.9/user/tyler.downer@gmail.com","name":"tyler.downer@gmail.com"},"change_time":"2010-08-30T17:40:02Z"},{"changes":[{"removed":"","added":"asqueella@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/asqueella@gmail.com","name":"asqueella@gmail.com"},"change_time":"2010-08-26T20:47:46Z"},{"changes":[{"removed":"","added":"590788","field_name":"depends_on"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2010-08-26T15:49:52Z"},{"changes":[{"removed":"","added":"benjamin@smedbergs.us","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2010-08-26T08:24:38Z"},{"changes":[{"removed":"","added":"bugs-bmo@unknownbrackets.org","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/bugs-bmo@unknownbrackets.org","name":"
bugs-bmo@unknownbrackets.org"},"change_time":"2010-08-26T07:24:55Z"},{"changes":[{"removed":"","added":"highmind63@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/highmind63@gmail.com","name":"highmind63@gmail.com"},"change_time":"2010-08-26T03:45:34Z"},{"changes":[{"removed":"stream@abv.bg","added":"","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/stream@abv.bg","name":"stream@abv.bg"},"change_time":"2010-08-24T16:50:19Z"},{"changes":[{"removed":"Infrastructure","added":"ProfileManager","field_name":"component"},{"removed":"jhammel@mozilla.com","added":"nobody@mozilla.org","field_name":"assigned_to"},{"removed":"infra@testing.bugs","added":"profilemanager@testing.bugs","field_name":"qa_contact"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2010-08-24T15:27:00Z"},{"changes":[{"removed":"","added":"justin.lebar+bug@g
mail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/justin.lebar+bug@gmail.com","name":"justin.lebar+bug@gmail.com"},"change_time":"2010-07-28T21:26:38Z"},{"changes":[{"removed":"mozilla.bugs@alyoung.com","added":"","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mozilla.bugs@alyoung.com","name":"mozilla.bugs@alyoung.com"},"change_time":"2010-07-22T23:59:31Z"},{"changes":[{"removed":"","added":"deletesoftware@yandex.ru","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/deletesoftware@yandex.ru","name":"deletesoftware@yandex.ru"},"change_time":"2010-06-19T14:19:55Z"},{"changes":[{"removed":"NEW","added":"ASSIGNED","field_name":"status"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2010-06-14T17:26:17Z"},{"changes":[{"removed":"nobody@mozilla.org","added":"jhammel@mozilla.com","field_name":
"assigned_to"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2010-05-27T15:42:33Z"},{"changes":[{"removed":"","added":"harthur@cmu.edu","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2010-03-18T20:49:42Z"},{"changes":[{"removed":"","added":"k0scist@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2010-03-09T17:10:48Z"},{"changes":[{"removed":"","added":"stream@abv.bg","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/stream@abv.bg","name":"stream@abv.bg"},"change_time":"2010-02-07T01:32:42Z"},{"changes":[{"removed":"","added":"VanillaMozilla@hotmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/VanillaMozilla@h
otmail.com","name":"VanillaMozilla@hotmail.com"},"change_time":"2010-01-22T17:28:59Z"},{"changes":[{"removed":"","added":"reed@reedloden.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/reed@reedloden.com","name":"reed@reedloden.com"},"change_time":"2010-01-17T19:22:31Z"},{"changes":[{"removed":"","added":"blizzard@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/blizzard@mozilla.com","name":"blizzard@mozilla.com"},"change_time":"2010-01-17T01:12:28Z"},{"changes":[{"removed":"","added":"540194","field_name":"blocks"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/david@rossde.com","name":"david@rossde.com"},"change_time":"2010-01-16T19:18:12Z"},{"changes":[{"removed":"","added":"fullmetaljacket.xp+bugmail@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/fullmetaljacket.xp+bugmail@gmail.com","name":"fullmetaljacket.xp+bugmail@gmail.co
m"},"change_time":"2010-01-15T09:22:52Z"},{"changes":[{"removed":"","added":"wladow@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/wladow@gmail.com","name":"wladow@gmail.com"},"change_time":"2010-01-14T22:31:39Z"},{"changes":[{"removed":"278860","added":"","field_name":"depends_on"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2010-01-14T17:46:11Z"},{"changes":[{"removed":"","added":"chado_moz@yahoo.co.jp","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/chado_moz@yahoo.co.jp","name":"chado_moz@yahoo.co.jp"},"change_time":"2010-01-14T15:30:57Z"},{"changes":[{"removed":"","added":"mnyromyr@tprac.de","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mnyromyr@tprac.de","name":"mnyromyr@tprac.de"},"change_time":"2010-01-14T10:56:22Z"},{"changes":[{"removed":"","added":"spitfire.kuden@g
mail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/spitfire.kuden@gmail.com","name":"spitfire.kuden@gmail.com"},"change_time":"2010-01-14T10:15:48Z"},{"changes":[{"removed":"","added":"mozilla.bugs@alyoung.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/mozilla.bugs@alyoung.com","name":"mozilla.bugs@alyoung.com"},"change_time":"2010-01-14T05:57:27Z"},{"changes":[{"removed":"","added":"nori@noasobi.net","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/nori@noasobi.net","name":"nori@noasobi.net"},"change_time":"2010-01-14T05:41:47Z"},{"changes":[{"removed":"","added":"michaelkohler@live.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/michaelkohler@linux.com","name":"michaelkohler@linux.com"},"change_time":"2010-01-14T01:39:36Z"},{"changes":[{"removed":"","added":"kairo@kairo.at","field_name":"cc"}],"changer":{"ref":"https://api
-dev.bugzilla.mozilla.org/0.9/user/kairo@kairo.at","name":"kairo@kairo.at"},"change_time":"2010-01-14T00:16:58Z"},{"changes":[{"removed":"normal","added":"enhancement","field_name":"severity"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/david@rossde.com","name":"david@rossde.com"},"change_time":"2010-01-14T00:08:41Z"},{"changes":[{"removed":"","added":"ryanvm@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ryanvm@gmail.com","name":"ryanvm@gmail.com"},"change_time":"2010-01-14T00:02:33Z"},{"changes":[{"removed":"","added":"phiw@l-c-n.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/phiw@l-c-n.com","name":"phiw@l-c-n.com"},"change_time":"2010-01-13T23:56:59Z"},{"changes":[{"removed":"","added":"pcvrcek@mozilla.cz","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/pcvrcek@mozilla.cz","name":"pcvrcek@mozilla.cz"},"change_time":"2010-01-13T23:45:00
Z"},{"changes":[{"removed":"","added":"axel@pike.org","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/l10n@mozilla.com","name":"l10n@mozilla.com"},"change_time":"2010-01-13T23:17:08Z"},{"changes":[{"removed":"","added":"stefanh@inbox.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/stefanh@inbox.com","name":"stefanh@inbox.com"},"change_time":"2010-01-13T23:12:13Z"},{"changes":[{"removed":"x86","added":"All","field_name":"platform"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2010-01-13T23:06:25Z"},{"changes":[{"removed":"","added":"johnath@mozilla.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/johnath@mozilla.com","name":"johnath@mozilla.com"},"change_time":"2010-01-13T23:04:10Z"},{"changes":[{"removed":"","added":"mrmazda@earthlink.net","field_name":"cc"}],"changer":{"ref":"https://ap
i-dev.bugzilla.mozilla.org/0.9/user/mrmazda@earthlink.net","name":"mrmazda@earthlink.net"},"change_time":"2010-01-13T22:46:40Z"},{"changes":[{"removed":"","added":"iann_bugzilla@blueyonder.co.uk","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/iann_bugzilla@blueyonder.co.uk","name":"iann_bugzilla@blueyonder.co.uk"},"change_time":"2010-01-13T21:41:32Z"},{"changes":[{"removed":"","added":"xtc4uall@gmail.com","field_name":"cc"},{"removed":"","added":"214675","field_name":"blocks"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/xtc4uall@gmail.com","name":"xtc4uall@gmail.com"},"change_time":"2010-01-13T21:34:20Z"},{"changes":[{"removed":"","added":"hskupin@gmail.com","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2010-01-13T21:31:14Z"},{"changes":[{"removed":"","added":"hickendorffbas@gmail.com","field_name":"cc"}],"changer":{"ref":"http
s://api-dev.bugzilla.mozilla.org/0.9/user/hickendorffbas@gmail.com","name":"hickendorffbas@gmail.com"},"change_time":"2010-01-13T20:58:31Z"}],"summary":"New Test/Triage Profile Manager Application","last_change_time":"2011-07-18T12:06:33Z","comments":[{"is_private":false,"creator":{"real_name":"Jonathan Griffin (:jgriffin)","name":"jgriffin"},"text":"","id":5480531,"creation_time":"2011-05-19T17:30:57Z"},{"is_private":false,"creator":{"real_name":"Spencer Selander [greenknight]","name":"spencerselander"},"text":"","id":5476603,"creation_time":"2011-05-18T07:58:37Z"},{"is_private":false,"creator":{"real_name":"Paul [sabret00the]","name":"sabret00the"},"text":"","id":5373656,"creation_time":"2011-03-28T06:59:22Z"},{"is_private":false,"creator":{"real_name":"Jonathan Griffin (:jgriffin)","name":"jgriffin"},"text":"","id":5240204,"creation_time":"2011-01-31T17:58:24Z"},{"is_private":false,"creator":{"real_name":"Terrell Kelley","name":"terrell.kelley"},"text":"","id":5239501,"creation_t
ime":"2011-01-31T11:46:28Z"},{"is_private":false,"creator":{"real_name":"Benjamin Smedberg [:bsmedberg]","name":"benjamin"},"text":"","id":5002085,"creation_time":"2010-10-11T18:04:48Z"},{"is_private":false,"creator":{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":5002054,"creation_time":"2010-10-11T17:52:13Z"},{"is_private":false,"creator":{"real_name":"Dave Townsend (:Mossop)","name":"dtownsend"},"text":"","id":4999117,"creation_time":"2010-10-08T22:12:23Z"},{"is_private":false,"creator":{"real_name":"Jonathan Griffin (:jgriffin)","name":"jgriffin"},"text":"","id":4999107,"creation_time":"2010-10-08T22:07:52Z"},{"is_private":false,"creator":{"real_name":"Benjamin Smedberg [:bsmedberg]","name":"benjamin"},"text":"","id":4991281,"creation_time":"2010-10-06T18:42:20Z"},{"is_private":false,"creator":{"real_name":"David E. Ross","name":"david"},"text":"","id":4990011,"creation_time":"2010-10-06T17:50:51Z"},{"is_private":false,"creator":{"real_name":"Benjami
n Smedberg [:bsmedberg]","name":"benjamin"},"text":"","id":4986111,"creation_time":"2010-10-05T02:54:24Z"},{"is_private":false,"creator":{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":4985884,"creation_time":"2010-10-05T00:30:08Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":4921920,"creation_time":"2010-09-08T15:20:06Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":4892626,"creation_time":"2010-08-26T16:05:50Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":4891863,"creation_time":"2010-08-26T08:24:38Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":4886114,"creation_time":"2010-08-24T15:31:05Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":4743315,"creation_time":"2010-06-14T
17:26:17Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":4716160,"creation_time":"2010-05-27T16:53:53Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":4716148,"creation_time":"2010-05-27T16:44:32Z"},{"is_private":false,"creator":{"real_name":"David E. Ross","name":"david"},"text":"","id":4492322,"creation_time":"2010-01-18T15:12:52Z"},{"is_private":false,"creator":{"real_name":"Christopher Blizzard (:blizzard)","name":"blizzard"},"text":"","id":4490922,"creation_time":"2010-01-17T01:13:33Z"},{"is_private":false,"creator":{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":4487552,"creation_time":"2010-01-14T17:46:11Z"},{"is_private":false,"creator":{"real_name":"David E. Ross","name":"david"},"text":"","id":4486520,"creation_time":"2010-01-14T00:08:41Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"
","id":4486434,"creation_time":"2010-01-13T23:06:25Z"},{"is_private":false,"creator":{"real_name":"XtC4UaLL [:xtc4uall]","name":"xtc4uall"},"text":"","id":4486282,"creation_time":"2010-01-13T21:34:20Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":4486275,"creation_time":"2010-01-13T21:31:14Z"},{"is_private":false,"creator":{"real_name":"Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":4486171,"creation_time":"2010-01-13T20:37:30Z"}],"id":539524},"events":[{"time":"2011-07-18T12:06:33Z","changeset":{"changes":[{"removed":"","added":"jwatt@jwatt.org","field_name":"cc"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jwatt@jwatt.org","name":"jwatt@jwatt.org"},"change_time":"2011-07-18T12:06:33Z"}}]},{"bug":{"history":[{"changes":[{"removed":"","added":"568943","field_name":"blocks"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"cha
nge_time":"2011-07-18T09:21:42Z"},{"changes":[{"removed":"[mozmill-next?]","added":"[mozmill-2.0-][mozmill-next?]","field_name":"whiteboard"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-05-25T12:01:37Z"},{"changes":[{"removed":"[mozmill-2.0+]","added":"[mozmill-next?]","field_name":"whiteboard"},{"removed":"critical","added":"normal","field_name":"severity"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-05-24T22:41:14Z"},{"changes":[{"removed":"[mozmill-2.0?]","added":"[mozmill-2.0+]","field_name":"whiteboard"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/ctalbert@mozilla.com","name":"ctalbert@mozilla.com"},"change_time":"2011-03-29T21:43:13Z"},{"changes":[{"removed":"","added":"dataloss","field_name":"keywords"},{"removed":"enhancement","added":"critical","field_name":"severity"}],"cha
nger":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-03-21T00:24:58Z"},{"changes":[{"removed":"nobody@mozilla.org","added":"jhammel@mozilla.com","field_name":"assigned_to"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-03-18T21:05:30Z"},{"changes":[{"removed":"","added":"ahalberstadt@mozilla.com, ctalbert@mozilla.com, fayearthur+bugs@gmail.com, hskupin@gmail.com","field_name":"cc"},{"removed":"","added":"[mozmill-2.0?]","field_name":"whiteboard"},{"removed":"normal","added":"enhancement","field_name":"severity"}],"changer":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/jhammel@mozilla.com","name":"jhammel@mozilla.com"},"change_time":"2011-03-18T16:29:22Z"}],"summary":"should be able to clone from a profile as a basis","last_change_time":"2011-07-18T09:21:42Z","comments":[{"is_private":false,"creator":{"real_name":"
Clint Talbert ( :ctalbert )","name":"ctalbert"},"text":"","id":5490872,"creation_time":"2011-05-24T22:41:14Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5357384,"creation_time":"2011-03-21T16:41:15Z"},{"is_private":false,"creator":{"real_name":"Henrik Skupin (:whimboo)","name":"hskupin"},"text":"","id":5356453,"creation_time":"2011-03-21T00:24:58Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5353489,"creation_time":"2011-03-18T16:32:57Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5353480,"creation_time":"2011-03-18T16:29:22Z"},{"is_private":false,"creator":{"real_name":"Jeff Hammel [:jhammel]","name":"jhammel"},"text":"","id":5353472,"creation_time":"2011-03-18T16:27:14Z"}],"id":642843},"events":[{"time":"2011-07-18T09:21:42Z","changeset":{"changes":[{"removed":"","added":"568943","field_name":"blocks"}],"chan
ger":{"ref":"https://api-dev.bugzilla.mozilla.org/0.9/user/hskupin@gmail.com","name":"hskupin@gmail.com"},"change_time":"2011-07-18T09:21:42Z"}}]}]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/package.json b/node_modules/node-firefox-connect/node_modules/firefox-client/package.json
new file mode 100644
index 0000000..8985573
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/package.json
@@ -0,0 +1,52 @@
+{
+ "name": "firefox-client",
+ "description": "Firefox remote debugging client",
+ "version": "0.3.0",
+ "author": {
+ "name": "Heather Arthur",
+ "email": "fayearthur@gmail.com"
+ },
+ "main": "index.js",
+ "repository": {
+ "type": "git",
+ "url": "http://github.com/harthur/firefox-client.git"
+ },
+ "dependencies": {
+ "colors": "0.5.x",
+ "js-select": "~0.6.0"
+ },
+ "devDependencies": {
+ "connect": "~2.8.2",
+ "mocha": "~1.12.0"
+ },
+ "keywords": [
+ "firefox",
+ "debugger",
+ "remote debugging"
+ ],
+ "bugs": {
+ "url": "https://github.com/harthur/firefox-client/issues"
+ },
+ "homepage": "https://github.com/harthur/firefox-client",
+ "_id": "firefox-client@0.3.0",
+ "dist": {
+ "shasum": "3794460f6eb6afcf41376addcbc7462e24a4cd8b",
+ "tarball": "http://registry.npmjs.org/firefox-client/-/firefox-client-0.3.0.tgz"
+ },
+ "_from": "firefox-client@^0.3.0",
+ "_npmVersion": "1.4.3",
+ "_npmUser": {
+ "name": "harth",
+ "email": "fayearthur@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "harth",
+ "email": "fayearthur@gmail.com"
+ }
+ ],
+ "directories": {},
+ "_shasum": "3794460f6eb6afcf41376addcbc7462e24a4cd8b",
+ "_resolved": "https://registry.npmjs.org/firefox-client/-/firefox-client-0.3.0.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test.js
new file mode 100644
index 0000000..1f2d334
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test.js
@@ -0,0 +1,54 @@
+var assert = require('assert'),
+ FirefoxClient = require("./index");
+
+
+var url = "file:///Users/harth/repos/sass-wwcode/index.html";
+
+loadUrl(url, function(tab) {
+ tab.StyleSheets.getStyleSheets(function(err, sheets) {
+ var sheet = sheets[1];
+ sheet.getOriginalSources(function(err, sources) {
+ console.log(err);
+ console.log(sources[0].url);
+ sources[0].getText(function(err, resp) {
+ console.log(err);
+ console.log(resp);
+ })
+ });
+ console.log(sheet.href);
+ });
+})
+
+
+/**
+ * Helper functions
+ */
+function loadUrl(url, callback) {
+ getFirstTab(function(tab) {
+ console.log("GOT TAB");
+ tab.navigateTo(url);
+
+ tab.once("navigate", function() {
+ console.log("NAVIGATED");
+ callback(tab);
+ });
+ });
+}
+
+function getFirstTab(callback) {
+ var client = new FirefoxClient({log: true});
+
+ client.connect(function() {
+ client.listTabs(function(err, tabs) {
+ if (err) throw err;
+
+ var tab = tabs[0];
+
+ // attach so we can receive load events
+ tab.attach(function(err) {
+ if (err) throw err;
+ callback(tab);
+ })
+ });
+ });
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/README.md b/node_modules/node-firefox-connect/node_modules/firefox-client/test/README.md
new file mode 100644
index 0000000..75bd86f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/README.md
@@ -0,0 +1,29 @@
+# testing
+
+### dependencies
+To run the tests in this directory, first install the dev dependencies with this command from the top-level directory:
+
+```
+npm install --dev
+```
+
+You'll also have to globally install [mocha](http://visionmedia.github.io/mocha). `npm install mocha -g`.
+
+### running
+First open up a [Firefox Nightly build](http://nightly.mozilla.org/) and serve the test files up:
+
+```
+node server.js &
+```
+
+visit the url the server tells you to visit.
+
+Finally, run the tests with:
+
+```
+mocha test-dom.js --timeout 10000
+````
+
+The increased timeout is to give you enough time to manually verify the incoming connection in Firefox.
+
+Right now you have to run each test individually, until Firefox [bug 891003](https://bugzilla.mozilla.org/show_bug.cgi?id=891003) is fixed.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/dom.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/dom.html b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/dom.html
new file mode 100644
index 0000000..c662637
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/dom.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>DOM tests</title>
+ <meta charset="utf-8">
+</head>
+<body>
+ <main>
+ <section id="test-section">
+ <div id="test1" class="item"></div>
+ <div id="test2" class="item">
+ <div id="child1"></div>
+ <div id="child2"></div>
+ </div>
+ <div id="test3" class="item"></div>
+ </section>
+ </main>
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/index.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/index.html b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/index.html
new file mode 100644
index 0000000..4a67c5a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/index.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Firefox remote debugging client tests</title>
+ <meta charset="utf-8">
+ <style>
+ header {
+ font-family: Georgia, sans-serif;
+ font-size: 3em;
+ margin: 3em;
+ color: hsl(30, 90%, 50%);
+ }
+ </style>
+</head>
+<body>
+ <header>
+ Firefox Client Tests
+ </header>
+ <main>
+ </main>
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/logs.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/logs.html b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/logs.html
new file mode 100644
index 0000000..56b7c1d
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/logs.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Logs tests</title>
+ <meta charset="utf-8">
+
+ <script>
+ console.log("hi");
+ console.dir({a: 3});
+ foo;
+ </script>
+</head>
+<body>
+ <main>
+ </main>
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/network.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/network.html b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/network.html
new file mode 100644
index 0000000..922e27c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/network.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Logs tests</title>
+ <meta charset="utf-8">
+
+ <script>
+ function sendRequest() {
+ var req = new XMLHttpRequest();
+
+ req.open("GET", "test-network.json", true);
+ req.responseType = "json";
+ req.setRequestHeader("test-header", "test-value");
+ req.send();
+ }
+ </script>
+</head>
+<body>
+ <main>
+ </main>
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/stylesheet1.css
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/stylesheet1.css b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/stylesheet1.css
new file mode 100644
index 0000000..ff5907f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/stylesheet1.css
@@ -0,0 +1,9 @@
+main {
+ font-family: Georgia, sans-serif;
+ color: black;
+}
+
+* {
+ padding: 0;
+ margin: 0;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/stylesheets.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/stylesheets.html b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/stylesheets.html
new file mode 100644
index 0000000..8cab1e8
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/stylesheets.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Stylesheets tests</title>
+ <meta charset="utf-8">
+ <style>
+ main {
+ margin: 20px;
+ }
+ </style>
+ <link rel="stylesheet" href="stylesheet1.css"/>
+</head>
+<body>
+ <main>
+ <main>
+ <div>Stylesheet Tests</div>
+ </main>
+ </main>
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/test-network.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/test-network.json b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/test-network.json
new file mode 100644
index 0000000..5b89410
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/pages/test-network.json
@@ -0,0 +1,4 @@
+{
+ "a": 2,
+ "b": "hello"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/server.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/server.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test/server.js
new file mode 100644
index 0000000..aca94f7
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/server.js
@@ -0,0 +1,8 @@
+var path = require("path"),
+ connect = require('connect');
+
+var port = 3000;
+
+connect.createServer(connect.static(path.join(__dirname, "pages"))).listen(port);
+
+console.log("visit:\nhttp://127.0.0.1:" + port + "/index.html");
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-console.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-console.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-console.js
new file mode 100644
index 0000000..9198ad0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-console.js
@@ -0,0 +1,64 @@
+var assert = require("assert"),
+ utils = require("./utils");
+
+var Console;
+
+before(function(done) {
+ utils.loadTab('dom.html', function(aTab) {
+ Console = aTab.Console;
+ done();
+ });
+});
+
+// Console - evaluateJS()
+
+describe('evaluateJS()', function() {
+ it('should evaluate expr to number', function(done) {
+ Console.evaluateJS('6 + 7', function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.equal(resp.result, 13);
+ done();
+ })
+ })
+
+ it('should evaluate expr to boolean', function(done) {
+ Console.evaluateJS('!!window', function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(resp.result, true);
+ done();
+ })
+ })
+
+ it('should evaluate expr to string', function(done) {
+ Console.evaluateJS('"hello"', function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.equal(resp.result, "hello");
+ done();
+ })
+ })
+
+ it('should evaluate expr to JSObject', function(done) {
+ Console.evaluateJS('x = {a: 2, b: "hello"}', function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.ok(resp.result.ownPropertyNames, "result has JSObject methods");
+ done();
+ })
+ })
+
+ it('should evaluate to undefined', function(done) {
+ Console.evaluateJS('undefined', function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.ok(resp.result.type, "undefined");
+ done();
+ })
+ })
+
+ it('should have exception in response', function(done) {
+ Console.evaluateJS('blargh', function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.equal(resp.exception.class, "Error"); // TODO: error should be JSObject
+ assert.equal(resp.exceptionMessage, "ReferenceError: blargh is not defined");
+ done();
+ })
+ })
+})
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[37/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/lex_test.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/lex_test.html b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/lex_test.html
new file mode 100644
index 0000000..788bfcd
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/lex_test.html
@@ -0,0 +1,122 @@
+<html>
+ <head>
+ <title>JSONSelect JS lex tests</title>
+ <link rel="stylesheet" type="text/css" href="js/doctest.css" />
+ <script src="js/doctest.js"></script>
+ <script src="../jsonselect.js"></script>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ </head>
+ <body>
+
+<div>
+ <button onclick="doctest()" type="button">run tests</button>
+ <pre id="doctestOutput"></pre>
+</div>
+
+ <h2> Tests of the JSONSelect lexer </h2>
+
+<div class="test">
+Simple tokens
+<pre class="doctest">
+$ JSONSelect._lex(">");
+[1, ">"]
+$ JSONSelect._lex("*");
+[1, "*"]
+$ JSONSelect._lex(",");
+[1, ","]
+$ JSONSelect._lex(".");
+[1, "."]
+</pre>
+</div>
+
+<div class="test">
+Offsets
+<pre class="doctest">
+$ JSONSelect._lex("foobar>",6);
+[7, ">"]
+</pre>
+</div>
+
+<div class="test">
+Types
+<pre class="doctest">
+$ JSONSelect._lex("string");
+[6, 3, "string"]
+$ JSONSelect._lex("boolean");
+[7, 3, "boolean"]
+$ JSONSelect._lex("null");
+[4, 3, "null"]
+$ JSONSelect._lex("array");
+[5, 3, "array"]
+$ JSONSelect._lex("object");
+[6, 3, "object"]
+$ JSONSelect._lex("number");
+[6, 3, "number"]
+</pre>
+</div>
+
+<div class="test">
+Whitespace
+<pre class="doctest">
+$ JSONSelect._lex("\r");
+[1, " "]
+$ JSONSelect._lex("\n");
+[1, " "]
+$ JSONSelect._lex("\t");
+[1, " "]
+$ JSONSelect._lex(" ");
+[1, " "]
+$ JSONSelect._lex(" \t \r\n !");
+[13, " "]
+</pre>
+
+<div class="test">
+pseudo classes
+<pre class="doctest">
+$ JSONSelect._lex(":root");
+[5, 1, ":root"]
+$ JSONSelect._lex(":first-child");
+[12, 1, ":first-child"]
+$ JSONSelect._lex(":last-child");
+[11, 1, ":last-child"]
+$ JSONSelect._lex(":only-child");
+[11, 1, ":only-child"]
+</pre>
+</div>
+
+<div class="test">
+json strings
+<pre class="doctest">
+$ JSONSelect._lex('"foo bar baz"');
+[13, 4, "foo bar baz"]
+$ JSONSelect._lex('"\\u0020"');
+[8, 4, " "]
+$ JSONSelect._lex('\"not terminated');
+Error: unclosed json string
+$ JSONSelect._lex('"invalid escape: \\y"');
+Error: invalid json string
+</pre>
+</div>
+
+<div class="test">
+identifiers (like after '.')
+<pre class="doctest">
+$ JSONSelect._lex("foo");
+[3, 4, "foo"]
+$ JSONSelect._lex("foo\\ bar");
+[8, 4, "foo bar"]
+$ JSONSelect._lex("_aB129bcde-\\:foo\\@$");
+[18, 4, "_aB129bcde-:foo@"]
+</pre>
+</div>
+
+<div class="test">
+non-ascii
+<pre class="doctest">
+$ JSONSelect._lex("обичам\\ те\\!");
+[12, 4, "обичам те!"]
+</pre>
+</div>
+
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/match_test.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/match_test.html b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/match_test.html
new file mode 100644
index 0000000..0fc784f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/match_test.html
@@ -0,0 +1,71 @@
+<html>
+ <head>
+ <title>JSONSelect JS matching tests</title>
+ <link rel="stylesheet" type="text/css" href="js/doctest.css" />
+ <script src="js/doctest.js"></script>
+ <script src="../jsonselect.js"></script>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ </head>
+ <body>
+
+<div>
+ <button onclick="doctest()" type="button">run tests</button>
+ <pre id="doctestOutput"></pre>
+</div>
+
+ <h2> Tests of the JSONSelect matcher </h2>
+
+<div class="test">
+Types
+<pre class="doctest">
+$ JSONSelect.match("null", null);
+[null]
+$ JSONSelect.match("array", { 1: [], 2: [] });
+[[], []]
+$ JSONSelect.match("object", [ {}, {} ]);
+[{}, {}]
+$ JSONSelect.match("string", [ "a", 1, true, null, false, "b", 3.1415, "c" ] );
+["a", "b", "c"]
+$ JSONSelect.match("boolean", [ "a", 1, true, null, false, "b", 3.1415, "c" ] );
+[true, false]
+$ JSONSelect.match("number", [ "a", 1, true, null, false, "b", 3.1415, "c" ] );
+[1, 3.1415]
+</pre>
+</div>
+
+<div class="test">
+IDs
+<pre class="doctest">
+$ JSONSelect.match(".foo", {foo: "aMatch", bar: [ { foo: "anotherMatch" } ] });
+["aMatch", "anotherMatch"]
+</pre>
+</div>
+
+<div class="test">
+Descendants
+<pre class="doctest">
+$ JSONSelect.match(".foo .bar", {foo: { baz: 1, bar: 2 }, bar: 3});
+[2]
+$ JSONSelect.match(".foo > .bar", {foo: { baz: 1, bar: 2 }, bar: 3});
+[2]
+$ JSONSelect.match(".foo > .bar", {foo: { baz: { bar: 4 }, bar: 2 }, bar: 3});
+[2]
+$ JSONSelect.match(".foo .bar", {foo: { baz: { bar: 4 }, bar: 2 }, bar: 3});
+[4, 2]
+</pre>
+</div>
+
+<div class="test">
+Grouping
+<pre class="doctest">
+$ JSONSelect.match("number,boolean", [ "a", 1, true, null, false, "b", 3.1415, "c" ] );
+[1, true, false, 3.1415]
+$ JSONSelect.match("number,boolean,null", [ "a", 1, true, null, false, "b", 3.1415, "c" ] );
+[1, true, null, false, 3.1415]
+</pre>
+</div>
+
+ </body>
+</html>
+
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/parse_test.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/parse_test.html b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/parse_test.html
new file mode 100644
index 0000000..9744457
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/parse_test.html
@@ -0,0 +1,98 @@
+<html>
+ <head>
+ <title>JSONSelect JS parser tests</title>
+ <link rel="stylesheet" type="text/css" href="js/doctest.css" />
+ <script src="js/doctest.js"></script>
+ <script src="../jsonselect.js"></script>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ </head>
+ <body>
+
+<div>
+ <button onclick="doctest()" type="button">run tests</button>
+ <pre id="doctestOutput"></pre>
+</div>
+
+ <h2> Tests of the JSONSelect parser </h2>
+
+<div class="test">
+Selectors
+<pre class="doctest">
+$ JSONSelect._parse(".foo");
+[{id: "foo"}]
+$ JSONSelect._parse('." foo "');
+[{id: " foo "}]
+$ JSONSelect._parse("string.foo:last-child");
+[{a: 0, b: 1, id: "foo", pf: ":nth-last-child", type: "string"}]
+$ JSONSelect._parse("string.foo.bar");
+Error: multiple ids not allowed
+$ JSONSelect._parse("string.foo:first-child.bar");
+Error: multiple ids not allowed
+$ JSONSelect._parse("string:last-child.foo:first-child.bar");
+Error: multiple pseudo classes (:xxx) not allowed
+$ JSONSelect._parse("string.");
+Error: string required after '.'
+$ JSONSelect._parse("string:bogus");
+Error: unrecognized pseudo class
+$ JSONSelect._parse("string.xxx\\@yyy");
+[{id: "xxx@yyy", type: "string"}]
+$ JSONSelect._parse(" ");
+Error: selector expected
+$ JSONSelect._parse("");
+Error: selector expected
+</pre>
+</div>
+
+<div class="test">
+Combinators
+<pre class="doctest">
+$ JSONSelect._parse(".foo .bar");
+[{id: "foo"}, {id: "bar"}]
+$ JSONSelect._parse("string.foo , number.foo");
+[",", [{id: "foo", type: "string"}], [{id: "foo", type: "number"}]]
+$ JSONSelect._parse("string > .foo number.bar");
+[{type: "string"}, ">", {id: "foo"}, {id: "bar", type: "number"}]
+$ JSONSelect._parse("string > .foo number.bar, object");
+[",", [{type: "string"}, ">", {id: "foo"}, {id: "bar", type: "number"}], [{type: "object"}]]
+$ JSONSelect._parse("string > .foo number.bar, object, string, .\"baz bing\", :root");
+[
+ ",",
+ [{type: "string"}, ">", {id: "foo"}, {id: "bar", type: "number"}],
+ [{type: "object"}],
+ [{type: "string"}],
+ [{id: "baz bing"}],
+ [{pc: ":root"}]
+]
+</pre>
+</div>
+
+<div class="test">
+Expressions
+<pre class="doctest">
+$ JSONSelect._parse(":nth-child(1)");
+[{a: 0, b: 1, pf: ":nth-child"}]
+$ JSONSelect._parse(":nth-child(2n+1)");
+[{a: 2, b: 1, pf: ":nth-child"}]
+$ JSONSelect._parse(":nth-child ( 2n + 1 )");
+[{a: 2, b: 1, pf: ":nth-child"}]
+$ JSONSelect._parse(":nth-child(odd)");
+[{a: 2, b: 1, pf: ":nth-child"}]
+$ JSONSelect._parse(":nth-child(even)");
+[{a: 2, b: 0, pf: ":nth-child"}]
+$ JSONSelect._parse(":nth-child(-n+6)");
+[{a: -1, b: 6, pf: ":nth-child"}]
+$ JSONSelect._parse(":nth-child(2n)");
+[{a: 2, b: 0, pf: ":nth-child"}]
+$ JSONSelect._parse(":nth-last-child(-3n - 3)");
+[{a: -3, b: -3, pf: ":nth-last-child"}]
+$ JSONSelect._parse(":first-child");
+[{a: 0, b: 1, pf: ":nth-child"}]
+$ JSONSelect._parse(":last-child");
+[{a: 0, b: 1, pf: ":nth-last-child"}]
+</pre>
+</div>
+
+ </body>
+</html>
+
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/run.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/run.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/run.js
new file mode 100644
index 0000000..c873c3a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/run.js
@@ -0,0 +1,85 @@
+/*
+ * a node.js test runner that executes all conformance
+ * tests and outputs results to console.
+ * Process returns zero on success, non-zero on failure.
+ */
+
+const fs = require('fs'),
+ path = require('path'),
+jsonselect = require('../jsonselect.js'),
+ sys = require('sys');
+
+var pathToTests = path.join(__dirname, "tests");
+
+// a map: document nametest name -> list of se
+var numTests = 0;
+var numPassed = 0;
+var tests = {};
+
+function runOneSync(name, selname, p) {
+ var testDocPath = path.join(p, name + ".json");
+ var selDocPath = path.join(p, name + '_' +
+ selname + ".selector");
+ var outputDocPath = selDocPath.replace(/selector$/, "output");
+
+ // take `obj`, apply `sel, get `got`, is it what we `want`?
+ var obj = JSON.parse(fs.readFileSync(testDocPath));
+ var want = String(fs.readFileSync(outputDocPath)).trim();
+ var got = "";
+ var sel = String(fs.readFileSync(selDocPath)).trim();
+
+ try {
+ jsonselect.forEach(sel, obj, function(m) {
+ got += JSON.stringify(m, undefined, 4) + "\n";
+ });
+ } catch(e) {
+ got = e.toString();
+ if (want.trim() != got.trim()) throw e;
+ }
+ if (want.trim() != got.trim()) throw "mismatch";
+}
+
+
+function runTests() {
+ console.log("Running Tests:");
+ for (var l in tests) {
+ for (var d in tests[l]) {
+ console.log(" level " + l + " tests against \"" + d + ".json\":");
+ for (var i = 0; i < tests[l][d].length; i++) {
+ sys.print(" " + tests[l][d][i][0] + ": ");
+ try {
+ runOneSync(d, tests[l][d][i][0], tests[l][d][i][1]);
+ numPassed++;
+ console.log("pass");
+ } catch (e) {
+ console.log("fail (" + e.toString() + ")");
+ }
+ }
+ }
+ }
+ console.log(numPassed + "/" + numTests + " passed");
+ process.exit(numPassed == numTests ? 0 : 1);
+}
+
+// discover all tests
+var pathToTests = path.join(__dirname, "tests");
+
+fs.readdirSync(pathToTests).forEach(function(subdir) {
+ var p = path.join(pathToTests, subdir);
+ if (!fs.statSync(p).isDirectory()) return;
+ var l = /^level_([\d+])$/.exec(subdir);
+ if (!l) return;
+ l = l[1];
+ var files = fs.readdirSync(p);
+ for (var i = 0; i < files.length; i++) {
+ var f = files[i];
+ var m = /^([A-Za-z]+)_(.+)\.selector$/.exec(f);
+ if (m) {
+ if (!tests.hasOwnProperty(l)) tests[l] = [];
+ if (!tests[l].hasOwnProperty(m[1])) tests[l][m[1]] = [];
+ numTests++;
+ tests[l][m[1]].push([m[2], p]);
+ }
+ }
+});
+runTests();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/.npmignore b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/.npmignore
new file mode 100644
index 0000000..b25c15b
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/.npmignore
@@ -0,0 +1 @@
+*~
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/README.md b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/README.md
new file mode 100644
index 0000000..a9e59ca
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/README.md
@@ -0,0 +1,22 @@
+## JSONSelect Conformance Tests.
+
+This repository contains conformance tests for the
+[JSONSelect](http://jsonselect.org) selector language. The tests
+are divided among subdirectories which correspond to "level" supported
+by a particular implementation. Levels are described more fully in the
+jsonselect [documentation](http://jsonselect.org/#docs).
+
+## Test organization
+
+Test documents have a suffix of `.json`, like `basic.json`.
+
+Selectors to be applied to test documents have the document name,
+followed by an underbar, followed by a description of the test, with
+a `.selector` file name suffix, like `basic_grouping.selector`.
+
+Expected output files have the same name as the `.selector` file,
+but have a `.output` suffix, like `basic_grouping.output`.
+
+Expected output files contain a stream of JSON objects that are what
+is expected to be produced when a given selector is applied to a given
+document.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic.json
new file mode 100644
index 0000000..83c3769
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic.json
@@ -0,0 +1,31 @@
+{
+ "name": {
+ "first": "Lloyd",
+ "last": "Hilaiel"
+ },
+ "favoriteColor": "yellow",
+ "languagesSpoken": [
+ {
+ "language": "Bulgarian",
+ "level": "advanced"
+ },
+ {
+ "language": "English",
+ "level": "native"
+ },
+ {
+ "language": "Spanish",
+ "level": "beginner"
+ }
+ ],
+ "seatingPreference": [
+ "window",
+ "aisle"
+ ],
+ "drinkPreference": [
+ "beer",
+ "whiskey",
+ "wine"
+ ],
+ "weight": 172
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_first-child.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_first-child.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_first-child.output
new file mode 100644
index 0000000..ba6c81a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_first-child.output
@@ -0,0 +1,2 @@
+"window"
+"beer"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_first-child.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_first-child.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_first-child.selector
new file mode 100644
index 0000000..8288dac
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_first-child.selector
@@ -0,0 +1,2 @@
+string:first-child
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_grouping.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_grouping.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_grouping.output
new file mode 100644
index 0000000..ebbc034
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_grouping.output
@@ -0,0 +1,4 @@
+"advanced"
+"native"
+"beginner"
+172
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_grouping.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_grouping.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_grouping.selector
new file mode 100644
index 0000000..b8d0d79
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_grouping.selector
@@ -0,0 +1 @@
+string.level,number
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id.output
new file mode 100644
index 0000000..1511f18
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id.output
@@ -0,0 +1 @@
+"yellow"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id.selector
new file mode 100644
index 0000000..7a3e32b
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id.selector
@@ -0,0 +1 @@
+.favoriteColor
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_multiple.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_multiple.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_multiple.output
new file mode 100644
index 0000000..9021aaa
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_multiple.output
@@ -0,0 +1,3 @@
+"Bulgarian"
+"English"
+"Spanish"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_multiple.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_multiple.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_multiple.selector
new file mode 100644
index 0000000..24170a9
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_multiple.selector
@@ -0,0 +1 @@
+.language
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_quotes.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_quotes.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_quotes.output
new file mode 100644
index 0000000..1912273
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_quotes.output
@@ -0,0 +1,2 @@
+172
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_quotes.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_quotes.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_quotes.selector
new file mode 100644
index 0000000..1adaed0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_quotes.selector
@@ -0,0 +1 @@
+."weight"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_with_type.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_with_type.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_with_type.output
new file mode 100644
index 0000000..1511f18
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_with_type.output
@@ -0,0 +1 @@
+"yellow"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_with_type.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_with_type.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_with_type.selector
new file mode 100644
index 0000000..48c2619
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_id_with_type.selector
@@ -0,0 +1 @@
+string.favoriteColor
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_last-child.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_last-child.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_last-child.output
new file mode 100644
index 0000000..9a334d0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_last-child.output
@@ -0,0 +1,2 @@
+"aisle"
+"wine"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_last-child.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_last-child.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_last-child.selector
new file mode 100644
index 0000000..8591de0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_last-child.selector
@@ -0,0 +1,2 @@
+string:last-child
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child-2.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child-2.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child-2.output
new file mode 100644
index 0000000..b55a882
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child-2.output
@@ -0,0 +1,4 @@
+"window"
+"aisle"
+"beer"
+"whiskey"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child-2.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child-2.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child-2.selector
new file mode 100644
index 0000000..6418a97
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child-2.selector
@@ -0,0 +1 @@
+string:nth-child(-n+2)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child.output
new file mode 100644
index 0000000..196d836
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child.output
@@ -0,0 +1,3 @@
+"window"
+"beer"
+"wine"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child.selector
new file mode 100644
index 0000000..9bd4c5f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-child.selector
@@ -0,0 +1 @@
+string:nth-child(odd)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-last-child.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-last-child.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-last-child.output
new file mode 100644
index 0000000..9a334d0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-last-child.output
@@ -0,0 +1,2 @@
+"aisle"
+"wine"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-last-child.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-last-child.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-last-child.selector
new file mode 100644
index 0000000..bc100d5
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_nth-last-child.selector
@@ -0,0 +1 @@
+string:nth-last-child(1)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_root_pseudo.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_root_pseudo.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_root_pseudo.output
new file mode 100644
index 0000000..83c3769
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_root_pseudo.output
@@ -0,0 +1,31 @@
+{
+ "name": {
+ "first": "Lloyd",
+ "last": "Hilaiel"
+ },
+ "favoriteColor": "yellow",
+ "languagesSpoken": [
+ {
+ "language": "Bulgarian",
+ "level": "advanced"
+ },
+ {
+ "language": "English",
+ "level": "native"
+ },
+ {
+ "language": "Spanish",
+ "level": "beginner"
+ }
+ ],
+ "seatingPreference": [
+ "window",
+ "aisle"
+ ],
+ "drinkPreference": [
+ "beer",
+ "whiskey",
+ "wine"
+ ],
+ "weight": 172
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_root_pseudo.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_root_pseudo.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_root_pseudo.selector
new file mode 100644
index 0000000..4035e80
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_root_pseudo.selector
@@ -0,0 +1 @@
+:root
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type.output
new file mode 100644
index 0000000..332db77
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type.output
@@ -0,0 +1,14 @@
+"Lloyd"
+"Hilaiel"
+"yellow"
+"Bulgarian"
+"advanced"
+"English"
+"native"
+"Spanish"
+"beginner"
+"window"
+"aisle"
+"beer"
+"whiskey"
+"wine"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type.selector
new file mode 100644
index 0000000..ec186f1
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type.selector
@@ -0,0 +1 @@
+string
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type2.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type2.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type2.output
new file mode 100644
index 0000000..730a054
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type2.output
@@ -0,0 +1 @@
+172
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type2.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type2.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type2.selector
new file mode 100644
index 0000000..0dfad6f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type2.selector
@@ -0,0 +1 @@
+number
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type3.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type3.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type3.output
new file mode 100644
index 0000000..8394ec8
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type3.output
@@ -0,0 +1,47 @@
+{
+ "first": "Lloyd",
+ "last": "Hilaiel"
+}
+{
+ "language": "Bulgarian",
+ "level": "advanced"
+}
+{
+ "language": "English",
+ "level": "native"
+}
+{
+ "language": "Spanish",
+ "level": "beginner"
+}
+{
+ "name": {
+ "first": "Lloyd",
+ "last": "Hilaiel"
+ },
+ "favoriteColor": "yellow",
+ "languagesSpoken": [
+ {
+ "language": "Bulgarian",
+ "level": "advanced"
+ },
+ {
+ "language": "English",
+ "level": "native"
+ },
+ {
+ "language": "Spanish",
+ "level": "beginner"
+ }
+ ],
+ "seatingPreference": [
+ "window",
+ "aisle"
+ ],
+ "drinkPreference": [
+ "beer",
+ "whiskey",
+ "wine"
+ ],
+ "weight": 172
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type3.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type3.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type3.selector
new file mode 100644
index 0000000..e2f6b77
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_type3.selector
@@ -0,0 +1 @@
+object
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_universal.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_universal.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_universal.output
new file mode 100644
index 0000000..cfbf20a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_universal.output
@@ -0,0 +1,85 @@
+"Lloyd"
+"Hilaiel"
+{
+ "first": "Lloyd",
+ "last": "Hilaiel"
+}
+"yellow"
+"Bulgarian"
+"advanced"
+{
+ "language": "Bulgarian",
+ "level": "advanced"
+}
+"English"
+"native"
+{
+ "language": "English",
+ "level": "native"
+}
+"Spanish"
+"beginner"
+{
+ "language": "Spanish",
+ "level": "beginner"
+}
+[
+ {
+ "language": "Bulgarian",
+ "level": "advanced"
+ },
+ {
+ "language": "English",
+ "level": "native"
+ },
+ {
+ "language": "Spanish",
+ "level": "beginner"
+ }
+]
+"window"
+"aisle"
+[
+ "window",
+ "aisle"
+]
+"beer"
+"whiskey"
+"wine"
+[
+ "beer",
+ "whiskey",
+ "wine"
+]
+172
+{
+ "name": {
+ "first": "Lloyd",
+ "last": "Hilaiel"
+ },
+ "favoriteColor": "yellow",
+ "languagesSpoken": [
+ {
+ "language": "Bulgarian",
+ "level": "advanced"
+ },
+ {
+ "language": "English",
+ "level": "native"
+ },
+ {
+ "language": "Spanish",
+ "level": "beginner"
+ }
+ ],
+ "seatingPreference": [
+ "window",
+ "aisle"
+ ],
+ "drinkPreference": [
+ "beer",
+ "whiskey",
+ "wine"
+ ],
+ "weight": 172
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_universal.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_universal.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_universal.selector
new file mode 100644
index 0000000..72e8ffc
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/basic_universal.selector
@@ -0,0 +1 @@
+*
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision.json
new file mode 100644
index 0000000..d2bc912
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision.json
@@ -0,0 +1,6 @@
+{
+ "object": {
+ "string": "some string",
+ "stringTwo": "some other string"
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_nested.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_nested.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_nested.output
new file mode 100644
index 0000000..e39067c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_nested.output
@@ -0,0 +1 @@
+"some string"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_nested.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_nested.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_nested.selector
new file mode 100644
index 0000000..5eaa374
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_nested.selector
@@ -0,0 +1 @@
+.object .string
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_quoted-string.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_quoted-string.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_quoted-string.output
new file mode 100644
index 0000000..e39067c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_quoted-string.output
@@ -0,0 +1 @@
+"some string"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_quoted-string.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_quoted-string.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_quoted-string.selector
new file mode 100644
index 0000000..4faa4aa
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_quoted-string.selector
@@ -0,0 +1 @@
+."string"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_string.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_string.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_string.output
new file mode 100644
index 0000000..e39067c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_string.output
@@ -0,0 +1 @@
+"some string"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_string.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_string.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_string.selector
new file mode 100644
index 0000000..8b2be0c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_1/collision_string.selector
@@ -0,0 +1 @@
+.string
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling.json
new file mode 100644
index 0000000..6e5aecb
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling.json
@@ -0,0 +1,18 @@
+{
+ "a": 1,
+ "b": 2,
+ "c": {
+ "a": 3,
+ "b": 4,
+ "c": {
+ "a": 5,
+ "b": 6
+ }
+ },
+ "d": {
+ "a": 7
+ },
+ "e": {
+ "b": 8
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_childof.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_childof.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_childof.output
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_childof.output
@@ -0,0 +1 @@
+2
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_childof.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_childof.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_childof.selector
new file mode 100644
index 0000000..f13fbdd
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_childof.selector
@@ -0,0 +1,2 @@
+:root > .a ~ .b
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_descendantof.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_descendantof.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_descendantof.output
new file mode 100644
index 0000000..e2ba1ef
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_descendantof.output
@@ -0,0 +1,3 @@
+2
+4
+6
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_descendantof.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_descendantof.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_descendantof.selector
new file mode 100644
index 0000000..7c637b9
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_descendantof.selector
@@ -0,0 +1 @@
+:root .a ~ .b
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_unrooted.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_unrooted.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_unrooted.output
new file mode 100644
index 0000000..e2ba1ef
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_unrooted.output
@@ -0,0 +1,3 @@
+2
+4
+6
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_unrooted.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_unrooted.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_unrooted.selector
new file mode 100644
index 0000000..9a4ae06
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_2/sibling_unrooted.selector
@@ -0,0 +1 @@
+.a ~ .b
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic.json
new file mode 100644
index 0000000..83c3769
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic.json
@@ -0,0 +1,31 @@
+{
+ "name": {
+ "first": "Lloyd",
+ "last": "Hilaiel"
+ },
+ "favoriteColor": "yellow",
+ "languagesSpoken": [
+ {
+ "language": "Bulgarian",
+ "level": "advanced"
+ },
+ {
+ "language": "English",
+ "level": "native"
+ },
+ {
+ "language": "Spanish",
+ "level": "beginner"
+ }
+ ],
+ "seatingPreference": [
+ "window",
+ "aisle"
+ ],
+ "drinkPreference": [
+ "beer",
+ "whiskey",
+ "wine"
+ ],
+ "weight": 172
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-multiple.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-multiple.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-multiple.output
new file mode 100644
index 0000000..1cb38cb
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-multiple.output
@@ -0,0 +1,4 @@
+{
+ "first": "Lloyd",
+ "last": "Hilaiel"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-multiple.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-multiple.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-multiple.selector
new file mode 100644
index 0000000..956f1bc
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-multiple.selector
@@ -0,0 +1 @@
+:root > object:has(string.first):has(string.last)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-root-in-expr.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-root-in-expr.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-root-in-expr.output
new file mode 100644
index 0000000..1cb38cb
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-root-in-expr.output
@@ -0,0 +1,4 @@
+{
+ "first": "Lloyd",
+ "last": "Hilaiel"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-root-in-expr.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-root-in-expr.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-root-in-expr.selector
new file mode 100644
index 0000000..329e224
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-root-in-expr.selector
@@ -0,0 +1 @@
+:has(:root > .first)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-first-paren.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-first-paren.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-first-paren.output
new file mode 100644
index 0000000..32f476b
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-first-paren.output
@@ -0,0 +1 @@
+Error: opening paren expected '(' in 'object:has .language)'
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-first-paren.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-first-paren.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-first-paren.selector
new file mode 100644
index 0000000..6165481
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-first-paren.selector
@@ -0,0 +1 @@
+object:has .language)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-paren.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-paren.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-paren.output
new file mode 100644
index 0000000..3baa674
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-paren.output
@@ -0,0 +1 @@
+Error: missing closing paren in 'object:has(.language'
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-paren.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-paren.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-paren.selector
new file mode 100644
index 0000000..8111708
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-sans-paren.selector
@@ -0,0 +1,2 @@
+object:has(.language
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-whitespace.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-whitespace.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-whitespace.output
new file mode 100644
index 0000000..7a87f46
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-whitespace.output
@@ -0,0 +1,12 @@
+{
+ "language": "Bulgarian",
+ "level": "advanced"
+}
+{
+ "language": "English",
+ "level": "native"
+}
+{
+ "language": "Spanish",
+ "level": "beginner"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-whitespace.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-whitespace.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-whitespace.selector
new file mode 100644
index 0000000..69d2801
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-whitespace.selector
@@ -0,0 +1 @@
+.languagesSpoken object:has ( .language )
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-with-comma.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-with-comma.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-with-comma.output
new file mode 100644
index 0000000..2df8708
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-with-comma.output
@@ -0,0 +1,17 @@
+{
+ "first": "Lloyd",
+ "last": "Hilaiel"
+}
+{
+ "language": "Bulgarian",
+ "level": "advanced"
+}
+{
+ "language": "English",
+ "level": "native"
+}
+{
+ "language": "Spanish",
+ "level": "beginner"
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-with-comma.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-with-comma.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-with-comma.selector
new file mode 100644
index 0000000..67e78d3
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has-with-comma.selector
@@ -0,0 +1 @@
+:has(:root > .language, :root > .last)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has.output
new file mode 100644
index 0000000..7a87f46
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has.output
@@ -0,0 +1,12 @@
+{
+ "language": "Bulgarian",
+ "level": "advanced"
+}
+{
+ "language": "English",
+ "level": "native"
+}
+{
+ "language": "Spanish",
+ "level": "beginner"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has.selector
new file mode 100644
index 0000000..aaa0c19
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_has.selector
@@ -0,0 +1 @@
+.languagesSpoken object:has(.language)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_multiple-has-with-strings.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_multiple-has-with-strings.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_multiple-has-with-strings.output
new file mode 100644
index 0000000..1ce5c78
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_multiple-has-with-strings.output
@@ -0,0 +1,5 @@
+{
+ "first": "Lloyd",
+ "last": "Hilaiel"
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_multiple-has-with-strings.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_multiple-has-with-strings.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_multiple-has-with-strings.selector
new file mode 100644
index 0000000..7dd0647
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/basic_multiple-has-with-strings.selector
@@ -0,0 +1 @@
+:has(:val("Lloyd")) object:has(:val("Hilaiel"))
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr.json
new file mode 100644
index 0000000..e1c9de8
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr.json
@@ -0,0 +1,9 @@
+{
+ "int": 42,
+ "float": 3.1415,
+ "string": "foo.exe",
+ "string2": "bar.dmg",
+ "null": null,
+ "true": true,
+ "false": false
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_div.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_div.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_div.output
new file mode 100644
index 0000000..d81cc07
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_div.output
@@ -0,0 +1 @@
+42
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_div.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_div.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_div.selector
new file mode 100644
index 0000000..55a288c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_div.selector
@@ -0,0 +1 @@
+:expr(7 = x / 6)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_ends-with.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_ends-with.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_ends-with.output
new file mode 100644
index 0000000..5517937
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_ends-with.output
@@ -0,0 +1 @@
+"bar.dmg"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_ends-with.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_ends-with.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_ends-with.selector
new file mode 100644
index 0000000..456c961
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_ends-with.selector
@@ -0,0 +1 @@
+:expr(x $= ".dmg")
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_false-eq.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_false-eq.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_false-eq.output
new file mode 100644
index 0000000..a232278
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_false-eq.output
@@ -0,0 +1,3 @@
+false
+
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_false-eq.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_false-eq.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_false-eq.selector
new file mode 100644
index 0000000..b906ff9
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_false-eq.selector
@@ -0,0 +1,4 @@
+:expr(false=x)
+
+
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_greater-than.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_greater-than.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_greater-than.output
new file mode 100644
index 0000000..4f86ad6
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_greater-than.output
@@ -0,0 +1,2 @@
+42
+3.1415
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_greater-than.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_greater-than.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_greater-than.selector
new file mode 100644
index 0000000..878cf08
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_greater-than.selector
@@ -0,0 +1 @@
+:expr(x>3.1)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_less-than.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_less-than.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_less-than.output
new file mode 100644
index 0000000..4f34d97
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_less-than.output
@@ -0,0 +1,2 @@
+3.1415
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_less-than.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_less-than.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_less-than.selector
new file mode 100644
index 0000000..bd4f1bc
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_less-than.selector
@@ -0,0 +1 @@
+:expr(x<4)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mod.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mod.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mod.output
new file mode 100644
index 0000000..d81cc07
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mod.output
@@ -0,0 +1 @@
+42
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mod.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mod.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mod.selector
new file mode 100644
index 0000000..fec575b
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mod.selector
@@ -0,0 +1 @@
+:expr((12 % 10) + 40 = x)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mult.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mult.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mult.output
new file mode 100644
index 0000000..d81cc07
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mult.output
@@ -0,0 +1 @@
+42
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mult.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mult.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mult.selector
new file mode 100644
index 0000000..869c723
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_mult.selector
@@ -0,0 +1 @@
+:expr(7 * 6 = x)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_null-eq.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_null-eq.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_null-eq.output
new file mode 100644
index 0000000..9fba3cf
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_null-eq.output
@@ -0,0 +1,5 @@
+null
+
+
+
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[07/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/tlssocket.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/tlssocket.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/tlssocket.js
new file mode 100644
index 0000000..9a00ea2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/tlssocket.js
@@ -0,0 +1,304 @@
+/**
+ * Socket wrapping functions for TLS.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2009-2012 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+/**
+ * Wraps a forge.net socket with a TLS layer.
+ *
+ * @param options:
+ * sessionId: a session ID to reuse, null for a new connection if no session
+ * cache is provided or it is empty.
+ * caStore: an array of certificates to trust.
+ * sessionCache: a session cache to use.
+ * cipherSuites: an optional array of cipher suites to use, see
+ * tls.CipherSuites.
+ * socket: the socket to wrap.
+ * virtualHost: the virtual server name to use in a TLS SNI extension.
+ * verify: a handler used to custom verify certificates in the chain.
+ * getCertificate: an optional callback used to get a certificate.
+ * getPrivateKey: an optional callback used to get a private key.
+ * getSignature: an optional callback used to get a signature.
+ * deflate: function(inBytes) if provided, will deflate TLS records using
+ * the deflate algorithm if the server supports it.
+ * inflate: function(inBytes) if provided, will inflate TLS records using
+ * the deflate algorithm if the server supports it.
+ *
+ * @return the TLS-wrapped socket.
+ */
+forge.tls.wrapSocket = function(options) {
+ // get raw socket
+ var socket = options.socket;
+
+ // create TLS socket
+ var tlsSocket = {
+ id: socket.id,
+ // set handlers
+ connected: socket.connected || function(e){},
+ closed: socket.closed || function(e){},
+ data: socket.data || function(e){},
+ error: socket.error || function(e){}
+ };
+
+ // create TLS connection
+ var c = forge.tls.createConnection({
+ server: false,
+ sessionId: options.sessionId || null,
+ caStore: options.caStore || [],
+ sessionCache: options.sessionCache || null,
+ cipherSuites: options.cipherSuites || null,
+ virtualHost: options.virtualHost,
+ verify: options.verify,
+ getCertificate: options.getCertificate,
+ getPrivateKey: options.getPrivateKey,
+ getSignature: options.getSignature,
+ deflate: options.deflate,
+ inflate: options.inflate,
+ connected: function(c) {
+ // first handshake complete, call handler
+ if(c.handshakes === 1) {
+ tlsSocket.connected({
+ id: socket.id,
+ type: 'connect',
+ bytesAvailable: c.data.length()
+ });
+ }
+ },
+ tlsDataReady: function(c) {
+ // send TLS data over socket
+ return socket.send(c.tlsData.getBytes());
+ },
+ dataReady: function(c) {
+ // indicate application data is ready
+ tlsSocket.data({
+ id: socket.id,
+ type: 'socketData',
+ bytesAvailable: c.data.length()
+ });
+ },
+ closed: function(c) {
+ // close socket
+ socket.close();
+ },
+ error: function(c, e) {
+ // send error, close socket
+ tlsSocket.error({
+ id: socket.id,
+ type: 'tlsError',
+ message: e.message,
+ bytesAvailable: 0,
+ error: e
+ });
+ socket.close();
+ }
+ });
+
+ // handle doing handshake after connecting
+ socket.connected = function(e) {
+ c.handshake(options.sessionId);
+ };
+
+ // handle closing TLS connection
+ socket.closed = function(e) {
+ if(c.open && c.handshaking) {
+ // error
+ tlsSocket.error({
+ id: socket.id,
+ type: 'ioError',
+ message: 'Connection closed during handshake.',
+ bytesAvailable: 0
+ });
+ }
+ c.close();
+
+ // call socket handler
+ tlsSocket.closed({
+ id: socket.id,
+ type: 'close',
+ bytesAvailable: 0
+ });
+ };
+
+ // handle error on socket
+ socket.error = function(e) {
+ // error
+ tlsSocket.error({
+ id: socket.id,
+ type: e.type,
+ message: e.message,
+ bytesAvailable: 0
+ });
+ c.close();
+ };
+
+ // handle receiving raw TLS data from socket
+ var _requiredBytes = 0;
+ socket.data = function(e) {
+ // drop data if connection not open
+ if(!c.open) {
+ socket.receive(e.bytesAvailable);
+ } else {
+ // only receive if there are enough bytes available to
+ // process a record
+ if(e.bytesAvailable >= _requiredBytes) {
+ var count = Math.max(e.bytesAvailable, _requiredBytes);
+ var data = socket.receive(count);
+ if(data !== null) {
+ _requiredBytes = c.process(data);
+ }
+ }
+ }
+ };
+
+ /**
+ * Destroys this socket.
+ */
+ tlsSocket.destroy = function() {
+ socket.destroy();
+ };
+
+ /**
+ * Sets this socket's TLS session cache. This should be called before
+ * the socket is connected or after it is closed.
+ *
+ * The cache is an object mapping session IDs to internal opaque state.
+ * An application might need to change the cache used by a particular
+ * tlsSocket between connections if it accesses multiple TLS hosts.
+ *
+ * @param cache the session cache to use.
+ */
+ tlsSocket.setSessionCache = function(cache) {
+ c.sessionCache = tls.createSessionCache(cache);
+ };
+
+ /**
+ * Connects this socket.
+ *
+ * @param options:
+ * host: the host to connect to.
+ * port: the port to connect to.
+ * policyPort: the policy port to use (if non-default), 0 to
+ * use the flash default.
+ * policyUrl: the policy file URL to use (instead of port).
+ */
+ tlsSocket.connect = function(options) {
+ socket.connect(options);
+ };
+
+ /**
+ * Closes this socket.
+ */
+ tlsSocket.close = function() {
+ c.close();
+ };
+
+ /**
+ * Determines if the socket is connected or not.
+ *
+ * @return true if connected, false if not.
+ */
+ tlsSocket.isConnected = function() {
+ return c.isConnected && socket.isConnected();
+ };
+
+ /**
+ * Writes bytes to this socket.
+ *
+ * @param bytes the bytes (as a string) to write.
+ *
+ * @return true on success, false on failure.
+ */
+ tlsSocket.send = function(bytes) {
+ return c.prepare(bytes);
+ };
+
+ /**
+ * Reads bytes from this socket (non-blocking). Fewer than the number of
+ * bytes requested may be read if enough bytes are not available.
+ *
+ * This method should be called from the data handler if there are enough
+ * bytes available. To see how many bytes are available, check the
+ * 'bytesAvailable' property on the event in the data handler or call the
+ * bytesAvailable() function on the socket. If the browser is msie, then the
+ * bytesAvailable() function should be used to avoid race conditions.
+ * Otherwise, using the property on the data handler's event may be quicker.
+ *
+ * @param count the maximum number of bytes to read.
+ *
+ * @return the bytes read (as a string) or null on error.
+ */
+ tlsSocket.receive = function(count) {
+ return c.data.getBytes(count);
+ };
+
+ /**
+ * Gets the number of bytes available for receiving on the socket.
+ *
+ * @return the number of bytes available for receiving.
+ */
+ tlsSocket.bytesAvailable = function() {
+ return c.data.length();
+ };
+
+ return tlsSocket;
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'tlssocket';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './tls'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/util.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/util.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/util.js
new file mode 100644
index 0000000..0290842
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/util.js
@@ -0,0 +1,2953 @@
+/**
+ * Utility functions for web applications.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+/* Utilities API */
+var util = forge.util = forge.util || {};
+
+// define setImmediate and nextTick
+if(typeof process === 'undefined' || !process.nextTick) {
+ if(typeof setImmediate === 'function') {
+ util.setImmediate = setImmediate;
+ util.nextTick = function(callback) {
+ return setImmediate(callback);
+ };
+ } else {
+ util.setImmediate = function(callback) {
+ setTimeout(callback, 0);
+ };
+ util.nextTick = util.setImmediate;
+ }
+} else {
+ util.nextTick = process.nextTick;
+ if(typeof setImmediate === 'function') {
+ util.setImmediate = setImmediate;
+ } else {
+ util.setImmediate = util.nextTick;
+ }
+}
+
+// define isArray
+util.isArray = Array.isArray || function(x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+};
+
+// define isArrayBuffer
+util.isArrayBuffer = function(x) {
+ return typeof ArrayBuffer !== 'undefined' && x instanceof ArrayBuffer;
+};
+
+// define isArrayBufferView
+var _arrayBufferViews = [];
+if(typeof DataView !== 'undefined') {
+ _arrayBufferViews.push(DataView);
+}
+if(typeof Int8Array !== 'undefined') {
+ _arrayBufferViews.push(Int8Array);
+}
+if(typeof Uint8Array !== 'undefined') {
+ _arrayBufferViews.push(Uint8Array);
+}
+if(typeof Uint8ClampedArray !== 'undefined') {
+ _arrayBufferViews.push(Uint8ClampedArray);
+}
+if(typeof Int16Array !== 'undefined') {
+ _arrayBufferViews.push(Int16Array);
+}
+if(typeof Uint16Array !== 'undefined') {
+ _arrayBufferViews.push(Uint16Array);
+}
+if(typeof Int32Array !== 'undefined') {
+ _arrayBufferViews.push(Int32Array);
+}
+if(typeof Uint32Array !== 'undefined') {
+ _arrayBufferViews.push(Uint32Array);
+}
+if(typeof Float32Array !== 'undefined') {
+ _arrayBufferViews.push(Float32Array);
+}
+if(typeof Float64Array !== 'undefined') {
+ _arrayBufferViews.push(Float64Array);
+}
+util.isArrayBufferView = function(x) {
+ for(var i = 0; i < _arrayBufferViews.length; ++i) {
+ if(x instanceof _arrayBufferViews[i]) {
+ return true;
+ }
+ }
+ return false;
+};
+
+// TODO: set ByteBuffer to best available backing
+util.ByteBuffer = ByteStringBuffer;
+
+/** Buffer w/BinaryString backing */
+
+/**
+ * Constructor for a binary string backed byte buffer.
+ *
+ * @param [b] the bytes to wrap (either encoded as string, one byte per
+ * character, or as an ArrayBuffer or Typed Array).
+ */
+function ByteStringBuffer(b) {
+ // TODO: update to match DataBuffer API
+
+ // the data in this buffer
+ this.data = '';
+ // the pointer for reading from this buffer
+ this.read = 0;
+
+ if(typeof b === 'string') {
+ this.data = b;
+ } else if(util.isArrayBuffer(b) || util.isArrayBufferView(b)) {
+ // convert native buffer to forge buffer
+ // FIXME: support native buffers internally instead
+ var arr = new Uint8Array(b);
+ try {
+ this.data = String.fromCharCode.apply(null, arr);
+ } catch(e) {
+ for(var i = 0; i < arr.length; ++i) {
+ this.putByte(arr[i]);
+ }
+ }
+ } else if(b instanceof ByteStringBuffer ||
+ (typeof b === 'object' && typeof b.data === 'string' &&
+ typeof b.read === 'number')) {
+ // copy existing buffer
+ this.data = b.data;
+ this.read = b.read;
+ }
+
+ // used for v8 optimization
+ this._constructedStringLength = 0;
+}
+util.ByteStringBuffer = ByteStringBuffer;
+
+/* Note: This is an optimization for V8-based browsers. When V8 concatenates
+ a string, the strings are only joined logically using a "cons string" or
+ "constructed/concatenated string". These containers keep references to one
+ another and can result in very large memory usage. For example, if a 2MB
+ string is constructed by concatenating 4 bytes together at a time, the
+ memory usage will be ~44MB; so ~22x increase. The strings are only joined
+ together when an operation requiring their joining takes place, such as
+ substr(). This function is called when adding data to this buffer to ensure
+ these types of strings are periodically joined to reduce the memory
+ footprint. */
+var _MAX_CONSTRUCTED_STRING_LENGTH = 4096;
+util.ByteStringBuffer.prototype._optimizeConstructedString = function(x) {
+ this._constructedStringLength += x;
+ if(this._constructedStringLength > _MAX_CONSTRUCTED_STRING_LENGTH) {
+ // this substr() should cause the constructed string to join
+ this.data.substr(0, 1);
+ this._constructedStringLength = 0;
+ }
+};
+
+/**
+ * Gets the number of bytes in this buffer.
+ *
+ * @return the number of bytes in this buffer.
+ */
+util.ByteStringBuffer.prototype.length = function() {
+ return this.data.length - this.read;
+};
+
+/**
+ * Gets whether or not this buffer is empty.
+ *
+ * @return true if this buffer is empty, false if not.
+ */
+util.ByteStringBuffer.prototype.isEmpty = function() {
+ return this.length() <= 0;
+};
+
+/**
+ * Puts a byte in this buffer.
+ *
+ * @param b the byte to put.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putByte = function(b) {
+ return this.putBytes(String.fromCharCode(b));
+};
+
+/**
+ * Puts a byte in this buffer N times.
+ *
+ * @param b the byte to put.
+ * @param n the number of bytes of value b to put.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.fillWithByte = function(b, n) {
+ b = String.fromCharCode(b);
+ var d = this.data;
+ while(n > 0) {
+ if(n & 1) {
+ d += b;
+ }
+ n >>>= 1;
+ if(n > 0) {
+ b += b;
+ }
+ }
+ this.data = d;
+ this._optimizeConstructedString(n);
+ return this;
+};
+
+/**
+ * Puts bytes in this buffer.
+ *
+ * @param bytes the bytes (as a UTF-8 encoded string) to put.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putBytes = function(bytes) {
+ this.data += bytes;
+ this._optimizeConstructedString(bytes.length);
+ return this;
+};
+
+/**
+ * Puts a UTF-16 encoded string into this buffer.
+ *
+ * @param str the string to put.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putString = function(str) {
+ return this.putBytes(util.encodeUtf8(str));
+};
+
+/**
+ * Puts a 16-bit integer in this buffer in big-endian order.
+ *
+ * @param i the 16-bit integer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putInt16 = function(i) {
+ return this.putBytes(
+ String.fromCharCode(i >> 8 & 0xFF) +
+ String.fromCharCode(i & 0xFF));
+};
+
+/**
+ * Puts a 24-bit integer in this buffer in big-endian order.
+ *
+ * @param i the 24-bit integer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putInt24 = function(i) {
+ return this.putBytes(
+ String.fromCharCode(i >> 16 & 0xFF) +
+ String.fromCharCode(i >> 8 & 0xFF) +
+ String.fromCharCode(i & 0xFF));
+};
+
+/**
+ * Puts a 32-bit integer in this buffer in big-endian order.
+ *
+ * @param i the 32-bit integer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putInt32 = function(i) {
+ return this.putBytes(
+ String.fromCharCode(i >> 24 & 0xFF) +
+ String.fromCharCode(i >> 16 & 0xFF) +
+ String.fromCharCode(i >> 8 & 0xFF) +
+ String.fromCharCode(i & 0xFF));
+};
+
+/**
+ * Puts a 16-bit integer in this buffer in little-endian order.
+ *
+ * @param i the 16-bit integer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putInt16Le = function(i) {
+ return this.putBytes(
+ String.fromCharCode(i & 0xFF) +
+ String.fromCharCode(i >> 8 & 0xFF));
+};
+
+/**
+ * Puts a 24-bit integer in this buffer in little-endian order.
+ *
+ * @param i the 24-bit integer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putInt24Le = function(i) {
+ return this.putBytes(
+ String.fromCharCode(i & 0xFF) +
+ String.fromCharCode(i >> 8 & 0xFF) +
+ String.fromCharCode(i >> 16 & 0xFF));
+};
+
+/**
+ * Puts a 32-bit integer in this buffer in little-endian order.
+ *
+ * @param i the 32-bit integer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putInt32Le = function(i) {
+ return this.putBytes(
+ String.fromCharCode(i & 0xFF) +
+ String.fromCharCode(i >> 8 & 0xFF) +
+ String.fromCharCode(i >> 16 & 0xFF) +
+ String.fromCharCode(i >> 24 & 0xFF));
+};
+
+/**
+ * Puts an n-bit integer in this buffer in big-endian order.
+ *
+ * @param i the n-bit integer.
+ * @param n the number of bits in the integer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putInt = function(i, n) {
+ var bytes = '';
+ do {
+ n -= 8;
+ bytes += String.fromCharCode((i >> n) & 0xFF);
+ } while(n > 0);
+ return this.putBytes(bytes);
+};
+
+/**
+ * Puts a signed n-bit integer in this buffer in big-endian order. Two's
+ * complement representation is used.
+ *
+ * @param i the n-bit integer.
+ * @param n the number of bits in the integer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putSignedInt = function(i, n) {
+ if(i < 0) {
+ i += 2 << (n - 1);
+ }
+ return this.putInt(i, n);
+};
+
+/**
+ * Puts the given buffer into this buffer.
+ *
+ * @param buffer the buffer to put into this one.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.putBuffer = function(buffer) {
+ return this.putBytes(buffer.getBytes());
+};
+
+/**
+ * Gets a byte from this buffer and advances the read pointer by 1.
+ *
+ * @return the byte.
+ */
+util.ByteStringBuffer.prototype.getByte = function() {
+ return this.data.charCodeAt(this.read++);
+};
+
+/**
+ * Gets a uint16 from this buffer in big-endian order and advances the read
+ * pointer by 2.
+ *
+ * @return the uint16.
+ */
+util.ByteStringBuffer.prototype.getInt16 = function() {
+ var rval = (
+ this.data.charCodeAt(this.read) << 8 ^
+ this.data.charCodeAt(this.read + 1));
+ this.read += 2;
+ return rval;
+};
+
+/**
+ * Gets a uint24 from this buffer in big-endian order and advances the read
+ * pointer by 3.
+ *
+ * @return the uint24.
+ */
+util.ByteStringBuffer.prototype.getInt24 = function() {
+ var rval = (
+ this.data.charCodeAt(this.read) << 16 ^
+ this.data.charCodeAt(this.read + 1) << 8 ^
+ this.data.charCodeAt(this.read + 2));
+ this.read += 3;
+ return rval;
+};
+
+/**
+ * Gets a uint32 from this buffer in big-endian order and advances the read
+ * pointer by 4.
+ *
+ * @return the word.
+ */
+util.ByteStringBuffer.prototype.getInt32 = function() {
+ var rval = (
+ this.data.charCodeAt(this.read) << 24 ^
+ this.data.charCodeAt(this.read + 1) << 16 ^
+ this.data.charCodeAt(this.read + 2) << 8 ^
+ this.data.charCodeAt(this.read + 3));
+ this.read += 4;
+ return rval;
+};
+
+/**
+ * Gets a uint16 from this buffer in little-endian order and advances the read
+ * pointer by 2.
+ *
+ * @return the uint16.
+ */
+util.ByteStringBuffer.prototype.getInt16Le = function() {
+ var rval = (
+ this.data.charCodeAt(this.read) ^
+ this.data.charCodeAt(this.read + 1) << 8);
+ this.read += 2;
+ return rval;
+};
+
+/**
+ * Gets a uint24 from this buffer in little-endian order and advances the read
+ * pointer by 3.
+ *
+ * @return the uint24.
+ */
+util.ByteStringBuffer.prototype.getInt24Le = function() {
+ var rval = (
+ this.data.charCodeAt(this.read) ^
+ this.data.charCodeAt(this.read + 1) << 8 ^
+ this.data.charCodeAt(this.read + 2) << 16);
+ this.read += 3;
+ return rval;
+};
+
+/**
+ * Gets a uint32 from this buffer in little-endian order and advances the read
+ * pointer by 4.
+ *
+ * @return the word.
+ */
+util.ByteStringBuffer.prototype.getInt32Le = function() {
+ var rval = (
+ this.data.charCodeAt(this.read) ^
+ this.data.charCodeAt(this.read + 1) << 8 ^
+ this.data.charCodeAt(this.read + 2) << 16 ^
+ this.data.charCodeAt(this.read + 3) << 24);
+ this.read += 4;
+ return rval;
+};
+
+/**
+ * Gets an n-bit integer from this buffer in big-endian order and advances the
+ * read pointer by n/8.
+ *
+ * @param n the number of bits in the integer.
+ *
+ * @return the integer.
+ */
+util.ByteStringBuffer.prototype.getInt = function(n) {
+ var rval = 0;
+ do {
+ rval = (rval << 8) + this.data.charCodeAt(this.read++);
+ n -= 8;
+ } while(n > 0);
+ return rval;
+};
+
+/**
+ * Gets a signed n-bit integer from this buffer in big-endian order, using
+ * two's complement, and advances the read pointer by n/8.
+ *
+ * @param n the number of bits in the integer.
+ *
+ * @return the integer.
+ */
+util.ByteStringBuffer.prototype.getSignedInt = function(n) {
+ var x = this.getInt(n);
+ var max = 2 << (n - 2);
+ if(x >= max) {
+ x -= max << 1;
+ }
+ return x;
+};
+
+/**
+ * Reads bytes out into a UTF-8 string and clears them from the buffer.
+ *
+ * @param count the number of bytes to read, undefined or null for all.
+ *
+ * @return a UTF-8 string of bytes.
+ */
+util.ByteStringBuffer.prototype.getBytes = function(count) {
+ var rval;
+ if(count) {
+ // read count bytes
+ count = Math.min(this.length(), count);
+ rval = this.data.slice(this.read, this.read + count);
+ this.read += count;
+ } else if(count === 0) {
+ rval = '';
+ } else {
+ // read all bytes, optimize to only copy when needed
+ rval = (this.read === 0) ? this.data : this.data.slice(this.read);
+ this.clear();
+ }
+ return rval;
+};
+
+/**
+ * Gets a UTF-8 encoded string of the bytes from this buffer without modifying
+ * the read pointer.
+ *
+ * @param count the number of bytes to get, omit to get all.
+ *
+ * @return a string full of UTF-8 encoded characters.
+ */
+util.ByteStringBuffer.prototype.bytes = function(count) {
+ return (typeof(count) === 'undefined' ?
+ this.data.slice(this.read) :
+ this.data.slice(this.read, this.read + count));
+};
+
+/**
+ * Gets a byte at the given index without modifying the read pointer.
+ *
+ * @param i the byte index.
+ *
+ * @return the byte.
+ */
+util.ByteStringBuffer.prototype.at = function(i) {
+ return this.data.charCodeAt(this.read + i);
+};
+
+/**
+ * Puts a byte at the given index without modifying the read pointer.
+ *
+ * @param i the byte index.
+ * @param b the byte to put.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.setAt = function(i, b) {
+ this.data = this.data.substr(0, this.read + i) +
+ String.fromCharCode(b) +
+ this.data.substr(this.read + i + 1);
+ return this;
+};
+
+/**
+ * Gets the last byte without modifying the read pointer.
+ *
+ * @return the last byte.
+ */
+util.ByteStringBuffer.prototype.last = function() {
+ return this.data.charCodeAt(this.data.length - 1);
+};
+
+/**
+ * Creates a copy of this buffer.
+ *
+ * @return the copy.
+ */
+util.ByteStringBuffer.prototype.copy = function() {
+ var c = util.createBuffer(this.data);
+ c.read = this.read;
+ return c;
+};
+
+/**
+ * Compacts this buffer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.compact = function() {
+ if(this.read > 0) {
+ this.data = this.data.slice(this.read);
+ this.read = 0;
+ }
+ return this;
+};
+
+/**
+ * Clears this buffer.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.clear = function() {
+ this.data = '';
+ this.read = 0;
+ return this;
+};
+
+/**
+ * Shortens this buffer by triming bytes off of the end of this buffer.
+ *
+ * @param count the number of bytes to trim off.
+ *
+ * @return this buffer.
+ */
+util.ByteStringBuffer.prototype.truncate = function(count) {
+ var len = Math.max(0, this.length() - count);
+ this.data = this.data.substr(this.read, len);
+ this.read = 0;
+ return this;
+};
+
+/**
+ * Converts this buffer to a hexadecimal string.
+ *
+ * @return a hexadecimal string.
+ */
+util.ByteStringBuffer.prototype.toHex = function() {
+ var rval = '';
+ for(var i = this.read; i < this.data.length; ++i) {
+ var b = this.data.charCodeAt(i);
+ if(b < 16) {
+ rval += '0';
+ }
+ rval += b.toString(16);
+ }
+ return rval;
+};
+
+/**
+ * Converts this buffer to a UTF-16 string (standard JavaScript string).
+ *
+ * @return a UTF-16 string.
+ */
+util.ByteStringBuffer.prototype.toString = function() {
+ return util.decodeUtf8(this.bytes());
+};
+
+/** End Buffer w/BinaryString backing */
+
+
+/** Buffer w/UInt8Array backing */
+
+/**
+ * FIXME: Experimental. Do not use yet.
+ *
+ * Constructor for an ArrayBuffer-backed byte buffer.
+ *
+ * The buffer may be constructed from a string, an ArrayBuffer, DataView, or a
+ * TypedArray.
+ *
+ * If a string is given, its encoding should be provided as an option,
+ * otherwise it will default to 'binary'. A 'binary' string is encoded such
+ * that each character is one byte in length and size.
+ *
+ * If an ArrayBuffer, DataView, or TypedArray is given, it will be used
+ * *directly* without any copying. Note that, if a write to the buffer requires
+ * more space, the buffer will allocate a new backing ArrayBuffer to
+ * accommodate. The starting read and write offsets for the buffer may be
+ * given as options.
+ *
+ * @param [b] the initial bytes for this buffer.
+ * @param options the options to use:
+ * [readOffset] the starting read offset to use (default: 0).
+ * [writeOffset] the starting write offset to use (default: the
+ * length of the first parameter).
+ * [growSize] the minimum amount, in bytes, to grow the buffer by to
+ * accommodate writes (default: 1024).
+ * [encoding] the encoding ('binary', 'utf8', 'utf16', 'hex') for the
+ * first parameter, if it is a string (default: 'binary').
+ */
+function DataBuffer(b, options) {
+ // default options
+ options = options || {};
+
+ // pointers for read from/write to buffer
+ this.read = options.readOffset || 0;
+ this.growSize = options.growSize || 1024;
+
+ var isArrayBuffer = util.isArrayBuffer(b);
+ var isArrayBufferView = util.isArrayBufferView(b);
+ if(isArrayBuffer || isArrayBufferView) {
+ // use ArrayBuffer directly
+ if(isArrayBuffer) {
+ this.data = new DataView(b);
+ } else {
+ // TODO: adjust read/write offset based on the type of view
+ // or specify that this must be done in the options ... that the
+ // offsets are byte-based
+ this.data = new DataView(b.buffer, b.byteOffset, b.byteLength);
+ }
+ this.write = ('writeOffset' in options ?
+ options.writeOffset : this.data.byteLength);
+ return;
+ }
+
+ // initialize to empty array buffer and add any given bytes using putBytes
+ this.data = new DataView(new ArrayBuffer(0));
+ this.write = 0;
+
+ if(b !== null && b !== undefined) {
+ this.putBytes(b);
+ }
+
+ if('writeOffset' in options) {
+ this.write = options.writeOffset;
+ }
+}
+util.DataBuffer = DataBuffer;
+
+/**
+ * Gets the number of bytes in this buffer.
+ *
+ * @return the number of bytes in this buffer.
+ */
+util.DataBuffer.prototype.length = function() {
+ return this.write - this.read;
+};
+
+/**
+ * Gets whether or not this buffer is empty.
+ *
+ * @return true if this buffer is empty, false if not.
+ */
+util.DataBuffer.prototype.isEmpty = function() {
+ return this.length() <= 0;
+};
+
+/**
+ * Ensures this buffer has enough empty space to accommodate the given number
+ * of bytes. An optional parameter may be given that indicates a minimum
+ * amount to grow the buffer if necessary. If the parameter is not given,
+ * the buffer will be grown by some previously-specified default amount
+ * or heuristic.
+ *
+ * @param amount the number of bytes to accommodate.
+ * @param [growSize] the minimum amount, in bytes, to grow the buffer by if
+ * necessary.
+ */
+util.DataBuffer.prototype.accommodate = function(amount, growSize) {
+ if(this.length() >= amount) {
+ return this;
+ }
+ growSize = Math.max(growSize || this.growSize, amount);
+
+ // grow buffer
+ var src = new Uint8Array(
+ this.data.buffer, this.data.byteOffset, this.data.byteLength);
+ var dst = new Uint8Array(this.length() + growSize);
+ dst.set(src);
+ this.data = new DataView(dst.buffer);
+
+ return this;
+};
+
+/**
+ * Puts a byte in this buffer.
+ *
+ * @param b the byte to put.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putByte = function(b) {
+ this.accommodate(1);
+ this.data.setUint8(this.write++, b);
+ return this;
+};
+
+/**
+ * Puts a byte in this buffer N times.
+ *
+ * @param b the byte to put.
+ * @param n the number of bytes of value b to put.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.fillWithByte = function(b, n) {
+ this.accommodate(n);
+ for(var i = 0; i < n; ++i) {
+ this.data.setUint8(b);
+ }
+ return this;
+};
+
+/**
+ * Puts bytes in this buffer. The bytes may be given as a string, an
+ * ArrayBuffer, a DataView, or a TypedArray.
+ *
+ * @param bytes the bytes to put.
+ * @param [encoding] the encoding for the first parameter ('binary', 'utf8',
+ * 'utf16', 'hex'), if it is a string (default: 'binary').
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putBytes = function(bytes, encoding) {
+ if(util.isArrayBufferView(bytes)) {
+ var src = new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
+ var len = src.byteLength - src.byteOffset;
+ this.accommodate(len);
+ var dst = new Uint8Array(this.data.buffer, this.write);
+ dst.set(src);
+ this.write += len;
+ return this;
+ }
+
+ if(util.isArrayBuffer(bytes)) {
+ var src = new Uint8Array(bytes);
+ this.accommodate(src.byteLength);
+ var dst = new Uint8Array(this.data.buffer);
+ dst.set(src, this.write);
+ this.write += src.byteLength;
+ return this;
+ }
+
+ // bytes is a util.DataBuffer or equivalent
+ if(bytes instanceof util.DataBuffer ||
+ (typeof bytes === 'object' &&
+ typeof bytes.read === 'number' && typeof bytes.write === 'number' &&
+ util.isArrayBufferView(bytes.data))) {
+ var src = new Uint8Array(bytes.data.byteLength, bytes.read, bytes.length());
+ this.accommodate(src.byteLength);
+ var dst = new Uint8Array(bytes.data.byteLength, this.write);
+ dst.set(src);
+ this.write += src.byteLength;
+ return this;
+ }
+
+ if(bytes instanceof util.ByteStringBuffer) {
+ // copy binary string and process as the same as a string parameter below
+ bytes = bytes.data;
+ encoding = 'binary';
+ }
+
+ // string conversion
+ encoding = encoding || 'binary';
+ if(typeof bytes === 'string') {
+ var view;
+
+ // decode from string
+ if(encoding === 'hex') {
+ this.accommodate(Math.ceil(bytes.length / 2));
+ view = new Uint8Array(this.data.buffer, this.write);
+ this.write += util.binary.hex.decode(bytes, view, this.write);
+ return this;
+ }
+ if(encoding === 'base64') {
+ this.accommodate(Math.ceil(bytes.length / 4) * 3);
+ view = new Uint8Array(this.data.buffer, this.write);
+ this.write += util.binary.base64.decode(bytes, view, this.write);
+ return this;
+ }
+
+ // encode text as UTF-8 bytes
+ if(encoding === 'utf8') {
+ // encode as UTF-8 then decode string as raw binary
+ bytes = util.encodeUtf8(bytes);
+ encoding = 'binary';
+ }
+
+ // decode string as raw binary
+ if(encoding === 'binary' || encoding === 'raw') {
+ // one byte per character
+ this.accommodate(bytes.length);
+ view = new Uint8Array(this.data.buffer, this.write);
+ this.write += util.binary.raw.decode(view);
+ return this;
+ }
+
+ // encode text as UTF-16 bytes
+ if(encoding === 'utf16') {
+ // two bytes per character
+ this.accommodate(bytes.length * 2);
+ view = new Uint16Array(this.data.buffer, this.write);
+ this.write += util.text.utf16.encode(view);
+ return this;
+ }
+
+ throw new Error('Invalid encoding: ' + encoding);
+ }
+
+ throw Error('Invalid parameter: ' + bytes);
+};
+
+/**
+ * Puts the given buffer into this buffer.
+ *
+ * @param buffer the buffer to put into this one.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putBuffer = function(buffer) {
+ this.putBytes(buffer);
+ buffer.clear();
+ return this;
+};
+
+/**
+ * Puts a string into this buffer.
+ *
+ * @param str the string to put.
+ * @param [encoding] the encoding for the string (default: 'utf16').
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putString = function(str) {
+ return this.putBytes(str, 'utf16');
+};
+
+/**
+ * Puts a 16-bit integer in this buffer in big-endian order.
+ *
+ * @param i the 16-bit integer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putInt16 = function(i) {
+ this.accommodate(2);
+ this.data.setInt16(this.write, i);
+ this.write += 2;
+ return this;
+};
+
+/**
+ * Puts a 24-bit integer in this buffer in big-endian order.
+ *
+ * @param i the 24-bit integer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putInt24 = function(i) {
+ this.accommodate(3);
+ this.data.setInt16(this.write, i >> 8 & 0xFFFF);
+ this.data.setInt8(this.write, i >> 16 & 0xFF);
+ this.write += 3;
+ return this;
+};
+
+/**
+ * Puts a 32-bit integer in this buffer in big-endian order.
+ *
+ * @param i the 32-bit integer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putInt32 = function(i) {
+ this.accommodate(4);
+ this.data.setInt32(this.write, i);
+ this.write += 4;
+ return this;
+};
+
+/**
+ * Puts a 16-bit integer in this buffer in little-endian order.
+ *
+ * @param i the 16-bit integer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putInt16Le = function(i) {
+ this.accommodate(2);
+ this.data.setInt16(this.write, i, true);
+ this.write += 2;
+ return this;
+};
+
+/**
+ * Puts a 24-bit integer in this buffer in little-endian order.
+ *
+ * @param i the 24-bit integer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putInt24Le = function(i) {
+ this.accommodate(3);
+ this.data.setInt8(this.write, i >> 16 & 0xFF);
+ this.data.setInt16(this.write, i >> 8 & 0xFFFF, true);
+ this.write += 3;
+ return this;
+};
+
+/**
+ * Puts a 32-bit integer in this buffer in little-endian order.
+ *
+ * @param i the 32-bit integer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putInt32Le = function(i) {
+ this.accommodate(4);
+ this.data.setInt32(this.write, i, true);
+ this.write += 4;
+ return this;
+};
+
+/**
+ * Puts an n-bit integer in this buffer in big-endian order.
+ *
+ * @param i the n-bit integer.
+ * @param n the number of bits in the integer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putInt = function(i, n) {
+ this.accommodate(n / 8);
+ do {
+ n -= 8;
+ this.data.setInt8(this.write++, (i >> n) & 0xFF);
+ } while(n > 0);
+ return this;
+};
+
+/**
+ * Puts a signed n-bit integer in this buffer in big-endian order. Two's
+ * complement representation is used.
+ *
+ * @param i the n-bit integer.
+ * @param n the number of bits in the integer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.putSignedInt = function(i, n) {
+ this.accommodate(n / 8);
+ if(i < 0) {
+ i += 2 << (n - 1);
+ }
+ return this.putInt(i, n);
+};
+
+/**
+ * Gets a byte from this buffer and advances the read pointer by 1.
+ *
+ * @return the byte.
+ */
+util.DataBuffer.prototype.getByte = function() {
+ return this.data.getInt8(this.read++);
+};
+
+/**
+ * Gets a uint16 from this buffer in big-endian order and advances the read
+ * pointer by 2.
+ *
+ * @return the uint16.
+ */
+util.DataBuffer.prototype.getInt16 = function() {
+ var rval = this.data.getInt16(this.read);
+ this.read += 2;
+ return rval;
+};
+
+/**
+ * Gets a uint24 from this buffer in big-endian order and advances the read
+ * pointer by 3.
+ *
+ * @return the uint24.
+ */
+util.DataBuffer.prototype.getInt24 = function() {
+ var rval = (
+ this.data.getInt16(this.read) << 8 ^
+ this.data.getInt8(this.read + 2));
+ this.read += 3;
+ return rval;
+};
+
+/**
+ * Gets a uint32 from this buffer in big-endian order and advances the read
+ * pointer by 4.
+ *
+ * @return the word.
+ */
+util.DataBuffer.prototype.getInt32 = function() {
+ var rval = this.data.getInt32(this.read);
+ this.read += 4;
+ return rval;
+};
+
+/**
+ * Gets a uint16 from this buffer in little-endian order and advances the read
+ * pointer by 2.
+ *
+ * @return the uint16.
+ */
+util.DataBuffer.prototype.getInt16Le = function() {
+ var rval = this.data.getInt16(this.read, true);
+ this.read += 2;
+ return rval;
+};
+
+/**
+ * Gets a uint24 from this buffer in little-endian order and advances the read
+ * pointer by 3.
+ *
+ * @return the uint24.
+ */
+util.DataBuffer.prototype.getInt24Le = function() {
+ var rval = (
+ this.data.getInt8(this.read) ^
+ this.data.getInt16(this.read + 1, true) << 8);
+ this.read += 3;
+ return rval;
+};
+
+/**
+ * Gets a uint32 from this buffer in little-endian order and advances the read
+ * pointer by 4.
+ *
+ * @return the word.
+ */
+util.DataBuffer.prototype.getInt32Le = function() {
+ var rval = this.data.getInt32(this.read, true);
+ this.read += 4;
+ return rval;
+};
+
+/**
+ * Gets an n-bit integer from this buffer in big-endian order and advances the
+ * read pointer by n/8.
+ *
+ * @param n the number of bits in the integer.
+ *
+ * @return the integer.
+ */
+util.DataBuffer.prototype.getInt = function(n) {
+ var rval = 0;
+ do {
+ rval = (rval << 8) + this.data.getInt8(this.read++);
+ n -= 8;
+ } while(n > 0);
+ return rval;
+};
+
+/**
+ * Gets a signed n-bit integer from this buffer in big-endian order, using
+ * two's complement, and advances the read pointer by n/8.
+ *
+ * @param n the number of bits in the integer.
+ *
+ * @return the integer.
+ */
+util.DataBuffer.prototype.getSignedInt = function(n) {
+ var x = this.getInt(n);
+ var max = 2 << (n - 2);
+ if(x >= max) {
+ x -= max << 1;
+ }
+ return x;
+};
+
+/**
+ * Reads bytes out into a UTF-8 string and clears them from the buffer.
+ *
+ * @param count the number of bytes to read, undefined or null for all.
+ *
+ * @return a UTF-8 string of bytes.
+ */
+util.DataBuffer.prototype.getBytes = function(count) {
+ // TODO: deprecate this method, it is poorly named and
+ // this.toString('binary') replaces it
+ // add a toTypedArray()/toArrayBuffer() function
+ var rval;
+ if(count) {
+ // read count bytes
+ count = Math.min(this.length(), count);
+ rval = this.data.slice(this.read, this.read + count);
+ this.read += count;
+ } else if(count === 0) {
+ rval = '';
+ } else {
+ // read all bytes, optimize to only copy when needed
+ rval = (this.read === 0) ? this.data : this.data.slice(this.read);
+ this.clear();
+ }
+ return rval;
+};
+
+/**
+ * Gets a UTF-8 encoded string of the bytes from this buffer without modifying
+ * the read pointer.
+ *
+ * @param count the number of bytes to get, omit to get all.
+ *
+ * @return a string full of UTF-8 encoded characters.
+ */
+util.DataBuffer.prototype.bytes = function(count) {
+ // TODO: deprecate this method, it is poorly named, add "getString()"
+ return (typeof(count) === 'undefined' ?
+ this.data.slice(this.read) :
+ this.data.slice(this.read, this.read + count));
+};
+
+/**
+ * Gets a byte at the given index without modifying the read pointer.
+ *
+ * @param i the byte index.
+ *
+ * @return the byte.
+ */
+util.DataBuffer.prototype.at = function(i) {
+ return this.data.getUint8(this.read + i);
+};
+
+/**
+ * Puts a byte at the given index without modifying the read pointer.
+ *
+ * @param i the byte index.
+ * @param b the byte to put.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.setAt = function(i, b) {
+ this.data.setUint8(i, b);
+ return this;
+};
+
+/**
+ * Gets the last byte without modifying the read pointer.
+ *
+ * @return the last byte.
+ */
+util.DataBuffer.prototype.last = function() {
+ return this.data.getUint8(this.write - 1);
+};
+
+/**
+ * Creates a copy of this buffer.
+ *
+ * @return the copy.
+ */
+util.DataBuffer.prototype.copy = function() {
+ return new util.DataBuffer(this);
+};
+
+/**
+ * Compacts this buffer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.compact = function() {
+ if(this.read > 0) {
+ var src = new Uint8Array(this.data.buffer, this.read);
+ var dst = new Uint8Array(src.byteLength);
+ dst.set(src);
+ this.data = new DataView(dst);
+ this.write -= this.read;
+ this.read = 0;
+ }
+ return this;
+};
+
+/**
+ * Clears this buffer.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.clear = function() {
+ this.data = new DataView(new ArrayBuffer(0));
+ this.read = this.write = 0;
+ return this;
+};
+
+/**
+ * Shortens this buffer by triming bytes off of the end of this buffer.
+ *
+ * @param count the number of bytes to trim off.
+ *
+ * @return this buffer.
+ */
+util.DataBuffer.prototype.truncate = function(count) {
+ this.write = Math.max(0, this.length() - count);
+ this.read = Math.min(this.read, this.write);
+ return this;
+};
+
+/**
+ * Converts this buffer to a hexadecimal string.
+ *
+ * @return a hexadecimal string.
+ */
+util.DataBuffer.prototype.toHex = function() {
+ var rval = '';
+ for(var i = this.read; i < this.data.byteLength; ++i) {
+ var b = this.data.getUint8(i);
+ if(b < 16) {
+ rval += '0';
+ }
+ rval += b.toString(16);
+ }
+ return rval;
+};
+
+/**
+ * Converts this buffer to a string, using the given encoding. If no
+ * encoding is given, 'utf8' (UTF-8) is used.
+ *
+ * @param [encoding] the encoding to use: 'binary', 'utf8', 'utf16', 'hex',
+ * 'base64' (default: 'utf8').
+ *
+ * @return a string representation of the bytes in this buffer.
+ */
+util.DataBuffer.prototype.toString = function(encoding) {
+ var view = new Uint8Array(this.data, this.read, this.length());
+ encoding = encoding || 'utf8';
+
+ // encode to string
+ if(encoding === 'binary' || encoding === 'raw') {
+ return util.binary.raw.encode(view);
+ }
+ if(encoding === 'hex') {
+ return util.binary.hex.encode(view);
+ }
+ if(encoding === 'base64') {
+ return util.binary.base64.encode(view);
+ }
+
+ // decode to text
+ if(encoding === 'utf8') {
+ return util.text.utf8.decode(view);
+ }
+ if(encoding === 'utf16') {
+ return util.text.utf16.decode(view);
+ }
+
+ throw new Error('Invalid encoding: ' + encoding);
+};
+
+/** End Buffer w/UInt8Array backing */
+
+
+/**
+ * Creates a buffer that stores bytes. A value may be given to put into the
+ * buffer that is either a string of bytes or a UTF-16 string that will
+ * be encoded using UTF-8 (to do the latter, specify 'utf8' as the encoding).
+ *
+ * @param [input] the bytes to wrap (as a string) or a UTF-16 string to encode
+ * as UTF-8.
+ * @param [encoding] (default: 'raw', other: 'utf8').
+ */
+util.createBuffer = function(input, encoding) {
+ // TODO: deprecate, use new ByteBuffer() instead
+ encoding = encoding || 'raw';
+ if(input !== undefined && encoding === 'utf8') {
+ input = util.encodeUtf8(input);
+ }
+ return new util.ByteBuffer(input);
+};
+
+/**
+ * Fills a string with a particular value. If you want the string to be a byte
+ * string, pass in String.fromCharCode(theByte).
+ *
+ * @param c the character to fill the string with, use String.fromCharCode
+ * to fill the string with a byte value.
+ * @param n the number of characters of value c to fill with.
+ *
+ * @return the filled string.
+ */
+util.fillString = function(c, n) {
+ var s = '';
+ while(n > 0) {
+ if(n & 1) {
+ s += c;
+ }
+ n >>>= 1;
+ if(n > 0) {
+ c += c;
+ }
+ }
+ return s;
+};
+
+/**
+ * Performs a per byte XOR between two byte strings and returns the result as a
+ * string of bytes.
+ *
+ * @param s1 first string of bytes.
+ * @param s2 second string of bytes.
+ * @param n the number of bytes to XOR.
+ *
+ * @return the XOR'd result.
+ */
+util.xorBytes = function(s1, s2, n) {
+ var s3 = '';
+ var b = '';
+ var t = '';
+ var i = 0;
+ var c = 0;
+ for(; n > 0; --n, ++i) {
+ b = s1.charCodeAt(i) ^ s2.charCodeAt(i);
+ if(c >= 10) {
+ s3 += t;
+ t = '';
+ c = 0;
+ }
+ t += String.fromCharCode(b);
+ ++c;
+ }
+ s3 += t;
+ return s3;
+};
+
+/**
+ * Converts a hex string into a 'binary' encoded string of bytes.
+ *
+ * @param hex the hexadecimal string to convert.
+ *
+ * @return the binary-encoded string of bytes.
+ */
+util.hexToBytes = function(hex) {
+ // TODO: deprecate: "Deprecated. Use util.binary.hex.decode instead."
+ var rval = '';
+ var i = 0;
+ if(hex.length & 1 == 1) {
+ // odd number of characters, convert first character alone
+ i = 1;
+ rval += String.fromCharCode(parseInt(hex[0], 16));
+ }
+ // convert 2 characters (1 byte) at a time
+ for(; i < hex.length; i += 2) {
+ rval += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
+ }
+ return rval;
+};
+
+/**
+ * Converts a 'binary' encoded string of bytes to hex.
+ *
+ * @param bytes the byte string to convert.
+ *
+ * @return the string of hexadecimal characters.
+ */
+util.bytesToHex = function(bytes) {
+ // TODO: deprecate: "Deprecated. Use util.binary.hex.encode instead."
+ return util.createBuffer(bytes).toHex();
+};
+
+/**
+ * Converts an 32-bit integer to 4-big-endian byte string.
+ *
+ * @param i the integer.
+ *
+ * @return the byte string.
+ */
+util.int32ToBytes = function(i) {
+ return (
+ String.fromCharCode(i >> 24 & 0xFF) +
+ String.fromCharCode(i >> 16 & 0xFF) +
+ String.fromCharCode(i >> 8 & 0xFF) +
+ String.fromCharCode(i & 0xFF));
+};
+
+// base64 characters, reverse mapping
+var _base64 =
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
+var _base64Idx = [
+/*43 -43 = 0*/
+/*'+', 1, 2, 3,'/' */
+ 62, -1, -1, -1, 63,
+
+/*'0','1','2','3','4','5','6','7','8','9' */
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+
+/*15, 16, 17,'=', 19, 20, 21 */
+ -1, -1, -1, 64, -1, -1, -1,
+
+/*65 - 43 = 22*/
+/*'A','B','C','D','E','F','G','H','I','J','K','L','M', */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+
+/*'N','O','P','Q','R','S','T','U','V','W','X','Y','Z' */
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+
+/*91 - 43 = 48 */
+/*48, 49, 50, 51, 52, 53 */
+ -1, -1, -1, -1, -1, -1,
+
+/*97 - 43 = 54*/
+/*'a','b','c','d','e','f','g','h','i','j','k','l','m' */
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+
+/*'n','o','p','q','r','s','t','u','v','w','x','y','z' */
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
+];
+
+/**
+ * Base64 encodes a 'binary' encoded string of bytes.
+ *
+ * @param input the binary encoded string of bytes to base64-encode.
+ * @param maxline the maximum number of encoded characters per line to use,
+ * defaults to none.
+ *
+ * @return the base64-encoded output.
+ */
+util.encode64 = function(input, maxline) {
+ // TODO: deprecate: "Deprecated. Use util.binary.base64.encode instead."
+ var line = '';
+ var output = '';
+ var chr1, chr2, chr3;
+ var i = 0;
+ while(i < input.length) {
+ chr1 = input.charCodeAt(i++);
+ chr2 = input.charCodeAt(i++);
+ chr3 = input.charCodeAt(i++);
+
+ // encode 4 character group
+ line += _base64.charAt(chr1 >> 2);
+ line += _base64.charAt(((chr1 & 3) << 4) | (chr2 >> 4));
+ if(isNaN(chr2)) {
+ line += '==';
+ } else {
+ line += _base64.charAt(((chr2 & 15) << 2) | (chr3 >> 6));
+ line += isNaN(chr3) ? '=' : _base64.charAt(chr3 & 63);
+ }
+
+ if(maxline && line.length > maxline) {
+ output += line.substr(0, maxline) + '\r\n';
+ line = line.substr(maxline);
+ }
+ }
+ output += line;
+ return output;
+};
+
+/**
+ * Base64 decodes a string into a 'binary' encoded string of bytes.
+ *
+ * @param input the base64-encoded input.
+ *
+ * @return the binary encoded string.
+ */
+util.decode64 = function(input) {
+ // TODO: deprecate: "Deprecated. Use util.binary.base64.decode instead."
+
+ // remove all non-base64 characters
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
+
+ var output = '';
+ var enc1, enc2, enc3, enc4;
+ var i = 0;
+
+ while(i < input.length) {
+ enc1 = _base64Idx[input.charCodeAt(i++) - 43];
+ enc2 = _base64Idx[input.charCodeAt(i++) - 43];
+ enc3 = _base64Idx[input.charCodeAt(i++) - 43];
+ enc4 = _base64Idx[input.charCodeAt(i++) - 43];
+
+ output += String.fromCharCode((enc1 << 2) | (enc2 >> 4));
+ if(enc3 !== 64) {
+ // decoded at least 2 bytes
+ output += String.fromCharCode(((enc2 & 15) << 4) | (enc3 >> 2));
+ if(enc4 !== 64) {
+ // decoded 3 bytes
+ output += String.fromCharCode(((enc3 & 3) << 6) | enc4);
+ }
+ }
+ }
+
+ return output;
+};
+
+/**
+ * UTF-8 encodes the given UTF-16 encoded string (a standard JavaScript
+ * string). Non-ASCII characters will be encoded as multiple bytes according
+ * to UTF-8.
+ *
+ * @param str the string to encode.
+ *
+ * @return the UTF-8 encoded string.
+ */
+util.encodeUtf8 = function(str) {
+ return unescape(encodeURIComponent(str));
+};
+
+/**
+ * Decodes a UTF-8 encoded string into a UTF-16 string.
+ *
+ * @param str the string to decode.
+ *
+ * @return the UTF-16 encoded string (standard JavaScript string).
+ */
+util.decodeUtf8 = function(str) {
+ return decodeURIComponent(escape(str));
+};
+
+// binary encoding/decoding tools
+// FIXME: Experimental. Do not use yet.
+util.binary = {
+ raw: {},
+ hex: {},
+ base64: {}
+};
+
+/**
+ * Encodes a Uint8Array as a binary-encoded string. This encoding uses
+ * a value between 0 and 255 for each character.
+ *
+ * @param bytes the Uint8Array to encode.
+ *
+ * @return the binary-encoded string.
+ */
+util.binary.raw.encode = function(bytes) {
+ return String.fromCharCode.apply(null, bytes);
+};
+
+/**
+ * Decodes a binary-encoded string to a Uint8Array. This encoding uses
+ * a value between 0 and 255 for each character.
+ *
+ * @param str the binary-encoded string to decode.
+ * @param [output] an optional Uint8Array to write the output to; if it
+ * is too small, an exception will be thrown.
+ * @param [offset] the start offset for writing to the output (default: 0).
+ *
+ * @return the Uint8Array or the number of bytes written if output was given.
+ */
+util.binary.raw.decode = function(str, output, offset) {
+ var out = output;
+ if(!out) {
+ out = new Uint8Array(str.length);
+ }
+ offset = offset || 0;
+ var j = offset;
+ for(var i = 0; i < str.length; ++i) {
+ out[j++] = str.charCodeAt(i);
+ }
+ return output ? (j - offset) : out;
+};
+
+/**
+ * Encodes a 'binary' string, ArrayBuffer, DataView, TypedArray, or
+ * ByteBuffer as a string of hexadecimal characters.
+ *
+ * @param bytes the bytes to convert.
+ *
+ * @return the string of hexadecimal characters.
+ */
+util.binary.hex.encode = util.bytesToHex;
+
+/**
+ * Decodes a hex-encoded string to a Uint8Array.
+ *
+ * @param hex the hexadecimal string to convert.
+ * @param [output] an optional Uint8Array to write the output to; if it
+ * is too small, an exception will be thrown.
+ * @param [offset] the start offset for writing to the output (default: 0).
+ *
+ * @return the Uint8Array or the number of bytes written if output was given.
+ */
+util.binary.hex.decode = function(hex, output, offset) {
+ var out = output;
+ if(!out) {
+ out = new Uint8Array(Math.ceil(hex.length / 2));
+ }
+ offset = offset || 0;
+ var i = 0, j = offset;
+ 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 output ? (j - offset) : out;
+};
+
+/**
+ * Base64-encodes a Uint8Array.
+ *
+ * @param input the Uint8Array to encode.
+ * @param maxline the maximum number of encoded characters per line to use,
+ * defaults to none.
+ *
+ * @return the base64-encoded output string.
+ */
+util.binary.base64.encode = function(input, maxline) {
+ var line = '';
+ var output = '';
+ var chr1, chr2, chr3;
+ var i = 0;
+ while(i < input.byteLength) {
+ chr1 = input[i++];
+ chr2 = input[i++];
+ chr3 = input[i++];
+
+ // encode 4 character group
+ line += _base64.charAt(chr1 >> 2);
+ line += _base64.charAt(((chr1 & 3) << 4) | (chr2 >> 4));
+ if(isNaN(chr2)) {
+ line += '==';
+ } else {
+ line += _base64.charAt(((chr2 & 15) << 2) | (chr3 >> 6));
+ line += isNaN(chr3) ? '=' : _base64.charAt(chr3 & 63);
+ }
+
+ if(maxline && line.length > maxline) {
+ output += line.substr(0, maxline) + '\r\n';
+ line = line.substr(maxline);
+ }
+ }
+ output += line;
+ return output;
+};
+
+/**
+ * Decodes a base64-encoded string to a Uint8Array.
+ *
+ * @param input the base64-encoded input string.
+ * @param [output] an optional Uint8Array to write the output to; if it
+ * is too small, an exception will be thrown.
+ * @param [offset] the start offset for writing to the output (default: 0).
+ *
+ * @return the Uint8Array or the number of bytes written if output was given.
+ */
+util.binary.base64.decode = function(input, output, offset) {
+ var out = output;
+ if(!out) {
+ out = new Uint8Array(Math.ceil(input.length / 4) * 3);
+ }
+
+ // remove all non-base64 characters
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
+
+ offset = offset || 0;
+ var enc1, enc2, enc3, enc4;
+ var i = 0, j = offset;
+
+ while(i < input.length) {
+ enc1 = _base64Idx[input.charCodeAt(i++) - 43];
+ enc2 = _base64Idx[input.charCodeAt(i++) - 43];
+ enc3 = _base64Idx[input.charCodeAt(i++) - 43];
+ enc4 = _base64Idx[input.charCodeAt(i++) - 43];
+
+ out[j++] = (enc1 << 2) | (enc2 >> 4);
+ if(enc3 !== 64) {
+ // decoded at least 2 bytes
+ out[j++] = ((enc2 & 15) << 4) | (enc3 >> 2);
+ if(enc4 !== 64) {
+ // decoded 3 bytes
+ out[j++] = ((enc3 & 3) << 6) | enc4;
+ }
+ }
+ }
+
+ // make sure result is the exact decoded length
+ return output ?
+ (j - offset) :
+ out.subarray(0, j);
+};
+
+// text encoding/decoding tools
+// FIXME: Experimental. Do not use yet.
+util.text = {
+ utf8: {},
+ utf16: {}
+};
+
+/**
+ * Encodes the given string as UTF-8 in a Uint8Array.
+ *
+ * @param str the string to encode.
+ * @param [output] an optional Uint8Array to write the output to; if it
+ * is too small, an exception will be thrown.
+ * @param [offset] the start offset for writing to the output (default: 0).
+ *
+ * @return the Uint8Array or the number of bytes written if output was given.
+ */
+util.text.utf8.encode = function(str, output, offset) {
+ str = util.encodeUtf8(str);
+ var out = output;
+ if(!out) {
+ out = new Uint8Array(str.length);
+ }
+ offset = offset || 0;
+ var j = offset;
+ for(var i = 0; i < str.length; ++i) {
+ out[j++] = str.charCodeAt(i);
+ }
+ return output ? (j - offset) : out;
+};
+
+/**
+ * Decodes the UTF-8 contents from a Uint8Array.
+ *
+ * @param bytes the Uint8Array to decode.
+ *
+ * @return the resulting string.
+ */
+util.text.utf8.decode = function(bytes) {
+ return util.decodeUtf8(String.fromCharCode.apply(null, bytes));
+};
+
+/**
+ * Encodes the given string as UTF-16 in a Uint8Array.
+ *
+ * @param str the string to encode.
+ * @param [output] an optional Uint8Array to write the output to; if it
+ * is too small, an exception will be thrown.
+ * @param [offset] the start offset for writing to the output (default: 0).
+ *
+ * @return the Uint8Array or the number of bytes written if output was given.
+ */
+util.text.utf16.encode = function(str, output, offset) {
+ var out = output;
+ if(!out) {
+ out = new Uint8Array(str.length);
+ }
+ var view = new Uint16Array(out);
+ offset = offset || 0;
+ var j = offset;
+ var k = offset;
+ for(var i = 0; i < str.length; ++i) {
+ view[k++] = str.charCodeAt(i);
+ j += 2;
+ }
+ return output ? (j - offset) : out;
+};
+
+/**
+ * Decodes the UTF-16 contents from a Uint8Array.
+ *
+ * @param bytes the Uint8Array to decode.
+ *
+ * @return the resulting string.
+ */
+util.text.utf16.decode = function(bytes) {
+ return String.fromCharCode.apply(null, new Uint16Array(bytes));
+};
+
+/**
+ * Deflates the given data using a flash interface.
+ *
+ * @param api the flash interface.
+ * @param bytes the data.
+ * @param raw true to return only raw deflate data, false to include zlib
+ * header and trailer.
+ *
+ * @return the deflated data as a string.
+ */
+util.deflate = function(api, bytes, raw) {
+ bytes = util.decode64(api.deflate(util.encode64(bytes)).rval);
+
+ // strip zlib header and trailer if necessary
+ if(raw) {
+ // zlib header is 2 bytes (CMF,FLG) where FLG indicates that
+ // there is a 4-byte DICT (alder-32) block before the data if
+ // its 5th bit is set
+ var start = 2;
+ var flg = bytes.charCodeAt(1);
+ if(flg & 0x20) {
+ start = 6;
+ }
+ // zlib trailer is 4 bytes of adler-32
+ bytes = bytes.substring(start, bytes.length - 4);
+ }
+
+ return bytes;
+};
+
+/**
+ * Inflates the given data using a flash interface.
+ *
+ * @param api the flash interface.
+ * @param bytes the data.
+ * @param raw true if the incoming data has no zlib header or trailer and is
+ * raw DEFLATE data.
+ *
+ * @return the inflated data as a string, null on error.
+ */
+util.inflate = function(api, bytes, raw) {
+ // TODO: add zlib header and trailer if necessary/possible
+ var rval = api.inflate(util.encode64(bytes)).rval;
+ return (rval === null) ? null : util.decode64(rval);
+};
+
+/**
+ * Sets a storage object.
+ *
+ * @param api the storage interface.
+ * @param id the storage ID to use.
+ * @param obj the storage object, null to remove.
+ */
+var _setStorageObject = function(api, id, obj) {
+ if(!api) {
+ throw new Error('WebStorage not available.');
+ }
+
+ var rval;
+ if(obj === null) {
+ rval = api.removeItem(id);
+ } else {
+ // json-encode and base64-encode object
+ obj = util.encode64(JSON.stringify(obj));
+ rval = api.setItem(id, obj);
+ }
+
+ // handle potential flash error
+ if(typeof(rval) !== 'undefined' && rval.rval !== true) {
+ var error = new Error(rval.error.message);
+ error.id = rval.error.id;
+ error.name = rval.error.name;
+ throw error;
+ }
+};
+
+/**
+ * Gets a storage object.
+ *
+ * @param api the storage interface.
+ * @param id the storage ID to use.
+ *
+ * @return the storage object entry or null if none exists.
+ */
+var _getStorageObject = function(api, id) {
+ if(!api) {
+ throw new Error('WebStorage not available.');
+ }
+
+ // get the existing entry
+ var rval = api.getItem(id);
+
+ /* Note: We check api.init because we can't do (api == localStorage)
+ on IE because of "Class doesn't support Automation" exception. Only
+ the flash api has an init method so this works too, but we need a
+ better solution in the future. */
+
+ // flash returns item wrapped in an object, handle special case
+ if(api.init) {
+ if(rval.rval === null) {
+ if(rval.error) {
+ var error = new Error(rval.error.message);
+ error.id = rval.error.id;
+ error.name = rval.error.name;
+ throw error;
+ }
+ // no error, but also no item
+ rval = null;
+ } else {
+ rval = rval.rval;
+ }
+ }
+
+ // handle decoding
+ if(rval !== null) {
+ // base64-decode and json-decode data
+ rval = JSON.parse(util.decode64(rval));
+ }
+
+ return rval;
+};
+
+/**
+ * Stores an item in local storage.
+ *
+ * @param api the storage interface.
+ * @param id the storage ID to use.
+ * @param key the key for the item.
+ * @param data the data for the item (any javascript object/primitive).
+ */
+var _setItem = function(api, id, key, data) {
+ // get storage object
+ var obj = _getStorageObject(api, id);
+ if(obj === null) {
+ // create a new storage object
+ obj = {};
+ }
+ // update key
+ obj[key] = data;
+
+ // set storage object
+ _setStorageObject(api, id, obj);
+};
+
+/**
+ * Gets an item from local storage.
+ *
+ * @param api the storage interface.
+ * @param id the storage ID to use.
+ * @param key the key for the item.
+ *
+ * @return the item.
+ */
+var _getItem = function(api, id, key) {
+ // get storage object
+ var rval = _getStorageObject(api, id);
+ if(rval !== null) {
+ // return data at key
+ rval = (key in rval) ? rval[key] : null;
+ }
+
+ return rval;
+};
+
+/**
+ * Removes an item from local storage.
+ *
+ * @param api the storage interface.
+ * @param id the storage ID to use.
+ * @param key the key for the item.
+ */
+var _removeItem = function(api, id, key) {
+ // get storage object
+ var obj = _getStorageObject(api, id);
+ if(obj !== null && key in obj) {
+ // remove key
+ delete obj[key];
+
+ // see if entry has no keys remaining
+ var empty = true;
+ for(var prop in obj) {
+ empty = false;
+ break;
+ }
+ if(empty) {
+ // remove entry entirely if no keys are left
+ obj = null;
+ }
+
+ // set storage object
+ _setStorageObject(api, id, obj);
+ }
+};
+
+/**
+ * Clears the local disk storage identified by the given ID.
+ *
+ * @param api the storage interface.
+ * @param id the storage ID to use.
+ */
+var _clearItems = function(api, id) {
+ _setStorageObject(api, id, null);
+};
+
+/**
+ * Calls a storage function.
+ *
+ * @param func the function to call.
+ * @param args the arguments for the function.
+ * @param location the location argument.
+ *
+ * @return the return value from the function.
+ */
+var _callStorageFunction = function(func, args, location) {
+ var rval = null;
+
+ // default storage types
+ if(typeof(location) === 'undefined') {
+ location = ['web', 'flash'];
+ }
+
+ // apply storage types in order of preference
+ var type;
+ var done = false;
+ var exception = null;
+ for(var idx in location) {
+ type = location[idx];
+ try {
+ if(type === 'flash' || type === 'both') {
+ if(args[0] === null) {
+ throw new Error('Flash local storage not available.');
+ }
+ rval = func.apply(this, args);
+ done = (type === 'flash');
+ }
+ if(type === 'web' || type === 'both') {
+ args[0] = localStorage;
+ rval = func.apply(this, args);
+ done = true;
+ }
+ } catch(ex) {
+ exception = ex;
+ }
+ if(done) {
+ break;
+ }
+ }
+
+ if(!done) {
+ throw exception;
+ }
+
+ return rval;
+};
+
+/**
+ * Stores an item on local disk.
+ *
+ * The available types of local storage include 'flash', 'web', and 'both'.
+ *
+ * The type 'flash' refers to flash local storage (SharedObject). In order
+ * to use flash local storage, the 'api' parameter must be valid. The type
+ * 'web' refers to WebStorage, if supported by the browser. The type 'both'
+ * refers to storing using both 'flash' and 'web', not just one or the
+ * other.
+ *
+ * The location array should list the storage types to use in order of
+ * preference:
+ *
+ * ['flash']: flash only storage
+ * ['web']: web only storage
+ * ['both']: try to store in both
+ * ['flash','web']: store in flash first, but if not available, 'web'
+ * ['web','flash']: store in web first, but if not available, 'flash'
+ *
+ * The location array defaults to: ['web', 'flash']
+ *
+ * @param api the flash interface, null to use only WebStorage.
+ * @param id the storage ID to use.
+ * @param key the key for the item.
+ * @param data the data for the item (any javascript object/primitive).
+ * @param location an array with the preferred types of storage to use.
+ */
+util.setItem = function(api, id, key, data, location) {
+ _callStorageFunction(_setItem, arguments, location);
+};
+
+/**
+ * Gets an item on local disk.
+ *
+ * Set setItem() for details on storage types.
+ *
+ * @param api the flash interface, null to use only WebStorage.
+ * @param id the storage ID to use.
+ * @param key the key for the item.
+ * @param location an array with the preferred types of storage to use.
+ *
+ * @return the item.
+ */
+util.getItem = function(api, id, key, location) {
+ return _callStorageFunction(_getItem, arguments, location);
+};
+
+/**
+ * Removes an item on local disk.
+ *
+ * Set setItem() for details on storage types.
+ *
+ * @param api the flash interface.
+ * @param id the storage ID to use.
+ * @param key the key for the item.
+ * @param location an array with the preferred types of storage to use.
+ */
+util.removeItem = function(api, id, key, location) {
+ _callStorageFunction(_removeItem, arguments, location);
+};
+
+/**
+ * Clears the local disk storage identified by the given ID.
+ *
+ * Set setItem() for details on storage types.
+ *
+ * @param api the flash interface if flash is available.
+ * @param id the storage ID to use.
+ * @param location an array with the preferred types of storage to use.
+ */
+util.clearItems = function(api, id, location) {
+ _callStorageFunction(_clearItems, arguments, location);
+};
+
+/**
+ * Parses the scheme, host, and port from an http(s) url.
+ *
+ * @param str the url string.
+ *
+ * @return the parsed url object or null if the url is invalid.
+ */
+util.parseUrl = function(str) {
+ // FIXME: this regex looks a bit broken
+ var regex = /^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;
+ regex.lastIndex = 0;
+ var m = regex.exec(str);
+ var url = (m === null) ? null : {
+ full: str,
+ scheme: m[1],
+ host: m[2],
+ port: m[3],
+ path: m[4]
+ };
+ if(url) {
+ url.fullHost = url.host;
+ if(url.port) {
+ if(url.port !== 80 && url.scheme === 'http') {
+ url.fullHost += ':' + url.port;
+ } else if(url.port !== 443 && url.scheme === 'https') {
+ url.fullHost += ':' + url.port;
+ }
+ } else if(url.scheme === 'http') {
+ url.port = 80;
+ } else if(url.scheme === 'https') {
+ url.port = 443;
+ }
+ url.full = url.scheme + '://' + url.fullHost;
+ }
+ return url;
+};
+
+/* Storage for query variables */
+var _queryVariables = null;
+
+/**
+ * Returns the window location query variables. Query is parsed on the first
+ * call and the same object is returned on subsequent calls. The mapping
+ * is from keys to an array of values. Parameters without values will have
+ * an object key set but no value added to the value array. Values are
+ * unescaped.
+ *
+ * ...?k1=v1&k2=v2:
+ * {
+ * "k1": ["v1"],
+ * "k2": ["v2"]
+ * }
+ *
+ * ...?k1=v1&k1=v2:
+ * {
+ * "k1": ["v1", "v2"]
+ * }
+ *
+ * ...?k1=v1&k2:
+ * {
+ * "k1": ["v1"],
+ * "k2": []
+ * }
+ *
+ * ...?k1=v1&k1:
+ * {
+ * "k1": ["v1"]
+ * }
+ *
+ * ...?k1&k1:
+ * {
+ * "k1": []
+ * }
+ *
+ * @param query the query string to parse (optional, default to cached
+ * results from parsing window location search query).
+ *
+ * @return object mapping keys to variables.
+ */
+util.getQueryVariables = function(query) {
+ var parse = function(q) {
+ var rval = {};
+ var kvpairs = q.split('&');
+ for(var i = 0; i < kvpairs.length; i++) {
+ var pos = kvpairs[i].indexOf('=');
+ var key;
+ var val;
+ if(pos > 0) {
+ key = kvpairs[i].substring(0, pos);
+ val = kvpairs[i].substring(pos + 1);
+ } else {
+ key = kvpairs[i];
+ val = null;
+ }
+ if(!(key in rval)) {
+ rval[key] = [];
+ }
+ // disallow overriding object prototype keys
+ if(!(key in Object.prototype) && val !== null) {
+ rval[key].push(unescape(val));
+ }
+ }
+ return rval;
+ };
+
+ var rval;
+ if(typeof(query) === 'undefined') {
+ // set cached variables if needed
+ if(_queryVariables === null) {
+ if(typeof(window) === 'undefined') {
+ // no query variables available
+ _queryVariables = {};
+ } else {
+ // parse window search query
+ _queryVariables = parse(window.location.search.substring(1));
+ }
+ }
+ rval = _queryVariables;
+ } else {
+ // parse given query
+ rval = parse(query);
+ }
+ return rval;
+};
+
+/**
+ * Parses a fragment into a path and query. This method will take a URI
+ * fragment and break it up as if it were the main URI. For example:
+ * /bar/baz?a=1&b=2
+ * results in:
+ * {
+ * path: ["bar", "baz"],
+ * query: {"k1": ["v1"], "k2": ["v2"]}
+ * }
+ *
+ * @return object with a path array and query object.
+ */
+util.parseFragment = function(fragment) {
+ // default to whole fragment
+ var fp = fragment;
+ var fq = '';
+ // split into path and query if possible at the first '?'
+ var pos = fragment.indexOf('?');
+ if(pos > 0) {
+ fp = fragment.substring(0, pos);
+ fq = fragment.substring(pos + 1);
+ }
+ // split path based on '/' and ignore first element if empty
+ var path = fp.split('/');
+ if(path.length > 0 && path[0] === '') {
+ path.shift();
+ }
+ // convert query into object
+ var query = (fq === '') ? {} : util.getQueryVariables(fq);
+
+ return {
+ pathString: fp,
+ queryString: fq,
+ path: path,
+ query: query
+ };
+};
+
+/**
+ * Makes a request out of a URI-like request string. This is intended to
+ * be used where a fragment id (after a URI '#') is parsed as a URI with
+ * path and query parts. The string should have a path beginning and
+ * delimited by '/' and optional query parameters following a '?'. The
+ * query should be a standard URL set of key value pairs delimited by
+ * '&'. For backwards compatibility the initial '/' on the path is not
+ * required. The request object has the following API, (fully described
+ * in the method code):
+ * {
+ * path: <the path string part>.
+ * query: <the query string part>,
+ * getPath(i): get part or all of the split path array,
+ * getQuery(k, i): get part or all of a query key array,
+ * getQueryLast(k, _default): get last element of a query key array.
+ * }
+ *
+ * @return object with request parameters.
+ */
+util.makeRequest = function(reqString) {
+ var frag = util.parseFragment(reqString);
+ var req = {
+ // full path string
+ path: frag.pathString,
+ // full query string
+ query: frag.queryString,
+ /**
+ * Get path or element in path.
+ *
+ * @param i optional path index.
+ *
+ * @return path or part of path if i provided.
+ */
+ getPath: function(i) {
+ return (typeof(i) === 'undefined') ? frag.path : frag.path[i];
+ },
+ /**
+ * Get query, values for a key, or value for a key index.
+ *
+ * @param k optional query key.
+ * @param i optional query key index.
+ *
+ * @return query, values for a key, or value for a key index.
+ */
+ getQuery: function(k, i) {
+ var rval;
+ if(typeof(k) === 'undefined') {
+ rval = frag.query;
+ } else {
+ rval = frag.query[k];
+ if(rval && typeof(i) !== 'undefined') {
+ rval = rval[i];
+ }
+ }
+ return rval;
+ },
+ getQueryLast: function(k, _default) {
+ var rval;
+ var vals = req.getQuery(k);
+ if(vals) {
+ rval = vals[vals.length - 1];
+ } else {
+ rval = _default;
+ }
+ return rval;
+ }
+ };
+ return req;
+};
+
+/**
+ * Makes a URI out of a path, an object with query parameters, and a
+ * fragment. Uses jQuery.param() internally for query string creation.
+ * If the path is an array, it will be joined with '/'.
+ *
+ * @param path string path or array of strings.
+ * @param query object with query parameters. (optional)
+ * @param fragment fragment string. (optional)
+ *
+ * @return string object with request parameters.
+ */
+util.makeLink = function(path, query, fragment) {
+ // join path parts if needed
+ path = jQuery.isArray(path) ? path.join('/') : path;
+
+ var qstr = jQuery.param(query || {});
+ fragment = fragment || '';
+ return path +
+ ((qstr.length > 0) ? ('?' + qstr) : '') +
+ ((fragment.length > 0) ? ('#' + fragment) : '');
+};
+
+/**
+ * Follows a path of keys deep into an object hierarchy and set a value.
+ * If a key does not exist or it's value is not an object, create an
+ * object in it's place. This can be destructive to a object tree if
+ * leaf nodes are given as non-final path keys.
+ * Used to avoid exceptions from missing parts of the path.
+ *
+ * @param object the starting object.
+ * @param keys an array of string keys.
+ * @param value the value to set.
+ */
+util.setPath = function(object, keys, value) {
+ // need to start at an object
+ if(typeof(object) === 'object' && object !== null) {
+ var i = 0;
+ var len = keys.length;
+ while(i < len) {
+ var next = keys[i++];
+ if(i == len) {
+ // last
+ object[next] = value;
+ } else {
+ // more
+ var hasNext = (next in object);
+ if(!hasNext ||
+ (hasNext && typeof(object[next]) !== 'object') ||
+ (hasNext && object[next] === null)) {
+ object[next] = {};
+ }
+ object = object[next];
+ }
+ }
+ }
+};
+
+/**
+ * Follows a path of keys deep into an object hierarchy and return a value.
+ * If a key does not exist, create an object in it's place.
+ * Used to avoid exceptions from missing parts of the path.
+ *
+ * @param object the starting object.
+ * @param keys an array of string keys.
+ * @param _default value to return if path not found.
+ *
+ * @return the value at the path if found, else default if given, else
+ * undefined.
+ */
+util.getPath = function(object, keys, _default) {
+ var i = 0;
+ var len = keys.length;
+ var hasNext = true;
+ while(hasNext && i < len &&
+ typeof(object) === 'object' && object !== null) {
+ var next = keys[i++];
+ hasNext = next in object;
+ if(hasNext) {
+ object = object[next];
+ }
+ }
+ return (hasNext ? object : _default);
+};
+
+/**
+ * Follow a path of keys deep into an object hierarchy and delete the
+ * last one. If a key does not exist, do nothing.
+ * Used to avoid exceptions from missing parts of the path.
+ *
+ * @param object the starting object.
+ * @param keys an array of string keys.
+ */
+util.deletePath = function(object, keys) {
+ // need to start at an object
+ if(typeof(object) === 'object' && object !== null) {
+ var i = 0;
+ var len = keys.length;
+ while(i < len) {
+ var next = keys[i++];
+ if(i == len) {
+ // last
+ delete object[next];
+ } else {
+ // more
+ if(!(next in object) ||
+ (typeof(object[next]) !== 'object') ||
+ (object[next] === null)) {
+ break;
+ }
+ object = object[next];
+ }
+ }
+ }
+};
+
+/**
+ * Check if an object is empty.
+ *
+ * Taken from:
+ * http://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object-from-json/679937#679937
+ *
+ * @param object the object to check.
+ */
+util.isEmpty = function(obj) {
+ for(var prop in obj) {
+ if(obj.hasOwnProperty(prop)) {
+ return false;
+ }
+ }
+ return true;
+};
+
+/**
+ * Format with simple printf-style interpolation.
+ *
+ * %%: literal '%'
+ * %s,%o: convert next argument into a string.
+ *
+ * @param format the string to format.
+ * @param ... arguments to interpolate into the format string.
+ */
+util.format = function(format) {
+ var re = /%./g;
+ // current match
+ var match;
+ // current part
+ var part;
+ // current arg index
+ var argi = 0;
+ // collected parts to recombine later
+ var parts = [];
+ // last index found
+ var last = 0;
+ // loop while matches remain
+ while((match = re.exec(format))) {
+ part = format.substring(last, re.lastIndex - 2);
+ // don't add empty strings (ie, parts between %s%s)
+ if(part.length > 0) {
+ parts.push(part);
+ }
+ last = re.lastIndex;
+ // switch on % code
+ var code = match[0][1];
+ switch(code) {
+ case 's':
+ case 'o':
+ // check if enough arguments were given
+ if(argi < arguments.length) {
+ parts.push(arguments[argi++ + 1]);
+ } else {
+ parts.push('<?>');
+ }
+ break;
+ // FIXME: do proper formating for numbers, etc
+ //case 'f':
+ //case 'd':
+ case '%':
+ parts.push('%');
+ break;
+ default:
+ parts.push('<%' + code + '?>');
+ }
+ }
+ // add trailing part of format string
+ parts.push(format.substring(last));
+ return parts.join('');
+};
+
+/**
+ * Formats a number.
+ *
+ * http://snipplr.com/view/5945/javascript-numberformat--ported-from-php/
+ */
+util.formatNumber = function(number, decimals, dec_point, thousands_sep) {
+ // http://kevin.vanzonneveld.net
+ // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
+ // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + bugfix by: Michael White (http://crestidg.com)
+ // + bugfix by: Benjamin Lupton
+ // + bugfix by: Allan Jensen (http://www.winternet.no)
+ // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
+ // * example 1: number_format(1234.5678, 2, '.', '');
+ // * returns 1: 1234.57
+
+ var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
+ var d = dec_point === undefined ? ',' : dec_point;
+ var t = thousands_sep === undefined ?
+ '.' : thousands_sep, s = n < 0 ? '-' : '';
+ var i = parseInt((n = Math.abs(+n || 0).toFixed(c)), 10) + '';
+ var j = (i.length > 3) ? i.length % 3 : 0;
+ return s + (j ? i.substr(0, j) + t : '') +
+ i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + t) +
+ (c ? d + Math.abs(n - i).toFixed(c).slice(2) : '');
+};
+
+/**
+ * Formats a byte size.
+ *
+ * http://snipplr.com/view/5949/format-humanize-file-byte-size-presentation-in-javascript/
+ */
+util.formatSize = function(size) {
+ if(size >= 1073741824) {
+ size = util.formatNumber(size / 1073741824, 2, '.', '') + ' GiB';
+ } else if(size >= 1048576) {
+ size = util.formatNumber(size / 1048576, 2, '.', '') + ' MiB';
+ } else if(size >= 1024) {
+ size = util.formatNumber(size / 1024, 0) + ' KiB';
+ } else {
+ size = util.formatNumber(size, 0) + ' bytes';
+ }
+ return size;
+};
+
+/**
+ * Converts an IPv4 or IPv6 string representation into bytes (in network order).
+ *
+ * @param ip the IPv4 or IPv6 address to convert.
+ *
+ * @return the 4-byte IPv6 or 16-byte IPv6 address or null if the address can't
+ * be parsed.
+ */
+util.bytesFromIP = function(ip) {
+ if(ip.indexOf('.') !== -1) {
+ return util.bytesFromIPv4(ip);
+ }
+ if(ip.indexOf(':') !== -1) {
+ return util.bytesFromIPv6(ip);
+ }
+ return null;
+};
+
+/**
+ * Converts an IPv4 string representation into bytes (in network order).
+ *
+ * @param ip the IPv4 address to convert.
+ *
+ * @return the 4-byte address or null if the address can't be parsed.
+ */
+util.bytesFromIPv4 = function(ip) {
+ ip = ip.split('.');
+ if(ip.length !== 4) {
+ return null;
+ }
+ var b = util.createBuffer();
+ for(var i = 0; i < ip.length; ++i) {
+ var num = parseInt(ip[i], 10);
+ if(isNaN(num)) {
+ return null;
+ }
+ b.putByte(num);
+ }
+ return b.getBytes();
+};
+
+/**
+ * Converts an IPv6 string representation into bytes (in network order).
+ *
+ * @param ip the IPv6 address to convert.
+ *
+ * @return the 16-byte address or null if the address can't be parsed.
+ */
+util.bytesFromIPv6 = function(ip) {
+ var blanks = 0;
+ ip = ip.split(':').filter(function(e) {
+ if(e.length === 0) ++blanks;
+ return true;
+ });
+ var zeros = (8 - ip.length + blanks) * 2;
+ var b = util.createBuffer();
+ for(var i = 0; i < 8; ++i) {
+ if(!ip[i] || ip[i].length === 0) {
+ b.fillWithByte(0, zeros);
+ zeros = 0;
+ continue;
+ }
+ var bytes = util.hexToBytes(ip[i]);
+ if(bytes.length < 2) {
+ b.putByte(0);
+ }
+ b.putBytes(bytes);
+ }
+ return b.getBytes();
+};
+
+/**
+ * Converts 4-bytes into an IPv4 string representation or 16-bytes into
+ * an IPv6 string representation. The bytes must be in network order.
+ *
+ * @param bytes the bytes to convert.
+ *
+ * @return the IPv4 or IPv6 string representation if 4 or 16 bytes,
+ * respectively, are given, otherwise null.
+ */
+util.bytesToIP = function(bytes) {
+ if(bytes.length === 4) {
+ return util.bytesToIPv4(bytes);
+ }
+ if(bytes.length === 16) {
+ return util.bytesToIPv6(bytes);
+ }
+ return null;
+};
+
+/**
+ * Converts 4-bytes into an IPv4 string representation. The bytes must be
+ * in network order.
+ *
+ * @param bytes the bytes to convert.
+ *
+ * @return the IPv4 string representation or null for an invalid # of bytes.
+ */
+util.bytesToIPv4 = function(bytes) {
+ if(bytes.length !== 4) {
+ return null;
+ }
+ var ip = [];
+ for(var i = 0; i < bytes.length; ++i) {
+ ip.push(bytes.charCodeAt(i));
+ }
+ return ip.join('.');
+};
+
+/**
+ * Converts 16-bytes into an IPv16 string representation. The bytes must be
+ * in network order.
+ *
+ * @param bytes the bytes to convert.
+ *
+ * @return the IPv16 string representation or null for an invalid # of bytes.
+ */
+util.bytesToIPv6 = function(bytes) {
+ if(bytes.length !== 16) {
+ return null;
+ }
+ var ip = [];
+ var zeroGroups = [];
+ var zeroMaxGroup = 0;
+ for(var i = 0; i < bytes.length; i += 2) {
+ var hex = util.bytesToHex(bytes[i] + bytes[i + 1]);
+ // canonicalize zero representation
+ while(hex[0] === '0' && hex !== '0') {
+ hex = hex.substr(1);
+ }
+ if(hex === '0') {
+ var last = zeroGroups[zeroGroups.length - 1];
+ var idx = ip.length;
+ if(!last || idx !== last.end + 1) {
+ zeroGroups.push({start: idx, end: idx});
+ } else {
+ last.end = idx;
+ if((last.end - last.start) >
+ (zeroGroups[zeroMaxGroup].end - zeroGroups[zeroMaxGroup].start)) {
+ zeroMaxGroup = zeroGroups.length - 1;
+ }
+ }
+ }
+ ip.push(hex);
+ }
+ if(zeroGroups.length > 0) {
+ var group = zeroGroups[zeroMaxGroup];
+ // only shorten group of length > 0
+ if(group.end - group.start > 0) {
+ ip.splice(group.start, group.end - group.start + 1, '');
+ if(group.start === 0) {
+ ip.unshift('');
+ }
+ if(group.end === 7) {
+ ip.push('');
+ }
+ }
+ }
+ return ip.join(':');
+};
+
+/**
+ * Estimates the number of processes that can be run concurrently. If
+ * creating Web Workers, keep in mind that the main JavaScript process needs
+ * its own core.
+ *
+ * @param options the options to use:
+ * update true to force an update (not use the cached value).
+ * @param callback(err, max) called once the operation completes.
+ */
+util.estimateCores = function(options, callback) {
+ if(typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+ if('cores' in util && !options.update) {
+ return callback(null, util.cores);
+ }
+ if(typeof navigator !== 'undefined' &&
+ 'hardwareConcurrency' in navigator &&
+ navigator.hardwareConcurrency > 0) {
+ util.cores = navigator.hardwareConcurrency;
+ return callback(null, util.cores);
+ }
+ if(typeof Worker === 'undefined') {
+ // workers not available
+ util.cores = 1;
+ return callback(null, util.cores);
+ }
+ if(typeof Blob === 'undefined') {
+ // can't estimate, default to 2
+ util.cores = 2;
+ return callback(null, util.cores);
+ }
+
+ // create worker concurrency estimation code as blob
+ var blobUrl = URL.createObjectURL(new Blob(['(',
+ function() {
+ self.addEventListener('message', function(e) {
+ // run worker for 4 ms
+ var st = Date.now();
+ var et = st + 4;
+ while(Date.now() < et);
+ self.postMessage({st: st, et: et});
+ });
+ }.toString(),
+ ')()'], {type: 'application/javascript'}));
+
+ // take 5 samples using 16 workers
+ sample([], 5, 16);
+
+ function sample(max, samples, numWorkers) {
+ if(samples === 0) {
+ // get overlap average
+ var avg = Math.floor(max.reduce(function(avg, x) {
+ return avg + x;
+ }, 0) / max.length);
+ util.cores = Math.max(1, avg);
+ URL.revokeObjectURL(blobUrl);
+ return callback(null, util.cores);
+ }
+ map(numWorkers, function(err, results) {
+ max.push(reduce(numWorkers, results));
+ sample(max, samples - 1, numWorkers);
+ });
+ }
+
+ function map(numWorkers, callback) {
+ var workers = [];
+ var results = [];
+ for(var i = 0; i < numWorkers; ++i) {
+ var worker = new Worker(blobUrl);
+ worker.addEventListener('message', function(e) {
+ results.push(e.data);
+ if(results.length === numWorkers) {
+ for(var i = 0; i < numWorkers; ++i) {
+ workers[i].terminate();
+ }
+ callback(null, results);
+ }
+ });
+ workers.push(worker);
+ }
+ for(var i = 0; i < numWorkers; ++i) {
+ workers[i].postMessage(i);
+ }
+ }
+
+ function reduce(numWorkers, results) {
+ // find overlapping time windows
+ var overlaps = [];
+ for(var n = 0; n < numWorkers; ++n) {
+ var r1 = results[n];
+ var overlap = overlaps[n] = [];
+ for(var i = 0; i < numWorkers; ++i) {
+ if(n === i) {
+ continue;
+ }
+ var r2 = results[i];
+ if((r1.st > r2.st && r1.st < r2.et) ||
+ (r2.st > r1.st && r2.st < r1.et)) {
+ overlap.push(i);
+ }
+ }
+ }
+ // get maximum overlaps ... don't include overlapping worker itself
+ // as the main JS process was also being scheduled during the work and
+ // would have to be subtracted from the estimate anyway
+ return overlaps.reduce(function(max, overlap) {
+ return Math.max(max, overlap.length);
+ }, 0);
+ }
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'util';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[11/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pki.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pki.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pki.js
new file mode 100644
index 0000000..3df7805
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pki.js
@@ -0,0 +1,161 @@
+/**
+ * Javascript implementation of a basic Public Key Infrastructure, including
+ * support for RSA public and private keys.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2013 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// shortcut for asn.1 API
+var asn1 = forge.asn1;
+
+/* Public Key Infrastructure (PKI) implementation. */
+var pki = forge.pki = forge.pki || {};
+
+/**
+ * NOTE: THIS METHOD IS DEPRECATED. Use pem.decode() instead.
+ *
+ * Converts PEM-formatted data to DER.
+ *
+ * @param pem the PEM-formatted data.
+ *
+ * @return the DER-formatted data.
+ */
+pki.pemToDer = function(pem) {
+ var msg = forge.pem.decode(pem)[0];
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
+ throw new Error('Could not convert PEM to DER; PEM is encrypted.');
+ }
+ return forge.util.createBuffer(msg.body);
+};
+
+/**
+ * Converts an RSA private key from PEM format.
+ *
+ * @param pem the PEM-formatted private key.
+ *
+ * @return the private key.
+ */
+pki.privateKeyFromPem = function(pem) {
+ var msg = forge.pem.decode(pem)[0];
+
+ if(msg.type !== 'PRIVATE KEY' && msg.type !== 'RSA PRIVATE KEY') {
+ var error = new Error('Could not convert private key from PEM; PEM ' +
+ 'header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');
+ error.headerType = msg.type;
+ throw error;
+ }
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
+ throw new Error('Could not convert private key from PEM; PEM is encrypted.');
+ }
+
+ // convert DER to ASN.1 object
+ var obj = asn1.fromDer(msg.body);
+
+ return pki.privateKeyFromAsn1(obj);
+};
+
+/**
+ * Converts an RSA private key to PEM format.
+ *
+ * @param key the private key.
+ * @param maxline the maximum characters per line, defaults to 64.
+ *
+ * @return the PEM-formatted private key.
+ */
+pki.privateKeyToPem = function(key, maxline) {
+ // convert to ASN.1, then DER, then PEM-encode
+ var msg = {
+ type: 'RSA PRIVATE KEY',
+ body: asn1.toDer(pki.privateKeyToAsn1(key)).getBytes()
+ };
+ return forge.pem.encode(msg, {maxline: maxline});
+};
+
+/**
+ * Converts a PrivateKeyInfo to PEM format.
+ *
+ * @param pki the PrivateKeyInfo.
+ * @param maxline the maximum characters per line, defaults to 64.
+ *
+ * @return the PEM-formatted private key.
+ */
+pki.privateKeyInfoToPem = function(pki, maxline) {
+ // convert to DER, then PEM-encode
+ var msg = {
+ type: 'PRIVATE KEY',
+ body: asn1.toDer(pki).getBytes()
+ };
+ return forge.pem.encode(msg, {maxline: maxline});
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'pki';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define([
+ 'require',
+ 'module',
+ './asn1',
+ './oids',
+ './pbe',
+ './pem',
+ './pbkdf2',
+ './pkcs12',
+ './pss',
+ './rsa',
+ './util',
+ './x509'
+], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prime.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prime.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prime.js
new file mode 100644
index 0000000..2857c36
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prime.js
@@ -0,0 +1,337 @@
+/**
+ * Prime number generation API.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// forge.prime already defined
+if(forge.prime) {
+ return;
+}
+
+/* PRIME API */
+var prime = forge.prime = forge.prime || {};
+
+var BigInteger = forge.jsbn.BigInteger;
+
+// primes are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29
+var GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];
+var THIRTY = new BigInteger(null);
+THIRTY.fromInt(30);
+var op_or = function(x, y) {return x|y;};
+
+/**
+ * Generates a random probable prime with the given number of bits.
+ *
+ * Alternative algorithms can be specified by name as a string or as an
+ * object with custom options like so:
+ *
+ * {
+ * name: 'PRIMEINC',
+ * options: {
+ * maxBlockTime: <the maximum amount of time to block the main
+ * thread before allowing I/O other JS to run>,
+ * millerRabinTests: <the number of miller-rabin tests to run>,
+ * workerScript: <the worker script URL>,
+ * workers: <the number of web workers (if supported) to use,
+ * -1 to use estimated cores minus one>.
+ * workLoad: the size of the work load, ie: number of possible prime
+ * numbers for each web worker to check per work assignment,
+ * (default: 100).
+ * }
+ * }
+ *
+ * @param bits the number of bits for the prime number.
+ * @param options the options to use.
+ * [algorithm] the algorithm to use (default: 'PRIMEINC').
+ * [prng] a custom crypto-secure pseudo-random number generator to use,
+ * that must define "getBytesSync".
+ *
+ * @return callback(err, num) called once the operation completes.
+ */
+prime.generateProbablePrime = function(bits, options, callback) {
+ if(typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+
+ // default to PRIMEINC algorithm
+ var algorithm = options.algorithm || 'PRIMEINC';
+ if(typeof algorithm === 'string') {
+ algorithm = {name: algorithm};
+ }
+ algorithm.options = algorithm.options || {};
+
+ // create prng with api that matches BigInteger secure random
+ var prng = options.prng || forge.random;
+ var rng = {
+ // x is an array to fill with bytes
+ nextBytes: function(x) {
+ var b = prng.getBytesSync(x.length);
+ for(var i = 0; i < x.length; ++i) {
+ x[i] = b.charCodeAt(i);
+ }
+ }
+ };
+
+ if(algorithm.name === 'PRIMEINC') {
+ return primeincFindPrime(bits, rng, algorithm.options, callback);
+ }
+
+ throw new Error('Invalid prime generation algorithm: ' + algorithm.name);
+};
+
+function primeincFindPrime(bits, rng, options, callback) {
+ if('workers' in options) {
+ return primeincFindPrimeWithWorkers(bits, rng, options, callback);
+ }
+ return primeincFindPrimeWithoutWorkers(bits, rng, options, callback);
+}
+
+function primeincFindPrimeWithoutWorkers(bits, rng, options, callback) {
+ // initialize random number
+ var num = generateRandom(bits, rng);
+
+ /* Note: All primes are of the form 30k+i for i < 30 and gcd(30, i)=1. The
+ number we are given is always aligned at 30k + 1. Each time the number is
+ determined not to be prime we add to get to the next 'i', eg: if the number
+ was at 30k + 1 we add 6. */
+ var deltaIdx = 0;
+
+ // get required number of MR tests
+ var mrTests = getMillerRabinTests(num.bitLength());
+ if('millerRabinTests' in options) {
+ mrTests = options.millerRabinTests;
+ }
+
+ // find prime nearest to 'num' for maxBlockTime ms
+ // 10 ms gives 5ms of leeway for other calculations before dropping
+ // below 60fps (1000/60 == 16.67), but in reality, the number will
+ // likely be higher due to an 'atomic' big int modPow
+ var maxBlockTime = 10;
+ if('maxBlockTime' in options) {
+ maxBlockTime = options.maxBlockTime;
+ }
+ var start = +new Date();
+ do {
+ // overflow, regenerate random number
+ if(num.bitLength() > bits) {
+ num = generateRandom(bits, rng);
+ }
+ // do primality test
+ if(num.isProbablePrime(mrTests)) {
+ return callback(null, num);
+ }
+ // get next potential prime
+ num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);
+ } while(maxBlockTime < 0 || (+new Date() - start < maxBlockTime));
+
+ // keep trying (setImmediate would be better here)
+ forge.util.setImmediate(function() {
+ primeincFindPrimeWithoutWorkers(bits, rng, options, callback);
+ });
+}
+
+function primeincFindPrimeWithWorkers(bits, rng, options, callback) {
+ // web workers unavailable
+ if(typeof Worker === 'undefined') {
+ return primeincFindPrimeWithoutWorkers(bits, rng, options, callback);
+ }
+
+ // initialize random number
+ var num = generateRandom(bits, rng);
+
+ // use web workers to generate keys
+ var numWorkers = options.workers;
+ var workLoad = options.workLoad || 100;
+ var range = workLoad * 30 / 8;
+ var workerScript = options.workerScript || 'forge/prime.worker.js';
+ if(numWorkers === -1) {
+ return forge.util.estimateCores(function(err, cores) {
+ if(err) {
+ // default to 2
+ cores = 2;
+ }
+ numWorkers = cores - 1;
+ generate();
+ });
+ }
+ generate();
+
+ function generate() {
+ // require at least 1 worker
+ numWorkers = Math.max(1, numWorkers);
+
+ // TODO: consider optimizing by starting workers outside getPrime() ...
+ // note that in order to clean up they will have to be made internally
+ // asynchronous which may actually be slower
+
+ // start workers immediately
+ var workers = [];
+ for(var i = 0; i < numWorkers; ++i) {
+ // FIXME: fix path or use blob URLs
+ workers[i] = new Worker(workerScript);
+ }
+ var running = numWorkers;
+
+ // listen for requests from workers and assign ranges to find prime
+ for(var i = 0; i < numWorkers; ++i) {
+ workers[i].addEventListener('message', workerMessage);
+ }
+
+ /* Note: The distribution of random numbers is unknown. Therefore, each
+ web worker is continuously allocated a range of numbers to check for a
+ random number until one is found.
+
+ Every 30 numbers will be checked just 8 times, because prime numbers
+ have the form:
+
+ 30k+i, for i < 30 and gcd(30, i)=1 (there are 8 values of i for this)
+
+ Therefore, if we want a web worker to run N checks before asking for
+ a new range of numbers, each range must contain N*30/8 numbers.
+
+ For 100 checks (workLoad), this is a range of 375. */
+
+ var found = false;
+ function workerMessage(e) {
+ // ignore message, prime already found
+ if(found) {
+ return;
+ }
+
+ --running;
+ var data = e.data;
+ if(data.found) {
+ // terminate all workers
+ for(var i = 0; i < workers.length; ++i) {
+ workers[i].terminate();
+ }
+ found = true;
+ return callback(null, new BigInteger(data.prime, 16));
+ }
+
+ // overflow, regenerate random number
+ if(num.bitLength() > bits) {
+ num = generateRandom(bits, rng);
+ }
+
+ // assign new range to check
+ var hex = num.toString(16);
+
+ // start prime search
+ e.target.postMessage({
+ hex: hex,
+ workLoad: workLoad
+ });
+
+ num.dAddOffset(range, 0);
+ }
+ }
+}
+
+/**
+ * Generates a random number using the given number of bits and RNG.
+ *
+ * @param bits the number of bits for the number.
+ * @param rng the random number generator to use.
+ *
+ * @return the random number.
+ */
+function generateRandom(bits, rng) {
+ var num = new BigInteger(bits, rng);
+ // force MSB set
+ var bits1 = bits - 1;
+ if(!num.testBit(bits1)) {
+ num.bitwiseTo(BigInteger.ONE.shiftLeft(bits1), op_or, num);
+ }
+ // align number on 30k+1 boundary
+ num.dAddOffset(31 - num.mod(THIRTY).byteValue(), 0);
+ return num;
+}
+
+/**
+ * Returns the required number of Miller-Rabin tests to generate a
+ * prime with an error probability of (1/2)^80.
+ *
+ * See Handbook of Applied Cryptography Chapter 4, Table 4.4.
+ *
+ * @param bits the bit size.
+ *
+ * @return the required number of iterations.
+ */
+function getMillerRabinTests(bits) {
+ if(bits <= 100) return 27;
+ if(bits <= 150) return 18;
+ if(bits <= 200) return 15;
+ if(bits <= 250) return 12;
+ if(bits <= 300) return 9;
+ if(bits <= 350) return 8;
+ if(bits <= 400) return 7;
+ if(bits <= 500) return 6;
+ if(bits <= 600) return 5;
+ if(bits <= 800) return 4;
+ if(bits <= 1250) return 3;
+ return 2;
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'prime';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util', './jsbn', './random'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prime.worker.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prime.worker.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prime.worker.js
new file mode 100644
index 0000000..5fdaa7f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prime.worker.js
@@ -0,0 +1,165 @@
+/**
+ * RSA Key Generation Worker.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2013 Digital Bazaar, Inc.
+ */
+importScripts('jsbn.js');
+
+// prime constants
+var LOW_PRIMES = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
+var LP_LIMIT = (1 << 26) / LOW_PRIMES[LOW_PRIMES.length - 1];
+
+var BigInteger = forge.jsbn.BigInteger;
+var BIG_TWO = new BigInteger(null);
+BIG_TWO.fromInt(2);
+
+self.addEventListener('message', function(e) {
+ var result = findPrime(e.data);
+ self.postMessage(result);
+});
+
+// start receiving ranges to check
+self.postMessage({found: false});
+
+// primes are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29
+var GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];
+
+function findPrime(data) {
+ // TODO: abstract based on data.algorithm (PRIMEINC vs. others)
+
+ // create BigInteger from given random bytes
+ var num = new BigInteger(data.hex, 16);
+
+ /* Note: All primes are of the form 30k+i for i < 30 and gcd(30, i)=1. The
+ number we are given is always aligned at 30k + 1. Each time the number is
+ determined not to be prime we add to get to the next 'i', eg: if the number
+ was at 30k + 1 we add 6. */
+ var deltaIdx = 0;
+
+ // find nearest prime
+ var workLoad = data.workLoad;
+ for(var i = 0; i < workLoad; ++i) {
+ // do primality test
+ if(isProbablePrime(num)) {
+ return {found: true, prime: num.toString(16)};
+ }
+ // get next potential prime
+ num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);
+ }
+
+ return {found: false};
+}
+
+function isProbablePrime(n) {
+ // divide by low primes, ignore even checks, etc (n alread aligned properly)
+ var i = 1;
+ while(i < LOW_PRIMES.length) {
+ var m = LOW_PRIMES[i];
+ var j = i + 1;
+ while(j < LOW_PRIMES.length && m < LP_LIMIT) {
+ m *= LOW_PRIMES[j++];
+ }
+ m = n.modInt(m);
+ while(i < j) {
+ if(m % LOW_PRIMES[i++] === 0) {
+ return false;
+ }
+ }
+ }
+ return runMillerRabin(n);
+}
+
+// HAC 4.24, Miller-Rabin
+function runMillerRabin(n) {
+ // n1 = n - 1
+ var n1 = n.subtract(BigInteger.ONE);
+
+ // get s and d such that n1 = 2^s * d
+ var s = n1.getLowestSetBit();
+ if(s <= 0) {
+ return false;
+ }
+ var d = n1.shiftRight(s);
+
+ var k = _getMillerRabinTests(n.bitLength());
+ var prng = getPrng();
+ var a;
+ for(var i = 0; i < k; ++i) {
+ // select witness 'a' at random from between 1 and n - 1
+ do {
+ a = new BigInteger(n.bitLength(), prng);
+ } while(a.compareTo(BigInteger.ONE) <= 0 || a.compareTo(n1) >= 0);
+
+ /* See if 'a' is a composite witness. */
+
+ // x = a^d mod n
+ var x = a.modPow(d, n);
+
+ // probably prime
+ if(x.compareTo(BigInteger.ONE) === 0 || x.compareTo(n1) === 0) {
+ continue;
+ }
+
+ var j = s;
+ while(--j) {
+ // x = x^2 mod a
+ x = x.modPowInt(2, n);
+
+ // 'n' is composite because no previous x == -1 mod n
+ if(x.compareTo(BigInteger.ONE) === 0) {
+ return false;
+ }
+ // x == -1 mod n, so probably prime
+ if(x.compareTo(n1) === 0) {
+ break;
+ }
+ }
+
+ // 'x' is first_x^(n1/2) and is not +/- 1, so 'n' is not prime
+ if(j === 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+// get pseudo random number generator
+function getPrng() {
+ // create prng with api that matches BigInteger secure random
+ return {
+ // x is an array to fill with bytes
+ nextBytes: function(x) {
+ for(var i = 0; i < x.length; ++i) {
+ x[i] = Math.floor(Math.random() * 0xFF);
+ }
+ }
+ };
+}
+
+/**
+ * Returns the required number of Miller-Rabin tests to generate a
+ * prime with an error probability of (1/2)^80.
+ *
+ * See Handbook of Applied Cryptography Chapter 4, Table 4.4.
+ *
+ * @param bits the bit size.
+ *
+ * @return the required number of iterations.
+ */
+function _getMillerRabinTests(bits) {
+ if(bits <= 100) return 27;
+ if(bits <= 150) return 18;
+ if(bits <= 200) return 15;
+ if(bits <= 250) return 12;
+ if(bits <= 300) return 9;
+ if(bits <= 350) return 8;
+ if(bits <= 400) return 7;
+ if(bits <= 500) return 6;
+ if(bits <= 600) return 5;
+ if(bits <= 800) return 4;
+ if(bits <= 1250) return 3;
+ return 2;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prng.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prng.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prng.js
new file mode 100644
index 0000000..72b4594
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/prng.js
@@ -0,0 +1,458 @@
+/**
+ * A javascript implementation of a cryptographically-secure
+ * Pseudo Random Number Generator (PRNG). The Fortuna algorithm is followed
+ * here though the use of SHA-256 is not enforced; when generating an
+ * a PRNG context, the hashing algorithm and block cipher used for
+ * the generator are specified via a plugin.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+var _nodejs = (
+ typeof process !== 'undefined' && process.versions && process.versions.node);
+var _crypto = null;
+if(!forge.disableNativeCode && _nodejs && !process.versions['node-webkit']) {
+ _crypto = require('crypto');
+}
+
+/* PRNG API */
+var prng = forge.prng = forge.prng || {};
+
+/**
+ * Creates a new PRNG context.
+ *
+ * A PRNG plugin must be passed in that will provide:
+ *
+ * 1. A function that initializes the key and seed of a PRNG context. It
+ * will be given a 16 byte key and a 16 byte seed. Any key expansion
+ * or transformation of the seed from a byte string into an array of
+ * integers (or similar) should be performed.
+ * 2. The cryptographic function used by the generator. It takes a key and
+ * a seed.
+ * 3. A seed increment function. It takes the seed and returns seed + 1.
+ * 4. An api to create a message digest.
+ *
+ * For an example, see random.js.
+ *
+ * @param plugin the PRNG plugin to use.
+ */
+prng.create = function(plugin) {
+ var ctx = {
+ plugin: plugin,
+ key: null,
+ seed: null,
+ time: null,
+ // number of reseeds so far
+ reseeds: 0,
+ // amount of data generated so far
+ generated: 0
+ };
+
+ // create 32 entropy pools (each is a message digest)
+ var md = plugin.md;
+ var pools = new Array(32);
+ for(var i = 0; i < 32; ++i) {
+ pools[i] = md.create();
+ }
+ ctx.pools = pools;
+
+ // entropy pools are written to cyclically, starting at index 0
+ ctx.pool = 0;
+
+ /**
+ * Generates random bytes. The bytes may be generated synchronously or
+ * asynchronously. Web workers must use the asynchronous interface or
+ * else the behavior is undefined.
+ *
+ * @param count the number of random bytes to generate.
+ * @param [callback(err, bytes)] called once the operation completes.
+ *
+ * @return count random bytes as a string.
+ */
+ ctx.generate = function(count, callback) {
+ // do synchronously
+ if(!callback) {
+ return ctx.generateSync(count);
+ }
+
+ // simple generator using counter-based CBC
+ var cipher = ctx.plugin.cipher;
+ var increment = ctx.plugin.increment;
+ var formatKey = ctx.plugin.formatKey;
+ var formatSeed = ctx.plugin.formatSeed;
+ var b = forge.util.createBuffer();
+
+ // reset key for every request
+ ctx.key = null;
+
+ generate();
+
+ function generate(err) {
+ if(err) {
+ return callback(err);
+ }
+
+ // sufficient bytes generated
+ if(b.length() >= count) {
+ return callback(null, b.getBytes(count));
+ }
+
+ // if amount of data generated is greater than 1 MiB, trigger reseed
+ if(ctx.generated > 0xfffff) {
+ ctx.key = null;
+ }
+
+ if(ctx.key === null) {
+ // prevent stack overflow
+ return forge.util.nextTick(function() {
+ _reseed(generate);
+ });
+ }
+
+ // generate the random bytes
+ var bytes = cipher(ctx.key, ctx.seed);
+ ctx.generated += bytes.length;
+ b.putBytes(bytes);
+
+ // generate bytes for a new key and seed
+ ctx.key = formatKey(cipher(ctx.key, increment(ctx.seed)));
+ ctx.seed = formatSeed(cipher(ctx.key, ctx.seed));
+
+ forge.util.setImmediate(generate);
+ }
+ };
+
+ /**
+ * Generates random bytes synchronously.
+ *
+ * @param count the number of random bytes to generate.
+ *
+ * @return count random bytes as a string.
+ */
+ ctx.generateSync = function(count) {
+ // simple generator using counter-based CBC
+ var cipher = ctx.plugin.cipher;
+ var increment = ctx.plugin.increment;
+ var formatKey = ctx.plugin.formatKey;
+ var formatSeed = ctx.plugin.formatSeed;
+
+ // reset key for every request
+ ctx.key = null;
+
+ var b = forge.util.createBuffer();
+ while(b.length() < count) {
+ // if amount of data generated is greater than 1 MiB, trigger reseed
+ if(ctx.generated > 0xfffff) {
+ ctx.key = null;
+ }
+
+ if(ctx.key === null) {
+ _reseedSync();
+ }
+
+ // generate the random bytes
+ var bytes = cipher(ctx.key, ctx.seed);
+ ctx.generated += bytes.length;
+ b.putBytes(bytes);
+
+ // generate bytes for a new key and seed
+ ctx.key = formatKey(cipher(ctx.key, increment(ctx.seed)));
+ ctx.seed = formatSeed(cipher(ctx.key, ctx.seed));
+ }
+
+ return b.getBytes(count);
+ };
+
+ /**
+ * Private function that asynchronously reseeds a generator.
+ *
+ * @param callback(err) called once the operation completes.
+ */
+ function _reseed(callback) {
+ if(ctx.pools[0].messageLength >= 32) {
+ _seed();
+ return callback();
+ }
+ // not enough seed data...
+ var needed = (32 - ctx.pools[0].messageLength) << 5;
+ ctx.seedFile(needed, function(err, bytes) {
+ if(err) {
+ return callback(err);
+ }
+ ctx.collect(bytes);
+ _seed();
+ callback();
+ });
+ }
+
+ /**
+ * Private function that synchronously reseeds a generator.
+ */
+ function _reseedSync() {
+ if(ctx.pools[0].messageLength >= 32) {
+ return _seed();
+ }
+ // not enough seed data...
+ var needed = (32 - ctx.pools[0].messageLength) << 5;
+ ctx.collect(ctx.seedFileSync(needed));
+ _seed();
+ }
+
+ /**
+ * Private function that seeds a generator once enough bytes are available.
+ */
+ function _seed() {
+ // create a plugin-based message digest
+ var md = ctx.plugin.md.create();
+
+ // digest pool 0's entropy and restart it
+ md.update(ctx.pools[0].digest().getBytes());
+ ctx.pools[0].start();
+
+ // digest the entropy of other pools whose index k meet the
+ // condition '2^k mod n == 0' where n is the number of reseeds
+ var k = 1;
+ for(var i = 1; i < 32; ++i) {
+ // prevent signed numbers from being used
+ k = (k === 31) ? 0x80000000 : (k << 2);
+ if(k % ctx.reseeds === 0) {
+ md.update(ctx.pools[i].digest().getBytes());
+ ctx.pools[i].start();
+ }
+ }
+
+ // get digest for key bytes and iterate again for seed bytes
+ var keyBytes = md.digest().getBytes();
+ md.start();
+ md.update(keyBytes);
+ var seedBytes = md.digest().getBytes();
+
+ // update
+ ctx.key = ctx.plugin.formatKey(keyBytes);
+ ctx.seed = ctx.plugin.formatSeed(seedBytes);
+ ctx.reseeds = (ctx.reseeds === 0xffffffff) ? 0 : ctx.reseeds + 1;
+ ctx.generated = 0;
+ }
+
+ /**
+ * The built-in default seedFile. This seedFile is used when entropy
+ * is needed immediately.
+ *
+ * @param needed the number of bytes that are needed.
+ *
+ * @return the random bytes.
+ */
+ function defaultSeedFile(needed) {
+ // use window.crypto.getRandomValues strong source of entropy if available
+ var getRandomValues = null;
+ if(typeof window !== 'undefined') {
+ var _crypto = window.crypto || window.msCrypto;
+ if(_crypto && _crypto.getRandomValues) {
+ getRandomValues = function(arr) {
+ return _crypto.getRandomValues(arr);
+ };
+ }
+ }
+
+ var b = forge.util.createBuffer();
+ if(getRandomValues) {
+ while(b.length() < needed) {
+ // max byte length is 65536 before QuotaExceededError is thrown
+ // http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues
+ var count = Math.max(1, Math.min(needed - b.length(), 65536) / 4);
+ var entropy = new Uint32Array(Math.floor(count));
+ try {
+ getRandomValues(entropy);
+ for(var i = 0; i < entropy.length; ++i) {
+ b.putInt32(entropy[i]);
+ }
+ } catch(e) {
+ /* only ignore QuotaExceededError */
+ if(!(typeof QuotaExceededError !== 'undefined' &&
+ e instanceof QuotaExceededError)) {
+ throw e;
+ }
+ }
+ }
+ }
+
+ // be sad and add some weak random data
+ if(b.length() < needed) {
+ /* Draws from Park-Miller "minimal standard" 31 bit PRNG,
+ implemented with David G. Carta's optimization: with 32 bit math
+ and without division (Public Domain). */
+ var hi, lo, next;
+ var seed = Math.floor(Math.random() * 0x010000);
+ while(b.length() < needed) {
+ lo = 16807 * (seed & 0xFFFF);
+ hi = 16807 * (seed >> 16);
+ lo += (hi & 0x7FFF) << 16;
+ lo += hi >> 15;
+ lo = (lo & 0x7FFFFFFF) + (lo >> 31);
+ seed = lo & 0xFFFFFFFF;
+
+ // consume lower 3 bytes of seed
+ for(var i = 0; i < 3; ++i) {
+ // throw in more pseudo random
+ next = seed >>> (i << 3);
+ next ^= Math.floor(Math.random() * 0x0100);
+ b.putByte(String.fromCharCode(next & 0xFF));
+ }
+ }
+ }
+
+ return b.getBytes(needed);
+ }
+ // initialize seed file APIs
+ if(_crypto) {
+ // use nodejs async API
+ ctx.seedFile = function(needed, callback) {
+ _crypto.randomBytes(needed, function(err, bytes) {
+ if(err) {
+ return callback(err);
+ }
+ callback(null, bytes.toString());
+ });
+ };
+ // use nodejs sync API
+ ctx.seedFileSync = function(needed) {
+ return _crypto.randomBytes(needed).toString();
+ };
+ } else {
+ ctx.seedFile = function(needed, callback) {
+ try {
+ callback(null, defaultSeedFile(needed));
+ } catch(e) {
+ callback(e);
+ }
+ };
+ ctx.seedFileSync = defaultSeedFile;
+ }
+
+ /**
+ * Adds entropy to a prng ctx's accumulator.
+ *
+ * @param bytes the bytes of entropy as a string.
+ */
+ ctx.collect = function(bytes) {
+ // iterate over pools distributing entropy cyclically
+ var count = bytes.length;
+ for(var i = 0; i < count; ++i) {
+ ctx.pools[ctx.pool].update(bytes.substr(i, 1));
+ ctx.pool = (ctx.pool === 31) ? 0 : ctx.pool + 1;
+ }
+ };
+
+ /**
+ * Collects an integer of n bits.
+ *
+ * @param i the integer entropy.
+ * @param n the number of bits in the integer.
+ */
+ ctx.collectInt = function(i, n) {
+ var bytes = '';
+ for(var x = 0; x < n; x += 8) {
+ bytes += String.fromCharCode((i >> x) & 0xFF);
+ }
+ ctx.collect(bytes);
+ };
+
+ /**
+ * Registers a Web Worker to receive immediate entropy from the main thread.
+ * This method is required until Web Workers can access the native crypto
+ * API. This method should be called twice for each created worker, once in
+ * the main thread, and once in the worker itself.
+ *
+ * @param worker the worker to register.
+ */
+ ctx.registerWorker = function(worker) {
+ // worker receives random bytes
+ if(worker === self) {
+ ctx.seedFile = function(needed, callback) {
+ function listener(e) {
+ var data = e.data;
+ if(data.forge && data.forge.prng) {
+ self.removeEventListener('message', listener);
+ callback(data.forge.prng.err, data.forge.prng.bytes);
+ }
+ }
+ self.addEventListener('message', listener);
+ self.postMessage({forge: {prng: {needed: needed}}});
+ };
+ } else {
+ // main thread sends random bytes upon request
+ var listener = function(e) {
+ var data = e.data;
+ if(data.forge && data.forge.prng) {
+ ctx.seedFile(data.forge.prng.needed, function(err, bytes) {
+ worker.postMessage({forge: {prng: {err: err, bytes: bytes}}});
+ });
+ }
+ };
+ // TODO: do we need to remove the event listener when the worker dies?
+ worker.addEventListener('message', listener);
+ }
+ };
+
+ return ctx;
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'prng';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './md', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pss.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pss.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pss.js
new file mode 100644
index 0000000..1b284fc
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pss.js
@@ -0,0 +1,295 @@
+/**
+ * Javascript implementation of PKCS#1 PSS signature padding.
+ *
+ * @author Stefan Siegl
+ *
+ * Copyright (c) 2012 Stefan Siegl <st...@brokenpipe.de>
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// shortcut for PSS API
+var pss = forge.pss = forge.pss || {};
+
+/**
+ * Creates a PSS signature scheme object.
+ *
+ * There are several ways to provide a salt for encoding:
+ *
+ * 1. Specify the saltLength only and the built-in PRNG will generate it.
+ * 2. Specify the saltLength and a custom PRNG with 'getBytesSync' defined that
+ * will be used.
+ * 3. Specify the salt itself as a forge.util.ByteBuffer.
+ *
+ * @param options the options to use:
+ * md the message digest object to use, a forge md instance.
+ * mgf the mask generation function to use, a forge mgf instance.
+ * [saltLength] the length of the salt in octets.
+ * [prng] the pseudo-random number generator to use to produce a salt.
+ * [salt] the salt to use when encoding.
+ *
+ * @return a signature scheme object.
+ */
+pss.create = function(options) {
+ // backwards compatibility w/legacy args: hash, mgf, sLen
+ if(arguments.length === 3) {
+ options = {
+ md: arguments[0],
+ mgf: arguments[1],
+ saltLength: arguments[2]
+ };
+ }
+
+ var hash = options.md;
+ var mgf = options.mgf;
+ var hLen = hash.digestLength;
+
+ var salt_ = options.salt || null;
+ if(typeof salt_ === 'string') {
+ // assume binary-encoded string
+ salt_ = forge.util.createBuffer(salt_);
+ }
+
+ var sLen;
+ if('saltLength' in options) {
+ sLen = options.saltLength;
+ } else if(salt_ !== null) {
+ sLen = salt_.length();
+ } else {
+ throw new Error('Salt length not specified or specific salt not given.');
+ }
+
+ if(salt_ !== null && salt_.length() !== sLen) {
+ throw new Error('Given salt length does not match length of given salt.');
+ }
+
+ var prng = options.prng || forge.random;
+
+ var pssobj = {};
+
+ /**
+ * Encodes a PSS signature.
+ *
+ * This function implements EMSA-PSS-ENCODE as per RFC 3447, section 9.1.1.
+ *
+ * @param md the message digest object with the hash to sign.
+ * @param modsBits the length of the RSA modulus in bits.
+ *
+ * @return the encoded message as a binary-encoded string of length
+ * ceil((modBits - 1) / 8).
+ */
+ pssobj.encode = function(md, modBits) {
+ var i;
+ var emBits = modBits - 1;
+ var emLen = Math.ceil(emBits / 8);
+
+ /* 2. Let mHash = Hash(M), an octet string of length hLen. */
+ var mHash = md.digest().getBytes();
+
+ /* 3. If emLen < hLen + sLen + 2, output "encoding error" and stop. */
+ if(emLen < hLen + sLen + 2) {
+ throw new Error('Message is too long to encrypt.');
+ }
+
+ /* 4. Generate a random octet string salt of length sLen; if sLen = 0,
+ * then salt is the empty string. */
+ var salt;
+ if(salt_ === null) {
+ salt = prng.getBytesSync(sLen);
+ } else {
+ salt = salt_.bytes();
+ }
+
+ /* 5. Let M' = (0x)00 00 00 00 00 00 00 00 || mHash || salt; */
+ var m_ = new forge.util.ByteBuffer();
+ m_.fillWithByte(0, 8);
+ m_.putBytes(mHash);
+ m_.putBytes(salt);
+
+ /* 6. Let H = Hash(M'), an octet string of length hLen. */
+ hash.start();
+ hash.update(m_.getBytes());
+ var h = hash.digest().getBytes();
+
+ /* 7. Generate an octet string PS consisting of emLen - sLen - hLen - 2
+ * zero octets. The length of PS may be 0. */
+ var ps = new forge.util.ByteBuffer();
+ ps.fillWithByte(0, emLen - sLen - hLen - 2);
+
+ /* 8. Let DB = PS || 0x01 || salt; DB is an octet string of length
+ * emLen - hLen - 1. */
+ ps.putByte(0x01);
+ ps.putBytes(salt);
+ var db = ps.getBytes();
+
+ /* 9. Let dbMask = MGF(H, emLen - hLen - 1). */
+ var maskLen = emLen - hLen - 1;
+ var dbMask = mgf.generate(h, maskLen);
+
+ /* 10. Let maskedDB = DB \xor dbMask. */
+ var maskedDB = '';
+ for(i = 0; i < maskLen; i ++) {
+ maskedDB += String.fromCharCode(db.charCodeAt(i) ^ dbMask.charCodeAt(i));
+ }
+
+ /* 11. Set the leftmost 8emLen - emBits bits of the leftmost octet in
+ * maskedDB to zero. */
+ var mask = (0xFF00 >> (8 * emLen - emBits)) & 0xFF;
+ maskedDB = String.fromCharCode(maskedDB.charCodeAt(0) & ~mask) +
+ maskedDB.substr(1);
+
+ /* 12. Let EM = maskedDB || H || 0xbc.
+ * 13. Output EM. */
+ return maskedDB + h + String.fromCharCode(0xbc);
+ };
+
+ /**
+ * Verifies a PSS signature.
+ *
+ * This function implements EMSA-PSS-VERIFY as per RFC 3447, section 9.1.2.
+ *
+ * @param mHash the message digest hash, as a binary-encoded string, to
+ * compare against the signature.
+ * @param em the encoded message, as a binary-encoded string
+ * (RSA decryption result).
+ * @param modsBits the length of the RSA modulus in bits.
+ *
+ * @return true if the signature was verified, false if not.
+ */
+ pssobj.verify = function(mHash, em, modBits) {
+ var i;
+ var emBits = modBits - 1;
+ var emLen = Math.ceil(emBits / 8);
+
+ /* c. Convert the message representative m to an encoded message EM
+ * of length emLen = ceil((modBits - 1) / 8) octets, where modBits
+ * is the length in bits of the RSA modulus n */
+ em = em.substr(-emLen);
+
+ /* 3. If emLen < hLen + sLen + 2, output "inconsistent" and stop. */
+ if(emLen < hLen + sLen + 2) {
+ throw new Error('Inconsistent parameters to PSS signature verification.');
+ }
+
+ /* 4. If the rightmost octet of EM does not have hexadecimal value
+ * 0xbc, output "inconsistent" and stop. */
+ if(em.charCodeAt(emLen - 1) !== 0xbc) {
+ throw new Error('Encoded message does not end in 0xBC.');
+ }
+
+ /* 5. Let maskedDB be the leftmost emLen - hLen - 1 octets of EM, and
+ * let H be the next hLen octets. */
+ var maskLen = emLen - hLen - 1;
+ var maskedDB = em.substr(0, maskLen);
+ var h = em.substr(maskLen, hLen);
+
+ /* 6. If the leftmost 8emLen - emBits bits of the leftmost octet in
+ * maskedDB are not all equal to zero, output "inconsistent" and stop. */
+ var mask = (0xFF00 >> (8 * emLen - emBits)) & 0xFF;
+ if((maskedDB.charCodeAt(0) & mask) !== 0) {
+ throw new Error('Bits beyond keysize not zero as expected.');
+ }
+
+ /* 7. Let dbMask = MGF(H, emLen - hLen - 1). */
+ var dbMask = mgf.generate(h, maskLen);
+
+ /* 8. Let DB = maskedDB \xor dbMask. */
+ var db = '';
+ for(i = 0; i < maskLen; i ++) {
+ db += String.fromCharCode(maskedDB.charCodeAt(i) ^ dbMask.charCodeAt(i));
+ }
+
+ /* 9. Set the leftmost 8emLen - emBits bits of the leftmost octet
+ * in DB to zero. */
+ db = String.fromCharCode(db.charCodeAt(0) & ~mask) + db.substr(1);
+
+ /* 10. If the emLen - hLen - sLen - 2 leftmost octets of DB are not zero
+ * or if the octet at position emLen - hLen - sLen - 1 (the leftmost
+ * position is "position 1") does not have hexadecimal value 0x01,
+ * output "inconsistent" and stop. */
+ var checkLen = emLen - hLen - sLen - 2;
+ for(i = 0; i < checkLen; i ++) {
+ if(db.charCodeAt(i) !== 0x00) {
+ throw new Error('Leftmost octets not zero as expected');
+ }
+ }
+
+ if(db.charCodeAt(checkLen) !== 0x01) {
+ throw new Error('Inconsistent PSS signature, 0x01 marker not found');
+ }
+
+ /* 11. Let salt be the last sLen octets of DB. */
+ var salt = db.substr(-sLen);
+
+ /* 12. Let M' = (0x)00 00 00 00 00 00 00 00 || mHash || salt */
+ var m_ = new forge.util.ByteBuffer();
+ m_.fillWithByte(0, 8);
+ m_.putBytes(mHash);
+ m_.putBytes(salt);
+
+ /* 13. Let H' = Hash(M'), an octet string of length hLen. */
+ hash.start();
+ hash.update(m_.getBytes());
+ var h_ = hash.digest().getBytes();
+
+ /* 14. If H = H', output "consistent." Otherwise, output "inconsistent." */
+ return h === h_;
+ };
+
+ return pssobj;
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'pss';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './random', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/random.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/random.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/random.js
new file mode 100644
index 0000000..febc1fd
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/random.js
@@ -0,0 +1,237 @@
+/**
+ * An API for getting cryptographically-secure random bytes. The bytes are
+ * generated using the Fortuna algorithm devised by Bruce Schneier and
+ * Niels Ferguson.
+ *
+ * Getting strong random bytes is not yet easy to do in javascript. The only
+ * truish random entropy that can be collected is from the mouse, keyboard, or
+ * from timing with respect to page loads, etc. This generator makes a poor
+ * attempt at providing random bytes when those sources haven't yet provided
+ * enough entropy to initially seed or to reseed the PRNG.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2009-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// forge.random already defined
+if(forge.random && forge.random.getBytes) {
+ return;
+}
+
+(function(jQuery) {
+
+// the default prng plugin, uses AES-128
+var prng_aes = {};
+var _prng_aes_output = new Array(4);
+var _prng_aes_buffer = forge.util.createBuffer();
+prng_aes.formatKey = function(key) {
+ // convert the key into 32-bit integers
+ var tmp = forge.util.createBuffer(key);
+ key = new Array(4);
+ key[0] = tmp.getInt32();
+ key[1] = tmp.getInt32();
+ key[2] = tmp.getInt32();
+ key[3] = tmp.getInt32();
+
+ // return the expanded key
+ return forge.aes._expandKey(key, false);
+};
+prng_aes.formatSeed = function(seed) {
+ // convert seed into 32-bit integers
+ var tmp = forge.util.createBuffer(seed);
+ seed = new Array(4);
+ seed[0] = tmp.getInt32();
+ seed[1] = tmp.getInt32();
+ seed[2] = tmp.getInt32();
+ seed[3] = tmp.getInt32();
+ return seed;
+};
+prng_aes.cipher = function(key, seed) {
+ forge.aes._updateBlock(key, seed, _prng_aes_output, false);
+ _prng_aes_buffer.putInt32(_prng_aes_output[0]);
+ _prng_aes_buffer.putInt32(_prng_aes_output[1]);
+ _prng_aes_buffer.putInt32(_prng_aes_output[2]);
+ _prng_aes_buffer.putInt32(_prng_aes_output[3]);
+ return _prng_aes_buffer.getBytes();
+};
+prng_aes.increment = function(seed) {
+ // FIXME: do we care about carry or signed issues?
+ ++seed[3];
+ return seed;
+};
+prng_aes.md = forge.md.sha256;
+
+/**
+ * Creates a new PRNG.
+ */
+function spawnPrng() {
+ var ctx = forge.prng.create(prng_aes);
+
+ /**
+ * Gets random bytes. If a native secure crypto API is unavailable, this
+ * method tries to make the bytes more unpredictable by drawing from data that
+ * can be collected from the user of the browser, eg: mouse movement.
+ *
+ * If a callback is given, this method will be called asynchronously.
+ *
+ * @param count the number of random bytes to get.
+ * @param [callback(err, bytes)] called once the operation completes.
+ *
+ * @return the random bytes in a string.
+ */
+ ctx.getBytes = function(count, callback) {
+ return ctx.generate(count, callback);
+ };
+
+ /**
+ * Gets random bytes asynchronously. If a native secure crypto API is
+ * unavailable, this method tries to make the bytes more unpredictable by
+ * drawing from data that can be collected from the user of the browser,
+ * eg: mouse movement.
+ *
+ * @param count the number of random bytes to get.
+ *
+ * @return the random bytes in a string.
+ */
+ ctx.getBytesSync = function(count) {
+ return ctx.generate(count);
+ };
+
+ return ctx;
+}
+
+// create default prng context
+var _ctx = spawnPrng();
+
+// add other sources of entropy only if window.crypto.getRandomValues is not
+// available -- otherwise this source will be automatically used by the prng
+var _nodejs = (
+ typeof process !== 'undefined' && process.versions && process.versions.node);
+var getRandomValues = null;
+if(typeof window !== 'undefined') {
+ var _crypto = window.crypto || window.msCrypto;
+ if(_crypto && _crypto.getRandomValues) {
+ getRandomValues = function(arr) {
+ return _crypto.getRandomValues(arr);
+ };
+ }
+}
+if(forge.disableNativeCode || (!_nodejs && !getRandomValues)) {
+ // if this is a web worker, do not use weak entropy, instead register to
+ // receive strong entropy asynchronously from the main thread
+ if(typeof window === 'undefined' || window.document === undefined) {
+ // FIXME:
+ }
+
+ // get load time entropy
+ _ctx.collectInt(+new Date(), 32);
+
+ // add some entropy from navigator object
+ if(typeof(navigator) !== 'undefined') {
+ var _navBytes = '';
+ for(var key in navigator) {
+ try {
+ if(typeof(navigator[key]) == 'string') {
+ _navBytes += navigator[key];
+ }
+ } catch(e) {
+ /* Some navigator keys might not be accessible, e.g. the geolocation
+ attribute throws an exception if touched in Mozilla chrome://
+ context.
+
+ Silently ignore this and just don't use this as a source of
+ entropy. */
+ }
+ }
+ _ctx.collect(_navBytes);
+ _navBytes = null;
+ }
+
+ // add mouse and keyboard collectors if jquery is available
+ if(jQuery) {
+ // set up mouse entropy capture
+ jQuery().mousemove(function(e) {
+ // add mouse coords
+ _ctx.collectInt(e.clientX, 16);
+ _ctx.collectInt(e.clientY, 16);
+ });
+
+ // set up keyboard entropy capture
+ jQuery().keypress(function(e) {
+ _ctx.collectInt(e.charCode, 8);
+ });
+ }
+}
+
+/* Random API */
+if(!forge.random) {
+ forge.random = _ctx;
+} else {
+ // extend forge.random with _ctx
+ for(var key in _ctx) {
+ forge.random[key] = _ctx[key];
+ }
+}
+
+// expose spawn PRNG
+forge.random.createInstance = spawnPrng;
+
+})(typeof(jQuery) !== 'undefined' ? jQuery : null);
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'random';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './aes', './md', './prng', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/rc2.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/rc2.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/rc2.js
new file mode 100644
index 0000000..0a67011
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/rc2.js
@@ -0,0 +1,470 @@
+/**
+ * RC2 implementation.
+ *
+ * @author Stefan Siegl
+ *
+ * Copyright (c) 2012 Stefan Siegl <st...@brokenpipe.de>
+ *
+ * Information on the RC2 cipher is available from RFC #2268,
+ * http://www.ietf.org/rfc/rfc2268.txt
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+var piTable = [
+ 0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d,
+ 0xc6, 0x7e, 0x37, 0x83, 0x2b, 0x76, 0x53, 0x8e, 0x62, 0x4c, 0x64, 0x88, 0x44, 0x8b, 0xfb, 0xa2,
+ 0x17, 0x9a, 0x59, 0xf5, 0x87, 0xb3, 0x4f, 0x13, 0x61, 0x45, 0x6d, 0x8d, 0x09, 0x81, 0x7d, 0x32,
+ 0xbd, 0x8f, 0x40, 0xeb, 0x86, 0xb7, 0x7b, 0x0b, 0xf0, 0x95, 0x21, 0x22, 0x5c, 0x6b, 0x4e, 0x82,
+ 0x54, 0xd6, 0x65, 0x93, 0xce, 0x60, 0xb2, 0x1c, 0x73, 0x56, 0xc0, 0x14, 0xa7, 0x8c, 0xf1, 0xdc,
+ 0x12, 0x75, 0xca, 0x1f, 0x3b, 0xbe, 0xe4, 0xd1, 0x42, 0x3d, 0xd4, 0x30, 0xa3, 0x3c, 0xb6, 0x26,
+ 0x6f, 0xbf, 0x0e, 0xda, 0x46, 0x69, 0x07, 0x57, 0x27, 0xf2, 0x1d, 0x9b, 0xbc, 0x94, 0x43, 0x03,
+ 0xf8, 0x11, 0xc7, 0xf6, 0x90, 0xef, 0x3e, 0xe7, 0x06, 0xc3, 0xd5, 0x2f, 0xc8, 0x66, 0x1e, 0xd7,
+ 0x08, 0xe8, 0xea, 0xde, 0x80, 0x52, 0xee, 0xf7, 0x84, 0xaa, 0x72, 0xac, 0x35, 0x4d, 0x6a, 0x2a,
+ 0x96, 0x1a, 0xd2, 0x71, 0x5a, 0x15, 0x49, 0x74, 0x4b, 0x9f, 0xd0, 0x5e, 0x04, 0x18, 0xa4, 0xec,
+ 0xc2, 0xe0, 0x41, 0x6e, 0x0f, 0x51, 0xcb, 0xcc, 0x24, 0x91, 0xaf, 0x50, 0xa1, 0xf4, 0x70, 0x39,
+ 0x99, 0x7c, 0x3a, 0x85, 0x23, 0xb8, 0xb4, 0x7a, 0xfc, 0x02, 0x36, 0x5b, 0x25, 0x55, 0x97, 0x31,
+ 0x2d, 0x5d, 0xfa, 0x98, 0xe3, 0x8a, 0x92, 0xae, 0x05, 0xdf, 0x29, 0x10, 0x67, 0x6c, 0xba, 0xc9,
+ 0xd3, 0x00, 0xe6, 0xcf, 0xe1, 0x9e, 0xa8, 0x2c, 0x63, 0x16, 0x01, 0x3f, 0x58, 0xe2, 0x89, 0xa9,
+ 0x0d, 0x38, 0x34, 0x1b, 0xab, 0x33, 0xff, 0xb0, 0xbb, 0x48, 0x0c, 0x5f, 0xb9, 0xb1, 0xcd, 0x2e,
+ 0xc5, 0xf3, 0xdb, 0x47, 0xe5, 0xa5, 0x9c, 0x77, 0x0a, 0xa6, 0x20, 0x68, 0xfe, 0x7f, 0xc1, 0xad
+];
+
+var s = [1, 2, 3, 5];
+
+
+/**
+ * Rotate a word left by given number of bits.
+ *
+ * Bits that are shifted out on the left are put back in on the right
+ * hand side.
+ *
+ * @param word The word to shift left.
+ * @param bits The number of bits to shift by.
+ * @return The rotated word.
+ */
+var rol = function(word, bits) {
+ return ((word << bits) & 0xffff) | ((word & 0xffff) >> (16 - bits));
+};
+
+/**
+ * Rotate a word right by given number of bits.
+ *
+ * Bits that are shifted out on the right are put back in on the left
+ * hand side.
+ *
+ * @param word The word to shift right.
+ * @param bits The number of bits to shift by.
+ * @return The rotated word.
+ */
+var ror = function(word, bits) {
+ return ((word & 0xffff) >> bits) | ((word << (16 - bits)) & 0xffff);
+};
+
+
+/* RC2 API */
+forge.rc2 = forge.rc2 || {};
+
+/**
+ * Perform RC2 key expansion as per RFC #2268, section 2.
+ *
+ * @param key variable-length user key (between 1 and 128 bytes)
+ * @param effKeyBits number of effective key bits (default: 128)
+ * @return the expanded RC2 key (ByteBuffer of 128 bytes)
+ */
+forge.rc2.expandKey = function(key, effKeyBits) {
+ if(typeof key === 'string') {
+ key = forge.util.createBuffer(key);
+ }
+ effKeyBits = effKeyBits || 128;
+
+ /* introduce variables that match the names used in RFC #2268 */
+ var L = key;
+ var T = key.length();
+ var T1 = effKeyBits;
+ var T8 = Math.ceil(T1 / 8);
+ var TM = 0xff >> (T1 & 0x07);
+ var i;
+
+ for(i = T; i < 128; i ++) {
+ L.putByte(piTable[(L.at(i - 1) + L.at(i - T)) & 0xff]);
+ }
+
+ L.setAt(128 - T8, piTable[L.at(128 - T8) & TM]);
+
+ for(i = 127 - T8; i >= 0; i --) {
+ L.setAt(i, piTable[L.at(i + 1) ^ L.at(i + T8)]);
+ }
+
+ return L;
+};
+
+
+/**
+ * Creates a RC2 cipher object.
+ *
+ * @param key the symmetric key to use (as base for key generation).
+ * @param bits the number of effective key bits.
+ * @param encrypt false for decryption, true for encryption.
+ *
+ * @return the cipher.
+ */
+var createCipher = function(key, bits, encrypt) {
+ var _finish = false, _input = null, _output = null, _iv = null;
+ var mixRound, mashRound;
+ var i, j, K = [];
+
+ /* Expand key and fill into K[] Array */
+ key = forge.rc2.expandKey(key, bits);
+ for(i = 0; i < 64; i ++) {
+ K.push(key.getInt16Le());
+ }
+
+ if(encrypt) {
+ /**
+ * Perform one mixing round "in place".
+ *
+ * @param R Array of four words to perform mixing on.
+ */
+ mixRound = function(R) {
+ for(i = 0; i < 4; i++) {
+ R[i] += K[j] + (R[(i + 3) % 4] & R[(i + 2) % 4]) +
+ ((~R[(i + 3) % 4]) & R[(i + 1) % 4]);
+ R[i] = rol(R[i], s[i]);
+ j ++;
+ }
+ };
+
+ /**
+ * Perform one mashing round "in place".
+ *
+ * @param R Array of four words to perform mashing on.
+ */
+ mashRound = function(R) {
+ for(i = 0; i < 4; i ++) {
+ R[i] += K[R[(i + 3) % 4] & 63];
+ }
+ };
+ } else {
+ /**
+ * Perform one r-mixing round "in place".
+ *
+ * @param R Array of four words to perform mixing on.
+ */
+ mixRound = function(R) {
+ for(i = 3; i >= 0; i--) {
+ R[i] = ror(R[i], s[i]);
+ R[i] -= K[j] + (R[(i + 3) % 4] & R[(i + 2) % 4]) +
+ ((~R[(i + 3) % 4]) & R[(i + 1) % 4]);
+ j --;
+ }
+ };
+
+ /**
+ * Perform one r-mashing round "in place".
+ *
+ * @param R Array of four words to perform mashing on.
+ */
+ mashRound = function(R) {
+ for(i = 3; i >= 0; i--) {
+ R[i] -= K[R[(i + 3) % 4] & 63];
+ }
+ };
+ }
+
+ /**
+ * Run the specified cipher execution plan.
+ *
+ * This function takes four words from the input buffer, applies the IV on
+ * it (if requested) and runs the provided execution plan.
+ *
+ * The plan must be put together in form of a array of arrays. Where the
+ * outer one is simply a list of steps to perform and the inner one needs
+ * to have two elements: the first one telling how many rounds to perform,
+ * the second one telling what to do (i.e. the function to call).
+ *
+ * @param {Array} plan The plan to execute.
+ */
+ var runPlan = function(plan) {
+ var R = [];
+
+ /* Get data from input buffer and fill the four words into R */
+ for(i = 0; i < 4; i ++) {
+ var val = _input.getInt16Le();
+
+ if(_iv !== null) {
+ if(encrypt) {
+ /* We're encrypting, apply the IV first. */
+ val ^= _iv.getInt16Le();
+ } else {
+ /* We're decryption, keep cipher text for next block. */
+ _iv.putInt16Le(val);
+ }
+ }
+
+ R.push(val & 0xffff);
+ }
+
+ /* Reset global "j" variable as per spec. */
+ j = encrypt ? 0 : 63;
+
+ /* Run execution plan. */
+ for(var ptr = 0; ptr < plan.length; ptr ++) {
+ for(var ctr = 0; ctr < plan[ptr][0]; ctr ++) {
+ plan[ptr][1](R);
+ }
+ }
+
+ /* Write back result to output buffer. */
+ for(i = 0; i < 4; i ++) {
+ if(_iv !== null) {
+ if(encrypt) {
+ /* We're encrypting in CBC-mode, feed back encrypted bytes into
+ IV buffer to carry it forward to next block. */
+ _iv.putInt16Le(R[i]);
+ } else {
+ R[i] ^= _iv.getInt16Le();
+ }
+ }
+
+ _output.putInt16Le(R[i]);
+ }
+ };
+
+
+ /* Create cipher object */
+ var cipher = null;
+ cipher = {
+ /**
+ * Starts or restarts the encryption or decryption process, whichever
+ * was previously configured.
+ *
+ * To use the cipher in CBC mode, iv may be given either as a string
+ * of bytes, or as a byte buffer. For ECB mode, give null as iv.
+ *
+ * @param iv the initialization vector to use, null for ECB mode.
+ * @param output the output the buffer to write to, null to create one.
+ */
+ start: function(iv, output) {
+ if(iv) {
+ /* CBC mode */
+ if(typeof iv === 'string') {
+ iv = forge.util.createBuffer(iv);
+ }
+ }
+
+ _finish = false;
+ _input = forge.util.createBuffer();
+ _output = output || new forge.util.createBuffer();
+ _iv = iv;
+
+ cipher.output = _output;
+ },
+
+ /**
+ * Updates the next block.
+ *
+ * @param input the buffer to read from.
+ */
+ update: function(input) {
+ if(!_finish) {
+ // not finishing, so fill the input buffer with more input
+ _input.putBuffer(input);
+ }
+
+ while(_input.length() >= 8) {
+ runPlan([
+ [ 5, mixRound ],
+ [ 1, mashRound ],
+ [ 6, mixRound ],
+ [ 1, mashRound ],
+ [ 5, mixRound ]
+ ]);
+ }
+ },
+
+ /**
+ * Finishes encrypting or decrypting.
+ *
+ * @param pad a padding function to use, null for PKCS#7 padding,
+ * signature(blockSize, buffer, decrypt).
+ *
+ * @return true if successful, false on error.
+ */
+ finish: function(pad) {
+ var rval = true;
+
+ if(encrypt) {
+ if(pad) {
+ rval = pad(8, _input, !encrypt);
+ } else {
+ // add PKCS#7 padding to block (each pad byte is the
+ // value of the number of pad bytes)
+ var padding = (_input.length() === 8) ? 8 : (8 - _input.length());
+ _input.fillWithByte(padding, padding);
+ }
+ }
+
+ if(rval) {
+ // do final update
+ _finish = true;
+ cipher.update();
+ }
+
+ if(!encrypt) {
+ // check for error: input data not a multiple of block size
+ rval = (_input.length() === 0);
+ if(rval) {
+ if(pad) {
+ rval = pad(8, _output, !encrypt);
+ } else {
+ // ensure padding byte count is valid
+ var len = _output.length();
+ var count = _output.at(len - 1);
+
+ if(count > len) {
+ rval = false;
+ } else {
+ // trim off padding bytes
+ _output.truncate(count);
+ }
+ }
+ }
+ }
+
+ return rval;
+ }
+ };
+
+ return cipher;
+};
+
+
+/**
+ * Creates an RC2 cipher object to encrypt data in ECB or CBC mode using the
+ * given symmetric key. The output will be stored in the 'output' member
+ * of the returned cipher.
+ *
+ * The key and iv may be given as a string of bytes or a byte buffer.
+ * The cipher is initialized to use 128 effective key bits.
+ *
+ * @param key the symmetric key to use.
+ * @param iv the initialization vector to use.
+ * @param output the buffer to write to, null to create one.
+ *
+ * @return the cipher.
+ */
+forge.rc2.startEncrypting = function(key, iv, output) {
+ var cipher = forge.rc2.createEncryptionCipher(key, 128);
+ cipher.start(iv, output);
+ return cipher;
+};
+
+/**
+ * Creates an RC2 cipher object to encrypt data in ECB or CBC mode using the
+ * given symmetric key.
+ *
+ * The key may be given as a string of bytes or a byte buffer.
+ *
+ * To start encrypting call start() on the cipher with an iv and optional
+ * output buffer.
+ *
+ * @param key the symmetric key to use.
+ *
+ * @return the cipher.
+ */
+forge.rc2.createEncryptionCipher = function(key, bits) {
+ return createCipher(key, bits, true);
+};
+
+/**
+ * Creates an RC2 cipher object to decrypt data in ECB or CBC mode using the
+ * given symmetric key. The output will be stored in the 'output' member
+ * of the returned cipher.
+ *
+ * The key and iv may be given as a string of bytes or a byte buffer.
+ * The cipher is initialized to use 128 effective key bits.
+ *
+ * @param key the symmetric key to use.
+ * @param iv the initialization vector to use.
+ * @param output the buffer to write to, null to create one.
+ *
+ * @return the cipher.
+ */
+forge.rc2.startDecrypting = function(key, iv, output) {
+ var cipher = forge.rc2.createDecryptionCipher(key, 128);
+ cipher.start(iv, output);
+ return cipher;
+};
+
+/**
+ * Creates an RC2 cipher object to decrypt data in ECB or CBC mode using the
+ * given symmetric key.
+ *
+ * The key may be given as a string of bytes or a byte buffer.
+ *
+ * To start decrypting call start() on the cipher with an iv and optional
+ * output buffer.
+ *
+ * @param key the symmetric key to use.
+ *
+ * @return the cipher.
+ */
+forge.rc2.createDecryptionCipher = function(key, bits) {
+ return createCipher(key, bits, false);
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'rc2';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[22/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise.js
new file mode 100644
index 0000000..a5fe1d6
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise.js
@@ -0,0 +1,1167 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function() {
+var global = require("./global.js");
+var util = require("./util.js");
+var async = require("./async.js");
+var errors = require("./errors.js");
+
+var INTERNAL = function(){};
+var APPLY = {};
+var NEXT_FILTER = {e: null};
+
+var PromiseArray = require("./promise_array.js")(Promise, INTERNAL);
+var CapturedTrace = require("./captured_trace.js")();
+var CatchFilter = require("./catch_filter.js")(NEXT_FILTER);
+var PromiseResolver = require("./promise_resolver.js");
+
+var isArray = util.isArray;
+
+var errorObj = util.errorObj;
+var tryCatch1 = util.tryCatch1;
+var tryCatch2 = util.tryCatch2;
+var tryCatchApply = util.tryCatchApply;
+var RangeError = errors.RangeError;
+var TypeError = errors.TypeError;
+var CancellationError = errors.CancellationError;
+var TimeoutError = errors.TimeoutError;
+var RejectionError = errors.RejectionError;
+var originatesFromRejection = errors.originatesFromRejection;
+var markAsOriginatingFromRejection = errors.markAsOriginatingFromRejection;
+var canAttach = errors.canAttach;
+var thrower = util.thrower;
+var apiRejection = require("./errors_api_rejection")(Promise);
+
+
+var makeSelfResolutionError = function Promise$_makeSelfResolutionError() {
+ return new TypeError("circular promise resolution chain");
+};
+
+function isPromise(obj) {
+ if (obj === void 0) return false;
+ return obj instanceof Promise;
+}
+
+function isPromiseArrayProxy(receiver, promiseSlotValue) {
+ if (receiver instanceof PromiseArray) {
+ return promiseSlotValue >= 0;
+ }
+ return false;
+}
+
+function Promise(resolver) {
+ if (typeof resolver !== "function") {
+ throw new TypeError("the promise constructor requires a resolver function");
+ }
+ if (this.constructor !== Promise) {
+ throw new TypeError("the promise constructor cannot be invoked directly");
+ }
+ this._bitField = 0;
+ this._fulfillmentHandler0 = void 0;
+ this._rejectionHandler0 = void 0;
+ this._promise0 = void 0;
+ this._receiver0 = void 0;
+ this._settledValue = void 0;
+ this._boundTo = void 0;
+ if (resolver !== INTERNAL) this._resolveFromResolver(resolver);
+}
+
+Promise.prototype.bind = function Promise$bind(thisArg) {
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(this.bind, this);
+ ret._follow(this);
+ ret._setBoundTo(thisArg);
+ if (this._cancellable()) {
+ ret._setCancellable();
+ ret._cancellationParent = this;
+ }
+ return ret;
+};
+
+Promise.prototype.toString = function Promise$toString() {
+ return "[object Promise]";
+};
+
+Promise.prototype.caught = Promise.prototype["catch"] =
+function Promise$catch(fn) {
+ var len = arguments.length;
+ if (len > 1) {
+ var catchInstances = new Array(len - 1),
+ j = 0, i;
+ for (i = 0; i < len - 1; ++i) {
+ var item = arguments[i];
+ if (typeof item === "function") {
+ catchInstances[j++] = item;
+ }
+ else {
+ var catchFilterTypeError =
+ new TypeError(
+ "A catch filter must be an error constructor "
+ + "or a filter function");
+
+ this._attachExtraTrace(catchFilterTypeError);
+ async.invoke(this._reject, this, catchFilterTypeError);
+ return;
+ }
+ }
+ catchInstances.length = j;
+ fn = arguments[i];
+
+ this._resetTrace(this.caught);
+ var catchFilter = new CatchFilter(catchInstances, fn, this);
+ return this._then(void 0, catchFilter.doFilter, void 0,
+ catchFilter, void 0, this.caught);
+ }
+ return this._then(void 0, fn, void 0, void 0, void 0, this.caught);
+};
+
+Promise.prototype.then =
+function Promise$then(didFulfill, didReject, didProgress) {
+ return this._then(didFulfill, didReject, didProgress,
+ void 0, void 0, this.then);
+};
+
+
+Promise.prototype.done =
+function Promise$done(didFulfill, didReject, didProgress) {
+ var promise = this._then(didFulfill, didReject, didProgress,
+ void 0, void 0, this.done);
+ promise._setIsFinal();
+};
+
+Promise.prototype.spread = function Promise$spread(didFulfill, didReject) {
+ return this._then(didFulfill, didReject, void 0,
+ APPLY, void 0, this.spread);
+};
+
+Promise.prototype.isFulfilled = function Promise$isFulfilled() {
+ return (this._bitField & 268435456) > 0;
+};
+
+
+Promise.prototype.isRejected = function Promise$isRejected() {
+ return (this._bitField & 134217728) > 0;
+};
+
+Promise.prototype.isPending = function Promise$isPending() {
+ return !this.isResolved();
+};
+
+
+Promise.prototype.isResolved = function Promise$isResolved() {
+ return (this._bitField & 402653184) > 0;
+};
+
+
+Promise.prototype.isCancellable = function Promise$isCancellable() {
+ return !this.isResolved() &&
+ this._cancellable();
+};
+
+Promise.prototype.toJSON = function Promise$toJSON() {
+ var ret = {
+ isFulfilled: false,
+ isRejected: false,
+ fulfillmentValue: void 0,
+ rejectionReason: void 0
+ };
+ if (this.isFulfilled()) {
+ ret.fulfillmentValue = this._settledValue;
+ ret.isFulfilled = true;
+ }
+ else if (this.isRejected()) {
+ ret.rejectionReason = this._settledValue;
+ ret.isRejected = true;
+ }
+ return ret;
+};
+
+Promise.prototype.all = function Promise$all() {
+ return Promise$_all(this, true, this.all);
+};
+
+
+Promise.is = isPromise;
+
+function Promise$_all(promises, useBound, caller) {
+ return Promise$_CreatePromiseArray(
+ promises,
+ PromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ ).promise();
+}
+Promise.all = function Promise$All(promises) {
+ return Promise$_all(promises, false, Promise.all);
+};
+
+Promise.join = function Promise$Join() {
+ var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
+ return Promise$_CreatePromiseArray(
+ args, PromiseArray, Promise.join, void 0).promise();
+};
+
+Promise.resolve = Promise.fulfilled =
+function Promise$Resolve(value, caller) {
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(typeof caller === "function"
+ ? caller
+ : Promise.resolve, void 0);
+ if (ret._tryFollow(value)) {
+ return ret;
+ }
+ ret._cleanValues();
+ ret._setFulfilled();
+ ret._settledValue = value;
+ return ret;
+};
+
+Promise.reject = Promise.rejected = function Promise$Reject(reason) {
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(Promise.reject, void 0);
+ markAsOriginatingFromRejection(reason);
+ ret._cleanValues();
+ ret._setRejected();
+ ret._settledValue = reason;
+ if (!canAttach(reason)) {
+ var trace = new Error(reason + "");
+ ret._setCarriedStackTrace(trace);
+ }
+ ret._ensurePossibleRejectionHandled();
+ return ret;
+};
+
+Promise.prototype.error = function Promise$_error(fn) {
+ return this.caught(originatesFromRejection, fn);
+};
+
+Promise.prototype._resolveFromSyncValue =
+function Promise$_resolveFromSyncValue(value, caller) {
+ if (value === errorObj) {
+ this._cleanValues();
+ this._setRejected();
+ this._settledValue = value.e;
+ this._ensurePossibleRejectionHandled();
+ }
+ else {
+ var maybePromise = Promise._cast(value, caller, void 0);
+ if (maybePromise instanceof Promise) {
+ this._follow(maybePromise);
+ }
+ else {
+ this._cleanValues();
+ this._setFulfilled();
+ this._settledValue = value;
+ }
+ }
+};
+
+Promise.method = function Promise$_Method(fn) {
+ if (typeof fn !== "function") {
+ throw new TypeError("fn must be a function");
+ }
+ return function Promise$_method() {
+ var value;
+ switch(arguments.length) {
+ case 0: value = tryCatch1(fn, this, void 0); break;
+ case 1: value = tryCatch1(fn, this, arguments[0]); break;
+ case 2: value = tryCatch2(fn, this, arguments[0], arguments[1]); break;
+ default:
+ var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
+ value = tryCatchApply(fn, args, this); break;
+ }
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(Promise$_method, void 0);
+ ret._resolveFromSyncValue(value, Promise$_method);
+ return ret;
+ };
+};
+
+Promise.attempt = Promise["try"] = function Promise$_Try(fn, args, ctx) {
+
+ if (typeof fn !== "function") {
+ return apiRejection("fn must be a function");
+ }
+ var value = isArray(args)
+ ? tryCatchApply(fn, args, ctx)
+ : tryCatch1(fn, ctx, args);
+
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(Promise.attempt, void 0);
+ ret._resolveFromSyncValue(value, Promise.attempt);
+ return ret;
+};
+
+Promise.defer = Promise.pending = function Promise$Defer(caller) {
+ var promise = new Promise(INTERNAL);
+ if (debugging) promise._setTrace(typeof caller === "function"
+ ? caller : Promise.defer, void 0);
+ return new PromiseResolver(promise);
+};
+
+Promise.bind = function Promise$Bind(thisArg) {
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(Promise.bind, void 0);
+ ret._setFulfilled();
+ ret._setBoundTo(thisArg);
+ return ret;
+};
+
+Promise.cast = function Promise$_Cast(obj, caller) {
+ if (typeof caller !== "function") {
+ caller = Promise.cast;
+ }
+ var ret = Promise._cast(obj, caller, void 0);
+ if (!(ret instanceof Promise)) {
+ return Promise.resolve(ret, caller);
+ }
+ return ret;
+};
+
+Promise.onPossiblyUnhandledRejection =
+function Promise$OnPossiblyUnhandledRejection(fn) {
+ if (typeof fn === "function") {
+ CapturedTrace.possiblyUnhandledRejection = fn;
+ }
+ else {
+ CapturedTrace.possiblyUnhandledRejection = void 0;
+ }
+};
+
+var debugging = false || !!(
+ typeof process !== "undefined" &&
+ typeof process.execPath === "string" &&
+ typeof process.env === "object" &&
+ (process.env["BLUEBIRD_DEBUG"] ||
+ process.env["NODE_ENV"] === "development")
+);
+
+
+Promise.longStackTraces = function Promise$LongStackTraces() {
+ if (async.haveItemsQueued() &&
+ debugging === false
+ ) {
+ throw new Error("cannot enable long stack traces after promises have been created");
+ }
+ debugging = CapturedTrace.isSupported();
+};
+
+Promise.hasLongStackTraces = function Promise$HasLongStackTraces() {
+ return debugging && CapturedTrace.isSupported();
+};
+
+Promise.prototype._setProxyHandlers =
+function Promise$_setProxyHandlers(receiver, promiseSlotValue) {
+ var index = this._length();
+
+ if (index >= 1048575 - 5) {
+ index = 0;
+ this._setLength(0);
+ }
+ if (index === 0) {
+ this._promise0 = promiseSlotValue;
+ this._receiver0 = receiver;
+ }
+ else {
+ var i = index - 5;
+ this[i + 3] = promiseSlotValue;
+ this[i + 4] = receiver;
+ this[i + 0] =
+ this[i + 1] =
+ this[i + 2] = void 0;
+ }
+ this._setLength(index + 5);
+};
+
+Promise.prototype._proxyPromiseArray =
+function Promise$_proxyPromiseArray(promiseArray, index) {
+ this._setProxyHandlers(promiseArray, index);
+};
+
+Promise.prototype._proxyPromise = function Promise$_proxyPromise(promise) {
+ promise._setProxied();
+ this._setProxyHandlers(promise, -1);
+};
+
+Promise.prototype._then =
+function Promise$_then(
+ didFulfill,
+ didReject,
+ didProgress,
+ receiver,
+ internalData,
+ caller
+) {
+ var haveInternalData = internalData !== void 0;
+ var ret = haveInternalData ? internalData : new Promise(INTERNAL);
+
+ if (debugging && !haveInternalData) {
+ var haveSameContext = this._peekContext() === this._traceParent;
+ ret._traceParent = haveSameContext ? this._traceParent : this;
+ ret._setTrace(typeof caller === "function"
+ ? caller
+ : this._then, this);
+ }
+
+ if (!haveInternalData && this._isBound()) {
+ ret._setBoundTo(this._boundTo);
+ }
+
+ var callbackIndex =
+ this._addCallbacks(didFulfill, didReject, didProgress, ret, receiver);
+
+ if (!haveInternalData && this._cancellable()) {
+ ret._setCancellable();
+ ret._cancellationParent = this;
+ }
+
+ if (this.isResolved()) {
+ async.invoke(this._queueSettleAt, this, callbackIndex);
+ }
+
+ return ret;
+};
+
+Promise.prototype._length = function Promise$_length() {
+ return this._bitField & 1048575;
+};
+
+Promise.prototype._isFollowingOrFulfilledOrRejected =
+function Promise$_isFollowingOrFulfilledOrRejected() {
+ return (this._bitField & 939524096) > 0;
+};
+
+Promise.prototype._isFollowing = function Promise$_isFollowing() {
+ return (this._bitField & 536870912) === 536870912;
+};
+
+Promise.prototype._setLength = function Promise$_setLength(len) {
+ this._bitField = (this._bitField & -1048576) |
+ (len & 1048575);
+};
+
+Promise.prototype._setFulfilled = function Promise$_setFulfilled() {
+ this._bitField = this._bitField | 268435456;
+};
+
+Promise.prototype._setRejected = function Promise$_setRejected() {
+ this._bitField = this._bitField | 134217728;
+};
+
+Promise.prototype._setFollowing = function Promise$_setFollowing() {
+ this._bitField = this._bitField | 536870912;
+};
+
+Promise.prototype._setIsFinal = function Promise$_setIsFinal() {
+ this._bitField = this._bitField | 33554432;
+};
+
+Promise.prototype._isFinal = function Promise$_isFinal() {
+ return (this._bitField & 33554432) > 0;
+};
+
+Promise.prototype._cancellable = function Promise$_cancellable() {
+ return (this._bitField & 67108864) > 0;
+};
+
+Promise.prototype._setCancellable = function Promise$_setCancellable() {
+ this._bitField = this._bitField | 67108864;
+};
+
+Promise.prototype._unsetCancellable = function Promise$_unsetCancellable() {
+ this._bitField = this._bitField & (~67108864);
+};
+
+Promise.prototype._setRejectionIsUnhandled =
+function Promise$_setRejectionIsUnhandled() {
+ this._bitField = this._bitField | 2097152;
+};
+
+Promise.prototype._unsetRejectionIsUnhandled =
+function Promise$_unsetRejectionIsUnhandled() {
+ this._bitField = this._bitField & (~2097152);
+};
+
+Promise.prototype._isRejectionUnhandled =
+function Promise$_isRejectionUnhandled() {
+ return (this._bitField & 2097152) > 0;
+};
+
+Promise.prototype._setCarriedStackTrace =
+function Promise$_setCarriedStackTrace(capturedTrace) {
+ this._bitField = this._bitField | 1048576;
+ this._fulfillmentHandler0 = capturedTrace;
+};
+
+Promise.prototype._unsetCarriedStackTrace =
+function Promise$_unsetCarriedStackTrace() {
+ this._bitField = this._bitField & (~1048576);
+ this._fulfillmentHandler0 = void 0;
+};
+
+Promise.prototype._isCarryingStackTrace =
+function Promise$_isCarryingStackTrace() {
+ return (this._bitField & 1048576) > 0;
+};
+
+Promise.prototype._getCarriedStackTrace =
+function Promise$_getCarriedStackTrace() {
+ return this._isCarryingStackTrace()
+ ? this._fulfillmentHandler0
+ : void 0;
+};
+
+Promise.prototype._receiverAt = function Promise$_receiverAt(index) {
+ var ret;
+ if (index === 0) {
+ ret = this._receiver0;
+ }
+ else {
+ ret = this[index + 4 - 5];
+ }
+ if (this._isBound() && ret === void 0) {
+ return this._boundTo;
+ }
+ return ret;
+};
+
+Promise.prototype._promiseAt = function Promise$_promiseAt(index) {
+ if (index === 0) return this._promise0;
+ return this[index + 3 - 5];
+};
+
+Promise.prototype._fulfillmentHandlerAt =
+function Promise$_fulfillmentHandlerAt(index) {
+ if (index === 0) return this._fulfillmentHandler0;
+ return this[index + 0 - 5];
+};
+
+Promise.prototype._rejectionHandlerAt =
+function Promise$_rejectionHandlerAt(index) {
+ if (index === 0) return this._rejectionHandler0;
+ return this[index + 1 - 5];
+};
+
+Promise.prototype._unsetAt = function Promise$_unsetAt(index) {
+ if (index === 0) {
+ this._rejectionHandler0 =
+ this._progressHandler0 =
+ this._promise0 =
+ this._receiver0 = void 0;
+ if (!this._isCarryingStackTrace()) {
+ this._fulfillmentHandler0 = void 0;
+ }
+ }
+ else {
+ this[index - 5 + 0] =
+ this[index - 5 + 1] =
+ this[index - 5 + 2] =
+ this[index - 5 + 3] =
+ this[index - 5 + 4] = void 0;
+ }
+};
+
+Promise.prototype._resolveFromResolver =
+function Promise$_resolveFromResolver(resolver) {
+ var promise = this;
+ var localDebugging = debugging;
+ if (localDebugging) {
+ this._setTrace(this._resolveFromResolver, void 0);
+ this._pushContext();
+ }
+ function Promise$_resolver(val) {
+ if (promise._tryFollow(val)) {
+ return;
+ }
+ promise._fulfill(val);
+ }
+ function Promise$_rejecter(val) {
+ var trace = canAttach(val) ? val : new Error(val + "");
+ promise._attachExtraTrace(trace);
+ markAsOriginatingFromRejection(val);
+ promise._reject(val, trace === val ? void 0 : trace);
+ }
+ var r = tryCatch2(resolver, void 0, Promise$_resolver, Promise$_rejecter);
+ if (localDebugging) this._popContext();
+
+ if (r !== void 0 && r === errorObj) {
+ var e = r.e;
+ var trace = canAttach(e) ? e : new Error(e + "");
+ promise._reject(e, trace);
+ }
+};
+
+Promise.prototype._addCallbacks = function Promise$_addCallbacks(
+ fulfill,
+ reject,
+ progress,
+ promise,
+ receiver
+) {
+ var index = this._length();
+
+ if (index >= 1048575 - 5) {
+ index = 0;
+ this._setLength(0);
+ }
+
+ if (index === 0) {
+ this._promise0 = promise;
+ if (receiver !== void 0) this._receiver0 = receiver;
+ if (typeof fulfill === "function" && !this._isCarryingStackTrace())
+ this._fulfillmentHandler0 = fulfill;
+ if (typeof reject === "function") this._rejectionHandler0 = reject;
+ if (typeof progress === "function") this._progressHandler0 = progress;
+ }
+ else {
+ var i = index - 5;
+ this[i + 3] = promise;
+ this[i + 4] = receiver;
+ this[i + 0] = typeof fulfill === "function"
+ ? fulfill : void 0;
+ this[i + 1] = typeof reject === "function"
+ ? reject : void 0;
+ this[i + 2] = typeof progress === "function"
+ ? progress : void 0;
+ }
+ this._setLength(index + 5);
+ return index;
+};
+
+
+
+Promise.prototype._setBoundTo = function Promise$_setBoundTo(obj) {
+ if (obj !== void 0) {
+ this._bitField = this._bitField | 8388608;
+ this._boundTo = obj;
+ }
+ else {
+ this._bitField = this._bitField & (~8388608);
+ }
+};
+
+Promise.prototype._isBound = function Promise$_isBound() {
+ return (this._bitField & 8388608) === 8388608;
+};
+
+Promise.prototype._spreadSlowCase =
+function Promise$_spreadSlowCase(targetFn, promise, values, boundTo) {
+ var promiseForAll =
+ Promise$_CreatePromiseArray
+ (values, PromiseArray, this._spreadSlowCase, boundTo)
+ .promise()
+ ._then(function() {
+ return targetFn.apply(boundTo, arguments);
+ }, void 0, void 0, APPLY, void 0, this._spreadSlowCase);
+
+ promise._follow(promiseForAll);
+};
+
+Promise.prototype._callSpread =
+function Promise$_callSpread(handler, promise, value, localDebugging) {
+ var boundTo = this._isBound() ? this._boundTo : void 0;
+ if (isArray(value)) {
+ var caller = this._settlePromiseFromHandler;
+ for (var i = 0, len = value.length; i < len; ++i) {
+ if (isPromise(Promise._cast(value[i], caller, void 0))) {
+ this._spreadSlowCase(handler, promise, value, boundTo);
+ return;
+ }
+ }
+ }
+ if (localDebugging) promise._pushContext();
+ return tryCatchApply(handler, value, boundTo);
+};
+
+Promise.prototype._callHandler =
+function Promise$_callHandler(
+ handler, receiver, promise, value, localDebugging) {
+ var x;
+ if (receiver === APPLY && !this.isRejected()) {
+ x = this._callSpread(handler, promise, value, localDebugging);
+ }
+ else {
+ if (localDebugging) promise._pushContext();
+ x = tryCatch1(handler, receiver, value);
+ }
+ if (localDebugging) promise._popContext();
+ return x;
+};
+
+Promise.prototype._settlePromiseFromHandler =
+function Promise$_settlePromiseFromHandler(
+ handler, receiver, value, promise
+) {
+ if (!isPromise(promise)) {
+ handler.call(receiver, value, promise);
+ return;
+ }
+
+ var localDebugging = debugging;
+ var x = this._callHandler(handler, receiver,
+ promise, value, localDebugging);
+
+ if (promise._isFollowing()) return;
+
+ if (x === errorObj || x === promise || x === NEXT_FILTER) {
+ var err = x === promise
+ ? makeSelfResolutionError()
+ : x.e;
+ var trace = canAttach(err) ? err : new Error(err + "");
+ if (x !== NEXT_FILTER) promise._attachExtraTrace(trace);
+ promise._rejectUnchecked(err, trace);
+ }
+ else {
+ var castValue = Promise._cast(x,
+ localDebugging ? this._settlePromiseFromHandler : void 0,
+ promise);
+
+ if (isPromise(castValue)) {
+ if (castValue.isRejected() &&
+ !castValue._isCarryingStackTrace() &&
+ !canAttach(castValue._settledValue)) {
+ var trace = new Error(castValue._settledValue + "");
+ promise._attachExtraTrace(trace);
+ castValue._setCarriedStackTrace(trace);
+ }
+ promise._follow(castValue);
+ if (castValue._cancellable()) {
+ promise._cancellationParent = castValue;
+ promise._setCancellable();
+ }
+ }
+ else {
+ promise._fulfillUnchecked(x);
+ }
+ }
+};
+
+Promise.prototype._follow =
+function Promise$_follow(promise) {
+ this._setFollowing();
+
+ if (promise.isPending()) {
+ if (promise._cancellable() ) {
+ this._cancellationParent = promise;
+ this._setCancellable();
+ }
+ promise._proxyPromise(this);
+ }
+ else if (promise.isFulfilled()) {
+ this._fulfillUnchecked(promise._settledValue);
+ }
+ else {
+ this._rejectUnchecked(promise._settledValue,
+ promise._getCarriedStackTrace());
+ }
+
+ if (promise._isRejectionUnhandled()) promise._unsetRejectionIsUnhandled();
+
+ if (debugging &&
+ promise._traceParent == null) {
+ promise._traceParent = this;
+ }
+};
+
+Promise.prototype._tryFollow =
+function Promise$_tryFollow(value) {
+ if (this._isFollowingOrFulfilledOrRejected() ||
+ value === this) {
+ return false;
+ }
+ var maybePromise = Promise._cast(value, this._tryFollow, void 0);
+ if (!isPromise(maybePromise)) {
+ return false;
+ }
+ this._follow(maybePromise);
+ return true;
+};
+
+Promise.prototype._resetTrace = function Promise$_resetTrace(caller) {
+ if (debugging) {
+ var context = this._peekContext();
+ var isTopLevel = context === void 0;
+ this._trace = new CapturedTrace(
+ typeof caller === "function"
+ ? caller
+ : this._resetTrace,
+ isTopLevel
+ );
+ }
+};
+
+Promise.prototype._setTrace = function Promise$_setTrace(caller, parent) {
+ if (debugging) {
+ var context = this._peekContext();
+ this._traceParent = context;
+ var isTopLevel = context === void 0;
+ if (parent !== void 0 &&
+ parent._traceParent === context) {
+ this._trace = parent._trace;
+ }
+ else {
+ this._trace = new CapturedTrace(
+ typeof caller === "function"
+ ? caller
+ : this._setTrace,
+ isTopLevel
+ );
+ }
+ }
+ return this;
+};
+
+Promise.prototype._attachExtraTrace =
+function Promise$_attachExtraTrace(error) {
+ if (debugging) {
+ var promise = this;
+ var stack = error.stack;
+ stack = typeof stack === "string"
+ ? stack.split("\n") : [];
+ var headerLineCount = 1;
+
+ while(promise != null &&
+ promise._trace != null) {
+ stack = CapturedTrace.combine(
+ stack,
+ promise._trace.stack.split("\n")
+ );
+ promise = promise._traceParent;
+ }
+
+ var max = Error.stackTraceLimit + headerLineCount;
+ var len = stack.length;
+ if (len > max) {
+ stack.length = max;
+ }
+ if (stack.length <= headerLineCount) {
+ error.stack = "(No stack trace)";
+ }
+ else {
+ error.stack = stack.join("\n");
+ }
+ }
+};
+
+Promise.prototype._cleanValues = function Promise$_cleanValues() {
+ if (this._cancellable()) {
+ this._cancellationParent = void 0;
+ }
+};
+
+Promise.prototype._fulfill = function Promise$_fulfill(value) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._fulfillUnchecked(value);
+};
+
+Promise.prototype._reject =
+function Promise$_reject(reason, carriedStackTrace) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._rejectUnchecked(reason, carriedStackTrace);
+};
+
+Promise.prototype._settlePromiseAt = function Promise$_settlePromiseAt(index) {
+ var handler = this.isFulfilled()
+ ? this._fulfillmentHandlerAt(index)
+ : this._rejectionHandlerAt(index);
+
+ var value = this._settledValue;
+ var receiver = this._receiverAt(index);
+ var promise = this._promiseAt(index);
+
+ if (typeof handler === "function") {
+ this._settlePromiseFromHandler(handler, receiver, value, promise);
+ }
+ else {
+ var done = false;
+ var isFulfilled = this.isFulfilled();
+ if (receiver !== void 0) {
+ if (receiver instanceof Promise &&
+ receiver._isProxied()) {
+ receiver._unsetProxied();
+
+ if (isFulfilled) receiver._fulfillUnchecked(value);
+ else receiver._rejectUnchecked(value,
+ this._getCarriedStackTrace());
+ done = true;
+ }
+ else if (isPromiseArrayProxy(receiver, promise)) {
+
+ if (isFulfilled) receiver._promiseFulfilled(value, promise);
+ else receiver._promiseRejected(value, promise);
+
+ done = true;
+ }
+ }
+
+ if (!done) {
+
+ if (isFulfilled) promise._fulfill(value);
+ else promise._reject(value, this._getCarriedStackTrace());
+
+ }
+ }
+
+ if (index >= 256) {
+ this._queueGC();
+ }
+};
+
+Promise.prototype._isProxied = function Promise$_isProxied() {
+ return (this._bitField & 4194304) === 4194304;
+};
+
+Promise.prototype._setProxied = function Promise$_setProxied() {
+ this._bitField = this._bitField | 4194304;
+};
+
+Promise.prototype._unsetProxied = function Promise$_unsetProxied() {
+ this._bitField = this._bitField & (~4194304);
+};
+
+Promise.prototype._isGcQueued = function Promise$_isGcQueued() {
+ return (this._bitField & -1073741824) === -1073741824;
+};
+
+Promise.prototype._setGcQueued = function Promise$_setGcQueued() {
+ this._bitField = this._bitField | -1073741824;
+};
+
+Promise.prototype._unsetGcQueued = function Promise$_unsetGcQueued() {
+ this._bitField = this._bitField & (~-1073741824);
+};
+
+Promise.prototype._queueGC = function Promise$_queueGC() {
+ if (this._isGcQueued()) return;
+ this._setGcQueued();
+ async.invokeLater(this._gc, this, void 0);
+};
+
+Promise.prototype._gc = function Promise$gc() {
+ var len = this._length();
+ this._unsetAt(0);
+ for (var i = 0; i < len; i++) {
+ delete this[i];
+ }
+ this._setLength(0);
+ this._unsetGcQueued();
+};
+
+Promise.prototype._queueSettleAt = function Promise$_queueSettleAt(index) {
+ if (this._isRejectionUnhandled()) this._unsetRejectionIsUnhandled();
+ async.invoke(this._settlePromiseAt, this, index);
+};
+
+Promise.prototype._fulfillUnchecked =
+function Promise$_fulfillUnchecked(value) {
+ if (!this.isPending()) return;
+ if (value === this) {
+ var err = makeSelfResolutionError();
+ this._attachExtraTrace(err);
+ return this._rejectUnchecked(err, void 0);
+ }
+ this._cleanValues();
+ this._setFulfilled();
+ this._settledValue = value;
+ var len = this._length();
+
+ if (len > 0) {
+ async.invoke(this._fulfillPromises, this, len);
+ }
+};
+
+Promise.prototype._rejectUncheckedCheckError =
+function Promise$_rejectUncheckedCheckError(reason) {
+ var trace = canAttach(reason) ? reason : new Error(reason + "");
+ this._rejectUnchecked(reason, trace === reason ? void 0 : trace);
+};
+
+Promise.prototype._rejectUnchecked =
+function Promise$_rejectUnchecked(reason, trace) {
+ if (!this.isPending()) return;
+ if (reason === this) {
+ var err = makeSelfResolutionError();
+ this._attachExtraTrace(err);
+ return this._rejectUnchecked(err);
+ }
+ this._cleanValues();
+ this._setRejected();
+ this._settledValue = reason;
+
+ if (this._isFinal()) {
+ async.invokeLater(thrower, void 0, trace === void 0 ? reason : trace);
+ return;
+ }
+ var len = this._length();
+
+ if (trace !== void 0) this._setCarriedStackTrace(trace);
+
+ if (len > 0) {
+ async.invoke(this._rejectPromises, this, null);
+ }
+ else {
+ this._ensurePossibleRejectionHandled();
+ }
+};
+
+Promise.prototype._rejectPromises = function Promise$_rejectPromises() {
+ var len = this._length();
+ for (var i = 0; i < len; i+= 5) {
+ this._settlePromiseAt(i);
+ }
+ this._unsetCarriedStackTrace();
+};
+
+Promise.prototype._fulfillPromises = function Promise$_fulfillPromises(len) {
+ len = this._length();
+ for (var i = 0; i < len; i+= 5) {
+ this._settlePromiseAt(i);
+ }
+};
+
+Promise.prototype._ensurePossibleRejectionHandled =
+function Promise$_ensurePossibleRejectionHandled() {
+ this._setRejectionIsUnhandled();
+ if (CapturedTrace.possiblyUnhandledRejection !== void 0) {
+ async.invokeLater(this._notifyUnhandledRejection, this, void 0);
+ }
+};
+
+Promise.prototype._notifyUnhandledRejection =
+function Promise$_notifyUnhandledRejection() {
+ if (this._isRejectionUnhandled()) {
+ var reason = this._settledValue;
+ var trace = this._getCarriedStackTrace();
+
+ this._unsetRejectionIsUnhandled();
+
+ if (trace !== void 0) {
+ this._unsetCarriedStackTrace();
+ reason = trace;
+ }
+ if (typeof CapturedTrace.possiblyUnhandledRejection === "function") {
+ CapturedTrace.possiblyUnhandledRejection(reason, this);
+ }
+ }
+};
+
+var contextStack = [];
+Promise.prototype._peekContext = function Promise$_peekContext() {
+ var lastIndex = contextStack.length - 1;
+ if (lastIndex >= 0) {
+ return contextStack[lastIndex];
+ }
+ return void 0;
+
+};
+
+Promise.prototype._pushContext = function Promise$_pushContext() {
+ if (!debugging) return;
+ contextStack.push(this);
+};
+
+Promise.prototype._popContext = function Promise$_popContext() {
+ if (!debugging) return;
+ contextStack.pop();
+};
+
+function Promise$_CreatePromiseArray(
+ promises, PromiseArrayConstructor, caller, boundTo) {
+
+ var list = null;
+ if (isArray(promises)) {
+ list = promises;
+ }
+ else {
+ list = Promise._cast(promises, caller, void 0);
+ if (list !== promises) {
+ list._setBoundTo(boundTo);
+ }
+ else if (!isPromise(list)) {
+ list = null;
+ }
+ }
+ if (list !== null) {
+ return new PromiseArrayConstructor(
+ list,
+ typeof caller === "function"
+ ? caller
+ : Promise$_CreatePromiseArray,
+ boundTo
+ );
+ }
+ return {
+ promise: function() {return apiRejection("expecting an array, a promise or a thenable");}
+ };
+}
+
+var old = global.Promise;
+
+Promise.noConflict = function() {
+ if (global.Promise === Promise) {
+ global.Promise = old;
+ }
+ return Promise;
+};
+
+if (!CapturedTrace.isSupported()) {
+ Promise.longStackTraces = function(){};
+ debugging = false;
+}
+
+Promise._makeSelfResolutionError = makeSelfResolutionError;
+require("./finally.js")(Promise, NEXT_FILTER);
+require("./direct_resolve.js")(Promise);
+require("./thenables.js")(Promise, INTERNAL);
+Promise.RangeError = RangeError;
+Promise.CancellationError = CancellationError;
+Promise.TimeoutError = TimeoutError;
+Promise.TypeError = TypeError;
+Promise.RejectionError = RejectionError;
+
+util.toFastProperties(Promise);
+util.toFastProperties(Promise.prototype);
+require('./timers.js')(Promise,INTERNAL);
+require('./synchronous_inspection.js')(Promise);
+require('./any.js')(Promise,Promise$_CreatePromiseArray,PromiseArray);
+require('./race.js')(Promise,INTERNAL);
+require('./call_get.js')(Promise);
+require('./filter.js')(Promise,Promise$_CreatePromiseArray,PromiseArray,apiRejection);
+require('./generators.js')(Promise,apiRejection,INTERNAL);
+require('./map.js')(Promise,Promise$_CreatePromiseArray,PromiseArray,apiRejection);
+require('./nodeify.js')(Promise);
+require('./promisify.js')(Promise,INTERNAL);
+require('./props.js')(Promise,PromiseArray);
+require('./reduce.js')(Promise,Promise$_CreatePromiseArray,PromiseArray,apiRejection,INTERNAL);
+require('./settle.js')(Promise,Promise$_CreatePromiseArray,PromiseArray);
+require('./some.js')(Promise,Promise$_CreatePromiseArray,PromiseArray,apiRejection);
+require('./progress.js')(Promise,isPromiseArrayProxy);
+require('./cancel.js')(Promise,INTERNAL);
+
+Promise.prototype = Promise.prototype;
+return Promise;
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_array.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_array.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_array.js
new file mode 100644
index 0000000..377f0ec
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_array.js
@@ -0,0 +1,233 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var canAttach = require("./errors.js").canAttach;
+var util = require("./util.js");
+var async = require("./async.js");
+var hasOwn = {}.hasOwnProperty;
+var isArray = util.isArray;
+
+function toResolutionValue(val) {
+ switch(val) {
+ case -1: return void 0;
+ case -2: return [];
+ case -3: return {};
+ }
+}
+
+function PromiseArray(values, caller, boundTo) {
+ var promise = this._promise = new Promise(INTERNAL);
+ var parent = void 0;
+ if (Promise.is(values)) {
+ parent = values;
+ if (values._cancellable()) {
+ promise._setCancellable();
+ promise._cancellationParent = values;
+ }
+ if (values._isBound()) {
+ promise._setBoundTo(boundTo);
+ }
+ }
+ promise._setTrace(caller, parent);
+ this._values = values;
+ this._length = 0;
+ this._totalResolved = 0;
+ this._init(void 0, -2);
+}
+PromiseArray.PropertiesPromiseArray = function() {};
+
+PromiseArray.prototype.length = function PromiseArray$length() {
+ return this._length;
+};
+
+PromiseArray.prototype.promise = function PromiseArray$promise() {
+ return this._promise;
+};
+
+PromiseArray.prototype._init =
+function PromiseArray$_init(_, resolveValueIfEmpty) {
+ var values = this._values;
+ if (Promise.is(values)) {
+ if (values.isFulfilled()) {
+ values = values._settledValue;
+ if (!isArray(values)) {
+ var err = new Promise.TypeError("expecting an array, a promise or a thenable");
+ this.__hardReject__(err);
+ return;
+ }
+ this._values = values;
+ }
+ else if (values.isPending()) {
+ values._then(
+ this._init,
+ this._reject,
+ void 0,
+ this,
+ resolveValueIfEmpty,
+ this.constructor
+ );
+ return;
+ }
+ else {
+ this._reject(values._settledValue);
+ return;
+ }
+ }
+
+ if (values.length === 0) {
+ this._resolve(toResolutionValue(resolveValueIfEmpty));
+ return;
+ }
+ var len = values.length;
+ var newLen = len;
+ var newValues;
+ if (this instanceof PromiseArray.PropertiesPromiseArray) {
+ newValues = this._values;
+ }
+ else {
+ newValues = new Array(len);
+ }
+ var isDirectScanNeeded = false;
+ for (var i = 0; i < len; ++i) {
+ var promise = values[i];
+ if (promise === void 0 && !hasOwn.call(values, i)) {
+ newLen--;
+ continue;
+ }
+ var maybePromise = Promise._cast(promise, void 0, void 0);
+ if (maybePromise instanceof Promise) {
+ if (maybePromise.isPending()) {
+ maybePromise._proxyPromiseArray(this, i);
+ }
+ else {
+ maybePromise._unsetRejectionIsUnhandled();
+ isDirectScanNeeded = true;
+ }
+ }
+ else {
+ isDirectScanNeeded = true;
+ }
+ newValues[i] = maybePromise;
+ }
+ if (newLen === 0) {
+ if (resolveValueIfEmpty === -2) {
+ this._resolve(newValues);
+ }
+ else {
+ this._resolve(toResolutionValue(resolveValueIfEmpty));
+ }
+ return;
+ }
+ this._values = newValues;
+ this._length = newLen;
+ if (isDirectScanNeeded) {
+ var scanMethod = newLen === len
+ ? this._scanDirectValues
+ : this._scanDirectValuesHoled;
+ async.invoke(scanMethod, this, len);
+ }
+};
+
+PromiseArray.prototype._settlePromiseAt =
+function PromiseArray$_settlePromiseAt(index) {
+ var value = this._values[index];
+ if (!Promise.is(value)) {
+ this._promiseFulfilled(value, index);
+ }
+ else if (value.isFulfilled()) {
+ this._promiseFulfilled(value._settledValue, index);
+ }
+ else if (value.isRejected()) {
+ this._promiseRejected(value._settledValue, index);
+ }
+};
+
+PromiseArray.prototype._scanDirectValuesHoled =
+function PromiseArray$_scanDirectValuesHoled(len) {
+ for (var i = 0; i < len; ++i) {
+ if (this._isResolved()) {
+ break;
+ }
+ if (hasOwn.call(this._values, i)) {
+ this._settlePromiseAt(i);
+ }
+ }
+};
+
+PromiseArray.prototype._scanDirectValues =
+function PromiseArray$_scanDirectValues(len) {
+ for (var i = 0; i < len; ++i) {
+ if (this._isResolved()) {
+ break;
+ }
+ this._settlePromiseAt(i);
+ }
+};
+
+PromiseArray.prototype._isResolved = function PromiseArray$_isResolved() {
+ return this._values === null;
+};
+
+PromiseArray.prototype._resolve = function PromiseArray$_resolve(value) {
+ this._values = null;
+ this._promise._fulfill(value);
+};
+
+PromiseArray.prototype.__hardReject__ =
+PromiseArray.prototype._reject = function PromiseArray$_reject(reason) {
+ this._values = null;
+ var trace = canAttach(reason) ? reason : new Error(reason + "");
+ this._promise._attachExtraTrace(trace);
+ this._promise._reject(reason, trace);
+};
+
+PromiseArray.prototype._promiseProgressed =
+function PromiseArray$_promiseProgressed(progressValue, index) {
+ if (this._isResolved()) return;
+ this._promise._progress({
+ index: index,
+ value: progressValue
+ });
+};
+
+
+PromiseArray.prototype._promiseFulfilled =
+function PromiseArray$_promiseFulfilled(value, index) {
+ if (this._isResolved()) return;
+ this._values[index] = value;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ this._resolve(this._values);
+ }
+};
+
+PromiseArray.prototype._promiseRejected =
+function PromiseArray$_promiseRejected(reason, index) {
+ if (this._isResolved()) return;
+ this._totalResolved++;
+ this._reject(reason);
+};
+
+return PromiseArray;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_inspection.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_inspection.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_inspection.js
new file mode 100644
index 0000000..0aa233b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_inspection.js
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var TypeError = require("./errors.js").TypeError;
+
+function PromiseInspection(promise) {
+ if (promise !== void 0) {
+ this._bitField = promise._bitField;
+ this._settledValue = promise.isResolved()
+ ? promise._settledValue
+ : void 0;
+ }
+ else {
+ this._bitField = 0;
+ this._settledValue = void 0;
+ }
+}
+PromiseInspection.prototype.isFulfilled =
+function PromiseInspection$isFulfilled() {
+ return (this._bitField & 268435456) > 0;
+};
+
+PromiseInspection.prototype.isRejected =
+function PromiseInspection$isRejected() {
+ return (this._bitField & 134217728) > 0;
+};
+
+PromiseInspection.prototype.isPending = function PromiseInspection$isPending() {
+ return (this._bitField & 402653184) === 0;
+};
+
+PromiseInspection.prototype.value = function PromiseInspection$value() {
+ if (!this.isFulfilled()) {
+ throw new TypeError("cannot get fulfillment value of a non-fulfilled promise");
+ }
+ return this._settledValue;
+};
+
+PromiseInspection.prototype.error = function PromiseInspection$error() {
+ if (!this.isRejected()) {
+ throw new TypeError("cannot get rejection reason of a non-rejected promise");
+ }
+ return this._settledValue;
+};
+
+module.exports = PromiseInspection;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_resolver.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_resolver.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_resolver.js
new file mode 100644
index 0000000..53ead00
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_resolver.js
@@ -0,0 +1,152 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var util = require("./util.js");
+var maybeWrapAsError = util.maybeWrapAsError;
+var errors = require("./errors.js");
+var TimeoutError = errors.TimeoutError;
+var RejectionError = errors.RejectionError;
+var async = require("./async.js");
+var haveGetters = util.haveGetters;
+var es5 = require("./es5.js");
+
+function isUntypedError(obj) {
+ return obj instanceof Error &&
+ es5.getPrototypeOf(obj) === Error.prototype;
+}
+
+function wrapAsRejectionError(obj) {
+ var ret;
+ if (isUntypedError(obj)) {
+ ret = new RejectionError(obj);
+ }
+ else {
+ ret = obj;
+ }
+ errors.markAsOriginatingFromRejection(ret);
+ return ret;
+}
+
+function nodebackForPromise(promise) {
+ function PromiseResolver$_callback(err, value) {
+ if (promise === null) return;
+
+ if (err) {
+ var wrapped = wrapAsRejectionError(maybeWrapAsError(err));
+ promise._attachExtraTrace(wrapped);
+ promise._reject(wrapped);
+ }
+ else {
+ if (arguments.length > 2) {
+ var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
+ promise._fulfill(args);
+ }
+ else {
+ promise._fulfill(value);
+ }
+ }
+
+ promise = null;
+ }
+ return PromiseResolver$_callback;
+}
+
+
+var PromiseResolver;
+if (!haveGetters) {
+ PromiseResolver = function PromiseResolver(promise) {
+ this.promise = promise;
+ this.asCallback = nodebackForPromise(promise);
+ this.callback = this.asCallback;
+ };
+}
+else {
+ PromiseResolver = function PromiseResolver(promise) {
+ this.promise = promise;
+ };
+}
+if (haveGetters) {
+ var prop = {
+ get: function() {
+ return nodebackForPromise(this.promise);
+ }
+ };
+ es5.defineProperty(PromiseResolver.prototype, "asCallback", prop);
+ es5.defineProperty(PromiseResolver.prototype, "callback", prop);
+}
+
+PromiseResolver._nodebackForPromise = nodebackForPromise;
+
+PromiseResolver.prototype.toString = function PromiseResolver$toString() {
+ return "[object PromiseResolver]";
+};
+
+PromiseResolver.prototype.resolve =
+PromiseResolver.prototype.fulfill = function PromiseResolver$resolve(value) {
+ var promise = this.promise;
+ if (promise._tryFollow(value)) {
+ return;
+ }
+ async.invoke(promise._fulfill, promise, value);
+};
+
+PromiseResolver.prototype.reject = function PromiseResolver$reject(reason) {
+ var promise = this.promise;
+ errors.markAsOriginatingFromRejection(reason);
+ var trace = errors.canAttach(reason) ? reason : new Error(reason + "");
+ promise._attachExtraTrace(trace);
+ async.invoke(promise._reject, promise, reason);
+ if (trace !== reason) {
+ async.invoke(this._setCarriedStackTrace, this, trace);
+ }
+};
+
+PromiseResolver.prototype.progress =
+function PromiseResolver$progress(value) {
+ async.invoke(this.promise._progress, this.promise, value);
+};
+
+PromiseResolver.prototype.cancel = function PromiseResolver$cancel() {
+ async.invoke(this.promise.cancel, this.promise, void 0);
+};
+
+PromiseResolver.prototype.timeout = function PromiseResolver$timeout() {
+ this.reject(new TimeoutError("timeout"));
+};
+
+PromiseResolver.prototype.isResolved = function PromiseResolver$isResolved() {
+ return this.promise.isResolved();
+};
+
+PromiseResolver.prototype.toJSON = function PromiseResolver$toJSON() {
+ return this.promise.toJSON();
+};
+
+PromiseResolver.prototype._setCarriedStackTrace =
+function PromiseResolver$_setCarriedStackTrace(trace) {
+ if (this.promise.isRejected()) {
+ this.promise._setCarriedStackTrace(trace);
+ }
+};
+
+module.exports = PromiseResolver;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_spawn.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_spawn.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_spawn.js
new file mode 100644
index 0000000..2d6525f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promise_spawn.js
@@ -0,0 +1,131 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var errors = require("./errors.js");
+var TypeError = errors.TypeError;
+var util = require("./util.js");
+var isArray = util.isArray;
+var errorObj = util.errorObj;
+var tryCatch1 = util.tryCatch1;
+var yieldHandlers = [];
+
+function promiseFromYieldHandler(value) {
+ var _yieldHandlers = yieldHandlers;
+ var _errorObj = errorObj;
+ var _Promise = Promise;
+ var len = _yieldHandlers.length;
+ for (var i = 0; i < len; ++i) {
+ var result = tryCatch1(_yieldHandlers[i], void 0, value);
+ if (result === _errorObj) {
+ return _Promise.reject(_errorObj.e);
+ }
+ var maybePromise = _Promise._cast(result,
+ promiseFromYieldHandler, void 0);
+ if (maybePromise instanceof _Promise) return maybePromise;
+ }
+ return null;
+}
+
+function PromiseSpawn(generatorFunction, receiver, caller) {
+ var promise = this._promise = new Promise(INTERNAL);
+ promise._setTrace(caller, void 0);
+ this._generatorFunction = generatorFunction;
+ this._receiver = receiver;
+ this._generator = void 0;
+}
+
+PromiseSpawn.prototype.promise = function PromiseSpawn$promise() {
+ return this._promise;
+};
+
+PromiseSpawn.prototype._run = function PromiseSpawn$_run() {
+ this._generator = this._generatorFunction.call(this._receiver);
+ this._receiver =
+ this._generatorFunction = void 0;
+ this._next(void 0);
+};
+
+PromiseSpawn.prototype._continue = function PromiseSpawn$_continue(result) {
+ if (result === errorObj) {
+ this._generator = void 0;
+ var trace = errors.canAttach(result.e)
+ ? result.e : new Error(result.e + "");
+ this._promise._attachExtraTrace(trace);
+ this._promise._reject(result.e, trace);
+ return;
+ }
+
+ var value = result.value;
+ if (result.done === true) {
+ this._generator = void 0;
+ if (!this._promise._tryFollow(value)) {
+ this._promise._fulfill(value);
+ }
+ }
+ else {
+ var maybePromise = Promise._cast(value, PromiseSpawn$_continue, void 0);
+ if (!(maybePromise instanceof Promise)) {
+ if (isArray(maybePromise)) {
+ maybePromise = Promise.all(maybePromise);
+ }
+ else {
+ maybePromise = promiseFromYieldHandler(maybePromise);
+ }
+ if (maybePromise === null) {
+ this._throw(new TypeError("A value was yielded that could not be treated as a promise"));
+ return;
+ }
+ }
+ maybePromise._then(
+ this._next,
+ this._throw,
+ void 0,
+ this,
+ null,
+ void 0
+ );
+ }
+};
+
+PromiseSpawn.prototype._throw = function PromiseSpawn$_throw(reason) {
+ if (errors.canAttach(reason))
+ this._promise._attachExtraTrace(reason);
+ this._continue(
+ tryCatch1(this._generator["throw"], this._generator, reason)
+ );
+};
+
+PromiseSpawn.prototype._next = function PromiseSpawn$_next(value) {
+ this._continue(
+ tryCatch1(this._generator.next, this._generator, value)
+ );
+};
+
+PromiseSpawn.addYieldHandler = function PromiseSpawn$AddYieldHandler(fn) {
+ if (typeof fn !== "function") throw new TypeError("fn must be a function");
+ yieldHandlers.push(fn);
+};
+
+return PromiseSpawn;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promisify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promisify.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promisify.js
new file mode 100644
index 0000000..a550fd0
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/promisify.js
@@ -0,0 +1,278 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var THIS = {};
+var util = require("./util.js");
+var es5 = require("./es5.js");
+var nodebackForPromise = require("./promise_resolver.js")
+ ._nodebackForPromise;
+var withAppended = util.withAppended;
+var maybeWrapAsError = util.maybeWrapAsError;
+var canEvaluate = util.canEvaluate;
+var notEnumerableProp = util.notEnumerableProp;
+var deprecated = util.deprecated;
+var roriginal = new RegExp("__beforePromisified__" + "$");
+var hasProp = {}.hasOwnProperty;
+function isPromisified(fn) {
+ return fn.__isPromisified__ === true;
+}
+var inheritedMethods = (function() {
+ if (es5.isES5) {
+ var create = Object.create;
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
+ return function(cur) {
+ var original = cur;
+ var ret = [];
+ var visitedKeys = create(null);
+ while (cur !== null) {
+ var keys = es5.keys(cur);
+ for (var i = 0, len = keys.length; i < len; ++i) {
+ var key = keys[i];
+ if (visitedKeys[key] ||
+ roriginal.test(key) ||
+ hasProp.call(original, key + "__beforePromisified__")
+ ) {
+ continue;
+ }
+ visitedKeys[key] = true;
+ var desc = getOwnPropertyDescriptor(cur, key);
+ if (desc != null &&
+ typeof desc.value === "function" &&
+ !isPromisified(desc.value)) {
+ ret.push(key, desc.value);
+ }
+ }
+ cur = es5.getPrototypeOf(cur);
+ }
+ return ret;
+ };
+ }
+ else {
+ return function(obj) {
+ var ret = [];
+ /*jshint forin:false */
+ for (var key in obj) {
+ if (roriginal.test(key) ||
+ hasProp.call(obj, key + "__beforePromisified__")) {
+ continue;
+ }
+ var fn = obj[key];
+ if (typeof fn === "function" &&
+ !isPromisified(fn)) {
+ ret.push(key, fn);
+ }
+ }
+ return ret;
+ };
+ }
+})();
+
+function switchCaseArgumentOrder(likelyArgumentCount) {
+ var ret = [likelyArgumentCount];
+ var min = Math.max(0, likelyArgumentCount - 1 - 5);
+ for(var i = likelyArgumentCount - 1; i >= min; --i) {
+ if (i === likelyArgumentCount) continue;
+ ret.push(i);
+ }
+ for(var i = likelyArgumentCount + 1; i <= 5; ++i) {
+ ret.push(i);
+ }
+ return ret;
+}
+
+function parameterDeclaration(parameterCount) {
+ var ret = new Array(parameterCount);
+ for(var i = 0; i < ret.length; ++i) {
+ ret[i] = "_arg" + i;
+ }
+ return ret.join(", ");
+}
+
+function parameterCount(fn) {
+ if (typeof fn.length === "number") {
+ return Math.max(Math.min(fn.length, 1023 + 1), 0);
+ }
+ return 0;
+}
+
+function propertyAccess(id) {
+ var rident = /^[a-z$_][a-z$_0-9]*$/i;
+
+ if (rident.test(id)) {
+ return "." + id;
+ }
+ else return "['" + id.replace(/(['\\])/g, "\\$1") + "']";
+}
+
+function makeNodePromisifiedEval(callback, receiver, originalName, fn) {
+ var newParameterCount = Math.max(0, parameterCount(fn) - 1);
+ var argumentOrder = switchCaseArgumentOrder(newParameterCount);
+
+ var callbackName = (typeof originalName === "string" ?
+ originalName + "Async" :
+ "promisified");
+
+ function generateCallForArgumentCount(count) {
+ var args = new Array(count);
+ for (var i = 0, len = args.length; i < len; ++i) {
+ args[i] = "arguments[" + i + "]";
+ }
+ var comma = count > 0 ? "," : "";
+
+ if (typeof callback === "string" &&
+ receiver === THIS) {
+ return "this" + propertyAccess(callback) + "("+args.join(",") +
+ comma +" fn);"+
+ "break;";
+ }
+ return (receiver === void 0
+ ? "callback("+args.join(",")+ comma +" fn);"
+ : "callback.call("+(receiver === THIS
+ ? "this"
+ : "receiver")+", "+args.join(",") + comma + " fn);") +
+ "break;";
+ }
+
+ function generateArgumentSwitchCase() {
+ var ret = "";
+ for(var i = 0; i < argumentOrder.length; ++i) {
+ ret += "case " + argumentOrder[i] +":" +
+ generateCallForArgumentCount(argumentOrder[i]);
+ }
+ ret += "default: var args = new Array(len + 1);" +
+ "var i = 0;" +
+ "for (var i = 0; i < len; ++i) { " +
+ " args[i] = arguments[i];" +
+ "}" +
+ "args[i] = fn;" +
+
+ (typeof callback === "string"
+ ? "this" + propertyAccess(callback) + ".apply("
+ : "callback.apply(") +
+
+ (receiver === THIS ? "this" : "receiver") +
+ ", args); break;";
+ return ret;
+ }
+
+ return new Function("Promise", "callback", "receiver",
+ "withAppended", "maybeWrapAsError", "nodebackForPromise",
+ "INTERNAL",
+ "var ret = function " + callbackName +
+ "(" + parameterDeclaration(newParameterCount) + ") {\"use strict\";" +
+ "var len = arguments.length;" +
+ "var promise = new Promise(INTERNAL);"+
+ "promise._setTrace(" + callbackName + ", void 0);" +
+ "var fn = nodebackForPromise(promise);"+
+ "try {" +
+ "switch(len) {" +
+ generateArgumentSwitchCase() +
+ "}" +
+ "}" +
+ "catch(e){ " +
+ "var wrapped = maybeWrapAsError(e);" +
+ "promise._attachExtraTrace(wrapped);" +
+ "promise._reject(wrapped);" +
+ "}" +
+ "return promise;" +
+ "" +
+ "}; ret.__isPromisified__ = true; return ret;"
+ )(Promise, callback, receiver, withAppended,
+ maybeWrapAsError, nodebackForPromise, INTERNAL);
+}
+
+function makeNodePromisifiedClosure(callback, receiver) {
+ function promisified() {
+ var _receiver = receiver;
+ if (receiver === THIS) _receiver = this;
+ if (typeof callback === "string") {
+ callback = _receiver[callback];
+ }
+ var promise = new Promise(INTERNAL);
+ promise._setTrace(promisified, void 0);
+ var fn = nodebackForPromise(promise);
+ try {
+ callback.apply(_receiver, withAppended(arguments, fn));
+ }
+ catch(e) {
+ var wrapped = maybeWrapAsError(e);
+ promise._attachExtraTrace(wrapped);
+ promise._reject(wrapped);
+ }
+ return promise;
+ }
+ promisified.__isPromisified__ = true;
+ return promisified;
+}
+
+var makeNodePromisified = canEvaluate
+ ? makeNodePromisifiedEval
+ : makeNodePromisifiedClosure;
+
+function _promisify(callback, receiver, isAll) {
+ if (isAll) {
+ var methods = inheritedMethods(callback);
+ for (var i = 0, len = methods.length; i < len; i+= 2) {
+ var key = methods[i];
+ var fn = methods[i+1];
+ var originalKey = key + "__beforePromisified__";
+ var promisifiedKey = key + "Async";
+ notEnumerableProp(callback, originalKey, fn);
+ callback[promisifiedKey] =
+ makeNodePromisified(originalKey, THIS,
+ key, fn);
+ }
+ util.toFastProperties(callback);
+ return callback;
+ }
+ else {
+ return makeNodePromisified(callback, receiver, void 0, callback);
+ }
+}
+
+Promise.promisify = function Promise$Promisify(fn, receiver) {
+ if (typeof fn === "object" && fn !== null) {
+ deprecated("Promise.promisify for promisifying entire objects is deprecated. Use Promise.promisifyAll instead.");
+ return _promisify(fn, receiver, true);
+ }
+ if (typeof fn !== "function") {
+ throw new TypeError("fn must be a function");
+ }
+ if (isPromisified(fn)) {
+ return fn;
+ }
+ return _promisify(
+ fn,
+ arguments.length < 2 ? THIS : receiver,
+ false);
+};
+
+Promise.promisifyAll = function Promise$PromisifyAll(target) {
+ if (typeof target !== "function" && typeof target !== "object") {
+ throw new TypeError("the target of promisifyAll must be an object or a function");
+ }
+ return _promisify(target, void 0, true);
+};
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/properties_promise_array.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/properties_promise_array.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/properties_promise_array.js
new file mode 100644
index 0000000..85f5990
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/properties_promise_array.js
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, PromiseArray) {
+var util = require("./util.js");
+var inherits = util.inherits;
+var es5 = require("./es5.js");
+
+function PropertiesPromiseArray(obj, caller, boundTo) {
+ var keys = es5.keys(obj);
+ var values = new Array(keys.length);
+ for (var i = 0, len = values.length; i < len; ++i) {
+ values[i] = obj[keys[i]];
+ }
+ this.constructor$(values, caller, boundTo);
+ if (!this._isResolved()) {
+ for (var i = 0, len = keys.length; i < len; ++i) {
+ values.push(keys[i]);
+ }
+ }
+}
+inherits(PropertiesPromiseArray, PromiseArray);
+
+PropertiesPromiseArray.prototype._init =
+function PropertiesPromiseArray$_init() {
+ this._init$(void 0, -3) ;
+};
+
+PropertiesPromiseArray.prototype._promiseFulfilled =
+function PropertiesPromiseArray$_promiseFulfilled(value, index) {
+ if (this._isResolved()) return;
+ this._values[index] = value;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ var val = {};
+ var keyOffset = this.length();
+ for (var i = 0, len = this.length(); i < len; ++i) {
+ val[this._values[i + keyOffset]] = this._values[i];
+ }
+ this._resolve(val);
+ }
+};
+
+PropertiesPromiseArray.prototype._promiseProgressed =
+function PropertiesPromiseArray$_promiseProgressed(value, index) {
+ if (this._isResolved()) return;
+
+ this._promise._progress({
+ key: this._values[index + this.length()],
+ value: value
+ });
+};
+
+PromiseArray.PropertiesPromiseArray = PropertiesPromiseArray;
+
+return PropertiesPromiseArray;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/props.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/props.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/props.js
new file mode 100644
index 0000000..3cdba43
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/props.js
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, PromiseArray) {
+ var PropertiesPromiseArray = require("./properties_promise_array.js")(
+ Promise, PromiseArray);
+ var util = require("./util.js");
+ var apiRejection = require("./errors_api_rejection")(Promise);
+ var isObject = util.isObject;
+
+ function Promise$_Props(promises, useBound, caller) {
+ var ret;
+ var castValue = Promise._cast(promises, caller, void 0);
+
+ if (!isObject(castValue)) {
+ return apiRejection("cannot await properties of a non-object");
+ }
+ else if (Promise.is(castValue)) {
+ ret = castValue._then(Promise.props, void 0, void 0,
+ void 0, void 0, caller);
+ }
+ else {
+ ret = new PropertiesPromiseArray(
+ castValue,
+ caller,
+ useBound === true && castValue._isBound()
+ ? castValue._boundTo
+ : void 0
+ ).promise();
+ useBound = false;
+ }
+ if (useBound === true && castValue._isBound()) {
+ ret._setBoundTo(castValue._boundTo);
+ }
+ return ret;
+ }
+
+ Promise.prototype.props = function Promise$props() {
+ return Promise$_Props(this, true, this.props);
+ };
+
+ Promise.props = function Promise$Props(promises) {
+ return Promise$_Props(promises, false, Promise.props);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/queue.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/queue.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/queue.js
new file mode 100644
index 0000000..bbd3f1b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/queue.js
@@ -0,0 +1,135 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+function arrayCopy(src, srcIndex, dst, dstIndex, len) {
+ for (var j = 0; j < len; ++j) {
+ dst[j + dstIndex] = src[j + srcIndex];
+ }
+}
+
+function pow2AtLeast(n) {
+ n = n >>> 0;
+ n = n - 1;
+ n = n | (n >> 1);
+ n = n | (n >> 2);
+ n = n | (n >> 4);
+ n = n | (n >> 8);
+ n = n | (n >> 16);
+ return n + 1;
+}
+
+function getCapacity(capacity) {
+ if (typeof capacity !== "number") return 16;
+ return pow2AtLeast(
+ Math.min(
+ Math.max(16, capacity), 1073741824)
+ );
+}
+
+function Queue(capacity) {
+ this._capacity = getCapacity(capacity);
+ this._length = 0;
+ this._front = 0;
+ this._makeCapacity();
+}
+
+Queue.prototype._willBeOverCapacity =
+function Queue$_willBeOverCapacity(size) {
+ return this._capacity < size;
+};
+
+Queue.prototype._pushOne = function Queue$_pushOne(arg) {
+ var length = this.length();
+ this._checkCapacity(length + 1);
+ var i = (this._front + length) & (this._capacity - 1);
+ this[i] = arg;
+ this._length = length + 1;
+};
+
+Queue.prototype.push = function Queue$push(fn, receiver, arg) {
+ var length = this.length() + 3;
+ if (this._willBeOverCapacity(length)) {
+ this._pushOne(fn);
+ this._pushOne(receiver);
+ this._pushOne(arg);
+ return;
+ }
+ var j = this._front + length - 3;
+ this._checkCapacity(length);
+ var wrapMask = this._capacity - 1;
+ this[(j + 0) & wrapMask] = fn;
+ this[(j + 1) & wrapMask] = receiver;
+ this[(j + 2) & wrapMask] = arg;
+ this._length = length;
+};
+
+Queue.prototype.shift = function Queue$shift() {
+ var front = this._front,
+ ret = this[front];
+
+ this[front] = void 0;
+ this._front = (front + 1) & (this._capacity - 1);
+ this._length--;
+ return ret;
+};
+
+Queue.prototype.length = function Queue$length() {
+ return this._length;
+};
+
+Queue.prototype._makeCapacity = function Queue$_makeCapacity() {
+ var len = this._capacity;
+ for (var i = 0; i < len; ++i) {
+ this[i] = void 0;
+ }
+};
+
+Queue.prototype._checkCapacity = function Queue$_checkCapacity(size) {
+ if (this._capacity < size) {
+ this._resizeTo(this._capacity << 3);
+ }
+};
+
+Queue.prototype._resizeTo = function Queue$_resizeTo(capacity) {
+ var oldFront = this._front;
+ var oldCapacity = this._capacity;
+ var oldQueue = new Array(oldCapacity);
+ var length = this.length();
+
+ arrayCopy(this, 0, oldQueue, 0, oldCapacity);
+ this._capacity = capacity;
+ this._makeCapacity();
+ this._front = 0;
+ if (oldFront + length <= oldCapacity) {
+ arrayCopy(oldQueue, oldFront, this, 0, length);
+ }
+ else { var lengthBeforeWrapping =
+ length - ((oldFront + length) & (oldCapacity - 1));
+
+ arrayCopy(oldQueue, oldFront, this, 0, lengthBeforeWrapping);
+ arrayCopy(oldQueue, 0, this, lengthBeforeWrapping,
+ length - lengthBeforeWrapping);
+ }
+};
+
+module.exports = Queue;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/race.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/race.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/race.js
new file mode 100644
index 0000000..82b8ce1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/race.js
@@ -0,0 +1,85 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+ var apiRejection = require("./errors_api_rejection.js")(Promise);
+ var isArray = require("./util.js").isArray;
+
+ var raceLater = function Promise$_raceLater(promise) {
+ return promise.then(function Promise$_lateRacer(array) {
+ return Promise$_Race(array, Promise$_lateRacer, promise);
+ });
+ };
+
+ var hasOwn = {}.hasOwnProperty;
+ function Promise$_Race(promises, caller, parent) {
+ var maybePromise = Promise._cast(promises, caller, void 0);
+
+ if (Promise.is(maybePromise)) {
+ return raceLater(maybePromise);
+ }
+ else if (!isArray(promises)) {
+ return apiRejection("expecting an array, a promise or a thenable");
+ }
+
+ var ret = new Promise(INTERNAL);
+ ret._setTrace(caller, parent);
+ if (parent !== void 0) {
+ if (parent._isBound()) {
+ ret._setBoundTo(parent._boundTo);
+ }
+ if (parent._cancellable()) {
+ ret._setCancellable();
+ ret._cancellationParent = parent;
+ }
+ }
+ var fulfill = ret._fulfill;
+ var reject = ret._reject;
+ for (var i = 0, len = promises.length; i < len; ++i) {
+ var val = promises[i];
+
+ if (val === void 0 && !(hasOwn.call(promises, i))) {
+ continue;
+ }
+
+ Promise.cast(val)._then(
+ fulfill,
+ reject,
+ void 0,
+ ret,
+ null,
+ caller
+ );
+ }
+ return ret;
+ }
+
+ Promise.race = function Promise$Race(promises) {
+ return Promise$_Race(promises, Promise.race, void 0);
+ };
+
+ Promise.prototype.race = function Promise$race() {
+ return Promise$_Race(this, this.race, void 0);
+ };
+
+};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[16/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/aes.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/aes.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/aes.js
new file mode 100644
index 0000000..d4b745b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/aes.js
@@ -0,0 +1,1146 @@
+/**
+ * Advanced Encryption Standard (AES) implementation.
+ *
+ * This implementation is based on the public domain library 'jscrypto' which
+ * was written by:
+ *
+ * Emily Stark (estark@stanford.edu)
+ * Mike Hamburg (mhamburg@stanford.edu)
+ * Dan Boneh (dabo@cs.stanford.edu)
+ *
+ * Parts of this code are based on the OpenSSL implementation of AES:
+ * http://www.openssl.org
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+/* AES API */
+forge.aes = forge.aes || {};
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * var cipher = forge.cipher.createCipher('AES-<mode>', key);
+ * cipher.start({iv: iv});
+ *
+ * Creates an AES cipher object to encrypt data using the given symmetric key.
+ * The output will be stored in the 'output' member of the returned cipher.
+ *
+ * The key and iv may be given as a string of bytes, an array of bytes,
+ * a byte buffer, or an array of 32-bit words.
+ *
+ * @param key the symmetric key to use.
+ * @param iv the initialization vector to use.
+ * @param output the buffer to write to, null to create one.
+ * @param mode the cipher mode to use (default: 'CBC').
+ *
+ * @return the cipher.
+ */
+forge.aes.startEncrypting = function(key, iv, output, mode) {
+ var cipher = _createCipher({
+ key: key,
+ output: output,
+ decrypt: false,
+ mode: mode
+ });
+ cipher.start(iv);
+ return cipher;
+};
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * var cipher = forge.cipher.createCipher('AES-<mode>', key);
+ *
+ * Creates an AES cipher object to encrypt data using the given symmetric key.
+ *
+ * The key may be given as a string of bytes, an array of bytes, a
+ * byte buffer, or an array of 32-bit words.
+ *
+ * @param key the symmetric key to use.
+ * @param mode the cipher mode to use (default: 'CBC').
+ *
+ * @return the cipher.
+ */
+forge.aes.createEncryptionCipher = function(key, mode) {
+ return _createCipher({
+ key: key,
+ output: null,
+ decrypt: false,
+ mode: mode
+ });
+};
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * var decipher = forge.cipher.createDecipher('AES-<mode>', key);
+ * decipher.start({iv: iv});
+ *
+ * Creates an AES cipher object to decrypt data using the given symmetric key.
+ * The output will be stored in the 'output' member of the returned cipher.
+ *
+ * The key and iv may be given as a string of bytes, an array of bytes,
+ * a byte buffer, or an array of 32-bit words.
+ *
+ * @param key the symmetric key to use.
+ * @param iv the initialization vector to use.
+ * @param output the buffer to write to, null to create one.
+ * @param mode the cipher mode to use (default: 'CBC').
+ *
+ * @return the cipher.
+ */
+forge.aes.startDecrypting = function(key, iv, output, mode) {
+ var cipher = _createCipher({
+ key: key,
+ output: output,
+ decrypt: true,
+ mode: mode
+ });
+ cipher.start(iv);
+ return cipher;
+};
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * var decipher = forge.cipher.createDecipher('AES-<mode>', key);
+ *
+ * Creates an AES cipher object to decrypt data using the given symmetric key.
+ *
+ * The key may be given as a string of bytes, an array of bytes, a
+ * byte buffer, or an array of 32-bit words.
+ *
+ * @param key the symmetric key to use.
+ * @param mode the cipher mode to use (default: 'CBC').
+ *
+ * @return the cipher.
+ */
+forge.aes.createDecryptionCipher = function(key, mode) {
+ return _createCipher({
+ key: key,
+ output: null,
+ decrypt: true,
+ mode: mode
+ });
+};
+
+/**
+ * Creates a new AES cipher algorithm object.
+ *
+ * @param name the name of the algorithm.
+ * @param mode the mode factory function.
+ *
+ * @return the AES algorithm object.
+ */
+forge.aes.Algorithm = function(name, mode) {
+ if(!init) {
+ initialize();
+ }
+ var self = this;
+ self.name = name;
+ self.mode = new mode({
+ blockSize: 16,
+ cipher: {
+ encrypt: function(inBlock, outBlock) {
+ return _updateBlock(self._w, inBlock, outBlock, false);
+ },
+ decrypt: function(inBlock, outBlock) {
+ return _updateBlock(self._w, inBlock, outBlock, true);
+ }
+ }
+ });
+ self._init = false;
+};
+
+/**
+ * Initializes this AES algorithm by expanding its key.
+ *
+ * @param options the options to use.
+ * key the key to use with this algorithm.
+ * decrypt true if the algorithm should be initialized for decryption,
+ * false for encryption.
+ */
+forge.aes.Algorithm.prototype.initialize = function(options) {
+ if(this._init) {
+ return;
+ }
+
+ var key = options.key;
+ var tmp;
+
+ /* Note: The key may be a string of bytes, an array of bytes, a byte
+ buffer, or an array of 32-bit integers. If the key is in bytes, then
+ it must be 16, 24, or 32 bytes in length. If it is in 32-bit
+ integers, it must be 4, 6, or 8 integers long. */
+
+ if(typeof key === 'string' &&
+ (key.length === 16 || key.length === 24 || key.length === 32)) {
+ // convert key string into byte buffer
+ key = forge.util.createBuffer(key);
+ } else if(forge.util.isArray(key) &&
+ (key.length === 16 || key.length === 24 || key.length === 32)) {
+ // convert key integer array into byte buffer
+ tmp = key;
+ key = forge.util.createBuffer();
+ for(var i = 0; i < tmp.length; ++i) {
+ key.putByte(tmp[i]);
+ }
+ }
+
+ // convert key byte buffer into 32-bit integer array
+ if(!forge.util.isArray(key)) {
+ tmp = key;
+ key = [];
+
+ // key lengths of 16, 24, 32 bytes allowed
+ var len = tmp.length();
+ if(len === 16 || len === 24 || len === 32) {
+ len = len >>> 2;
+ for(var i = 0; i < len; ++i) {
+ key.push(tmp.getInt32());
+ }
+ }
+ }
+
+ // key must be an array of 32-bit integers by now
+ if(!forge.util.isArray(key) ||
+ !(key.length === 4 || key.length === 6 || key.length === 8)) {
+ throw new Error('Invalid key parameter.');
+ }
+
+ // encryption operation is always used for these modes
+ var mode = this.mode.name;
+ var encryptOp = (['CFB', 'OFB', 'CTR', 'GCM'].indexOf(mode) !== -1);
+
+ // do key expansion
+ this._w = _expandKey(key, options.decrypt && !encryptOp);
+ this._init = true;
+};
+
+/**
+ * Expands a key. Typically only used for testing.
+ *
+ * @param key the symmetric key to expand, as an array of 32-bit words.
+ * @param decrypt true to expand for decryption, false for encryption.
+ *
+ * @return the expanded key.
+ */
+forge.aes._expandKey = function(key, decrypt) {
+ if(!init) {
+ initialize();
+ }
+ return _expandKey(key, decrypt);
+};
+
+/**
+ * Updates a single block. Typically only used for testing.
+ *
+ * @param w the expanded key to use.
+ * @param input an array of block-size 32-bit words.
+ * @param output an array of block-size 32-bit words.
+ * @param decrypt true to decrypt, false to encrypt.
+ */
+forge.aes._updateBlock = _updateBlock;
+
+
+/** Register AES algorithms **/
+
+registerAlgorithm('AES-CBC', forge.cipher.modes.cbc);
+registerAlgorithm('AES-CFB', forge.cipher.modes.cfb);
+registerAlgorithm('AES-OFB', forge.cipher.modes.ofb);
+registerAlgorithm('AES-CTR', forge.cipher.modes.ctr);
+registerAlgorithm('AES-GCM', forge.cipher.modes.gcm);
+
+function registerAlgorithm(name, mode) {
+ var factory = function() {
+ return new forge.aes.Algorithm(name, mode);
+ };
+ forge.cipher.registerAlgorithm(name, factory);
+}
+
+
+/** AES implementation **/
+
+var init = false; // not yet initialized
+var Nb = 4; // number of words comprising the state (AES = 4)
+var sbox; // non-linear substitution table used in key expansion
+var isbox; // inversion of sbox
+var rcon; // round constant word array
+var mix; // mix-columns table
+var imix; // inverse mix-columns table
+
+/**
+ * Performs initialization, ie: precomputes tables to optimize for speed.
+ *
+ * One way to understand how AES works is to imagine that 'addition' and
+ * 'multiplication' are interfaces that require certain mathematical
+ * properties to hold true (ie: they are associative) but they might have
+ * different implementations and produce different kinds of results ...
+ * provided that their mathematical properties remain true. AES defines
+ * its own methods of addition and multiplication but keeps some important
+ * properties the same, ie: associativity and distributivity. The
+ * explanation below tries to shed some light on how AES defines addition
+ * and multiplication of bytes and 32-bit words in order to perform its
+ * encryption and decryption algorithms.
+ *
+ * The basics:
+ *
+ * The AES algorithm views bytes as binary representations of polynomials
+ * that have either 1 or 0 as the coefficients. It defines the addition
+ * or subtraction of two bytes as the XOR operation. It also defines the
+ * multiplication of two bytes as a finite field referred to as GF(2^8)
+ * (Note: 'GF' means "Galois Field" which is a field that contains a finite
+ * number of elements so GF(2^8) has 256 elements).
+ *
+ * This means that any two bytes can be represented as binary polynomials;
+ * when they multiplied together and modularly reduced by an irreducible
+ * polynomial of the 8th degree, the results are the field GF(2^8). The
+ * specific irreducible polynomial that AES uses in hexadecimal is 0x11b.
+ * This multiplication is associative with 0x01 as the identity:
+ *
+ * (b * 0x01 = GF(b, 0x01) = b).
+ *
+ * The operation GF(b, 0x02) can be performed at the byte level by left
+ * shifting b once and then XOR'ing it (to perform the modular reduction)
+ * with 0x11b if b is >= 128. Repeated application of the multiplication
+ * of 0x02 can be used to implement the multiplication of any two bytes.
+ *
+ * For instance, multiplying 0x57 and 0x13, denoted as GF(0x57, 0x13), can
+ * be performed by factoring 0x13 into 0x01, 0x02, and 0x10. Then these
+ * factors can each be multiplied by 0x57 and then added together. To do
+ * the multiplication, values for 0x57 multiplied by each of these 3 factors
+ * can be precomputed and stored in a table. To add them, the values from
+ * the table are XOR'd together.
+ *
+ * AES also defines addition and multiplication of words, that is 4-byte
+ * numbers represented as polynomials of 3 degrees where the coefficients
+ * are the values of the bytes.
+ *
+ * The word [a0, a1, a2, a3] is a polynomial a3x^3 + a2x^2 + a1x + a0.
+ *
+ * Addition is performed by XOR'ing like powers of x. Multiplication
+ * is performed in two steps, the first is an algebriac expansion as
+ * you would do normally (where addition is XOR). But the result is
+ * a polynomial larger than 3 degrees and thus it cannot fit in a word. So
+ * next the result is modularly reduced by an AES-specific polynomial of
+ * degree 4 which will always produce a polynomial of less than 4 degrees
+ * such that it will fit in a word. In AES, this polynomial is x^4 + 1.
+ *
+ * The modular product of two polynomials 'a' and 'b' is thus:
+ *
+ * d(x) = d3x^3 + d2x^2 + d1x + d0
+ * with
+ * d0 = GF(a0, b0) ^ GF(a3, b1) ^ GF(a2, b2) ^ GF(a1, b3)
+ * d1 = GF(a1, b0) ^ GF(a0, b1) ^ GF(a3, b2) ^ GF(a2, b3)
+ * d2 = GF(a2, b0) ^ GF(a1, b1) ^ GF(a0, b2) ^ GF(a3, b3)
+ * d3 = GF(a3, b0) ^ GF(a2, b1) ^ GF(a1, b2) ^ GF(a0, b3)
+ *
+ * As a matrix:
+ *
+ * [d0] = [a0 a3 a2 a1][b0]
+ * [d1] [a1 a0 a3 a2][b1]
+ * [d2] [a2 a1 a0 a3][b2]
+ * [d3] [a3 a2 a1 a0][b3]
+ *
+ * Special polynomials defined by AES (0x02 == {02}):
+ * a(x) = {03}x^3 + {01}x^2 + {01}x + {02}
+ * a^-1(x) = {0b}x^3 + {0d}x^2 + {09}x + {0e}.
+ *
+ * These polynomials are used in the MixColumns() and InverseMixColumns()
+ * operations, respectively, to cause each element in the state to affect
+ * the output (referred to as diffusing).
+ *
+ * RotWord() uses: a0 = a1 = a2 = {00} and a3 = {01}, which is the
+ * polynomial x3.
+ *
+ * The ShiftRows() method modifies the last 3 rows in the state (where
+ * the state is 4 words with 4 bytes per word) by shifting bytes cyclically.
+ * The 1st byte in the second row is moved to the end of the row. The 1st
+ * and 2nd bytes in the third row are moved to the end of the row. The 1st,
+ * 2nd, and 3rd bytes are moved in the fourth row.
+ *
+ * More details on how AES arithmetic works:
+ *
+ * In the polynomial representation of binary numbers, XOR performs addition
+ * and subtraction and multiplication in GF(2^8) denoted as GF(a, b)
+ * corresponds with the multiplication of polynomials modulo an irreducible
+ * polynomial of degree 8. In other words, for AES, GF(a, b) will multiply
+ * polynomial 'a' with polynomial 'b' and then do a modular reduction by
+ * an AES-specific irreducible polynomial of degree 8.
+ *
+ * A polynomial is irreducible if its only divisors are one and itself. For
+ * the AES algorithm, this irreducible polynomial is:
+ *
+ * m(x) = x^8 + x^4 + x^3 + x + 1,
+ *
+ * or {01}{1b} in hexadecimal notation, where each coefficient is a bit:
+ * 100011011 = 283 = 0x11b.
+ *
+ * For example, GF(0x57, 0x83) = 0xc1 because
+ *
+ * 0x57 = 87 = 01010111 = x^6 + x^4 + x^2 + x + 1
+ * 0x85 = 131 = 10000101 = x^7 + x + 1
+ *
+ * (x^6 + x^4 + x^2 + x + 1) * (x^7 + x + 1)
+ * = x^13 + x^11 + x^9 + x^8 + x^7 +
+ * x^7 + x^5 + x^3 + x^2 + x +
+ * x^6 + x^4 + x^2 + x + 1
+ * = x^13 + x^11 + x^9 + x^8 + x^6 + x^5 + x^4 + x^3 + 1 = y
+ * y modulo (x^8 + x^4 + x^3 + x + 1)
+ * = x^7 + x^6 + 1.
+ *
+ * The modular reduction by m(x) guarantees the result will be a binary
+ * polynomial of less than degree 8, so that it can fit in a byte.
+ *
+ * The operation to multiply a binary polynomial b with x (the polynomial
+ * x in binary representation is 00000010) is:
+ *
+ * b_7x^8 + b_6x^7 + b_5x^6 + b_4x^5 + b_3x^4 + b_2x^3 + b_1x^2 + b_0x^1
+ *
+ * To get GF(b, x) we must reduce that by m(x). If b_7 is 0 (that is the
+ * most significant bit is 0 in b) then the result is already reduced. If
+ * it is 1, then we can reduce it by subtracting m(x) via an XOR.
+ *
+ * It follows that multiplication by x (00000010 or 0x02) can be implemented
+ * by performing a left shift followed by a conditional bitwise XOR with
+ * 0x1b. This operation on bytes is denoted by xtime(). Multiplication by
+ * higher powers of x can be implemented by repeated application of xtime().
+ *
+ * By adding intermediate results, multiplication by any constant can be
+ * implemented. For instance:
+ *
+ * GF(0x57, 0x13) = 0xfe because:
+ *
+ * xtime(b) = (b & 128) ? (b << 1 ^ 0x11b) : (b << 1)
+ *
+ * Note: We XOR with 0x11b instead of 0x1b because in javascript our
+ * datatype for b can be larger than 1 byte, so a left shift will not
+ * automatically eliminate bits that overflow a byte ... by XOR'ing the
+ * overflow bit with 1 (the extra one from 0x11b) we zero it out.
+ *
+ * GF(0x57, 0x02) = xtime(0x57) = 0xae
+ * GF(0x57, 0x04) = xtime(0xae) = 0x47
+ * GF(0x57, 0x08) = xtime(0x47) = 0x8e
+ * GF(0x57, 0x10) = xtime(0x8e) = 0x07
+ *
+ * GF(0x57, 0x13) = GF(0x57, (0x01 ^ 0x02 ^ 0x10))
+ *
+ * And by the distributive property (since XOR is addition and GF() is
+ * multiplication):
+ *
+ * = GF(0x57, 0x01) ^ GF(0x57, 0x02) ^ GF(0x57, 0x10)
+ * = 0x57 ^ 0xae ^ 0x07
+ * = 0xfe.
+ */
+function initialize() {
+ init = true;
+
+ /* Populate the Rcon table. These are the values given by
+ [x^(i-1),{00},{00},{00}] where x^(i-1) are powers of x (and x = 0x02)
+ in the field of GF(2^8), where i starts at 1.
+
+ rcon[0] = [0x00, 0x00, 0x00, 0x00]
+ rcon[1] = [0x01, 0x00, 0x00, 0x00] 2^(1-1) = 2^0 = 1
+ rcon[2] = [0x02, 0x00, 0x00, 0x00] 2^(2-1) = 2^1 = 2
+ ...
+ rcon[9] = [0x1B, 0x00, 0x00, 0x00] 2^(9-1) = 2^8 = 0x1B
+ rcon[10] = [0x36, 0x00, 0x00, 0x00] 2^(10-1) = 2^9 = 0x36
+
+ We only store the first byte because it is the only one used.
+ */
+ rcon = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36];
+
+ // compute xtime table which maps i onto GF(i, 0x02)
+ var xtime = new Array(256);
+ for(var i = 0; i < 128; ++i) {
+ xtime[i] = i << 1;
+ xtime[i + 128] = (i + 128) << 1 ^ 0x11B;
+ }
+
+ // compute all other tables
+ sbox = new Array(256);
+ isbox = new Array(256);
+ mix = new Array(4);
+ imix = new Array(4);
+ for(var i = 0; i < 4; ++i) {
+ mix[i] = new Array(256);
+ imix[i] = new Array(256);
+ }
+ var e = 0, ei = 0, e2, e4, e8, sx, sx2, me, ime;
+ for(var i = 0; i < 256; ++i) {
+ /* We need to generate the SubBytes() sbox and isbox tables so that
+ we can perform byte substitutions. This requires us to traverse
+ all of the elements in GF, find their multiplicative inverses,
+ and apply to each the following affine transformation:
+
+ bi' = bi ^ b(i + 4) mod 8 ^ b(i + 5) mod 8 ^ b(i + 6) mod 8 ^
+ b(i + 7) mod 8 ^ ci
+ for 0 <= i < 8, where bi is the ith bit of the byte, and ci is the
+ ith bit of a byte c with the value {63} or {01100011}.
+
+ It is possible to traverse every possible value in a Galois field
+ using what is referred to as a 'generator'. There are many
+ generators (128 out of 256): 3,5,6,9,11,82 to name a few. To fully
+ traverse GF we iterate 255 times, multiplying by our generator
+ each time.
+
+ On each iteration we can determine the multiplicative inverse for
+ the current element.
+
+ Suppose there is an element in GF 'e'. For a given generator 'g',
+ e = g^x. The multiplicative inverse of e is g^(255 - x). It turns
+ out that if use the inverse of a generator as another generator
+ it will produce all of the corresponding multiplicative inverses
+ at the same time. For this reason, we choose 5 as our inverse
+ generator because it only requires 2 multiplies and 1 add and its
+ inverse, 82, requires relatively few operations as well.
+
+ In order to apply the affine transformation, the multiplicative
+ inverse 'ei' of 'e' can be repeatedly XOR'd (4 times) with a
+ bit-cycling of 'ei'. To do this 'ei' is first stored in 's' and
+ 'x'. Then 's' is left shifted and the high bit of 's' is made the
+ low bit. The resulting value is stored in 's'. Then 'x' is XOR'd
+ with 's' and stored in 'x'. On each subsequent iteration the same
+ operation is performed. When 4 iterations are complete, 'x' is
+ XOR'd with 'c' (0x63) and the transformed value is stored in 'x'.
+ For example:
+
+ s = 01000001
+ x = 01000001
+
+ iteration 1: s = 10000010, x ^= s
+ iteration 2: s = 00000101, x ^= s
+ iteration 3: s = 00001010, x ^= s
+ iteration 4: s = 00010100, x ^= s
+ x ^= 0x63
+
+ This can be done with a loop where s = (s << 1) | (s >> 7). However,
+ it can also be done by using a single 16-bit (in this case 32-bit)
+ number 'sx'. Since XOR is an associative operation, we can set 'sx'
+ to 'ei' and then XOR it with 'sx' left-shifted 1,2,3, and 4 times.
+ The most significant bits will flow into the high 8 bit positions
+ and be correctly XOR'd with one another. All that remains will be
+ to cycle the high 8 bits by XOR'ing them all with the lower 8 bits
+ afterwards.
+
+ At the same time we're populating sbox and isbox we can precompute
+ the multiplication we'll need to do to do MixColumns() later.
+ */
+
+ // apply affine transformation
+ sx = ei ^ (ei << 1) ^ (ei << 2) ^ (ei << 3) ^ (ei << 4);
+ sx = (sx >> 8) ^ (sx & 255) ^ 0x63;
+
+ // update tables
+ sbox[e] = sx;
+ isbox[sx] = e;
+
+ /* Mixing columns is done using matrix multiplication. The columns
+ that are to be mixed are each a single word in the current state.
+ The state has Nb columns (4 columns). Therefore each column is a
+ 4 byte word. So to mix the columns in a single column 'c' where
+ its rows are r0, r1, r2, and r3, we use the following matrix
+ multiplication:
+
+ [2 3 1 1]*[r0,c]=[r'0,c]
+ [1 2 3 1] [r1,c] [r'1,c]
+ [1 1 2 3] [r2,c] [r'2,c]
+ [3 1 1 2] [r3,c] [r'3,c]
+
+ r0, r1, r2, and r3 are each 1 byte of one of the words in the
+ state (a column). To do matrix multiplication for each mixed
+ column c' we multiply the corresponding row from the left matrix
+ with the corresponding column from the right matrix. In total, we
+ get 4 equations:
+
+ r0,c' = 2*r0,c + 3*r1,c + 1*r2,c + 1*r3,c
+ r1,c' = 1*r0,c + 2*r1,c + 3*r2,c + 1*r3,c
+ r2,c' = 1*r0,c + 1*r1,c + 2*r2,c + 3*r3,c
+ r3,c' = 3*r0,c + 1*r1,c + 1*r2,c + 2*r3,c
+
+ As usual, the multiplication is as previously defined and the
+ addition is XOR. In order to optimize mixing columns we can store
+ the multiplication results in tables. If you think of the whole
+ column as a word (it might help to visualize by mentally rotating
+ the equations above by counterclockwise 90 degrees) then you can
+ see that it would be useful to map the multiplications performed on
+ each byte (r0, r1, r2, r3) onto a word as well. For instance, we
+ could map 2*r0,1*r0,1*r0,3*r0 onto a word by storing 2*r0 in the
+ highest 8 bits and 3*r0 in the lowest 8 bits (with the other two
+ respectively in the middle). This means that a table can be
+ constructed that uses r0 as an index to the word. We can do the
+ same with r1, r2, and r3, creating a total of 4 tables.
+
+ To construct a full c', we can just look up each byte of c in
+ their respective tables and XOR the results together.
+
+ Also, to build each table we only have to calculate the word
+ for 2,1,1,3 for every byte ... which we can do on each iteration
+ of this loop since we will iterate over every byte. After we have
+ calculated 2,1,1,3 we can get the results for the other tables
+ by cycling the byte at the end to the beginning. For instance
+ we can take the result of table 2,1,1,3 and produce table 3,2,1,1
+ by moving the right most byte to the left most position just like
+ how you can imagine the 3 moved out of 2,1,1,3 and to the front
+ to produce 3,2,1,1.
+
+ There is another optimization in that the same multiples of
+ the current element we need in order to advance our generator
+ to the next iteration can be reused in performing the 2,1,1,3
+ calculation. We also calculate the inverse mix column tables,
+ with e,9,d,b being the inverse of 2,1,1,3.
+
+ When we're done, and we need to actually mix columns, the first
+ byte of each state word should be put through mix[0] (2,1,1,3),
+ the second through mix[1] (3,2,1,1) and so forth. Then they should
+ be XOR'd together to produce the fully mixed column.
+ */
+
+ // calculate mix and imix table values
+ sx2 = xtime[sx];
+ e2 = xtime[e];
+ e4 = xtime[e2];
+ e8 = xtime[e4];
+ me =
+ (sx2 << 24) ^ // 2
+ (sx << 16) ^ // 1
+ (sx << 8) ^ // 1
+ (sx ^ sx2); // 3
+ ime =
+ (e2 ^ e4 ^ e8) << 24 ^ // E (14)
+ (e ^ e8) << 16 ^ // 9
+ (e ^ e4 ^ e8) << 8 ^ // D (13)
+ (e ^ e2 ^ e8); // B (11)
+ // produce each of the mix tables by rotating the 2,1,1,3 value
+ for(var n = 0; n < 4; ++n) {
+ mix[n][e] = me;
+ imix[n][sx] = ime;
+ // cycle the right most byte to the left most position
+ // ie: 2,1,1,3 becomes 3,2,1,1
+ me = me << 24 | me >>> 8;
+ ime = ime << 24 | ime >>> 8;
+ }
+
+ // get next element and inverse
+ if(e === 0) {
+ // 1 is the inverse of 1
+ e = ei = 1;
+ } else {
+ // e = 2e + 2*2*2*(10e)) = multiply e by 82 (chosen generator)
+ // ei = ei + 2*2*ei = multiply ei by 5 (inverse generator)
+ e = e2 ^ xtime[xtime[xtime[e2 ^ e8]]];
+ ei ^= xtime[xtime[ei]];
+ }
+ }
+}
+
+/**
+ * Generates a key schedule using the AES key expansion algorithm.
+ *
+ * The AES algorithm takes the Cipher Key, K, and performs a Key Expansion
+ * routine to generate a key schedule. The Key Expansion generates a total
+ * of Nb*(Nr + 1) words: the algorithm requires an initial set of Nb words,
+ * and each of the Nr rounds requires Nb words of key data. The resulting
+ * key schedule consists of a linear array of 4-byte words, denoted [wi ],
+ * with i in the range 0 ≤ i < Nb(Nr + 1).
+ *
+ * KeyExpansion(byte key[4*Nk], word w[Nb*(Nr+1)], Nk)
+ * AES-128 (Nb=4, Nk=4, Nr=10)
+ * AES-192 (Nb=4, Nk=6, Nr=12)
+ * AES-256 (Nb=4, Nk=8, Nr=14)
+ * Note: Nr=Nk+6.
+ *
+ * Nb is the number of columns (32-bit words) comprising the State (or
+ * number of bytes in a block). For AES, Nb=4.
+ *
+ * @param key the key to schedule (as an array of 32-bit words).
+ * @param decrypt true to modify the key schedule to decrypt, false not to.
+ *
+ * @return the generated key schedule.
+ */
+function _expandKey(key, decrypt) {
+ // copy the key's words to initialize the key schedule
+ var w = key.slice(0);
+
+ /* RotWord() will rotate a word, moving the first byte to the last
+ byte's position (shifting the other bytes left).
+
+ We will be getting the value of Rcon at i / Nk. 'i' will iterate
+ from Nk to (Nb * Nr+1). Nk = 4 (4 byte key), Nb = 4 (4 words in
+ a block), Nr = Nk + 6 (10). Therefore 'i' will iterate from
+ 4 to 44 (exclusive). Each time we iterate 4 times, i / Nk will
+ increase by 1. We use a counter iNk to keep track of this.
+ */
+
+ // go through the rounds expanding the key
+ var temp, iNk = 1;
+ var Nk = w.length;
+ var Nr1 = Nk + 6 + 1;
+ var end = Nb * Nr1;
+ for(var i = Nk; i < end; ++i) {
+ temp = w[i - 1];
+ if(i % Nk === 0) {
+ // temp = SubWord(RotWord(temp)) ^ Rcon[i / Nk]
+ temp =
+ sbox[temp >>> 16 & 255] << 24 ^
+ sbox[temp >>> 8 & 255] << 16 ^
+ sbox[temp & 255] << 8 ^
+ sbox[temp >>> 24] ^ (rcon[iNk] << 24);
+ iNk++;
+ } else if(Nk > 6 && (i % Nk === 4)) {
+ // temp = SubWord(temp)
+ temp =
+ sbox[temp >>> 24] << 24 ^
+ sbox[temp >>> 16 & 255] << 16 ^
+ sbox[temp >>> 8 & 255] << 8 ^
+ sbox[temp & 255];
+ }
+ w[i] = w[i - Nk] ^ temp;
+ }
+
+ /* When we are updating a cipher block we always use the code path for
+ encryption whether we are decrypting or not (to shorten code and
+ simplify the generation of look up tables). However, because there
+ are differences in the decryption algorithm, other than just swapping
+ in different look up tables, we must transform our key schedule to
+ account for these changes:
+
+ 1. The decryption algorithm gets its key rounds in reverse order.
+ 2. The decryption algorithm adds the round key before mixing columns
+ instead of afterwards.
+
+ We don't need to modify our key schedule to handle the first case,
+ we can just traverse the key schedule in reverse order when decrypting.
+
+ The second case requires a little work.
+
+ The tables we built for performing rounds will take an input and then
+ perform SubBytes() and MixColumns() or, for the decrypt version,
+ InvSubBytes() and InvMixColumns(). But the decrypt algorithm requires
+ us to AddRoundKey() before InvMixColumns(). This means we'll need to
+ apply some transformations to the round key to inverse-mix its columns
+ so they'll be correct for moving AddRoundKey() to after the state has
+ had its columns inverse-mixed.
+
+ To inverse-mix the columns of the state when we're decrypting we use a
+ lookup table that will apply InvSubBytes() and InvMixColumns() at the
+ same time. However, the round key's bytes are not inverse-substituted
+ in the decryption algorithm. To get around this problem, we can first
+ substitute the bytes in the round key so that when we apply the
+ transformation via the InvSubBytes()+InvMixColumns() table, it will
+ undo our substitution leaving us with the original value that we
+ want -- and then inverse-mix that value.
+
+ This change will correctly alter our key schedule so that we can XOR
+ each round key with our already transformed decryption state. This
+ allows us to use the same code path as the encryption algorithm.
+
+ We make one more change to the decryption key. Since the decryption
+ algorithm runs in reverse from the encryption algorithm, we reverse
+ the order of the round keys to avoid having to iterate over the key
+ schedule backwards when running the encryption algorithm later in
+ decryption mode. In addition to reversing the order of the round keys,
+ we also swap each round key's 2nd and 4th rows. See the comments
+ section where rounds are performed for more details about why this is
+ done. These changes are done inline with the other substitution
+ described above.
+ */
+ if(decrypt) {
+ var tmp;
+ var m0 = imix[0];
+ var m1 = imix[1];
+ var m2 = imix[2];
+ var m3 = imix[3];
+ var wnew = w.slice(0);
+ end = w.length;
+ for(var i = 0, wi = end - Nb; i < end; i += Nb, wi -= Nb) {
+ // do not sub the first or last round key (round keys are Nb
+ // words) as no column mixing is performed before they are added,
+ // but do change the key order
+ if(i === 0 || i === (end - Nb)) {
+ wnew[i] = w[wi];
+ wnew[i + 1] = w[wi + 3];
+ wnew[i + 2] = w[wi + 2];
+ wnew[i + 3] = w[wi + 1];
+ } else {
+ // substitute each round key byte because the inverse-mix
+ // table will inverse-substitute it (effectively cancel the
+ // substitution because round key bytes aren't sub'd in
+ // decryption mode) and swap indexes 3 and 1
+ for(var n = 0; n < Nb; ++n) {
+ tmp = w[wi + n];
+ wnew[i + (3&-n)] =
+ m0[sbox[tmp >>> 24]] ^
+ m1[sbox[tmp >>> 16 & 255]] ^
+ m2[sbox[tmp >>> 8 & 255]] ^
+ m3[sbox[tmp & 255]];
+ }
+ }
+ }
+ w = wnew;
+ }
+
+ return w;
+}
+
+/**
+ * Updates a single block (16 bytes) using AES. The update will either
+ * encrypt or decrypt the block.
+ *
+ * @param w the key schedule.
+ * @param input the input block (an array of 32-bit words).
+ * @param output the updated output block.
+ * @param decrypt true to decrypt the block, false to encrypt it.
+ */
+function _updateBlock(w, input, output, decrypt) {
+ /*
+ Cipher(byte in[4*Nb], byte out[4*Nb], word w[Nb*(Nr+1)])
+ begin
+ byte state[4,Nb]
+ state = in
+ AddRoundKey(state, w[0, Nb-1])
+ for round = 1 step 1 to Nr–1
+ SubBytes(state)
+ ShiftRows(state)
+ MixColumns(state)
+ AddRoundKey(state, w[round*Nb, (round+1)*Nb-1])
+ end for
+ SubBytes(state)
+ ShiftRows(state)
+ AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])
+ out = state
+ end
+
+ InvCipher(byte in[4*Nb], byte out[4*Nb], word w[Nb*(Nr+1)])
+ begin
+ byte state[4,Nb]
+ state = in
+ AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])
+ for round = Nr-1 step -1 downto 1
+ InvShiftRows(state)
+ InvSubBytes(state)
+ AddRoundKey(state, w[round*Nb, (round+1)*Nb-1])
+ InvMixColumns(state)
+ end for
+ InvShiftRows(state)
+ InvSubBytes(state)
+ AddRoundKey(state, w[0, Nb-1])
+ out = state
+ end
+ */
+
+ // Encrypt: AddRoundKey(state, w[0, Nb-1])
+ // Decrypt: AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])
+ var Nr = w.length / 4 - 1;
+ var m0, m1, m2, m3, sub;
+ if(decrypt) {
+ m0 = imix[0];
+ m1 = imix[1];
+ m2 = imix[2];
+ m3 = imix[3];
+ sub = isbox;
+ } else {
+ m0 = mix[0];
+ m1 = mix[1];
+ m2 = mix[2];
+ m3 = mix[3];
+ sub = sbox;
+ }
+ var a, b, c, d, a2, b2, c2;
+ a = input[0] ^ w[0];
+ b = input[decrypt ? 3 : 1] ^ w[1];
+ c = input[2] ^ w[2];
+ d = input[decrypt ? 1 : 3] ^ w[3];
+ var i = 3;
+
+ /* In order to share code we follow the encryption algorithm when both
+ encrypting and decrypting. To account for the changes required in the
+ decryption algorithm, we use different lookup tables when decrypting
+ and use a modified key schedule to account for the difference in the
+ order of transformations applied when performing rounds. We also get
+ key rounds in reverse order (relative to encryption). */
+ for(var round = 1; round < Nr; ++round) {
+ /* As described above, we'll be using table lookups to perform the
+ column mixing. Each column is stored as a word in the state (the
+ array 'input' has one column as a word at each index). In order to
+ mix a column, we perform these transformations on each row in c,
+ which is 1 byte in each word. The new column for c0 is c'0:
+
+ m0 m1 m2 m3
+ r0,c'0 = 2*r0,c0 + 3*r1,c0 + 1*r2,c0 + 1*r3,c0
+ r1,c'0 = 1*r0,c0 + 2*r1,c0 + 3*r2,c0 + 1*r3,c0
+ r2,c'0 = 1*r0,c0 + 1*r1,c0 + 2*r2,c0 + 3*r3,c0
+ r3,c'0 = 3*r0,c0 + 1*r1,c0 + 1*r2,c0 + 2*r3,c0
+
+ So using mix tables where c0 is a word with r0 being its upper
+ 8 bits and r3 being its lower 8 bits:
+
+ m0[c0 >> 24] will yield this word: [2*r0,1*r0,1*r0,3*r0]
+ ...
+ m3[c0 & 255] will yield this word: [1*r3,1*r3,3*r3,2*r3]
+
+ Therefore to mix the columns in each word in the state we
+ do the following (& 255 omitted for brevity):
+ c'0,r0 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]
+ c'0,r1 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]
+ c'0,r2 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]
+ c'0,r3 = m0[c0 >> 24] ^ m1[c1 >> 16] ^ m2[c2 >> 8] ^ m3[c3]
+
+ However, before mixing, the algorithm requires us to perform
+ ShiftRows(). The ShiftRows() transformation cyclically shifts the
+ last 3 rows of the state over different offsets. The first row
+ (r = 0) is not shifted.
+
+ s'_r,c = s_r,(c + shift(r, Nb) mod Nb
+ for 0 < r < 4 and 0 <= c < Nb and
+ shift(1, 4) = 1
+ shift(2, 4) = 2
+ shift(3, 4) = 3.
+
+ This causes the first byte in r = 1 to be moved to the end of
+ the row, the first 2 bytes in r = 2 to be moved to the end of
+ the row, the first 3 bytes in r = 3 to be moved to the end of
+ the row:
+
+ r1: [c0 c1 c2 c3] => [c1 c2 c3 c0]
+ r2: [c0 c1 c2 c3] [c2 c3 c0 c1]
+ r3: [c0 c1 c2 c3] [c3 c0 c1 c2]
+
+ We can make these substitutions inline with our column mixing to
+ generate an updated set of equations to produce each word in the
+ state (note the columns have changed positions):
+
+ c0 c1 c2 c3 => c0 c1 c2 c3
+ c0 c1 c2 c3 c1 c2 c3 c0 (cycled 1 byte)
+ c0 c1 c2 c3 c2 c3 c0 c1 (cycled 2 bytes)
+ c0 c1 c2 c3 c3 c0 c1 c2 (cycled 3 bytes)
+
+ Therefore:
+
+ c'0 = 2*r0,c0 + 3*r1,c1 + 1*r2,c2 + 1*r3,c3
+ c'0 = 1*r0,c0 + 2*r1,c1 + 3*r2,c2 + 1*r3,c3
+ c'0 = 1*r0,c0 + 1*r1,c1 + 2*r2,c2 + 3*r3,c3
+ c'0 = 3*r0,c0 + 1*r1,c1 + 1*r2,c2 + 2*r3,c3
+
+ c'1 = 2*r0,c1 + 3*r1,c2 + 1*r2,c3 + 1*r3,c0
+ c'1 = 1*r0,c1 + 2*r1,c2 + 3*r2,c3 + 1*r3,c0
+ c'1 = 1*r0,c1 + 1*r1,c2 + 2*r2,c3 + 3*r3,c0
+ c'1 = 3*r0,c1 + 1*r1,c2 + 1*r2,c3 + 2*r3,c0
+
+ ... and so forth for c'2 and c'3. The important distinction is
+ that the columns are cycling, with c0 being used with the m0
+ map when calculating c0, but c1 being used with the m0 map when
+ calculating c1 ... and so forth.
+
+ When performing the inverse we transform the mirror image and
+ skip the bottom row, instead of the top one, and move upwards:
+
+ c3 c2 c1 c0 => c0 c3 c2 c1 (cycled 3 bytes) *same as encryption
+ c3 c2 c1 c0 c1 c0 c3 c2 (cycled 2 bytes)
+ c3 c2 c1 c0 c2 c1 c0 c3 (cycled 1 byte) *same as encryption
+ c3 c2 c1 c0 c3 c2 c1 c0
+
+ If you compare the resulting matrices for ShiftRows()+MixColumns()
+ and for InvShiftRows()+InvMixColumns() the 2nd and 4th columns are
+ different (in encrypt mode vs. decrypt mode). So in order to use
+ the same code to handle both encryption and decryption, we will
+ need to do some mapping.
+
+ If in encryption mode we let a=c0, b=c1, c=c2, d=c3, and r<N> be
+ a row number in the state, then the resulting matrix in encryption
+ mode for applying the above transformations would be:
+
+ r1: a b c d
+ r2: b c d a
+ r3: c d a b
+ r4: d a b c
+
+ If we did the same in decryption mode we would get:
+
+ r1: a d c b
+ r2: b a d c
+ r3: c b a d
+ r4: d c b a
+
+ If instead we swap d and b (set b=c3 and d=c1), then we get:
+
+ r1: a b c d
+ r2: d a b c
+ r3: c d a b
+ r4: b c d a
+
+ Now the 1st and 3rd rows are the same as the encryption matrix. All
+ we need to do then to make the mapping exactly the same is to swap
+ the 2nd and 4th rows when in decryption mode. To do this without
+ having to do it on each iteration, we swapped the 2nd and 4th rows
+ in the decryption key schedule. We also have to do the swap above
+ when we first pull in the input and when we set the final output. */
+ a2 =
+ m0[a >>> 24] ^
+ m1[b >>> 16 & 255] ^
+ m2[c >>> 8 & 255] ^
+ m3[d & 255] ^ w[++i];
+ b2 =
+ m0[b >>> 24] ^
+ m1[c >>> 16 & 255] ^
+ m2[d >>> 8 & 255] ^
+ m3[a & 255] ^ w[++i];
+ c2 =
+ m0[c >>> 24] ^
+ m1[d >>> 16 & 255] ^
+ m2[a >>> 8 & 255] ^
+ m3[b & 255] ^ w[++i];
+ d =
+ m0[d >>> 24] ^
+ m1[a >>> 16 & 255] ^
+ m2[b >>> 8 & 255] ^
+ m3[c & 255] ^ w[++i];
+ a = a2;
+ b = b2;
+ c = c2;
+ }
+
+ /*
+ Encrypt:
+ SubBytes(state)
+ ShiftRows(state)
+ AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])
+
+ Decrypt:
+ InvShiftRows(state)
+ InvSubBytes(state)
+ AddRoundKey(state, w[0, Nb-1])
+ */
+ // Note: rows are shifted inline
+ output[0] =
+ (sub[a >>> 24] << 24) ^
+ (sub[b >>> 16 & 255] << 16) ^
+ (sub[c >>> 8 & 255] << 8) ^
+ (sub[d & 255]) ^ w[++i];
+ output[decrypt ? 3 : 1] =
+ (sub[b >>> 24] << 24) ^
+ (sub[c >>> 16 & 255] << 16) ^
+ (sub[d >>> 8 & 255] << 8) ^
+ (sub[a & 255]) ^ w[++i];
+ output[2] =
+ (sub[c >>> 24] << 24) ^
+ (sub[d >>> 16 & 255] << 16) ^
+ (sub[a >>> 8 & 255] << 8) ^
+ (sub[b & 255]) ^ w[++i];
+ output[decrypt ? 1 : 3] =
+ (sub[d >>> 24] << 24) ^
+ (sub[a >>> 16 & 255] << 16) ^
+ (sub[b >>> 8 & 255] << 8) ^
+ (sub[c & 255]) ^ w[++i];
+}
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * forge.cipher.createCipher('AES-<mode>', key);
+ * forge.cipher.createDecipher('AES-<mode>', key);
+ *
+ * Creates a deprecated AES cipher object. This object's mode will default to
+ * CBC (cipher-block-chaining).
+ *
+ * The key and iv may be given as a string of bytes, an array of bytes, a
+ * byte buffer, or an array of 32-bit words.
+ *
+ * @param options the options to use.
+ * key the symmetric key to use.
+ * output the buffer to write to.
+ * decrypt true for decryption, false for encryption.
+ * mode the cipher mode to use (default: 'CBC').
+ *
+ * @return the cipher.
+ */
+function _createCipher(options) {
+ options = options || {};
+ var mode = (options.mode || 'CBC').toUpperCase();
+ var algorithm = 'AES-' + mode;
+
+ var cipher;
+ if(options.decrypt) {
+ cipher = forge.cipher.createDecipher(algorithm, options.key);
+ } else {
+ cipher = forge.cipher.createCipher(algorithm, options.key);
+ }
+
+ // backwards compatible start API
+ var start = cipher.start;
+ cipher.start = function(iv, options) {
+ // backwards compatibility: support second arg as output buffer
+ var output = null;
+ if(options instanceof forge.util.ByteBuffer) {
+ output = options;
+ options = {};
+ }
+ options = options || {};
+ options.output = output;
+ options.iv = iv;
+ start.call(cipher, options);
+ };
+
+ return cipher;
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'aes';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(
+ ['require', 'module', './cipher', './cipherModes', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/aesCipherSuites.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/aesCipherSuites.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/aesCipherSuites.js
new file mode 100644
index 0000000..b0b4b4f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/aesCipherSuites.js
@@ -0,0 +1,312 @@
+/**
+ * A Javascript implementation of AES Cipher Suites for TLS.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2009-2014 Digital Bazaar, Inc.
+ *
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+var tls = forge.tls;
+
+/**
+ * Supported cipher suites.
+ */
+tls.CipherSuites['TLS_RSA_WITH_AES_128_CBC_SHA'] = {
+ id: [0x00,0x2f],
+ name: 'TLS_RSA_WITH_AES_128_CBC_SHA',
+ initSecurityParameters: function(sp) {
+ sp.bulk_cipher_algorithm = tls.BulkCipherAlgorithm.aes;
+ sp.cipher_type = tls.CipherType.block;
+ sp.enc_key_length = 16;
+ sp.block_length = 16;
+ sp.fixed_iv_length = 16;
+ sp.record_iv_length = 16;
+ sp.mac_algorithm = tls.MACAlgorithm.hmac_sha1;
+ sp.mac_length = 20;
+ sp.mac_key_length = 20;
+ },
+ initConnectionState: initConnectionState
+};
+tls.CipherSuites['TLS_RSA_WITH_AES_256_CBC_SHA'] = {
+ id: [0x00,0x35],
+ name: 'TLS_RSA_WITH_AES_256_CBC_SHA',
+ initSecurityParameters: function(sp) {
+ sp.bulk_cipher_algorithm = tls.BulkCipherAlgorithm.aes;
+ sp.cipher_type = tls.CipherType.block;
+ sp.enc_key_length = 32;
+ sp.block_length = 16;
+ sp.fixed_iv_length = 16;
+ sp.record_iv_length = 16;
+ sp.mac_algorithm = tls.MACAlgorithm.hmac_sha1;
+ sp.mac_length = 20;
+ sp.mac_key_length = 20;
+ },
+ initConnectionState: initConnectionState
+};
+
+function initConnectionState(state, c, sp) {
+ var client = (c.entity === forge.tls.ConnectionEnd.client);
+
+ // cipher setup
+ state.read.cipherState = {
+ init: false,
+ cipher: forge.cipher.createDecipher('AES-CBC', client ?
+ sp.keys.server_write_key : sp.keys.client_write_key),
+ iv: client ? sp.keys.server_write_IV : sp.keys.client_write_IV
+ };
+ state.write.cipherState = {
+ init: false,
+ cipher: forge.cipher.createCipher('AES-CBC', client ?
+ sp.keys.client_write_key : sp.keys.server_write_key),
+ iv: client ? sp.keys.client_write_IV : sp.keys.server_write_IV
+ };
+ state.read.cipherFunction = decrypt_aes_cbc_sha1;
+ state.write.cipherFunction = encrypt_aes_cbc_sha1;
+
+ // MAC setup
+ state.read.macLength = state.write.macLength = sp.mac_length;
+ state.read.macFunction = state.write.macFunction = tls.hmac_sha1;
+}
+
+/**
+ * Encrypts the TLSCompressed record into a TLSCipherText record using AES
+ * in CBC mode.
+ *
+ * @param record the TLSCompressed record to encrypt.
+ * @param s the ConnectionState to use.
+ *
+ * @return true on success, false on failure.
+ */
+function encrypt_aes_cbc_sha1(record, s) {
+ var rval = false;
+
+ // append MAC to fragment, update sequence number
+ var mac = s.macFunction(s.macKey, s.sequenceNumber, record);
+ record.fragment.putBytes(mac);
+ s.updateSequenceNumber();
+
+ // TLS 1.1+ use an explicit IV every time to protect against CBC attacks
+ var iv;
+ if(record.version.minor === tls.Versions.TLS_1_0.minor) {
+ // use the pre-generated IV when initializing for TLS 1.0, otherwise use
+ // the residue from the previous encryption
+ iv = s.cipherState.init ? null : s.cipherState.iv;
+ } else {
+ iv = forge.random.getBytesSync(16);
+ }
+
+ s.cipherState.init = true;
+
+ // start cipher
+ var cipher = s.cipherState.cipher;
+ cipher.start({iv: iv});
+
+ // TLS 1.1+ write IV into output
+ if(record.version.minor >= tls.Versions.TLS_1_1.minor) {
+ cipher.output.putBytes(iv);
+ }
+
+ // do encryption (default padding is appropriate)
+ cipher.update(record.fragment);
+ if(cipher.finish(encrypt_aes_cbc_sha1_padding)) {
+ // set record fragment to encrypted output
+ record.fragment = cipher.output;
+ record.length = record.fragment.length();
+ rval = true;
+ }
+
+ return rval;
+}
+
+/**
+ * Handles padding for aes_cbc_sha1 in encrypt mode.
+ *
+ * @param blockSize the block size.
+ * @param input the input buffer.
+ * @param decrypt true in decrypt mode, false in encrypt mode.
+ *
+ * @return true on success, false on failure.
+ */
+function encrypt_aes_cbc_sha1_padding(blockSize, input, decrypt) {
+ /* The encrypted data length (TLSCiphertext.length) is one more than the sum
+ of SecurityParameters.block_length, TLSCompressed.length,
+ SecurityParameters.mac_length, and padding_length.
+
+ The padding may be any length up to 255 bytes long, as long as it results in
+ the TLSCiphertext.length being an integral multiple of the block length.
+ Lengths longer than necessary might be desirable to frustrate attacks on a
+ protocol based on analysis of the lengths of exchanged messages. Each uint8
+ in the padding data vector must be filled with the padding length value.
+
+ The padding length should be such that the total size of the
+ GenericBlockCipher structure is a multiple of the cipher's block length.
+ Legal values range from zero to 255, inclusive. This length specifies the
+ length of the padding field exclusive of the padding_length field itself.
+
+ This is slightly different from PKCS#7 because the padding value is 1
+ less than the actual number of padding bytes if you include the
+ padding_length uint8 itself as a padding byte. */
+ if(!decrypt) {
+ // get the number of padding bytes required to reach the blockSize and
+ // subtract 1 for the padding value (to make room for the padding_length
+ // uint8)
+ var padding = blockSize - (input.length() % blockSize);
+ input.fillWithByte(padding - 1, padding);
+ }
+ return true;
+}
+
+/**
+ * Handles padding for aes_cbc_sha1 in decrypt mode.
+ *
+ * @param blockSize the block size.
+ * @param output the output buffer.
+ * @param decrypt true in decrypt mode, false in encrypt mode.
+ *
+ * @return true on success, false on failure.
+ */
+function decrypt_aes_cbc_sha1_padding(blockSize, output, decrypt) {
+ var rval = true;
+ if(decrypt) {
+ /* The last byte in the output specifies the number of padding bytes not
+ including itself. Each of the padding bytes has the same value as that
+ last byte (known as the padding_length). Here we check all padding
+ bytes to ensure they have the value of padding_length even if one of
+ them is bad in order to ward-off timing attacks. */
+ var len = output.length();
+ var paddingLength = output.last();
+ for(var i = len - 1 - paddingLength; i < len - 1; ++i) {
+ rval = rval && (output.at(i) == paddingLength);
+ }
+ if(rval) {
+ // trim off padding bytes and last padding length byte
+ output.truncate(paddingLength + 1);
+ }
+ }
+ return rval;
+}
+
+/**
+ * Decrypts a TLSCipherText record into a TLSCompressed record using
+ * AES in CBC mode.
+ *
+ * @param record the TLSCipherText record to decrypt.
+ * @param s the ConnectionState to use.
+ *
+ * @return true on success, false on failure.
+ */
+var count = 0;
+function decrypt_aes_cbc_sha1(record, s) {
+ var rval = false;
+ ++count;
+
+ var iv;
+ if(record.version.minor === tls.Versions.TLS_1_0.minor) {
+ // use pre-generated IV when initializing for TLS 1.0, otherwise use the
+ // residue from the previous decryption
+ iv = s.cipherState.init ? null : s.cipherState.iv;
+ } else {
+ // TLS 1.1+ use an explicit IV every time to protect against CBC attacks
+ // that is appended to the record fragment
+ iv = record.fragment.getBytes(16);
+ }
+
+ s.cipherState.init = true;
+
+ // start cipher
+ var cipher = s.cipherState.cipher;
+ cipher.start({iv: iv});
+
+ // do decryption
+ cipher.update(record.fragment);
+ rval = cipher.finish(decrypt_aes_cbc_sha1_padding);
+
+ // even if decryption fails, keep going to minimize timing attacks
+
+ // decrypted data:
+ // first (len - 20) bytes = application data
+ // last 20 bytes = MAC
+ var macLen = s.macLength;
+
+ // create a zero'd out mac
+ var mac = '';
+ for(var i = 0; i < macLen; ++i) {
+ mac += String.fromCharCode(0);
+ }
+
+ // get fragment and mac
+ var len = cipher.output.length();
+ if(len >= macLen) {
+ record.fragment = cipher.output.getBytes(len - macLen);
+ mac = cipher.output.getBytes(macLen);
+ } else {
+ // bad data, but get bytes anyway to try to keep timing consistent
+ record.fragment = cipher.output.getBytes();
+ }
+ record.fragment = forge.util.createBuffer(record.fragment);
+ record.length = record.fragment.length();
+
+ // see if data integrity checks out, update sequence number
+ var mac2 = s.macFunction(s.macKey, s.sequenceNumber, record);
+ s.updateSequenceNumber();
+ rval = (mac2 === mac) && rval;
+ return rval;
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'aesCipherSuites';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './aes', './tls'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/asn1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/asn1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/asn1.js
new file mode 100644
index 0000000..9ac7df4
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/asn1.js
@@ -0,0 +1,1114 @@
+/**
+ * Javascript implementation of Abstract Syntax Notation Number One.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ *
+ * An API for storing data using the Abstract Syntax Notation Number One
+ * format using DER (Distinguished Encoding Rules) encoding. This encoding is
+ * commonly used to store data for PKI, i.e. X.509 Certificates, and this
+ * implementation exists for that purpose.
+ *
+ * Abstract Syntax Notation Number One (ASN.1) is used to define the abstract
+ * syntax of information without restricting the way the information is encoded
+ * for transmission. It provides a standard that allows for open systems
+ * communication. ASN.1 defines the syntax of information data and a number of
+ * simple data types as well as a notation for describing them and specifying
+ * values for them.
+ *
+ * The RSA algorithm creates public and private keys that are often stored in
+ * X.509 or PKCS#X formats -- which use ASN.1 (encoded in DER format). This
+ * class provides the most basic functionality required to store and load DSA
+ * keys that are encoded according to ASN.1.
+ *
+ * The most common binary encodings for ASN.1 are BER (Basic Encoding Rules)
+ * and DER (Distinguished Encoding Rules). DER is just a subset of BER that
+ * has stricter requirements for how data must be encoded.
+ *
+ * Each ASN.1 structure has a tag (a byte identifying the ASN.1 structure type)
+ * and a byte array for the value of this ASN1 structure which may be data or a
+ * list of ASN.1 structures.
+ *
+ * Each ASN.1 structure using BER is (Tag-Length-Value):
+ *
+ * | byte 0 | bytes X | bytes Y |
+ * |--------|---------|----------
+ * | tag | length | value |
+ *
+ * ASN.1 allows for tags to be of "High-tag-number form" which allows a tag to
+ * be two or more octets, but that is not supported by this class. A tag is
+ * only 1 byte. Bits 1-5 give the tag number (ie the data type within a
+ * particular 'class'), 6 indicates whether or not the ASN.1 value is
+ * constructed from other ASN.1 values, and bits 7 and 8 give the 'class'. If
+ * bits 7 and 8 are both zero, the class is UNIVERSAL. If only bit 7 is set,
+ * then the class is APPLICATION. If only bit 8 is set, then the class is
+ * CONTEXT_SPECIFIC. If both bits 7 and 8 are set, then the class is PRIVATE.
+ * The tag numbers for the data types for the class UNIVERSAL are listed below:
+ *
+ * UNIVERSAL 0 Reserved for use by the encoding rules
+ * UNIVERSAL 1 Boolean type
+ * UNIVERSAL 2 Integer type
+ * UNIVERSAL 3 Bitstring type
+ * UNIVERSAL 4 Octetstring type
+ * UNIVERSAL 5 Null type
+ * UNIVERSAL 6 Object identifier type
+ * UNIVERSAL 7 Object descriptor type
+ * UNIVERSAL 8 External type and Instance-of type
+ * UNIVERSAL 9 Real type
+ * UNIVERSAL 10 Enumerated type
+ * UNIVERSAL 11 Embedded-pdv type
+ * UNIVERSAL 12 UTF8String type
+ * UNIVERSAL 13 Relative object identifier type
+ * UNIVERSAL 14-15 Reserved for future editions
+ * UNIVERSAL 16 Sequence and Sequence-of types
+ * UNIVERSAL 17 Set and Set-of types
+ * UNIVERSAL 18-22, 25-30 Character string types
+ * UNIVERSAL 23-24 Time types
+ *
+ * The length of an ASN.1 structure is specified after the tag identifier.
+ * There is a definite form and an indefinite form. The indefinite form may
+ * be used if the encoding is constructed and not all immediately available.
+ * The indefinite form is encoded using a length byte with only the 8th bit
+ * set. The end of the constructed object is marked using end-of-contents
+ * octets (two zero bytes).
+ *
+ * The definite form looks like this:
+ *
+ * The length may take up 1 or more bytes, it depends on the length of the
+ * value of the ASN.1 structure. DER encoding requires that if the ASN.1
+ * structure has a value that has a length greater than 127, more than 1 byte
+ * will be used to store its length, otherwise just one byte will be used.
+ * This is strict.
+ *
+ * In the case that the length of the ASN.1 value is less than 127, 1 octet
+ * (byte) is used to store the "short form" length. The 8th bit has a value of
+ * 0 indicating the length is "short form" and not "long form" and bits 7-1
+ * give the length of the data. (The 8th bit is the left-most, most significant
+ * bit: also known as big endian or network format).
+ *
+ * In the case that the length of the ASN.1 value is greater than 127, 2 to
+ * 127 octets (bytes) are used to store the "long form" length. The first
+ * byte's 8th bit is set to 1 to indicate the length is "long form." Bits 7-1
+ * give the number of additional octets. All following octets are in base 256
+ * with the most significant digit first (typical big-endian binary unsigned
+ * integer storage). So, for instance, if the length of a value was 257, the
+ * first byte would be set to:
+ *
+ * 10000010 = 130 = 0x82.
+ *
+ * This indicates there are 2 octets (base 256) for the length. The second and
+ * third bytes (the octets just mentioned) would store the length in base 256:
+ *
+ * octet 2: 00000001 = 1 * 256^1 = 256
+ * octet 3: 00000001 = 1 * 256^0 = 1
+ * total = 257
+ *
+ * The algorithm for converting a js integer value of 257 to base-256 is:
+ *
+ * var value = 257;
+ * var bytes = [];
+ * bytes[0] = (value >>> 8) & 0xFF; // most significant byte first
+ * bytes[1] = value & 0xFF; // least significant byte last
+ *
+ * On the ASN.1 UNIVERSAL Object Identifier (OID) type:
+ *
+ * An OID can be written like: "value1.value2.value3...valueN"
+ *
+ * The DER encoding rules:
+ *
+ * The first byte has the value 40 * value1 + value2.
+ * The following bytes, if any, encode the remaining values. Each value is
+ * encoded in base 128, most significant digit first (big endian), with as
+ * few digits as possible, and the most significant bit of each byte set
+ * to 1 except the last in each value's encoding. For example: Given the
+ * OID "1.2.840.113549", its DER encoding is (remember each byte except the
+ * last one in each encoding is OR'd with 0x80):
+ *
+ * byte 1: 40 * 1 + 2 = 42 = 0x2A.
+ * bytes 2-3: 128 * 6 + 72 = 840 = 6 72 = 6 72 = 0x0648 = 0x8648
+ * bytes 4-6: 16384 * 6 + 128 * 119 + 13 = 6 119 13 = 0x06770D = 0x86F70D
+ *
+ * The final value is: 0x2A864886F70D.
+ * The full OID (including ASN.1 tag and length of 6 bytes) is:
+ * 0x06062A864886F70D
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+/* ASN.1 API */
+var asn1 = forge.asn1 = forge.asn1 || {};
+
+/**
+ * ASN.1 classes.
+ */
+asn1.Class = {
+ UNIVERSAL: 0x00,
+ APPLICATION: 0x40,
+ CONTEXT_SPECIFIC: 0x80,
+ PRIVATE: 0xC0
+};
+
+/**
+ * ASN.1 types. Not all types are supported by this implementation, only
+ * those necessary to implement a simple PKI are implemented.
+ */
+asn1.Type = {
+ NONE: 0,
+ BOOLEAN: 1,
+ INTEGER: 2,
+ BITSTRING: 3,
+ OCTETSTRING: 4,
+ NULL: 5,
+ OID: 6,
+ ODESC: 7,
+ EXTERNAL: 8,
+ REAL: 9,
+ ENUMERATED: 10,
+ EMBEDDED: 11,
+ UTF8: 12,
+ ROID: 13,
+ SEQUENCE: 16,
+ SET: 17,
+ PRINTABLESTRING: 19,
+ IA5STRING: 22,
+ UTCTIME: 23,
+ GENERALIZEDTIME: 24,
+ BMPSTRING: 30
+};
+
+/**
+ * Creates a new asn1 object.
+ *
+ * @param tagClass the tag class for the object.
+ * @param type the data type (tag number) for the object.
+ * @param constructed true if the asn1 object is in constructed form.
+ * @param value the value for the object, if it is not constructed.
+ *
+ * @return the asn1 object.
+ */
+asn1.create = function(tagClass, type, constructed, value) {
+ /* An asn1 object has a tagClass, a type, a constructed flag, and a
+ value. The value's type depends on the constructed flag. If
+ constructed, it will contain a list of other asn1 objects. If not,
+ it will contain the ASN.1 value as an array of bytes formatted
+ according to the ASN.1 data type. */
+
+ // remove undefined values
+ if(forge.util.isArray(value)) {
+ var tmp = [];
+ for(var i = 0; i < value.length; ++i) {
+ if(value[i] !== undefined) {
+ tmp.push(value[i]);
+ }
+ }
+ value = tmp;
+ }
+
+ return {
+ tagClass: tagClass,
+ type: type,
+ constructed: constructed,
+ composed: constructed || forge.util.isArray(value),
+ value: value
+ };
+};
+
+/**
+ * Gets the length of an ASN.1 value.
+ *
+ * In case the length is not specified, undefined is returned.
+ *
+ * @param b the ASN.1 byte buffer.
+ *
+ * @return the length of the ASN.1 value.
+ */
+var _getValueLength = function(b) {
+ var b2 = b.getByte();
+ if(b2 === 0x80) {
+ return undefined;
+ }
+
+ // see if the length is "short form" or "long form" (bit 8 set)
+ var length;
+ var longForm = b2 & 0x80;
+ if(!longForm) {
+ // length is just the first byte
+ length = b2;
+ } else {
+ // the number of bytes the length is specified in bits 7 through 1
+ // and each length byte is in big-endian base-256
+ length = b.getInt((b2 & 0x7F) << 3);
+ }
+ return length;
+};
+
+/**
+ * Parses an asn1 object from a byte buffer in DER format.
+ *
+ * @param bytes the byte buffer to parse from.
+ * @param strict true to be strict when checking value lengths, false to
+ * allow truncated values (default: true).
+ *
+ * @return the parsed asn1 object.
+ */
+asn1.fromDer = function(bytes, strict) {
+ if(strict === undefined) {
+ strict = true;
+ }
+
+ // wrap in buffer if needed
+ if(typeof bytes === 'string') {
+ bytes = forge.util.createBuffer(bytes);
+ }
+
+ // minimum length for ASN.1 DER structure is 2
+ if(bytes.length() < 2) {
+ var error = new Error('Too few bytes to parse DER.');
+ error.bytes = bytes.length();
+ throw error;
+ }
+
+ // get the first byte
+ var b1 = bytes.getByte();
+
+ // get the tag class
+ var tagClass = (b1 & 0xC0);
+
+ // get the type (bits 1-5)
+ var type = b1 & 0x1F;
+
+ // get the value length
+ var length = _getValueLength(bytes);
+
+ // ensure there are enough bytes to get the value
+ if(bytes.length() < length) {
+ if(strict) {
+ var error = new Error('Too few bytes to read ASN.1 value.');
+ error.detail = bytes.length() + ' < ' + length;
+ throw error;
+ }
+ // Note: be lenient with truncated values
+ length = bytes.length();
+ }
+
+ // prepare to get value
+ var value;
+
+ // constructed flag is bit 6 (32 = 0x20) of the first byte
+ var constructed = ((b1 & 0x20) === 0x20);
+
+ // determine if the value is composed of other ASN.1 objects (if its
+ // constructed it will be and if its a BITSTRING it may be)
+ var composed = constructed;
+ if(!composed && tagClass === asn1.Class.UNIVERSAL &&
+ type === asn1.Type.BITSTRING && length > 1) {
+ /* The first octet gives the number of bits by which the length of the
+ bit string is less than the next multiple of eight (this is called
+ the "number of unused bits").
+
+ The second and following octets give the value of the bit string
+ converted to an octet string. */
+ // if there are no unused bits, maybe the bitstring holds ASN.1 objs
+ var read = bytes.read;
+ var unused = bytes.getByte();
+ if(unused === 0) {
+ // if the first byte indicates UNIVERSAL or CONTEXT_SPECIFIC,
+ // and the length is valid, assume we've got an ASN.1 object
+ b1 = bytes.getByte();
+ var tc = (b1 & 0xC0);
+ if(tc === asn1.Class.UNIVERSAL || tc === asn1.Class.CONTEXT_SPECIFIC) {
+ try {
+ var len = _getValueLength(bytes);
+ composed = (len === length - (bytes.read - read));
+ if(composed) {
+ // adjust read/length to account for unused bits byte
+ ++read;
+ --length;
+ }
+ } catch(ex) {}
+ }
+ }
+ // restore read pointer
+ bytes.read = read;
+ }
+
+ if(composed) {
+ // parse child asn1 objects from the value
+ value = [];
+ if(length === undefined) {
+ // asn1 object of indefinite length, read until end tag
+ for(;;) {
+ if(bytes.bytes(2) === String.fromCharCode(0, 0)) {
+ bytes.getBytes(2);
+ break;
+ }
+ value.push(asn1.fromDer(bytes, strict));
+ }
+ } else {
+ // parsing asn1 object of definite length
+ var start = bytes.length();
+ while(length > 0) {
+ value.push(asn1.fromDer(bytes, strict));
+ length -= start - bytes.length();
+ start = bytes.length();
+ }
+ }
+ } else {
+ // asn1 not composed, get raw value
+ // TODO: do DER to OID conversion and vice-versa in .toDer?
+
+ if(length === undefined) {
+ if(strict) {
+ throw new Error('Non-constructed ASN.1 object of indefinite length.');
+ }
+ // be lenient and use remaining bytes
+ length = bytes.length();
+ }
+
+ if(type === asn1.Type.BMPSTRING) {
+ value = '';
+ for(var i = 0; i < length; i += 2) {
+ value += String.fromCharCode(bytes.getInt16());
+ }
+ } else {
+ value = bytes.getBytes(length);
+ }
+ }
+
+ // create and return asn1 object
+ return asn1.create(tagClass, type, constructed, value);
+};
+
+/**
+ * Converts the given asn1 object to a buffer of bytes in DER format.
+ *
+ * @param asn1 the asn1 object to convert to bytes.
+ *
+ * @return the buffer of bytes.
+ */
+asn1.toDer = function(obj) {
+ var bytes = forge.util.createBuffer();
+
+ // build the first byte
+ var b1 = obj.tagClass | obj.type;
+
+ // for storing the ASN.1 value
+ var value = forge.util.createBuffer();
+
+ // if composed, use each child asn1 object's DER bytes as value
+ if(obj.composed) {
+ // turn on 6th bit (0x20 = 32) to indicate asn1 is constructed
+ // from other asn1 objects
+ if(obj.constructed) {
+ b1 |= 0x20;
+ } else {
+ // type is a bit string, add unused bits of 0x00
+ value.putByte(0x00);
+ }
+
+ // add all of the child DER bytes together
+ for(var i = 0; i < obj.value.length; ++i) {
+ if(obj.value[i] !== undefined) {
+ value.putBuffer(asn1.toDer(obj.value[i]));
+ }
+ }
+ } else {
+ // use asn1.value directly
+ if(obj.type === asn1.Type.BMPSTRING) {
+ for(var i = 0; i < obj.value.length; ++i) {
+ value.putInt16(obj.value.charCodeAt(i));
+ }
+ } else {
+ value.putBytes(obj.value);
+ }
+ }
+
+ // add tag byte
+ bytes.putByte(b1);
+
+ // use "short form" encoding
+ if(value.length() <= 127) {
+ // one byte describes the length
+ // bit 8 = 0 and bits 7-1 = length
+ bytes.putByte(value.length() & 0x7F);
+ } else {
+ // use "long form" encoding
+ // 2 to 127 bytes describe the length
+ // first byte: bit 8 = 1 and bits 7-1 = # of additional bytes
+ // other bytes: length in base 256, big-endian
+ var len = value.length();
+ var lenBytes = '';
+ do {
+ lenBytes += String.fromCharCode(len & 0xFF);
+ len = len >>> 8;
+ } while(len > 0);
+
+ // set first byte to # bytes used to store the length and turn on
+ // bit 8 to indicate long-form length is used
+ bytes.putByte(lenBytes.length | 0x80);
+
+ // concatenate length bytes in reverse since they were generated
+ // little endian and we need big endian
+ for(var i = lenBytes.length - 1; i >= 0; --i) {
+ bytes.putByte(lenBytes.charCodeAt(i));
+ }
+ }
+
+ // concatenate value bytes
+ bytes.putBuffer(value);
+ return bytes;
+};
+
+/**
+ * Converts an OID dot-separated string to a byte buffer. The byte buffer
+ * contains only the DER-encoded value, not any tag or length bytes.
+ *
+ * @param oid the OID dot-separated string.
+ *
+ * @return the byte buffer.
+ */
+asn1.oidToDer = function(oid) {
+ // split OID into individual values
+ var values = oid.split('.');
+ var bytes = forge.util.createBuffer();
+
+ // first byte is 40 * value1 + value2
+ bytes.putByte(40 * parseInt(values[0], 10) + parseInt(values[1], 10));
+ // other bytes are each value in base 128 with 8th bit set except for
+ // the last byte for each value
+ var last, valueBytes, value, b;
+ for(var i = 2; i < values.length; ++i) {
+ // produce value bytes in reverse because we don't know how many
+ // bytes it will take to store the value
+ last = true;
+ valueBytes = [];
+ value = parseInt(values[i], 10);
+ do {
+ b = value & 0x7F;
+ value = value >>> 7;
+ // if value is not last, then turn on 8th bit
+ if(!last) {
+ b |= 0x80;
+ }
+ valueBytes.push(b);
+ last = false;
+ } while(value > 0);
+
+ // add value bytes in reverse (needs to be in big endian)
+ for(var n = valueBytes.length - 1; n >= 0; --n) {
+ bytes.putByte(valueBytes[n]);
+ }
+ }
+
+ return bytes;
+};
+
+/**
+ * Converts a DER-encoded byte buffer to an OID dot-separated string. The
+ * byte buffer should contain only the DER-encoded value, not any tag or
+ * length bytes.
+ *
+ * @param bytes the byte buffer.
+ *
+ * @return the OID dot-separated string.
+ */
+asn1.derToOid = function(bytes) {
+ var oid;
+
+ // wrap in buffer if needed
+ if(typeof bytes === 'string') {
+ bytes = forge.util.createBuffer(bytes);
+ }
+
+ // first byte is 40 * value1 + value2
+ var b = bytes.getByte();
+ oid = Math.floor(b / 40) + '.' + (b % 40);
+
+ // other bytes are each value in base 128 with 8th bit set except for
+ // the last byte for each value
+ var value = 0;
+ while(bytes.length() > 0) {
+ b = bytes.getByte();
+ value = value << 7;
+ // not the last byte for the value
+ if(b & 0x80) {
+ value += b & 0x7F;
+ } else {
+ // last byte
+ oid += '.' + (value + b);
+ value = 0;
+ }
+ }
+
+ return oid;
+};
+
+/**
+ * Converts a UTCTime value to a date.
+ *
+ * Note: GeneralizedTime has 4 digits for the year and is used for X.509
+ * dates passed 2049. Parsing that structure hasn't been implemented yet.
+ *
+ * @param utc the UTCTime value to convert.
+ *
+ * @return the date.
+ */
+asn1.utcTimeToDate = function(utc) {
+ /* The following formats can be used:
+
+ YYMMDDhhmmZ
+ YYMMDDhhmm+hh'mm'
+ YYMMDDhhmm-hh'mm'
+ YYMMDDhhmmssZ
+ YYMMDDhhmmss+hh'mm'
+ YYMMDDhhmmss-hh'mm'
+
+ Where:
+
+ YY is the least significant two digits of the year
+ MM is the month (01 to 12)
+ DD is the day (01 to 31)
+ hh is the hour (00 to 23)
+ mm are the minutes (00 to 59)
+ ss are the seconds (00 to 59)
+ Z indicates that local time is GMT, + indicates that local time is
+ later than GMT, and - indicates that local time is earlier than GMT
+ hh' is the absolute value of the offset from GMT in hours
+ mm' is the absolute value of the offset from GMT in minutes */
+ var date = new Date();
+
+ // if YY >= 50 use 19xx, if YY < 50 use 20xx
+ var year = parseInt(utc.substr(0, 2), 10);
+ year = (year >= 50) ? 1900 + year : 2000 + year;
+ var MM = parseInt(utc.substr(2, 2), 10) - 1; // use 0-11 for month
+ var DD = parseInt(utc.substr(4, 2), 10);
+ var hh = parseInt(utc.substr(6, 2), 10);
+ var mm = parseInt(utc.substr(8, 2), 10);
+ var ss = 0;
+
+ // not just YYMMDDhhmmZ
+ if(utc.length > 11) {
+ // get character after minutes
+ var c = utc.charAt(10);
+ var end = 10;
+
+ // see if seconds are present
+ if(c !== '+' && c !== '-') {
+ // get seconds
+ ss = parseInt(utc.substr(10, 2), 10);
+ end += 2;
+ }
+ }
+
+ // update date
+ date.setUTCFullYear(year, MM, DD);
+ date.setUTCHours(hh, mm, ss, 0);
+
+ if(end) {
+ // get +/- after end of time
+ c = utc.charAt(end);
+ if(c === '+' || c === '-') {
+ // get hours+minutes offset
+ var hhoffset = parseInt(utc.substr(end + 1, 2), 10);
+ var mmoffset = parseInt(utc.substr(end + 4, 2), 10);
+
+ // calculate offset in milliseconds
+ var offset = hhoffset * 60 + mmoffset;
+ offset *= 60000;
+
+ // apply offset
+ if(c === '+') {
+ date.setTime(+date - offset);
+ } else {
+ date.setTime(+date + offset);
+ }
+ }
+ }
+
+ return date;
+};
+
+/**
+ * Converts a GeneralizedTime value to a date.
+ *
+ * @param gentime the GeneralizedTime value to convert.
+ *
+ * @return the date.
+ */
+asn1.generalizedTimeToDate = function(gentime) {
+ /* The following formats can be used:
+
+ YYYYMMDDHHMMSS
+ YYYYMMDDHHMMSS.fff
+ YYYYMMDDHHMMSSZ
+ YYYYMMDDHHMMSS.fffZ
+ YYYYMMDDHHMMSS+hh'mm'
+ YYYYMMDDHHMMSS.fff+hh'mm'
+ YYYYMMDDHHMMSS-hh'mm'
+ YYYYMMDDHHMMSS.fff-hh'mm'
+
+ Where:
+
+ YYYY is the year
+ MM is the month (01 to 12)
+ DD is the day (01 to 31)
+ hh is the hour (00 to 23)
+ mm are the minutes (00 to 59)
+ ss are the seconds (00 to 59)
+ .fff is the second fraction, accurate to three decimal places
+ Z indicates that local time is GMT, + indicates that local time is
+ later than GMT, and - indicates that local time is earlier than GMT
+ hh' is the absolute value of the offset from GMT in hours
+ mm' is the absolute value of the offset from GMT in minutes */
+ var date = new Date();
+
+ var YYYY = parseInt(gentime.substr(0, 4), 10);
+ var MM = parseInt(gentime.substr(4, 2), 10) - 1; // use 0-11 for month
+ var DD = parseInt(gentime.substr(6, 2), 10);
+ var hh = parseInt(gentime.substr(8, 2), 10);
+ var mm = parseInt(gentime.substr(10, 2), 10);
+ var ss = parseInt(gentime.substr(12, 2), 10);
+ var fff = 0;
+ var offset = 0;
+ var isUTC = false;
+
+ if(gentime.charAt(gentime.length - 1) === 'Z') {
+ isUTC = true;
+ }
+
+ var end = gentime.length - 5, c = gentime.charAt(end);
+ if(c === '+' || c === '-') {
+ // get hours+minutes offset
+ var hhoffset = parseInt(gentime.substr(end + 1, 2), 10);
+ var mmoffset = parseInt(gentime.substr(end + 4, 2), 10);
+
+ // calculate offset in milliseconds
+ offset = hhoffset * 60 + mmoffset;
+ offset *= 60000;
+
+ // apply offset
+ if(c === '+') {
+ offset *= -1;
+ }
+
+ isUTC = true;
+ }
+
+ // check for second fraction
+ if(gentime.charAt(14) === '.') {
+ fff = parseFloat(gentime.substr(14), 10) * 1000;
+ }
+
+ if(isUTC) {
+ date.setUTCFullYear(YYYY, MM, DD);
+ date.setUTCHours(hh, mm, ss, fff);
+
+ // apply offset
+ date.setTime(+date + offset);
+ } else {
+ date.setFullYear(YYYY, MM, DD);
+ date.setHours(hh, mm, ss, fff);
+ }
+
+ return date;
+};
+
+
+/**
+ * Converts a date to a UTCTime value.
+ *
+ * Note: GeneralizedTime has 4 digits for the year and is used for X.509
+ * dates passed 2049. Converting to a GeneralizedTime hasn't been
+ * implemented yet.
+ *
+ * @param date the date to convert.
+ *
+ * @return the UTCTime value.
+ */
+asn1.dateToUtcTime = function(date) {
+ var rval = '';
+
+ // create format YYMMDDhhmmssZ
+ var format = [];
+ format.push(('' + date.getUTCFullYear()).substr(2));
+ format.push('' + (date.getUTCMonth() + 1));
+ format.push('' + date.getUTCDate());
+ format.push('' + date.getUTCHours());
+ format.push('' + date.getUTCMinutes());
+ format.push('' + date.getUTCSeconds());
+
+ // ensure 2 digits are used for each format entry
+ for(var i = 0; i < format.length; ++i) {
+ if(format[i].length < 2) {
+ rval += '0';
+ }
+ rval += format[i];
+ }
+ rval += 'Z';
+
+ return rval;
+};
+
+/**
+ * Converts a javascript integer to a DER-encoded byte buffer to be used
+ * as the value for an INTEGER type.
+ *
+ * @param x the integer.
+ *
+ * @return the byte buffer.
+ */
+asn1.integerToDer = function(x) {
+ var rval = forge.util.createBuffer();
+ if(x >= -0x80 && x < 0x80) {
+ return rval.putSignedInt(x, 8);
+ }
+ if(x >= -0x8000 && x < 0x8000) {
+ return rval.putSignedInt(x, 16);
+ }
+ if(x >= -0x800000 && x < 0x800000) {
+ return rval.putSignedInt(x, 24);
+ }
+ if(x >= -0x80000000 && x < 0x80000000) {
+ return rval.putSignedInt(x, 32);
+ }
+ var error = new Error('Integer too large; max is 32-bits.');
+ error.integer = x;
+ throw error;
+};
+
+/**
+ * Converts a DER-encoded byte buffer to a javascript integer. This is
+ * typically used to decode the value of an INTEGER type.
+ *
+ * @param bytes the byte buffer.
+ *
+ * @return the integer.
+ */
+asn1.derToInteger = function(bytes) {
+ // wrap in buffer if needed
+ if(typeof bytes === 'string') {
+ bytes = forge.util.createBuffer(bytes);
+ }
+
+ var n = bytes.length() * 8;
+ if(n > 32) {
+ throw new Error('Integer too large; max is 32-bits.');
+ }
+ return bytes.getSignedInt(n);
+};
+
+/**
+ * Validates the that given ASN.1 object is at least a super set of the
+ * given ASN.1 structure. Only tag classes and types are checked. An
+ * optional map may also be provided to capture ASN.1 values while the
+ * structure is checked.
+ *
+ * To capture an ASN.1 value, set an object in the validator's 'capture'
+ * parameter to the key to use in the capture map. To capture the full
+ * ASN.1 object, specify 'captureAsn1'.
+ *
+ * Objects in the validator may set a field 'optional' to true to indicate
+ * that it isn't necessary to pass validation.
+ *
+ * @param obj the ASN.1 object to validate.
+ * @param v the ASN.1 structure validator.
+ * @param capture an optional map to capture values in.
+ * @param errors an optional array for storing validation errors.
+ *
+ * @return true on success, false on failure.
+ */
+asn1.validate = function(obj, v, capture, errors) {
+ var rval = false;
+
+ // ensure tag class and type are the same if specified
+ if((obj.tagClass === v.tagClass || typeof(v.tagClass) === 'undefined') &&
+ (obj.type === v.type || typeof(v.type) === 'undefined')) {
+ // ensure constructed flag is the same if specified
+ if(obj.constructed === v.constructed ||
+ typeof(v.constructed) === 'undefined') {
+ rval = true;
+
+ // handle sub values
+ if(v.value && forge.util.isArray(v.value)) {
+ var j = 0;
+ for(var i = 0; rval && i < v.value.length; ++i) {
+ rval = v.value[i].optional || false;
+ if(obj.value[j]) {
+ rval = asn1.validate(obj.value[j], v.value[i], capture, errors);
+ if(rval) {
+ ++j;
+ } else if(v.value[i].optional) {
+ rval = true;
+ }
+ }
+ if(!rval && errors) {
+ errors.push(
+ '[' + v.name + '] ' +
+ 'Tag class "' + v.tagClass + '", type "' +
+ v.type + '" expected value length "' +
+ v.value.length + '", got "' +
+ obj.value.length + '"');
+ }
+ }
+ }
+
+ if(rval && capture) {
+ if(v.capture) {
+ capture[v.capture] = obj.value;
+ }
+ if(v.captureAsn1) {
+ capture[v.captureAsn1] = obj;
+ }
+ }
+ } else if(errors) {
+ errors.push(
+ '[' + v.name + '] ' +
+ 'Expected constructed "' + v.constructed + '", got "' +
+ obj.constructed + '"');
+ }
+ } else if(errors) {
+ if(obj.tagClass !== v.tagClass) {
+ errors.push(
+ '[' + v.name + '] ' +
+ 'Expected tag class "' + v.tagClass + '", got "' +
+ obj.tagClass + '"');
+ }
+ if(obj.type !== v.type) {
+ errors.push(
+ '[' + v.name + '] ' +
+ 'Expected type "' + v.type + '", got "' + obj.type + '"');
+ }
+ }
+ return rval;
+};
+
+// regex for testing for non-latin characters
+var _nonLatinRegex = /[^\\u0000-\\u00ff]/;
+
+/**
+ * Pretty prints an ASN.1 object to a string.
+ *
+ * @param obj the object to write out.
+ * @param level the level in the tree.
+ * @param indentation the indentation to use.
+ *
+ * @return the string.
+ */
+asn1.prettyPrint = function(obj, level, indentation) {
+ var rval = '';
+
+ // set default level and indentation
+ level = level || 0;
+ indentation = indentation || 2;
+
+ // start new line for deep levels
+ if(level > 0) {
+ rval += '\n';
+ }
+
+ // create indent
+ var indent = '';
+ for(var i = 0; i < level * indentation; ++i) {
+ indent += ' ';
+ }
+
+ // print class:type
+ rval += indent + 'Tag: ';
+ switch(obj.tagClass) {
+ case asn1.Class.UNIVERSAL:
+ rval += 'Universal:';
+ break;
+ case asn1.Class.APPLICATION:
+ rval += 'Application:';
+ break;
+ case asn1.Class.CONTEXT_SPECIFIC:
+ rval += 'Context-Specific:';
+ break;
+ case asn1.Class.PRIVATE:
+ rval += 'Private:';
+ break;
+ }
+
+ if(obj.tagClass === asn1.Class.UNIVERSAL) {
+ rval += obj.type;
+
+ // known types
+ switch(obj.type) {
+ case asn1.Type.NONE:
+ rval += ' (None)';
+ break;
+ case asn1.Type.BOOLEAN:
+ rval += ' (Boolean)';
+ break;
+ case asn1.Type.BITSTRING:
+ rval += ' (Bit string)';
+ break;
+ case asn1.Type.INTEGER:
+ rval += ' (Integer)';
+ break;
+ case asn1.Type.OCTETSTRING:
+ rval += ' (Octet string)';
+ break;
+ case asn1.Type.NULL:
+ rval += ' (Null)';
+ break;
+ case asn1.Type.OID:
+ rval += ' (Object Identifier)';
+ break;
+ case asn1.Type.ODESC:
+ rval += ' (Object Descriptor)';
+ break;
+ case asn1.Type.EXTERNAL:
+ rval += ' (External or Instance of)';
+ break;
+ case asn1.Type.REAL:
+ rval += ' (Real)';
+ break;
+ case asn1.Type.ENUMERATED:
+ rval += ' (Enumerated)';
+ break;
+ case asn1.Type.EMBEDDED:
+ rval += ' (Embedded PDV)';
+ break;
+ case asn1.Type.UTF8:
+ rval += ' (UTF8)';
+ break;
+ case asn1.Type.ROID:
+ rval += ' (Relative Object Identifier)';
+ break;
+ case asn1.Type.SEQUENCE:
+ rval += ' (Sequence)';
+ break;
+ case asn1.Type.SET:
+ rval += ' (Set)';
+ break;
+ case asn1.Type.PRINTABLESTRING:
+ rval += ' (Printable String)';
+ break;
+ case asn1.Type.IA5String:
+ rval += ' (IA5String (ASCII))';
+ break;
+ case asn1.Type.UTCTIME:
+ rval += ' (UTC time)';
+ break;
+ case asn1.Type.GENERALIZEDTIME:
+ rval += ' (Generalized time)';
+ break;
+ case asn1.Type.BMPSTRING:
+ rval += ' (BMP String)';
+ break;
+ }
+ } else {
+ rval += obj.type;
+ }
+
+ rval += '\n';
+ rval += indent + 'Constructed: ' + obj.constructed + '\n';
+
+ if(obj.composed) {
+ var subvalues = 0;
+ var sub = '';
+ for(var i = 0; i < obj.value.length; ++i) {
+ if(obj.value[i] !== undefined) {
+ subvalues += 1;
+ sub += asn1.prettyPrint(obj.value[i], level + 1, indentation);
+ if((i + 1) < obj.value.length) {
+ sub += ',';
+ }
+ }
+ }
+ rval += indent + 'Sub values: ' + subvalues + sub;
+ } else {
+ rval += indent + 'Value: ';
+ if(obj.type === asn1.Type.OID) {
+ var oid = asn1.derToOid(obj.value);
+ rval += oid;
+ if(forge.pki && forge.pki.oids) {
+ if(oid in forge.pki.oids) {
+ rval += ' (' + forge.pki.oids[oid] + ') ';
+ }
+ }
+ }
+ if(obj.type === asn1.Type.INTEGER) {
+ try {
+ rval += asn1.derToInteger(obj.value);
+ } catch(ex) {
+ rval += '0x' + forge.util.bytesToHex(obj.value);
+ }
+ } else if(obj.type === asn1.Type.OCTETSTRING) {
+ if(!_nonLatinRegex.test(obj.value)) {
+ rval += '(' + obj.value + ') ';
+ }
+ rval += '0x' + forge.util.bytesToHex(obj.value);
+ } else if(obj.type === asn1.Type.UTF8) {
+ rval += forge.util.decodeUtf8(obj.value);
+ } else if(obj.type === asn1.Type.PRINTABLESTRING ||
+ obj.type === asn1.Type.IA5String) {
+ rval += obj.value;
+ } else if(_nonLatinRegex.test(obj.value)) {
+ rval += '0x' + forge.util.bytesToHex(obj.value);
+ } else if(obj.value.length === 0) {
+ rval += '[null]';
+ } else {
+ rval += obj.value;
+ }
+ }
+
+ return rval;
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'asn1';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util', './oids'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[17/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/Makefile.in
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/Makefile.in b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/Makefile.in
new file mode 100644
index 0000000..eb4495e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/Makefile.in
@@ -0,0 +1,110 @@
+# Makefile for Forge
+
+# Top-level build and dist dir
+BUILD_DIR=@FORGE_DIR@/build
+TOP_DIST_DIR=@FORGE_DIR@/dist
+DIST_DIR=$(TOP_DIST_DIR)/forge
+
+_FLASH := $(DIST_DIR)/SocketPool.swf
+ifeq (@BUILD_FLASH@,yes)
+FLASH := $(_FLASH)
+else
+ifeq (@USE_PRE_BUILT_FLASH@,yes)
+FLASH := $(_FLASH)
+endif
+endif
+JS_SOURCES := $(wildcard js/*.js)
+JS_DIST := $(JS_SOURCES:js/%.js=$(DIST_DIR)/%.js)
+JS_DIST_MIN := $(JS_DIST:%.js=%.min.js)
+TESTS_FORGE_LINK := @FORGE_DIR@/tests/forge
+
+ifeq (@BUILD_PYTHON_MODULES@,yes)
+SSL_SESSIONS_DIR = \
+ $(TOP_DIST_DIR)/forge_ssl/lib/python@PYTHON_VERSION@/site-packages
+SSL_SESSIONS_FILES = \
+ $(SSL_SESSIONS_DIR)/_forge_ssl.so \
+ $(SSL_SESSIONS_DIR)/forge/ssl.py
+endif
+
+# Whether or not to print commands as they are being executed, helpful for
+# debugging the build system.
+ifdef PRINT_COMMANDS
+PCMD=
+else
+PCMD=@
+endif
+
+.PHONY: all build-all update-all verbose clean verbose-commands
+
+# debug flags for flash build
+ifeq (@MXMLC_DEBUG_MODE@,yes)
+FLASH_FLAGS = \
+ -debug=true \
+ -define=CONFIG::debugging,true \
+ -define=CONFIG::release,false
+else
+FLASH_FLAGS = \
+ -debug=false \
+ -define=CONFIG::debugging,false \
+ -define=CONFIG::release,true
+endif
+
+all: $(BUILD_DIR) $(DIST_DIR) $(FLASH) $(JS_DIST) $(TESTS_FORGE_LINK) $(SSL_SESSIONS_FILES)
+ @echo "forge build complete."
+
+build-all: all
+
+update-all:
+ @git pull && ./build-setup && make all
+
+$(BUILD_DIR):
+ $(PCMD) mkdir -p $@
+$(DIST_DIR):
+ $(PCMD) mkdir -p $@
+
+ifeq (@BUILD_FLASH@,yes)
+$(DIST_DIR)/SocketPool.swf: flash/SocketPool.as flash/PooledSocket.as flash/SocketEvent.as
+ @echo "Building $@..."
+ $(PCMD) @MXMLC@ $(FLASH_FLAGS) \
+ -load-config+=build-flash.xml \
+ -output=$@ $<
+else
+ifeq (@USE_PRE_BUILT_FLASH@,yes)
+$(DIST_DIR)/SocketPool.swf: @FORGE_DIR@/swf/SocketPool.swf
+ @echo "Copying pre-built $(@F)..."
+ $(PCMD) cp $< $@
+endif
+endif
+
+$(DIST_DIR)/%.js: js/%.js
+ @echo "Linking $@..."
+ $(PCMD) ln -sf $(realpath $<) $@
+
+$(TESTS_FORGE_LINK): $(DIST_DIR)
+ @echo "Linking $@..."
+ $(PCMD) ln -sf $(realpath $<) $@
+
+ifeq (@BUILD_PYTHON_MODULES@,yes)
+$(SSL_SESSIONS_DIR)/_forge_ssl.so: \
+ @FORGE_DIR@/tests/forge_ssl/forge/_ssl.c \
+ @FORGE_DIR@/tests/forge_ssl/forge/socketmodule.h \
+ @FORGE_DIR@/tests/forge_ssl/setup.py
+$(SSL_SESSIONS_DIR)/forge/ssl.py: \
+ @FORGE_DIR@/tests/forge_ssl/forge/ssl.py \
+ @FORGE_DIR@/tests/forge_ssl/setup.py
+ (cd @FORGE_DIR@/tests/forge_ssl && \
+ @PYTHON@ setup.py \
+ build --build-base $(BUILD_DIR) \
+ install --prefix=$(TOP_DIST_DIR)/forge_ssl)
+ @# fix distutils timestamp issue
+ @# (sub-seconds of source file are truncated on target so rebuild is
+ @# always triggered)
+ @touch $@
+endif
+
+clean:
+ $(PCMD) rm -rf $(BUILD_DIR) $(TOP_DIST_DIR)
+ @echo "Removed all generated files."
+
+verbose-commands:
+ PRINT_COMMANDS=true $(MAKE) all
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/README.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/README.md
new file mode 100644
index 0000000..00eb178
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/README.md
@@ -0,0 +1,1782 @@
+# Forge
+
+[![Build Status][travis-ci-png]][travis-ci-site]
+[travis-ci-png]: https://travis-ci.org/digitalbazaar/forge.png?branch=master
+[travis-ci-site]: https://travis-ci.org/digitalbazaar/forge
+
+A native implementation of [TLS][] (and various other cryptographic tools) in
+[JavaScript][].
+
+## Introduction
+
+The Forge software is a fully native implementation of the [TLS][] protocol in
+JavaScript as well as a set of tools for developing Web Apps that utilize many
+network resources.
+
+## Performance
+
+Forge is fast. Benchmarks against other popular JavaScript cryptography
+libraries can be found here:
+
+http://dominictarr.github.io/crypto-bench/
+
+http://cryptojs.altervista.org/test/simulate-threading-speed_test.html
+
+## Getting Started
+------------------
+
+### Node.js ###
+
+If you want to use forge with [node.js][], it is available through `npm`:
+
+https://npmjs.org/package/node-forge
+
+Installation:
+
+ npm install node-forge
+
+You can then use forge as a regular module:
+
+ var forge = require('node-forge');
+
+### Requirements ###
+
+* General
+ * Optional: GNU autotools for the build infrastructure if using Flash.
+* Building a Browser Bundle:
+ * nodejs
+ * npm
+* Testing
+ * nodejs
+ * Optional: Python and OpenSSL development environment to build
+ * a special SSL module with session cache support for testing with flash.
+ * http://www.python.org/dev/
+ * http://www.openssl.org/
+ * Debian users should install python-dev and libssl-dev.
+* Optional: Flash
+ * A pre-built SocketPool.swf is included.
+ * Adobe Flex 3 SDK to build the Flash socket code.
+ * http://opensource.adobe.com/wiki/display/flexsdk/
+
+### Building a browser bundle ###
+
+To create a minimized JavaScript bundle, run the following:
+
+```
+npm install
+npm run minify
+```
+
+This will create a single minimized file that can be included in
+the browser:
+
+```
+js/forge.min.js
+```
+
+Include the file via:
+
+```html
+<script src="js/forge.min.js"></script>
+```
+
+Note that the minify script depends on the requirejs package,
+and that the requirejs binary 'r.js' assumes that the name of
+the node binary is 'node' not 'nodejs', as it is on some
+systems. You may need to change the hashbang line to use
+'nodejs' or run the command manually.
+
+To create a single non-minimized file that can be included in
+the browser:
+
+```
+npm install
+npm run bundle
+```
+
+This will create:
+
+```
+js/forge.bundle.js
+```
+
+Include the file via:
+
+```html
+<script src="js/forge.bundle.js"></script>
+```
+
+The above bundles will synchronously create a global 'forge' object.
+
+Keep in mind that these bundles will not include any WebWorker
+scripts (eg: prime.worker.js) or their dependencies, so these will
+need to be accessible from the browser if any WebWorkers are used.
+
+### Testing with NodeJS & RequireJS ###
+
+A test server for [node.js][] can be found at `./nodejs`. The following are included:
+
+ * Example of how to use `forge` within NodeJS in the form of a [mocha](http://visionmedia.github.io/mocha/) test.
+ * Example of how to serve `forge` to the browser using [RequireJS](http://requirejs.org/).
+
+To run:
+
+ cd nodejs
+ npm install
+ npm test
+ npm start
+
+
+### Old build system that includes flash support ###
+
+To build the whole project, including Flash, run the following:
+
+ $ ./build-setup
+ $ make
+
+This will create the SWF, symlink all the JavaScript files, and build a Python
+SSL module for testing. To see configure options, run `./configure --help`.
+
+### Old test system including flash support ###
+
+A test server is provided which can be run in TLS mode and non-TLS mode. Use
+the --help option to get help for configuring ports. The server will print out
+the local URL you can vist to run tests.
+
+Some of the simplier tests should be run with just the non-TLS server::
+
+ $ ./tests/server.py
+
+More advanced tests need TLS enabled::
+
+ $ ./tests/server.py --tls
+
+## Contributing
+---------------
+
+Any contributions (eg: PRs) that are accepted will be brought under the same
+license used by the rest of the Forge project. This license allows Forge to
+be used under the terms of either the BSD License or the GNU General Public
+License (GPL) Version 2.
+
+See: [LICENSE](https://github.com/digitalbazaar/forge/blob/cbebca3780658703d925b61b2caffb1d263a6c1d/LICENSE)
+
+If a contribution contains 3rd party source code with its own license, it
+may retain it, so long as that license is compatible with the Forge license.
+
+## Documentation
+----------------
+
+### Transports
+
+* [TLS](#tls)
+* [HTTP](#http)
+* [SSH](#ssh)
+* [XHR](#xhr)
+* [Sockets](#socket)
+
+### Ciphers
+
+* [CIPHER](#cipher)
+* [AES](#aes)
+* [DES](#des)
+* [RC2](#rc2)
+
+### PKI
+
+* [RSA](#rsa)
+* [RSA-KEM](#rsakem)
+* [X.509](#x509)
+* [PKCS#5](#pkcs5)
+* [PKCS#7](#pkcs7)
+* [PKCS#8](#pkcs8)
+* [PKCS#10](#pkcs10)
+* [PKCS#12](#pkcs12)
+* [ASN.1](#asn)
+
+### Message Digests
+
+* [SHA1](#sha1)
+* [SHA256](#sha256)
+* [SHA384](#sha384)
+* [SHA512](#sha512)
+* [MD5](#md5)
+* [HMAC](#hmac)
+
+### Utilities
+
+* [Prime](#prime)
+* [PRNG](#prng)
+* [Tasks](#task)
+* [Utilities](#util)
+* [Logging](#log)
+* [Debugging](#debug)
+* [Flash Socket Policy Module](#fsp)
+
+---------------------------------------
+
+If at any time you wish to disable the use of native code, where available,
+for particular forge features like its secure random number generator, you
+may set the ```disableNativeCode``` flag on ```forge``` to ```true```. It
+is not recommended that you set this flag as native code is typically more
+performant and may have stronger security properties. It may be useful to
+set this flag to test certain features that you plan to run in environments
+that are different from your testing environment.
+
+To disable native code when including forge in the browser:
+
+```js
+forge = {disableNativeCode: true};
+// now include forge script file(s)
+// Note: with this approach, script files *must*
+// be included after initializing the global forge var
+
+// alternatively, include script files first and then call
+forge = forge({disableNativeCode: true});
+
+// Note: forge will be permanently reconfigured now;
+// to avoid this but use the same "forge" var name,
+// you can wrap your code in a function to shadow the
+// global var, eg:
+(function(forge) {
+ // ...
+})(forge({disableNativeCode: true}));
+```
+
+To disable native code when using node.js:
+
+```js
+var forge = require('node-forge')({disableNativeCode: true});
+```
+
+---------------------------------------
+## Transports
+
+<a name="tls" />
+### TLS
+
+Provides a native javascript client and server-side [TLS][] implementation.
+
+__Examples__
+
+```js
+// create TLS client
+var client = forge.tls.createConnection({
+ server: false,
+ caStore: /* Array of PEM-formatted certs or a CA store object */,
+ sessionCache: {},
+ // supported cipher suites in order of preference
+ cipherSuites: [
+ forge.tls.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA,
+ forge.tls.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA],
+ virtualHost: 'example.com',
+ verify: function(connection, verified, depth, certs) {
+ if(depth === 0) {
+ var cn = certs[0].subject.getField('CN').value;
+ if(cn !== 'example.com') {
+ verified = {
+ alert: forge.tls.Alert.Description.bad_certificate,
+ message: 'Certificate common name does not match hostname.'
+ };
+ }
+ }
+ return verified;
+ },
+ connected: function(connection) {
+ console.log('connected');
+ // send message to server
+ connection.prepare(forge.util.encodeUtf8('Hi server!'));
+ /* NOTE: experimental, start heartbeat retransmission timer
+ myHeartbeatTimer = setInterval(function() {
+ connection.prepareHeartbeatRequest(forge.util.createBuffer('1234'));
+ }, 5*60*1000);*/
+ },
+ /* provide a client-side cert if you want
+ getCertificate: function(connection, hint) {
+ return myClientCertificate;
+ },
+ /* the private key for the client-side cert if provided */
+ getPrivateKey: function(connection, cert) {
+ return myClientPrivateKey;
+ },
+ tlsDataReady: function(connection) {
+ // TLS data (encrypted) is ready to be sent to the server
+ sendToServerSomehow(connection.tlsData.getBytes());
+ // if you were communicating with the server below, you'd do:
+ // server.process(connection.tlsData.getBytes());
+ },
+ dataReady: function(connection) {
+ // clear data from the server is ready
+ console.log('the server sent: ' +
+ forge.util.decodeUtf8(connection.data.getBytes()));
+ // close connection
+ connection.close();
+ },
+ /* NOTE: experimental
+ heartbeatReceived: function(connection, payload) {
+ // restart retransmission timer, look at payload
+ clearInterval(myHeartbeatTimer);
+ myHeartbeatTimer = setInterval(function() {
+ connection.prepareHeartbeatRequest(forge.util.createBuffer('1234'));
+ }, 5*60*1000);
+ payload.getBytes();
+ },*/
+ closed: function(connection) {
+ console.log('disconnected');
+ },
+ error: function(connection, error) {
+ console.log('uh oh', error);
+ }
+});
+
+// start the handshake process
+client.handshake();
+
+// when encrypted TLS data is received from the server, process it
+client.process(encryptedBytesFromServer);
+
+// create TLS server
+var server = forge.tls.createConnection({
+ server: true,
+ caStore: /* Array of PEM-formatted certs or a CA store object */,
+ sessionCache: {},
+ // supported cipher suites in order of preference
+ cipherSuites: [
+ forge.tls.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA,
+ forge.tls.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA],
+ // require a client-side certificate if you want
+ verifyClient: true,
+ verify: function(connection, verified, depth, certs) {
+ if(depth === 0) {
+ var cn = certs[0].subject.getField('CN').value;
+ if(cn !== 'the-client') {
+ verified = {
+ alert: forge.tls.Alert.Description.bad_certificate,
+ message: 'Certificate common name does not match expected client.'
+ };
+ }
+ }
+ return verified;
+ },
+ connected: function(connection) {
+ console.log('connected');
+ // send message to client
+ connection.prepare(forge.util.encodeUtf8('Hi client!'));
+ /* NOTE: experimental, start heartbeat retransmission timer
+ myHeartbeatTimer = setInterval(function() {
+ connection.prepareHeartbeatRequest(forge.util.createBuffer('1234'));
+ }, 5*60*1000);*/
+ },
+ getCertificate: function(connection, hint) {
+ return myServerCertificate;
+ },
+ getPrivateKey: function(connection, cert) {
+ return myServerPrivateKey;
+ },
+ tlsDataReady: function(connection) {
+ // TLS data (encrypted) is ready to be sent to the client
+ sendToClientSomehow(connection.tlsData.getBytes());
+ // if you were communicating with the client above you'd do:
+ // client.process(connection.tlsData.getBytes());
+ },
+ dataReady: function(connection) {
+ // clear data from the client is ready
+ console.log('the client sent: ' +
+ forge.util.decodeUtf8(connection.data.getBytes()));
+ // close connection
+ connection.close();
+ },
+ /* NOTE: experimental
+ heartbeatReceived: function(connection, payload) {
+ // restart retransmission timer, look at payload
+ clearInterval(myHeartbeatTimer);
+ myHeartbeatTimer = setInterval(function() {
+ connection.prepareHeartbeatRequest(forge.util.createBuffer('1234'));
+ }, 5*60*1000);
+ payload.getBytes();
+ },*/
+ closed: function(connection) {
+ console.log('disconnected');
+ },
+ error: function(connection, error) {
+ console.log('uh oh', error);
+ }
+});
+
+// when encrypted TLS data is received from the client, process it
+server.process(encryptedBytesFromClient);
+```
+
+Connect to a TLS server using node's net.Socket:
+
+```js
+var socket = new net.Socket();
+
+var client = forge.tls.createConnection({
+ server: false,
+ verify: function(connection, verified, depth, certs) {
+ // skip verification for testing
+ console.log('[tls] server certificate verified');
+ return true;
+ },
+ connected: function(connection) {
+ console.log('[tls] connected');
+ // prepare some data to send (note that the string is interpreted as
+ // 'binary' encoded, which works for HTTP which only uses ASCII, use
+ // forge.util.encodeUtf8(str) otherwise
+ client.prepare('GET / HTTP/1.0\r\n\r\n');
+ },
+ tlsDataReady: function(connection) {
+ // encrypted data is ready to be sent to the server
+ var data = connection.tlsData.getBytes();
+ socket.write(data, 'binary'); // encoding should be 'binary'
+ },
+ dataReady: function(connection) {
+ // clear data from the server is ready
+ var data = connection.data.getBytes();
+ console.log('[tls] data received from the server: ' + data);
+ },
+ closed: function() {
+ console.log('[tls] disconnected');
+ },
+ error: function(connection, error) {
+ console.log('[tls] error', error);
+ }
+});
+
+socket.on('connect', function() {
+ console.log('[socket] connected');
+ client.handshake();
+});
+socket.on('data', function(data) {
+ client.process(data.toString('binary')); // encoding should be 'binary'
+});
+socket.on('end', function() {
+ console.log('[socket] disconnected');
+});
+
+// connect to google.com
+socket.connect(443, 'google.com');
+
+// or connect to gmail's imap server (but don't send the HTTP header above)
+//socket.connect(993, 'imap.gmail.com');
+```
+
+<a name="http" />
+### HTTP
+
+Provides a native [JavaScript][] mini-implementation of an http client that
+uses pooled sockets.
+
+__Examples__
+
+```js
+// create an HTTP GET request
+var request = forge.http.createRequest({method: 'GET', path: url.path});
+
+// send the request somewhere
+sendSomehow(request.toString());
+
+// receive response
+var buffer = forge.util.createBuffer();
+var response = forge.http.createResponse();
+var someAsyncDataHandler = function(bytes) {
+ if(!response.bodyReceived) {
+ buffer.putBytes(bytes);
+ if(!response.headerReceived) {
+ if(response.readHeader(buffer)) {
+ console.log('HTTP response header: ' + response.toString());
+ }
+ }
+ if(response.headerReceived && !response.bodyReceived) {
+ if(response.readBody(buffer)) {
+ console.log('HTTP response body: ' + response.body);
+ }
+ }
+ }
+};
+```
+
+<a name="ssh" />
+### SSH
+
+Provides some SSH utility functions.
+
+__Examples__
+
+```js
+// encodes (and optionally encrypts) a private RSA key as a Putty PPK file
+forge.ssh.privateKeyToPutty(privateKey, passphrase, comment);
+
+// encodes a public RSA key as an OpenSSH file
+forge.ssh.publicKeyToOpenSSH(key, comment);
+
+// encodes a private RSA key as an OpenSSH file
+forge.ssh.privateKeyToOpenSSH(privateKey, passphrase);
+
+// gets the SSH public key fingerprint in a byte buffer
+forge.ssh.getPublicKeyFingerprint(key);
+
+// gets a hex-encoded, colon-delimited SSH public key fingerprint
+forge.ssh.getPublicKeyFingerprint(key, {encoding: 'hex', delimiter: ':'});
+```
+
+<a name="xhr" />
+### XHR
+
+Provides an XmlHttpRequest implementation using forge.http as a backend.
+
+__Examples__
+
+```js
+```
+
+<a name="socket" />
+### Sockets
+
+Provides an interface to create and use raw sockets provided via Flash.
+
+__Examples__
+
+```js
+```
+
+---------------------------------------
+## Ciphers
+
+<a name="cipher" />
+### CIPHER
+
+Provides a basic API for block encryption and decryption. There is built-in
+support for the ciphers: [AES][], [3DES][], and [DES][], and for the modes
+of operation: [ECB][], [CBC][], [CFB][], [OFB][], [CTR][], and [GCM][].
+
+These algorithms are currently supported:
+
+* AES-CBC
+* AES-CFB
+* AES-OFB
+* AES-CTR
+* AES-GCM
+* 3DES-ECB
+* 3DES-CBC
+* DES-ECB
+* DES-CBC
+
+When using an [AES][] algorithm, the key size will determine whether
+AES-128, AES-192, or AES-256 is used (all are supported). When a [DES][]
+algorithm is used, the key size will determine whether [3DES][] or regular
+[DES][] is used. Use a [3DES][] algorithm to enforce Triple-DES.
+
+__Examples__
+
+```js
+// generate a random key and IV
+// Note: a key size of 16 bytes will use AES-128, 24 => AES-192, 32 => AES-256
+var key = forge.random.getBytesSync(16);
+var iv = forge.random.getBytesSync(16);
+
+/* alternatively, generate a password-based 16-byte key
+var salt = forge.random.getBytesSync(128);
+var key = forge.pkcs5.pbkdf2('password', salt, numIterations, 16);
+*/
+
+// encrypt some bytes using CBC mode
+// (other modes include: CFB, OFB, CTR, and GCM)
+var cipher = forge.cipher.createCipher('AES-CBC', key);
+cipher.start({iv: iv});
+cipher.update(forge.util.createBuffer(someBytes));
+cipher.finish();
+var encrypted = cipher.output;
+// outputs encrypted hex
+console.log(encrypted.toHex());
+
+// decrypt some bytes using CBC mode
+// (other modes include: CFB, OFB, CTR, and GCM)
+var decipher = forge.cipher.createDecipher('AES-CBC', key);
+decipher.start({iv: iv});
+decipher.update(encrypted);
+decipher.finish();
+// outputs decrypted hex
+console.log(decipher.output.toHex());
+
+// encrypt some bytes using GCM mode
+var cipher = forge.cipher.createCipher('AES-GCM', key);
+cipher.start({
+ iv: iv, // should be a 12-byte binary-encoded string or byte buffer
+ additionalData: 'binary-encoded string', // optional
+ tagLength: 128 // optional, defaults to 128 bits
+});
+cipher.update(forge.util.createBuffer(someBytes));
+cipher.finish();
+var encrypted = cipher.output;
+var tag = cipher.mode.tag;
+// outputs encrypted hex
+console.log(encrypted.toHex());
+// outputs authentication tag
+console.log(tag.toHex());
+
+// decrypt some bytes using GCM mode
+var decipher = forge.cipher.createDecipher('AES-GCM', key);
+decipher.start({
+ iv: iv,
+ additionalData: 'binary-encoded string', // optional
+ tagLength: 128, // optional, defaults to 128 bits
+ tag: tag // authentication tag from encryption
+});
+decipher.update(encrypted);
+var pass = decipher.finish();
+// pass is false if there was a failure (eg: authentication tag didn't match)
+if(pass) {
+ // outputs decrypted hex
+ console.log(decipher.output.toHex());
+}
+```
+
+Using forge in node.js to match openssl's "enc" command line tool (**Note**: OpenSSL "enc" uses a non-standard file format with a custom key derivation function and a fixed iteration count of 1, which some consider less secure than alternatives such as [OpenPGP](https://tools.ietf.org/html/rfc4880)/[GnuPG](https://www.gnupg.org/)):
+
+```js
+var forge = require('node-forge');
+var fs = require('fs');
+
+// openssl enc -des3 -in input.txt -out input.enc
+function encrypt(password) {
+ var input = fs.readFileSync('input.txt', {encoding: 'binary'});
+
+ // 3DES key and IV sizes
+ var keySize = 24;
+ var ivSize = 8;
+
+ // get derived bytes
+ // Notes:
+ // 1. If using an alternative hash (eg: "-md sha1") pass
+ // "forge.md.sha1.create()" as the final parameter.
+ // 2. If using "-nosalt", set salt to null.
+ var salt = forge.random.getBytesSync(8);
+ // var md = forge.md.sha1.create(); // "-md sha1"
+ var derivedBytes = forge.pbe.opensslDeriveBytes(
+ password, salt, keySize + ivSize/*, md*/);
+ var buffer = forge.util.createBuffer(derivedBytes);
+ var key = buffer.getBytes(keySize);
+ var iv = buffer.getBytes(ivSize);
+
+ var cipher = forge.cipher.createCipher('3DES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(forge.util.createBuffer(input, 'binary'));
+ cipher.finish();
+
+ var output = forge.util.createBuffer();
+
+ // if using a salt, prepend this to the output:
+ if(salt !== null) {
+ output.putBytes('Salted__'); // (add to match openssl tool output)
+ output.putBytes(salt);
+ }
+ output.putBuffer(cipher.output);
+
+ fs.writeFileSync('input.enc', output.getBytes(), {encoding: 'binary'});
+}
+
+// openssl enc -d -des3 -in input.enc -out input.dec.txt
+function decrypt(password) {
+ var input = fs.readFileSync('input.enc', {encoding: 'binary'});
+
+ // parse salt from input
+ input = forge.util.createBuffer(input, 'binary');
+ // skip "Salted__" (if known to be present)
+ input.getBytes('Salted__'.length);
+ // read 8-byte salt
+ var salt = input.getBytes(8);
+
+ // Note: if using "-nosalt", skip above parsing and use
+ // var salt = null;
+
+ // 3DES key and IV sizes
+ var keySize = 24;
+ var ivSize = 8;
+
+ var derivedBytes = forge.pbe.opensslDeriveBytes(
+ password, salt, keySize + ivSize);
+ var buffer = forge.util.createBuffer(derivedBytes);
+ var key = buffer.getBytes(keySize);
+ var iv = buffer.getBytes(ivSize);
+
+ var decipher = forge.cipher.createDecipher('3DES-CBC', key);
+ decipher.start({iv: iv});
+ decipher.update(input);
+ var result = decipher.finish(); // check 'result' for true/false
+
+ fs.writeFileSync(
+ 'input.dec.txt', decipher.output.getBytes(), {encoding: 'binary'});
+}
+```
+
+<a name="aes" />
+### AES
+
+Provides [AES][] encryption and decryption in [CBC][], [CFB][], [OFB][],
+[CTR][], and [GCM][] modes. See [CIPHER](#cipher) for examples.
+
+<a name="des" />
+### DES
+
+Provides [3DES][] and [DES][] encryption and decryption in [ECB][] and
+[CBC][] modes. See [CIPHER](#cipher) for examples.
+
+<a name="rc2" />
+### RC2
+
+__Examples__
+
+```js
+// generate a random key and IV
+var key = forge.random.getBytesSync(16);
+var iv = forge.random.getBytesSync(8);
+
+// encrypt some bytes
+var cipher = forge.rc2.createEncryptionCipher(key);
+cipher.start(iv);
+cipher.update(forge.util.createBuffer(someBytes));
+cipher.finish();
+var encrypted = cipher.output;
+// outputs encrypted hex
+console.log(encrypted.toHex());
+
+// decrypt some bytes
+var cipher = forge.rc2.createDecryptionCipher(key);
+cipher.start(iv);
+cipher.update(encrypted);
+cipher.finish();
+// outputs decrypted hex
+console.log(cipher.output.toHex());
+```
+---------------------------------------
+## PKI
+
+Provides [X.509][] certificate and RSA public and private key encoding,
+decoding, encryption/decryption, and signing/verifying.
+
+<a name="rsa" />
+### RSA
+
+__Examples__
+
+```js
+var rsa = forge.pki.rsa;
+
+// generate an RSA key pair synchronously
+var keypair = rsa.generateKeyPair({bits: 2048, e: 0x10001});
+
+// generate an RSA key pair asynchronously (uses web workers if available)
+// use workers: -1 to run a fast core estimator to optimize # of workers
+rsa.generateKeyPair({bits: 2048, workers: 2}, function(err, keypair) {
+ // keypair.privateKey, keypair.publicKey
+});
+
+// generate an RSA key pair in steps that attempt to run for a specified period
+// of time on the main JS thread
+var state = rsa.createKeyPairGenerationState(2048, 0x10001);
+var step = function() {
+ // run for 100 ms
+ if(!rsa.stepKeyPairGenerationState(state, 100)) {
+ setTimeout(step, 1);
+ }
+ else {
+ // done, turn off progress indicator, use state.keys
+ }
+};
+// turn on progress indicator, schedule generation to run
+setTimeout(step);
+
+// sign data with a private key and output DigestInfo DER-encoded bytes
+// (defaults to RSASSA PKCS#1 v1.5)
+var md = forge.md.sha1.create();
+md.update('sign this', 'utf8');
+var signature = privateKey.sign(md);
+
+// verify data with a public key
+// (defaults to RSASSA PKCS#1 v1.5)
+var verified = publicKey.verify(md.digest().bytes(), signature);
+
+// sign data using RSASSA-PSS where PSS uses a SHA-1 hash, a SHA-1 based
+// masking function MGF1, and a 20 byte salt
+var md = forge.md.sha1.create();
+md.update('sign this', 'utf8');
+var pss = forge.pss.create({
+ md: forge.md.sha1.create(),
+ mgf: forge.mgf.mgf1.create(forge.md.sha1.create()),
+ saltLength: 20
+ // optionally pass 'prng' with a custom PRNG implementation
+ // optionalls pass 'salt' with a forge.util.ByteBuffer w/custom salt
+});
+var signature = privateKey.sign(md, pss);
+
+// verify RSASSA-PSS signature
+var pss = forge.pss.create({
+ md: forge.md.sha1.create(),
+ mgf: forge.mgf.mgf1.create(forge.md.sha1.create()),
+ saltLength: 20
+ // optionally pass 'prng' with a custom PRNG implementation
+});
+var md = forge.md.sha1.create();
+md.update('sign this', 'utf8');
+publicKey.verify(md.digest().getBytes(), signature, pss);
+
+// encrypt data with a public key (defaults to RSAES PKCS#1 v1.5)
+var encrypted = publicKey.encrypt(bytes);
+
+// decrypt data with a private key (defaults to RSAES PKCS#1 v1.5)
+var decrypted = privateKey.decrypt(encrypted);
+
+// encrypt data with a public key using RSAES PKCS#1 v1.5
+var encrypted = publicKey.encrypt(bytes, 'RSAES-PKCS1-V1_5');
+
+// decrypt data with a private key using RSAES PKCS#1 v1.5
+var decrypted = privateKey.decrypt(encrypted, 'RSAES-PKCS1-V1_5');
+
+// encrypt data with a public key using RSAES-OAEP
+var encrypted = publicKey.encrypt(bytes, 'RSA-OAEP');
+
+// decrypt data with a private key using RSAES-OAEP
+var decrypted = privateKey.decrypt(encrypted, 'RSA-OAEP');
+
+// encrypt data with a public key using RSAES-OAEP/SHA-256
+var encrypted = publicKey.encrypt(bytes, 'RSA-OAEP', {
+ md: forge.md.sha256.create()
+});
+
+// decrypt data with a private key using RSAES-OAEP/SHA-256
+var decrypted = privateKey.decrypt(encrypted, 'RSA-OAEP', {
+ md: forge.md.sha256.create()
+});
+
+// encrypt data with a public key using RSAES-OAEP/SHA-256/MGF1-SHA-1
+// compatible with Java's RSA/ECB/OAEPWithSHA-256AndMGF1Padding
+var encrypted = publicKey.encrypt(bytes, 'RSA-OAEP', {
+ md: forge.md.sha256.create(),
+ mgf1: {
+ md: forge.md.sha1.create()
+ }
+});
+
+// decrypt data with a private key using RSAES-OAEP/SHA-256/MGF1-SHA-1
+// compatible with Java's RSA/ECB/OAEPWithSHA-256AndMGF1Padding
+var decrypted = privateKey.decrypt(encrypted, 'RSA-OAEP', {
+ md: forge.md.sha256.create(),
+ mgf1: {
+ md: forge.md.sha1.create()
+ }
+});
+
+```
+
+<a name="rsakem" />
+### RSA-KEM
+
+__Examples__
+
+```js
+// generate an RSA key pair asynchronously (uses web workers if available)
+// use workers: -1 to run a fast core estimator to optimize # of workers
+forge.rsa.generateKeyPair({bits: 2048, workers: -1}, function(err, keypair) {
+ // keypair.privateKey, keypair.publicKey
+});
+
+// generate and encapsulate a 16-byte secret key
+var kdf1 = new forge.kem.kdf1(forge.md.sha1.create());
+var kem = forge.kem.rsa.create(kdf1);
+var result = kem.encrypt(keypair.publicKey, 16);
+// result has 'encapsulation' and 'key'
+
+// encrypt some bytes
+var iv = forge.random.getBytesSync(12);
+var someBytes = 'hello world!';
+var cipher = forge.cipher.createCipher('AES-GCM', result.key);
+cipher.start({iv: iv});
+cipher.update(forge.util.createBuffer(someBytes));
+cipher.finish();
+var encrypted = cipher.output.getBytes();
+var tag = cipher.mode.tag.getBytes();
+
+// send 'encrypted', 'iv', 'tag', and result.encapsulation to recipient
+
+// decrypt encapsulated 16-byte secret key
+var kdf1 = new forge.kem.kdf1(forge.md.sha1.create());
+var kem = forge.kem.rsa.create(kdf1);
+var key = kem.decrypt(keypair.privateKey, result.encapsulation, 16);
+
+// decrypt some bytes
+var decipher = forge.cipher.createDecipher('AES-GCM', key);
+decipher.start({iv: iv, tag: tag});
+decipher.update(forge.util.createBuffer(encrypted));
+var pass = decipher.finish();
+// pass is false if there was a failure (eg: authentication tag didn't match)
+if(pass) {
+ // outputs 'hello world!'
+ console.log(decipher.output.getBytes());
+}
+
+```
+
+<a name="x509" />
+### X.509
+
+__Examples__
+
+```js
+var pki = forge.pki;
+
+// convert a PEM-formatted public key to a Forge public key
+var publicKey = pki.publicKeyFromPem(pem);
+
+// convert a Forge public key to PEM-format
+var pem = pki.publicKeyToPem(publicKey);
+
+// convert an ASN.1 SubjectPublicKeyInfo to a Forge public key
+var publicKey = pki.publicKeyFromAsn1(subjectPublicKeyInfo);
+
+// convert a Forge public key to an ASN.1 SubjectPublicKeyInfo
+var subjectPublicKeyInfo = pki.publicKeyToAsn1(publicKey);
+
+// gets a SHA-1 RSAPublicKey fingerprint a byte buffer
+pki.getPublicKeyFingerprint(key);
+
+// gets a SHA-1 SubjectPublicKeyInfo fingerprint a byte buffer
+pki.getPublicKeyFingerprint(key, {type: 'SubjectPublicKeyInfo'});
+
+// gets a hex-encoded, colon-delimited SHA-1 RSAPublicKey public key fingerprint
+pki.getPublicKeyFingerprint(key, {encoding: 'hex', delimiter: ':'});
+
+// gets a hex-encoded, colon-delimited SHA-1 SubjectPublicKeyInfo public key fingerprint
+pki.getPublicKeyFingerprint(key, {
+ type: 'SubjectPublicKeyInfo',
+ encoding: 'hex',
+ delimiter: ':'
+});
+
+// gets a hex-encoded, colon-delimited MD5 RSAPublicKey public key fingerprint
+pki.getPublicKeyFingerprint(key, {
+ md: forge.md.md5.create(),
+ encoding: 'hex',
+ delimiter: ':'
+});
+
+// creates a CA store
+var caStore = pki.createCaStore([/* PEM-encoded cert */, ...]);
+
+// add a certificate to the CA store
+caStore.addCertificate(certObjectOrPemString);
+
+// gets the issuer (its certificate) for the given certificate
+var issuerCert = caStore.getIssuer(subjectCert);
+
+// verifies a certificate chain against a CA store
+pki.verifyCertificateChain(caStore, chain, customVerifyCallback);
+
+// signs a certificate using the given private key
+cert.sign(privateKey);
+
+// signs a certificate using SHA-256 instead of SHA-1
+cert.sign(privateKey, forge.md.sha256.create());
+
+// verifies an issued certificate using the certificates public key
+var verified = issuer.verify(issued);
+
+// generate a keypair and create an X.509v3 certificate
+var keys = pki.rsa.generateKeyPair(2048);
+var cert = pki.createCertificate();
+cert.publicKey = keys.publicKey;
+// alternatively set public key from a csr
+//cert.publicKey = csr.publicKey;
+cert.serialNumber = '01';
+cert.validity.notBefore = new Date();
+cert.validity.notAfter = new Date();
+cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 1);
+var attrs = [{
+ name: 'commonName',
+ value: 'example.org'
+}, {
+ name: 'countryName',
+ value: 'US'
+}, {
+ shortName: 'ST',
+ value: 'Virginia'
+}, {
+ name: 'localityName',
+ value: 'Blacksburg'
+}, {
+ name: 'organizationName',
+ value: 'Test'
+}, {
+ shortName: 'OU',
+ value: 'Test'
+}];
+cert.setSubject(attrs);
+// alternatively set subject from a csr
+//cert.setSubject(csr.subject.attributes);
+cert.setIssuer(attrs);
+cert.setExtensions([{
+ name: 'basicConstraints',
+ cA: true
+}, {
+ name: 'keyUsage',
+ keyCertSign: true,
+ digitalSignature: true,
+ nonRepudiation: true,
+ keyEncipherment: true,
+ dataEncipherment: true
+}, {
+ name: 'extKeyUsage',
+ serverAuth: true,
+ clientAuth: true,
+ codeSigning: true,
+ emailProtection: true,
+ timeStamping: true
+}, {
+ name: 'nsCertType',
+ client: true,
+ server: true,
+ email: true,
+ objsign: true,
+ sslCA: true,
+ emailCA: true,
+ objCA: true
+}, {
+ name: 'subjectAltName',
+ altNames: [{
+ type: 6, // URI
+ value: 'http://example.org/webid#me'
+ }, {
+ type: 7, // IP
+ ip: '127.0.0.1'
+ }]
+}, {
+ name: 'subjectKeyIdentifier'
+}]);
+/* alternatively set extensions from a csr
+var extensions = csr.getAttribute({name: 'extensionRequest'}).extensions;
+// optionally add more extensions
+extensions.push.apply(extensions, [{
+ name: 'basicConstraints',
+ cA: true
+}, {
+ name: 'keyUsage',
+ keyCertSign: true,
+ digitalSignature: true,
+ nonRepudiation: true,
+ keyEncipherment: true,
+ dataEncipherment: true
+}]);
+cert.setExtensions(extensions);
+*/
+// self-sign certificate
+cert.sign(keys.privateKey);
+
+// convert a Forge certificate to PEM
+var pem = pki.certificateToPem(cert);
+
+// convert a Forge certificate from PEM
+var cert = pki.certificateFromPem(pem);
+
+// convert an ASN.1 X.509x3 object to a Forge certificate
+var cert = pki.certificateFromAsn1(obj);
+
+// convert a Forge certificate to an ASN.1 X.509v3 object
+var asn1Cert = pki.certificateToAsn1(cert);
+```
+
+<a name="pkcs5" />
+### PKCS#5
+
+Provides the password-based key-derivation function from [PKCS#5][].
+
+__Examples__
+
+```js
+// generate a password-based 16-byte key
+// note an optional message digest can be passed as the final parameter
+var salt = forge.random.getBytesSync(128);
+var derivedKey = forge.pkcs5.pbkdf2('password', salt, numIterations, 16);
+
+// generate key asynchronously
+// note an optional message digest can be passed before the callback
+forge.pkcs5.pbkdf2('password', salt, numIterations, 16, function(err, derivedKey) {
+ // do something w/derivedKey
+});
+```
+
+<a name="pkcs7" />
+### PKCS#7
+
+Provides cryptographically protected messages from [PKCS#7][].
+
+__Examples__
+
+```js
+// convert a message from PEM
+var p7 = forge.pkcs7.messageFromPem(pem);
+// look at p7.recipients
+
+// find a recipient by the issuer of a certificate
+var recipient = p7.findRecipient(cert);
+
+// decrypt
+p7.decrypt(p7.recipients[0], privateKey);
+
+// create a p7 enveloped message
+var p7 = forge.pkcs7.createEnvelopedData();
+
+// add a recipient
+var cert = forge.pki.certificateFromPem(certPem);
+p7.addRecipient(cert);
+
+// set content
+p7.content = forge.util.createBuffer('Hello');
+
+// encrypt
+p7.encrypt();
+
+// convert message to PEM
+var pem = forge.pkcs7.messageToPem(p7);
+
+// create a degenerate PKCS#7 certificate container
+// (CRLs not currently supported, only certificates)
+var p7 = forge.pkcs7.createSignedData();
+p7.addCertificate(certOrCertPem1);
+p7.addCertificate(certOrCertPem2);
+var pem = forge.pkcs7.messageToPem(p7);
+```
+
+<a name="pkcs8" />
+### PKCS#8
+
+__Examples__
+
+```js
+var pki = forge.pki;
+
+// convert a PEM-formatted private key to a Forge private key
+var privateKey = pki.privateKeyFromPem(pem);
+
+// convert a Forge private key to PEM-format
+var pem = pki.privateKeyToPem(privateKey);
+
+// convert an ASN.1 PrivateKeyInfo or RSAPrivateKey to a Forge private key
+var privateKey = pki.privateKeyFromAsn1(rsaPrivateKey);
+
+// convert a Forge private key to an ASN.1 RSAPrivateKey
+var rsaPrivateKey = pki.privateKeyToAsn1(privateKey);
+
+// wrap an RSAPrivateKey ASN.1 object in a PKCS#8 ASN.1 PrivateKeyInfo
+var privateKeyInfo = pki.wrapRsaPrivateKey(rsaPrivateKey);
+
+// convert a PKCS#8 ASN.1 PrivateKeyInfo to PEM
+var pem = pki.privateKeyInfoToPem(privateKeyInfo);
+
+// encrypts a PrivateKeyInfo and outputs an EncryptedPrivateKeyInfo
+var encryptedPrivateKeyInfo = pki.encryptPrivateKeyInfo(
+ privateKeyInfo, 'password', {
+ algorithm: 'aes256', // 'aes128', 'aes192', 'aes256', '3des'
+ });
+
+// decrypts an ASN.1 EncryptedPrivateKeyInfo
+var privateKeyInfo = pki.decryptPrivateKeyInfo(
+ encryptedPrivateKeyInfo, 'password');
+
+// converts an EncryptedPrivateKeyInfo to PEM
+var pem = pki.encryptedPrivateKeyToPem(encryptedPrivateKeyInfo);
+
+// converts a PEM-encoded EncryptedPrivateKeyInfo to ASN.1 format
+var encryptedPrivateKeyInfo = pki.encryptedPrivateKeyFromPem(pem);
+
+// wraps and encrypts a Forge private key and outputs it in PEM format
+var pem = pki.encryptRsaPrivateKey(privateKey, 'password');
+
+// encrypts a Forge private key and outputs it in PEM format using OpenSSL's
+// proprietary legacy format + encapsulated PEM headers (DEK-Info)
+var pem = pki.encryptRsaPrivateKey(privateKey, 'password', {legacy: true});
+
+// decrypts a PEM-formatted, encrypted private key
+var privateKey = pki.decryptRsaPrivateKey(pem, 'password');
+
+// sets an RSA public key from a private key
+var publicKey = pki.setRsaPublicKey(privateKey.n, privateKey.e);
+```
+
+<a name="pkcs10" />
+### PKCS#10
+
+Provides certification requests or certificate signing requests (CSR) from
+[PKCS#10][].
+
+__Examples__
+
+```js
+// generate a key pair
+var keys = forge.pki.rsa.generateKeyPair(1024);
+
+// create a certification request (CSR)
+var csr = forge.pki.createCertificationRequest();
+csr.publicKey = keys.publicKey;
+csr.setSubject([{
+ name: 'commonName',
+ value: 'example.org'
+}, {
+ name: 'countryName',
+ value: 'US'
+}, {
+ shortName: 'ST',
+ value: 'Virginia'
+}, {
+ name: 'localityName',
+ value: 'Blacksburg'
+}, {
+ name: 'organizationName',
+ value: 'Test'
+}, {
+ shortName: 'OU',
+ value: 'Test'
+}]);
+// set (optional) attributes
+csr.setAttributes([{
+ name: 'challengePassword',
+ value: 'password'
+}, {
+ name: 'unstructuredName',
+ value: 'My Company, Inc.'
+}, {
+ name: 'extensionRequest',
+ extensions: [{
+ name: 'subjectAltName',
+ altNames: [{
+ // 2 is DNS type
+ type: 2,
+ value: 'test.domain.com'
+ }, {
+ type: 2,
+ value: 'other.domain.com',
+ }, {
+ type: 2,
+ value: 'www.domain.net'
+ }]
+ }]
+}]);
+
+// sign certification request
+csr.sign(keys.privateKey);
+
+// verify certification request
+var verified = csr.verify();
+
+// convert certification request to PEM-format
+var pem = forge.pki.certificationRequestToPem(csr);
+
+// convert a Forge certification request from PEM-format
+var csr = forge.pki.certificationRequestFromPem(pem);
+
+// get an attribute
+csr.getAttribute({name: 'challengePassword'});
+
+// get extensions array
+csr.getAttribute({name: 'extensionRequest'}).extensions;
+
+```
+
+<a name="pkcs12" />
+### PKCS#12
+
+Provides the cryptographic archive file format from [PKCS#12][].
+
+__Examples__
+
+```js
+// decode p12 from base64
+var p12Der = forge.util.decode64(p12b64);
+// get p12 as ASN.1 object
+var p12Asn1 = forge.asn1.fromDer(p12Der);
+// decrypt p12 using the password 'password'
+var p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1, 'password');
+// decrypt p12 using non-strict parsing mode (resolves some ASN.1 parse errors)
+var p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1, false, 'password');
+// decrypt p12 using literally no password (eg: Mac OS X/apple push)
+var p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1);
+// decrypt p12 using an "empty" password (eg: OpenSSL with no password input)
+var p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1, '');
+// p12.safeContents is an array of safe contents, each of
+// which contains an array of safeBags
+
+// get bags by friendlyName
+var bags = p12.getBags({friendlyName: 'test'});
+// bags are key'd by attribute type (here "friendlyName")
+// and the key values are an array of matching objects
+var cert = bags.friendlyName[0];
+
+// get bags by localKeyId
+var bags = p12.getBags({localKeyId: buffer});
+// bags are key'd by attribute type (here "localKeyId")
+// and the key values are an array of matching objects
+var cert = bags.localKeyId[0];
+
+// get bags by localKeyId (input in hex)
+var bags = p12.getBags({localKeyIdHex: '7b59377ff142d0be4565e9ac3d396c01401cd879'});
+// bags are key'd by attribute type (here "localKeyId", *not* "localKeyIdHex")
+// and the key values are an array of matching objects
+var cert = bags.localKeyId[0];
+
+// get bags by type
+var bags = p12.getBags({bagType: forge.pki.oids.certBag});
+// bags are key'd by bagType and each bagType key's value
+// is an array of matches (in this case, certificate objects)
+var cert = bags[forge.pki.oids.certBag][0];
+
+// get bags by friendlyName and filter on bag type
+var bags = p12.getBags({
+ friendlyName: 'test',
+ bagType: forge.pki.oids.certBag
+});
+
+// generate a p12 using AES (default)
+var p12Asn1 = forge.pkcs12.toPkcs12Asn1(
+ privateKey, certificateChain, 'password');
+
+// generate a p12 that can be imported by Chrome/Firefox
+// (requires the use of Triple DES instead of AES)
+var p12Asn1 = forge.pkcs12.toPkcs12Asn1(
+ privateKey, certificateChain, 'password',
+ {algorithm: '3des'});
+
+// base64-encode p12
+var p12Der = forge.asn1.toDer(p12Asn1).getBytes();
+var p12b64 = forge.util.encode64(p12Der);
+
+// create download link for p12
+var a = document.createElement('a');
+a.download = 'example.p12';
+a.setAttribute('href', 'data:application/x-pkcs12;base64,' + p12b64);
+a.appendChild(document.createTextNode('Download'));
+```
+
+<a name="asn" />
+### ASN.1
+
+Provides [ASN.1][] DER encoding and decoding.
+
+__Examples__
+
+```js
+var asn1 = forge.asn1;
+
+// create a SubjectPublicKeyInfo
+var subjectPublicKeyInfo =
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // AlgorithmIdentifier
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // algorithm
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids['rsaEncryption']).getBytes()),
+ // parameters (null)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
+ ]),
+ // subjectPublicKey
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, [
+ // RSAPublicKey
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // modulus (n)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.n)),
+ // publicExponent (e)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.e))
+ ])
+ ])
+ ]);
+
+// serialize an ASN.1 object to DER format
+var derBuffer = asn1.toDer(subjectPublicKeyInfo);
+
+// deserialize to an ASN.1 object from a byte buffer filled with DER data
+var object = asn1.fromDer(derBuffer);
+
+// convert an OID dot-separated string to a byte buffer
+var derOidBuffer = asn1.oidToDer('1.2.840.113549.1.1.5');
+
+// convert a byte buffer with a DER-encoded OID to a dot-separated string
+console.log(asn1.derToDer(derOidBuffer));
+// output: 1.2.840.113549.1.1.5
+
+// validates that an ASN.1 object matches a particular ASN.1 structure and
+// captures data of interest from that structure for easy access
+var publicKeyValidator = {
+ name: 'SubjectPublicKeyInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'subjectPublicKeyInfo',
+ value: [{
+ name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'AlgorithmIdentifier.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'publicKeyOid'
+ }]
+ }, {
+ // subjectPublicKey
+ name: 'SubjectPublicKeyInfo.subjectPublicKey',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.BITSTRING,
+ constructed: false,
+ value: [{
+ // RSAPublicKey
+ name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ optional: true,
+ captureAsn1: 'rsaPublicKey'
+ }]
+ }]
+};
+
+var capture = {};
+var errors = [];
+if(!asn1.validate(
+ publicKeyValidator, subjectPublicKeyInfo, validator, capture, errors)) {
+ throw 'ASN.1 object is not a SubjectPublicKeyInfo.';
+}
+// capture.subjectPublicKeyInfo contains the full ASN.1 object
+// capture.rsaPublicKey contains the full ASN.1 object for the RSA public key
+// capture.publicKeyOid only contains the value for the OID
+var oid = asn1.derToOid(capture.publicKeyOid);
+if(oid !== pki.oids['rsaEncryption']) {
+ throw 'Unsupported OID.';
+}
+
+// pretty print an ASN.1 object to a string for debugging purposes
+asn1.prettyPrint(object);
+```
+
+---------------------------------------
+## Message Digests
+
+<a name="sha1" />
+### SHA1
+
+Provides [SHA-1][] message digests.
+
+__Examples__
+
+```js
+var md = forge.md.sha1.create();
+md.update('The quick brown fox jumps over the lazy dog');
+console.log(md.digest().toHex());
+// output: 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
+```
+
+<a name="sha256" />
+### SHA256
+
+Provides [SHA-256][] message digests.
+
+__Examples__
+
+```js
+var md = forge.md.sha256.create();
+md.update('The quick brown fox jumps over the lazy dog');
+console.log(md.digest().toHex());
+// output: d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592
+```
+
+<a name="sha384" />
+### SHA384
+
+Provides [SHA-384][] message digests.
+
+__Examples__
+
+```js
+var md = forge.md.sha384.create();
+md.update('The quick brown fox jumps over the lazy dog');
+console.log(md.digest().toHex());
+// output: ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1
+```
+
+<a name="sha512" />
+### SHA512
+
+Provides [SHA-512][] message digests.
+
+__Examples__
+
+```js
+// SHA-512
+var md = forge.md.sha512.create();
+md.update('The quick brown fox jumps over the lazy dog');
+console.log(md.digest().toHex());
+// output: 07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6
+
+// SHA-512/224
+var md = forge.md.sha512.sha224.create();
+md.update('The quick brown fox jumps over the lazy dog');
+console.log(md.digest().toHex());
+// output: 944cd2847fb54558d4775db0485a50003111c8e5daa63fe722c6aa37
+
+// SHA-512/256
+var md = forge.md.sha512.sha256.create();
+md.update('The quick brown fox jumps over the lazy dog');
+console.log(md.digest().toHex());
+// output: dd9d67b371519c339ed8dbd25af90e976a1eeefd4ad3d889005e532fc5bef04d
+```
+
+<a name="md5" />
+### MD5
+
+Provides [MD5][] message digests.
+
+__Examples__
+
+```js
+var md = forge.md.md5.create();
+md.update('The quick brown fox jumps over the lazy dog');
+console.log(md.digest().toHex());
+// output: 9e107d9d372bb6826bd81d3542a419d6
+```
+
+<a name="hmac" />
+### HMAC
+
+Provides [HMAC][] w/any supported message digest algorithm.
+
+__Examples__
+
+```js
+var hmac = forge.hmac.create();
+hmac.start('sha1', 'Jefe');
+hmac.update('what do ya want for nothing?');
+console.log(hmac.digest().toHex());
+// output: effcdf6ae5eb2fa2d27416d5f184df9c259a7c79
+```
+
+---------------------------------------
+## Utilities
+
+<a name="prime" />
+### Prime
+
+Provides an API for generating large, random, probable primes.
+
+__Examples__
+
+```js
+// generate a random prime on the main JS thread
+var bits = 1024;
+forge.prime.generateProbablePrime(bits, function(err, num) {
+ console.log('random prime', num.toString(16));
+});
+
+// generate a random prime using Web Workers (if available, otherwise
+// falls back to the main thread)
+var bits = 1024;
+var options = {
+ algorithm: {
+ name: 'PRIMEINC',
+ workers: -1 // auto-optimize # of workers
+ }
+};
+forge.prime.generateProbablePrime(bits, options, function(err, num) {
+ console.log('random prime', num.toString(16));
+});
+```
+
+<a name="prng" />
+### PRNG
+
+Provides a [Fortuna][]-based cryptographically-secure pseudo-random number
+generator, to be used with a cryptographic function backend, e.g. [AES][]. An
+implementation using [AES][] as a backend is provided. An API for collecting
+entropy is given, though if window.crypto.getRandomValues is available, it will
+be used automatically.
+
+__Examples__
+
+```js
+// get some random bytes synchronously
+var bytes = forge.random.getBytesSync(32);
+console.log(forge.util.bytesToHex(bytes));
+
+// get some random bytes asynchronously
+forge.random.getBytes(32, function(err, bytes) {
+ console.log(forge.util.bytesToHex(bytes));
+});
+
+// collect some entropy if you'd like
+forge.random.collect(someRandomBytes);
+jQuery().mousemove(function(e) {
+ forge.random.collectInt(e.clientX, 16);
+ forge.random.collectInt(e.clientY, 16);
+});
+
+// specify a seed file for use with the synchronous API if you'd like
+forge.random.seedFileSync = function(needed) {
+ // get 'needed' number of random bytes from somewhere
+ return fetchedRandomBytes;
+};
+
+// specify a seed file for use with the asynchronous API if you'd like
+forge.random.seedFile = function(needed, callback) {
+ // get the 'needed' number of random bytes from somewhere
+ callback(null, fetchedRandomBytes);
+});
+
+// register the main thread to send entropy or a Web Worker to receive
+// entropy on demand from the main thread
+forge.random.registerWorker(self);
+
+// generate a new instance of a PRNG with no collected entropy
+var myPrng = forge.random.createInstance();
+```
+
+<a name="task" />
+### Tasks
+
+Provides queuing and synchronizing tasks in a web application.
+
+__Examples__
+
+```js
+```
+
+<a name="util" />
+### Utilities
+
+Provides utility functions, including byte buffer support, base64,
+bytes to/from hex, zlib inflate/deflate, etc.
+
+__Examples__
+
+```js
+// encode/decode base64
+var encoded = forge.util.encode64(str);
+var str = forge.util.decode64(encoded);
+
+// encode/decode UTF-8
+var encoded = forge.util.encodeUtf8(str);
+var str = forge.util.decodeUtf8(encoded);
+
+// bytes to/from hex
+var bytes = forge.util.hexToBytes(hex);
+var hex = forge.util.bytesToHex(bytes);
+
+// create an empty byte buffer
+var buffer = forge.util.createBuffer();
+// create a byte buffer from raw binary bytes
+var buffer = forge.util.createBuffer(input, 'raw');
+// create a byte buffer from utf8 bytes
+var buffer = forge.util.createBuffer(input, 'utf8');
+
+// get the length of the buffer in bytes
+buffer.length();
+// put bytes into the buffer
+buffer.putBytes(bytes);
+// put a 32-bit integer into the buffer
+buffer.putInt32(10);
+// buffer to hex
+buffer.toHex();
+// get a copy of the bytes in the buffer
+bytes.bytes(/* count */);
+// empty this buffer and get its contents
+bytes.getBytes(/* count */);
+
+// convert a forge buffer into a node.js Buffer
+// make sure you specify the encoding as 'binary'
+var forgeBuffer = forge.util.createBuffer();
+var nodeBuffer = new Buffer(forgeBuffer.getBytes(), 'binary');
+
+// convert a node.js Buffer into a forge buffer
+// make sure you specify the encoding as 'binary'
+var nodeBuffer = new Buffer();
+var forgeBuffer = forge.util.createBuffer(nodeBuffer.toString('binary'));
+
+// parse a URL
+var parsed = forge.util.parseUrl('http://example.com/foo?bar=baz');
+// parsed.scheme, parsed.host, parsed.port, parsed.path, parsed.fullHost
+```
+
+<a name="log" />
+### Logging
+
+Provides logging to a javascript console using various categories and
+levels of verbosity.
+
+__Examples__
+
+```js
+```
+
+<a name="debug" />
+### Debugging
+
+Provides storage of debugging information normally inaccessible in
+closures for viewing/investigation.
+
+__Examples__
+
+```js
+```
+
+<a name="fsp" />
+### Flash Socket Policy Module
+
+Provides an [Apache][] module "mod_fsp" that can serve up a Flash Socket
+Policy. See `mod_fsp/README` for more details. This module makes it easy to
+modify an [Apache][] server to allow cross domain requests to be made to it.
+
+
+Library Details
+---------------
+
+* http://digitalbazaar.com/2010/07/20/javascript-tls-1/
+* http://digitalbazaar.com/2010/07/20/javascript-tls-2/
+
+Contact
+-------
+
+* Code: https://github.com/digitalbazaar/forge
+* Bugs: https://github.com/digitalbazaar/forge/issues
+* Email: support@digitalbazaar.com
+
+Donations welcome:
+
+* Donate: paypal@digitalbazaar.com
+
+[AES]: http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
+[ASN.1]: http://en.wikipedia.org/wiki/ASN.1
+[Apache]: http://httpd.apache.org/
+[CFB]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
+[CBC]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
+[CTR]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
+[3DES]: http://en.wikipedia.org/wiki/Triple_DES
+[DES]: http://en.wikipedia.org/wiki/Data_Encryption_Standard
+[ECB]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
+[Fortuna]: http://en.wikipedia.org/wiki/Fortuna_(PRNG)
+[GCM]: http://en.wikipedia.org/wiki/GCM_mode
+[HMAC]: http://en.wikipedia.org/wiki/HMAC
+[JavaScript]: http://en.wikipedia.org/wiki/JavaScript
+[MD5]: http://en.wikipedia.org/wiki/MD5
+[OFB]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
+[PKCS#5]: http://en.wikipedia.org/wiki/PKCS
+[PKCS#7]: http://en.wikipedia.org/wiki/Cryptographic_Message_Syntax
+[PKCS#10]: http://en.wikipedia.org/wiki/Certificate_signing_request
+[PKCS#12]: http://en.wikipedia.org/wiki/PKCS_%E2%99%AF12
+[RC2]: http://en.wikipedia.org/wiki/RC2
+[SHA-1]: http://en.wikipedia.org/wiki/SHA-1
+[SHA-256]: http://en.wikipedia.org/wiki/SHA-256
+[SHA-384]: http://en.wikipedia.org/wiki/SHA-384
+[SHA-512]: http://en.wikipedia.org/wiki/SHA-512
+[TLS]: http://en.wikipedia.org/wiki/Transport_Layer_Security
+[X.509]: http://en.wikipedia.org/wiki/X.509
+[node.js]: http://nodejs.org/
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/bower.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/bower.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/bower.json
new file mode 100644
index 0000000..c65a95e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/bower.json
@@ -0,0 +1,15 @@
+{
+ "name": "forge",
+ "version": "0.6.21",
+ "description": "JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.",
+ "authors": [
+ "Digital Bazaar, Inc."
+ ],
+ "license": "BSD",
+ "main": ["js/forge.js"],
+ "dependencies": {},
+ "ignore": [
+ "node_modules",
+ "bower_components"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/build-flash.xml
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/build-flash.xml b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/build-flash.xml
new file mode 100644
index 0000000..8d8829c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/build-flash.xml
@@ -0,0 +1,7 @@
+<flex-config>
+ <compiler>
+ <source-path>
+ <path-element>flash</path-element>
+ </source-path>
+ </compiler>
+</flex-config>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/build-setup
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/build-setup b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/build-setup
new file mode 100755
index 0000000..5c3866e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/build-setup
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# This shell script sets up the software to be built using 'make'. In
+# order to perform a build from a fresh source tree, do the following:
+#
+# 1. ./build-setup
+# 2. make
+#
+# If you don't want ./configure to be run automatically, you can do
+# the following: ./build-setup -s
+
+# Process command line options
+SKIP_CONFIGURE=0
+for arg in "$*"
+do
+ case $arg in
+ "-s" | "--setup-only" ) SKIP_CONFIGURE=1 ;;
+ esac
+done
+
+# Check and add potential aclocal dirs
+MAYBE_AC_DIRS="
+ /usr/local/share/aclocal
+ /opt/local/share/aclocal
+ /sw/share/aclocal
+ "
+ACDIRS="-I m4"
+for dir in $MAYBE_AC_DIRS; do
+ if test -d $dir; then
+ ACDIRS="$ACDIRS -I $dir"
+ fi
+done
+
+# Run aclocal on the set of local ac scripts
+cd setup
+aclocal $ACDIRS
+# Generate the configure script
+autoconf && mv configure ..
+cd ..
+
+# Run the configure script if "-s" isn't a command line option
+if [ $SKIP_CONFIGURE -eq 0 ]; then
+ # Run the configure script in default development mode
+ ./configure $*
+fi
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/end.frag
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/end.frag b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/end.frag
new file mode 100644
index 0000000..cbcf226
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/end.frag
@@ -0,0 +1,4 @@
+
+return require('js/forge');
+
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/PooledSocket.as
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/PooledSocket.as b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/PooledSocket.as
new file mode 100644
index 0000000..15e3ae4
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/PooledSocket.as
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2009 Digital Bazaar, Inc. All rights reserved.
+ *
+ * @author Dave Longley
+ */
+package
+{
+ import flash.net.Socket;
+
+ /**
+ * A helper class that contains the ID for a Socket.
+ */
+ public class PooledSocket extends Socket
+ {
+ // the ID in the related socket pool
+ public var id:String;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/SocketEvent.as
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/SocketEvent.as b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/SocketEvent.as
new file mode 100644
index 0000000..56f5e7f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/SocketEvent.as
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2009 Digital Bazaar, Inc. All rights reserved.
+ *
+ * @author Dave Longley
+ */
+package
+{
+ import flash.events.Event;
+
+ /**
+ * A helper class that contains the ID for a Socket.
+ */
+ public class SocketEvent extends Event
+ {
+ // the associated socket
+ public var socket:PooledSocket;
+ // an associated message
+ public var message:String;
+
+ /**
+ * Creates a new SocketEvent.
+ *
+ * @param type the type of event.
+ * @param socket the associated PooledSocket.
+ * @param message an associated message.
+ */
+ public function SocketEvent(
+ type:String, socket:PooledSocket, message:String = null)
+ {
+ super(type, false, false);
+ this.socket = socket;
+ this.message = message;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/SocketPool.as
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/SocketPool.as b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/SocketPool.as
new file mode 100644
index 0000000..d99b3ec
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/flash/SocketPool.as
@@ -0,0 +1,754 @@
+/*
+ * Copyright (c) 2009-2010 Digital Bazaar, Inc. All rights reserved.
+ *
+ * @author Dave Longley
+ */
+package
+{
+ import flash.display.Sprite;
+
+ /**
+ * A SocketPool is a flash object that can be embedded in a web page to
+ * allow javascript access to pools of Sockets.
+ *
+ * Javascript can create a pool and then as many Sockets as it desires. Each
+ * Socket will be assigned a unique ID that allows continued javascript
+ * access to it. There is no limit on the number of persistent socket
+ * connections.
+ */
+ public class SocketPool extends Sprite
+ {
+ import flash.events.Event;
+ import flash.events.EventDispatcher;
+ import flash.errors.IOError;
+ import flash.events.IOErrorEvent;
+ import flash.events.ProgressEvent;
+ import flash.events.SecurityErrorEvent;
+ import flash.events.TextEvent;
+ import flash.external.ExternalInterface;
+ import flash.net.SharedObject;
+ import flash.system.Security;
+ import flash.utils.ByteArray;
+ import mx.utils.Base64Decoder;
+ import mx.utils.Base64Encoder;
+
+ // a map of ID to Socket
+ private var mSocketMap:Object;
+
+ // a counter for Socket IDs (Note: assumes there will be no overflow)
+ private var mNextId:uint;
+
+ // an event dispatcher for sending events to javascript
+ private var mEventDispatcher:EventDispatcher;
+
+ /**
+ * Creates a new, unitialized SocketPool.
+ *
+ * @throws Error - if no external interface is available to provide
+ * javascript access.
+ */
+ public function SocketPool()
+ {
+ if(!ExternalInterface.available)
+ {
+ trace("ExternalInterface is not available");
+ throw new Error(
+ "Flash's ExternalInterface is not available. This is a " +
+ "requirement of SocketPool and therefore, it will be " +
+ "unavailable.");
+ }
+ else
+ {
+ try
+ {
+ // set up javascript access:
+
+ // initializes/cleans up the SocketPool
+ ExternalInterface.addCallback("init", init);
+ ExternalInterface.addCallback("cleanup", cleanup);
+
+ // creates/destroys a socket
+ ExternalInterface.addCallback("create", create);
+ ExternalInterface.addCallback("destroy", destroy);
+
+ // connects/closes a socket
+ ExternalInterface.addCallback("connect", connect);
+ ExternalInterface.addCallback("close", close);
+
+ // checks for a connection
+ ExternalInterface.addCallback("isConnected", isConnected);
+
+ // sends/receives data over the socket
+ ExternalInterface.addCallback("send", send);
+ ExternalInterface.addCallback("receive", receive);
+
+ // gets the number of bytes available on a socket
+ ExternalInterface.addCallback(
+ "getBytesAvailable", getBytesAvailable);
+
+ // add a callback for subscribing to socket events
+ ExternalInterface.addCallback("subscribe", subscribe);
+
+ // add callbacks for deflate/inflate
+ ExternalInterface.addCallback("deflate", deflate);
+ ExternalInterface.addCallback("inflate", inflate);
+
+ // add callbacks for local disk storage
+ ExternalInterface.addCallback("setItem", setItem);
+ ExternalInterface.addCallback("getItem", getItem);
+ ExternalInterface.addCallback("removeItem", removeItem);
+ ExternalInterface.addCallback("clearItems", clearItems);
+
+ // socket pool is now ready
+ ExternalInterface.call("window.forge.socketPool.ready");
+ }
+ catch(e:Error)
+ {
+ log("error=" + e.errorID + "," + e.name + "," + e.message);
+ throw e;
+ }
+
+ log("ready");
+ }
+ }
+
+ /**
+ * A debug logging function.
+ *
+ * @param obj the string or error to log.
+ */
+ CONFIG::debugging
+ private function log(obj:Object):void
+ {
+ if(obj is String)
+ {
+ var str:String = obj as String;
+ ExternalInterface.call("console.log", "SocketPool", str);
+ }
+ else if(obj is Error)
+ {
+ var e:Error = obj as Error;
+ log("error=" + e.errorID + "," + e.name + "," + e.message);
+ }
+ }
+
+ CONFIG::release
+ private function log(obj:Object):void
+ {
+ // log nothing in release mode
+ }
+
+ /**
+ * Called by javascript to initialize this SocketPool.
+ *
+ * @param options:
+ * marshallExceptions: true to pass exceptions to and from
+ * javascript.
+ */
+ private function init(... args):void
+ {
+ log("init()");
+
+ // get options from first argument
+ var options:Object = args.length > 0 ? args[0] : null;
+
+ // create socket map, set next ID, and create event dispatcher
+ mSocketMap = new Object();
+ mNextId = 1;
+ mEventDispatcher = new EventDispatcher();
+
+ // enable marshalling exceptions if appropriate
+ if(options != null &&
+ "marshallExceptions" in options &&
+ options.marshallExceptions === true)
+ {
+ try
+ {
+ // Note: setting marshallExceptions in IE, even inside of a
+ // try-catch block will terminate flash. Don't set this on IE.
+ ExternalInterface.marshallExceptions = true;
+ }
+ catch(e:Error)
+ {
+ log(e);
+ }
+ }
+
+ log("init() done");
+ }
+
+ /**
+ * Called by javascript to clean up a SocketPool.
+ */
+ private function cleanup():void
+ {
+ log("cleanup()");
+
+ mSocketMap = null;
+ mNextId = 1;
+ mEventDispatcher = null;
+
+ log("cleanup() done");
+ }
+
+ /**
+ * Handles events.
+ *
+ * @param e the event to handle.
+ */
+ private function handleEvent(e:Event):void
+ {
+ // dispatch socket event
+ var message:String = (e is TextEvent) ? (e as TextEvent).text : null;
+ mEventDispatcher.dispatchEvent(
+ new SocketEvent(e.type, e.target as PooledSocket, message));
+ }
+
+ /**
+ * Called by javascript to create a Socket.
+ *
+ * @return the Socket ID.
+ */
+ private function create():String
+ {
+ log("create()");
+
+ // create a Socket
+ var id:String = "" + mNextId++;
+ var s:PooledSocket = new PooledSocket();
+ s.id = id;
+ s.addEventListener(Event.CONNECT, handleEvent);
+ s.addEventListener(Event.CLOSE, handleEvent);
+ s.addEventListener(ProgressEvent.SOCKET_DATA, handleEvent);
+ s.addEventListener(IOErrorEvent.IO_ERROR, handleEvent);
+ s.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleEvent);
+ mSocketMap[id] = s;
+
+ log("socket " + id + " created");
+ log("create() done");
+
+ return id;
+ }
+
+ /**
+ * Called by javascript to clean up a Socket.
+ *
+ * @param id the ID of the Socket to clean up.
+ */
+ private function destroy(id:String):void
+ {
+ log("destroy(" + id + ")");
+
+ if(id in mSocketMap)
+ {
+ // remove Socket
+ delete mSocketMap[id];
+ log("socket " + id + " destroyed");
+ }
+
+ log("destroy(" + id + ") done");
+ }
+
+ /**
+ * Connects the Socket with the given ID to the given host and port,
+ * using the given socket policy port.
+ *
+ * @param id the ID of the Socket.
+ * @param host the host to connect to.
+ * @param port the port to connect to.
+ * @param spPort the security policy port to use, 0 to use a url.
+ * @param spUrl the http URL to the policy file to use, null for default.
+ */
+ private function connect(
+ id:String, host:String, port:uint, spPort:uint,
+ spUrl:String = null):void
+ {
+ log("connect(" +
+ id + "," + host + "," + port + "," + spPort + "," + spUrl + ")");
+
+ if(id in mSocketMap)
+ {
+ // get the Socket
+ var s:PooledSocket = mSocketMap[id];
+
+ // load socket policy file
+ // (permits socket access to backend)
+ if(spPort !== 0)
+ {
+ spUrl = "xmlsocket://" + host + ":" + spPort;
+ log("using cross-domain url: " + spUrl);
+ Security.loadPolicyFile(spUrl);
+ }
+ else if(spUrl !== null && typeof(spUrl) !== undefined)
+ {
+ log("using cross-domain url: " + spUrl);
+ Security.loadPolicyFile(spUrl);
+ }
+ else
+ {
+ log("not loading any cross-domain url");
+ }
+
+ // connect
+ s.connect(host, port);
+ }
+ else
+ {
+ // no such socket
+ log("socket " + id + " does not exist");
+ }
+
+ log("connect(" + id + ") done");
+ }
+
+ /**
+ * Closes the Socket with the given ID.
+ *
+ * @param id the ID of the Socket.
+ */
+ private function close(id:String):void
+ {
+ log("close(" + id + ")");
+
+ if(id in mSocketMap)
+ {
+ // close the Socket
+ var s:PooledSocket = mSocketMap[id];
+ if(s.connected)
+ {
+ s.close();
+ }
+ }
+ else
+ {
+ // no such socket
+ log("socket " + id + " does not exist");
+ }
+
+ log("close(" + id + ") done");
+ }
+
+ /**
+ * Determines if the Socket with the given ID is connected or not.
+ *
+ * @param id the ID of the Socket.
+ *
+ * @return true if the socket is connected, false if not.
+ */
+ private function isConnected(id:String):Boolean
+ {
+ var rval:Boolean = false;
+ log("isConnected(" + id + ")");
+
+ if(id in mSocketMap)
+ {
+ // check the Socket
+ var s:PooledSocket = mSocketMap[id];
+ rval = s.connected;
+ }
+ else
+ {
+ // no such socket
+ log("socket " + id + " does not exist");
+ }
+
+ log("isConnected(" + id + ") done");
+ return rval;
+ }
+
+ /**
+ * Writes bytes to a Socket.
+ *
+ * @param id the ID of the Socket.
+ * @param bytes the string of base64-encoded bytes to write.
+ *
+ * @return true on success, false on failure.
+ */
+ private function send(id:String, bytes:String):Boolean
+ {
+ var rval:Boolean = false;
+ log("send(" + id + ")");
+
+ if(id in mSocketMap)
+ {
+ // write bytes to socket
+ var s:PooledSocket = mSocketMap[id];
+ try
+ {
+ var b64:Base64Decoder = new Base64Decoder();
+ b64.decode(bytes);
+ var b:ByteArray = b64.toByteArray();
+ s.writeBytes(b, 0, b.length);
+ s.flush();
+ rval = true;
+ }
+ catch(e:IOError)
+ {
+ log(e);
+
+ // dispatch IO error event
+ mEventDispatcher.dispatchEvent(new SocketEvent(
+ IOErrorEvent.IO_ERROR, s, e.message));
+ if(s.connected)
+ {
+ s.close();
+ }
+ }
+ }
+ else
+ {
+ // no such socket
+ log("socket " + id + " does not exist");
+ }
+
+ log("send(" + id + ") done");
+ return rval;
+ }
+
+ /**
+ * Receives bytes from a Socket.
+ *
+ * @param id the ID of the Socket.
+ * @param count the maximum number of bytes to receive.
+ *
+ * @return an object with 'rval' set to the received bytes,
+ * base64-encoded, or set to null on error.
+ */
+ private function receive(id:String, count:uint):Object
+ {
+ var rval:String = null;
+ log("receive(" + id + "," + count + ")");
+
+ if(id in mSocketMap)
+ {
+ // only read what is available
+ var s:PooledSocket = mSocketMap[id];
+ if(count > s.bytesAvailable)
+ {
+ count = s.bytesAvailable;
+ }
+
+ try
+ {
+ // read bytes from socket
+ var b:ByteArray = new ByteArray();
+ s.readBytes(b, 0, count);
+ b.position = 0;
+ var b64:Base64Encoder = new Base64Encoder();
+ b64.insertNewLines = false;
+ b64.encodeBytes(b, 0, b.length);
+ rval = b64.toString();
+ }
+ catch(e:IOError)
+ {
+ log(e);
+
+ // dispatch IO error event
+ mEventDispatcher.dispatchEvent(new SocketEvent(
+ IOErrorEvent.IO_ERROR, s, e.message));
+ if(s.connected)
+ {
+ s.close();
+ }
+ }
+ }
+ else
+ {
+ // no such socket
+ log("socket " + id + " does not exist");
+ }
+
+ log("receive(" + id + "," + count + ") done");
+ return {rval: rval};
+ }
+
+ /**
+ * Gets the number of bytes available from a Socket.
+ *
+ * @param id the ID of the Socket.
+ *
+ * @return the number of available bytes.
+ */
+ private function getBytesAvailable(id:String):uint
+ {
+ var rval:uint = 0;
+ log("getBytesAvailable(" + id + ")");
+
+ if(id in mSocketMap)
+ {
+ var s:PooledSocket = mSocketMap[id];
+ rval = s.bytesAvailable;
+ }
+ else
+ {
+ // no such socket
+ log("socket " + id + " does not exist");
+ }
+
+ log("getBytesAvailable(" + id +") done");
+ return rval;
+ }
+
+ /**
+ * Registers a javascript function as a callback for an event.
+ *
+ * @param eventType the type of event (socket event types).
+ * @param callback the name of the callback function.
+ */
+ private function subscribe(eventType:String, callback:String):void
+ {
+ log("subscribe(" + eventType + "," + callback + ")");
+
+ switch(eventType)
+ {
+ case Event.CONNECT:
+ case Event.CLOSE:
+ case IOErrorEvent.IO_ERROR:
+ case SecurityErrorEvent.SECURITY_ERROR:
+ case ProgressEvent.SOCKET_DATA:
+ {
+ log(eventType + " => " + callback);
+ mEventDispatcher.addEventListener(
+ eventType, function(event:SocketEvent):void
+ {
+ log("event dispatched: " + eventType);
+
+ // build event for javascript
+ var e:Object = new Object();
+ e.id = event.socket ? event.socket.id : 0;
+ e.type = eventType;
+ if(event.socket && event.socket.connected)
+ {
+ e.bytesAvailable = event.socket.bytesAvailable;
+ }
+ else
+ {
+ e.bytesAvailable = 0;
+ }
+ if(event.message)
+ {
+ e.message = event.message;
+ }
+
+ // send event to javascript
+ ExternalInterface.call(callback, e);
+ });
+ break;
+ }
+ default:
+ throw new ArgumentError(
+ "Could not subscribe to event. " +
+ "Invalid event type specified: " + eventType);
+ }
+
+ log("subscribe(" + eventType + "," + callback + ") done");
+ }
+
+ /**
+ * Deflates the given data.
+ *
+ * @param data the base64-encoded data to deflate.
+ *
+ * @return an object with 'rval' set to deflated data, base64-encoded.
+ */
+ private function deflate(data:String):Object
+ {
+ log("deflate");
+
+ var b64d:Base64Decoder = new Base64Decoder();
+ b64d.decode(data);
+ var b:ByteArray = b64d.toByteArray();
+ b.compress();
+ b.position = 0;
+ var b64e:Base64Encoder = new Base64Encoder();
+ b64e.insertNewLines = false;
+ b64e.encodeBytes(b, 0, b.length);
+
+ log("deflate done");
+ return {rval: b64e.toString()};
+ }
+
+ /**
+ * Inflates the given data.
+ *
+ * @param data the base64-encoded data to inflate.
+ *
+ * @return an object with 'rval' set to the inflated data,
+ * base64-encoded, null on error.
+ */
+ private function inflate(data:String):Object
+ {
+ log("inflate");
+ var rval:Object = {rval: null};
+
+ try
+ {
+ var b64d:Base64Decoder = new Base64Decoder();
+ b64d.decode(data);
+ var b:ByteArray = b64d.toByteArray();
+ b.uncompress();
+ b.position = 0;
+ var b64e:Base64Encoder = new Base64Encoder();
+ b64e.insertNewLines = false;
+ b64e.encodeBytes(b, 0, b.length);
+ rval.rval = b64e.toString();
+ }
+ catch(e:Error)
+ {
+ log(e);
+ rval.error = {
+ id: e.errorID,
+ name: e.name,
+ message: e.message
+ };
+ }
+
+ log("inflate done");
+ return rval;
+ }
+
+ /**
+ * Stores an item with a key and arbitrary base64-encoded data on local
+ * disk.
+ *
+ * @param key the key for the item.
+ * @param data the base64-encoded item data.
+ * @param storeId the storage ID to use, defaults to "forge.storage".
+ *
+ * @return an object with rval set to true on success, false on failure
+ * with error included.
+ */
+ private function setItem(
+ key:String, data:String, storeId:String = "forge.storage"):Object
+ {
+ var rval:Object = {rval: false};
+ try
+ {
+ var store:SharedObject = SharedObject.getLocal(storeId);
+ if(!('keys' in store.data))
+ {
+ store.data.keys = {};
+ }
+ store.data.keys[key] = data;
+ store.flush();
+ rval.rval = true;
+ }
+ catch(e:Error)
+ {
+ log(e);
+ rval.error = {
+ id: e.errorID,
+ name: e.name,
+ message: e.message
+ };
+ }
+ return rval;
+ }
+
+ /**
+ * Gets an item from the local disk.
+ *
+ * @param key the key for the item.
+ * @param storeId the storage ID to use, defaults to "forge.storage".
+ *
+ * @return an object with rval set to the item data (which may be null),
+ * check for error object if null.
+ */
+ private function getItem(
+ key:String, storeId:String = "forge.storage"):Object
+ {
+ var rval:Object = {rval: null};
+ try
+ {
+ var store:SharedObject = SharedObject.getLocal(storeId);
+ if('keys' in store.data && key in store.data.keys)
+ {
+ rval.rval = store.data.keys[key];
+ }
+ }
+ catch(e:Error)
+ {
+ log(e);
+ rval.error = {
+ id: e.errorID,
+ name: e.name,
+ message: e.message
+ };
+ }
+ return rval;
+ }
+
+ /**
+ * Removes an item from the local disk.
+ *
+ * @param key the key for the item.
+ * @param storeId the storage ID to use, defaults to "forge.storage".
+ *
+ * @return an object with rval set to true if removed, false if not.
+ */
+ private function removeItem(
+ key:String, storeId:String = "forge.storage"):Object
+ {
+ var rval:Object = {rval: false};
+ try
+ {
+ var store:SharedObject = SharedObject.getLocal(storeId);
+ if('keys' in store.data && key in store.data.keys)
+ {
+ delete store.data.keys[key];
+
+ // clean up storage entirely if empty
+ var empty:Boolean = true;
+ for(var prop:String in store.data.keys)
+ {
+ empty = false;
+ break;
+ }
+ if(empty)
+ {
+ store.clear();
+ }
+ rval.rval = true;
+ }
+ }
+ catch(e:Error)
+ {
+ log(e);
+ rval.error = {
+ id: e.errorID,
+ name: e.name,
+ message: e.message
+ };
+ }
+ return rval;
+ }
+
+ /**
+ * Clears an entire store of all of its items.
+ *
+ * @param storeId the storage ID to use, defaults to "forge.storage".
+ *
+ * @return an object with rval set to true if cleared, false if not.
+ */
+ private function clearItems(storeId:String = "forge.storage"):Object
+ {
+ var rval:Object = {rval: false};
+ try
+ {
+ var store:SharedObject = SharedObject.getLocal(storeId);
+ store.clear();
+ rval.rval = true;
+ }
+ catch(e:Error)
+ {
+ log(e);
+ rval.error = {
+ id: e.errorID,
+ name: e.name,
+ message: e.message
+ };
+ }
+ return rval;
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[25/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/API.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/API.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/API.md
new file mode 100644
index 0000000..7e940c2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/API.md
@@ -0,0 +1,1741 @@
+#API Reference
+
+- [Core](#core)
+ - [`new Promise(Function<Function resolve, Function reject> resolver)`](#new-promisefunctionfunction-resolve-function-reject-resolver---promise)
+ - [`.then([Function fulfilledHandler] [, Function rejectedHandler ] [, Function progressHandler ])`](#thenfunction-fulfilledhandler--function-rejectedhandler---function-progresshandler----promise)
+ - [`.catch(Function handler)`](#catchfunction-handler---promise)
+ - [`.catch([Function ErrorClass|Function predicate...], Function handler)`](#catchfunction-errorclassfunction-predicate-function-handler---promise)
+ - [`.error( [rejectedHandler] )`](#error-rejectedhandler----promise)
+ - [`.finally(Function handler)`](#finallyfunction-handler---promise)
+ - [`.tap(Function handler)`](#tapfunction-handler---promise)
+ - [`.bind(dynamic thisArg)`](#binddynamic-thisarg---promise)
+ - [`.done([Function fulfilledHandler] [, Function rejectedHandler ] [, Function progressHandler ])`](#donefunction-fulfilledhandler--function-rejectedhandler---function-progresshandler----promise)
+ - [`Promise.try(Function fn [, Array<dynamic>|dynamic arguments] [, dynamic ctx] )`](#promisetryfunction-fn--arraydynamicdynamic-arguments--dynamic-ctx----promise)
+ - [`Promise.method(Function fn)`](#promisemethodfunction-fn---function)
+ - [`Promise.resolve(dynamic value)`](#promiseresolvedynamic-value---promise)
+ - [`Promise.reject(dynamic reason)`](#promiserejectdynamic-reason---promise)
+ - [`Promise.defer()`](#promisedefer---promiseresolver)
+ - [`Promise.cast(dynamic value)`](#promisecastdynamic-value---promise)
+ - [`Promise.bind(dynamic thisArg)`](#promisebinddynamic-thisarg---promise)
+ - [`Promise.is(dynamic value)`](#promiseisdynamic-value---boolean)
+ - [`Promise.longStackTraces()`](#promiselongstacktraces---void)
+- [Progression](#progression)
+ - [`.progressed(Function handler)`](#progressedfunction-handler---promise)
+- [Promise resolution](#promise-resolution)
+ - [`.resolve(dynamic value)`](#resolvedynamic-value---undefined)
+ - [`.reject(dynamic reason)`](#rejectdynamic-reason---undefined)
+ - [`.progress(dynamic value)`](#progressdynamic-value---undefined)
+ - [`.callback`](#callback---function)
+- [Timers](#timers)
+ - [`.delay(int ms)`](#delayint-ms---promise)
+ - [`.timeout(int ms [, String message])`](#timeoutint-ms--string-message---promise)
+ - [`Promise.delay([dynamic value], int ms)`](#promisedelaydynamic-value-int-ms---promise)
+- [Promisification](#promisification)
+ - [`Promise.promisify(Function nodeFunction [, dynamic receiver])`](#promisepromisifyfunction-nodefunction--dynamic-receiver---function)
+ - [`Promise.promisify(Object target)`](#promisepromisifyobject-target---object)
+ - [`Promise.promisifyAll(Object target)`](#promisepromisifyallobject-target---object)
+ - [`.nodeify([Function callback])`](#nodeifyfunction-callback---promise)
+- [Cancellation](#cancellation)
+ - [`.cancellable()`](#cancellable---promise)
+ - [`.cancel()`](#cancel---promise)
+ - [`.fork([Function fulfilledHandler] [, Function rejectedHandler ] [, Function progressHandler ])`](#forkfunction-fulfilledhandler--function-rejectedhandler---function-progresshandler----promise)
+ - [`.uncancellable()`](#uncancellable---promise)
+ - [`.isCancellable()`](#iscancellable---boolean)
+- [Synchronous inspection](#synchronous-inspection)
+ - [`.isFulfilled()`](#isfulfilled---boolean)
+ - [`.isRejected()`](#isrejected---boolean)
+ - [`.isPending()`](#isdefer---boolean)
+ - [`.isResolved()`](#isresolved---boolean)
+ - [`.inspect()`](#inspect---promiseinspection)
+- [Generators](#generators)
+ - [`Promise.coroutine(GeneratorFunction generatorFunction)`](#promisecoroutinegeneratorfunction-generatorfunction---function)
+ - [`Promise.coroutine.addYieldHandler(function handler)`](#promisecoroutineaddyieldhandlerfunction-handler---void)
+- [Utility](#utility)
+ - [`.call(String propertyName [, dynamic arg...])`](#callstring-propertyname--dynamic-arg---promise)
+ - [`.get(String propertyName)`](#getstring-propertyname---promise)
+ - [`.return(dynamic value)`](#returndynamic-value---promise)
+ - [`.throw(dynamic reason)`](#throwdynamic-reason---promise)
+ - [`.toString()`](#tostring---string)
+ - [`.toJSON()`](#tojson---object)
+ - [`Promise.noConflict()`](#promisenoconflict---object)
+ - [`Promise.onPossiblyUnhandledRejection(Function handler)`](#promiseonpossiblyunhandledrejectionfunction-handler---undefined)
+- [Collections](#collections)
+ - [`.all()`](#all---promise)
+ - [`.props()`](#props---promise)
+ - [`.settle()`](#settle---promise)
+ - [`.any()`](#any---promise)
+ - [`.race()`](#race---promise)
+ - [`.some(int count)`](#someint-count---promise)
+ - [`.spread([Function fulfilledHandler] [, Function rejectedHandler ])`](#spreadfunction-fulfilledhandler--function-rejectedhandler----promise)
+ - [`.map(Function mapper)`](#mapfunction-mapper---promise)
+ - [`.reduce(Function reducer [, dynamic initialValue])`](#reducefunction-reducer--dynamic-initialvalue---promise)
+ - [`.filter(Function filterer)`](#filterfunction-filterer---promise)
+ - [`Promise.all(Array<dynamic>|Promise values)`](#promiseallarraydynamicpromise-values---promise)
+ - [`Promise.props(Object|Promise object)`](#promisepropsobjectpromise-object---promise)
+ - [`Promise.settle(Array<dynamic>|Promise values)`](#promisesettlearraydynamicpromise-values---promise)
+ - [`Promise.any(Array<dynamic>|Promise values)`](#promiseanyarraydynamicpromise-values---promise)
+ - [`Promise.race(Array|Promise promises)`](#promiseracearraypromise-promises---promise)
+ - [`Promise.some(Array<dynamic>|Promise values, int count)`](#promisesomearraydynamicpromise-values-int-count---promise)
+ - [`Promise.join([dynamic value...])`](#promisejoindynamic-value---promise)
+ - [`Promise.map(Array<dynamic>|Promise values, Function mapper)`](#promisemaparraydynamicpromise-values-function-mapper---promise)
+ - [`Promise.reduce(Array<dynamic>|Promise values, Function reducer [, dynamic initialValue])`](#promisereducearraydynamicpromise-values-function-reducer--dynamic-initialvalue---promise)
+ - [`Promise.filter(Array<dynamic>|Promise values, Function filterer)`](#promisefilterarraydynamicpromise-values-function-filterer---promise)
+
+##Core
+
+Core methods of `Promise` instances and core static methods of the Promise class.
+
+#####`new Promise(Function<Function resolve, Function reject> resolver)` -> `Promise`
+
+Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
+
+Example:
+
+```js
+function ajaxGetAsync(url) {
+ return new Promise(function (resolve, reject) {
+ var xhr = new XMLHttpRequest;
+ xhr.addEventListener("error", reject);
+ xhr.addEventListener("load", resolve);
+ xhr.open("GET", url);
+ xhr.send(null);
+ });
+}
+```
+
+If you pass a promise object to the `resolve` function, the created promise will follow the state of that promise.
+
+<hr>
+
+To make sure a function that returns a promise is following the implicit but critically important contract of promises, you can start a function with `new Promise` if you cannot start a chain immediately:
+
+```js
+function getConnection(urlString) {
+ return new Promise(function(resolve) {
+ //Without new Promise, this throwing will throw an actual exception
+ var params = parse(urlString);
+ resolve(getAdapater(params).getConnection());
+ });
+}
+```
+
+The above ensures `getConnection()` fulfills the contract of a promise-returning function of never throwing a synchronous exception. Also see [`Promise.try`](#promisetryfunction-fn--arraydynamicdynamic-arguments--dynamic-ctx----promise) and [`Promise.method`](#promisemethodfunction-fn---function)
+
+<hr>
+
+#####`.then([Function fulfilledHandler] [, Function rejectedHandler ] [, Function progressHandler ])` -> `Promise`
+
+[Promises/A+ `.then()`](http://promises-aplus.github.io/promises-spec/) with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
+
+Example:
+
+```js
+promptAsync("Which url to visit?").then(function(url){
+ return ajaxGetAsync(url);
+}).then(function(contents){
+ alertAsync("The contents were: " + contents);
+}).catch(function(e){
+ alertAsync("Exception " + e);
+});
+```
+
+<hr>
+
+#####`.catch(Function handler)` -> `Promise`
+
+This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
+
+*For compatibility with earlier ECMAScript version, an alias `.caught()` is provided for `.catch()`.*
+
+<hr>
+
+#####`.catch([Function ErrorClass|Function predicate...], Function handler)` -> `Promise`
+
+This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
+
+Example:
+
+```js
+somePromise.then(function(){
+ return a.b.c.d();
+}).catch(TypeError, function(e){
+ //If a is defined, will end up here because
+ //it is a type error to reference property of undefined
+}).catch(ReferenceError, function(e){
+ //Will end up here if a wasn't defined at all
+}).catch(function(e){
+ //Generic catch-the rest, error wasn't TypeError nor
+ //ReferenceError
+});
+ ```
+
+You may also add multiple filters for a catch handler:
+
+```js
+somePromise.then(function(){
+ return a.b.c.d();
+}).catch(TypeError, ReferenceError, function(e){
+ //Will end up here on programmer error
+}).catch(NetworkError, TimeoutError, function(e){
+ //Will end up here on expected everyday network errors
+}).catch(function(e){
+ //Catch any unexpected errors
+});
+```
+
+For a parameter to be considered a type of error that you want to filter, you need the constructor to have its `.prototype` property be `instanceof Error`.
+
+Such a constructor can be minimally created like so:
+
+```js
+function MyCustomError() {}
+MyCustomError.prototype = Object.create(Error.prototype);
+```
+
+Using it:
+
+```js
+Promise.resolve().then(function(){
+ throw new MyCustomError();
+}).catch(MyCustomError, function(e){
+ //will end up here now
+});
+```
+
+However if you want stack traces and cleaner string output, then you should do:
+
+*in Node.js and other V8 environments, with support for `Error.captureStackTrace`*
+
+```js
+function MyCustomError(message) {
+ this.message = message;
+ this.name = "MyCustomError";
+ Error.captureStackTrace(this, MyCustomError);
+}
+MyCustomError.prototype = Object.create(Error.prototype);
+MyCustomError.prototype.constructor = MyCustomError;
+```
+
+Using CoffeeScript's `class` for the same:
+
+```coffee
+class MyCustomError extends Error
+ constructor: (@message) ->
+ @name = "MyCustomError"
+ Error.captureStackTrace(this, MyCustomError)
+```
+
+This method also supports predicate-based filters. If you pass a
+predicate function instead of an error constructor, the predicate will receive
+the error as an argument. The return result of the predicate will be used
+determine whether the error handler should be called.
+
+Predicates should allow for very fine grained control over caught errors:
+pattern matching, error-type sets with set operations and many other techniques
+can be implemented on top of them.
+
+Example of using a predicate-based filter:
+
+```js
+var Promise = require("bluebird");
+var request = Promise.promisify(require("request"));
+
+function clientError(e) {
+ return e.code >= 400 && e.code < 500;
+}
+
+request("http://www.google.com").then(function(contents){
+ console.log(contents);
+}).catch(clientError, function(e){
+ //A client error like 400 Bad Request happened
+});
+```
+
+*For compatibility with earlier ECMAScript version, an alias `.caught()` is provided for `.catch()`.*
+
+<hr>
+
+#####`.error( [rejectedHandler] )` -> `Promise`
+
+Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
+
+*Note, "errors" mean errors, as in objects that are `instanceof Error` - not strings, numbers and so on. See [a string is not an error](http://www.devthought.com/2011/12/22/a-string-is-not-an-error/).*
+
+For example, if a promisified function errbacks the node-style callback with an error, that could be caught with `.error()`. However if the node-style callback **throws** an error, only `.catch` would catch that.
+
+In the following example you might want to handle just the `SyntaxError` from JSON.parse and Filesystem errors from `fs` but let programmer errors bubble as unhandled rejections:
+
+```js
+var fs = Promise.promisifyAll(require("fs"));
+
+fs.readFileAsync("myfile.json").then(JSON.parse).then(function (json) {
+ console.log("Successful json")
+}).catch(SyntaxError, function (e) {
+ console.error("file contains invalid json");
+}).error(function (e) {
+ console.error("unable to read file, because: ", e.message);
+});
+```
+
+Now, because there is no catch-all handler, if you typed `console.lag` (causes an error you don't expect), you will see:
+
+```
+Possibly unhandled TypeError: Object #<Console> has no method 'lag'
+ at application.js:8:13
+From previous event:
+ at Object.<anonymous> (application.js:7:4)
+ at Module._compile (module.js:449:26)
+ at Object.Module._extensions..js (module.js:467:10)
+ at Module.load (module.js:349:32)
+ at Function.Module._load (module.js:305:12)
+ at Function.Module.runMain (module.js:490:10)
+ at startup (node.js:121:16)
+ at node.js:761:3
+```
+
+*( If you don't get the above - you need to enable [long stack traces](#promiselongstacktraces---void) )*
+
+And if the file contains invalid JSON:
+
+```
+file contains invalid json
+```
+
+And if the `fs` module causes an error like file not found:
+
+```
+unable to read file, because: ENOENT, open 'not_there.txt'
+```
+
+<hr>
+
+#####`.finally(Function handler)` -> `Promise`
+
+Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
+
+Consider the example:
+
+```js
+function anyway() {
+ $("#ajax-loader-animation").hide();
+}
+
+function ajaxGetAsync(url) {
+ return new Promise(function (resolve, reject) {
+ var xhr = new XMLHttpRequest;
+ xhr.addEventListener("error", reject);
+ xhr.addEventListener("load", resolve);
+ xhr.open("GET", url);
+ xhr.send(null);
+ }).then(anyway, anyway);
+}
+```
+
+This example doesn't work as intended because the `then` handler actually swallows the exception and returns `undefined` for any further chainers.
+
+The situation can be fixed with `.finally`:
+
+```js
+function ajaxGetAsync(url) {
+ return new Promise(function (resolve, reject) {
+ var xhr = new XMLHttpRequest;
+ xhr.addEventListener("error", reject);
+ xhr.addEventListener("load", resolve);
+ xhr.open("GET", url);
+ xhr.send(null);
+ }).finally(function(){
+ $("#ajax-loader-animation").hide();
+ });
+}
+```
+
+Now the animation is hidden but an exception or the actual return value will automatically skip the finally and propagate to further chainers. This is more in line with the synchronous `finally` keyword.
+
+The `.finally` works like [Q's finally method](https://github.com/kriskowal/q/wiki/API-Reference#promisefinallycallback).
+
+*For compatibility with earlier ECMAScript version, an alias `.lastly()` is provided for `.finally()`.*
+
+<hr>
+
+#####`.tap(Function handler)` -> `Promise`
+
+Like `.finally` that is not called for rejections.
+
+```js
+getUser().tap(function(user) {
+ //Like in finally, if you return a promise from the handler
+ //the promise is awaited for before passing the original value through
+ return recordStatsAsync();
+}).then(function(user) {
+ //user is the user from getUser(), not recordStatsAsync()
+});
+```
+
+<hr>
+
+#####`.bind(dynamic thisArg)` -> `Promise`
+
+Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
+
+<hr>
+
+Without arrow functions that provide lexical `this`, the correspondence between async and sync code breaks down when writing object-oriented code. `.bind()` alleviates this.
+
+Consider:
+
+```js
+MyClass.prototype.method = function() {
+ try {
+ var contents = fs.readFileSync(this.file);
+ var url = urlParse(contents);
+ var result = this.httpGetSync(url);
+ var refined = this.refine(result);
+ return this.writeRefinedSync(refined);
+ }
+ catch (e) {
+ this.error(e.stack);
+ }
+};
+```
+
+The above has a direct translation:
+
+```js
+MyClass.prototype.method = function() {
+ return fs.readFileAsync(this.file).bind(this)
+ .then(function(contents) {
+ var url = urlParse(contents);
+ return this.httpGetAsync(url);
+ }).then(function(result){
+ var refined = this.refine(result);
+ return this.writeRefinedAsync(refined);
+ }).catch(function(e){
+ this.error(e.stack);
+ });
+};
+```
+
+`.bind()` is the most efficient way of utilizing `this` with promises. The handler functions in the above code are not closures and can therefore even be hoisted out if needed. There is literally no overhead when propagating the bound value from one promise to another.
+
+<hr>
+
+`.bind()` also has a useful side purpose - promise handlers don't need to share a function to use shared state:
+
+```js
+somethingAsync().bind({})
+.then(function (aValue, bValue) {
+ this.aValue = aValue;
+ this.bValue = bValue;
+ return somethingElseAsync(aValue, bValue);
+})
+.then(function (cValue) {
+ return this.aValue + this.bValue + cValue;
+});
+```
+
+The above without `.bind()` could be achieved with:
+
+```js
+var scope = {};
+somethingAsync()
+.then(function (aValue, bValue) {
+ scope.aValue = aValue;
+ scope.bValue = bValue;
+ return somethingElseAsync(aValue, bValue);
+})
+.then(function (cValue) {
+ return scope.aValue + scope.bValue + cValue;
+});
+```
+
+However, there are many differences when you look closer:
+
+- Requires a statement so cannot be used in an expression context
+- If not there already, an additional wrapper function is required to avoid leaking or sharing `scope`
+- The handler functions are now closures, thus less efficient and not reusable
+
+<hr>
+
+Note that bind is only propagated with promise transformation. If you create new promise chains inside a handler, those chains are not bound to the "upper" `this`:
+
+```js
+something().bind(var1).then(function(){
+ //`this` is var1 here
+ return Promise.all(getStuff()).then(function(results){
+ //`this` is undefined here
+ //refine results here etc
+ });
+}).then(function(){
+ //`this` is var1 here
+});
+```
+
+However, if you are utilizing the full bluebird API offering, you will *almost never* need to resort to nesting promises in the first place. The above should be written more like:
+
+```js
+something().bind(var1).then(function() {
+ //`this` is var1 here
+ return getStuff();
+}).map(function(result){
+ //`this` is var1 here
+ //refine result here
+}).then(function(){
+ //`this` is var1 here
+});
+```
+
+Also see [this Stackoverflow answer](http://stackoverflow.com/a/19467053/995876) on a good example on how utilizing the collection instance methods like [`.map()`](#mapfunction-mapper---promise) can clean up code.
+
+<hr>
+
+If you don't want to return a bound promise to the consumers of a promise, you can rebind the chain at the end:
+
+```js
+MyClass.prototype.method = function() {
+ return fs.readFileAsync(this.file).bind(this)
+ .then(function(contents) {
+ var url = urlParse(contents);
+ return this.httpGetAsync(url);
+ }).then(function(result){
+ var refined = this.refine(result);
+ return this.writeRefinedAsync(refined);
+ }).catch(function(e){
+ this.error(e.stack);
+ }).bind(); //The `thisArg` is implicitly undefined - I.E. the default promise `this` value
+};
+```
+
+Rebinding can also be abused to do something gratuitous like this:
+
+```js
+Promise.resolve("my-element")
+ .bind(document)
+ .then(document.getElementById)
+ .bind(console)
+ .then(console.log);
+```
+
+The above does `console.log(document.getElementById("my-element"));`. The `.bind()`s are necessary because in browser neither of the methods can be called as a stand-alone function.
+
+<hr>
+
+#####`.done([Function fulfilledHandler] [, Function rejectedHandler ] [, Function progressHandler ])` -> `Promise`
+
+Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
+
+<hr>
+
+#####`Promise.try(Function fn [, Array<dynamic>|dynamic arguments] [, dynamic ctx] )` -> `Promise`
+
+Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
+
+```js
+function getUserById(id) {
+ return Promise.try(function(){
+ if (typeof id !== "number") {
+ throw new Error("id must be a number");
+ }
+ return db.getUserById(id);
+ });
+}
+```
+
+Now if someone uses this function, they will catch all errors in their Promise `.catch` handlers instead of having to handle both synchronous and asynchronous exception flows.
+
+Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.
+
+*For compatibility with earlier ECMAScript version, an alias `Promise.attempt()` is provided for `Promise.try()`.*
+
+<hr>
+
+#####`Promise.method(Function fn)` -> `Function`
+
+Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
+
+This method is convenient when a function can sometimes return synchronously or throw synchronously.
+
+Example without using `Promise.method`:
+
+```js
+MyClass.prototype.method = function(input) {
+ if (!this.isValid(input)) {
+ return Promise.reject(new TypeError("input is not valid"));
+ }
+
+ if (this.cache(input)) {
+ return Promise.resolve(this.someCachedValue);
+ }
+
+ return db.queryAsync(input).bind(this).then(function(value) {
+ this.someCachedValue = value;
+ return value;
+ });
+};
+```
+
+Using the same function `Promise.method`, there is no need to manually wrap direct return or throw values into a promise:
+
+```js
+MyClass.prototype.method = Promise.method(function(input) {
+ if (!this.isValid(input)) {
+ throw new TypeError("input is not valid");
+ }
+
+ if (this.cachedFor(input)) {
+ return this.someCachedValue;
+ }
+
+ return db.queryAsync(input).bind(this).then(function(value) {
+ this.someCachedValue = value;
+ return value;
+ });
+});
+```
+
+<hr>
+
+#####`Promise.resolve(dynamic value)` -> `Promise`
+
+Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
+
+<hr>
+
+#####`Promise.reject(dynamic reason)` -> `Promise`
+
+Create a promise that is rejected with the given `reason`.
+
+<hr>
+
+#####`Promise.defer()` -> `PromiseResolver`
+
+Create a promise with undecided fate and return a `PromiseResolver` to control it. See [Promise resolution](#promise-resolution).
+
+The use of `Promise.defer` is discouraged - it is much more awkward and error-prone than using `new Promise`.
+
+<hr>
+
+#####`Promise.cast(dynamic value)` -> `Promise`
+
+Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled Promise is returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted Promise that assimilates the state of the thenable.
+
+Example: (`$` is jQuery)
+
+```js
+Promise.cast($.get("http://www.google.com")).then(function(){
+ //Returning a thenable from a handler is automatically
+ //cast to a trusted Promise as per Promises/A+ specification
+ return $.post("http://www.yahoo.com");
+}).then(function(){
+
+}).catch(function(e){
+ //jQuery doesn't throw real errors so use catch-all
+ console.log(e.statusText);
+});
+```
+
+<hr>
+
+#####`Promise.bind(dynamic thisArg)` -> `Promise`
+
+Sugar for `Promise.resolve(undefined).bind(thisArg);`. See [`.bind()`](#binddynamic-thisarg---promise).
+
+<hr>
+
+#####`Promise.is(dynamic value)` -> `boolean`
+
+See if `value` is a trusted Promise.
+
+```js
+Promise.is($.get("http://www.google.com")); //false , thenable returned from $.get is not a `Promise` instance
+Promise.is(Promise.cast($.get("http://www.google.com"))) //true, `.cast` cast the thenable into a `Promise`
+```
+
+Trusted Promises are promises originating in the currently used copy of Bluebird. Promises originating in other libraries are called thenables and are _not_ trusted promises. This method is used for checking if a passed value is of the same type as `Promise` itself creates.
+
+<hr>
+
+#####`Promise.longStackTraces()` -> `void`
+
+Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
+
+Long stack traces are enabled by default in the debug build.
+
+To enable them in all instances of bluebird in node.js, use the environment variable `BLUEBIRD_DEBUG`:
+
+```
+BLUEBIRD_DEBUG=1 node server.js
+```
+
+You should enabled long stack traces if you want better debugging experience. For example:
+
+```js
+Promise.longStackTraces();
+Promise.resolve().then(function outer() {
+ return Promise.resolve().then(function inner() {
+ return Promise.resolve().then(function evenMoreInner() {
+ a.b.c.d()
+ }).catch(function catcher(e){
+ console.error(e.stack);
+ });
+ });
+});
+```
+
+Gives
+
+ ReferenceError: a is not defined
+ at evenMoreInner (<anonymous>:6:13)
+ From previous event:
+ at inner (<anonymous>:5:24)
+ From previous event:
+ at outer (<anonymous>:4:20)
+ From previous event:
+ at <anonymous>:3:9
+ at Object.InjectedScript._evaluateOn (<anonymous>:581:39)
+ at Object.InjectedScript._evaluateAndWrap (<anonymous>:540:52)
+ at Object.InjectedScript.evaluate (<anonymous>:459:21)
+
+While with long stack traces disabled, you would get:
+
+ ReferenceError: a is not defined
+ at evenMoreInner (<anonymous>:6:13)
+ at tryCatch1 (<anonymous>:41:19)
+ at Promise$_resolvePromise [as _resolvePromise] (<anonymous>:1739:13)
+ at Promise$_resolveLast [as _resolveLast] (<anonymous>:1520:14)
+ at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (<anonymous>:560:33)
+ at Async$consumeFunctionBuffer (<anonymous>:515:14)
+ at MutationObserver.Promise$_Deferred (<anonymous>:433:17)
+
+On client side, long stack traces currently only work in Firefox and Chrome.
+
+<hr>
+
+##Progression
+
+#####`.progressed(Function handler)` -> `Promise`
+
+Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
+
+<hr>
+
+##Promise resolution
+
+A `PromiseResolver` can be used to control the fate of a promise. It is like "Deferred" known in jQuery. The `PromiseResolver` objects have a `.promise` property which returns a reference to the controlled promise that can be passed to clients. `.promise` of a `PromiseResolver` is not a getter function to match other implementations.
+
+The methods of a `PromiseResolver` have no effect if the fate of the underlying promise is already decided (follow, reject, fulfill).
+
+The use of `Promise.defer` and deferred objects is discouraged - it is much more awkward and error-prone than using `new Promise`.
+
+<hr>
+
+#####`.resolve(dynamic value)` -> `undefined`
+
+Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state.
+
+<hr>
+
+#####`.reject(dynamic reason)` -> `undefined`
+
+Reject the underlying promise with `reason` as the rejection reason.
+
+<hr>
+
+#####`.progress(dynamic value)` -> `undefined`
+
+Progress the underlying promise with `value` as the progression value.
+
+Example
+
+```js
+function delay(ms) {
+ var resolver = Promise.defer();
+ var now = Date.now();
+ setTimeout(function(){
+ resolver.resolve(Date.now() - now);
+ }, ms);
+ return resolver.promise;
+}
+
+delay(500).then(function(ms){
+ console.log(ms + " ms passed");
+});
+```
+
+<hr>
+
+#####`.callback` -> `Function`
+
+Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
+
+If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
+
+```js
+var fs = require("fs");
+function readAbc() {
+ var resolver = Promise.defer();
+ fs.readFile("abc.txt", resolver.callback);
+ return resolver.promise;
+}
+
+readAbc()
+.then(function(abcContents) {
+ console.log(abcContents);
+})
+.catch(function(e) {
+ console.error(e);
+});
+```
+
+This example is an alternative to automatic promisification of node functions.
+
+*Performance tips*
+
+The `callback` is actually an accessor property (except on legacy browsers where it's eager data property) - so save the result if you need to call it multiple times.
+
+This is more efficient way of promisification than using `new Promise`.
+
+<hr>
+
+##Timers
+
+Methods to delay and time promises out.
+
+#####`.delay(int ms)` -> `Promise`
+
+Same as calling [`Promise.delay(this, ms)`](#promisedelaydynamic-value-int-ms---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+<hr>
+
+#####`.timeout(int ms [, String message])` -> `Promise`
+
+Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
+
+You may specify a custom error message with the `message` parameter.
+
+The example function `fetchContent` tries to fetch the contents of a web page with a 50ms timeout and sleeping 100ms between each retry. If there is no response after 5 retries, then the returned promise is rejected with a `ServerError` (made up error type). Additionally the whole process can be cancelled from outside at any point.
+
+```js
+function fetchContent(retries) {
+ if (!retries) retries = 0;
+ var jqXHR = $.get("http://www.slowpage.com");
+ //Cast the jQuery promise into a bluebird promise
+ return Promise.cast(jqXHR)
+ .cancellable()
+ .timeout(50)
+ .catch(Promise.TimeoutError, function() {
+ if (retries < 5) {
+ return Promise.delay(100).then(function(){
+ return fetchContent(retries+1);
+ });
+ }
+ else {
+ throw new ServerError("not responding after 5 retries");
+ }
+ })
+ .catch(Promise.CancellationError, function(er) {
+ jqXHR.abort();
+ throw er; //Don't swallow it
+ });
+}
+```
+
+<hr>
+
+#####`Promise.delay([dynamic value], int ms)` -> `Promise`
+
+Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise.
+
+```js
+Promise.delay(500).then(function(){
+ console.log("500 ms passed");
+ return "Hello world";
+}).delay(500).then(function(helloWorldString) {
+ console.log(helloWorldString);
+ console.log("another 500 ms passed") ;
+});
+```
+
+<hr>
+
+##Promisification
+
+#####`Promise.promisify(Function nodeFunction [, dynamic receiver])` -> `Function`
+
+Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.
+
+If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
+
+If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
+
+Example of promisifying the asynchronous `readFile` of node.js `fs`-module:
+
+```js
+var readFile = Promise.promisify(require("fs").readFile);
+
+readFile("myfile.js", "utf8").then(function(contents){
+ return eval(contents);
+}).then(function(result){
+ console.log("The result of evaluating myfile.js", result);
+}).catch(SyntaxError, function(e){
+ console.log("File had syntax error", e);
+//Catch any other error
+}).catch(function(e){
+ console.log("Error reading file", e);
+});
+```
+
+Note that if the node function is a method of some object, you need to pass the object as the second argument like so:
+
+```js
+var redisGet = Promise.promisify(redisClient.get, redisClient);
+redisGet.then(function(){
+ //...
+});
+```
+
+**Tip**
+
+Use [`.spread`](#spreadfunction-fulfilledhandler--function-rejectedhandler----promise) with APIs that have multiple success values:
+
+```js
+var Promise = require("bluebird");
+var request = Promise.promisify(require('request'));
+request("http://www.google.com").spread(function(request, body) {
+ console.log(body);
+}).catch(function(err) {
+ console.error(err);
+});
+```
+
+The above uses [request](https://github.com/mikeal/request) library which has a callback signature of multiple success values.
+
+<hr>
+
+#####`Promise.promisify(Object target)` -> `Object`
+
+This overload has been **deprecated**. The overload will continue working for now. The recommended method for promisifying multiple methods at once is [`Promise.promisifyAll(Object target)`](#promisepromisifyallobject-target---object)
+
+<hr>
+
+#####`Promise.promisifyAll(Object target)` -> `Object`
+
+Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
+
+Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
+
+Example:
+
+```js
+Promise.promisifyAll(RedisClient.prototype);
+
+//Later on, all redis client instances have promise returning functions:
+
+redisClient.hexistsAsync("myhash", "field").then(function(v){
+
+}).catch(function(e){
+
+});
+```
+
+If you don't want to write on foreign prototypes, you can sub-class the target and promisify your subclass:
+
+```js
+function MyRedisClient() {
+ RedisClient.apply(this, arguments);
+}
+MyRedisClient.prototype = Object.create(RedisClient.prototype);
+MyRedisClient.prototype.constructor = MyRedisClient;
+Promise.promisify(MyRedisClient.prototype);
+```
+
+The promisified methods will be written on the `MyRedisClient.prototype` instead. This specific example doesn't actually work with `node_redis` because the `createClient` factory is hardcoded to instantiate `RedisClient` from closure.
+
+
+It also works on singletons or specific instances:
+
+```js
+var fs = Promise.promisifyAll(require("fs"));
+
+fs.readFileAsync("myfile.js", "utf8").then(function(contents){
+ console.log(contents);
+}).catch(function(e){
+ console.error(e.stack);
+});
+```
+
+The entire prototype chain of the object is promisified on the object. Only enumerable are considered. If the object already has a promisified version of the method, it will be skipped. The target methods are assumed to conform to node.js callback convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument. If the node method calls its callback with multiple success values, the fulfillment value will be an array of them.
+
+If a method already has `"Async"` postfix, it will be duplicated. E.g. `getAsync`'s promisified name is `getAsyncAsync`.
+
+<hr>
+
+#####`.nodeify([Function callback])` -> `Promise`
+
+Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
+
+Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
+
+This can be used to create APIs that both accept node-style callbacks and return promises:
+
+```js
+function getDataFor(input, callback) {
+ return dataFromDataBase(input).nodeify(callback);
+}
+```
+
+The above function can then make everyone happy.
+
+Promises:
+
+```js
+getDataFor("me").then(function(dataForMe) {
+ console.log(dataForMe);
+});
+```
+
+Normal callbacks:
+
+```js
+getDataFor("me", function(err, dataForMe) {
+ if( err ) {
+ console.error( err );
+ }
+ console.log(dataForMe);
+});
+```
+
+There is no effect on peformance if the user doesn't actually pass a node-style callback function.
+
+<hr>
+
+##Cancellation
+
+By default, a promise is not cancellable. A promise can be marked as cancellable with `.cancellable()`. A cancellable promise can be cancelled if it's not resolved. Cancelling a promise propagates to the farthest cancellable ancestor of the target promise that is still pending, and rejects that promise with `CancellationError`. The rejection will then propagate back to the original promise and to its descendants. This roughly follows the semantics described [here](https://github.com/promises-aplus/cancellation-spec/issues/7).
+
+Promises marked with `.cancellable()` return cancellable promises automatically.
+
+If you are the resolver for a promise, you can react to a cancel in your promise by catching the `CancellationError`:
+
+```js
+function ajaxGetAsync(url) {
+ var xhr = new XMLHttpRequest;
+ return new Promise(function (resolve, reject) {
+ xhr.addEventListener("error", reject);
+ xhr.addEventListener("load", resolve);
+ xhr.open("GET", url);
+ xhr.send(null);
+ }).cancellable().catch(Promise.CancellationError, function(e) {
+ xhr.abort();
+ throw e; //Don't swallow it
+ });
+}
+```
+
+<hr>
+
+#####`.cancellable()` -> `Promise`
+
+Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for [`.cancel()`](#cancel---promise) to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
+
+If you have code written prior v0.11 using cancellation, add calls to `.cancellable()` at the starts of promise chains that need to support
+cancellation in themselves or somewhere in their descendants.
+
+<hr>
+
+#####`.cancel()` -> `Promise`
+
+Cancel this promise. The cancellation will propagate
+to farthest cancellable ancestor promise which is still pending.
+
+That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`)
+object as the rejection reason.
+
+In a promise rejection handler you may check for a cancellation
+by seeing if the reason object has `.name === "Cancel"`.
+
+Promises are by default not cancellable. Use [`.cancellable()`](#cancellable---promise) to mark a promise as cancellable.
+
+<hr>
+
+#####`.fork([Function fulfilledHandler] [, Function rejectedHandler ] [, Function progressHandler ])` -> `Promise`
+
+Like `.then()`, but cancellation of the the returned promise
+or any of its descendant will not propagate cancellation
+to this promise or this promise's ancestors.
+
+<hr>
+
+#####`.uncancellable()` -> `Promise`
+
+Create an uncancellable promise based on this promise.
+
+<hr>
+
+#####`.isCancellable()` -> `boolean`
+
+See if this promise can be cancelled.
+
+<hr>
+
+##Synchronous inspection
+
+Because `.then()` must give asynchronous guarantees, it cannot be used to inspect a given promise's state synchronously. The following code won't work:
+
+```js
+var wasFulfilled = false;
+var wasRejected = false;
+var resolutionValueOrRejectionReason = null;
+somePromise.then(function(v){
+ wasFulfilled = true;
+ resolutionValueOrRejectionReason = v
+}).catch(function(v){
+ wasRejected = true;
+ resolutionValueOrRejectionReason = v
+});
+//Using the variables won't work here because .then must be called asynchronously
+```
+
+Synchronous inspection API allows you to do this like so:
+
+```js
+var inspection = somePromise.inspect();
+
+if(inspection.isFulfilled()){
+ console.log("Was fulfilled with", inspection.value());
+}
+```
+
+<hr>
+
+#####`.isFulfilled()` -> `boolean`
+
+See if this `promise` has been fulfilled.
+
+<hr>
+
+#####`.isRejected()` -> `boolean`
+
+See if this `promise` has been rejected.
+
+<hr>
+
+#####`.isPending()` -> `boolean`
+
+See if this `promise` is still defer.
+
+<hr>
+
+#####`.isResolved()` -> `boolean`
+
+See if this `promise` is resolved -> either fulfilled or rejected.
+
+<hr>
+
+#####`.inspect()` -> `PromiseInspection`
+
+Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`. It will have the following methods:
+
+`.isFulfilled()` -> `boolean`
+
+See if the underlying promise was fulfilled at the creation time of this inspection object.
+
+`.isRejected()` -> `boolean`
+
+See if the underlying promise was rejected at the creation time of this inspection object.
+
+`.isPending()` -> `boolean`
+
+See if the underlying promise was defer at the creation time of this inspection object.
+
+`.value()` -> `dynamic`, throws `TypeError`
+
+Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object.
+
+`.error()` -> `dynamic`, throws `TypeError`
+
+Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object.
+
+<hr>
+
+##Generators
+
+Using ECMAScript6 generators feature to implement C# 5.0 `async/await` like syntax.
+
+#####`Promise.coroutine(GeneratorFunction generatorFunction)` -> `Function`
+
+Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
+
+This is the recommended, simplest and most performant way of using asynchronous generators with bluebird. It is even faster than typical promise code because the creation of new anonymous function identities at runtime can be completely avoided without obfuscating your code.
+
+```js
+var Promise = require("bluebird");
+
+function delay(ms) {
+ return new Promise(function(f){
+ setTimeout(f, ms);
+ });
+}
+
+function PingPong() {
+
+}
+
+PingPong.prototype.ping = Promise.coroutine(function* (val) {
+ console.log("Ping?", val)
+ yield delay(500)
+ this.pong(val+1)
+});
+
+PingPong.prototype.pong = Promise.coroutine(function* (val) {
+ console.log("Pong!", val)
+ yield delay(500);
+ this.ping(val+1)
+});
+
+var a = new PingPong();
+a.ping(0);
+```
+
+Running the example with node version at least 0.11.2:
+
+ $ node --harmony test.js
+ Ping? 0
+ Pong! 1
+ Ping? 2
+ Pong! 3
+ Ping? 4
+ Pong! 5
+ Ping? 6
+ Pong! 7
+ Ping? 8
+ ...
+
+When called, the coroutine function will start an instance of the generator and returns a promise for its final value.
+
+Doing `Promise.coroutine(function*(){})` is almost like using the C# `async` keyword to mark the function, with `yield` working as the `await` keyword. Promises are somewhat like `Task`s.
+
+**Tip**
+
+If you yield an array then its elements are implicitly waited for. You may add your own custom special treatments with [`Promise.coroutine.addYieldHandler`](#promisecoroutineaddyieldhandlerfunction-handler---void)
+
+You can combine it with ES6 destructuring for some neat syntax:
+
+```js
+var getData = Promise.coroutine(function* (urlA, urlB) {
+ [resultA, resultB] = yield [http.getAsync(urlA), http.getAsync(urlB)];
+ //use resultA
+ //use resultB
+});
+```
+
+You might wonder why not just do this?
+
+```js
+var getData = Promise.coroutine(function* (urlA, urlB) {
+ var resultA = yield http.getAsync(urlA);
+ var resultB = yield http.getAsync(urlB);
+});
+```
+
+The problem with the above is that the requests are not done in parallel. It will completely wait for request A to complete before even starting request B. In the array syntax both requests fire off at the same time in parallel.
+
+<hr>
+
+#####`Promise.coroutine.addYieldHandler(function handler)` -> `void`
+
+By default you can only yield Promises, Thenables and Arrays inside coroutines. You can use this function to add yielding support for arbitrary types.
+
+For example, if you wanted `yield 500` to be same as `yield Promise.delay(500)`:
+
+```js
+Promise.coroutine.addYieldHandler(function(value) {
+ if (typeof value === "number") return Promise.delay(value);
+});
+```
+
+Yield handlers are called when you yield something that is not supported by default. The first yield handler to return a promise or a thenable will be used.
+If no yield handler returns a promise or a thenable then an error is raised.
+
+An example of implementing callback support with `addYieldHandler`:
+
+*This is a demonstration of how powerful the feature is and not the recommended usage. For best performance you need to use `promisifyAll` and yield promises directly.*
+
+```js
+var Promise = require("bluebird");
+var fs = require("fs");
+
+var _ = (function() {
+ var promise = null;
+ Promise.coroutine.addYieldHandler(function(v) {
+ if (v === void 0 && promise != null) {
+ return promise;
+ }
+ promise = null;
+ });
+ return function() {
+ var def = Promise.defer();
+ promise = def.promise;
+ return def.callback;
+ };
+})();
+
+
+var readFileJSON = Promise.coroutine(function* (fileName) {
+ var contents = yield fs.readFile(fileName, "utf8", _());
+ return JSON.parse(contents);
+});
+```
+
+An example of implementing thunks support with `addYieldHandler`:
+
+*This is a demonstration of how powerful the feature is and not the recommended usage. For best performance you need to use `promisifyAll` and yield promises directly.*
+
+```js
+var Promise = require("bluebird");
+var fs = require("fs");
+
+Promise.coroutine.addYieldHandler(function(v) {
+ if (typeof v === "function") {
+ var def = Promise.defer();
+ try { v(def.callback); } catch(e) { def.reject(e); }
+ return def.promise;
+ }
+});
+
+var readFileThunk = function(fileName, encoding) {
+ return function(cb) {
+ return fs.readFile(fileName, encoding, cb);
+ };
+};
+
+var readFileJSON = Promise.coroutine(function* (fileName) {
+ var contents = yield readFileThunk(fileName, "utf8");
+ return JSON.parse(contents);
+});
+```
+
+##Utility
+
+Functions that could potentially be handy in some situations.
+
+#####`.call(String propertyName [, dynamic arg...])` -> `Promise`
+
+This is a convenience method for doing:
+
+```js
+promise.then(function(obj){
+ return obj[propertyName].call(obj, arg...);
+});
+```
+
+<hr>
+
+#####`.get(String propertyName)` -> `Promise`
+
+This is a convenience method for doing:
+
+```js
+promise.then(function(obj){
+ return obj[propertyName];
+});
+```
+
+<hr>
+
+#####`.return(dynamic value)` -> `Promise`
+
+Convenience method for:
+
+```js
+.then(function() {
+ return value;
+});
+```
+
+in the case where `value` doesn't change its value.
+
+That means `value` is bound at the time of calling `.return()` so this will not work as expected:
+
+```js
+function getData() {
+ var data;
+
+ return query().then(function(result) {
+ data = result;
+ }).return(data);
+}
+```
+
+because `data` is `undefined` at the time `.return` is called.
+
+*For compatibility with earlier ECMAScript version, an alias `.thenReturn()` is provided for `.return()`.*
+
+<hr>
+
+#####`.throw(dynamic reason)` -> `Promise`
+
+Convenience method for:
+
+```js
+.then(function() {
+ throw reason;
+});
+```
+
+Same limitations apply as with `.return()`.
+
+*For compatibility with earlier ECMAScript version, an alias `.thenThrow()` is provided for `.throw()`.*
+
+<hr>
+
+#####`.toString()` -> `String`
+
+<hr>
+
+#####`.toJSON()` -> `Object`
+
+This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
+
+<hr>
+
+#####`Promise.noConflict()` -> `Object`
+
+This is relevant to browser environments with no module loader.
+
+Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else.
+
+```html
+<!-- the other promise library must be loaded first -->
+<script type="text/javascript" src="/scripts/other_promise.js"></script>
+<script type="text/javascript" src="/scripts/bluebird_debug.js"></script>
+<script type="text/javascript">
+//Release control right after
+var Bluebird = Promise.noConflict();
+
+//Cast a promise from some other Promise library using the Promise namespace to Bluebird:
+var promise = Bluebird.cast(new Promise());
+</script>
+```
+
+<hr>
+
+#####`Promise.onPossiblyUnhandledRejection(Function handler)` -> `undefined`
+
+Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
+
+```html
+Promise.onPossiblyUnhandledRejection(function(e, promise){
+ throw e;
+});
+```
+
+Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
+
+<hr>
+
+##Collections
+
+Methods of `Promise` instances and core static methods of the Promise class to deal with
+collections of promises or mixed promises and values.
+
+#####`.all()` -> `Promise`
+
+Same as calling [Promise.all\(thisPromise\)](#promiseallarraydynamicpromise-values---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+<hr>
+
+#####`.props()` -> `Promise`
+
+Same as calling [Promise.props\(thisPromise\)](#promisepropsobjectpromise-object---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+<hr>
+
+#####`.settle()` -> `Promise`
+
+Same as calling [Promise.settle\(thisPromise\)](#promisesettlearraydynamicpromise-values---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+<hr>
+
+#####`.any()` -> `Promise`
+
+Same as calling [Promise.any\(thisPromise\)](#promiseanyarraydynamicpromise-values---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+<hr>
+
+#####`.race()` -> `Promise`
+
+Same as calling [Promise.race\(thisPromise\)](#promiseracearraypromise-promises---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+<hr>
+
+
+#####`.some(int count)` -> `Promise`
+
+Same as calling [Promise.some\(thisPromise, count\)](#promisesomearraydynamicpromise-values-int-count---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+<hr>
+
+#####`.spread([Function fulfilledHandler] [, Function rejectedHandler ])` -> `Promise`
+
+Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
+
+```js
+Promise.all([task1, task2, task3]).spread(function(result1, result2, result3){
+
+});
+```
+
+Normally when using `.then` the code would be like:
+
+```js
+Promise.all([task1, task2, task3]).then(function(results){
+ var result1 = results[0];
+ var result2 = results[1];
+ var result3 = results[2];
+});
+```
+
+This is useful when the `results` array contains items that are not conceptually items of the same list.
+
+<hr>
+
+#####`.map(Function mapper)` -> `Promise`
+
+Same as calling [Promise.map\(thisPromise, mapper\)](#promisemaparraydynamicpromise-values-function-mapper---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+<hr>
+
+#####`.reduce(Function reducer [, dynamic initialValue])` -> `Promise`
+
+Same as calling [Promise.reduce\(thisPromise, Function reducer, initialValue\)](#promisereducearraydynamicpromise-values-function-reducer--dynamic-initialvalue---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+<hr>
+
+#####`.filter(Function filterer)` -> `Promise`
+
+Same as calling [`Promise.filter(thisPromise, filterer)`](#promisefilterarraydynamicpromise-values-function-filterer---promise). With the exception that if this promise is [bound](#binddynamic-thisarg---promise) to a value, the returned promise is bound to that value too.
+
+In this example, a list of websites are pinged with 100ms timeout. [`.settle()`](#settle---promise) is used to wait until all pings are either fulfilled or rejected. Then the settled
+list of [`PromiseInspections`](#inspect---promiseinspection) is filtered for those that fulfilled (responded in under 100ms) and [`mapped`](#promisemaparraydynamicpromise-values-function-mapper---promise) to the actual fulfillment value.
+
+```js
+pingWebsitesAsync({timeout: 100}).settle()
+.filter(function(inspection){
+ return inspection.isFulfilled();
+})
+.map(function(inspection){
+ return inspection.value();
+})
+.then(function(websites){
+ //List of website names which answered
+});
+```
+
+The above pattern is actually reusable and can be captured in a method:
+
+```js
+Promise.prototype.settledWithFulfill = function() {
+ return this.settle()
+ .filter(function(inspection){
+ return inspection.isFulfilled();
+ })
+ .map(function(inspection){
+ return inspection.value();
+ });
+};
+```
+
+<hr>
+
+#####`Promise.all(Array<dynamic>|Promise values)` -> `Promise`
+
+Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
+
+In this example we create a promise that is fulfilled only when the pictures, comments and tweets are all loaded.
+
+```js
+Promise.all([getPictures(), getComments(), getTweets()]).then(function(results){
+ //Everything loaded and good to go
+ var pictures = results[0];
+ var comments = results[1];
+ var tweets = results[2];
+}).catch(function(e){
+ alertAsync("error when getting your stuff");
+});
+```
+
+See [`.spread()`](#spreadfunction-fulfilledhandler--function-rejectedhandler----promise) for a more convenient way to extract the fulfillment values.
+
+*The original array is not modified. The input array sparsity is retained in the resulting array.*
+
+<hr>
+
+#####`Promise.props(Object|Promise object)` -> `Promise`
+
+Like [`Promise.all`](#promiseallarraydynamic-values---promise) but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
+
+If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
+
+```js
+Promise.props({
+ pictures: getPictures(),
+ comments: getComments(),
+ tweets: getTweets()
+}).then(function(result){
+ console.log(result.tweets, result.pictures, result.comments);
+});
+```
+
+Note that if you have no use for the result object other than retrieving the properties, it is more convenient to use [`Promise.all`](#promiseallarraydynamic-values---promise) and [`.spread()`](#spreadfunction-fulfilledhandler--function-rejectedhandler----promise):
+
+```js
+Promise.all([getPictures(), getComments(), getTweets()])
+.spread(function(pictures, comments, tweets) {
+ console.log(pictures, comments, tweets);
+});
+```
+
+*The original object is not modified.*
+
+<hr>
+
+#####`Promise.settle(Array<dynamic>|Promise values)` -> `Promise`
+
+Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of [`PromiseInspection`](#inspect---promiseinspection) instances at respective positions in relation to the input array.
+
+*The original array is not modified. The input array sparsity is retained in the resulting array.*
+
+<hr>
+
+#####`Promise.any(Array<dynamic>|Promise values)` -> `Promise`
+
+Like [`Promise.some\(\)`](#someint-count---promise), with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
+
+<hr>
+
+#####`Promise.race(Array|Promise promises)` -> `Promise`
+
+Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
+
+Example of implementing a timeout in terms of `Promise.race`:
+
+```js
+var Promise = require("bluebird");
+var fs = Promise.promisifyAll(require("fs"));
+
+function delay(ms) {
+ return new Promise(function (v) {
+ setTimeout(v, ms);
+ });
+}
+
+function timeout(promise, time) {
+ var timeout = delay(time).then(function () {
+ throw new Promise.TimeoutError("Operation timed out after " + time + " ms");
+ });
+
+ return Promise.race([promise, timeout]);
+}
+
+timeout(fs.readFileAsync("slowfile.txt"), 300).then(function (contents) {
+ console.log("Here are the contents", contents);
+}).
+catch(Promise.TimeoutError, function (e) {
+ console.error("Sorry retrieving file took too long");
+});
+```
+
+**Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
+
+<hr>
+
+#####`Promise.some(Array<dynamic>|Promise values, int count)` -> `Promise`
+
+Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
+
+This example pings 4 nameservers, and logs the fastest 2 on console:
+
+```js
+Promise.some([
+ ping("ns1.example.com"),
+ ping("ns2.example.com"),
+ ping("ns3.example.com"),
+ ping("ns4.example.com")
+], 2).spread(function(first, second) {
+ console.log(first, second);
+});
+```
+
+If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
+
+*The original array is not modified.*
+
+<hr>
+
+#####`Promise.join([dynamic value...])` -> `Promise`
+
+Like [`Promise.all\(\)`](#promiseallarraydynamic-values---promise) but instead of having to pass an array, the array is generated from the passed variadic arguments.
+
+So instead of:
+
+```js
+Promise.all([a, b]).spread(function(aResult, bResult) {
+
+});
+```
+
+You can do:
+
+```js
+Promise.join(a, b).spread(function(aResult, bResult) {
+
+});
+```
+
+<hr>
+
+#####`Promise.map(Array<dynamic>|Promise values, Function mapper)` -> `Promise`
+
+Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
+
+If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
+
+*(TODO: an example where this is useful)*
+
+*The original array is not modified.*
+
+<hr>
+
+#####`Promise.reduce(Array<dynamic>|Promise values, Function reducer [, dynamic initialValue])` -> `Promise`
+
+Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
+
+If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
+
+Read given files sequentially while summing their contents as an integer. Each file contains just the text `10`.
+
+```js
+Promise.reduce(["file1.txt", "file2.txt", "file3.txt"], function(total, fileName) {
+ return fs.readFileAsync(fileName, "utf8").then(function(contents) {
+ return total + parseInt(contents, 10);
+ });
+}, 0).then(function(total) {
+ //Total is 30
+});
+```
+
+*The original array is not modified. If `intialValue` is `undefined` (or a promise that resolves to `undefined`) and the array contains only 1 item, the callback will not be called and `undefined` is returned. If the array is empty, the callback will not be called and `initialValue` is returned (which may be `undefined`).*
+
+<hr>
+
+#####`Promise.filter(Array<dynamic>|Promise values, Function filterer)` -> `Promise`
+
+Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
+
+The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
+
+[See the instance method `.filter()` for an example.](#filterfunction-filterer---promise)
+
+*The original array is not modified.
+
+<hr>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/CONTRIBUTING.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/CONTRIBUTING.md
new file mode 100644
index 0000000..7042bcb
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/CONTRIBUTING.md
@@ -0,0 +1,68 @@
+# Contributing to bluebird
+
+1. [Directory structure](#directory-structure)
+2. [Style guide](#style-guide)
+3. [Scripts and macros](#scripts-and-macros)
+4. [JSHint](#jshint)
+5. [Testing](#testing)
+
+## Directory structure
+
+- `/benchmark` contains benchmark scripts and stats of benchmarks
+
+- `/browser` contains scripts and output for browser testing environment
+
+- `/js` contains automatically generated build output. **NOTE** never commit any changes to these files to git.
+
+ - `/js/browser` contains a file suitable for use in browsers
+ - `/js/main` contains the main build to be used with node. The npm package points to /js/main/bluebird.js
+ - `/js/debug` contains the debug build to be used with node. Used when running tests
+ - `/js/zalgo` contains the zalgo build not to be used by any mortals.
+
+- `/node_modules` contains development dependencies such as grunt
+
+- `/src` contains the source code
+
+- `/test/mocha` contains tests using the mocha testing framework
+
+## Scripts and macros
+
+Scripts and macros are necessary for the code the code to remain readable and performant. For example, there is no way to turn the `arguments` object into an array without using a build step macro unless you want to compromise readability or performance.
+
+`/ast_passes.js` contains functions called ast passes that will parse input source code into an AST, modify it in some way and spit out new source code with the changes reflected.
+
+`/src/constants.js` contains declarations for constants that will be inlined in the resulting code during in the build step. JavaScript lacks a way to express constants, particularly if you are expecting the performance implications.
+
+`/Gruntfile.js` contains task definitions to be used with the Grunt build framework. It for example sets up source code transformations.
+
+`/bench` a bash script to run benchmarks.
+
+`/mocharun.js` a hack script to make mocha work when running multiple tests in parallel processes
+
+## JSHint
+
+Due to JSHint globals being dynamic, the JSHint rules are declared in `/Gruntfile.js`.
+
+## Style guide
+
+Use the same style as is used in the surrounding code.
+
+###Whitespace
+
+- No more than 80 columns per line
+- 4 space indentation
+- No trailing whitespace
+- LF at end of files
+- Curly braces can be left out of single statement `if/else/else if`s when it is obvious there will never be multiple statements such as null check at the top of a function for an early return.
+- Add an additional new line between logical sections of code.
+
+###Variables
+
+- Use multiple `var` statements instead of a single one with comma separator. Do not declare variables until you need them.
+
+###Equality and type checks
+
+- Always use `===` except when checking for null or undefined. To check for null or undefined, use `x == null`.
+- For checks that can be done with `typeof`: do not make helper functions, save results of `typeof` to a variable or make the type string a non-constant. Always write the check in the form `typeof expression === "constant string"` even if it feels like repeating yourself.
+
+## Testing
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[24/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/Gruntfile.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/Gruntfile.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/Gruntfile.js
new file mode 100644
index 0000000..77fc162
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/Gruntfile.js
@@ -0,0 +1,725 @@
+"use strict";
+Error.stackTraceLimit = 100;
+var astPasses = require("./ast_passes.js");
+var node11 = parseInt(process.versions.node.split(".")[1], 10) >= 11;
+var Q = require("q");
+Q.longStackSupport = true;
+
+module.exports = function( grunt ) {
+ var isCI = !!grunt.option("ci");
+
+
+ function getBrowsers() {
+ //Terse format to generate the verbose format required by sauce
+ var browsers = {
+ "internet explorer|WIN8": ["10"],
+ "internet explorer|WIN8.1": ["11"],
+ "firefox|Windows 7": ["3.5", "3.6", "4", "25"],
+ "firefox|WIN8.1": null,
+ "chrome|Windows 7": null,
+ "safari|Windows 7": ["5"],
+ "iphone|OS X 10.8": ["6.0"]
+ };
+
+ var ret = [];
+ for( var browserAndPlatform in browsers) {
+ var split = browserAndPlatform.split("|");
+ var browser = split[0];
+ var platform = split[1];
+ var versions = browsers[browserAndPlatform];
+ if( versions != null ) {
+ for( var i = 0, len = versions.length; i < len; ++i ) {
+ ret.push({
+ browserName: browser,
+ platform: platform,
+ version: versions[i]
+ });
+ }
+ }
+ else {
+ ret.push({
+ browserName: browser,
+ platform: platform
+ });
+ }
+ }
+ return ret;
+ }
+
+
+ var optionalModuleDependencyMap = {
+ "timers.js": ['Promise', 'INTERNAL'],
+ "any.js": ['Promise', 'Promise$_CreatePromiseArray', 'PromiseArray'],
+ "race.js": ['Promise', 'INTERNAL'],
+ "call_get.js": ['Promise'],
+ "filter.js": ['Promise', 'Promise$_CreatePromiseArray', 'PromiseArray', 'apiRejection'],
+ "generators.js": ['Promise', 'apiRejection', 'INTERNAL'],
+ "map.js": ['Promise', 'Promise$_CreatePromiseArray', 'PromiseArray', 'apiRejection'],
+ "nodeify.js": ['Promise'],
+ "promisify.js": ['Promise', 'INTERNAL'],
+ "props.js": ['Promise', 'PromiseArray'],
+ "reduce.js": ['Promise', 'Promise$_CreatePromiseArray', 'PromiseArray', 'apiRejection', 'INTERNAL'],
+ "settle.js": ['Promise', 'Promise$_CreatePromiseArray', 'PromiseArray'],
+ "some.js": ['Promise', 'Promise$_CreatePromiseArray', 'PromiseArray', 'apiRejection'],
+ "progress.js": ['Promise', 'isPromiseArrayProxy'],
+ "cancel.js": ['Promise', 'INTERNAL'],
+ "synchronous_inspection.js": ['Promise']
+
+ };
+
+ var optionalModuleRequireMap = {
+ "timers.js": true,
+ "race.js": true,
+ "any.js": true,
+ "call_get.js": true,
+ "filter.js": true,
+ "generators.js": true,
+ "map.js": true,
+ "nodeify.js": true,
+ "promisify.js": true,
+ "props.js": true,
+ "reduce.js": true,
+ "settle.js": true,
+ "some.js": true,
+ "progress.js": true,
+ "cancel.js": true,
+ "synchronous_inspection.js": true
+
+ };
+
+ function getOptionalRequireCode( srcs ) {
+ return srcs.reduce(function(ret, cur, i){
+ if( optionalModuleRequireMap[cur] ) {
+ ret += "require('./"+cur+"')("+ optionalModuleDependencyMap[cur] +");\n";
+ }
+ return ret;
+ }, "") + "\nPromise.prototype = Promise.prototype;\nreturn Promise;\n";
+ }
+
+ function getBrowserBuildHeader( sources ) {
+ var header = "/**\n * bluebird build version " + gruntConfig.pkg.version + "\n";
+ var enabledFeatures = ["core"];
+ var disabledFeatures = [];
+ featureLoop: for( var key in optionalModuleRequireMap ) {
+ for( var i = 0, len = sources.length; i < len; ++i ) {
+ var source = sources[i];
+ if( source.fileName === key ) {
+ enabledFeatures.push( key.replace( ".js", "") );
+ continue featureLoop;
+ }
+ }
+ disabledFeatures.push( key.replace( ".js", "") );
+ }
+
+ header += ( " * Features enabled: " + enabledFeatures.join(", ") + "\n" );
+
+ if( disabledFeatures.length ) {
+ header += " * Features disabled: " + disabledFeatures.join(", ") + "\n";
+ }
+ header += "*/\n";
+ return header;
+ }
+
+ function applyOptionalRequires( src, optionalRequireCode ) {
+ return src.replace( /};([^}]*)$/, optionalRequireCode + "\n};$1");
+ }
+
+ var CONSTANTS_FILE = './src/constants.js';
+ var BUILD_DEBUG_DEST = "./js/debug/bluebird.js";
+
+ var license;
+ function getLicense() {
+ if( !license ) {
+ var fs = require("fs");
+ var text = fs.readFileSync("LICENSE", "utf8");
+ text = text.split("\n").map(function(line, index){
+ return " * " + line;
+ }).join("\n")
+ license = "/**\n" + text + "\n */\n";
+ }
+ return license
+ }
+
+ var preserved;
+ function getLicensePreserve() {
+ if( !preserved ) {
+ var fs = require("fs");
+ var text = fs.readFileSync("LICENSE", "utf8");
+ text = text.split("\n").map(function(line, index){
+ if( index === 0 ) {
+ return " * @preserve " + line;
+ }
+ return " * " + line;
+ }).join("\n")
+ preserved = "/**\n" + text + "\n */\n";
+ }
+ return preserved;
+ }
+
+ function writeFile( dest, content ) {
+ grunt.file.write( dest, content );
+ grunt.log.writeln('File "' + dest + '" created.');
+ }
+
+ function writeFileAsync( dest, content ) {
+ var fs = require("fs");
+ return Q.nfcall(fs.writeFile, dest, content).then(function(){
+ grunt.log.writeln('File "' + dest + '" created.');
+ });
+ }
+
+ var gruntConfig = {};
+
+ var getGlobals = function() {
+ var fs = require("fs");
+ var file = "./src/constants.js";
+ var contents = fs.readFileSync(file, "utf8");
+ var rconstantname = /CONSTANT\(\s*([^,]+)/g;
+ var m;
+ var globals = {
+ Error: true,
+ args: true,
+ INLINE_SLICE: false,
+ TypeError: true,
+ RangeError: true,
+ __DEBUG__: false,
+ __BROWSER__: false,
+ process: true,
+ "console": false,
+ "require": false,
+ "module": false,
+ "define": false
+ };
+ while( ( m = rconstantname.exec( contents ) ) ) {
+ globals[m[1]] = false;
+ }
+ return globals;
+ }
+
+ gruntConfig.pkg = grunt.file.readJSON("package.json");
+
+ gruntConfig.jshint = {
+ all: {
+ options: {
+ globals: getGlobals(),
+
+ "bitwise": false,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "es3": true,
+ "forin": true,
+ "immed": true,
+ "latedef": false,
+ "newcap": true,
+ "noarg": true,
+ "noempty": true,
+ "nonew": true,
+ "plusplus": false,
+ "quotmark": "double",
+ "undef": true,
+ "unused": true,
+ "strict": false,
+ "trailing": true,
+ "maxparams": 6,
+ "maxlen": 80,
+
+ "asi": false,
+ "boss": true,
+ "eqnull": true,
+ "evil": true,
+ "expr": false,
+ "funcscope": false,
+ "globalstrict": false,
+ "lastsemic": false,
+ "laxcomma": false,
+ "laxbreak": false,
+ "loopfunc": true,
+ "multistr": true,
+ "proto": false,
+ "scripturl": true,
+ "smarttabs": false,
+ "shadow": true,
+ "sub": true,
+ "supernew": false,
+ "validthis": true,
+
+ "browser": true,
+ "jquery": true,
+ "devel": true,
+
+
+ '-W014': true,
+ '-W116': true,
+ '-W106': true,
+ '-W064': true,
+ '-W097': true
+ },
+
+ files: {
+ src: [
+ "./src/finally.js",
+ "./src/direct_resolve.js",
+ "./src/synchronous_inspection.js",
+ "./src/thenables.js",
+ "./src/progress.js",
+ "./src/cancel.js",
+ "./src/any.js",
+ "./src/race.js",
+ "./src/call_get.js",
+ "./src/filter.js",
+ "./src/generators.js",
+ "./src/map.js",
+ "./src/nodeify.js",
+ "./src/promisify.js",
+ "./src/props.js",
+ "./src/reduce.js",
+ "./src/settle.js",
+ "./src/some.js",
+ "./src/util.js",
+ "./src/schedule.js",
+ "./src/queue.js",
+ "./src/errors.js",
+ "./src/captured_trace.js",
+ "./src/async.js",
+ "./src/catch_filter.js",
+ "./src/promise.js",
+ "./src/promise_array.js",
+ "./src/settled_promise_array.js",
+ "./src/some_promise_array.js",
+ "./src/properties_promise_array.js",
+ "./src/promise_inspection.js",
+ "./src/promise_resolver.js",
+ "./src/promise_spawn.js"
+ ]
+ }
+ }
+ };
+
+ if( !isCI ) {
+ gruntConfig.jshint.all.options.reporter = require("jshint-stylish");
+ }
+
+ gruntConfig.connect = {
+ server: {
+ options: {
+ base: "./browser",
+ port: 9999
+ }
+ }
+ };
+
+ gruntConfig.watch = {};
+
+ gruntConfig["saucelabs-mocha"] = {
+ all: {
+ options: {
+ urls: ["http://127.0.0.1:9999/index.html"],
+ tunnelTimeout: 5,
+ build: process.env.TRAVIS_JOB_ID,
+ concurrency: 3,
+ browsers: getBrowsers(),
+ testname: "mocha tests",
+ tags: ["master"]
+ }
+ }
+ };
+
+ gruntConfig.bump = {
+ options: {
+ files: ['package.json'],
+ updateConfigs: [],
+ commit: true,
+ commitMessage: 'Release v%VERSION%',
+ commitFiles: ['-a'],
+ createTag: true,
+ tagName: 'v%VERSION%',
+ tagMessage: 'Version %VERSION%',
+ false: true,
+ pushTo: 'master',
+ gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
+ }
+ };
+
+ grunt.initConfig(gruntConfig);
+ grunt.loadNpmTasks("grunt-contrib-connect");
+ grunt.loadNpmTasks("grunt-saucelabs");
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-watch');
+ grunt.loadNpmTasks('grunt-contrib-concat');
+
+ function runIndependentTest( file, cb , env) {
+ var fs = require("fs");
+ var path = require("path");
+ var sys = require('sys');
+ var spawn = require('child_process').spawn;
+ var p = path.join(process.cwd(), "test");
+
+ var stdio = [
+ 'ignore',
+ grunt.option("verbose")
+ ? process.stdout
+ : 'ignore',
+ process.stderr
+ ];
+ var flags = node11 ? ["--harmony-generators"] : [];
+ flags.push("--allow-natives-syntax");
+ if( file.indexOf( "mocha/") > -1 || file === "aplus.js" ) {
+ var node = spawn(typeof node11 === "string" ? node11 : 'node',
+ flags.concat(["../mocharun.js", file]),
+ {cwd: p, stdio: stdio, env: env});
+ }
+ else {
+ var node = spawn('node', flags.concat(["./"+file]),
+ {cwd: p, stdio: stdio, env:env});
+ }
+ node.on('exit', exit );
+
+ function exit( code ) {
+ if( code !== 0 ) {
+ cb(new Error("process didn't exit normally. Code: " + code));
+ }
+ else {
+ cb(null);
+ }
+ }
+
+
+ }
+
+ function buildMain( sources, optionalRequireCode ) {
+ var fs = require("fs");
+ var Q = require("q");
+ var root = cleanDirectory("./js/main/");
+
+ return Q.all(sources.map(function( source ) {
+ var src = astPasses.removeAsserts( source.sourceCode, source.fileName );
+ src = astPasses.inlineExpansion( src, source.fileName );
+ src = astPasses.expandConstants( src, source.fileName );
+ src = src.replace( /__DEBUG__/g, "false" );
+ src = src.replace( /__BROWSER__/g, "false" );
+ if( source.fileName === "promise.js" ) {
+ src = applyOptionalRequires( src, optionalRequireCode );
+ }
+ var path = root + source.fileName;
+ return writeFileAsync(path, src);
+ }));
+ }
+
+ function buildDebug( sources, optionalRequireCode ) {
+ var fs = require("fs");
+ var Q = require("q");
+ var root = cleanDirectory("./js/debug/");
+
+ return Q.nfcall(require('mkdirp'), root).then(function(){
+ return Q.all(sources.map(function( source ) {
+ var src = astPasses.expandAsserts( source.sourceCode, source.fileName );
+ src = astPasses.inlineExpansion( src, source.fileName );
+ src = astPasses.expandConstants( src, source.fileName );
+ src = src.replace( /__DEBUG__/g, "true" );
+ src = src.replace( /__BROWSER__/g, "false" );
+ if( source.fileName === "promise.js" ) {
+ src = applyOptionalRequires( src, optionalRequireCode );
+ }
+ var path = root + source.fileName;
+ return writeFileAsync(path, src);
+ }));
+ });
+ }
+
+ function buildZalgo( sources, optionalRequireCode ) {
+ var fs = require("fs");
+ var Q = require("q");
+ var root = cleanDirectory("./js/zalgo/");
+
+ return Q.all(sources.map(function( source ) {
+ var src = astPasses.removeAsserts( source.sourceCode, source.fileName );
+ src = astPasses.inlineExpansion( src, source.fileName );
+ src = astPasses.expandConstants( src, source.fileName );
+ src = astPasses.asyncConvert( src, "async", "invoke", source.fileName);
+ src = src.replace( /__DEBUG__/g, "false" );
+ src = src.replace( /__BROWSER__/g, "false" );
+ if( source.fileName === "promise.js" ) {
+ src = applyOptionalRequires( src, optionalRequireCode );
+ }
+ var path = root + source.fileName;
+ return writeFileAsync(path, src);
+ }));
+ }
+
+ function buildBrowser( sources ) {
+ var fs = require("fs");
+ var browserify = require("browserify");
+ var b = browserify("./js/main/bluebird.js");
+ var dest = "./js/browser/bluebird.js";
+
+ var header = getBrowserBuildHeader( sources );
+
+ return Q.nbind(b.bundle, b)({
+ detectGlobals: false,
+ standalone: "Promise"
+ }).then(function(src) {
+ return writeFileAsync( dest,
+ getLicensePreserve() + src )
+ }).then(function() {
+ return Q.nfcall(fs.readFile, dest, "utf8" );
+ }).then(function( src ) {
+ src = header + src;
+ return Q.nfcall(fs.writeFile, dest, src );
+ });
+ }
+
+ function cleanDirectory(dir) {
+ if (isCI) return dir;
+ var fs = require("fs");
+ require("rimraf").sync(dir);
+ fs.mkdirSync(dir);
+ return dir;
+ }
+
+ function getOptionalPathsFromOption( opt ) {
+ opt = (opt + "").toLowerCase().split(/\s+/g);
+ return optionalPaths.filter(function(v){
+ v = v.replace("./src/", "").replace( ".js", "" ).toLowerCase();
+ return opt.indexOf(v) > -1;
+ });
+ }
+
+ var optionalPaths = [
+ "./src/timers.js",
+ "./src/synchronous_inspection.js",
+ "./src/any.js",
+ "./src/race.js",
+ "./src/call_get.js",
+ "./src/filter.js",
+ "./src/generators.js",
+ "./src/map.js",
+ "./src/nodeify.js",
+ "./src/promisify.js",
+ "./src/props.js",
+ "./src/reduce.js",
+ "./src/settle.js",
+ "./src/some.js",
+ "./src/progress.js",
+ "./src/cancel.js"
+ ];
+
+ var mandatoryPaths = [
+ "./src/finally.js",
+ "./src/es5.js",
+ "./src/bluebird.js",
+ "./src/thenables.js",
+ "./src/assert.js",
+ "./src/global.js",
+ "./src/util.js",
+ "./src/schedule.js",
+ "./src/queue.js",
+ "./src/errors.js",
+ "./src/errors_api_rejection.js",
+ "./src/captured_trace.js",
+ "./src/async.js",
+ "./src/catch_filter.js",
+ "./src/promise.js",
+ "./src/promise_array.js",
+ "./src/settled_promise_array.js",
+ "./src/some_promise_array.js",
+ "./src/properties_promise_array.js",
+ "./src/promise_inspection.js",
+ "./src/promise_resolver.js",
+ "./src/promise_spawn.js",
+ "./src/direct_resolve.js"
+ ];
+
+
+
+ function build( paths, isCI ) {
+ var fs = require("fs");
+ astPasses.readConstants(fs.readFileSync(CONSTANTS_FILE, "utf8"), CONSTANTS_FILE);
+ if( !paths ) {
+ paths = optionalPaths.concat(mandatoryPaths);
+ }
+ var optionalRequireCode = getOptionalRequireCode(paths.map(function(v) {
+ return v.replace("./src/", "");
+ }));
+
+ var Q = require("q");
+
+ var promises = [];
+ var sources = paths.map(function(v){
+ var promise = Q.nfcall(fs.readFile, v, "utf8");
+ promises.push(promise);
+ var ret = {};
+
+ ret.fileName = v.replace("./src/", "");
+ ret.sourceCode = promise.then(function(v){
+ ret.sourceCode = v;
+ });
+ return ret;
+ });
+
+ //Perform common AST passes on all builds
+ return Q.all(promises.slice()).then(function(){
+ sources.forEach( function( source ) {
+ var src = source.sourceCode
+ src = astPasses.removeComments(src, source.fileName);
+ src = getLicense() + src;
+ source.sourceCode = src;
+ });
+
+ if( isCI ) {
+ return buildDebug( sources, optionalRequireCode );
+ }
+ else {
+ return Q.all([
+ buildMain( sources, optionalRequireCode ).then( function() {
+ return buildBrowser( sources );
+ }),
+ buildDebug( sources, optionalRequireCode ),
+ buildZalgo( sources, optionalRequireCode )
+ ]);
+ }
+ });
+ }
+
+ String.prototype.contains = function String$contains( str ) {
+ return this.indexOf( str ) >= 0;
+ };
+
+ function isSlowTest( file ) {
+ return file.contains("2.3.3") ||
+ file.contains("bind") ||
+ file.contains("unhandled_rejections");
+ }
+
+ function testRun( testOption ) {
+ var fs = require("fs");
+ var path = require("path");
+ var done = this.async();
+
+ var totalTests = 0;
+ var testsDone = 0;
+ function testDone() {
+ testsDone++;
+ if( testsDone >= totalTests ) {
+ done();
+ }
+ }
+ var files;
+ if( testOption === "aplus" ) {
+ files = fs.readdirSync("test/mocha").filter(function(f){
+ return /^\d+\.\d+\.\d+/.test(f);
+ }).map(function( f ){
+ return "mocha/" + f;
+ });
+ }
+ else {
+ files = testOption === "all"
+ ? fs.readdirSync('test')
+ .concat(fs.readdirSync('test/mocha')
+ .map(function(fileName){
+ return "mocha/" + fileName
+ })
+ )
+ : [testOption + ".js" ];
+
+
+ if( testOption !== "all" &&
+ !fs.existsSync( "./test/" + files[0] ) ) {
+ files[0] = "mocha/" + files[0];
+ }
+ }
+ files = files.filter(function(fileName){
+ if( !node11 && fileName.indexOf("generator") > -1 ) {
+ return false;
+ }
+ return /\.js$/.test(fileName);
+ }).map(function(f){
+ return f.replace( /(\d)(\d)(\d)/, "$1.$2.$3" );
+ });
+
+
+ var slowTests = files.filter(isSlowTest);
+ files = files.filter(function(file){
+ return !isSlowTest(file);
+ });
+
+ function runFile(file) {
+ totalTests++;
+ grunt.log.writeln("Running test " + file );
+ var env = undefined;
+ if (file.indexOf("bluebird-debug-env-flag") >= 0) {
+ env = Object.create(process.env);
+ env["BLUEBIRD_DEBUG"] = true;
+ }
+ runIndependentTest(file, function(err) {
+ if( err ) throw new Error(err + " " + file + " failed");
+ grunt.log.writeln("Test " + file + " succeeded");
+ testDone();
+ if( files.length > 0 ) {
+ runFile( files.shift() );
+ }
+ }, env);
+ }
+
+ slowTests.forEach(runFile);
+
+ var maxParallelProcesses = 10;
+ var len = Math.min( files.length, maxParallelProcesses );
+ for( var i = 0; i < len; ++i ) {
+ runFile( files.shift() );
+ }
+ }
+
+ grunt.registerTask( "build", function() {
+
+ var done = this.async();
+ var features = grunt.option("features");
+ var paths = null;
+ if( features ) {
+ paths = getOptionalPathsFromOption( features ).concat( mandatoryPaths );
+ }
+
+ build( paths, isCI ).then(function() {
+ done();
+ }).catch(function(e) {
+ if( e.fileName && e.stack ) {
+ console.log(e.scriptSrc);
+ var stack = e.stack.split("\n");
+ stack[0] = stack[0] + " " + e.fileName;
+ console.error(stack.join("\n"));
+ if (!grunt.option("verbose")) {
+ console.error("use --verbose to see the source code");
+ }
+
+ }
+ else {
+ console.error(e.stack);
+ }
+ done(false);
+ });
+ });
+
+ grunt.registerTask( "testrun", function(){
+ var testOption = grunt.option("run");
+ var node11path = grunt.option("node11");
+
+ if (typeof node11path === "string" && node11path) {
+ node11 = node11path;
+ }
+
+ if( !testOption ) testOption = "all";
+ else {
+ testOption = ("" + testOption);
+ testOption = testOption
+ .replace( /\.js$/, "" )
+ .replace( /[^a-zA-Z0-9_-]/g, "" );
+ }
+ testRun.call( this, testOption );
+ });
+
+ grunt.registerTask( "test", ["jshint", "build", "testrun"] );
+ grunt.registerTask( "test-browser", ["connect", "saucelabs-mocha"]);
+ grunt.registerTask( "default", ["jshint", "build"] );
+ grunt.registerTask( "dev", ["connect", "watch"] );
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/LICENSE b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/LICENSE
new file mode 100644
index 0000000..9ed7b98
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2014 Petka Antonov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:</p>
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/README.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/README.md
new file mode 100644
index 0000000..7d4d1ae
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/README.md
@@ -0,0 +1,696 @@
+[](https://travis-ci.org/petkaantonov/bluebird)
+
+<a href="http://promisesaplus.com/">
+ <img src="http://promisesaplus.com/assets/logo-small.png" alt="Promises/A+ logo"
+ title="Promises/A+ 1.0 compliant" align="right" />
+</a>
+
+#Introduction
+
+Bluebird is a fully featured [promise](#what-are-promises-and-why-should-i-use-them) library with focus on innovative features and performance
+
+#Topics
+
+- [Features](#features)
+- [Quick start](#quick-start)
+- [API Reference and examples](https://github.com/petkaantonov/bluebird/blob/master/API.md)
+- [What are promises and why should I use them?](#what-are-promises-and-why-should-i-use-them)
+- [Questions and issues](#questions-and-issues)
+- [Error handling](#error-handling)
+- [Development](#development)
+ - [Testing](#testing)
+ - [Benchmarking](#benchmarks)
+ - [Custom builds](#custom-builds)
+ - [For library authors](#for-library-authors)
+- [What is the sync build?](#what-is-the-sync-build)
+- [License](#license)
+- [Snippets for common problems](https://github.com/petkaantonov/bluebird/wiki/Snippets)
+- [Promise anti-patterns](https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns)
+- [Changelog](https://github.com/petkaantonov/bluebird/blob/master/changelog.md)
+- [Optimization guide](#optimization-guide)
+
+#Features:
+
+- [Promises A+ 2.0.2](http://promisesaplus.com)
+- [Cancellation](https://github.com/promises-aplus)
+- [Progression](https://github.com/promises-aplus/progress-spec)
+- [Synchronous inspection](https://github.com/promises-aplus/synchronous-inspection-spec)
+- [`.bind`](https://github.com/petkaantonov/bluebird/blob/master/API.md#binddynamic-thisarg---promise)
+- [Complete parallel for C# 5.0 async and await](https://github.com/petkaantonov/bluebird/blob/master/API.md#promisecoroutinegeneratorfunction-generatorfunction---function)
+- [Collection methods](https://github.com/petkaantonov/bluebird/blob/master/API.md#collections) such as All, any, some, settle, map, filter, reduce, spread, join, race...
+- [Practical debugging solutions](#error-handling) such as unhandled rejection reporting, typed catches, catching only what you expect and very long, relevant stack traces without losing perf
+- [Sick performance](https://github.com/petkaantonov/bluebird/tree/master/benchmark/stats)
+
+Passes [AP2](https://github.com/petkaantonov/bluebird/tree/master/test/mocha), [AP3](https://github.com/petkaantonov/bluebird/tree/master/test/mocha), [Cancellation](https://github.com/petkaantonov/bluebird/blob/master/test/mocha/cancel.js), [Progress](https://github.com/petkaantonov/bluebird/blob/master/test/mocha/q_progress.js) tests and more. See [testing](#testing).
+
+<hr>
+
+#Quick start
+
+##Node.js
+
+ npm install bluebird
+
+Then:
+
+```js
+var Promise = require("bluebird");
+```
+
+##Browsers
+
+Download the [bluebird.js](https://github.com/petkaantonov/bluebird/tree/master/js/browser) file. And then use a script tag:
+
+```html
+<script type="text/javascript" src="/scripts/bluebird.js"></script>
+```
+
+The global variable `Promise` becomes available after the above script tag.
+
+####Browser support
+
+Browsers that [implement ECMA-262, edition 3](http://en.wikipedia.org/wiki/Ecmascript#Implementations) and later are supported.
+
+[](https://saucelabs.com/u/petka_antonov)
+
+*IE7 and IE8 had to be removed from tests due to SauceLabs bug but are supported and pass all tests*
+
+**Note** that in ECMA-262, edition 3 (IE7, IE8 etc) it is not possible to use methods that have keyword names like `.catch` and `.finally`. The [API documentation](https://github.com/petkaantonov/bluebird/blob/master/API.md) always lists a compatible alternative name that you can use if you need to support these browsers. For example `.catch` is replaced with `.caught` and `.finally` with `.lastly`.
+
+Also, [long stack trace](https://github.com/petkaantonov/bluebird/blob/master/API.md#promiselongstacktraces---void) support is only available in Chrome and Firefox.
+
+<sub>Previously bluebird required es5-shim.js and es5-sham.js to support Edition 3 - these are **no longer required** as of **0.10.4**.</sub>
+
+After quick start, see [API Reference and examples](https://github.com/petkaantonov/bluebird/blob/master/API.md)
+
+<hr>
+
+#What are promises and why should I use them?
+
+You should use promises to turn this:
+
+```js
+readFile("file.json", function(err, val) {
+ if( err ) {
+ console.error("unable to read file");
+ }
+ else {
+ try {
+ val = JSON.parse(val);
+ console.log(val.success);
+ }
+ catch( e ) {
+ console.error("invalid json in file");
+ }
+ }
+});
+```
+
+Into this:
+
+```js
+readFile("file.json").then(JSON.parse).then(function(val) {
+ console.log(val.success);
+})
+.catch(SyntaxError, function(e) {
+ console.error("invalid json in file");
+})
+.catch(function(e){
+ console.error("unable to read file")
+});
+```
+
+Actually you might notice the latter has a lot in common with code that would do the same using synchronous I/O:
+
+```js
+try {
+ var val = JSON.parse(readFile("file.json"));
+ console.log(val.success);
+}
+//Syntax actually not supported in JS but drives the point
+catch(SyntaxError e) {
+ console.error("invalid json in file");
+}
+catch(Error e) {
+ console.error("unable to read file")
+}
+```
+
+And that is the point - being able to have something that is a lot like `return` and `throw` in synchronous code.
+
+You can also use promises to improve code that was written with callback helpers:
+
+
+```js
+//Copyright Plato http://stackoverflow.com/a/19385911/995876
+//CC BY-SA 2.5
+mapSeries(URLs, function (URL, done) {
+ var options = {};
+ needle.get(URL, options, function (error, response, body) {
+ if (error) {
+ return done(error)
+ }
+ try {
+ var ret = JSON.parse(body);
+ return done(null, ret);
+ }
+ catch (e) {
+ done(e);
+ }
+ });
+}, function (err, results) {
+ if (err) {
+ console.log(err)
+ } else {
+ console.log('All Needle requests successful');
+ // results is a 1 to 1 mapping in order of URLs > needle.body
+ processAndSaveAllInDB(results, function (err) {
+ if (err) {
+ return done(err)
+ }
+ console.log('All Needle requests saved');
+ done(null);
+ });
+ }
+});
+```
+
+Is more pleasing to the eye when done with promises:
+
+```js
+Promise.promisifyAll(needle);
+var options = {};
+
+var current = Promise.resolve();
+Promise.map(URLs, function(URL) {
+ current = current.then(function () {
+ return needle.getAsync(URL, options);
+ });
+ return current;
+}).map(function(responseAndBody){
+ return JSON.parse(responseAndBody[1]);
+}).then(function (results) {
+ return processAndSaveAllInDB(results);
+}).then(function(){
+ console.log('All Needle requests saved');
+}).catch(function (e) {
+ console.log(e);
+});
+```
+
+Also promises don't just give you correspondences for synchronous features but can also be used as limited event emitters or callback aggregators.
+
+More reading:
+
+ - [Promise nuggets](http://spion.github.io/promise-nuggets/)
+ - [Why I am switching to promises](http://spion.github.io/posts/why-i-am-switching-to-promises.html)
+ - [What is the the point of promises](http://domenic.me/2012/10/14/youre-missing-the-point-of-promises/#toc_1)
+ - [Snippets for common problems](https://github.com/petkaantonov/bluebird/wiki/Snippets)
+ - [Promise anti-patterns](https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns)
+
+#Questions and issues
+
+If you find a bug in bluebird or have a feature request, file an issue in the [github issue tracker](https://github.com/petkaantonov/bluebird/issues). Anything else, such as questions for help in using the library, should be posted in [StackOverflow](http://stackoverflow.com/questions/tagged/bluebird) under tags `promise` and `bluebird`.
+
+#Error handling
+
+This is a problem every promise library needs to handle in some way. Unhandled rejections/exceptions don't really have a good agreed-on asynchronous correspondence. The problem is that it is impossible to predict the future and know if a rejected promise will eventually be handled.
+
+There are two common pragmatic attempts at solving the problem that promise libraries do.
+
+The more popular one is to have the user explicitly communicate that they are done and any unhandled rejections should be thrown, like so:
+
+```js
+download().then(...).then(...).done();
+```
+
+For handling this problem, in my opinion, this is completely unacceptable and pointless. The user must remember to explicitly call `.done` and that cannot be justified when the problem is forgetting to create an error handler in the first place.
+
+The second approach, which is what bluebird by default takes, is to call a registered handler if a rejection is unhandled by the start of a second turn. The default handler is to write the stack trace to stderr or `console.error` in browsers. This is close to what happens with synchronous code - your code doens't work as expected and you open console and see a stack trace. Nice.
+
+Of course this is not perfect, if your code for some reason needs to swoop in and attach error handler to some promise after the promise has been hanging around a while then you will see annoying messages. In that case you can use the `.done()` method to signal that any hanging exceptions should be thrown.
+
+If you want to override the default handler for these possibly unhandled rejections, you can pass yours like so:
+
+```js
+Promise.onPossiblyUnhandledRejection(function(error){
+ throw error;
+});
+```
+
+If you want to also enable long stack traces, call:
+
+```js
+Promise.longStackTraces();
+```
+
+right after the library is loaded.
+
+In node.js use the environment flag `BLUEBIRD_DEBUG`:
+
+```
+BLUEBIRD_DEBUG=1 node server.js
+```
+
+to enable long stack traces in all instances of bluebird.
+
+Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, even after using every trick to optimize them.
+
+Long stack traces are enabled by default in the debug build.
+
+####Expected and unexpected errors
+
+A practical problem with Promises/A+ is that it models Javascript `try-catch` too closely for its own good. Therefore by default promises inherit `try-catch` warts such as the inability to specify the error types that the catch block is eligible for. It is an anti-pattern in every other language to use catch-all handlers because they swallow exceptions that you might not know about.
+
+Now, Javascript does have a perfectly fine and working way of creating error type hierarchies. It is still quite awkward to use them with the built-in `try-catch` however:
+
+```js
+try {
+ //code
+}
+catch(e) {
+ if( e instanceof WhatIWantError) {
+ //handle
+ }
+ else {
+ throw e;
+ }
+}
+```
+
+Without such checking, unexpected errors would be silently swallowed. However, with promises, bluebird brings the future (hopefully) here now and extends the `.catch` to [accept potential error type eligibility](https://github.com/petkaantonov/bluebird/blob/master/API.md#catchfunction-errorclass-function-handler---promise).
+
+For instance here it is expected that some evil or incompetent entity will try to crash our server from `SyntaxError` by providing syntactically invalid JSON:
+
+```js
+getJSONFromSomewhere().then(function(jsonString) {
+ return JSON.parse(jsonString);
+}).then(function(object) {
+ console.log("it was valid json: ", object);
+}).catch(SyntaxError, function(e){
+ console.log("don't be evil");
+});
+```
+
+Here any kind of unexpected error will automatically reported on stderr along with a stack trace because we only register a handler for the expected `SyntaxError`.
+
+Ok, so, that's pretty neat. But actually not many libraries define error types and it is in fact a complete ghetto out there with ad hoc strings being attached as some arbitrary property name like `.name`, `.type`, `.code`, not having any property at all or even throwing strings as errors and so on. So how can we still listen for expected errors?
+
+Bluebird defines a special error type `RejectionError` (you can get a reference from `Promise.RejectionError`). This type of error is given as rejection reason by promisified methods when
+their underlying library gives an untyped, but expected error. Primitives such as strings, and error objects that are directly created like `new Error("database didn't respond")` are considered untyped.
+
+Example of such library is the node core library `fs`. So if we promisify it, we can catch just the errors we want pretty easily and have programmer errors be redirected to unhandled rejection handler so that we notice them:
+
+```js
+//Read more about promisification in the API Reference:
+//https://github.com/petkaantonov/bluebird/blob/master/API.md
+var fs = Promise.promisifyAll(require("fs"));
+
+fs.readFileAsync("myfile.json").then(JSON.parse).then(function (json) {
+ console.log("Successful json")
+}).catch(SyntaxError, function (e) {
+ console.error("file contains invalid json");
+}).catch(Promise.RejectionError, function (e) {
+ console.error("unable to read file, because: ", e.message);
+});
+```
+
+The last `catch` handler is only invoked when the `fs` module explicitly used the `err` argument convention of async callbacks to inform of an expected error. The `RejectionError` instance will contain the original error in its `.cause` property but it does have a direct copy of the `.message` and `.stack` too. In this code any unexpected error - be it in our code or the `fs` module - would not be caught by these handlers and therefore not swallowed.
+
+Since a `catch` handler typed to `Promise.RejectionError` is expected to be used very often, it has a neat shorthand:
+
+```js
+.error(function (e) {
+ console.error("unable to read file, because: ", e.message);
+});
+```
+
+See [API documentation for `.error()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#error-rejectedhandler----promise)
+
+Finally, Bluebird also supports predicate-based filters. If you pass a
+predicate function instead of an error type, the predicate will receive
+the error as an argument. The return result will be used determine whether
+the error handler should be called.
+
+Predicates should allow for very fine grained control over caught errors:
+pattern matching, error typesets with set operations and many other techniques
+can be implemented on top of them.
+
+Example of using a predicate-based filter:
+
+```js
+var Promise = require("bluebird");
+var request = Promise.promisify(require("request"));
+
+function clientError(e) {
+ return e.code >= 400 && e.code < 500;
+}
+
+request("http://www.google.com").then(function(contents){
+ console.log(contents);
+}).catch(clientError, function(e){
+ //A client error like 400 Bad Request happened
+});
+```
+
+**Danger:** The JavaScript language allows throwing primitive values like strings. Throwing primitives can lead to worse or no stack traces. Primitives [are not exceptions](http://www.devthought.com/2011/12/22/a-string-is-not-an-error/). You should consider always throwing Error objects when handling exceptions.
+
+<hr>
+
+####How do long stack traces differ from e.g. Q?
+
+Bluebird attempts to have more elaborate traces. Consider:
+
+```js
+Error.stackTraceLimit = 25;
+Q.longStackSupport = true;
+Q().then(function outer() {
+ return Q().then(function inner() {
+ return Q().then(function evenMoreInner() {
+ a.b.c.d();
+ }).catch(function catcher(e){
+ console.error(e.stack);
+ });
+ })
+});
+```
+
+You will see
+
+ ReferenceError: a is not defined
+ at evenMoreInner (<anonymous>:7:13)
+ From previous event:
+ at inner (<anonymous>:6:20)
+
+Compare to:
+
+```js
+Error.stackTraceLimit = 25;
+Promise.longStackTraces();
+Promise.resolve().then(function outer() {
+ return Promise.resolve().then(function inner() {
+ return Promise.resolve().then(function evenMoreInner() {
+ a.b.c.d()
+ }).catch(function catcher(e){
+ console.error(e.stack);
+ });
+ });
+});
+```
+
+ ReferenceError: a is not defined
+ at evenMoreInner (<anonymous>:7:13)
+ From previous event:
+ at inner (<anonymous>:6:36)
+ From previous event:
+ at outer (<anonymous>:5:32)
+ From previous event:
+ at <anonymous>:4:21
+ at Object.InjectedScript._evaluateOn (<anonymous>:572:39)
+ at Object.InjectedScript._evaluateAndWrap (<anonymous>:531:52)
+ at Object.InjectedScript.evaluate (<anonymous>:450:21)
+
+
+A better and more practical example of the differences can be seen in gorgikosev's [debuggability competition](https://github.com/spion/async-compare#debuggability).
+
+<hr>
+
+####Can I use long stack traces in production?
+
+Probably yes. Bluebird uses multiple innovative techniques to optimize long stack traces. Even with long stack traces, it is still way faster than similarly featured implementations that don't have long stack traces enabled and about same speed as minimal implementations. A slowdown of 4-5x is expected, not 50x.
+
+What techniques are used?
+
+#####V8 API second argument
+
+This technique utilizes the [slightly under-documented](https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi#Stack_trace_collection_for_custom_exceptions) second argument of V8 `Error.captureStackTrace`. It turns out that the second argument can actually be used to make V8 skip all library internal stack frames [for free](https://github.com/v8/v8/blob/b5fabb9225e1eb1c20fd527b037e3f877296e52a/src/isolate.cc#L665). It only requires propagation of callers manually in library internals but this is not visible to you as user at all.
+
+Without this technique, every promise (well not every, see second technique) created would have to waste time creating and collecting library internal frames which will just be thrown away anyway. It also allows one to use smaller stack trace limits because skipped frames are not counted towards the limit whereas with collecting everything upfront and filtering afterwards would likely have to use higher limits to get more user stack frames in.
+
+#####Sharing stack traces
+
+Consider:
+
+```js
+function getSomethingAsync(fileName) {
+ return readFileAsync(fileName).then(function(){
+ //...
+ }).then(function() {
+ //...
+ }).then(function() {
+ //...
+ });
+}
+```
+
+Everytime you call this function it creates 4 promises and in a straight-forward long stack traces implementation it would collect 4 almost identical stack traces. Bluebird has a light weight internal data-structure (kcnown as context stack in the source code) to help tracking when traces can be re-used and this example would only collect one trace.
+
+#####Lazy formatting
+
+After a stack trace has been collected on an object, one must be careful not to reference the `.stack` property until necessary. Referencing the property causes
+an expensive format call and the stack property is turned into a string which uses much more memory.
+
+What about [Q #111](https://github.com/kriskowal/q/issues/111)?
+
+Long stack traces is not inherently the problem. For example with latest Q with stack traces disabled:
+
+```js
+var Q = require("q");
+
+
+function test(i){
+ if (i <= 0){
+ return Q.when('done')
+ } else {
+ return Q.when(i-1).then(test)
+ }
+}
+test(1000000000).then(function(output){console.log(output) });
+```
+
+After 2 minutes of running this, it will give:
+
+```js
+FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
+```
+
+So the problem with this is how much absolute memory is used per promise - not whether long traces are enabled or not.
+
+For some purpose, let's say 100000 parallel pending promises in memory at the same time is the maximum. You would then roughly use 100MB for them instead of 10MB with stack traces disabled.For comparison, just creating 100000 functions alone will use 14MB if they're closures. All numbers can be halved for 32-bit node.
+
+<hr>
+
+#Development
+
+For development tasks such as running benchmarks or testing, you need to clone the repository and install dev-dependencies.
+
+Install [node](http://nodejs.org/), [npm](https://npmjs.org/), and [grunt](http://gruntjs.com/).
+
+ git clone git@github.com:petkaantonov/bluebird.git
+ cd bluebird
+ npm install
+
+##Testing
+
+To run all tests, run `grunt test`. Note that 10 processes are created to run the tests in parallel. The stdout of tests is ignored by default and everything will stop at the first failure.
+
+Individual files can be run with `grunt test --run=filename` where `filename` is a test file name in `/test` folder or `/test/mocha` folder. The `.js` prefix is not needed. The dots for AP compliance tests are not needed, so to run `/test/mocha/2.3.3.js` for instance:
+
+ grunt test --run=233
+
+When trying to get a test to pass, run only that individual test file with `--verbose` to see the output from that test:
+
+ grunt test --run=233 --verbose
+
+The reason for the unusual way of testing is because the majority of tests are from different libraries using different testing frameworks and because it takes forever to test sequentially.
+
+
+###Testing in browsers
+
+To test in browsers:
+
+ cd browser
+ setup
+
+Then open the `index.html` in your browser. Requires bash (on windows the mingw32 that comes with git works fine too).
+
+You may also [visit the github hosted page](http://petkaantonov.github.io/bluebird/browser/).
+
+Keep the test tab active because some tests are timing-sensitive and will fail if the browser is throttling timeouts. Chrome will do this for example when the tab is not active.
+
+##Benchmarks
+
+To run a benchmark, run the given command for a benchmark while on the project root. Requires bash (on windows the mingw32 that comes with git works fine too).
+
+Node 0.11.2+ is required to run the generator examples.
+
+###1\. DoxBee sequential
+
+Currently the most relevant benchmark is @gorkikosev's benchmark in the article [Analysis of generators and other async patterns in node](http://spion.github.io/posts/analysis-generators-and-other-async-patterns-node.html). The benchmark emulates a situation where n amount of users are making a request in parallel to execute some mixed async/sync action. The benchmark has been modified to include a warm-up phase to minimize any JITing during timed sections.
+
+Command: `bench doxbee`
+
+###2\. Made-up parallel
+
+This made-up scenario runs 15 shimmed queries in parallel.
+
+Command: `bench parallel`
+
+##Custom builds
+
+Custom builds for browsers are supported through a command-line utility.
+
+
+
+
+<table>
+ <caption>The following features can be disabled</caption>
+ <thead>
+ <tr>
+ <th>Feature(s)</th>
+ <th>Command line identifier</th>
+ </tr>
+ </thead>
+ <tbody>
+
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#any---promise"><code>.any</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promiseanyarraydynamicpromise-values---promise"><code>Promise.any</code></a></td><td><code>any</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#race---promise"><code>.race</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promiseracearraypromise-promises---promise"><code>Promise.race</code></a></td><td><code>race</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#callstring-propertyname--dynamic-arg---promise"><code>.call</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#getstring-propertyname---promise"><code>.get</code></a></td><td><code>call_get</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#filterfunction-filterer---promise"><code>.filter</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promisefilterarraydynamicpromise-values-function-filterer---promise"><code>Promise.filter</code></a></td><td><code>filter</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#mapfunction-mapper---promise"><code>.map</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promisemaparraydynamicpromise-values-function-mapper---promise"><code>Promise.map</code></a></td><td><code>map</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#reducefunction-reducer--dynamic-initialvalue---promise"><code>.reduce</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promisereducearraydynamicpromise-values-function-reducer--dynamic-initialvalue---promise"><code>Promise.reduce</code></a></td><td><code>reduce</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#props---promise"><code>.props</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promisepropsobjectpromise-object---promise"><code>Promise.props</code></a></td><td><code>props</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#settle---promise"><code>.settle</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promisesettlearraydynamicpromise-values---promise"><code>Promise.settle</code></a></td><td><code>settle</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#someint-count---promise"><code>.some</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promisesomearraydynamicpromise-values-int-count---promise"><code>Promise.some</code></a></td><td><code>some</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#nodeifyfunction-callback---promise"><code>.nodeify</code></a></td><td><code>nodeify</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promisecoroutinegeneratorfunction-generatorfunction---function"><code>Promise.coroutine</code></a> and <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promisespawngeneratorfunction-generatorfunction---promise"><code>Promise.spawn</code></a></td><td><code>generators</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#progression">Progression</a></td><td><code>progress</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#promisification">Promisification</a></td><td><code>promisify</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#cancellation">Cancellation</a></td><td><code>cancel</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#synchronous-inspection">Synchronous inspection</a></td><td><code>synchronous_inspection</code></td></tr>
+ <tr><td><a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#timers">Timers</a></td><td><code>timers</code></td></tr>
+
+ </tbody>
+</table>
+
+
+Make sure you have cloned the repo somewhere and did `npm install` successfully.
+
+After that you can run:
+
+ grunt build --features="core"
+
+
+The above builds the most minimal build you can get. You can add more features separated by spaces from the above list:
+
+ grunt build --features="core filter map reduce"
+
+The custom build file will be found from `/js/browser/bluebird.js`. It will have a comment that lists the disabled and enabled features.
+
+Note that the build leaves the `/js/main` etc folders with same features so if you use the folder for node.js at the same time, don't forget to build
+a full version afterwards (after having taken a copy of the bluebird.js somewhere):
+
+ grunt build
+
+<hr>
+
+##For library authors
+
+Building a library that depends on bluebird? You should know about a few features.
+
+If your library needs to do something obtrusive like adding or modifying methods on the `Promise` prototype, uses long stack traces or uses a custom unhandled rejection handler then... that's totally ok as long as you don't use `require("bluebird")`. Instead you should create a file
+that creates an isolated copy. For example, creating a file called `bluebird-extended.js` that contains:
+
+```js
+ //NOTE the function call right after
+module.exports = require("bluebird/js/main/promise")();
+```
+
+Your library can then use `var Promise = require("bluebird-extended");` and do whatever it wants with it. Then if the application or other library uses their own bluebird promises they will all play well together because of Promises/A+ thenable assimilation magic.
+
+You should also know about [`.nodeify()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#nodeifyfunction-callback---promise) which makes it easy to provide a dual callback/promise API.
+
+<hr>
+
+##What is the sync build?
+
+You may now use sync build by:
+
+ var Promise = require("bluebird/zalgo");
+
+The sync build is provided to see how forced asynchronity affects benchmarks. It should not be used in real code due to the implied hazards.
+
+The normal async build gives Promises/A+ guarantees about asynchronous resolution of promises. Some people think this affects performance or just plain love their code having a possibility
+of stack overflow errors and non-deterministic behavior.
+
+The sync build skips the async call trampoline completely, e.g code like:
+
+ async.invoke( this.fn, this, val );
+
+Appears as this in the sync build:
+
+ this.fn(val);
+
+This should pressure the CPU slightly less and thus the sync build should perform better. Indeed it does, but only marginally. The biggest performance boosts are from writing efficient Javascript, not from compromising determinism.
+
+Note that while some benchmarks are waiting for the next event tick, the CPU is actually not in use during that time. So the resulting benchmark result is not completely accurate because on node.js you only care about how much the CPU is taxed. Any time spent on CPU is time the whole process (or server) is paralyzed. And it is not graceful like it would be with threads.
+
+
+```js
+var cache = new Map(); //ES6 Map or DataStructures/Map or whatever...
+function getResult(url) {
+ var resolver = Promise.pending();
+ if (cache.has(url)) {
+ resolver.resolve(cache.get(url));
+ }
+ else {
+ http.get(url, function(err, content) {
+ if (err) resolver.reject(err);
+ else {
+ cache.set(url, content);
+ resolver.resolve(content);
+ }
+ });
+ }
+ return resolver.promise;
+}
+
+
+
+//The result of console.log is truly random without async guarantees
+function guessWhatItPrints( url ) {
+ var i = 3;
+ getResult(url).then(function(){
+ i = 4;
+ });
+ console.log(i);
+}
+```
+
+#Optimization guide
+
+Articles about optimization will be periodically posted in [the wiki section](https://github.com/petkaantonov/bluebird/wiki), polishing edits are welcome.
+
+A single cohesive guide compiled from the articles will probably be done eventually.
+
+#License
+
+Copyright (c) 2014 Petka Antonov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:</p>
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/benchmark/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/benchmark/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/benchmark/package.json
new file mode 100644
index 0000000..19cefed
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/benchmark/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "async-compare",
+ "version": "0.1.1",
+ "description": "Compare the performance and code of multiple async patterns",
+ "main": "perf.js",
+ "dependencies": {
+ "async": "~0.2.9",
+ "deferred": "~0.6.6",
+ "kew": "~0.3.0",
+ "liar": "~0.6.0",
+ "optimist": "~0.6.0",
+ "q": "~1.0.0",
+ "rsvp": "~3.0.0",
+ "text-table": "~0.2.0",
+ "when": "~3.0.0",
+ "vow": "~0.4.1",
+ "davy": "~0.2.0"
+ },
+ "devDependencies": {},
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "keywords": [
+ "generators",
+ "fibers",
+ "promises",
+ "callbacks",
+ "comparison",
+ "compare",
+ "async"
+ ],
+ "author": "spion",
+ "license": "MIT"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/bower.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/bower.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/bower.json
new file mode 100644
index 0000000..396073a
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/bower.json
@@ -0,0 +1,35 @@
+{
+ "name": "bluebird",
+ "version": "1.0.0",
+ "homepage": "https://github.com/petkaantonov/bluebird",
+ "authors": [
+ "Petka Antonov <pe...@hotmail.com>"
+ ],
+ "description": "Bluebird is a full featured promise library with unmatched performance.",
+ "main": "js/browser/bluebird.js",
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "benchmark",
+ "bower_components",
+ "./browser",
+ "js/zalgo",
+ "node_modules",
+ "test"
+ ],
+ "keywords": [
+ "promise",
+ "performance",
+ "promises",
+ "promises-a",
+ "promises-aplus",
+ "async",
+ "await",
+ "deferred",
+ "deferreds",
+ "future",
+ "flow control",
+ "dsl",
+ "fluent interface"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/bundle.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/bundle.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/bundle.js
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/changelog.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/changelog.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/changelog.md
new file mode 100644
index 0000000..9ae6be2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/changelog.md
@@ -0,0 +1,1135 @@
+## 1.1.1 (2014-03-18)
+
+Bugfixes:
+
+ - [#138](https://github.com/petkaantonov/bluebird/issues/138)
+ - [#144](https://github.com/petkaantonov/bluebird/issues/144)
+ - [#148](https://github.com/petkaantonov/bluebird/issues/148)
+ - [#151](https://github.com/petkaantonov/bluebird/issues/151)
+
+## 1.1.0 (2014-03-08)
+
+Features:
+
+ - Implement [`Promise.prototype.tap()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#tapfunction-handler---promise)
+ - Implement [`Promise.coroutine.addYieldHandler()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#promisecoroutineaddyieldhandlerfunction-handler---void)
+ - Deprecate `Promise.prototype.spawn`
+
+Bugfixes:
+
+ - Fix already rejected promises being reported as unhandled when handled through collection methods
+ - Fix browserisfy crashing from checking `process.version.indexOf`
+
+## 1.0.8 (2014-03-03)
+
+Bugfixes:
+
+ - Fix active domain being lost across asynchronous boundaries in Node.JS 10.xx
+
+## 1.0.7 (2014-02-25)
+
+Bugfixes:
+
+ - Fix handled errors being reported
+
+## 1.0.6 (2014-02-17)
+
+Bugfixes:
+
+ - Fix bug with unhandled rejections not being reported
+ when using `Promise.try` or `Promise.method` without
+ attaching further handlers
+
+## 1.0.5 (2014-02-15)
+
+Features:
+
+ - Node.js performance: promisified functions try to check amount of passed arguments in most optimal order
+ - Node.js promisified functions will have same `.length` as the original function minus one (for the callback parameter)
+
+## 1.0.4 (2014-02-09)
+
+Features:
+
+ - Possibly unhandled rejection handler will always get a stack trace, even if the rejection or thrown error was not an error
+ - Unhandled rejections are tracked per promise, not per error. So if you create multiple branches from a single ancestor and that ancestor gets rejected, each branch with no error handler with the end will cause a possibly unhandled rejection handler invocation
+
+Bugfixes:
+
+ - Fix unhandled non-writable objects or primitives not reported by possibly unhandled rejection handler
+
+## 1.0.3 (2014-02-05)
+
+Bugfixes:
+
+ - [#93](https://github.com/petkaantonov/bluebird/issues/88)
+
+## 1.0.2 (2014-02-04)
+
+Features:
+
+ - Significantly improve performance of foreign bluebird thenables
+
+Bugfixes:
+
+ - [#88](https://github.com/petkaantonov/bluebird/issues/88)
+
+## 1.0.1 (2014-01-28)
+
+Features:
+
+ - Error objects that have property `.isAsync = true` will now be caught by `.error()`
+
+Bugfixes:
+
+ - Fix TypeError and RangeError shims not working without `new` operator
+
+## 1.0.0 (2014-01-12)
+
+Features:
+
+ - `.filter`, `.map`, and `.reduce` no longer skip sparse array holes. This is a backwards incompatible change.
+ - Like `.map` and `.filter`, `.reduce` now allows returning promises and thenables from the iteration function.
+
+Bugfixes:
+
+ - [#58](https://github.com/petkaantonov/bluebird/issues/58)
+ - [#61](https://github.com/petkaantonov/bluebird/issues/61)
+ - [#64](https://github.com/petkaantonov/bluebird/issues/64)
+ - [#60](https://github.com/petkaantonov/bluebird/issues/60)
+
+## 0.11.6-1 (2013-12-29)
+
+## 0.11.6-0 (2013-12-29)
+
+Features:
+
+ - You may now return promises and thenables from the filterer function used in `Promise.filter` and `Promise.prototype.filter`.
+
+ - `.error()` now catches additional sources of rejections:
+
+ - Rejections originating from `Promise.reject`
+
+ - Rejections originating from thenables using
+ the `reject` callback
+
+ - Rejections originating from promisified callbacks
+ which use the `errback` argument
+
+ - Rejections originating from `new Promise` constructor
+ where the `reject` callback is called explicitly
+
+ - Rejections originating from `PromiseResolver` where
+ `.reject()` method is called explicitly
+
+Bugfixes:
+
+ - Fix `captureStackTrace` being called when it was `null`
+ - Fix `Promise.map` not unwrapping thenables
+
+## 0.11.5-1 (2013-12-15)
+
+## 0.11.5-0 (2013-12-03)
+
+Features:
+
+ - Improve performance of collection methods
+ - Improve performance of promise chains
+
+## 0.11.4-1 (2013-12-02)
+
+## 0.11.4-0 (2013-12-02)
+
+Bugfixes:
+
+ - Fix `Promise.some` behavior with arguments like negative integers, 0...
+ - Fix stack traces of synchronously throwing promisified functions'
+
+## 0.11.3-0 (2013-12-02)
+
+Features:
+
+ - Improve performance of generators
+
+Bugfixes:
+
+ - Fix critical bug with collection methods.
+
+## 0.11.2-0 (2013-12-02)
+
+Features:
+
+ - Improve performance of all collection methods
+
+## 0.11.1-0 (2013-12-02)
+
+Features:
+
+- Improve overall performance.
+- Improve performance of promisified functions.
+- Improve performance of catch filters.
+- Improve performance of .finally.
+
+Bugfixes:
+
+- Fix `.finally()` rejecting if passed non-function. It will now ignore non-functions like `.then`.
+- Fix `.finally()` not converting thenables returned from the handler to promises.
+- `.spread()` now rejects if the ultimate value given to it is not spreadable.
+
+## 0.11.0-0 (2013-12-02)
+
+Features:
+
+ - Improve overall performance when not using `.bind()` or cancellation.
+ - Promises are now not cancellable by default. This is backwards incompatible change - see [`.cancellable()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#cancellable---promise)
+ - [`Promise.delay`](https://github.com/petkaantonov/bluebird/blob/master/API.md#promisedelaydynamic-value-int-ms---promise)
+ - [`.delay()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#delayint-ms---promise)
+ - [`.timeout()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#timeoutint-ms--string-message---promise)
+
+## 0.10.14-0 (2013-12-01)
+
+Bugfixes:
+
+ - Fix race condition when mixing 3rd party asynchrony.
+
+## 0.10.13-1 (2013-11-30)
+
+## 0.10.13-0 (2013-11-30)
+
+Bugfixes:
+
+ - Fix another bug with progression.
+
+## 0.10.12-0 (2013-11-30)
+
+Bugfixes:
+
+ - Fix bug with progression.
+
+## 0.10.11-4 (2013-11-29)
+
+## 0.10.11-2 (2013-11-29)
+
+Bugfixes:
+
+ - Fix `.race()` not propagating bound values.
+
+## 0.10.11-1 (2013-11-29)
+
+Features:
+
+ - Improve performance of `Promise.race`
+
+## 0.10.11-0 (2013-11-29)
+
+Bugfixes:
+
+ - Fixed `Promise.promisifyAll` invoking property accessors. Only data properties with function values are considered.
+
+## 0.10.10-0 (2013-11-28)
+
+Features:
+
+ - Disable long stack traces in browsers by default. Call `Promise.longStackTraces()` to enable them.
+
+## 0.10.9-1 (2013-11-27)
+
+Bugfixes:
+
+ - Fail early when `new Promise` is constructed incorrectly
+
+## 0.10.9-0 (2013-11-27)
+
+Bugfixes:
+
+ - Promise.props now takes a [thenable-for-collection](https://github.com/petkaantonov/bluebird/blob/f41edac61b7c421608ff439bb5a09b7cffeadcf9/test/mocha/props.js#L197-L217)
+ - All promise collection methods now reject when a promise-or-thenable-for-collection turns out not to give a collection
+
+## 0.10.8-0 (2013-11-25)
+
+Features:
+
+ - All static collection methods take thenable-for-collection
+
+## 0.10.7-0 (2013-11-25)
+
+Features:
+
+ - throw TypeError when thenable resolves with itself
+ - Make .race() and Promise.race() forever pending on empty collections
+
+## 0.10.6-0 (2013-11-25)
+
+Bugfixes:
+
+ - Promise.resolve and PromiseResolver.resolve follow thenables too.
+
+## 0.10.5-0 (2013-11-24)
+
+Bugfixes:
+
+ - Fix infinite loop when thenable resolves with itself
+
+## 0.10.4-1 (2013-11-24)
+
+Bugfixes:
+
+ - Fix a file missing from build. (Critical fix)
+
+## 0.10.4-0 (2013-11-24)
+
+Features:
+
+ - Remove dependency of es5-shim and es5-sham when using ES3.
+
+## 0.10.3-0 (2013-11-24)
+
+Features:
+
+ - Improve performance of `Promise.method`
+
+## 0.10.2-1 (2013-11-24)
+
+Features:
+
+ - Rename PromiseResolver#asCallback to PromiseResolver#callback
+
+## 0.10.2-0 (2013-11-24)
+
+Features:
+
+ - Remove memoization of thenables
+
+## 0.10.1-0 (2013-11-21)
+
+Features:
+
+ - Add methods `Promise.resolve()`, `Promise.reject()`, `Promise.defer()` and `.resolve()`.
+
+## 0.10.0-1 (2013-11-17)
+
+## 0.10.0-0 (2013-11-17)
+
+Features:
+
+ - Implement `Promise.method()`
+ - Implement `.return()`
+ - Implement `.throw()`
+
+Bugfixes:
+
+ - Fix promises being able to use themselves as resolution or follower value
+
+## 0.9.11-1 (2013-11-14)
+
+Features:
+
+ - Implicit `Promise.all()` when yielding an array from generators
+
+## 0.9.11-0 (2013-11-13)
+
+Bugfixes:
+
+ - Fix `.spread` not unwrapping thenables
+
+## 0.9.10-2 (2013-11-13)
+
+Features:
+
+ - Improve performance of promisified functions on V8
+
+Bugfixes:
+
+ - Report unhandled rejections even when long stack traces are disabled
+ - Fix `.error()` showing up in stack traces
+
+## 0.9.10-1 (2013-11-05)
+
+Bugfixes:
+
+ - Catch filter method calls showing in stack traces
+
+## 0.9.10-0 (2013-11-05)
+
+Bugfixes:
+
+ - Support primitives in catch filters
+
+## 0.9.9-0 (2013-11-05)
+
+Features:
+
+ - Add `Promise.race()` and `.race()`
+
+## 0.9.8-0 (2013-11-01)
+
+Bugfixes:
+
+ - Fix bug with `Promise.try` not unwrapping returned promises and thenables
+
+## 0.9.7-0 (2013-10-29)
+
+Bugfixes:
+
+ - Fix bug with build files containing duplicated code for promise.js
+
+## 0.9.6-0 (2013-10-28)
+
+Features:
+
+ - Improve output of reporting unhandled non-errors
+ - Implement RejectionError wrapping and `.error()` method
+
+## 0.9.5-0 (2013-10-27)
+
+Features:
+
+ - Allow fresh copies of the library to be made
+
+## 0.9.4-1 (2013-10-27)
+
+## 0.9.4-0 (2013-10-27)
+
+Bugfixes:
+
+ - Rollback non-working multiple fresh copies feature
+
+## 0.9.3-0 (2013-10-27)
+
+Features:
+
+ - Allow fresh copies of the library to be made
+ - Add more components to customized builds
+
+## 0.9.2-1 (2013-10-25)
+
+## 0.9.2-0 (2013-10-25)
+
+Features:
+
+ - Allow custom builds
+
+## 0.9.1-1 (2013-10-22)
+
+Bugfixes:
+
+ - Fix unhandled rethrown exceptions not reported
+
+## 0.9.1-0 (2013-10-22)
+
+Features:
+
+ - Improve performance of `Promise.try`
+ - Extend `Promise.try` to accept arguments and ctx to make it more usable in promisification of synchronous functions.
+
+## 0.9.0-0 (2013-10-18)
+
+Features:
+
+ - Implement `.bind` and `Promise.bind`
+
+Bugfixes:
+
+ - Fix `.some()` when argument is a pending promise that later resolves to an array
+
+## 0.8.5-1 (2013-10-17)
+
+Features:
+
+ - Enable process wide long stack traces through BLUEBIRD_DEBUG environment variable
+
+## 0.8.5-0 (2013-10-16)
+
+Features:
+
+ - Improve performance of all collection methods
+
+Bugfixes:
+
+ - Fix .finally passing the value to handlers
+ - Remove kew from benchmarks due to bugs in the library breaking the benchmark
+ - Fix some bluebird library calls potentially appearing in stack traces
+
+## 0.8.4-1 (2013-10-15)
+
+Bugfixes:
+
+ - Fix .pending() call showing in long stack traces
+
+## 0.8.4-0 (2013-10-15)
+
+Bugfixes:
+
+ - Fix PromiseArray and its sub-classes swallowing possibly unhandled rejections
+
+## 0.8.3-3 (2013-10-14)
+
+Bugfixes:
+
+ - Fix AMD-declaration using named module.
+
+## 0.8.3-2 (2013-10-14)
+
+Features:
+
+ - The mortals that can handle it may now release Zalgo by `require("bluebird/zalgo");`
+
+## 0.8.3-1 (2013-10-14)
+
+Bugfixes:
+
+ - Fix memory leak when using the same promise to attach handlers over and over again
+
+## 0.8.3-0 (2013-10-13)
+
+Features:
+
+ - Add `Promise.props()` and `Promise.prototype.props()`. They work like `.all()` for object properties.
+
+Bugfixes:
+
+ - Fix bug with .some returning garbage when sparse arrays have rejections
+
+## 0.8.2-2 (2013-10-13)
+
+Features:
+
+ - Improve performance of `.reduce()` when `initialValue` can be synchronously cast to a value
+
+## 0.8.2-1 (2013-10-12)
+
+Bugfixes:
+
+ - Fix .npmignore having irrelevant files
+
+## 0.8.2-0 (2013-10-12)
+
+Features:
+
+ - Improve performance of `.some()`
+
+## 0.8.1-0 (2013-10-11)
+
+Bugfixes:
+
+ - Remove uses of dynamic evaluation (`new Function`, `eval` etc) when strictly not necessary. Use feature detection to use static evaluation to avoid errors when dynamic evaluation is prohibited.
+
+## 0.8.0-3 (2013-10-10)
+
+Features:
+
+ - Add `.asCallback` property to `PromiseResolver`s
+
+## 0.8.0-2 (2013-10-10)
+
+## 0.8.0-1 (2013-10-09)
+
+Features:
+
+ - Improve overall performance. Be able to sustain infinite recursion when using promises.
+
+## 0.8.0-0 (2013-10-09)
+
+Bugfixes:
+
+ - Fix stackoverflow error when function calls itself "synchronously" from a promise handler
+
+## 0.7.12-2 (2013-10-09)
+
+Bugfixes:
+
+ - Fix safari 6 not using `MutationObserver` as a scheduler
+ - Fix process exceptions interfering with internal queue flushing
+
+## 0.7.12-1 (2013-10-09)
+
+Bugfixes:
+
+ - Don't try to detect if generators are available to allow shims to be used
+
+## 0.7.12-0 (2013-10-08)
+
+Features:
+
+ - Promisification now consider all functions on the object and its prototype chain
+ - Individual promisifcation uses current `this` if no explicit receiver is given
+ - Give better stack traces when promisified callbacks throw or errback primitives such as strings by wrapping them in an `Error` object.
+
+Bugfixes:
+
+ - Fix runtime APIs throwing synchronous errors
+
+## 0.7.11-0 (2013-10-08)
+
+Features:
+
+ - Deprecate `Promise.promisify(Object target)` in favor of `Promise.promisifyAll(Object target)` to avoid confusion with function objects
+ - Coroutines now throw error when a non-promise is `yielded`
+
+## 0.7.10-1 (2013-10-05)
+
+Features:
+
+ - Make tests pass Internet Explorer 8
+
+## 0.7.10-0 (2013-10-05)
+
+Features:
+
+ - Create browser tests
+
+## 0.7.9-1 (2013-10-03)
+
+Bugfixes:
+
+ - Fix promise cast bug when thenable fulfills using itself as the fulfillment value
+
+## 0.7.9-0 (2013-10-03)
+
+Features:
+
+ - More performance improvements when long stack traces are enabled
+
+## 0.7.8-1 (2013-10-02)
+
+Features:
+
+ - Performance improvements when long stack traces are enabled
+
+## 0.7.8-0 (2013-10-02)
+
+Bugfixes:
+
+ - Fix promisified methods not turning synchronous exceptions into rejections
+
+## 0.7.7-1 (2013-10-02)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.7-0 (2013-10-01)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.6-0 (2013-09-29)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.5-0 (2013-09-28)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.4-1 (2013-09-28)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.4-0 (2013-09-28)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.3-1 (2013-09-28)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.3-0 (2013-09-27)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.2-0 (2013-09-27)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-5 (2013-09-26)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-4 (2013-09-25)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-3 (2013-09-25)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-2 (2013-09-24)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-1 (2013-09-24)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-0 (2013-09-24)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.0-1 (2013-09-23)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.0-0 (2013-09-23)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.5-2 (2013-09-20)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.5-1 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.5-0 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.4-1 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.4-0 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-4 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-3 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-2 (2013-09-16)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-1 (2013-09-16)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-0 (2013-09-15)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.2-1 (2013-09-14)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.2-0 (2013-09-14)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.1-0 (2013-09-14)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.0-0 (2013-09-13)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-6 (2013-09-12)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-5 (2013-09-12)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-4 (2013-09-12)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-3 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-2 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-1 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-0 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.8-1 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.8-0 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.7-0 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.6-1 (2013-09-10)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.6-0 (2013-09-10)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.5-1 (2013-09-10)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.5-0 (2013-09-09)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.4-1 (2013-09-08)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.4-0 (2013-09-08)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.3-0 (2013-09-07)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.2-0 (2013-09-07)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.1-0 (2013-09-07)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.0-0 (2013-09-07)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.4.0-0 (2013-09-06)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.3.0-1 (2013-09-06)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.3.0 (2013-09-06)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/any.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/any.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/any.js
new file mode 100644
index 0000000..8d174cf
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/any.js
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, Promise$_CreatePromiseArray, PromiseArray) {
+
+ var SomePromiseArray = require("./some_promise_array.js")(PromiseArray);
+ function Promise$_Any(promises, useBound, caller) {
+ var ret = Promise$_CreatePromiseArray(
+ promises,
+ SomePromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ );
+ var promise = ret.promise();
+ if (promise.isRejected()) {
+ return promise;
+ }
+ ret.setHowMany(1);
+ ret.setUnwrap();
+ ret.init();
+ return promise;
+ }
+
+ Promise.any = function Promise$Any(promises) {
+ return Promise$_Any(promises, false, Promise.any);
+ };
+
+ Promise.prototype.any = function Promise$any() {
+ return Promise$_Any(this, true, this.any);
+ };
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/assert.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/assert.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/assert.js
new file mode 100644
index 0000000..4adb8c2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/assert.js
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = (function(){
+ var AssertionError = (function() {
+ function AssertionError(a) {
+ this.constructor$(a);
+ this.message = a;
+ this.name = "AssertionError";
+ }
+ AssertionError.prototype = new Error();
+ AssertionError.prototype.constructor = AssertionError;
+ AssertionError.prototype.constructor$ = Error;
+ return AssertionError;
+ })();
+
+ function getParams(args) {
+ var params = [];
+ for (var i = 0; i < args.length; ++i) params.push("arg" + i);
+ return params;
+ }
+
+ function nativeAssert(callName, args, expect) {
+ try {
+ var params = getParams(args);
+ var constructorArgs = params;
+ constructorArgs.push("return " +
+ callName + "("+ params.join(",") + ");");
+ var fn = Function.apply(null, constructorArgs);
+ return fn.apply(null, args);
+ }
+ catch (e) {
+ if (!(e instanceof SyntaxError)) {
+ throw e;
+ }
+ else {
+ return expect;
+ }
+ }
+ }
+
+ return function assert(boolExpr, message) {
+ if (boolExpr === true) return;
+
+ if (typeof boolExpr === "string" &&
+ boolExpr.charAt(0) === "%") {
+ var nativeCallName = boolExpr;
+ var $_len = arguments.length;var args = new Array($_len - 2); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];}
+ if (nativeAssert(nativeCallName, args, message) === message) return;
+ message = (nativeCallName + " !== " + message);
+ }
+
+ var ret = new AssertionError(message);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(ret, assert);
+ }
+ if (console && console.error) {
+ console.error(ret.stack + "");
+ }
+ throw ret;
+
+ };
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[48/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/resolve.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
new file mode 100644
index 0000000..1b3c533
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
@@ -0,0 +1,49 @@
+import {
+ noop,
+ resolve as _resolve
+} from '../-internal';
+
+/**
+ `Promise.resolve` returns a promise that will become resolved with the
+ passed `value`. It is shorthand for the following:
+
+ ```javascript
+ var promise = new Promise(function(resolve, reject){
+ resolve(1);
+ });
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = Promise.resolve(1);
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ @method resolve
+ @static
+ @param {Any} value value that the returned promise will be resolved with
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise that will become fulfilled with the given
+ `value`
+*/
+export default function resolve(object, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
+
+ var promise = new Constructor(noop, label);
+ _resolve(promise, object);
+ return promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/utils.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/utils.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/utils.js
new file mode 100644
index 0000000..6b49bbf
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/utils.js
@@ -0,0 +1,39 @@
+export function objectOrFunction(x) {
+ return typeof x === 'function' || (typeof x === 'object' && x !== null);
+}
+
+export function isFunction(x) {
+ return typeof x === 'function';
+}
+
+export function isMaybeThenable(x) {
+ return typeof x === 'object' && x !== null;
+}
+
+var _isArray;
+if (!Array.isArray) {
+ _isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+} else {
+ _isArray = Array.isArray;
+}
+
+export var isArray = _isArray;
+
+// Date.now is not available in browsers < IE9
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
+export var now = Date.now || function() { return new Date().getTime(); };
+
+function F() { }
+
+export var o_create = (Object.create || function (o) {
+ if (arguments.length > 1) {
+ throw new Error('Second argument not supported');
+ }
+ if (typeof o !== 'object') {
+ throw new TypeError('Argument must be an object');
+ }
+ F.prototype = o;
+ return new F();
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/package.json b/node_modules/node-firefox-connect/node_modules/es6-promise/package.json
new file mode 100644
index 0000000..28494ce
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/package.json
@@ -0,0 +1,81 @@
+{
+ "name": "es6-promise",
+ "namespace": "es6-promise",
+ "version": "2.0.1",
+ "description": "A lightweight library that provides tools for organizing asynchronous code",
+ "main": "dist/es6-promise.js",
+ "directories": {
+ "lib": "lib"
+ },
+ "devDependencies": {
+ "bower": "^1.3.9",
+ "brfs": "0.0.8",
+ "broccoli-closure-compiler": "^0.2.0",
+ "broccoli-compile-modules": "git+https://github.com/eventualbuddha/broccoli-compile-modules",
+ "broccoli-concat": "0.0.7",
+ "broccoli-es3-safe-recast": "0.0.8",
+ "broccoli-file-mover": "^0.4.0",
+ "broccoli-jshint": "^0.5.1",
+ "broccoli-merge-trees": "^0.1.4",
+ "broccoli-static-compiler": "^0.1.4",
+ "broccoli-string-replace": "0.0.1",
+ "browserify": "^4.2.0",
+ "ember-cli": "0.0.40",
+ "ember-publisher": "0.0.7",
+ "es6-module-transpiler-amd-formatter": "0.0.1",
+ "express": "^4.5.0",
+ "jshint": "~0.9.1",
+ "mkdirp": "^0.5.0",
+ "mocha": "^1.20.1",
+ "promises-aplus-tests": "git://github.com/stefanpenner/promises-tests.git",
+ "release-it": "0.0.10",
+ "testem": "^0.6.17",
+ "json3": "^3.3.2"
+ },
+ "scripts": {
+ "test": "testem ci -R dot",
+ "test-server": "testem",
+ "lint": "jshint lib",
+ "prepublish": "ember build --environment production",
+ "aplus": "browserify test/main.js",
+ "build-all": "ember build --environment production && browserify ./test/main.js -o tmp/test-bundle.js",
+ "dry-run-release": "ember build --environment production && release-it --dry-run --non-interactive"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jakearchibald/ES6-Promises.git"
+ },
+ "bugs": {
+ "url": "https://github.com/jakearchibald/ES6-Promises/issues"
+ },
+ "keywords": [
+ "promises",
+ "futures"
+ ],
+ "author": {
+ "name": "Yehuda Katz, Tom Dale, Stefan Penner and contributors",
+ "url": "Conversion to ES6 API by Jake Archibald"
+ },
+ "license": "MIT",
+ "homepage": "https://github.com/jakearchibald/ES6-Promises",
+ "_id": "es6-promise@2.0.1",
+ "dist": {
+ "shasum": "ccc4963e679f0ca9fb187c777b9e583d3c7573c2",
+ "tarball": "http://registry.npmjs.org/es6-promise/-/es6-promise-2.0.1.tgz"
+ },
+ "_from": "es6-promise@^2.0.1",
+ "_npmVersion": "1.3.24",
+ "_npmUser": {
+ "name": "jaffathecake",
+ "email": "jaffathecake@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "jaffathecake",
+ "email": "jaffathecake@gmail.com"
+ }
+ ],
+ "_shasum": "ccc4963e679f0ca9fb187c777b9e583d3c7573c2",
+ "_resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-2.0.1.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/server/.jshintrc
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/server/.jshintrc b/node_modules/node-firefox-connect/node_modules/es6-promise/server/.jshintrc
new file mode 100644
index 0000000..c1f2978
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/server/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "node": true
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/server/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/server/index.js b/node_modules/node-firefox-connect/node_modules/es6-promise/server/index.js
new file mode 100644
index 0000000..8a54d36
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/server/index.js
@@ -0,0 +1,6 @@
+module.exports = function(app) {
+ app.use(require('express').static(__dirname + '/../'));
+ app.get('/', function(req, res) {
+ res.redirect('/test/');
+ })
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/testem.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/testem.json b/node_modules/node-firefox-connect/node_modules/es6-promise/testem.json
new file mode 100644
index 0000000..7494912
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/testem.json
@@ -0,0 +1,11 @@
+{
+ "test_page": "test/index.html",
+ "parallel": 5,
+ "before_tests": "npm run build-all",
+ "launchers": {
+ "Mocha": {
+ "command": "./node_modules/.bin/mocha test/main.js"
+ }
+ },
+ "launch_in_ci": ["PhantomJS", "Mocha"]
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/README.md b/node_modules/node-firefox-connect/node_modules/firefox-client/README.md
new file mode 100644
index 0000000..c6aefea
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/README.md
@@ -0,0 +1,157 @@
+# firefox-client
+`firefox-client` is a [node](nodejs.org) library for remote debugging Firefox. You can use it to make things like [fxconsole](https://github.com/harthur/fxconsole), a remote JavaScript REPL.
+
+```javascript
+var FirefoxClient = require("firefox-client");
+
+var client = new FirefoxClient();
+
+client.connect(6000, function() {
+ client.listTabs(function(err, tabs) {
+ console.log("first tab:", tabs[0].url);
+ });
+});
+```
+
+## Install
+With [node.js](http://nodejs.org/) npm package manager:
+
+```bash
+npm install firefox-client
+```
+
+## Connecting
+
+### Desktop Firefox
+1. Enable remote debugging (You'll only have to do this once)
+ 1. Open the DevTools. **Web Developer** > **Toggle Tools**
+ 2. Visit the settings panel (gear icon)
+ 3. Check "Enable remote debugging" under Advanced Settings
+
+2. Listen for a connection
+ 1. Open the Firefox command line with **Tools** > **Web Developer** > **Developer Toolbar**.
+ 2. Start a server by entering this command: `listen 6000` (where `6000` is the port number)
+
+### Firefox for Android
+Follow the instructions in [this Hacks video](https://www.youtube.com/watch?v=Znj_8IFeTVs)
+
+### Firefox OS 1.1 Simulator
+A limited set of the API (`Console`, `StyleSheets`) is compatible with the [Simulator 4.0](https://addons.mozilla.org/en-US/firefox/addon/firefox-os-simulator/). See the [wiki instructions](https://github.com/harthur/firefox-client/wiki/Firefox-OS-Simulator-Instructions) for connecting.
+
+`client.listTabs()` will list the currently open apps in the Simulator.
+
+### Firefox OS 1.2+ Simulator and devices
+
+`client.getWebapps()` will expose the webapps in the Simulator, where each app implements the `Tab` API.
+
+```
+client.getWebapps(function(err, webapps) {
+ webapps.getApp("app://homescreen.gaiamobile.org/manifest.webapp", function (err, app) {
+ console.log("homescreen:", actor.url);
+ app.Console.evaluateJS("alert('foo')", function(err, resp) {
+ console.log("alert dismissed");
+ });
+ });
+});
+```
+
+## Compatibility
+
+This latest version of the library will stay compatible with [Firefox Nightly](http://nightly.mozilla.org/). Almost all of it will be compatible with [Firefox Aurora](http://www.mozilla.org/en-US/firefox/aurora/) as well.
+
+## API
+
+A `FirefoxClient` is the entry point to the API. After connecting, get a `Tab` object with `listTabs()` or `selectedTab()`. Once you have a `Tab`, you can call methods and listen to events from the tab's modules, `Console` or `Network`. There are also experimental `DOM` and `StyleSheets` tab modules, and an upcoming `Debugger` module.
+
+#### Methods
+Almost all API calls take a callback that will get called with an error as the first argument (or `null` if there is no error), and a return value as the second:
+
+```javascript
+tab.Console.evaluateJS("6 + 7", function(err, resp) {
+ if (err) throw err;
+
+ console.log(resp.result);
+});
+```
+
+#### Events
+
+The modules are `EventEmitter`s, listen for events with `on` or `once`, and stop listening with `off`:
+
+```javascript
+tab.Console.on("page-error", function(event) {
+ console.log("new error from tab:", event.errorMessage);
+});
+```
+
+Summary of the offerings of the modules and objects:
+
+#### [FirefoxClient](http://github.com/harthur/firefox-client/wiki/FirefoxClient)
+Methods: `connect()`, `disconnect()`, `listTabs()`, `selectedTab()`, `getWebapps()`, `getRoot()`
+
+Events: `"error"`, `"timeout"`, `"end"`
+
+#### [Tab](https://github.com/harthur/firefox-client/wiki/Tab)
+Properties: `url`, `title`
+
+Methods: `reload()`, `navigateTo()`, `attach()`, `detach()`
+
+Events: `"navigate"`, `"before-navigate"`
+
+#### [Tab.Console](https://github.com/harthur/firefox-client/wiki/Console)
+Methods: `evaluateJS()`, `startListening()`, `stopListening()`, `getCachedLogs()`
+
+Events: `"page-error"`, `"console-api-call"`
+
+#### [JSObject](https://github.com/harthur/firefox-client/wiki/JSObject)
+Properties: `class`, `name`, `displayName`
+
+Methods: `ownPropertyNames()`, `ownPropertyDescriptor()`, `ownProperties()`, `prototype()`
+
+#### [Tab.Network](https://github.com/harthur/firefox-client/wiki/Network)
+Methods: `startLogging()`, `stopLogging()`, `sendHTTPRequest()`
+
+Events: `"network-event"`
+
+#### [NetworkEvent](https://github.com/harthur/firefox-client/wiki/NetworkEvent)
+Properties: `url`, `method`, `isXHR`
+
+Methods: `getRequestHeaders()`, `getRequestCookies()`, `getRequestPostData()`, `getResponseHeaders()`, `getResponseCookies()`, `getResponseContent()`, `getEventTimings()`
+
+Events: `"request-headers"`, `"request-cookies"`, `"request-postdata"`, `"response-start"`, `"response-headers"`, `"response-cookies"`, `"event-timings"`
+
+#### [Tab.DOM](https://github.com/harthur/firefox-client/wiki/DOM)
+Methods: `document()`, `documentElement()`, `querySelector()`, `querySelectorAll()`
+
+#### [DOMNode](https://github.com/harthur/firefox-client/wiki/DOMNode)
+Properties: `nodeValue`, `nodeName`, `namespaceURI`
+
+Methods: `parentNode()`, `parents()`, `siblings()`, `nextSibling()`, `previousSibling()`, `querySelector()`, `querySelectorAll()`, `innerHTML()`, `outerHTML()`, `setAttribute()`, `remove()`, `release()`
+
+#### [Tab.StyleSheets](https://github.com/harthur/firefox-client/wiki/StyleSheets)
+Methods: `getStyleSheets()`, `addStyleSheet()`
+
+#### [StyleSheet](https://github.com/harthur/firefox-client/wiki/StyleSheet)
+Properties: `href`, `disabled`, `ruleCount`
+
+Methods: `getText()`, `update()`, `toggleDisabled()`, `getOriginalSources()`
+
+Events: `"disabled-changed"`, `"ruleCount-changed"`
+
+#### Tab.Memory
+Methods: `measure()`
+
+#### Webapps
+Methods: `listRunningApps()`, `getInstalledApps()`, `watchApps()`, `unwatchApps()`, `launch()`, `close()`, `getApp()`, `installHosted()`, `installPackaged()`, `installPackagedWithADB()`, `uninstall()`
+
+Events: `"appOpen"`, `"appClose"`, `"appInstall"`, `"appUninstall"`
+
+## Examples
+
+[fxconsole](https://github.com/harthur/fxconsole) - a remote JavaScript console for Firefox
+
+[webapps test script](https://pastebin.mozilla.org/5094843) - a sample usage of all webapps features
+
+## Feedback
+
+What do you need from the API? [File an issue](https://github.com/harthur/firefox-client/issues/new).
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/index.js b/node_modules/node-firefox-connect/node_modules/firefox-client/index.js
new file mode 100644
index 0000000..cbf7a39
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/index.js
@@ -0,0 +1 @@
+module.exports = require("./lib/browser");
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/browser.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/browser.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/browser.js
new file mode 100644
index 0000000..2e52220
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/browser.js
@@ -0,0 +1,123 @@
+var extend = require("./extend"),
+ ClientMethods = require("./client-methods"),
+ Client = require("./client"),
+ Tab = require("./tab"),
+ Webapps = require("./webapps"),
+ Device = require("./device"),
+ SimulatorApps = require("./simulator");
+
+const DEFAULT_PORT = 6000;
+const DEFAULT_HOST = "localhost";
+
+module.exports = FirefoxClient;
+
+function FirefoxClient(options) {
+ var client = new Client(options);
+ var actor = 'root';
+
+ client.on("error", this.onError.bind(this));
+ client.on("end", this.onEnd.bind(this));
+ client.on("timeout", this.onTimeout.bind(this));
+
+ this.initialize(client, actor);
+}
+
+FirefoxClient.prototype = extend(ClientMethods, {
+ connect: function(port, host, cb) {
+ if (typeof port == "function") {
+ // (cb)
+ cb = port;
+ port = DEFAULT_PORT;
+ host = DEFAULT_HOST;
+
+ }
+ if (typeof host == "function") {
+ // (port, cb)
+ cb = host;
+ host = DEFAULT_HOST;
+ }
+ // (port, host, cb)
+
+ this.client.connect(port, host, cb);
+
+ this.client.expectReply(this.actor, function(packet) {
+ // root message
+ });
+ },
+
+ disconnect: function() {
+ this.client.disconnect();
+ },
+
+ onError: function(error) {
+ this.emit("error", error);
+ },
+
+ onEnd: function() {
+ this.emit("end");
+ },
+
+ onTimeout: function() {
+ this.emit("timeout");
+ },
+
+ selectedTab: function(cb) {
+ this.request("listTabs", function(resp) {
+ var tab = resp.tabs[resp.selected];
+ return new Tab(this.client, tab);
+ }.bind(this), cb);
+ },
+
+ listTabs: function(cb) {
+ this.request("listTabs", function(err, resp) {
+ if (err) {
+ return cb(err);
+ }
+
+ if (resp.simulatorWebappsActor) {
+ // the server is the Firefox OS Simulator, return apps as "tabs"
+ var apps = new SimulatorApps(this.client, resp.simulatorWebappsActor);
+ apps.listApps(cb);
+ }
+ else {
+ var tabs = resp.tabs.map(function(tab) {
+ return new Tab(this.client, tab);
+ }.bind(this));
+ cb(null, tabs);
+ }
+ }.bind(this));
+ },
+
+ getWebapps: function(cb) {
+ this.request("listTabs", (function(err, resp) {
+ if (err) {
+ return cb(err);
+ }
+ var webapps = new Webapps(this.client, resp);
+ cb(null, webapps);
+ }).bind(this));
+ },
+
+ getDevice: function(cb) {
+ this.request("listTabs", (function(err, resp) {
+ if (err) {
+ return cb(err);
+ }
+ var device = new Device(this.client, resp);
+ cb(null, device);
+ }).bind(this));
+ },
+
+ getRoot: function(cb) {
+ this.request("listTabs", (function(err, resp) {
+ if (err) {
+ return cb(err);
+ }
+ if (!resp.consoleActor) {
+ return cb("No root actor being available.");
+ }
+ var root = new Tab(this.client, resp);
+ cb(null, root);
+ }).bind(this));
+ }
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/client-methods.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/client-methods.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/client-methods.js
new file mode 100644
index 0000000..c92c44c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/client-methods.js
@@ -0,0 +1,115 @@
+var events = require("events"),
+ extend = require("./extend");
+
+// to be instantiated later - to avoid circular dep resolution
+var JSObject;
+
+var ClientMethods = extend(events.EventEmitter.prototype, {
+ /**
+ * Intialize this client object.
+ *
+ * @param {object} client
+ * Client to send requests on.
+ * @param {string} actor
+ * Actor id to set as 'from' field on requests
+ */
+ initialize: function(client, actor) {
+ this.client = client;
+ this.actor = actor;
+
+ this.client.on('message', function(message) {
+ if (message.from == this.actor) {
+ this.emit(message.type, message);
+ }
+ }.bind(this));
+ },
+
+ /**
+ * Make request to our actor on the server.
+ *
+ * @param {string} type
+ * Method name of the request
+ * @param {object} message
+ * Optional extra properties (arguments to method)
+ * @param {Function} transform
+ * Optional tranform for response object. Takes response object
+ * and returns object to send on.
+ * @param {Function} callback
+ * Callback to call with (maybe transformed) response
+ */
+ request: function(type, message, transform, callback) {
+ if (typeof message == "function") {
+ if (typeof transform == "function") {
+ // (type, trans, cb)
+ callback = transform;
+ transform = message;
+ }
+ else {
+ // (type, cb)
+ callback = message;
+ }
+ message = {};
+ }
+ else if (!callback) {
+ if (!message) {
+ // (type)
+ message = {};
+ }
+ // (type, message, cb)
+ callback = transform;
+ transform = null;
+ }
+
+ message.to = this.actor;
+ message.type = type;
+
+ this.client.makeRequest(message, function(resp) {
+ delete resp.from;
+
+ if (resp.error) {
+ var err = new Error(resp.message);
+ err.name = resp.error;
+
+ callback(err);
+ return;
+ }
+
+ if (transform) {
+ resp = transform(resp);
+ }
+
+ if (callback) {
+ callback(null, resp);
+ }
+ });
+ },
+
+ /*
+ * Transform obj response into a JSObject
+ */
+ createJSObject: function(obj) {
+ if (obj == null) {
+ return;
+ }
+ if (!JSObject) {
+ // circular dependencies
+ JSObject = require("./jsobject");
+ }
+ if (obj.type == "object") {
+ return new JSObject(this.client, obj);
+ }
+ return obj;
+ },
+
+ /**
+ * Create function that plucks out only one value from an object.
+ * Used as the transform function for some responses.
+ */
+ pluck: function(prop) {
+ return function(obj) {
+ return obj[prop];
+ }
+ }
+})
+
+module.exports = ClientMethods;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/client.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/client.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/client.js
new file mode 100644
index 0000000..22b3179
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/client.js
@@ -0,0 +1,246 @@
+var net = require("net"),
+ events = require("events"),
+ extend = require("./extend");
+
+var colors = require("colors");
+
+module.exports = Client;
+
+// this is very unfortunate! and temporary. we can't
+// rely on 'type' property to signify an event, and we
+// need to write clients for each actor to handle differences
+// in actor protocols
+var unsolicitedEvents = {
+ "tabNavigated": "tabNavigated",
+ "styleApplied": "styleApplied",
+ "propertyChange": "propertyChange",
+ "networkEventUpdate": "networkEventUpdate",
+ "networkEvent": "networkEvent",
+ "propertyChange": "propertyChange",
+ "newMutations": "newMutations",
+ "appOpen": "appOpen",
+ "appClose": "appClose",
+ "appInstall": "appInstall",
+ "appUninstall": "appUninstall",
+ "frameUpdate": "frameUpdate"
+};
+
+/**
+ * a Client object handles connecting with a Firefox remote debugging
+ * server instance (e.g. a Firefox instance), plus sending and receiving
+ * packets on that conection using the Firefox remote debugging protocol.
+ *
+ * Important methods:
+ * connect - Create the connection to the server.
+ * makeRequest - Make a request to the server with a JSON message,
+ * and a callback to call with the response.
+ *
+ * Important events:
+ * 'message' - An unsolicited (e.g. not a response to a prior request)
+ * packet has been received. These packets usually describe events.
+ */
+function Client(options) {
+ this.options = options || {};
+
+ this.incoming = new Buffer("");
+
+ this._pendingRequests = [];
+ this._activeRequests = {};
+}
+
+Client.prototype = extend(events.EventEmitter.prototype, {
+ connect: function(port, host, cb) {
+ this.client = net.createConnection({
+ port: port,
+ host: host
+ });
+
+ this.client.on("connect", cb);
+ this.client.on("data", this.onData.bind(this));
+ this.client.on("error", this.onError.bind(this));
+ this.client.on("end", this.onEnd.bind(this));
+ this.client.on("timeout", this.onTimeout.bind(this));
+ },
+
+ disconnect: function() {
+ if (this.client) {
+ this.client.end();
+ }
+ },
+
+ /**
+ * Set a request to be sent to an actor on the server. If the actor
+ * is already handling a request, queue this request until the actor
+ * has responded to the previous request.
+ *
+ * @param {object} request
+ * Message to be JSON-ified and sent to server.
+ * @param {function} callback
+ * Function that's called with the response from the server.
+ */
+ makeRequest: function(request, callback) {
+ this.log("request: " + JSON.stringify(request).green);
+
+ if (!request.to) {
+ var type = request.type || "";
+ throw new Error(type + " request packet has no destination.");
+ }
+ this._pendingRequests.push({ to: request.to,
+ message: request,
+ callback: callback });
+ this._flushRequests();
+ },
+
+ /**
+ * Activate (send) any pending requests to actors that don't have an
+ * active request.
+ */
+ _flushRequests: function() {
+ this._pendingRequests = this._pendingRequests.filter(function(request) {
+ // only one active request per actor at a time
+ if (this._activeRequests[request.to]) {
+ return true;
+ }
+
+ // no active requests for this actor, so activate this one
+ this.sendMessage(request.message);
+ this.expectReply(request.to, request.callback);
+
+ // remove from pending requests
+ return false;
+ }.bind(this));
+ },
+
+ /**
+ * Send a JSON message over the connection to the server.
+ */
+ sendMessage: function(message) {
+ if (!message.to) {
+ throw new Error("No actor specified in request");
+ }
+ if (!this.client) {
+ throw new Error("Not connected, connect() before sending requests");
+ }
+ var str = JSON.stringify(message);
+
+ // message is preceded by byteLength(message):
+ str = (new Buffer(str).length) + ":" + str;
+
+ this.client.write(str);
+ },
+
+ /**
+ * Arrange to hand the next reply from |actor| to |handler|.
+ */
+ expectReply: function(actor, handler) {
+ if (this._activeRequests[actor]) {
+ throw Error("clashing handlers for next reply from " + uneval(actor));
+ }
+ this._activeRequests[actor] = handler;
+ },
+
+ /**
+ * Handler for a new message coming in. It's either an unsolicited event
+ * from the server, or a response to a previous request from the client.
+ */
+ handleMessage: function(message) {
+ if (!message.from) {
+ if (message.error) {
+ throw new Error(message.message);
+ }
+ throw new Error("Server didn't specify an actor: " + JSON.stringify(message));
+ }
+
+ if (!(message.type in unsolicitedEvents)
+ && this._activeRequests[message.from]) {
+ this.log("response: " + JSON.stringify(message).yellow);
+
+ var callback = this._activeRequests[message.from];
+ delete this._activeRequests[message.from];
+
+ callback(message);
+
+ this._flushRequests();
+ }
+ else if (message.type) {
+ // this is an unsolicited event from the server
+ this.log("unsolicited event: ".grey + JSON.stringify(message).grey);
+
+ this.emit('message', message);
+ return;
+ }
+ else {
+ throw new Error("Unexpected packet from actor " + message.from
+ + JSON.stringify(message));
+ }
+ },
+
+ /**
+ * Called when a new data chunk is received on the connection.
+ * Parse data into message(s) and call message handler for any full
+ * messages that are read in.
+ */
+ onData: function(data) {
+ this.incoming = Buffer.concat([this.incoming, data]);
+
+ while(this.readMessage()) {};
+ },
+
+ /**
+ * Parse out and process the next message from the data read from
+ * the connection. Returns true if a full meassage was parsed, false
+ * otherwise.
+ */
+ readMessage: function() {
+ var sep = this.incoming.toString().indexOf(':');
+ if (sep < 0) {
+ return false;
+ }
+
+ // beginning of a message is preceded by byteLength(message) + ":"
+ var count = parseInt(this.incoming.slice(0, sep));
+
+ if (this.incoming.length - (sep + 1) < count) {
+ this.log("no complete response yet".grey);
+ return false;
+ }
+ this.incoming = this.incoming.slice(sep + 1);
+
+ var packet = this.incoming.slice(0, count);
+
+ this.incoming = this.incoming.slice(count);
+
+ var message;
+ try {
+ message = JSON.parse(packet.toString());
+ } catch(e) {
+ throw new Error("Couldn't parse packet from server as JSON " + e
+ + ", message:\n" + packet);
+ }
+ this.handleMessage(message);
+
+ return true;
+ },
+
+ onError: function(error) {
+ var code = error.code ? error.code : error;
+ this.log("connection error: ".red + code.red);
+ this.emit("error", error);
+ },
+
+ onEnd: function() {
+ this.log("connection closed by server".red);
+ this.emit("end");
+ },
+
+ onTimeout: function() {
+ this.log("connection timeout".red);
+ this.emit("timeout");
+ },
+
+ log: function(str) {
+ if (this.options.log) {
+ console.log(str);
+ }
+ }
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/console.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/console.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/console.js
new file mode 100644
index 0000000..3f3dcff
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/console.js
@@ -0,0 +1,107 @@
+var select = require("js-select"),
+ extend = require("./extend"),
+ ClientMethods = require("./client-methods"),
+ JSObject = require("./jsobject");
+
+module.exports = Console;
+
+function Console(client, actor) {
+ this.initialize(client, actor);
+
+ this.on("consoleAPICall", this.onConsoleAPI.bind(this));
+ this.on("pageError", this.onPageError.bind(this));
+}
+
+Console.prototype = extend(ClientMethods, {
+ types: ["PageError", "ConsoleAPI"],
+
+ /**
+ * Response object:
+ * -empty-
+ */
+ startListening: function(cb) {
+ this.request('startListeners', { listeners: this.types }, cb);
+ },
+
+ /**
+ * Response object:
+ * -empty-
+ */
+ stopListening: function(cb) {
+ this.request('stopListeners', { listeners: this.types }, cb);
+ },
+
+ /**
+ * Event object:
+ * level - "log", etc.
+ * filename - file with call
+ * lineNumber - line number of call
+ * functionName - function log called from
+ * timeStamp - ms timestamp of call
+ * arguments - array of the arguments to log call
+ * private -
+ */
+ onConsoleAPI: function(event) {
+ var message = this.transformConsoleCall(event.message);
+
+ this.emit("console-api-call", message);
+ },
+
+ /**
+ * Event object:
+ * errorMessage - string error message
+ * sourceName - file error
+ * lineText
+ * lineNumber - line number of error
+ * columnNumber - column number of error
+ * category - usually "content javascript",
+ * timeStamp - time in ms of error occurance
+ * warning - whether it's a warning
+ * error - whether it's an error
+ * exception - whether it's an exception
+ * strict -
+ * private -
+ */
+ onPageError: function(event) {
+ this.emit("page-error", event.pageError);
+ },
+
+ /**
+ * Response object: array of page error or console call objects.
+ */
+ getCachedLogs: function(cb) {
+ var message = {
+ messageTypes: this.types
+ };
+ this.request('getCachedMessages', message, function(resp) {
+ select(resp, ".messages > *").update(this.transformConsoleCall.bind(this));
+ return resp.messages;
+ }.bind(this), cb);
+ },
+
+ /**
+ * Response object:
+ * -empty-
+ */
+ clearCachedLogs: function(cb) {
+ this.request('clearMessagesCache', cb);
+ },
+
+ /**
+ * Response object:
+ * input - original input
+ * result - result of the evaluation, a value or JSObject
+ * timestamp - timestamp in ms of the evaluation
+ * exception - any exception as a result of the evaluation
+ */
+ evaluateJS: function(text, cb) {
+ this.request('evaluateJS', { text: text }, function(resp) {
+ return select(resp, ".result, .exception")
+ .update(this.createJSObject.bind(this));
+ }.bind(this), cb)
+ },
+
+ transformConsoleCall: function(message) {
+ return select(message, ".arguments > *").update(this.createJSObject.bind(this));
+ }
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/device.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/device.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/device.js
new file mode 100644
index 0000000..6c5da84
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/device.js
@@ -0,0 +1,29 @@
+var extend = require("./extend"),
+ ClientMethods = require("./client-methods");
+
+module.exports = Device;
+
+function Device(client, tab) {
+ this.initialize(client, tab.deviceActor);
+}
+
+Device.prototype = extend(ClientMethods, {
+ getDescription: function(cb) {
+ this.request("getDescription", function(err, resp) {
+ if (err) {
+ return cb(err);
+ }
+
+ cb(null, resp.value);
+ });
+ },
+ getRawPermissionsTable: function(cb) {
+ this.request("getRawPermissionsTable", function(err, resp) {
+ if (err) {
+ return cb(err);
+ }
+
+ cb(null, resp.value.rawPermissionsTable);
+ });
+ }
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/dom.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/dom.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/dom.js
new file mode 100644
index 0000000..a00018c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/dom.js
@@ -0,0 +1,68 @@
+var extend = require("./extend"),
+ ClientMethods = require("./client-methods"),
+ Node = require("./domnode");
+
+module.exports = DOM;
+
+function DOM(client, actor) {
+ this.initialize(client, actor);
+ this.walker = null;
+}
+
+DOM.prototype = extend(ClientMethods, {
+ document: function(cb) {
+ this.walkerRequest("document", function(err, resp) {
+ if (err) return cb(err);
+
+ var node = new Node(this.client, this.walker, resp.node);
+ cb(null, node);
+ }.bind(this))
+ },
+
+ documentElement: function(cb) {
+ this.walkerRequest("documentElement", function(err, resp) {
+ var node = new Node(this.client, this.walker, resp.node);
+ cb(err, node);
+ }.bind(this))
+ },
+
+ querySelector: function(selector, cb) {
+ this.document(function(err, node) {
+ if (err) return cb(err);
+
+ node.querySelector(selector, cb);
+ })
+ },
+
+ querySelectorAll: function(selector, cb) {
+ this.document(function(err, node) {
+ if (err) return cb(err);
+
+ node.querySelectorAll(selector, cb);
+ })
+ },
+
+ walkerRequest: function(type, message, cb) {
+ this.getWalker(function(err, walker) {
+ walker.request(type, message, cb);
+ });
+ },
+
+ getWalker: function(cb) {
+ if (this.walker) {
+ return cb(null, this.walker);
+ }
+ this.request('getWalker', function(err, resp) {
+ this.walker = new Walker(this.client, resp.walker);
+ cb(err, this.walker);
+ }.bind(this))
+ }
+})
+
+function Walker(client, walker) {
+ this.initialize(client, walker.actor);
+
+ this.root = new Node(client, this, walker.root);
+}
+
+Walker.prototype = extend(ClientMethods, {});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/domnode.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/domnode.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/domnode.js
new file mode 100644
index 0000000..e0a55b8
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/domnode.js
@@ -0,0 +1,169 @@
+var extend = require("./extend"),
+ ClientMethods = require("./client-methods");
+
+module.exports = Node;
+
+function Node(client, walker, node) {
+ this.initialize(client, node.actor);
+ this.walker = walker;
+
+ this.getNode = this.getNode.bind(this);
+ this.getNodeArray = this.getNodeArray.bind(this);
+ this.getNodeList = this.getNodeList.bind(this);
+
+ walker.on('newMutations', function(event) {
+ //console.log("on new mutations! ", JSON.stringify(event));
+ });
+
+ ['nodeType', 'nodeName', 'namespaceURI', 'attrs']
+ .forEach(function(attr) {
+ this[attr] = node[attr];
+ }.bind(this));
+}
+
+Node.prototype = extend(ClientMethods, {
+ getAttribute: function(name) {
+ for (var i in this.attrs) {
+ var attr = this.attrs[i];
+ if (attr.name == name) {
+ return attr.value;
+ }
+ }
+ },
+
+ setAttribute: function(name, value, cb) {
+ var mods = [{
+ attributeName: name,
+ newValue: value
+ }];
+ this.request('modifyAttributes', { modifications: mods }, cb);
+ },
+
+ parentNode: function(cb) {
+ this.parents(function(err, nodes) {
+ if (err) {
+ return cb(err);
+ }
+ var node = null;
+ if (nodes.length) {
+ node = nodes[0];
+ }
+ cb(null, node);
+ })
+ },
+
+ parents: function(cb) {
+ this.nodeRequest('parents', this.getNodeArray, cb);
+ },
+
+ children: function(cb) {
+ this.nodeRequest('children', this.getNodeArray, cb);
+ },
+
+ siblings: function(cb) {
+ this.nodeRequest('siblings', this.getNodeArray, cb);
+ },
+
+ nextSibling: function(cb) {
+ this.nodeRequest('nextSibling', this.getNode, cb);
+ },
+
+ previousSibling: function(cb) {
+ this.nodeRequest('previousSibling', this.getNode, cb);
+ },
+
+ querySelector: function(selector, cb) {
+ this.nodeRequest('querySelector', { selector: selector },
+ this.getNode, cb);
+ },
+
+ querySelectorAll: function(selector, cb) {
+ this.nodeRequest('querySelectorAll', { selector: selector },
+ this.getNodeList, cb);
+ },
+
+ innerHTML: function(cb) {
+ this.nodeRequest('innerHTML', function(resp) {
+ return resp.value;
+ }, cb)
+ },
+
+ outerHTML: function(cb) {
+ this.nodeRequest('outerHTML', function(resp) {
+ return resp.value;
+ }, cb)
+ },
+
+ remove: function(cb) {
+ this.nodeRequest('removeNode', function(resp) {
+ return new Node(this.client, this.walker, resp.nextSibling);
+ }.bind(this), cb);
+ },
+
+ highlight: function(cb) {
+ this.nodeRequest('highlight', cb);
+ },
+
+ release: function(cb) {
+ this.nodeRequest('releaseNode', cb);
+ },
+
+ getNode: function(resp) {
+ if (resp.node) {
+ return new Node(this.client, this.walker, resp.node);
+ }
+ return null;
+ },
+
+ getNodeArray: function(resp) {
+ return resp.nodes.map(function(form) {
+ return new Node(this.client, this.walker, form);
+ }.bind(this));
+ },
+
+ getNodeList: function(resp) {
+ return new NodeList(this.client, this.walker, resp.list);
+ },
+
+ nodeRequest: function(type, message, transform, cb) {
+ if (!cb) {
+ cb = transform;
+ transform = message;
+ message = {};
+ }
+ message.node = this.actor;
+
+ this.walker.request(type, message, transform, cb);
+ }
+});
+
+function NodeList(client, walker, list) {
+ this.client = client;
+ this.walker = walker;
+ this.actor = list.actor;
+
+ this.length = list.length;
+}
+
+NodeList.prototype = extend(ClientMethods, {
+ items: function(start, end, cb) {
+ if (typeof start == "function") {
+ cb = start;
+ start = 0;
+ end = this.length;
+ }
+ else if (typeof end == "function") {
+ cb = end;
+ end = this.length;
+ }
+ this.request('items', { start: start, end: end },
+ this.getNodeArray.bind(this), cb);
+ },
+
+ // TODO: add this function to ClientMethods
+ getNodeArray: function(resp) {
+ return resp.nodes.map(function(form) {
+ return new Node(this.client, this.walker, form);
+ }.bind(this));
+ }
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/extend.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/extend.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/extend.js
new file mode 100644
index 0000000..8624103
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/extend.js
@@ -0,0 +1,12 @@
+module.exports = function extend(prototype, properties) {
+ return Object.create(prototype, getOwnPropertyDescriptors(properties));
+}
+
+function getOwnPropertyDescriptors(object) {
+ var names = Object.getOwnPropertyNames(object);
+
+ return names.reduce(function(descriptor, name) {
+ descriptor[name] = Object.getOwnPropertyDescriptor(object, name);
+ return descriptor;
+ }, {});
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/jsobject.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/jsobject.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/jsobject.js
new file mode 100644
index 0000000..907999f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/jsobject.js
@@ -0,0 +1,91 @@
+var select = require("js-select"),
+ extend = require("./extend"),
+ ClientMethods = require("./client-methods");
+
+module.exports = JSObject;
+
+function JSObject(client, obj) {
+ this.initialize(client, obj.actor);
+ this.obj = obj;
+}
+
+JSObject.prototype = extend(ClientMethods, {
+ type: "object",
+
+ get class() {
+ return this.obj.class;
+ },
+
+ get name() {
+ return this.obj.name;
+ },
+
+ get displayName() {
+ return this.obj.displayName;
+ },
+
+ ownPropertyNames: function(cb) {
+ this.request('ownPropertyNames', function(resp) {
+ return resp.ownPropertyNames;
+ }, cb);
+ },
+
+ ownPropertyDescriptor: function(name, cb) {
+ this.request('property', { name: name }, function(resp) {
+ return this.transformDescriptor(resp.descriptor);
+ }.bind(this), cb);
+ },
+
+ ownProperties: function(cb) {
+ this.request('prototypeAndProperties', function(resp) {
+ return this.transformProperties(resp.ownProperties);
+ }.bind(this), cb);
+ },
+
+ prototype: function(cb) {
+ this.request('prototype', function(resp) {
+ return this.createJSObject(resp.prototype);
+ }.bind(this), cb);
+ },
+
+ ownPropertiesAndPrototype: function(cb) {
+ this.request('prototypeAndProperties', function(resp) {
+ resp.ownProperties = this.transformProperties(resp.ownProperties);
+ resp.safeGetterValues = this.transformGetters(resp.safeGetterValues);
+ resp.prototype = this.createJSObject(resp.prototype);
+
+ return resp;
+ }.bind(this), cb);
+ },
+
+ /* helpers */
+ transformProperties: function(props) {
+ var transformed = {};
+ for (var prop in props) {
+ transformed[prop] = this.transformDescriptor(props[prop]);
+ }
+ return transformed;
+ },
+
+ transformGetters: function(getters) {
+ var transformed = {};
+ for (var prop in getters) {
+ transformed[prop] = this.transformGetter(getters[prop]);
+ }
+ return transformed;
+ },
+
+ transformDescriptor: function(descriptor) {
+ descriptor.value = this.createJSObject(descriptor.value);
+ return descriptor;
+ },
+
+ transformGetter: function(getter) {
+ return {
+ value: this.createJSObject(getter.getterValue),
+ prototypeLevel: getter.getterPrototypeLevel,
+ enumerable: getter.enumerable,
+ writable: getter.writable
+ }
+ }
+})
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/memory.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/memory.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/memory.js
new file mode 100644
index 0000000..8468539
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/memory.js
@@ -0,0 +1,16 @@
+var extend = require("./extend"),
+ ClientMethods = require("./client-methods");
+
+module.exports = Memory;
+
+function Memory(client, actor) {
+ this.initialize(client, actor);
+}
+
+Memory.prototype = extend(ClientMethods, {
+ measure: function(cb) {
+ this.request('measure', function (err, resp) {
+ cb(err, resp);
+ });
+ }
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/network.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/network.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/network.js
new file mode 100644
index 0000000..5c1afdb
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/network.js
@@ -0,0 +1,105 @@
+var extend = require("./extend");
+var ClientMethods = require("./client-methods");
+
+module.exports = Network;
+
+function Network(client, actor) {
+ this.initialize(client, actor);
+
+ this.on("networkEvent", this.onNetworkEvent.bind(this));
+}
+
+Network.prototype = extend(ClientMethods, {
+ types: ["NetworkActivity"],
+
+ startLogging: function(cb) {
+ this.request('startListeners', { listeners: this.types }, cb);
+ },
+
+ stopLogging: function(cb) {
+ this.request('stopListeners', { listeners: this.types }, cb);
+ },
+
+ onNetworkEvent: function(event) {
+ var networkEvent = new NetworkEvent(this.client, event.eventActor);
+
+ this.emit("network-event", networkEvent);
+ },
+
+ sendHTTPRequest: function(request, cb) {
+ this.request('sendHTTPRequest', { request: request }, function(resp) {
+ return new NetworkEvent(this.client, resp.eventActor);
+ }.bind(this), cb);
+ }
+})
+
+function NetworkEvent(client, event) {
+ this.initialize(client, event.actor);
+ this.event = event;
+
+ this.on("networkEventUpdate", this.onUpdate.bind(this));
+}
+
+NetworkEvent.prototype = extend(ClientMethods, {
+ get url() {
+ return this.event.url;
+ },
+
+ get method() {
+ return this.event.method;
+ },
+
+ get isXHR() {
+ return this.event.isXHR;
+ },
+
+ getRequestHeaders: function(cb) {
+ this.request('getRequestHeaders', cb);
+ },
+
+ getRequestCookies: function(cb) {
+ this.request('getRequestCookies', this.pluck('cookies'), cb);
+ },
+
+ getRequestPostData: function(cb) {
+ this.request('getRequestPostData', cb);
+ },
+
+ getResponseHeaders: function(cb) {
+ this.request('getResponseHeaders', cb);
+ },
+
+ getResponseCookies: function(cb) {
+ this.request('getResponseCookies', this.pluck('cookies'), cb);
+ },
+
+ getResponseContent: function(cb) {
+ this.request('getResponseContent', cb);
+ },
+
+ getEventTimings: function(cb) {
+ this.request('getEventTimings', cb);
+ },
+
+ onUpdate: function(event) {
+ var types = {
+ "requestHeaders": "request-headers",
+ "requestCookies": "request-cookies",
+ "requestPostData": "request-postdata",
+ "responseStart": "response-start",
+ "responseHeaders": "response-headers",
+ "responseCookies": "response-cookies",
+ "responseContent": "response-content",
+ "eventTimings": "event-timings"
+ }
+
+ var type = types[event.updateType];
+ delete event.updateType;
+
+ this.emit(type, event);
+ }
+})
+
+
+
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/simulator.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/simulator.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/simulator.js
new file mode 100644
index 0000000..4df6a2b
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/simulator.js
@@ -0,0 +1,22 @@
+var extend = require("./extend"),
+ ClientMethods = require("./client-methods"),
+ Tab = require("./tab");
+
+module.exports = SimulatorApps;
+
+function SimulatorApps(client, actor) {
+ this.initialize(client, actor);
+}
+
+SimulatorApps.prototype = extend(ClientMethods, {
+ listApps: function(cb) {
+ this.request('listApps', function(resp) {
+ var apps = [];
+ for (var url in resp.apps) {
+ var app = resp.apps[url];
+ apps.push(new Tab(this.client, app));
+ }
+ return apps;
+ }.bind(this), cb);
+ }
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/stylesheets.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/stylesheets.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/stylesheets.js
new file mode 100644
index 0000000..0677c02
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/stylesheets.js
@@ -0,0 +1,96 @@
+var extend = require("./extend");
+var ClientMethods = require("./client-methods");
+
+module.exports = StyleSheets;
+
+function StyleSheets(client, actor) {
+ this.initialize(client, actor);
+}
+
+StyleSheets.prototype = extend(ClientMethods, {
+ getStyleSheets: function(cb) {
+ this.request('getStyleSheets', function(resp) {
+ return resp.styleSheets.map(function(sheet) {
+ return new StyleSheet(this.client, sheet);
+ }.bind(this));
+ }.bind(this), cb);
+ },
+
+ addStyleSheet: function(text, cb) {
+ this.request('addStyleSheet', { text: text }, function(resp) {
+ return new StyleSheet(this.client, resp.styleSheet);
+ }.bind(this), cb);
+ }
+})
+
+function StyleSheet(client, sheet) {
+ this.initialize(client, sheet.actor);
+ this.sheet = sheet;
+
+ this.on("propertyChange", this.onPropertyChange.bind(this));
+}
+
+StyleSheet.prototype = extend(ClientMethods, {
+ get href() {
+ return this.sheet.href;
+ },
+
+ get disabled() {
+ return this.sheet.disabled;
+ },
+
+ get ruleCount() {
+ return this.sheet.ruleCount;
+ },
+
+ onPropertyChange: function(event) {
+ this.sheet[event.property] = event.value;
+ this.emit(event.property + "-changed", event.value);
+ },
+
+ toggleDisabled: function(cb) {
+ this.request('toggleDisabled', function(err, resp) {
+ if (err) return cb(err);
+
+ this.sheet.disabled = resp.disabled;
+ cb(null, resp.disabled);
+ }.bind(this));
+ },
+
+ getOriginalSources: function(cb) {
+ this.request('getOriginalSources', function(resp) {
+ if (resp.originalSources === null) {
+ return [];
+ }
+ return resp.originalSources.map(function(form) {
+ return new OriginalSource(this.client, form);
+ }.bind(this));
+ }.bind(this), cb);
+ },
+
+ update: function(text, cb) {
+ this.request('update', { text: text, transition: true }, cb);
+ },
+
+ getText: function(cb) {
+ this.request('getText', this.pluck('text'), cb);
+ }
+});
+
+
+function OriginalSource(client, source) {
+ console.log("source", source);
+ this.initialize(client, source.actor);
+
+ this.source = source;
+}
+
+OriginalSource.prototype = extend(ClientMethods, {
+ get url() {
+ return this.source.url
+ },
+
+ getText: function(cb) {
+ this.request('getText', this.pluck('text'), cb);
+ }
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/tab.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/tab.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/tab.js
new file mode 100644
index 0000000..5e19e1c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/tab.js
@@ -0,0 +1,87 @@
+var extend = require("./extend"),
+ ClientMethods = require("./client-methods"),
+ Console = require("./console"),
+ Memory = require("./memory"),
+ DOM = require("./dom"),
+ Network = require("./network"),
+ StyleSheets = require("./stylesheets");
+
+module.exports = Tab;
+
+function Tab(client, tab) {
+ this.initialize(client, tab.actor);
+
+ this.tab = tab;
+ this.updateInfo(tab);
+
+ this.on("tabNavigated", this.onTabNavigated.bind(this));
+}
+
+Tab.prototype = extend(ClientMethods, {
+ updateInfo: function(form) {
+ this.url = form.url;
+ this.title = form.title;
+ },
+
+ get StyleSheets() {
+ if (!this._StyleSheets) {
+ this._StyleSheets = new StyleSheets(this.client, this.tab.styleSheetsActor);
+ }
+ return this._StyleSheets;
+ },
+
+ get DOM() {
+ if (!this._DOM) {
+ this._DOM = new DOM(this.client, this.tab.inspectorActor);
+ }
+ return this._DOM;
+ },
+
+ get Network() {
+ if (!this._Network) {
+ this._Network = new Network(this.client, this.tab.consoleActor);
+ }
+ return this._Network;
+ },
+
+ get Console() {
+ if (!this._Console) {
+ this._Console = new Console(this.client, this.tab.consoleActor);
+ }
+ return this._Console;
+ },
+
+ get Memory() {
+ if (!this._Memory) {
+ this._Memory = new Memory(this.client, this.tab.memoryActor);
+ }
+ return this._Memory;
+ },
+
+ onTabNavigated: function(event) {
+ if (event.state == "start") {
+ this.emit("before-navigate", { url: event.url });
+ }
+ else if (event.state == "stop") {
+ this.updateInfo(event);
+
+ this.emit("navigate", { url: event.url, title: event.title });
+ }
+ },
+
+ attach: function(cb) {
+ this.request("attach", cb);
+ },
+
+ detach: function(cb) {
+ this.request("detach", cb);
+ },
+
+ reload: function(cb) {
+ this.request("reload", cb);
+ },
+
+ navigateTo: function(url, cb) {
+ this.request("navigateTo", { url: url }, cb);
+ }
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/lib/webapps.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/lib/webapps.js b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/webapps.js
new file mode 100644
index 0000000..5ede808
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/lib/webapps.js
@@ -0,0 +1,170 @@
+var extend = require("./extend"),
+ ClientMethods = require("./client-methods"),
+ Tab = require("./tab"),
+ fs = require("fs"),
+ spawn = require("child_process").spawn;
+
+module.exports = Webapps;
+
+var CHUNK_SIZE = 20480;
+
+// Also dispatch appOpen/appClose, appInstall/appUninstall events
+function Webapps(client, tab) {
+ this.initialize(client, tab.webappsActor);
+}
+
+Webapps.prototype = extend(ClientMethods, {
+ watchApps: function(cb) {
+ this.request("watchApps", cb);
+ },
+ unwatchApps: function(cb) {
+ this.request("unwatchApps", cb);
+ },
+ launch: function(manifestURL, cb) {
+ this.request("launch", {manifestURL: manifestURL}, cb);
+ },
+ close: function(manifestURL, cb) {
+ this.request("close", {manifestURL: manifestURL}, cb);
+ },
+ getInstalledApps: function(cb) {
+ this.request("getAll", function (err, resp) {
+ if (err) {
+ cb(err);
+ return;
+ }
+ cb(null, resp.apps);
+ });
+ },
+ listRunningApps: function(cb) {
+ this.request("listRunningApps", function (err, resp) {
+ if (err) {
+ cb(err);
+ return;
+ }
+ cb(null, resp.apps);
+ });
+ },
+ getApp: function(manifestURL, cb) {
+ this.request("getAppActor", {manifestURL: manifestURL}, (function (err, resp) {
+ if (err) {
+ cb(err);
+ return;
+ }
+ var actor = new Tab(this.client, resp.actor);
+ cb(null, actor);
+ }).bind(this));
+ },
+ installHosted: function(options, cb) {
+ this.request(
+ "install",
+ { appId: options.appId,
+ metadata: options.metadata,
+ manifest: options.manifest },
+ function (err, resp) {
+ if (err || resp.error) {
+ cb(err || resp.error);
+ return;
+ }
+ cb(null, resp.appId);
+ });
+ },
+ _upload: function (path, cb) {
+ // First create an upload actor
+ this.request("uploadPackage", function (err, resp) {
+ var actor = resp.actor;
+ fs.readFile(path, function(err, data) {
+ chunk(actor, data);
+ });
+ });
+ // Send push the file chunk by chunk
+ var self = this;
+ var step = 0;
+ function chunk(actor, data) {
+ var i = step++ * CHUNK_SIZE;
+ var m = Math.min(i + CHUNK_SIZE, data.length);
+ var c = "";
+ for(; i < m; i++)
+ c += String.fromCharCode(data[i]);
+ var message = {
+ to: actor,
+ type: "chunk",
+ chunk: c
+ };
+ self.client.makeRequest(message, function(resp) {
+ if (resp.error) {
+ cb(resp);
+ return;
+ }
+ if (i < data.length) {
+ setTimeout(chunk, 0, actor, data);
+ } else {
+ done(actor);
+ }
+ });
+ }
+ // Finally close the upload
+ function done(actor) {
+ var message = {
+ to: actor,
+ type: "done"
+ };
+ self.client.makeRequest(message, function(resp) {
+ if (resp.error) {
+ cb(resp);
+ } else {
+ cb(null, actor, cleanup.bind(null, actor));
+ }
+ });
+ }
+
+ // Remove the temporary uploaded file from the server:
+ function cleanup(actor) {
+ var message = {
+ to: actor,
+ type: "remove"
+ };
+ self.client.makeRequest(message, function () {});
+ }
+ },
+ installPackaged: function(path, appId, cb) {
+ this._upload(path, (function (err, actor, cleanup) {
+ this.request("install", {appId: appId, upload: actor},
+ function (err, resp) {
+ if (err) {
+ cb(err);
+ return;
+ }
+ cb(null, resp.appId);
+ cleanup();
+ });
+ }).bind(this));
+ },
+ installPackagedWithADB: function(path, appId, cb) {
+ var self = this;
+ // First ensure the temporary folder exists
+ function createTemporaryFolder() {
+ var c = spawn("adb", ["shell", "mkdir -p /data/local/tmp/b2g/" + appId], {stdio:"inherit"});
+ c.on("close", uploadPackage);
+ }
+ // then upload the package to the temporary directory
+ function uploadPackage() {
+ var child = spawn("adb", ["push", path, "/data/local/tmp/b2g/" + appId + "/application.zip"], {stdio:"inherit"});
+ child.on("close", installApp);
+ }
+ // finally order the webapps actor to install the app
+ function installApp() {
+ self.request("install", {appId: appId},
+ function (err, resp) {
+ if (err) {
+ cb(err);
+ return;
+ }
+ cb(null, resp.appId);
+ });
+ }
+ createTemporaryFolder();
+ },
+ uninstall: function(manifestURL, cb) {
+ this.request("uninstall", {manifestURL: manifestURL}, cb);
+ }
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/MIT-LICENSE.txt
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/MIT-LICENSE.txt b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/MIT-LICENSE.txt
new file mode 100644
index 0000000..7df0d5e
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/MIT-LICENSE.txt
@@ -0,0 +1,19 @@
+Copyright (c) 2010 Alexis Sellier (cloudhead) , Marak Squires
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/ReadMe.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/ReadMe.md b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/ReadMe.md
new file mode 100644
index 0000000..74acead
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/ReadMe.md
@@ -0,0 +1,30 @@
+<h1>colors.js - get color and style in your node.js console like what</h1>
+
+<img src="http://i.imgur.com/goJdO.png" border = "0"/>
+
+ var sys = require('sys');
+ var colors = require('./colors');
+
+ sys.puts('hello'.green); // outputs green text
+ sys.puts('i like cake and pies'.underline.red) // outputs red underlined text
+ sys.puts('inverse the color'.inverse); // inverses the color
+ sys.puts('OMG Rainbows!'.rainbow); // rainbow (ignores spaces)
+
+<h2>colors and styles!</h2>
+- bold
+- italic
+- underline
+- inverse
+- yellow
+- cyan
+- white
+- magenta
+- green
+- red
+- grey
+- blue
+
+
+### Authors
+
+#### Alexis Sellier (cloudhead) , Marak Squires , Justin Campbell, Dustin Diaz (@ded)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/colors.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/colors.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/colors.js
new file mode 100644
index 0000000..8c1d706
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/colors.js
@@ -0,0 +1,230 @@
+/*
+colors.js
+
+Copyright (c) 2010 Alexis Sellier (cloudhead) , Marak Squires
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*/
+
+exports.mode = "console";
+
+// prototypes the string object to have additional method calls that add terminal colors
+
+var addProperty = function (color, func) {
+ exports[color] = function(str) {
+ return func.apply(str);
+ };
+ String.prototype.__defineGetter__(color, func);
+}
+
+var isHeadless = (typeof module !== 'undefined');
+['bold', 'underline', 'italic', 'inverse', 'grey', 'black', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'].forEach(function (style) {
+
+ // __defineGetter__ at the least works in more browsers
+ // http://robertnyman.com/javascript/javascript-getters-setters.html
+ // Object.defineProperty only works in Chrome
+ addProperty(style, function () {
+ return isHeadless ?
+ stylize(this, style) : // for those running in node (headless environments)
+ this.replace(/( )/, '$1'); // and for those running in browsers:
+ // re: ^ you'd think 'return this' works (but doesn't) so replace coerces the string to be a real string
+ });
+});
+
+// prototypes string with method "rainbow"
+// rainbow will apply a the color spectrum to a string, changing colors every letter
+addProperty('rainbow', function () {
+ if (!isHeadless) {
+ return this.replace(/( )/, '$1');
+ }
+ var rainbowcolors = ['red','yellow','green','blue','magenta']; //RoY G BiV
+ var exploded = this.split("");
+ var i=0;
+ exploded = exploded.map(function(letter) {
+ if (letter==" ") {
+ return letter;
+ }
+ else {
+ return stylize(letter,rainbowcolors[i++ % rainbowcolors.length]);
+ }
+ });
+ return exploded.join("");
+});
+
+function stylize(str, style) {
+ if (exports.mode == 'console') {
+ var styles = {
+ //styles
+ 'bold' : ['\033[1m', '\033[22m'],
+ 'italic' : ['\033[3m', '\033[23m'],
+ 'underline' : ['\033[4m', '\033[24m'],
+ 'inverse' : ['\033[7m', '\033[27m'],
+ //grayscale
+ 'white' : ['\033[37m', '\033[39m'],
+ 'grey' : ['\033[90m', '\033[39m'],
+ 'black' : ['\033[30m', '\033[39m'],
+ //colors
+ 'blue' : ['\033[34m', '\033[39m'],
+ 'cyan' : ['\033[36m', '\033[39m'],
+ 'green' : ['\033[32m', '\033[39m'],
+ 'magenta' : ['\033[35m', '\033[39m'],
+ 'red' : ['\033[31m', '\033[39m'],
+ 'yellow' : ['\033[33m', '\033[39m']
+ };
+ } else if (exports.mode == 'browser') {
+ var styles = {
+ //styles
+ 'bold' : ['<b>', '</b>'],
+ 'italic' : ['<i>', '</i>'],
+ 'underline' : ['<u>', '</u>'],
+ 'inverse' : ['<span style="background-color:black;color:white;">', '</span>'],
+ //grayscale
+ 'white' : ['<span style="color:white;">', '</span>'],
+ 'grey' : ['<span style="color:grey;">', '</span>'],
+ 'black' : ['<span style="color:black;">', '</span>'],
+ //colors
+ 'blue' : ['<span style="color:blue;">', '</span>'],
+ 'cyan' : ['<span style="color:cyan;">', '</span>'],
+ 'green' : ['<span style="color:green;">', '</span>'],
+ 'magenta' : ['<span style="color:magenta;">', '</span>'],
+ 'red' : ['<span style="color:red;">', '</span>'],
+ 'yellow' : ['<span style="color:yellow;">', '</span>']
+ };
+ } else if (exports.mode == 'none') {
+ return str;
+ } else {
+ console.log('unsupported mode, try "browser", "console" or "none"');
+ }
+
+ return styles[style][0] + str + styles[style][1];
+};
+
+// don't summon zalgo
+addProperty('zalgo', function () {
+ return zalgo(this);
+});
+
+// please no
+function zalgo(text, options) {
+ var soul = {
+ "up" : [
+ '̍','̎','̄','̅',
+ '̿','̑','̆','̐',
+ '͒','͗','͑','̇',
+ '̈','̊','͂','̓',
+ '̈','͊','͋','͌',
+ '̃','̂','̌','͐',
+ '̀','́','̋','̏',
+ '̒','̓','̔','̽',
+ '̉','ͣ','ͤ','ͥ',
+ 'ͦ','ͧ','ͨ','ͩ',
+ 'ͪ','ͫ','ͬ','ͭ',
+ 'ͮ','ͯ','̾','͛',
+ '͆','̚'
+ ],
+ "down" : [
+ '̖','̗','̘','̙',
+ '̜','̝','̞','̟',
+ '̠','̤','̥','̦',
+ '̩','̪','̫','̬',
+ '̭','̮','̯','̰',
+ '̱','̲','̳','̹',
+ '̺','̻','̼','ͅ',
+ '͇','͈','͉','͍',
+ '͎','͓','͔','͕',
+ '͖','͙','͚','̣'
+ ],
+ "mid" : [
+ '̕','̛','̀','́',
+ '͘','̡','̢','̧',
+ '̨','̴','̵','̶',
+ '͜','͝','͞',
+ '͟','͠','͢','̸',
+ '̷','͡',' ҉'
+ ]
+ },
+ all = [].concat(soul.up, soul.down, soul.mid),
+ zalgo = {};
+
+ function randomNumber(range) {
+ r = Math.floor(Math.random()*range);
+ return r;
+ };
+
+ function is_char(character) {
+ var bool = false;
+ all.filter(function(i){
+ bool = (i == character);
+ });
+ return bool;
+ }
+
+ function heComes(text, options){
+ result = '';
+ options = options || {};
+ options["up"] = options["up"] || true;
+ options["mid"] = options["mid"] || true;
+ options["down"] = options["down"] || true;
+ options["size"] = options["size"] || "maxi";
+ var counts;
+ text = text.split('');
+ for(var l in text){
+ if(is_char(l)) { continue; }
+ result = result + text[l];
+
+ counts = {"up" : 0, "down" : 0, "mid" : 0};
+
+ switch(options.size) {
+ case 'mini':
+ counts.up = randomNumber(8);
+ counts.min= randomNumber(2);
+ counts.down = randomNumber(8);
+ break;
+ case 'maxi':
+ counts.up = randomNumber(16) + 3;
+ counts.min = randomNumber(4) + 1;
+ counts.down = randomNumber(64) + 3;
+ break;
+ default:
+ counts.up = randomNumber(8) + 1;
+ counts.mid = randomNumber(6) / 2;
+ counts.down= randomNumber(8) + 1;
+ break;
+ }
+
+ var arr = ["up", "mid", "down"];
+ for(var d in arr){
+ var index = arr[d];
+ for (var i = 0 ; i <= counts[index]; i++)
+ {
+ if(options[index]) {
+ result = result + soul[index][randomNumber(soul[index].length)];
+ }
+ }
+ }
+ }
+ return result;
+ };
+ return heComes(text);
+}
+
+addProperty('stripColors', function() {
+ return ("" + this).replace(/\u001b\[\d+m/g,'');
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/example.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/example.html b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/example.html
new file mode 100644
index 0000000..c9cd68c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/example.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html lang="en-us">
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>Colors Example</title>
+ <script src="colors.js"></script>
+ <script type="text/javascript">
+ console.log('Rainbows are fun!'.rainbow);
+ console.log('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse);
+ console.log('Chains are also cool.'.bold.italic.underline.red);
+ </script>
+ </head>
+ <body>
+ <script>
+ document.write('Rainbows are fun!'.rainbow + '<br>');
+ document.write('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse + '<br>');
+ document.write('Chains are also cool.'.bold.italic.underline.red);
+ </script>
+ </body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/example.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/example.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/example.js
new file mode 100644
index 0000000..12d8b1a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/example.js
@@ -0,0 +1,20 @@
+var util = require('util');
+var colors = require('./colors');
+
+//colors.mode = "browser";
+
+var test = colors.red("hopefully colorless output");
+util.puts('Rainbows are fun!'.rainbow);
+util.puts('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
+util.puts('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
+//util.puts('zalgo time!'.zalgo);
+util.puts(test.stripColors);
+util.puts("a".grey + " b".black);
+
+util.puts(colors.rainbow('Rainbows are fun!'));
+util.puts(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported
+util.puts(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported
+//util.puts(colors.zalgo('zalgo time!'));
+util.puts(colors.stripColors(test));
+util.puts(colors.grey("a") + colors.black(" b"));
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/package.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/package.json
new file mode 100644
index 0000000..b0b4f79
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/colors/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "colors",
+ "description": "get colors in your node.js console like what",
+ "version": "0.5.1",
+ "author": {
+ "name": "Marak Squires"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Marak/colors.js.git"
+ },
+ "engines": {
+ "node": ">=0.1.90"
+ },
+ "main": "colors",
+ "_npmJsonOpts": {
+ "file": "/Users/maraksquires/.npm/colors/0.5.1/package/package.json",
+ "wscript": false,
+ "contributors": false,
+ "serverjs": false
+ },
+ "_id": "colors@0.5.1",
+ "dependencies": {},
+ "devDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.0.30",
+ "_nodeVersion": "v0.4.10",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "7d0023eaeb154e8ee9fce75dcb923d0ed1667774",
+ "tarball": "http://registry.npmjs.org/colors/-/colors-0.5.1.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "marak",
+ "email": "marak.squires@gmail.com"
+ }
+ ],
+ "directories": {},
+ "_shasum": "7d0023eaeb154e8ee9fce75dcb923d0ed1667774",
+ "_from": "colors@0.5.x",
+ "_resolved": "https://registry.npmjs.org/colors/-/colors-0.5.1.tgz",
+ "bugs": {
+ "url": "https://github.com/Marak/colors.js/issues"
+ },
+ "readme": "ERROR: No README data found!",
+ "homepage": "https://github.com/Marak/colors.js",
+ "scripts": {}
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/LICENSE b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/LICENSE
new file mode 100644
index 0000000..2983774
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2011 Heather Arthur
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/README.md b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/README.md
new file mode 100644
index 0000000..6c218a4
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/README.md
@@ -0,0 +1,118 @@
+# js-select
+
+js-select uses [js-traverse](https://github.com/substack/js-traverse) to traverse and modify JavaScript object nodes that match [JSONSelect](http://jsonselect.org/) selectors.
+
+```javascript
+var people = {
+ george: {
+ age : 35,
+ movie: "Repo Man"
+ },
+ mary: {
+ age: 15,
+ movie: "Twilight"
+ }
+};
+```
+
+### .forEach(fn)
+
+Iterates over all matching nodes in the object. The callback gets a special `this` context. See [js-traverse](https://github.com/substack/js-traverse) for all the things you can do to modify and inspect the node with this context. In addition, js-select adds a `this.matches()` which will test if the node matches a selector:
+
+```javascript
+select(people).forEach(function(node) {
+ if (this.matches(".mary > .movie")) {
+ this.remove();
+ }
+});
+```
+
+### .nodes()
+
+Returns all matching nodes from the object.
+
+```javascript
+select(people, ".age").nodes(); // [35, 15]
+```
+
+### .remove()
+
+Removes matching elements from the original object.
+
+```javascript
+select(people, ".age").remove();
+```
+
+### .update(fn)
+
+Updates all matching nodes using the given callback.
+
+```javascript
+select(people, ".age").update(function(age) {
+ return age - 5;
+});
+```
+
+### .condense()
+
+Reduces the original object down to only the matching elements (the hierarchy is maintained).
+
+```javascript
+select(people, ".age").condense();
+```
+
+```javascript
+{
+ george: { age: 35 },
+ mary: { age: 15 }
+}
+```
+
+## Selectors
+
+js-select supports the following [JSONSelect](http://jsonselect.org/) selectors:
+
+```
+*
+type
+.key
+ancestor selector
+parent > selector
+sibling ~ selector
+selector1, selector2
+:root
+:nth-child(n)
+:nth-child(even)
+:nth-child(odd)
+:nth-last-child(n)
+:first-child
+:last-child
+:only-child
+:has(selector)
+:val("string")
+:contains("substring")
+```
+
+See [details](http://jsonselect.org/#docs/overview) on each selector, and [try them](http://jsonselect.org/#tryit) out on the JSONSelect website.
+
+## Install
+
+For [node](http://nodejs.org), install with [npm](http://npmjs.org):
+
+```bash
+npm install js-select
+```
+
+For the browser, download the select.js file or fetch the latest version from [npm](http://npmjs.org) and build a browser file using [browserify](https://github.com/substack/node-browserify):
+
+```bash
+npm install browserify -g
+npm install js-select
+
+browserify --require js-select --outfile select.js
+```
+this will build a browser file with `require('js-select')` available.
+
+## Propers
+
+Huge thanks to [@substack](http://github.com/substack) for the ingenious [js-traverse](https://github.com/substack/js-traverse) and [@lloyd](https://github.com/lloyd) for the ingenious [JSONSelect spec](http://http://jsonselect.org/) and [selector parser](http://search.npmjs.org/#/JSONSelect).
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/index.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/index.js
new file mode 100644
index 0000000..1489b8e
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/index.js
@@ -0,0 +1,197 @@
+var traverse = require("traverse"),
+ JSONSelect = require("JSONSelect");
+
+module.exports = function(obj, string) {
+ var sels = parseSelectors(string);
+
+ return {
+ nodes: function() {
+ var nodes = [];
+ this.forEach(function(node) {
+ nodes.push(node);
+ });
+ return nodes;
+ },
+
+ update: function(cb) {
+ this.forEach(function(node) {
+ this.update(typeof cb == "function" ? cb(node) : cb);
+ });
+ return obj;
+ },
+
+ remove: function() {
+ this.forEach(function(node) {
+ this.remove();
+ })
+ return obj;
+ },
+
+ condense: function() {
+ traverse(obj).forEach(function(node) {
+ if (!this.parent) return;
+
+ if (this.parent.keep) {
+ this.keep = true;
+ } else {
+ var match = matchesAny(sels, this);
+ this.keep = match;
+ if (!match) {
+ if (this.isLeaf) {
+ this.remove();
+ } else {
+ this.after(function() {
+ if (this.keep_child) {
+ this.parent.keep_child = true;
+ }
+ if (!this.keep && !this.keep_child) {
+ this.remove();
+ }
+ });
+ }
+ } else {
+ this.parent.keep_child = true;
+ }
+ }
+ });
+ return obj;
+ },
+
+ forEach: function(cb) {
+ traverse(obj).forEach(function(node) {
+ if (matchesAny(sels, this)) {
+ this.matches = function(string) {
+ return matchesAny(parseSelectors(string), this);
+ };
+ // inherit context from js-traverse
+ cb.call(this, node);
+ }
+ });
+ return obj;
+ }
+ };
+}
+
+function parseSelectors(string) {
+ var parsed = JSONSelect._parse(string || "*")[1];
+ return getSelectors(parsed);
+}
+
+function getSelectors(parsed) {
+ if (parsed[0] == ",") { // "selector1, selector2"
+ return parsed.slice(1);
+ }
+ return [parsed];
+}
+
+function matchesAny(sels, context) {
+ for (var i = 0; i < sels.length; i++) {
+ if (matches(sels[i], context)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function matches(sel, context) {
+ var path = context.parents.concat([context]),
+ i = path.length - 1,
+ j = sel.length - 1;
+
+ // walk up the ancestors
+ var must = true;
+ while(j >= 0 && i >= 0) {
+ var part = sel[j],
+ context = path[i];
+
+ if (part == ">") {
+ j--;
+ must = true;
+ continue;
+ }
+
+ if (matchesKey(part, context)) {
+ j--;
+ }
+ else if (must) {
+ return false;
+ }
+
+ i--;
+ must = false;
+ }
+ return j == -1;
+}
+
+function matchesKey(part, context) {
+ var key = context.key,
+ node = context.node,
+ parent = context.parent;
+
+ if (part.id && key != part.id) {
+ return false;
+ }
+ if (part.type) {
+ var type = part.type;
+
+ if (type == "null" && node !== null) {
+ return false;
+ }
+ else if (type == "array" && !isArray(node)) {
+ return false;
+ }
+ else if (type == "object" && (typeof node != "object"
+ || node === null || isArray(node))) {
+ return false;
+ }
+ else if ((type == "boolean" || type == "string" || type == "number")
+ && type != typeof node) {
+ return false;
+ }
+ }
+ if (part.pf == ":nth-child") {
+ var index = parseInt(key) + 1;
+ if ((part.a == 0 && index !== part.b) // :nth-child(i)
+ || (part.a == 1 && !(index >= -part.b)) // :nth-child(n)
+ || (part.a == -1 && !(index <= part.b)) // :nth-child(-n + 1)
+ || (part.a == 2 && index % 2 != part.b)) { // :nth-child(even)
+ return false;
+ }
+ }
+ if (part.pf == ":nth-last-child"
+ && (!parent || key != parent.node.length - part.b)) {
+ return false;
+ }
+ if (part.pc == ":only-child"
+ && (!parent || parent.node.length != 1)) {
+ return false;
+ }
+ if (part.pc == ":root" && key !== undefined) {
+ return false;
+ }
+ if (part.has) {
+ var sels = getSelectors(part.has[0]),
+ match = false;
+ traverse(node).forEach(function(child) {
+ if (matchesAny(sels, this)) {
+ match = true;
+ }
+ });
+ if (!match) {
+ return false;
+ }
+ }
+ if (part.expr) {
+ var expr = part.expr, lhs = expr[0], op = expr[1], rhs = expr[2];
+ if (typeof node != "string"
+ || (!lhs && op == "=" && node != rhs) // :val("str")
+ || (!lhs && op == "*=" && node.indexOf(rhs) == -1)) { // :contains("substr")
+ return false;
+ }
+ }
+ return true;
+}
+
+var isArray = Array.isArray || function(obj) {
+ return toString.call(obj) === '[object Array]';
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[29/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/trackjdwp.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/trackjdwp.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/trackjdwp.js
new file mode 100644
index 0000000..07ec6a9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/trackjdwp.js
@@ -0,0 +1,123 @@
+(function() {
+ var Command, EventEmitter, Parser, Promise, Protocol, TrackJdwpCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ EventEmitter = require('events').EventEmitter;
+
+ Promise = require('bluebird');
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ Parser = require('../../parser');
+
+ TrackJdwpCommand = (function(_super) {
+ var Tracker;
+
+ __extends(TrackJdwpCommand, _super);
+
+ function TrackJdwpCommand() {
+ return TrackJdwpCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ TrackJdwpCommand.prototype.execute = function() {
+ this._send('track-jdwp');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return new Tracker(_this);
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ Tracker = (function(_super1) {
+ __extends(Tracker, _super1);
+
+ function Tracker(command) {
+ this.command = command;
+ this.pids = [];
+ this.pidMap = Object.create(null);
+ this.reader = this.read()["catch"](Parser.PrematureEOFError, (function(_this) {
+ return function(err) {
+ return _this.emit('end');
+ };
+ })(this))["catch"](Promise.CancellationError, (function(_this) {
+ return function(err) {
+ _this.command.connection.end();
+ return _this.emit('end');
+ };
+ })(this))["catch"]((function(_this) {
+ return function(err) {
+ _this.command.connection.end();
+ _this.emit('error', err);
+ return _this.emit('end');
+ };
+ })(this));
+ }
+
+ Tracker.prototype.read = function() {
+ return this.command.parser.readValue().cancellable().then((function(_this) {
+ return function(list) {
+ var maybeEmpty, pids;
+ pids = list.toString().split('\n');
+ if (maybeEmpty = pids.pop()) {
+ pids.push(maybeEmpty);
+ }
+ return _this.update(pids);
+ };
+ })(this));
+ };
+
+ Tracker.prototype.update = function(newList) {
+ var changeSet, newMap, pid, _i, _j, _len, _len1, _ref;
+ changeSet = {
+ removed: [],
+ added: []
+ };
+ newMap = Object.create(null);
+ for (_i = 0, _len = newList.length; _i < _len; _i++) {
+ pid = newList[_i];
+ if (!this.pidMap[pid]) {
+ changeSet.added.push(pid);
+ this.emit('add', pid);
+ newMap[pid] = pid;
+ }
+ }
+ _ref = this.pids;
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
+ pid = _ref[_j];
+ if (!newMap[pid]) {
+ changeSet.removed.push(pid);
+ this.emit('remove', pid);
+ }
+ }
+ this.pids = newList;
+ this.pidMap = newMap;
+ this.emit('changeSet', changeSet, newList);
+ return this;
+ };
+
+ Tracker.prototype.end = function() {
+ this.reader.cancel();
+ return this;
+ };
+
+ return Tracker;
+
+ })(EventEmitter);
+
+ return TrackJdwpCommand;
+
+ })(Command);
+
+ module.exports = TrackJdwpCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/uninstall.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/uninstall.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/uninstall.js
new file mode 100644
index 0000000..0fdb286
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/uninstall.js
@@ -0,0 +1,47 @@
+(function() {
+ var Command, Protocol, UninstallCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ UninstallCommand = (function(_super) {
+ __extends(UninstallCommand, _super);
+
+ function UninstallCommand() {
+ return UninstallCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ UninstallCommand.prototype.execute = function(pkg) {
+ this._send("shell:pm uninstall " + pkg + " 2>/dev/null");
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAscii(7).then(function(reply) {
+ switch (reply) {
+ case 'Success':
+ case 'Failure':
+ return true;
+ default:
+ return _this.parser.unexpected(reply, "'Success' or 'Failure'");
+ }
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, "OKAY or FAIL");
+ }
+ };
+ })(this));
+ };
+
+ return UninstallCommand;
+
+ })(Command);
+
+ module.exports = UninstallCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/usb.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/usb.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/usb.js
new file mode 100644
index 0000000..8c5e797
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/usb.js
@@ -0,0 +1,51 @@
+(function() {
+ var Command, LineTransform, Protocol, UsbCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ LineTransform = require('../../linetransform');
+
+ UsbCommand = (function(_super) {
+ var RE_OK;
+
+ __extends(UsbCommand, _super);
+
+ function UsbCommand() {
+ return UsbCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RE_OK = /restarting in/;
+
+ UsbCommand.prototype.execute = function() {
+ this._send('usb:');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAll().then(function(value) {
+ if (RE_OK.test(value)) {
+ return true;
+ } else {
+ throw new Error(value.toString().trim());
+ }
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return UsbCommand;
+
+ })(Command);
+
+ module.exports = UsbCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/waitbootcomplete.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/waitbootcomplete.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/waitbootcomplete.js
new file mode 100644
index 0000000..739e397
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/waitbootcomplete.js
@@ -0,0 +1,45 @@
+(function() {
+ var Command, Protocol, WaitBootCompleteCommand, debug,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ debug = require('debug')('adb:command:waitboot');
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ WaitBootCompleteCommand = (function(_super) {
+ __extends(WaitBootCompleteCommand, _super);
+
+ function WaitBootCompleteCommand() {
+ return WaitBootCompleteCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ WaitBootCompleteCommand.prototype.execute = function() {
+ this._send('shell:while getprop sys.boot_completed 2>/dev/null; do sleep 1; done');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.searchLine(/^1$/)["finally"](function() {
+ return _this.connection.end();
+ }).then(function() {
+ return true;
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return WaitBootCompleteCommand;
+
+ })(Command);
+
+ module.exports = WaitBootCompleteCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/connect.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/connect.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/connect.js
new file mode 100644
index 0000000..fd9da1c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/connect.js
@@ -0,0 +1,49 @@
+(function() {
+ var Command, ConnectCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ ConnectCommand = (function(_super) {
+ var RE_OK;
+
+ __extends(ConnectCommand, _super);
+
+ function ConnectCommand() {
+ return ConnectCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RE_OK = /connected to|already connected/;
+
+ ConnectCommand.prototype.execute = function(host, port) {
+ this._send("host:connect:" + host + ":" + port);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readValue().then(function(value) {
+ if (RE_OK.test(value)) {
+ return "" + host + ":" + port;
+ } else {
+ throw new Error(value.toString());
+ }
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return ConnectCommand;
+
+ })(Command);
+
+ module.exports = ConnectCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/devices.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/devices.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/devices.js
new file mode 100644
index 0000000..e9d5a46
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/devices.js
@@ -0,0 +1,67 @@
+(function() {
+ var Command, HostDevicesCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ HostDevicesCommand = (function(_super) {
+ __extends(HostDevicesCommand, _super);
+
+ function HostDevicesCommand() {
+ return HostDevicesCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ HostDevicesCommand.prototype.execute = function() {
+ this._send('host:devices');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this._readDevices();
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ HostDevicesCommand.prototype._readDevices = function() {
+ return this.parser.readValue().then((function(_this) {
+ return function(value) {
+ return _this._parseDevices(value);
+ };
+ })(this));
+ };
+
+ HostDevicesCommand.prototype._parseDevices = function(value) {
+ var devices, id, line, type, _i, _len, _ref, _ref1;
+ devices = [];
+ if (!value.length) {
+ return devices;
+ }
+ _ref = value.toString('ascii').split('\n');
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ line = _ref[_i];
+ if (line) {
+ _ref1 = line.split('\t'), id = _ref1[0], type = _ref1[1];
+ devices.push({
+ id: id,
+ type: type
+ });
+ }
+ }
+ return devices;
+ };
+
+ return HostDevicesCommand;
+
+ })(Command);
+
+ module.exports = HostDevicesCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/deviceswithpaths.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/deviceswithpaths.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/deviceswithpaths.js
new file mode 100644
index 0000000..a63cdf1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/deviceswithpaths.js
@@ -0,0 +1,68 @@
+(function() {
+ var Command, HostDevicesWithPathsCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ HostDevicesWithPathsCommand = (function(_super) {
+ __extends(HostDevicesWithPathsCommand, _super);
+
+ function HostDevicesWithPathsCommand() {
+ return HostDevicesWithPathsCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ HostDevicesWithPathsCommand.prototype.execute = function() {
+ this._send('host:devices-l');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this._readDevices();
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ HostDevicesWithPathsCommand.prototype._readDevices = function() {
+ return this.parser.readValue().then((function(_this) {
+ return function(value) {
+ return _this._parseDevices(value);
+ };
+ })(this));
+ };
+
+ HostDevicesWithPathsCommand.prototype._parseDevices = function(value) {
+ var devices, id, line, path, type, _i, _len, _ref, _ref1;
+ devices = [];
+ if (!value.length) {
+ return devices;
+ }
+ _ref = value.toString('ascii').split('\n');
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ line = _ref[_i];
+ if (line) {
+ _ref1 = line.split(/\s+/), id = _ref1[0], type = _ref1[1], path = _ref1[2];
+ devices.push({
+ id: id,
+ type: type,
+ path: path
+ });
+ }
+ }
+ return devices;
+ };
+
+ return HostDevicesWithPathsCommand;
+
+ })(Command);
+
+ module.exports = HostDevicesWithPathsCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/disconnect.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/disconnect.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/disconnect.js
new file mode 100644
index 0000000..9cf978e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/disconnect.js
@@ -0,0 +1,49 @@
+(function() {
+ var Command, DisconnectCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ DisconnectCommand = (function(_super) {
+ var RE_OK;
+
+ __extends(DisconnectCommand, _super);
+
+ function DisconnectCommand() {
+ return DisconnectCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RE_OK = /^$/;
+
+ DisconnectCommand.prototype.execute = function(host, port) {
+ this._send("host:disconnect:" + host + ":" + port);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readValue().then(function(value) {
+ if (RE_OK.test(value)) {
+ return "" + host + ":" + port;
+ } else {
+ throw new Error(value.toString());
+ }
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return DisconnectCommand;
+
+ })(Command);
+
+ module.exports = DisconnectCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/kill.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/kill.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/kill.js
new file mode 100644
index 0000000..74d531c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/kill.js
@@ -0,0 +1,39 @@
+(function() {
+ var Command, HostKillCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ HostKillCommand = (function(_super) {
+ __extends(HostKillCommand, _super);
+
+ function HostKillCommand() {
+ return HostKillCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ HostKillCommand.prototype.execute = function() {
+ this._send('host:kill');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return true;
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return HostKillCommand;
+
+ })(Command);
+
+ module.exports = HostKillCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/trackdevices.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/trackdevices.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/trackdevices.js
new file mode 100644
index 0000000..103793a
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/trackdevices.js
@@ -0,0 +1,43 @@
+(function() {
+ var Command, HostDevicesCommand, HostTrackDevicesCommand, Protocol, Tracker,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ Tracker = require('../../tracker');
+
+ HostDevicesCommand = require('./devices');
+
+ HostTrackDevicesCommand = (function(_super) {
+ __extends(HostTrackDevicesCommand, _super);
+
+ function HostTrackDevicesCommand() {
+ return HostTrackDevicesCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ HostTrackDevicesCommand.prototype.execute = function() {
+ this._send('host:track-devices');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return new Tracker(_this);
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return HostTrackDevicesCommand;
+
+ })(HostDevicesCommand);
+
+ module.exports = HostTrackDevicesCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/transport.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/transport.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/transport.js
new file mode 100644
index 0000000..8264c4f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/transport.js
@@ -0,0 +1,39 @@
+(function() {
+ var Command, HostTransportCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ HostTransportCommand = (function(_super) {
+ __extends(HostTransportCommand, _super);
+
+ function HostTransportCommand() {
+ return HostTransportCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ HostTransportCommand.prototype.execute = function(serial) {
+ this._send("host:transport:" + serial);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return true;
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return HostTransportCommand;
+
+ })(Command);
+
+ module.exports = HostTransportCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/version.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/version.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/version.js
new file mode 100644
index 0000000..48accc1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host/version.js
@@ -0,0 +1,45 @@
+(function() {
+ var Command, HostVersionCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ HostVersionCommand = (function(_super) {
+ __extends(HostVersionCommand, _super);
+
+ function HostVersionCommand() {
+ return HostVersionCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ HostVersionCommand.prototype.execute = function() {
+ this._send('host:version');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readValue().then(function(value) {
+ return _this._parseVersion(value);
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this._parseVersion(reply);
+ }
+ };
+ })(this));
+ };
+
+ HostVersionCommand.prototype._parseVersion = function(version) {
+ return parseInt(version, 16);
+ };
+
+ return HostVersionCommand;
+
+ })(Command);
+
+ module.exports = HostVersionCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/connection.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/connection.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/connection.js
new file mode 100644
index 0000000..bccd503
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/connection.js
@@ -0,0 +1,108 @@
+(function() {
+ var Connection, EventEmitter, Net, Parser, debug, execFile,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Net = require('net');
+
+ debug = require('debug')('adb:connection');
+
+ EventEmitter = require('events').EventEmitter;
+
+ execFile = require('child_process').execFile;
+
+ Parser = require('./parser');
+
+ Connection = (function(_super) {
+ __extends(Connection, _super);
+
+ function Connection(options) {
+ this.options = options;
+ this.socket = null;
+ this.parser = null;
+ this.triedStarting = false;
+ }
+
+ Connection.prototype.connect = function() {
+ this.socket = Net.connect(this.options);
+ this.parser = new Parser(this.socket);
+ this.socket.on('connect', (function(_this) {
+ return function() {
+ return _this.emit('connect');
+ };
+ })(this));
+ this.socket.on('end', (function(_this) {
+ return function() {
+ return _this.emit('end');
+ };
+ })(this));
+ this.socket.on('drain', (function(_this) {
+ return function() {
+ return _this.emit('drain');
+ };
+ })(this));
+ this.socket.on('timeout', (function(_this) {
+ return function() {
+ return _this.emit('timeout');
+ };
+ })(this));
+ this.socket.on('error', (function(_this) {
+ return function(err) {
+ return _this._handleError(err);
+ };
+ })(this));
+ this.socket.on('close', (function(_this) {
+ return function(hadError) {
+ return _this.emit('close', hadError);
+ };
+ })(this));
+ return this;
+ };
+
+ Connection.prototype.end = function() {
+ this.socket.end();
+ return this;
+ };
+
+ Connection.prototype.write = function(data, callback) {
+ this.socket.write(data, callback);
+ return this;
+ };
+
+ Connection.prototype.startServer = function(callback) {
+ debug("Starting ADB server via '" + this.options.bin + " start-server'");
+ return this._exec(['start-server'], {}, callback);
+ };
+
+ Connection.prototype._exec = function(args, options, callback) {
+ debug("CLI: " + this.options.bin + " " + (args.join(' ')));
+ execFile(this.options.bin, args, options, callback);
+ return this;
+ };
+
+ Connection.prototype._handleError = function(err) {
+ if (err.code === 'ECONNREFUSED' && !this.triedStarting) {
+ debug("Connection was refused, let's try starting the server once");
+ this.triedStarting = true;
+ this.startServer((function(_this) {
+ return function(err) {
+ if (err) {
+ return _this._handleError(err);
+ }
+ return _this.connect();
+ };
+ })(this));
+ } else {
+ debug("Connection had an error: " + err.message);
+ this.emit('error', err);
+ this.end();
+ }
+ };
+
+ return Connection;
+
+ })(EventEmitter);
+
+ module.exports = Connection;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/framebuffer/rgbtransform.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/framebuffer/rgbtransform.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/framebuffer/rgbtransform.js
new file mode 100644
index 0000000..e759722
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/framebuffer/rgbtransform.js
@@ -0,0 +1,58 @@
+(function() {
+ var Assert, RgbTransform, Stream,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Assert = require('assert');
+
+ Stream = require('stream');
+
+ RgbTransform = (function(_super) {
+ __extends(RgbTransform, _super);
+
+ function RgbTransform(meta, options) {
+ this.meta = meta;
+ this._buffer = new Buffer('');
+ Assert.ok(this.meta.bpp === 24 || this.meta.bpp === 32, 'Only 24-bit and 32-bit raw images with 8-bits per color are supported');
+ this._r_pos = this.meta.red_offset / 8;
+ this._g_pos = this.meta.green_offset / 8;
+ this._b_pos = this.meta.blue_offset / 8;
+ this._a_pos = this.meta.alpha_offset / 8;
+ this._pixel_bytes = this.meta.bpp / 8;
+ RgbTransform.__super__.constructor.call(this, options);
+ }
+
+ RgbTransform.prototype._transform = function(chunk, encoding, done) {
+ var b, g, r, sourceCursor, target, targetCursor;
+ if (this._buffer.length) {
+ this._buffer = Buffer.concat([this._buffer, chunk], this._buffer.length + chunk.length);
+ } else {
+ this._buffer = chunk;
+ }
+ sourceCursor = 0;
+ targetCursor = 0;
+ target = this._pixel_bytes === 3 ? this._buffer : new Buffer(Math.max(4, chunk.length / this._pixel_bytes * 3));
+ while (this._buffer.length - sourceCursor >= this._pixel_bytes) {
+ r = this._buffer[sourceCursor + this._r_pos];
+ g = this._buffer[sourceCursor + this._g_pos];
+ b = this._buffer[sourceCursor + this._b_pos];
+ target[targetCursor + 0] = r;
+ target[targetCursor + 1] = g;
+ target[targetCursor + 2] = b;
+ sourceCursor += this._pixel_bytes;
+ targetCursor += 3;
+ }
+ if (targetCursor) {
+ this.push(target.slice(0, targetCursor));
+ this._buffer = this._buffer.slice(sourceCursor);
+ }
+ done();
+ };
+
+ return RgbTransform;
+
+ })(Stream.Transform);
+
+ module.exports = RgbTransform;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/keycode.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/keycode.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/keycode.js
new file mode 100644
index 0000000..0ca3c08
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/keycode.js
@@ -0,0 +1,228 @@
+(function() {
+ module.exports = {
+ KEYCODE_UNKNOWN: 0,
+ KEYCODE_SOFT_LEFT: 1,
+ KEYCODE_SOFT_RIGHT: 2,
+ KEYCODE_HOME: 3,
+ KEYCODE_BACK: 4,
+ KEYCODE_CALL: 5,
+ KEYCODE_ENDCALL: 6,
+ KEYCODE_0: 7,
+ KEYCODE_1: 8,
+ KEYCODE_2: 9,
+ KEYCODE_3: 10,
+ KEYCODE_4: 11,
+ KEYCODE_5: 12,
+ KEYCODE_6: 13,
+ KEYCODE_7: 14,
+ KEYCODE_8: 15,
+ KEYCODE_9: 16,
+ KEYCODE_STAR: 17,
+ KEYCODE_POUND: 18,
+ KEYCODE_DPAD_UP: 19,
+ KEYCODE_DPAD_DOWN: 20,
+ KEYCODE_DPAD_LEFT: 21,
+ KEYCODE_DPAD_RIGHT: 22,
+ KEYCODE_DPAD_CENTER: 23,
+ KEYCODE_VOLUME_UP: 24,
+ KEYCODE_VOLUME_DOWN: 25,
+ KEYCODE_POWER: 26,
+ KEYCODE_CAMERA: 27,
+ KEYCODE_CLEAR: 28,
+ KEYCODE_A: 29,
+ KEYCODE_B: 30,
+ KEYCODE_C: 31,
+ KEYCODE_D: 32,
+ KEYCODE_E: 33,
+ KEYCODE_F: 34,
+ KEYCODE_G: 35,
+ KEYCODE_H: 36,
+ KEYCODE_I: 37,
+ KEYCODE_J: 38,
+ KEYCODE_K: 39,
+ KEYCODE_L: 40,
+ KEYCODE_M: 41,
+ KEYCODE_N: 42,
+ KEYCODE_O: 43,
+ KEYCODE_P: 44,
+ KEYCODE_Q: 45,
+ KEYCODE_R: 46,
+ KEYCODE_S: 47,
+ KEYCODE_T: 48,
+ KEYCODE_U: 49,
+ KEYCODE_V: 50,
+ KEYCODE_W: 51,
+ KEYCODE_X: 52,
+ KEYCODE_Y: 53,
+ KEYCODE_Z: 54,
+ KEYCODE_COMMA: 55,
+ KEYCODE_PERIOD: 56,
+ KEYCODE_ALT_LEFT: 57,
+ KEYCODE_ALT_RIGHT: 58,
+ KEYCODE_SHIFT_LEFT: 59,
+ KEYCODE_SHIFT_RIGHT: 60,
+ KEYCODE_TAB: 61,
+ KEYCODE_SPACE: 62,
+ KEYCODE_SYM: 63,
+ KEYCODE_EXPLORER: 64,
+ KEYCODE_ENVELOPE: 65,
+ KEYCODE_ENTER: 66,
+ KEYCODE_DEL: 67,
+ KEYCODE_GRAVE: 68,
+ KEYCODE_MINUS: 69,
+ KEYCODE_EQUALS: 70,
+ KEYCODE_LEFT_BRACKET: 71,
+ KEYCODE_RIGHT_BRACKET: 72,
+ KEYCODE_BACKSLASH: 73,
+ KEYCODE_SEMICOLON: 74,
+ KEYCODE_APOSTROPHE: 75,
+ KEYCODE_SLASH: 76,
+ KEYCODE_AT: 77,
+ KEYCODE_NUM: 78,
+ KEYCODE_HEADSETHOOK: 79,
+ KEYCODE_FOCUS: 80,
+ KEYCODE_PLUS: 81,
+ KEYCODE_MENU: 82,
+ KEYCODE_NOTIFICATION: 83,
+ KEYCODE_SEARCH: 84,
+ KEYCODE_MEDIA_PLAY_PAUSE: 85,
+ KEYCODE_MEDIA_STOP: 86,
+ KEYCODE_MEDIA_NEXT: 87,
+ KEYCODE_MEDIA_PREVIOUS: 88,
+ KEYCODE_MEDIA_REWIND: 89,
+ KEYCODE_MEDIA_FAST_FORWARD: 90,
+ KEYCODE_MUTE: 91,
+ KEYCODE_PAGE_UP: 92,
+ KEYCODE_PAGE_DOWN: 93,
+ KEYCODE_PICTSYMBOLS: 94,
+ KEYCODE_SWITCH_CHARSET: 95,
+ KEYCODE_BUTTON_A: 96,
+ KEYCODE_BUTTON_B: 97,
+ KEYCODE_BUTTON_C: 98,
+ KEYCODE_BUTTON_X: 99,
+ KEYCODE_BUTTON_Y: 100,
+ KEYCODE_BUTTON_Z: 101,
+ KEYCODE_BUTTON_L1: 102,
+ KEYCODE_BUTTON_R1: 103,
+ KEYCODE_BUTTON_L2: 104,
+ KEYCODE_BUTTON_R2: 105,
+ KEYCODE_BUTTON_THUMBL: 106,
+ KEYCODE_BUTTON_THUMBR: 107,
+ KEYCODE_BUTTON_START: 108,
+ KEYCODE_BUTTON_SELECT: 109,
+ KEYCODE_BUTTON_MODE: 110,
+ KEYCODE_ESCAPE: 111,
+ KEYCODE_FORWARD_DEL: 112,
+ KEYCODE_CTRL_LEFT: 113,
+ KEYCODE_CTRL_RIGHT: 114,
+ KEYCODE_CAPS_LOCK: 115,
+ KEYCODE_SCROLL_LOCK: 116,
+ KEYCODE_META_LEFT: 117,
+ KEYCODE_META_RIGHT: 118,
+ KEYCODE_FUNCTION: 119,
+ KEYCODE_SYSRQ: 120,
+ KEYCODE_BREAK: 121,
+ KEYCODE_MOVE_HOME: 122,
+ KEYCODE_MOVE_END: 123,
+ KEYCODE_INSERT: 124,
+ KEYCODE_FORWARD: 125,
+ KEYCODE_MEDIA_PLAY: 126,
+ KEYCODE_MEDIA_PAUSE: 127,
+ KEYCODE_MEDIA_CLOSE: 128,
+ KEYCODE_MEDIA_EJECT: 129,
+ KEYCODE_MEDIA_RECORD: 130,
+ KEYCODE_F1: 131,
+ KEYCODE_F2: 132,
+ KEYCODE_F3: 133,
+ KEYCODE_F4: 134,
+ KEYCODE_F5: 135,
+ KEYCODE_F6: 136,
+ KEYCODE_F7: 137,
+ KEYCODE_F8: 138,
+ KEYCODE_F9: 139,
+ KEYCODE_F10: 140,
+ KEYCODE_F11: 141,
+ KEYCODE_F12: 142,
+ KEYCODE_NUM_LOCK: 143,
+ KEYCODE_NUMPAD_0: 144,
+ KEYCODE_NUMPAD_1: 145,
+ KEYCODE_NUMPAD_2: 146,
+ KEYCODE_NUMPAD_3: 147,
+ KEYCODE_NUMPAD_4: 148,
+ KEYCODE_NUMPAD_5: 149,
+ KEYCODE_NUMPAD_6: 150,
+ KEYCODE_NUMPAD_7: 151,
+ KEYCODE_NUMPAD_8: 152,
+ KEYCODE_NUMPAD_9: 153,
+ KEYCODE_NUMPAD_DIVIDE: 154,
+ KEYCODE_NUMPAD_MULTIPLY: 155,
+ KEYCODE_NUMPAD_SUBTRACT: 156,
+ KEYCODE_NUMPAD_ADD: 157,
+ KEYCODE_NUMPAD_DOT: 158,
+ KEYCODE_NUMPAD_COMMA: 159,
+ KEYCODE_NUMPAD_ENTER: 160,
+ KEYCODE_NUMPAD_EQUALS: 161,
+ KEYCODE_NUMPAD_LEFT_PAREN: 162,
+ KEYCODE_NUMPAD_RIGHT_PAREN: 163,
+ KEYCODE_VOLUME_MUTE: 164,
+ KEYCODE_INFO: 165,
+ KEYCODE_CHANNEL_UP: 166,
+ KEYCODE_CHANNEL_DOWN: 167,
+ KEYCODE_ZOOM_IN: 168,
+ KEYCODE_ZOOM_OUT: 169,
+ KEYCODE_TV: 170,
+ KEYCODE_WINDOW: 171,
+ KEYCODE_GUIDE: 172,
+ KEYCODE_DVR: 173,
+ KEYCODE_BOOKMARK: 174,
+ KEYCODE_CAPTIONS: 175,
+ KEYCODE_SETTINGS: 176,
+ KEYCODE_TV_POWER: 177,
+ KEYCODE_TV_INPUT: 178,
+ KEYCODE_STB_POWER: 179,
+ KEYCODE_STB_INPUT: 180,
+ KEYCODE_AVR_POWER: 181,
+ KEYCODE_AVR_INPUT: 182,
+ KEYCODE_PROG_RED: 183,
+ KEYCODE_PROG_GREEN: 184,
+ KEYCODE_PROG_YELLOW: 185,
+ KEYCODE_PROG_BLUE: 186,
+ KEYCODE_APP_SWITCH: 187,
+ KEYCODE_BUTTON_1: 188,
+ KEYCODE_BUTTON_2: 189,
+ KEYCODE_BUTTON_3: 190,
+ KEYCODE_BUTTON_4: 191,
+ KEYCODE_BUTTON_5: 192,
+ KEYCODE_BUTTON_6: 193,
+ KEYCODE_BUTTON_7: 194,
+ KEYCODE_BUTTON_8: 195,
+ KEYCODE_BUTTON_9: 196,
+ KEYCODE_BUTTON_10: 197,
+ KEYCODE_BUTTON_11: 198,
+ KEYCODE_BUTTON_12: 199,
+ KEYCODE_BUTTON_13: 200,
+ KEYCODE_BUTTON_14: 201,
+ KEYCODE_BUTTON_15: 202,
+ KEYCODE_BUTTON_16: 203,
+ KEYCODE_LANGUAGE_SWITCH: 204,
+ KEYCODE_MANNER_MODE: 205,
+ KEYCODE_3D_MODE: 206,
+ KEYCODE_CONTACTS: 207,
+ KEYCODE_CALENDAR: 208,
+ KEYCODE_MUSIC: 209,
+ KEYCODE_CALCULATOR: 210,
+ KEYCODE_ZENKAKU_HANKAKU: 211,
+ KEYCODE_EISU: 212,
+ KEYCODE_MUHENKAN: 213,
+ KEYCODE_HENKAN: 214,
+ KEYCODE_KATAKANA_HIRAGANA: 215,
+ KEYCODE_YEN: 216,
+ KEYCODE_RO: 217,
+ KEYCODE_KANA: 218,
+ KEYCODE_ASSIST: 219,
+ KEYCODE_BRIGHTNESS_DOWN: 220,
+ KEYCODE_BRIGHTNESS_UP: 221,
+ KEYCODE_MEDIA_AUDIO_TRACK: 222
+ };
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/linetransform.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/linetransform.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/linetransform.js
new file mode 100644
index 0000000..05efce1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/linetransform.js
@@ -0,0 +1,58 @@
+(function() {
+ var LineTransform, Stream,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Stream = require('stream');
+
+ LineTransform = (function(_super) {
+ __extends(LineTransform, _super);
+
+ function LineTransform(options) {
+ this.savedR = null;
+ LineTransform.__super__.constructor.call(this, options);
+ }
+
+ LineTransform.prototype._transform = function(chunk, encoding, done) {
+ var hi, last, lo;
+ lo = 0;
+ hi = 0;
+ if (this.savedR) {
+ if (chunk[0] !== 0x0a) {
+ this.push(this.savedR);
+ }
+ this.savedR = null;
+ }
+ last = chunk.length - 1;
+ while (hi <= last) {
+ if (chunk[hi] === 0x0d) {
+ if (hi === last) {
+ this.savedR = chunk.slice(last);
+ break;
+ } else if (chunk[hi + 1] === 0x0a) {
+ this.push(chunk.slice(lo, hi));
+ lo = hi + 1;
+ }
+ }
+ hi += 1;
+ }
+ if (hi !== lo) {
+ this.push(chunk.slice(lo, hi));
+ }
+ done();
+ };
+
+ LineTransform.prototype._flush = function(done) {
+ if (this.savedR) {
+ this.push(this.savedR);
+ }
+ return done();
+ };
+
+ return LineTransform;
+
+ })(Stream.Transform);
+
+ module.exports = LineTransform;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/parser.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/parser.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/parser.js
new file mode 100644
index 0000000..65c50f6
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/parser.js
@@ -0,0 +1,247 @@
+(function() {
+ var Parser, Promise, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Promise = require('bluebird');
+
+ Protocol = require('./protocol');
+
+ Parser = (function() {
+ Parser.FailError = (function(_super) {
+ __extends(FailError, _super);
+
+ function FailError(message) {
+ Error.call(this);
+ this.name = 'FailError';
+ this.message = "Failure: '" + message + "'";
+ Error.captureStackTrace(this, Parser.FailError);
+ }
+
+ return FailError;
+
+ })(Error);
+
+ Parser.PrematureEOFError = (function(_super) {
+ __extends(PrematureEOFError, _super);
+
+ function PrematureEOFError(howManyMissing) {
+ Error.call(this);
+ this.name = 'PrematureEOFError';
+ this.message = "Premature end of stream, needed " + howManyMissing + " more bytes";
+ this.missingBytes = howManyMissing;
+ Error.captureStackTrace(this, Parser.PrematureEOFError);
+ }
+
+ return PrematureEOFError;
+
+ })(Error);
+
+ Parser.UnexpectedDataError = (function(_super) {
+ __extends(UnexpectedDataError, _super);
+
+ function UnexpectedDataError(unexpected, expected) {
+ Error.call(this);
+ this.name = 'UnexpectedDataError';
+ this.message = "Unexpected '" + unexpected + "', was expecting " + expected;
+ this.unexpected = unexpected;
+ this.expected = expected;
+ Error.captureStackTrace(this, Parser.UnexpectedDataError);
+ }
+
+ return UnexpectedDataError;
+
+ })(Error);
+
+ function Parser(stream) {
+ this.stream = stream;
+ }
+
+ Parser.prototype.raw = function() {
+ return this.stream;
+ };
+
+ Parser.prototype.readAll = function() {
+ var all, endListener, errorListener, resolver, tryRead;
+ all = new Buffer(0);
+ resolver = Promise.defer();
+ tryRead = (function(_this) {
+ return function() {
+ var chunk, _results;
+ _results = [];
+ while (chunk = _this.stream.read()) {
+ _results.push(all = Buffer.concat([all, chunk]));
+ }
+ return _results;
+ };
+ })(this);
+ this.stream.on('readable', tryRead);
+ this.stream.on('error', errorListener = function(err) {
+ return resolver.reject(err);
+ });
+ this.stream.on('end', endListener = function() {
+ return resolver.resolve(all);
+ });
+ tryRead();
+ return resolver.promise.cancellable()["finally"]((function(_this) {
+ return function() {
+ _this.stream.removeListener('readable', tryRead);
+ _this.stream.removeListener('error', errorListener);
+ return _this.stream.removeListener('end', endListener);
+ };
+ })(this));
+ };
+
+ Parser.prototype.readAscii = function(howMany) {
+ return this.readBytes(howMany).then(function(chunk) {
+ return chunk.toString('ascii');
+ });
+ };
+
+ Parser.prototype.readBytes = function(howMany) {
+ var endListener, errorListener, resolver, tryRead;
+ resolver = Promise.defer();
+ tryRead = (function(_this) {
+ return function() {
+ var chunk;
+ if (howMany) {
+ if (chunk = _this.stream.read(howMany)) {
+ howMany -= chunk.length;
+ if (howMany === 0) {
+ return resolver.resolve(chunk);
+ }
+ }
+ } else {
+ return resolver.resolve(new Buffer(0));
+ }
+ };
+ })(this);
+ endListener = function() {
+ return resolver.reject(new Parser.PrematureEOFError(howMany));
+ };
+ errorListener = function(err) {
+ return resolver.reject(err);
+ };
+ this.stream.on('readable', tryRead);
+ this.stream.on('error', errorListener);
+ this.stream.on('end', endListener);
+ tryRead();
+ return resolver.promise.cancellable()["finally"]((function(_this) {
+ return function() {
+ _this.stream.removeListener('readable', tryRead);
+ _this.stream.removeListener('error', errorListener);
+ return _this.stream.removeListener('end', endListener);
+ };
+ })(this));
+ };
+
+ Parser.prototype.readByteFlow = function(howMany) {
+ var endListener, errorListener, resolver, tryRead;
+ resolver = Promise.defer();
+ tryRead = (function(_this) {
+ return function() {
+ var chunk, _results;
+ if (howMany) {
+ _results = [];
+ while (chunk = _this.stream.read(howMany) || _this.stream.read()) {
+ howMany -= chunk.length;
+ if (howMany === 0) {
+ resolver.progress(chunk);
+ resolver.resolve();
+ break;
+ }
+ _results.push(resolver.progress(chunk));
+ }
+ return _results;
+ } else {
+ return resolver.resolve();
+ }
+ };
+ })(this);
+ endListener = function() {
+ return resolver.reject(new Parser.PrematureEOFError(howMany));
+ };
+ errorListener = function(err) {
+ return resolver.reject(err);
+ };
+ this.stream.on('readable', tryRead);
+ this.stream.on('error', errorListener);
+ this.stream.on('end', endListener);
+ tryRead();
+ return resolver.promise.cancellable()["finally"]((function(_this) {
+ return function() {
+ _this.stream.removeListener('readable', tryRead);
+ _this.stream.removeListener('error', errorListener);
+ return _this.stream.removeListener('end', endListener);
+ };
+ })(this));
+ };
+
+ Parser.prototype.readError = function() {
+ return this.readValue().then(function(value) {
+ return Promise.reject(new Parser.FailError(value.toString()));
+ });
+ };
+
+ Parser.prototype.readValue = function() {
+ return this.readAscii(4).then((function(_this) {
+ return function(value) {
+ var length;
+ length = Protocol.decodeLength(value);
+ return _this.readBytes(length);
+ };
+ })(this));
+ };
+
+ Parser.prototype.readUntil = function(code) {
+ var read, skipped;
+ skipped = new Buffer(0);
+ read = (function(_this) {
+ return function() {
+ return _this.readBytes(1).then(function(chunk) {
+ if (chunk[0] === code) {
+ return skipped;
+ } else {
+ skipped = Buffer.concat([skipped, chunk]);
+ return read();
+ }
+ });
+ };
+ })(this);
+ return read();
+ };
+
+ Parser.prototype.searchLine = function(re) {
+ return this.readLine().then((function(_this) {
+ return function(line) {
+ var match;
+ if (match = re.exec(line)) {
+ return match;
+ } else {
+ return _this.searchLine(re);
+ }
+ };
+ })(this));
+ };
+
+ Parser.prototype.readLine = function() {
+ return this.readUntil(0x0a).then(function(line) {
+ if (line[line.length - 1] === 0x0d) {
+ return line.slice(0, -1);
+ } else {
+ return line;
+ }
+ });
+ };
+
+ Parser.prototype.unexpected = function(data, expected) {
+ return Promise.reject(new Parser.UnexpectedDataError(data, expected));
+ };
+
+ return Parser;
+
+ })();
+
+ module.exports = Parser;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/proc/stat.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/proc/stat.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/proc/stat.js
new file mode 100644
index 0000000..76ac4e9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/proc/stat.js
@@ -0,0 +1,140 @@
+(function() {
+ var EventEmitter, Parser, ProcStat, split,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ EventEmitter = require('events').EventEmitter;
+
+ split = require('split');
+
+ Parser = require('../parser');
+
+ ProcStat = (function(_super) {
+ var RE_COLSEP, RE_CPULINE;
+
+ __extends(ProcStat, _super);
+
+ RE_CPULINE = /^cpu[0-9]+ .*$/mg;
+
+ RE_COLSEP = /\ +/g;
+
+ function ProcStat(sync) {
+ this.sync = sync;
+ this.interval = 1000;
+ this.stats = this._emptyStats();
+ this._ignore = {};
+ this._timer = setInterval((function(_this) {
+ return function() {
+ return _this.update();
+ };
+ })(this), this.interval);
+ this.update();
+ }
+
+ ProcStat.prototype.end = function() {
+ clearInterval(this._timer);
+ this.sync.end();
+ return this.sync = null;
+ };
+
+ ProcStat.prototype.update = function() {
+ return new Parser(this.sync.pull('/proc/stat')).readAll().then((function(_this) {
+ return function(out) {
+ return _this._parse(out);
+ };
+ })(this))["catch"]((function(_this) {
+ return function(err) {
+ _this._error(err);
+ };
+ })(this));
+ };
+
+ ProcStat.prototype._parse = function(out) {
+ var cols, line, match, stats, total, type, val, _i, _len;
+ stats = this._emptyStats();
+ while (match = RE_CPULINE.exec(out)) {
+ line = match[0];
+ cols = line.split(RE_COLSEP);
+ type = cols.shift();
+ if (this._ignore[type] === line) {
+ continue;
+ }
+ total = 0;
+ for (_i = 0, _len = cols.length; _i < _len; _i++) {
+ val = cols[_i];
+ total += +val;
+ }
+ stats.cpus[type] = {
+ line: line,
+ user: +cols[0] || 0,
+ nice: +cols[1] || 0,
+ system: +cols[2] || 0,
+ idle: +cols[3] || 0,
+ iowait: +cols[4] || 0,
+ irq: +cols[5] || 0,
+ softirq: +cols[6] || 0,
+ steal: +cols[7] || 0,
+ guest: +cols[8] || 0,
+ guestnice: +cols[9] || 0,
+ total: total
+ };
+ }
+ return this._set(stats);
+ };
+
+ ProcStat.prototype._set = function(stats) {
+ var cur, found, id, loads, m, old, ticks, _ref;
+ loads = {};
+ found = false;
+ _ref = stats.cpus;
+ for (id in _ref) {
+ cur = _ref[id];
+ old = this.stats.cpus[id];
+ if (!old) {
+ continue;
+ }
+ ticks = cur.total - old.total;
+ if (ticks > 0) {
+ found = true;
+ m = 100 / ticks;
+ loads[id] = {
+ user: Math.floor(m * (cur.user - old.user)),
+ nice: Math.floor(m * (cur.nice - old.nice)),
+ system: Math.floor(m * (cur.system - old.system)),
+ idle: Math.floor(m * (cur.idle - old.idle)),
+ iowait: Math.floor(m * (cur.iowait - old.iowait)),
+ irq: Math.floor(m * (cur.irq - old.irq)),
+ softirq: Math.floor(m * (cur.softirq - old.softirq)),
+ steal: Math.floor(m * (cur.steal - old.steal)),
+ guest: Math.floor(m * (cur.guest - old.guest)),
+ guestnice: Math.floor(m * (cur.guestnice - old.guestnice)),
+ total: 100
+ };
+ } else {
+ this._ignore[id] = cur.line;
+ delete stats.cpus[id];
+ }
+ }
+ if (found) {
+ this.emit('load', loads);
+ }
+ return this.stats = stats;
+ };
+
+ ProcStat.prototype._error = function(err) {
+ return this.emit('error', err);
+ };
+
+ ProcStat.prototype._emptyStats = function() {
+ return {
+ cpus: {}
+ };
+ };
+
+ return ProcStat;
+
+ })(EventEmitter);
+
+ module.exports = ProcStat;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/protocol.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/protocol.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/protocol.js
new file mode 100644
index 0000000..72ac5f3
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/protocol.js
@@ -0,0 +1,48 @@
+(function() {
+ var Protocol;
+
+ Protocol = (function() {
+ function Protocol() {}
+
+ Protocol.OKAY = 'OKAY';
+
+ Protocol.FAIL = 'FAIL';
+
+ Protocol.STAT = 'STAT';
+
+ Protocol.LIST = 'LIST';
+
+ Protocol.DENT = 'DENT';
+
+ Protocol.RECV = 'RECV';
+
+ Protocol.DATA = 'DATA';
+
+ Protocol.DONE = 'DONE';
+
+ Protocol.SEND = 'SEND';
+
+ Protocol.QUIT = 'QUIT';
+
+ Protocol.decodeLength = function(length) {
+ return parseInt(length, 16);
+ };
+
+ Protocol.encodeLength = function(length) {
+ return ('0000' + length.toString(16)).slice(-4).toUpperCase();
+ };
+
+ Protocol.encodeData = function(data) {
+ if (!Buffer.isBuffer(data)) {
+ data = new Buffer(data);
+ }
+ return Buffer.concat([new Buffer(Protocol.encodeLength(data.length)), data]);
+ };
+
+ return Protocol;
+
+ })();
+
+ module.exports = Protocol;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync.js
new file mode 100644
index 0000000..8c157a9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync.js
@@ -0,0 +1,337 @@
+(function() {
+ var Entry, EventEmitter, Fs, Path, Promise, Protocol, PullTransfer, PushTransfer, Stats, Sync, debug,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Fs = require('fs');
+
+ Path = require('path');
+
+ Promise = require('bluebird');
+
+ EventEmitter = require('events').EventEmitter;
+
+ debug = require('debug')('adb:sync');
+
+ Protocol = require('./protocol');
+
+ Stats = require('./sync/stats');
+
+ Entry = require('./sync/entry');
+
+ PushTransfer = require('./sync/pushtransfer');
+
+ PullTransfer = require('./sync/pulltransfer');
+
+ Sync = (function(_super) {
+ var DATA_MAX_LENGTH, DEFAULT_CHMOD, TEMP_PATH;
+
+ __extends(Sync, _super);
+
+ TEMP_PATH = '/data/local/tmp';
+
+ DEFAULT_CHMOD = 0x1a4;
+
+ DATA_MAX_LENGTH = 65536;
+
+ Sync.temp = function(path) {
+ return "" + TEMP_PATH + "/" + (Path.basename(path));
+ };
+
+ function Sync(connection) {
+ this.connection = connection;
+ this.parser = this.connection.parser;
+ }
+
+ Sync.prototype.stat = function(path, callback) {
+ this._sendCommandWithArg(Protocol.STAT, path);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.STAT:
+ return _this.parser.readBytes(12).then(function(stat) {
+ var mode, mtime, size;
+ mode = stat.readUInt32LE(0);
+ size = stat.readUInt32LE(4);
+ mtime = stat.readUInt32LE(8);
+ if (mode === 0) {
+ return _this._enoent(path);
+ } else {
+ return new Stats(mode, size, mtime);
+ }
+ });
+ case Protocol.FAIL:
+ return _this._readError();
+ default:
+ return _this.parser.unexpected(reply, 'STAT or FAIL');
+ }
+ };
+ })(this)).nodeify(callback);
+ };
+
+ Sync.prototype.readdir = function(path, callback) {
+ var files, readNext;
+ files = [];
+ readNext = (function(_this) {
+ return function() {
+ return _this.parser.readAscii(4).then(function(reply) {
+ switch (reply) {
+ case Protocol.DENT:
+ return _this.parser.readBytes(16).then(function(stat) {
+ var mode, mtime, namelen, size;
+ mode = stat.readUInt32LE(0);
+ size = stat.readUInt32LE(4);
+ mtime = stat.readUInt32LE(8);
+ namelen = stat.readUInt32LE(12);
+ return _this.parser.readBytes(namelen).then(function(name) {
+ name = name.toString();
+ if (!(name === '.' || name === '..')) {
+ files.push(new Entry(name, mode, size, mtime));
+ }
+ return readNext();
+ });
+ });
+ case Protocol.DONE:
+ return _this.parser.readBytes(16).then(function(zero) {
+ return files;
+ });
+ case Protocol.FAIL:
+ return _this._readError();
+ default:
+ return _this.parser.unexpected(reply, 'DENT, DONE or FAIL');
+ }
+ });
+ };
+ })(this);
+ this._sendCommandWithArg(Protocol.LIST, path);
+ return readNext().nodeify(callback);
+ };
+
+ Sync.prototype.push = function(contents, path, mode) {
+ if (typeof contents === 'string') {
+ return this.pushFile(contents, path, mode);
+ } else {
+ return this.pushStream(contents, path, mode);
+ }
+ };
+
+ Sync.prototype.pushFile = function(file, path, mode) {
+ if (mode == null) {
+ mode = DEFAULT_CHMOD;
+ }
+ mode || (mode = DEFAULT_CHMOD);
+ return this.pushStream(Fs.createReadStream(file), path, mode);
+ };
+
+ Sync.prototype.pushStream = function(stream, path, mode) {
+ if (mode == null) {
+ mode = DEFAULT_CHMOD;
+ }
+ mode |= Stats.S_IFREG;
+ this._sendCommandWithArg(Protocol.SEND, "" + path + "," + mode);
+ return this._writeData(stream, Math.floor(Date.now() / 1000));
+ };
+
+ Sync.prototype.pull = function(path) {
+ this._sendCommandWithArg(Protocol.RECV, "" + path);
+ return this._readData();
+ };
+
+ Sync.prototype.end = function() {
+ this.connection.end();
+ return this;
+ };
+
+ Sync.prototype.tempFile = function(path) {
+ return Sync.temp(path);
+ };
+
+ Sync.prototype._writeData = function(stream, timeStamp) {
+ var readReply, reader, transfer, writeData, writer;
+ transfer = new PushTransfer;
+ writeData = (function(_this) {
+ return function() {
+ var endListener, errorListener, readableListener, resolver, track, waitForDrain, writeNext, writer;
+ resolver = Promise.defer();
+ writer = Promise.resolve().cancellable();
+ stream.on('end', endListener = function() {
+ return writer.then(function() {
+ _this._sendCommandWithLength(Protocol.DONE, timeStamp);
+ return resolver.resolve();
+ });
+ });
+ waitForDrain = function() {
+ var drainListener;
+ resolver = Promise.defer();
+ _this.connection.on('drain', drainListener = function() {
+ return resolver.resolve();
+ });
+ return resolver.promise["finally"](function() {
+ return _this.connection.removeListener('drain', drainListener);
+ });
+ };
+ track = function() {
+ return transfer.pop();
+ };
+ writeNext = function() {
+ var chunk;
+ if (chunk = stream.read(DATA_MAX_LENGTH) || stream.read()) {
+ _this._sendCommandWithLength(Protocol.DATA, chunk.length);
+ transfer.push(chunk.length);
+ if (_this.connection.write(chunk, track)) {
+ return writeNext();
+ } else {
+ return waitForDrain().then(writeNext);
+ }
+ } else {
+ return Promise.resolve();
+ }
+ };
+ stream.on('readable', readableListener = function() {
+ return writer.then(writeNext);
+ });
+ stream.on('error', errorListener = function(err) {
+ return resolver.reject(err);
+ });
+ return resolver.promise["finally"](function() {
+ stream.removeListener('end', endListener);
+ stream.removeListener('readable', readableListener);
+ stream.removeListener('error', errorListener);
+ return writer.cancel();
+ });
+ };
+ })(this);
+ readReply = (function(_this) {
+ return function() {
+ return _this.parser.readAscii(4).then(function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readBytes(4).then(function(zero) {
+ return true;
+ });
+ case Protocol.FAIL:
+ return _this._readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ });
+ };
+ })(this);
+ writer = writeData().cancellable()["catch"](Promise.CancellationError, (function(_this) {
+ return function(err) {
+ return _this.connection.end();
+ };
+ })(this))["catch"](function(err) {
+ transfer.emit('error', err);
+ return reader.cancel();
+ });
+ reader = readReply().cancellable()["catch"](Promise.CancellationError, function(err) {
+ return true;
+ })["catch"](function(err) {
+ transfer.emit('error', err);
+ return writer.cancel();
+ })["finally"](function() {
+ return transfer.end();
+ });
+ transfer.on('cancel', function() {
+ writer.cancel();
+ return reader.cancel();
+ });
+ return transfer;
+ };
+
+ Sync.prototype._readData = function() {
+ var cancelListener, readNext, reader, transfer;
+ transfer = new PullTransfer;
+ readNext = (function(_this) {
+ return function() {
+ return _this.parser.readAscii(4).cancellable().then(function(reply) {
+ switch (reply) {
+ case Protocol.DATA:
+ return _this.parser.readBytes(4).then(function(lengthData) {
+ var length;
+ length = lengthData.readUInt32LE(0);
+ return _this.parser.readByteFlow(length).progressed(function(chunk) {
+ return transfer.write(chunk);
+ }).then(function() {
+ return readNext();
+ });
+ });
+ case Protocol.DONE:
+ return _this.parser.readBytes(4).then(function(zero) {
+ return true;
+ });
+ case Protocol.FAIL:
+ return _this._readError();
+ default:
+ return _this.parser.unexpected(reply, 'DATA, DONE or FAIL');
+ }
+ });
+ };
+ })(this);
+ reader = readNext()["catch"](Promise.CancellationError, (function(_this) {
+ return function(err) {
+ return _this.connection.end();
+ };
+ })(this))["catch"](function(err) {
+ return transfer.emit('error', err);
+ })["finally"](function() {
+ transfer.removeListener('cancel', cancelListener);
+ return transfer.end();
+ });
+ transfer.on('cancel', cancelListener = function() {
+ return reader.cancel();
+ });
+ return transfer;
+ };
+
+ Sync.prototype._readError = function() {
+ return this.parser.readBytes(4).then((function(_this) {
+ return function(zero) {
+ return _this.parser.readAll().then(function(buf) {
+ return Promise.reject(new Parser.FailError(buf.toString()));
+ });
+ };
+ })(this));
+ };
+
+ Sync.prototype._sendCommandWithLength = function(cmd, length) {
+ var payload;
+ if (cmd !== Protocol.DATA) {
+ debug(cmd);
+ }
+ payload = new Buffer(cmd.length + 4);
+ payload.write(cmd, 0, cmd.length);
+ payload.writeUInt32LE(length, cmd.length);
+ return this.connection.write(payload);
+ };
+
+ Sync.prototype._sendCommandWithArg = function(cmd, arg) {
+ var payload, pos;
+ debug("" + cmd + " " + arg);
+ payload = new Buffer(cmd.length + 4 + arg.length);
+ pos = 0;
+ payload.write(cmd, pos, cmd.length);
+ pos += cmd.length;
+ payload.writeUInt32LE(arg.length, pos);
+ pos += 4;
+ payload.write(arg, pos);
+ return this.connection.write(payload);
+ };
+
+ Sync.prototype._enoent = function(path) {
+ var err;
+ err = new Error("ENOENT, no such file or directory '" + path + "'");
+ err.errno = 34;
+ err.code = 'ENOENT';
+ err.path = path;
+ return Promise.reject(err);
+ };
+
+ return Sync;
+
+ })(EventEmitter);
+
+ module.exports = Sync;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/entry.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/entry.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/entry.js
new file mode 100644
index 0000000..1025e82
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/entry.js
@@ -0,0 +1,26 @@
+(function() {
+ var Entry, Stats,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Stats = require('./stats');
+
+ Entry = (function(_super) {
+ __extends(Entry, _super);
+
+ function Entry(name, mode, size, mtime) {
+ this.name = name;
+ Entry.__super__.constructor.call(this, mode, size, mtime);
+ }
+
+ Entry.prototype.toString = function() {
+ return this.name;
+ };
+
+ return Entry;
+
+ })(Stats);
+
+ module.exports = Entry;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/pulltransfer.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/pulltransfer.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/pulltransfer.js
new file mode 100644
index 0000000..1032956
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/pulltransfer.js
@@ -0,0 +1,34 @@
+(function() {
+ var PullTransfer, Stream,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Stream = require('stream');
+
+ PullTransfer = (function(_super) {
+ __extends(PullTransfer, _super);
+
+ function PullTransfer() {
+ this.stats = {
+ bytesTransferred: 0
+ };
+ PullTransfer.__super__.constructor.call(this);
+ }
+
+ PullTransfer.prototype.cancel = function() {
+ return this.emit('cancel');
+ };
+
+ PullTransfer.prototype.write = function(chunk, encoding, callback) {
+ this.stats.bytesTransferred += chunk.length;
+ this.emit('progress', this.stats);
+ return PullTransfer.__super__.write.call(this, chunk, encoding, callback);
+ };
+
+ return PullTransfer;
+
+ })(Stream.PassThrough);
+
+ module.exports = PullTransfer;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/pushtransfer.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/pushtransfer.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/pushtransfer.js
new file mode 100644
index 0000000..a966c3c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/pushtransfer.js
@@ -0,0 +1,43 @@
+(function() {
+ var EventEmitter, PushTransfer,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ EventEmitter = require('events').EventEmitter;
+
+ PushTransfer = (function(_super) {
+ __extends(PushTransfer, _super);
+
+ function PushTransfer() {
+ this._stack = [];
+ this.stats = {
+ bytesTransferred: 0
+ };
+ }
+
+ PushTransfer.prototype.cancel = function() {
+ return this.emit('cancel');
+ };
+
+ PushTransfer.prototype.push = function(byteCount) {
+ return this._stack.push(byteCount);
+ };
+
+ PushTransfer.prototype.pop = function() {
+ var byteCount;
+ byteCount = this._stack.pop();
+ this.stats.bytesTransferred += byteCount;
+ return this.emit('progress', this.stats);
+ };
+
+ PushTransfer.prototype.end = function() {
+ return this.emit('end');
+ };
+
+ return PushTransfer;
+
+ })(EventEmitter);
+
+ module.exports = PushTransfer;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/stats.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/stats.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/stats.js
new file mode 100644
index 0000000..39d2c9b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/sync/stats.js
@@ -0,0 +1,57 @@
+(function() {
+ var Fs, Stats,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Fs = require('fs');
+
+ Stats = (function(_super) {
+ __extends(Stats, _super);
+
+ Stats.S_IFMT = 0xf000;
+
+ Stats.S_IFSOCK = 0xc000;
+
+ Stats.S_IFLNK = 0xa000;
+
+ Stats.S_IFREG = 0x8000;
+
+ Stats.S_IFBLK = 0x6000;
+
+ Stats.S_IFDIR = 0x4000;
+
+ Stats.S_IFCHR = 0x2000;
+
+ Stats.S_IFIFO = 0x1000;
+
+ Stats.S_ISUID = 0x800;
+
+ Stats.S_ISGID = 0x400;
+
+ Stats.S_ISVTX = 0x200;
+
+ Stats.S_IRWXU = 0x1c0;
+
+ Stats.S_IRUSR = 0x100;
+
+ Stats.S_IWUSR = 0x80;
+
+ Stats.S_IXUSR = 0x40;
+
+ Stats.S_IRWXG = 0x38;
+
+ Stats.S_IRGRP = 0x20;
+
+ function Stats(mode, size, mtime) {
+ this.mode = mode;
+ this.size = size;
+ this.mtime = new Date(mtime * 1000);
+ }
+
+ return Stats;
+
+ })(Fs.Stats);
+
+ module.exports = Stats;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/rollingcounter.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/rollingcounter.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/rollingcounter.js
new file mode 100644
index 0000000..f339afa
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/rollingcounter.js
@@ -0,0 +1,24 @@
+(function() {
+ var RollingCounter;
+
+ RollingCounter = (function() {
+ function RollingCounter(max, min) {
+ this.max = max;
+ this.min = min != null ? min : 1;
+ this.now = this.min;
+ }
+
+ RollingCounter.prototype.next = function() {
+ if (!(this.now < this.max)) {
+ this.now = this.min;
+ }
+ return ++this.now;
+ };
+
+ return RollingCounter;
+
+ })();
+
+ module.exports = RollingCounter;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/server.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/server.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/server.js
new file mode 100644
index 0000000..0d13739
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/server.js
@@ -0,0 +1,72 @@
+(function() {
+ var EventEmitter, Net, Server, Socket,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Net = require('net');
+
+ EventEmitter = require('events').EventEmitter;
+
+ Socket = require('./socket');
+
+ Server = (function(_super) {
+ __extends(Server, _super);
+
+ function Server(client, serial, options) {
+ this.client = client;
+ this.serial = serial;
+ this.options = options;
+ this.connections = [];
+ this.server = Net.createServer();
+ this.server.on('error', (function(_this) {
+ return function(err) {
+ return _this.emit('error', err);
+ };
+ })(this));
+ this.server.on('listening', (function(_this) {
+ return function() {
+ return _this.emit('listening');
+ };
+ })(this));
+ this.server.on('close', (function(_this) {
+ return function() {
+ return _this.emit('close');
+ };
+ })(this));
+ this.server.on('connection', (function(_this) {
+ return function(conn) {
+ var socket;
+ socket = new Socket(_this.client, _this.serial, conn, _this.options);
+ _this.connections.push(socket);
+ return _this.emit('connection', socket);
+ };
+ })(this));
+ }
+
+ Server.prototype.listen = function() {
+ this.server.listen.apply(this.server, arguments);
+ return this;
+ };
+
+ Server.prototype.close = function() {
+ this.server.close();
+ return this;
+ };
+
+ Server.prototype.end = function() {
+ var conn, _i, _len, _ref;
+ _ref = this.connections;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ conn = _ref[_i];
+ conn.end();
+ }
+ return this;
+ };
+
+ return Server;
+
+ })(EventEmitter);
+
+ module.exports = Server;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/servicemap.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/servicemap.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/servicemap.js
new file mode 100644
index 0000000..d4b3ccc
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/servicemap.js
@@ -0,0 +1,43 @@
+(function() {
+ var ServiceMap;
+
+ ServiceMap = (function() {
+ function ServiceMap() {
+ this.remotes = Object.create(null);
+ }
+
+ ServiceMap.prototype.end = function() {
+ var remote, remoteId, _ref;
+ _ref = this.remotes;
+ for (remoteId in _ref) {
+ remote = _ref[remoteId];
+ remote.end();
+ }
+ this.remotes = Object.create(null);
+ };
+
+ ServiceMap.prototype.put = function(remoteId, socket) {
+ return this.remotes[remoteId] = socket;
+ };
+
+ ServiceMap.prototype.get = function(remoteId) {
+ return this.remotes[remoteId] || null;
+ };
+
+ ServiceMap.prototype.remove = function(remoteId) {
+ var remote;
+ if (remote = this.remotes[remoteId]) {
+ delete this.remotes[remoteId];
+ return remote;
+ } else {
+ return null;
+ }
+ };
+
+ return ServiceMap;
+
+ })();
+
+ module.exports = ServiceMap;
+
+}).call(this);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[15/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/cipher.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/cipher.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/cipher.js
new file mode 100644
index 0000000..58db4ce
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/cipher.js
@@ -0,0 +1,286 @@
+/**
+ * Cipher base API.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+forge.cipher = forge.cipher || {};
+
+// registered algorithms
+forge.cipher.algorithms = forge.cipher.algorithms || {};
+
+/**
+ * Creates a cipher object that can be used to encrypt data using the given
+ * algorithm and key. The algorithm may be provided as a string value for a
+ * previously registered algorithm or it may be given as a cipher algorithm
+ * API object.
+ *
+ * @param algorithm the algorithm to use, either a string or an algorithm API
+ * object.
+ * @param key the key to use, as a binary-encoded string of bytes or a
+ * byte buffer.
+ *
+ * @return the cipher.
+ */
+forge.cipher.createCipher = function(algorithm, key) {
+ var api = algorithm;
+ if(typeof api === 'string') {
+ api = forge.cipher.getAlgorithm(api);
+ if(api) {
+ api = api();
+ }
+ }
+ if(!api) {
+ throw new Error('Unsupported algorithm: ' + algorithm);
+ }
+
+ // assume block cipher
+ return new forge.cipher.BlockCipher({
+ algorithm: api,
+ key: key,
+ decrypt: false
+ });
+};
+
+/**
+ * Creates a decipher object that can be used to decrypt data using the given
+ * algorithm and key. The algorithm may be provided as a string value for a
+ * previously registered algorithm or it may be given as a cipher algorithm
+ * API object.
+ *
+ * @param algorithm the algorithm to use, either a string or an algorithm API
+ * object.
+ * @param key the key to use, as a binary-encoded string of bytes or a
+ * byte buffer.
+ *
+ * @return the cipher.
+ */
+forge.cipher.createDecipher = function(algorithm, key) {
+ var api = algorithm;
+ if(typeof api === 'string') {
+ api = forge.cipher.getAlgorithm(api);
+ if(api) {
+ api = api();
+ }
+ }
+ if(!api) {
+ throw new Error('Unsupported algorithm: ' + algorithm);
+ }
+
+ // assume block cipher
+ return new forge.cipher.BlockCipher({
+ algorithm: api,
+ key: key,
+ decrypt: true
+ });
+};
+
+/**
+ * Registers an algorithm by name. If the name was already registered, the
+ * algorithm API object will be overwritten.
+ *
+ * @param name the name of the algorithm.
+ * @param algorithm the algorithm API object.
+ */
+forge.cipher.registerAlgorithm = function(name, algorithm) {
+ name = name.toUpperCase();
+ forge.cipher.algorithms[name] = algorithm;
+};
+
+/**
+ * Gets a registered algorithm by name.
+ *
+ * @param name the name of the algorithm.
+ *
+ * @return the algorithm, if found, null if not.
+ */
+forge.cipher.getAlgorithm = function(name) {
+ name = name.toUpperCase();
+ if(name in forge.cipher.algorithms) {
+ return forge.cipher.algorithms[name];
+ }
+ return null;
+};
+
+var BlockCipher = forge.cipher.BlockCipher = function(options) {
+ this.algorithm = options.algorithm;
+ this.mode = this.algorithm.mode;
+ this.blockSize = this.mode.blockSize;
+ this._finish = false;
+ this._input = null;
+ this.output = null;
+ this._op = options.decrypt ? this.mode.decrypt : this.mode.encrypt;
+ this._decrypt = options.decrypt;
+ this.algorithm.initialize(options);
+};
+
+/**
+ * Starts or restarts the encryption or decryption process, whichever
+ * was previously configured.
+ *
+ * For non-GCM mode, the IV may be a binary-encoded string of bytes, an array
+ * of bytes, a byte buffer, or an array of 32-bit integers. If the IV is in
+ * bytes, then it must be Nb (16) bytes in length. If the IV is given in as
+ * 32-bit integers, then it must be 4 integers long.
+ *
+ * For GCM-mode, the IV must be given as a binary-encoded string of bytes or
+ * a byte buffer. The number of bytes should be 12 (96 bits) as recommended
+ * by NIST SP-800-38D but another length may be given.
+ *
+ * @param options the options to use:
+ * iv the initialization vector to use as a binary-encoded string of
+ * bytes, null to reuse the last ciphered block from a previous
+ * update() (this "residue" method is for legacy support only).
+ * additionalData additional authentication data as a binary-encoded
+ * string of bytes, for 'GCM' mode, (default: none).
+ * tagLength desired length of authentication tag, in bits, for
+ * 'GCM' mode (0-128, default: 128).
+ * tag the authentication tag to check if decrypting, as a
+ * binary-encoded string of bytes.
+ * output the output the buffer to write to, null to create one.
+ */
+BlockCipher.prototype.start = function(options) {
+ options = options || {};
+ var opts = {};
+ for(var key in options) {
+ opts[key] = options[key];
+ }
+ opts.decrypt = this._decrypt;
+ this._finish = false;
+ this._input = forge.util.createBuffer();
+ this.output = options.output || forge.util.createBuffer();
+ this.mode.start(opts);
+};
+
+/**
+ * Updates the next block according to the cipher mode.
+ *
+ * @param input the buffer to read from.
+ */
+BlockCipher.prototype.update = function(input) {
+ if(!this._finish) {
+ // not finishing, so fill the input buffer with more input
+ this._input.putBuffer(input);
+ }
+
+ // do cipher operation while input contains full blocks or if finishing
+ while(this._input.length() >= this.blockSize ||
+ (this._input.length() > 0 && this._finish)) {
+ this._op.call(this.mode, this._input, this.output);
+ }
+
+ // free consumed memory from input buffer
+ this._input.compact();
+};
+
+/**
+ * Finishes encrypting or decrypting.
+ *
+ * @param pad a padding function to use in CBC mode, null for default,
+ * signature(blockSize, buffer, decrypt).
+ *
+ * @return true if successful, false on error.
+ */
+BlockCipher.prototype.finish = function(pad) {
+ // backwards-compatibility w/deprecated padding API
+ // Note: will overwrite padding functions even after another start() call
+ if(pad && this.mode.name === 'CBC') {
+ this.mode.pad = function(input) {
+ return pad(this.blockSize, input, false);
+ };
+ this.mode.unpad = function(output) {
+ return pad(this.blockSize, output, true);
+ };
+ }
+
+ // build options for padding and afterFinish functions
+ var options = {};
+ options.decrypt = this._decrypt;
+
+ // get # of bytes that won't fill a block
+ options.overflow = this._input.length() % this.blockSize;
+
+ if(!this._decrypt && this.mode.pad) {
+ if(!this.mode.pad(this._input, options)) {
+ return false;
+ }
+ }
+
+ // do final update
+ this._finish = true;
+ this.update();
+
+ if(this._decrypt && this.mode.unpad) {
+ if(!this.mode.unpad(this.output, options)) {
+ return false;
+ }
+ }
+
+ if(this.mode.afterFinish) {
+ if(!this.mode.afterFinish(this.output, options)) {
+ return false;
+ }
+ }
+
+ return true;
+};
+
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'cipher';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/cipherModes.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/cipherModes.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/cipherModes.js
new file mode 100644
index 0000000..9ed318f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/cipherModes.js
@@ -0,0 +1,817 @@
+/**
+ * Supported cipher modes.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+forge.cipher = forge.cipher || {};
+
+// supported cipher modes
+var modes = forge.cipher.modes = forge.cipher.modes || {};
+
+
+/** Electronic codebook (ECB) (Don't use this; it's not secure) **/
+
+modes.ecb = function(options) {
+ options = options || {};
+ this.name = 'ECB';
+ this.cipher = options.cipher;
+ this.blockSize = options.blockSize || 16;
+ this._blocks = this.blockSize / 4;
+ this._inBlock = new Array(this._blocks);
+ this._outBlock = new Array(this._blocks);
+};
+
+modes.ecb.prototype.start = function(options) {};
+
+modes.ecb.prototype.encrypt = function(input, output) {
+ // get next block
+ for(var i = 0; i < this._blocks; ++i) {
+ this._inBlock[i] = input.getInt32();
+ }
+
+ // encrypt block
+ this.cipher.encrypt(this._inBlock, this._outBlock);
+
+ // write output
+ for(var i = 0; i < this._blocks; ++i) {
+ output.putInt32(this._outBlock[i]);
+ }
+};
+
+modes.ecb.prototype.decrypt = function(input, output) {
+ // get next block
+ for(var i = 0; i < this._blocks; ++i) {
+ this._inBlock[i] = input.getInt32();
+ }
+
+ // decrypt block
+ this.cipher.decrypt(this._inBlock, this._outBlock);
+
+ // write output
+ for(var i = 0; i < this._blocks; ++i) {
+ output.putInt32(this._outBlock[i]);
+ }
+};
+
+modes.ecb.prototype.pad = function(input, options) {
+ // add PKCS#7 padding to block (each pad byte is the
+ // value of the number of pad bytes)
+ var padding = (input.length() === this.blockSize ?
+ this.blockSize : (this.blockSize - input.length()));
+ input.fillWithByte(padding, padding);
+ return true;
+};
+
+modes.ecb.prototype.unpad = function(output, options) {
+ // check for error: input data not a multiple of blockSize
+ if(options.overflow > 0) {
+ return false;
+ }
+
+ // ensure padding byte count is valid
+ var len = output.length();
+ var count = output.at(len - 1);
+ if(count > (this.blockSize << 2)) {
+ return false;
+ }
+
+ // trim off padding bytes
+ output.truncate(count);
+ return true;
+};
+
+
+/** Cipher-block Chaining (CBC) **/
+
+modes.cbc = function(options) {
+ options = options || {};
+ this.name = 'CBC';
+ this.cipher = options.cipher;
+ this.blockSize = options.blockSize || 16;
+ this._blocks = this.blockSize / 4;
+ this._inBlock = new Array(this._blocks);
+ this._outBlock = new Array(this._blocks);
+};
+
+modes.cbc.prototype.start = function(options) {
+ // Note: legacy support for using IV residue (has security flaws)
+ // if IV is null, reuse block from previous processing
+ if(options.iv === null) {
+ // must have a previous block
+ if(!this._prev) {
+ throw new Error('Invalid IV parameter.');
+ }
+ this._iv = this._prev.slice(0);
+ } else if(!('iv' in options)) {
+ throw new Error('Invalid IV parameter.');
+ } else {
+ // save IV as "previous" block
+ this._iv = transformIV(options.iv);
+ this._prev = this._iv.slice(0);
+ }
+};
+
+modes.cbc.prototype.encrypt = function(input, output) {
+ // get next block
+ // CBC XOR's IV (or previous block) with plaintext
+ for(var i = 0; i < this._blocks; ++i) {
+ this._inBlock[i] = this._prev[i] ^ input.getInt32();
+ }
+
+ // encrypt block
+ this.cipher.encrypt(this._inBlock, this._outBlock);
+
+ // write output, save previous block
+ for(var i = 0; i < this._blocks; ++i) {
+ output.putInt32(this._outBlock[i]);
+ }
+ this._prev = this._outBlock;
+};
+
+modes.cbc.prototype.decrypt = function(input, output) {
+ // get next block
+ for(var i = 0; i < this._blocks; ++i) {
+ this._inBlock[i] = input.getInt32();
+ }
+
+ // decrypt block
+ this.cipher.decrypt(this._inBlock, this._outBlock);
+
+ // write output, save previous ciphered block
+ // CBC XOR's IV (or previous block) with ciphertext
+ for(var i = 0; i < this._blocks; ++i) {
+ output.putInt32(this._prev[i] ^ this._outBlock[i]);
+ }
+ this._prev = this._inBlock.slice(0);
+};
+
+modes.cbc.prototype.pad = function(input, options) {
+ // add PKCS#7 padding to block (each pad byte is the
+ // value of the number of pad bytes)
+ var padding = (input.length() === this.blockSize ?
+ this.blockSize : (this.blockSize - input.length()));
+ input.fillWithByte(padding, padding);
+ return true;
+};
+
+modes.cbc.prototype.unpad = function(output, options) {
+ // check for error: input data not a multiple of blockSize
+ if(options.overflow > 0) {
+ return false;
+ }
+
+ // ensure padding byte count is valid
+ var len = output.length();
+ var count = output.at(len - 1);
+ if(count > (this.blockSize << 2)) {
+ return false;
+ }
+
+ // trim off padding bytes
+ output.truncate(count);
+ return true;
+};
+
+
+/** Cipher feedback (CFB) **/
+
+modes.cfb = function(options) {
+ options = options || {};
+ this.name = 'CFB';
+ this.cipher = options.cipher;
+ this.blockSize = options.blockSize || 16;
+ this._blocks = this.blockSize / 4;
+ this._inBlock = null;
+ this._outBlock = new Array(this._blocks);
+};
+
+modes.cfb.prototype.start = function(options) {
+ if(!('iv' in options)) {
+ throw new Error('Invalid IV parameter.');
+ }
+ // use IV as first input
+ this._iv = transformIV(options.iv);
+ this._inBlock = this._iv.slice(0);
+};
+
+modes.cfb.prototype.encrypt = function(input, output) {
+ // encrypt block
+ this.cipher.encrypt(this._inBlock, this._outBlock);
+
+ // XOR input with output, write input as output
+ for(var i = 0; i < this._blocks; ++i) {
+ this._inBlock[i] = input.getInt32() ^ this._outBlock[i];
+ output.putInt32(this._inBlock[i]);
+ }
+};
+
+modes.cfb.prototype.decrypt = function(input, output) {
+ // encrypt block (CFB always uses encryption mode)
+ this.cipher.encrypt(this._inBlock, this._outBlock);
+
+ // XOR input with output
+ for(var i = 0; i < this._blocks; ++i) {
+ this._inBlock[i] = input.getInt32();
+ output.putInt32(this._inBlock[i] ^ this._outBlock[i]);
+ }
+};
+
+modes.cfb.prototype.afterFinish = function(output, options) {
+ // handle stream mode truncation
+ if(options.overflow > 0) {
+ output.truncate(this.blockSize - options.overflow);
+ }
+ return true;
+};
+
+/** Output feedback (OFB) **/
+
+modes.ofb = function(options) {
+ options = options || {};
+ this.name = 'OFB';
+ this.cipher = options.cipher;
+ this.blockSize = options.blockSize || 16;
+ this._blocks = this.blockSize / 4;
+ this._inBlock = null;
+ this._outBlock = new Array(this._blocks);
+};
+
+modes.ofb.prototype.start = function(options) {
+ if(!('iv' in options)) {
+ throw new Error('Invalid IV parameter.');
+ }
+ // use IV as first input
+ this._iv = transformIV(options.iv);
+ this._inBlock = this._iv.slice(0);
+};
+
+modes.ofb.prototype.encrypt = function(input, output) {
+ // encrypt block (OFB always uses encryption mode)
+ this.cipher.encrypt(this._inBlock, this._outBlock);
+
+ // XOR input with output and update next input
+ for(var i = 0; i < this._blocks; ++i) {
+ output.putInt32(input.getInt32() ^ this._outBlock[i]);
+ this._inBlock[i] = this._outBlock[i];
+ }
+};
+
+modes.ofb.prototype.decrypt = modes.ofb.prototype.encrypt;
+
+modes.ofb.prototype.afterFinish = function(output, options) {
+ // handle stream mode truncation
+ if(options.overflow > 0) {
+ output.truncate(this.blockSize - options.overflow);
+ }
+ return true;
+};
+
+
+/** Counter (CTR) **/
+
+modes.ctr = function(options) {
+ options = options || {};
+ this.name = 'CTR';
+ this.cipher = options.cipher;
+ this.blockSize = options.blockSize || 16;
+ this._blocks = this.blockSize / 4;
+ this._inBlock = null;
+ this._outBlock = new Array(this._blocks);
+};
+
+modes.ctr.prototype.start = function(options) {
+ if(!('iv' in options)) {
+ throw new Error('Invalid IV parameter.');
+ }
+ // use IV as first input
+ this._iv = transformIV(options.iv);
+ this._inBlock = this._iv.slice(0);
+};
+
+modes.ctr.prototype.encrypt = function(input, output) {
+ // encrypt block (CTR always uses encryption mode)
+ this.cipher.encrypt(this._inBlock, this._outBlock);
+
+ // increment counter (input block)
+ inc32(this._inBlock);
+
+ // XOR input with output
+ for(var i = 0; i < this._blocks; ++i) {
+ output.putInt32(input.getInt32() ^ this._outBlock[i]);
+ }
+};
+
+modes.ctr.prototype.decrypt = modes.ctr.prototype.encrypt;
+
+modes.ctr.prototype.afterFinish = function(output, options) {
+ // handle stream mode truncation
+ if(options.overflow > 0) {
+ output.truncate(this.blockSize - options.overflow);
+ }
+ return true;
+};
+
+
+/** Galois/Counter Mode (GCM) **/
+
+modes.gcm = function(options) {
+ options = options || {};
+ this.name = 'GCM';
+ this.cipher = options.cipher;
+ this.blockSize = options.blockSize || 16;
+ this._blocks = this.blockSize / 4;
+ this._inBlock = new Array(this._blocks);
+ this._outBlock = new Array(this._blocks);
+
+ // R is actually this value concatenated with 120 more zero bits, but
+ // we only XOR against R so the other zeros have no effect -- we just
+ // apply this value to the first integer in a block
+ this._R = 0xE1000000;
+};
+
+modes.gcm.prototype.start = function(options) {
+ if(!('iv' in options)) {
+ throw new Error('Invalid IV parameter.');
+ }
+ // ensure IV is a byte buffer
+ var iv = forge.util.createBuffer(options.iv);
+
+ // no ciphered data processed yet
+ this._cipherLength = 0;
+
+ // default additional data is none
+ var additionalData;
+ if('additionalData' in options) {
+ additionalData = forge.util.createBuffer(options.additionalData);
+ } else {
+ additionalData = forge.util.createBuffer();
+ }
+
+ // default tag length is 128 bits
+ if('tagLength' in options) {
+ this._tagLength = options.tagLength;
+ } else {
+ this._tagLength = 128;
+ }
+
+ // if tag is given, ensure tag matches tag length
+ this._tag = null;
+ if(options.decrypt) {
+ // save tag to check later
+ this._tag = forge.util.createBuffer(options.tag).getBytes();
+ if(this._tag.length !== (this._tagLength / 8)) {
+ throw new Error('Authentication tag does not match tag length.');
+ }
+ }
+
+ // create tmp storage for hash calculation
+ this._hashBlock = new Array(this._blocks);
+
+ // no tag generated yet
+ this.tag = null;
+
+ // generate hash subkey
+ // (apply block cipher to "zero" block)
+ this._hashSubkey = new Array(this._blocks);
+ this.cipher.encrypt([0, 0, 0, 0], this._hashSubkey);
+
+ // generate table M
+ // use 4-bit tables (32 component decomposition of a 16 byte value)
+ // 8-bit tables take more space and are known to have security
+ // vulnerabilities (in native implementations)
+ this.componentBits = 4;
+ this._m = this.generateHashTable(this._hashSubkey, this.componentBits);
+
+ // Note: support IV length different from 96 bits? (only supporting
+ // 96 bits is recommended by NIST SP-800-38D)
+ // generate J_0
+ var ivLength = iv.length();
+ if(ivLength === 12) {
+ // 96-bit IV
+ this._j0 = [iv.getInt32(), iv.getInt32(), iv.getInt32(), 1];
+ } else {
+ // IV is NOT 96-bits
+ this._j0 = [0, 0, 0, 0];
+ while(iv.length() > 0) {
+ this._j0 = this.ghash(
+ this._hashSubkey, this._j0,
+ [iv.getInt32(), iv.getInt32(), iv.getInt32(), iv.getInt32()]);
+ }
+ this._j0 = this.ghash(
+ this._hashSubkey, this._j0, [0, 0].concat(from64To32(ivLength * 8)));
+ }
+
+ // generate ICB (initial counter block)
+ this._inBlock = this._j0.slice(0);
+ inc32(this._inBlock);
+
+ // consume authentication data
+ additionalData = forge.util.createBuffer(additionalData);
+ // save additional data length as a BE 64-bit number
+ this._aDataLength = from64To32(additionalData.length() * 8);
+ // pad additional data to 128 bit (16 byte) block size
+ var overflow = additionalData.length() % this.blockSize;
+ if(overflow) {
+ additionalData.fillWithByte(0, this.blockSize - overflow);
+ }
+ this._s = [0, 0, 0, 0];
+ while(additionalData.length() > 0) {
+ this._s = this.ghash(this._hashSubkey, this._s, [
+ additionalData.getInt32(),
+ additionalData.getInt32(),
+ additionalData.getInt32(),
+ additionalData.getInt32()
+ ]);
+ }
+};
+
+modes.gcm.prototype.encrypt = function(input, output) {
+ // encrypt block
+ this.cipher.encrypt(this._inBlock, this._outBlock);
+
+ // increment counter (input block)
+ inc32(this._inBlock);
+
+ // save input length
+ var inputLength = input.length();
+
+ // XOR input with output
+ for(var i = 0; i < this._blocks; ++i) {
+ this._outBlock[i] ^= input.getInt32();
+ }
+
+ // handle overflow prior to hashing
+ if(inputLength < this.blockSize) {
+ // get block overflow
+ var overflow = inputLength % this.blockSize;
+ this._cipherLength += overflow;
+
+ // truncate for hash function
+ var tmp = forge.util.createBuffer();
+ tmp.putInt32(this._outBlock[0]);
+ tmp.putInt32(this._outBlock[1]);
+ tmp.putInt32(this._outBlock[2]);
+ tmp.putInt32(this._outBlock[3]);
+ tmp.truncate(this.blockSize - overflow);
+ this._outBlock[0] = tmp.getInt32();
+ this._outBlock[1] = tmp.getInt32();
+ this._outBlock[2] = tmp.getInt32();
+ this._outBlock[3] = tmp.getInt32();
+ } else {
+ this._cipherLength += this.blockSize;
+ }
+
+ for(var i = 0; i < this._blocks; ++i) {
+ output.putInt32(this._outBlock[i]);
+ }
+
+ // update hash block S
+ this._s = this.ghash(this._hashSubkey, this._s, this._outBlock);
+};
+
+modes.gcm.prototype.decrypt = function(input, output) {
+ // encrypt block (GCM always uses encryption mode)
+ this.cipher.encrypt(this._inBlock, this._outBlock);
+
+ // increment counter (input block)
+ inc32(this._inBlock);
+
+ // save input length
+ var inputLength = input.length();
+
+ // update hash block S
+ this._hashBlock[0] = input.getInt32();
+ this._hashBlock[1] = input.getInt32();
+ this._hashBlock[2] = input.getInt32();
+ this._hashBlock[3] = input.getInt32();
+ this._s = this.ghash(this._hashSubkey, this._s, this._hashBlock);
+
+ // XOR hash input with output
+ for(var i = 0; i < this._blocks; ++i) {
+ output.putInt32(this._outBlock[i] ^ this._hashBlock[i]);
+ }
+
+ // increment cipher data length
+ if(inputLength < this.blockSize) {
+ this._cipherLength += inputLength % this.blockSize;
+ } else {
+ this._cipherLength += this.blockSize;
+ }
+};
+
+modes.gcm.prototype.afterFinish = function(output, options) {
+ var rval = true;
+
+ // handle overflow
+ if(options.overflow) {
+ output.truncate(this.blockSize - options.overflow);
+ }
+
+ // handle authentication tag
+ this.tag = forge.util.createBuffer();
+
+ // concatenate additional data length with cipher length
+ var lengths = this._aDataLength.concat(from64To32(this._cipherLength * 8));
+
+ // include lengths in hash
+ this._s = this.ghash(this._hashSubkey, this._s, lengths);
+
+ // do GCTR(J_0, S)
+ var tag = [];
+ this.cipher.encrypt(this._j0, tag);
+ for(var i = 0; i < this._blocks; ++i) {
+ this.tag.putInt32(this._s[i] ^ tag[i]);
+ }
+
+ // trim tag to length
+ this.tag.truncate(this.tag.length() % (this._tagLength / 8));
+
+ // check authentication tag
+ if(options.decrypt && this.tag.bytes() !== this._tag) {
+ rval = false;
+ }
+
+ return rval;
+};
+
+/**
+ * See NIST SP-800-38D 6.3 (Algorithm 1). This function performs Galois
+ * field multiplication. The field, GF(2^128), is defined by the polynomial:
+ *
+ * x^128 + x^7 + x^2 + x + 1
+ *
+ * Which is represented in little-endian binary form as: 11100001 (0xe1). When
+ * the value of a coefficient is 1, a bit is set. The value R, is the
+ * concatenation of this value and 120 zero bits, yielding a 128-bit value
+ * which matches the block size.
+ *
+ * This function will multiply two elements (vectors of bytes), X and Y, in
+ * the field GF(2^128). The result is initialized to zero. For each bit of
+ * X (out of 128), x_i, if x_i is set, then the result is multiplied (XOR'd)
+ * by the current value of Y. For each bit, the value of Y will be raised by
+ * a power of x (multiplied by the polynomial x). This can be achieved by
+ * shifting Y once to the right. If the current value of Y, prior to being
+ * multiplied by x, has 0 as its LSB, then it is a 127th degree polynomial.
+ * Otherwise, we must divide by R after shifting to find the remainder.
+ *
+ * @param x the first block to multiply by the second.
+ * @param y the second block to multiply by the first.
+ *
+ * @return the block result of the multiplication.
+ */
+modes.gcm.prototype.multiply = function(x, y) {
+ var z_i = [0, 0, 0, 0];
+ var v_i = y.slice(0);
+
+ // calculate Z_128 (block has 128 bits)
+ for(var i = 0; i < 128; ++i) {
+ // if x_i is 0, Z_{i+1} = Z_i (unchanged)
+ // else Z_{i+1} = Z_i ^ V_i
+ // get x_i by finding 32-bit int position, then left shift 1 by remainder
+ var x_i = x[(i / 32) | 0] & (1 << (31 - i % 32));
+ if(x_i) {
+ z_i[0] ^= v_i[0];
+ z_i[1] ^= v_i[1];
+ z_i[2] ^= v_i[2];
+ z_i[3] ^= v_i[3];
+ }
+
+ // if LSB(V_i) is 1, V_i = V_i >> 1
+ // else V_i = (V_i >> 1) ^ R
+ this.pow(v_i, v_i);
+ }
+
+ return z_i;
+};
+
+modes.gcm.prototype.pow = function(x, out) {
+ // if LSB(x) is 1, x = x >>> 1
+ // else x = (x >>> 1) ^ R
+ var lsb = x[3] & 1;
+
+ // always do x >>> 1:
+ // starting with the rightmost integer, shift each integer to the right
+ // one bit, pulling in the bit from the integer to the left as its top
+ // most bit (do this for the last 3 integers)
+ for(var i = 3; i > 0; --i) {
+ out[i] = (x[i] >>> 1) | ((x[i - 1] & 1) << 31);
+ }
+ // shift the first integer normally
+ out[0] = x[0] >>> 1;
+
+ // if lsb was not set, then polynomial had a degree of 127 and doesn't
+ // need to divided; otherwise, XOR with R to find the remainder; we only
+ // need to XOR the first integer since R technically ends w/120 zero bits
+ if(lsb) {
+ out[0] ^= this._R;
+ }
+};
+
+modes.gcm.prototype.tableMultiply = function(x) {
+ // assumes 4-bit tables are used
+ var z = [0, 0, 0, 0];
+ for(var i = 0; i < 32; ++i) {
+ var idx = (i / 8) | 0;
+ var x_i = (x[idx] >>> ((7 - (i % 8)) * 4)) & 0xF;
+ var ah = this._m[i][x_i];
+ z[0] ^= ah[0];
+ z[1] ^= ah[1];
+ z[2] ^= ah[2];
+ z[3] ^= ah[3];
+ }
+ return z;
+};
+
+/**
+ * A continuing version of the GHASH algorithm that operates on a single
+ * block. The hash block, last hash value (Ym) and the new block to hash
+ * are given.
+ *
+ * @param h the hash block.
+ * @param y the previous value for Ym, use [0, 0, 0, 0] for a new hash.
+ * @param x the block to hash.
+ *
+ * @return the hashed value (Ym).
+ */
+modes.gcm.prototype.ghash = function(h, y, x) {
+ y[0] ^= x[0];
+ y[1] ^= x[1];
+ y[2] ^= x[2];
+ y[3] ^= x[3];
+ return this.tableMultiply(y);
+ //return this.multiply(y, h);
+};
+
+/**
+ * Precomputes a table for multiplying against the hash subkey. This
+ * mechanism provides a substantial speed increase over multiplication
+ * performed without a table. The table-based multiplication this table is
+ * for solves X * H by multiplying each component of X by H and then
+ * composing the results together using XOR.
+ *
+ * This function can be used to generate tables with different bit sizes
+ * for the components, however, this implementation assumes there are
+ * 32 components of X (which is a 16 byte vector), therefore each component
+ * takes 4-bits (so the table is constructed with bits=4).
+ *
+ * @param h the hash subkey.
+ * @param bits the bit size for a component.
+ */
+modes.gcm.prototype.generateHashTable = function(h, bits) {
+ // TODO: There are further optimizations that would use only the
+ // first table M_0 (or some variant) along with a remainder table;
+ // this can be explored in the future
+ var multiplier = 8 / bits;
+ var perInt = 4 * multiplier;
+ var size = 16 * multiplier;
+ var m = new Array(size);
+ for(var i = 0; i < size; ++i) {
+ var tmp = [0, 0, 0, 0];
+ var idx = (i / perInt) | 0;
+ var shft = ((perInt - 1 - (i % perInt)) * bits);
+ tmp[idx] = (1 << (bits - 1)) << shft;
+ m[i] = this.generateSubHashTable(this.multiply(tmp, h), bits);
+ }
+ return m;
+};
+
+/**
+ * Generates a table for multiplying against the hash subkey for one
+ * particular component (out of all possible component values).
+ *
+ * @param mid the pre-multiplied value for the middle key of the table.
+ * @param bits the bit size for a component.
+ */
+modes.gcm.prototype.generateSubHashTable = function(mid, bits) {
+ // compute the table quickly by minimizing the number of
+ // POW operations -- they only need to be performed for powers of 2,
+ // all other entries can be composed from those powers using XOR
+ var size = 1 << bits;
+ var half = size >>> 1;
+ var m = new Array(size);
+ m[half] = mid.slice(0);
+ var i = half >>> 1;
+ while(i > 0) {
+ // raise m0[2 * i] and store in m0[i]
+ this.pow(m[2 * i], m[i] = []);
+ i >>= 1;
+ }
+ i = 2;
+ while(i < half) {
+ for(var j = 1; j < i; ++j) {
+ var m_i = m[i];
+ var m_j = m[j];
+ m[i + j] = [
+ m_i[0] ^ m_j[0],
+ m_i[1] ^ m_j[1],
+ m_i[2] ^ m_j[2],
+ m_i[3] ^ m_j[3]
+ ];
+ }
+ i *= 2;
+ }
+ m[0] = [0, 0, 0, 0];
+ /* Note: We could avoid storing these by doing composition during multiply
+ calculate top half using composition by speed is preferred. */
+ for(i = half + 1; i < size; ++i) {
+ var c = m[i ^ half];
+ m[i] = [mid[0] ^ c[0], mid[1] ^ c[1], mid[2] ^ c[2], mid[3] ^ c[3]];
+ }
+ return m;
+};
+
+
+/** Utility functions */
+
+function transformIV(iv) {
+ if(typeof iv === 'string') {
+ // convert iv string into byte buffer
+ iv = forge.util.createBuffer(iv);
+ }
+
+ if(forge.util.isArray(iv) && iv.length > 4) {
+ // convert iv byte array into byte buffer
+ var tmp = iv;
+ iv = forge.util.createBuffer();
+ for(var i = 0; i < tmp.length; ++i) {
+ iv.putByte(tmp[i]);
+ }
+ }
+ if(!forge.util.isArray(iv)) {
+ // convert iv byte buffer into 32-bit integer array
+ iv = [iv.getInt32(), iv.getInt32(), iv.getInt32(), iv.getInt32()];
+ }
+
+ return iv;
+}
+
+function inc32(block) {
+ // increment last 32 bits of block only
+ block[block.length - 1] = (block[block.length - 1] + 1) & 0xFFFFFFFF;
+}
+
+function from64To32(num) {
+ // convert 64-bit number to two BE Int32s
+ return [(num / 0x100000000) | 0, num & 0xFFFFFFFF];
+}
+
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'cipherModes';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/debug.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/debug.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/debug.js
new file mode 100644
index 0000000..4f7c13d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/debug.js
@@ -0,0 +1,134 @@
+/**
+ * Debugging support for web applications.
+ *
+ * @author David I. Lehn <dl...@digitalbazaar.com>
+ *
+ * Copyright 2008-2013 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+/* DEBUG API */
+forge.debug = forge.debug || {};
+
+// Private storage for debugging.
+// Useful to expose data that is otherwise unviewable behind closures.
+// NOTE: remember that this can hold references to data and cause leaks!
+// format is "forge._debug.<modulename>.<dataname> = data"
+// Example:
+// (function() {
+// var cat = 'forge.test.Test'; // debugging category
+// var sState = {...}; // local state
+// forge.debug.set(cat, 'sState', sState);
+// })();
+forge.debug.storage = {};
+
+/**
+ * Gets debug data. Omit name for all cat data Omit name and cat for
+ * all data.
+ *
+ * @param cat name of debugging category.
+ * @param name name of data to get (optional).
+ * @return object with requested debug data or undefined.
+ */
+forge.debug.get = function(cat, name) {
+ var rval;
+ if(typeof(cat) === 'undefined') {
+ rval = forge.debug.storage;
+ } else if(cat in forge.debug.storage) {
+ if(typeof(name) === 'undefined') {
+ rval = forge.debug.storage[cat];
+ } else {
+ rval = forge.debug.storage[cat][name];
+ }
+ }
+ return rval;
+};
+
+/**
+ * Sets debug data.
+ *
+ * @param cat name of debugging category.
+ * @param name name of data to set.
+ * @param data data to set.
+ */
+forge.debug.set = function(cat, name, data) {
+ if(!(cat in forge.debug.storage)) {
+ forge.debug.storage[cat] = {};
+ }
+ forge.debug.storage[cat][name] = data;
+};
+
+/**
+ * Clears debug data. Omit name for all cat data. Omit name and cat for
+ * all data.
+ *
+ * @param cat name of debugging category.
+ * @param name name of data to clear or omit to clear entire category.
+ */
+forge.debug.clear = function(cat, name) {
+ if(typeof(cat) === 'undefined') {
+ forge.debug.storage = {};
+ } else if(cat in forge.debug.storage) {
+ if(typeof(name) === 'undefined') {
+ delete forge.debug.storage[cat];
+ } else {
+ delete forge.debug.storage[cat][name];
+ }
+ }
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'debug';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/des.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/des.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/des.js
new file mode 100644
index 0000000..bf6d477
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/des.js
@@ -0,0 +1,552 @@
+/**
+ * DES (Data Encryption Standard) implementation.
+ *
+ * This implementation supports DES as well as 3DES-EDE in ECB and CBC mode.
+ * It is based on the BSD-licensed implementation by Paul Tero:
+ *
+ * Paul Tero, July 2001
+ * http://www.tero.co.uk/des/
+ *
+ * Optimised for performance with large blocks by Michael Hayworth, November 2001
+ * http://www.netdealing.com
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @author Stefan Siegl
+ * @author Dave Longley
+ *
+ * Copyright (c) 2012 Stefan Siegl <st...@brokenpipe.de>
+ * Copyright (c) 2012-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+/* DES API */
+forge.des = forge.des || {};
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * var cipher = forge.cipher.createCipher('DES-<mode>', key);
+ * cipher.start({iv: iv});
+ *
+ * Creates an DES cipher object to encrypt data using the given symmetric key.
+ * The output will be stored in the 'output' member of the returned cipher.
+ *
+ * The key and iv may be given as binary-encoded strings of bytes or
+ * byte buffers.
+ *
+ * @param key the symmetric key to use (64 or 192 bits).
+ * @param iv the initialization vector to use.
+ * @param output the buffer to write to, null to create one.
+ * @param mode the cipher mode to use (default: 'CBC' if IV is
+ * given, 'ECB' if null).
+ *
+ * @return the cipher.
+ */
+forge.des.startEncrypting = function(key, iv, output, mode) {
+ var cipher = _createCipher({
+ key: key,
+ output: output,
+ decrypt: false,
+ mode: mode || (iv === null ? 'ECB' : 'CBC')
+ });
+ cipher.start(iv);
+ return cipher;
+};
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * var cipher = forge.cipher.createCipher('DES-<mode>', key);
+ *
+ * Creates an DES cipher object to encrypt data using the given symmetric key.
+ *
+ * The key may be given as a binary-encoded string of bytes or a byte buffer.
+ *
+ * @param key the symmetric key to use (64 or 192 bits).
+ * @param mode the cipher mode to use (default: 'CBC').
+ *
+ * @return the cipher.
+ */
+forge.des.createEncryptionCipher = function(key, mode) {
+ return _createCipher({
+ key: key,
+ output: null,
+ decrypt: false,
+ mode: mode
+ });
+};
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * var decipher = forge.cipher.createDecipher('DES-<mode>', key);
+ * decipher.start({iv: iv});
+ *
+ * Creates an DES cipher object to decrypt data using the given symmetric key.
+ * The output will be stored in the 'output' member of the returned cipher.
+ *
+ * The key and iv may be given as binary-encoded strings of bytes or
+ * byte buffers.
+ *
+ * @param key the symmetric key to use (64 or 192 bits).
+ * @param iv the initialization vector to use.
+ * @param output the buffer to write to, null to create one.
+ * @param mode the cipher mode to use (default: 'CBC' if IV is
+ * given, 'ECB' if null).
+ *
+ * @return the cipher.
+ */
+forge.des.startDecrypting = function(key, iv, output, mode) {
+ var cipher = _createCipher({
+ key: key,
+ output: output,
+ decrypt: true,
+ mode: mode || (iv === null ? 'ECB' : 'CBC')
+ });
+ cipher.start(iv);
+ return cipher;
+};
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * var decipher = forge.cipher.createDecipher('DES-<mode>', key);
+ *
+ * Creates an DES cipher object to decrypt data using the given symmetric key.
+ *
+ * The key may be given as a binary-encoded string of bytes or a byte buffer.
+ *
+ * @param key the symmetric key to use (64 or 192 bits).
+ * @param mode the cipher mode to use (default: 'CBC').
+ *
+ * @return the cipher.
+ */
+forge.des.createDecryptionCipher = function(key, mode) {
+ return _createCipher({
+ key: key,
+ output: null,
+ decrypt: true,
+ mode: mode
+ });
+};
+
+/**
+ * Creates a new DES cipher algorithm object.
+ *
+ * @param name the name of the algorithm.
+ * @param mode the mode factory function.
+ *
+ * @return the DES algorithm object.
+ */
+forge.des.Algorithm = function(name, mode) {
+ var self = this;
+ self.name = name;
+ self.mode = new mode({
+ blockSize: 8,
+ cipher: {
+ encrypt: function(inBlock, outBlock) {
+ return _updateBlock(self._keys, inBlock, outBlock, false);
+ },
+ decrypt: function(inBlock, outBlock) {
+ return _updateBlock(self._keys, inBlock, outBlock, true);
+ }
+ }
+ });
+ self._init = false;
+};
+
+/**
+ * Initializes this DES algorithm by expanding its key.
+ *
+ * @param options the options to use.
+ * key the key to use with this algorithm.
+ * decrypt true if the algorithm should be initialized for decryption,
+ * false for encryption.
+ */
+forge.des.Algorithm.prototype.initialize = function(options) {
+ if(this._init) {
+ return;
+ }
+
+ var key = forge.util.createBuffer(options.key);
+ if(this.name.indexOf('3DES') === 0) {
+ if(key.length() !== 24) {
+ throw new Error('Invalid Triple-DES key size: ' + key.length() * 8);
+ }
+ }
+
+ // do key expansion to 16 or 48 subkeys (single or triple DES)
+ this._keys = _createKeys(key);
+ this._init = true;
+};
+
+
+/** Register DES algorithms **/
+
+registerAlgorithm('DES-ECB', forge.cipher.modes.ecb);
+registerAlgorithm('DES-CBC', forge.cipher.modes.cbc);
+registerAlgorithm('DES-CFB', forge.cipher.modes.cfb);
+registerAlgorithm('DES-OFB', forge.cipher.modes.ofb);
+registerAlgorithm('DES-CTR', forge.cipher.modes.ctr);
+
+registerAlgorithm('3DES-ECB', forge.cipher.modes.ecb);
+registerAlgorithm('3DES-CBC', forge.cipher.modes.cbc);
+registerAlgorithm('3DES-CFB', forge.cipher.modes.cfb);
+registerAlgorithm('3DES-OFB', forge.cipher.modes.ofb);
+registerAlgorithm('3DES-CTR', forge.cipher.modes.ctr);
+
+function registerAlgorithm(name, mode) {
+ var factory = function() {
+ return new forge.des.Algorithm(name, mode);
+ };
+ forge.cipher.registerAlgorithm(name, factory);
+}
+
+
+/** DES implementation **/
+
+var spfunction1 = [0x1010400,0,0x10000,0x1010404,0x1010004,0x10404,0x4,0x10000,0x400,0x1010400,0x1010404,0x400,0x1000404,0x1010004,0x1000000,0x4,0x404,0x1000400,0x1000400,0x10400,0x10400,0x1010000,0x1010000,0x1000404,0x10004,0x1000004,0x1000004,0x10004,0,0x404,0x10404,0x1000000,0x10000,0x1010404,0x4,0x1010000,0x1010400,0x1000000,0x1000000,0x400,0x1010004,0x10000,0x10400,0x1000004,0x400,0x4,0x1000404,0x10404,0x1010404,0x10004,0x1010000,0x1000404,0x1000004,0x404,0x10404,0x1010400,0x404,0x1000400,0x1000400,0,0x10004,0x10400,0,0x1010004];
+var spfunction2 = [-0x7fef7fe0,-0x7fff8000,0x8000,0x108020,0x100000,0x20,-0x7fefffe0,-0x7fff7fe0,-0x7fffffe0,-0x7fef7fe0,-0x7fef8000,-0x80000000,-0x7fff8000,0x100000,0x20,-0x7fefffe0,0x108000,0x100020,-0x7fff7fe0,0,-0x80000000,0x8000,0x108020,-0x7ff00000,0x100020,-0x7fffffe0,0,0x108000,0x8020,-0x7fef8000,-0x7ff00000,0x8020,0,0x108020,-0x7fefffe0,0x100000,-0x7fff7fe0,-0x7ff00000,-0x7fef8000,0x8000,-0x7ff00000,-0x7fff8000,0x20,-0x7fef7fe0,0x108020,0x20,0x8000,-0x80000000,0x8020,-0x7fef8000,0x100000,-0x7fffffe0,0x100020,-0x7fff7fe0,-0x7fffffe0,0x100020,0x108000,0,-0x7fff8000,0x8020,-0x80000000,-0x7fefffe0,-0x7fef7fe0,0x108000];
+var spfunction3 = [0x208,0x8020200,0,0x8020008,0x8000200,0,0x20208,0x8000200,0x20008,0x8000008,0x8000008,0x20000,0x8020208,0x20008,0x8020000,0x208,0x8000000,0x8,0x8020200,0x200,0x20200,0x8020000,0x8020008,0x20208,0x8000208,0x20200,0x20000,0x8000208,0x8,0x8020208,0x200,0x8000000,0x8020200,0x8000000,0x20008,0x208,0x20000,0x8020200,0x8000200,0,0x200,0x20008,0x8020208,0x8000200,0x8000008,0x200,0,0x8020008,0x8000208,0x20000,0x8000000,0x8020208,0x8,0x20208,0x20200,0x8000008,0x8020000,0x8000208,0x208,0x8020000,0x20208,0x8,0x8020008,0x20200];
+var spfunction4 = [0x802001,0x2081,0x2081,0x80,0x802080,0x800081,0x800001,0x2001,0,0x802000,0x802000,0x802081,0x81,0,0x800080,0x800001,0x1,0x2000,0x800000,0x802001,0x80,0x800000,0x2001,0x2080,0x800081,0x1,0x2080,0x800080,0x2000,0x802080,0x802081,0x81,0x800080,0x800001,0x802000,0x802081,0x81,0,0,0x802000,0x2080,0x800080,0x800081,0x1,0x802001,0x2081,0x2081,0x80,0x802081,0x81,0x1,0x2000,0x800001,0x2001,0x802080,0x800081,0x2001,0x2080,0x800000,0x802001,0x80,0x800000,0x2000,0x802080];
+var spfunction5 = [0x100,0x2080100,0x2080000,0x42000100,0x80000,0x100,0x40000000,0x2080000,0x40080100,0x80000,0x2000100,0x40080100,0x42000100,0x42080000,0x80100,0x40000000,0x2000000,0x40080000,0x40080000,0,0x40000100,0x42080100,0x42080100,0x2000100,0x42080000,0x40000100,0,0x42000000,0x2080100,0x2000000,0x42000000,0x80100,0x80000,0x42000100,0x100,0x2000000,0x40000000,0x2080000,0x42000100,0x40080100,0x2000100,0x40000000,0x42080000,0x2080100,0x40080100,0x100,0x2000000,0x42080000,0x42080100,0x80100,0x42000000,0x42080100,0x2080000,0,0x40080000,0x42000000,0x80100,0x2000100,0x40000100,0x80000,0,0x40080000,0x2080100,0x40000100];
+var spfunction6 = [0x20000010,0x20400000,0x4000,0x20404010,0x20400000,0x10,0x20404010,0x400000,0x20004000,0x404010,0x400000,0x20000010,0x400010,0x20004000,0x20000000,0x4010,0,0x400010,0x20004010,0x4000,0x404000,0x20004010,0x10,0x20400010,0x20400010,0,0x404010,0x20404000,0x4010,0x404000,0x20404000,0x20000000,0x20004000,0x10,0x20400010,0x404000,0x20404010,0x400000,0x4010,0x20000010,0x400000,0x20004000,0x20000000,0x4010,0x20000010,0x20404010,0x404000,0x20400000,0x404010,0x20404000,0,0x20400010,0x10,0x4000,0x20400000,0x404010,0x4000,0x400010,0x20004010,0,0x20404000,0x20000000,0x400010,0x20004010];
+var spfunction7 = [0x200000,0x4200002,0x4000802,0,0x800,0x4000802,0x200802,0x4200800,0x4200802,0x200000,0,0x4000002,0x2,0x4000000,0x4200002,0x802,0x4000800,0x200802,0x200002,0x4000800,0x4000002,0x4200000,0x4200800,0x200002,0x4200000,0x800,0x802,0x4200802,0x200800,0x2,0x4000000,0x200800,0x4000000,0x200800,0x200000,0x4000802,0x4000802,0x4200002,0x4200002,0x2,0x200002,0x4000000,0x4000800,0x200000,0x4200800,0x802,0x200802,0x4200800,0x802,0x4000002,0x4200802,0x4200000,0x200800,0,0x2,0x4200802,0,0x200802,0x4200000,0x800,0x4000002,0x4000800,0x800,0x200002];
+var spfunction8 = [0x10001040,0x1000,0x40000,0x10041040,0x10000000,0x10001040,0x40,0x10000000,0x40040,0x10040000,0x10041040,0x41000,0x10041000,0x41040,0x1000,0x40,0x10040000,0x10000040,0x10001000,0x1040,0x41000,0x40040,0x10040040,0x10041000,0x1040,0,0,0x10040040,0x10000040,0x10001000,0x41040,0x40000,0x41040,0x40000,0x10041000,0x1000,0x40,0x10040040,0x1000,0x41040,0x10001000,0x40,0x10000040,0x10040000,0x10040040,0x10000000,0x40000,0x10001040,0,0x10041040,0x40040,0x10000040,0x10040000,0x10001000,0x10001040,0,0x10041040,0x41000,0x41000,0x1040,0x1040,0x40040,0x10000000,0x10041000];
+
+/**
+ * Create necessary sub keys.
+ *
+ * @param key the 64-bit or 192-bit key.
+ *
+ * @return the expanded keys.
+ */
+function _createKeys(key) {
+ var pc2bytes0 = [0,0x4,0x20000000,0x20000004,0x10000,0x10004,0x20010000,0x20010004,0x200,0x204,0x20000200,0x20000204,0x10200,0x10204,0x20010200,0x20010204],
+ pc2bytes1 = [0,0x1,0x100000,0x100001,0x4000000,0x4000001,0x4100000,0x4100001,0x100,0x101,0x100100,0x100101,0x4000100,0x4000101,0x4100100,0x4100101],
+ pc2bytes2 = [0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808,0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808],
+ pc2bytes3 = [0,0x200000,0x8000000,0x8200000,0x2000,0x202000,0x8002000,0x8202000,0x20000,0x220000,0x8020000,0x8220000,0x22000,0x222000,0x8022000,0x8222000],
+ pc2bytes4 = [0,0x40000,0x10,0x40010,0,0x40000,0x10,0x40010,0x1000,0x41000,0x1010,0x41010,0x1000,0x41000,0x1010,0x41010],
+ pc2bytes5 = [0,0x400,0x20,0x420,0,0x400,0x20,0x420,0x2000000,0x2000400,0x2000020,0x2000420,0x2000000,0x2000400,0x2000020,0x2000420],
+ pc2bytes6 = [0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002,0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002],
+ pc2bytes7 = [0,0x10000,0x800,0x10800,0x20000000,0x20010000,0x20000800,0x20010800,0x20000,0x30000,0x20800,0x30800,0x20020000,0x20030000,0x20020800,0x20030800],
+ pc2bytes8 = [0,0x40000,0,0x40000,0x2,0x40002,0x2,0x40002,0x2000000,0x2040000,0x2000000,0x2040000,0x2000002,0x2040002,0x2000002,0x2040002],
+ pc2bytes9 = [0,0x10000000,0x8,0x10000008,0,0x10000000,0x8,0x10000008,0x400,0x10000400,0x408,0x10000408,0x400,0x10000400,0x408,0x10000408],
+ pc2bytes10 = [0,0x20,0,0x20,0x100000,0x100020,0x100000,0x100020,0x2000,0x2020,0x2000,0x2020,0x102000,0x102020,0x102000,0x102020],
+ pc2bytes11 = [0,0x1000000,0x200,0x1000200,0x200000,0x1200000,0x200200,0x1200200,0x4000000,0x5000000,0x4000200,0x5000200,0x4200000,0x5200000,0x4200200,0x5200200],
+ pc2bytes12 = [0,0x1000,0x8000000,0x8001000,0x80000,0x81000,0x8080000,0x8081000,0x10,0x1010,0x8000010,0x8001010,0x80010,0x81010,0x8080010,0x8081010],
+ pc2bytes13 = [0,0x4,0x100,0x104,0,0x4,0x100,0x104,0x1,0x5,0x101,0x105,0x1,0x5,0x101,0x105];
+
+ // how many iterations (1 for des, 3 for triple des)
+ // changed by Paul 16/6/2007 to use Triple DES for 9+ byte keys
+ var iterations = key.length() > 8 ? 3 : 1;
+
+ // stores the return keys
+ var keys = [];
+
+ // now define the left shifts which need to be done
+ var shifts = [0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0];
+
+ var n = 0, tmp;
+ for(var j = 0; j < iterations; j ++) {
+ var left = key.getInt32();
+ var right = key.getInt32();
+
+ tmp = ((left >>> 4) ^ right) & 0x0f0f0f0f;
+ right ^= tmp;
+ left ^= (tmp << 4);
+
+ tmp = ((right >>> -16) ^ left) & 0x0000ffff;
+ left ^= tmp;
+ right ^= (tmp << -16);
+
+ tmp = ((left >>> 2) ^ right) & 0x33333333;
+ right ^= tmp;
+ left ^= (tmp << 2);
+
+ tmp = ((right >>> -16) ^ left) & 0x0000ffff;
+ left ^= tmp;
+ right ^= (tmp << -16);
+
+ tmp = ((left >>> 1) ^ right) & 0x55555555;
+ right ^= tmp;
+ left ^= (tmp << 1);
+
+ tmp = ((right >>> 8) ^ left) & 0x00ff00ff;
+ left ^= tmp;
+ right ^= (tmp << 8);
+
+ tmp = ((left >>> 1) ^ right) & 0x55555555;
+ right ^= tmp;
+ left ^= (tmp << 1);
+
+ // right needs to be shifted and OR'd with last four bits of left
+ tmp = (left << 8) | ((right >>> 20) & 0x000000f0);
+
+ // left needs to be put upside down
+ left = ((right << 24) | ((right << 8) & 0xff0000) |
+ ((right >>> 8) & 0xff00) | ((right >>> 24) & 0xf0));
+ right = tmp;
+
+ // now go through and perform these shifts on the left and right keys
+ for(var i = 0; i < shifts.length; ++i) {
+ //shift the keys either one or two bits to the left
+ if(shifts[i]) {
+ left = (left << 2) | (left >>> 26);
+ right = (right << 2) | (right >>> 26);
+ } else {
+ left = (left << 1) | (left >>> 27);
+ right = (right << 1) | (right >>> 27);
+ }
+ left &= -0xf;
+ right &= -0xf;
+
+ // now apply PC-2, in such a way that E is easier when encrypting or
+ // decrypting this conversion will look like PC-2 except only the last 6
+ // bits of each byte are used rather than 48 consecutive bits and the
+ // order of lines will be according to how the S selection functions will
+ // be applied: S2, S4, S6, S8, S1, S3, S5, S7
+ var lefttmp = (
+ pc2bytes0[left >>> 28] | pc2bytes1[(left >>> 24) & 0xf] |
+ pc2bytes2[(left >>> 20) & 0xf] | pc2bytes3[(left >>> 16) & 0xf] |
+ pc2bytes4[(left >>> 12) & 0xf] | pc2bytes5[(left >>> 8) & 0xf] |
+ pc2bytes6[(left >>> 4) & 0xf]);
+ var righttmp = (
+ pc2bytes7[right >>> 28] | pc2bytes8[(right >>> 24) & 0xf] |
+ pc2bytes9[(right >>> 20) & 0xf] | pc2bytes10[(right >>> 16) & 0xf] |
+ pc2bytes11[(right >>> 12) & 0xf] | pc2bytes12[(right >>> 8) & 0xf] |
+ pc2bytes13[(right >>> 4) & 0xf]);
+ tmp = ((righttmp >>> 16) ^ lefttmp) & 0x0000ffff;
+ keys[n++] = lefttmp ^ tmp;
+ keys[n++] = righttmp ^ (tmp << 16);
+ }
+ }
+
+ return keys;
+}
+
+/**
+ * Updates a single block (1 byte) using DES. The update will either
+ * encrypt or decrypt the block.
+ *
+ * @param keys the expanded keys.
+ * @param input the input block (an array of 32-bit words).
+ * @param output the updated output block.
+ * @param decrypt true to decrypt the block, false to encrypt it.
+ */
+function _updateBlock(keys, input, output, decrypt) {
+ // set up loops for single or triple DES
+ var iterations = keys.length === 32 ? 3 : 9;
+ var looping;
+ if(iterations === 3) {
+ looping = decrypt ? [30, -2, -2] : [0, 32, 2];
+ } else {
+ looping = (decrypt ?
+ [94, 62, -2, 32, 64, 2, 30, -2, -2] :
+ [0, 32, 2, 62, 30, -2, 64, 96, 2]);
+ }
+
+ var tmp;
+
+ var left = input[0];
+ var right = input[1];
+
+ // first each 64 bit chunk of the message must be permuted according to IP
+ tmp = ((left >>> 4) ^ right) & 0x0f0f0f0f;
+ right ^= tmp;
+ left ^= (tmp << 4);
+
+ tmp = ((left >>> 16) ^ right) & 0x0000ffff;
+ right ^= tmp;
+ left ^= (tmp << 16);
+
+ tmp = ((right >>> 2) ^ left) & 0x33333333;
+ left ^= tmp;
+ right ^= (tmp << 2);
+
+ tmp = ((right >>> 8) ^ left) & 0x00ff00ff;
+ left ^= tmp;
+ right ^= (tmp << 8);
+
+ tmp = ((left >>> 1) ^ right) & 0x55555555;
+ right ^= tmp;
+ left ^= (tmp << 1);
+
+ // rotate left 1 bit
+ left = ((left << 1) | (left >>> 31));
+ right = ((right << 1) | (right >>> 31));
+
+ for(var j = 0; j < iterations; j += 3) {
+ var endloop = looping[j + 1];
+ var loopinc = looping[j + 2];
+
+ // now go through and perform the encryption or decryption
+ for(var i = looping[j]; i != endloop; i += loopinc) {
+ var right1 = right ^ keys[i];
+ var right2 = ((right >>> 4) | (right << 28)) ^ keys[i + 1];
+
+ // passing these bytes through the S selection functions
+ tmp = left;
+ left = right;
+ right = tmp ^ (
+ spfunction2[(right1 >>> 24) & 0x3f] |
+ spfunction4[(right1 >>> 16) & 0x3f] |
+ spfunction6[(right1 >>> 8) & 0x3f] |
+ spfunction8[right1 & 0x3f] |
+ spfunction1[(right2 >>> 24) & 0x3f] |
+ spfunction3[(right2 >>> 16) & 0x3f] |
+ spfunction5[(right2 >>> 8) & 0x3f] |
+ spfunction7[right2 & 0x3f]);
+ }
+ // unreverse left and right
+ tmp = left;
+ left = right;
+ right = tmp;
+ }
+
+ // rotate right 1 bit
+ left = ((left >>> 1) | (left << 31));
+ right = ((right >>> 1) | (right << 31));
+
+ // now perform IP-1, which is IP in the opposite direction
+ tmp = ((left >>> 1) ^ right) & 0x55555555;
+ right ^= tmp;
+ left ^= (tmp << 1);
+
+ tmp = ((right >>> 8) ^ left) & 0x00ff00ff;
+ left ^= tmp;
+ right ^= (tmp << 8);
+
+ tmp = ((right >>> 2) ^ left) & 0x33333333;
+ left ^= tmp;
+ right ^= (tmp << 2);
+
+ tmp = ((left >>> 16) ^ right) & 0x0000ffff;
+ right ^= tmp;
+ left ^= (tmp << 16);
+
+ tmp = ((left >>> 4) ^ right) & 0x0f0f0f0f;
+ right ^= tmp;
+ left ^= (tmp << 4);
+
+ output[0] = left;
+ output[1] = right;
+}
+
+/**
+ * Deprecated. Instead, use:
+ *
+ * forge.cipher.createCipher('DES-<mode>', key);
+ * forge.cipher.createDecipher('DES-<mode>', key);
+ *
+ * Creates a deprecated DES cipher object. This object's mode will default to
+ * CBC (cipher-block-chaining).
+ *
+ * The key may be given as a binary-encoded string of bytes or a byte buffer.
+ *
+ * @param options the options to use.
+ * key the symmetric key to use (64 or 192 bits).
+ * output the buffer to write to.
+ * decrypt true for decryption, false for encryption.
+ * mode the cipher mode to use (default: 'CBC').
+ *
+ * @return the cipher.
+ */
+function _createCipher(options) {
+ options = options || {};
+ var mode = (options.mode || 'CBC').toUpperCase();
+ var algorithm = 'DES-' + mode;
+
+ var cipher;
+ if(options.decrypt) {
+ cipher = forge.cipher.createDecipher(algorithm, options.key);
+ } else {
+ cipher = forge.cipher.createCipher(algorithm, options.key);
+ }
+
+ // backwards compatible start API
+ var start = cipher.start;
+ cipher.start = function(iv, options) {
+ // backwards compatibility: support second arg as output buffer
+ var output = null;
+ if(options instanceof forge.util.ByteBuffer) {
+ output = options;
+ options = {};
+ }
+ options = options || {};
+ options.output = output;
+ options.iv = iv;
+ start.call(cipher, options);
+ };
+
+ return cipher;
+}
+
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'des';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(
+ ['require', 'module', './cipher', './cipherModes', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/forge.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/forge.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/forge.js
new file mode 100644
index 0000000..b314e22
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/forge.js
@@ -0,0 +1,92 @@
+/**
+ * Node.js module for Forge.
+ *
+ * @author Dave Longley
+ *
+ * Copyright 2011-2014 Digital Bazaar, Inc.
+ */
+(function() {
+var name = 'forge';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ // set to true to disable native code if even it's available
+ forge = {disableNativeCode: false};
+ }
+ return;
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ });
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge;
+ };
+ // set to true to disable native code if even it's available
+ module.exports.disableNativeCode = false;
+ module.exports(module.exports);
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define([
+ 'require',
+ 'module',
+ './aes',
+ './aesCipherSuites',
+ './asn1',
+ './cipher',
+ './cipherModes',
+ './debug',
+ './des',
+ './hmac',
+ './kem',
+ './log',
+ './md',
+ './mgf1',
+ './pbkdf2',
+ './pem',
+ './pkcs7',
+ './pkcs1',
+ './pkcs12',
+ './pki',
+ './prime',
+ './prng',
+ './pss',
+ './random',
+ './rc2',
+ './ssh',
+ './task',
+ './tls',
+ './util'
+], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/form.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/form.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/form.js
new file mode 100644
index 0000000..62d4424
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/form.js
@@ -0,0 +1,157 @@
+/**
+ * Functions for manipulating web forms.
+ *
+ * @author David I. Lehn <dl...@digitalbazaar.com>
+ * @author Dave Longley
+ * @author Mike Johnson
+ *
+ * Copyright (c) 2011-2014 Digital Bazaar, Inc. All rights reserved.
+ */
+(function($) {
+
+/**
+ * The form namespace.
+ */
+var form = {};
+
+/**
+ * Regex for parsing a single name property (handles array brackets).
+ */
+var _regex = /(.*?)\[(.*?)\]/g;
+
+/**
+ * Parses a single name property into an array with the name and any
+ * array indices.
+ *
+ * @param name the name to parse.
+ *
+ * @return the array of the name and its array indices in order.
+ */
+var _parseName = function(name) {
+ var rval = [];
+
+ var matches;
+ while(!!(matches = _regex.exec(name))) {
+ if(matches[1].length > 0) {
+ rval.push(matches[1]);
+ }
+ if(matches.length >= 2) {
+ rval.push(matches[2]);
+ }
+ }
+ if(rval.length === 0) {
+ rval.push(name);
+ }
+
+ return rval;
+};
+
+/**
+ * Adds a field from the given form to the given object.
+ *
+ * @param obj the object.
+ * @param names the field as an array of object property names.
+ * @param value the value of the field.
+ * @param dict a dictionary of names to replace.
+ */
+var _addField = function(obj, names, value, dict) {
+ // combine array names that fall within square brackets
+ var tmp = [];
+ for(var i = 0; i < names.length; ++i) {
+ // check name for starting square bracket but no ending one
+ var name = names[i];
+ if(name.indexOf('[') !== -1 && name.indexOf(']') === -1 &&
+ i < names.length - 1) {
+ do {
+ name += '.' + names[++i];
+ } while(i < names.length - 1 && names[i].indexOf(']') === -1);
+ }
+ tmp.push(name);
+ }
+ names = tmp;
+
+ // split out array indexes
+ var tmp = [];
+ $.each(names, function(n, name) {
+ tmp = tmp.concat(_parseName(name));
+ });
+ names = tmp;
+
+ // iterate over object property names until value is set
+ $.each(names, function(n, name) {
+ // do dictionary name replacement
+ if(dict && name.length !== 0 && name in dict) {
+ name = dict[name];
+ }
+
+ // blank name indicates appending to an array, set name to
+ // new last index of array
+ if(name.length === 0) {
+ name = obj.length;
+ }
+
+ // value already exists, append value
+ if(obj[name]) {
+ // last name in the field
+ if(n == names.length - 1) {
+ // more than one value, so convert into an array
+ if(!$.isArray(obj[name])) {
+ obj[name] = [obj[name]];
+ }
+ obj[name].push(value);
+ } else {
+ // not last name, go deeper into object
+ obj = obj[name];
+ }
+ } else if(n == names.length - 1) {
+ // new value, last name in the field, set value
+ obj[name] = value;
+ } else {
+ // new value, not last name, go deeper
+ // get next name
+ var next = names[n + 1];
+
+ // blank next value indicates array-appending, so create array
+ if(next.length === 0) {
+ obj[name] = [];
+ } else {
+ // if next name is a number create an array, otherwise a map
+ var isNum = ((next - 0) == next && next.length > 0);
+ obj[name] = isNum ? [] : {};
+ }
+ obj = obj[name];
+ }
+ });
+};
+
+/**
+ * Serializes a form to a JSON object. Object properties will be separated
+ * using the given separator (defaults to '.') and by square brackets.
+ *
+ * @param input the jquery form to serialize.
+ * @param sep the object-property separator (defaults to '.').
+ * @param dict a dictionary of names to replace (name=replace).
+ *
+ * @return the JSON-serialized form.
+ */
+form.serialize = function(input, sep, dict) {
+ var rval = {};
+
+ // add all fields in the form to the object
+ sep = sep || '.';
+ $.each(input.serializeArray(), function() {
+ _addField(rval, this.name.split(sep), this.value || '', dict);
+ });
+
+ return rval;
+};
+
+/**
+ * The forge namespace and form API.
+ */
+if(typeof forge === 'undefined') {
+ forge = {};
+}
+forge.form = form;
+
+})(jQuery);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/hmac.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/hmac.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/hmac.js
new file mode 100644
index 0000000..eee58bc
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/hmac.js
@@ -0,0 +1,200 @@
+/**
+ * Hash-based Message Authentication Code implementation. Requires a message
+ * digest object that can be obtained, for example, from forge.md.sha1 or
+ * forge.md.md5.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2012 Digital Bazaar, Inc. All rights reserved.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+/* HMAC API */
+var hmac = forge.hmac = forge.hmac || {};
+
+/**
+ * Creates an HMAC object that uses the given message digest object.
+ *
+ * @return an HMAC object.
+ */
+hmac.create = function() {
+ // the hmac key to use
+ var _key = null;
+
+ // the message digest to use
+ var _md = null;
+
+ // the inner padding
+ var _ipadding = null;
+
+ // the outer padding
+ var _opadding = null;
+
+ // hmac context
+ var ctx = {};
+
+ /**
+ * Starts or restarts the HMAC with the given key and message digest.
+ *
+ * @param md the message digest to use, null to reuse the previous one,
+ * a string to use builtin 'sha1', 'md5', 'sha256'.
+ * @param key the key to use as a string, array of bytes, byte buffer,
+ * or null to reuse the previous key.
+ */
+ ctx.start = function(md, key) {
+ if(md !== null) {
+ if(typeof md === 'string') {
+ // create builtin message digest
+ md = md.toLowerCase();
+ if(md in forge.md.algorithms) {
+ _md = forge.md.algorithms[md].create();
+ } else {
+ throw new Error('Unknown hash algorithm "' + md + '"');
+ }
+ } else {
+ // store message digest
+ _md = md;
+ }
+ }
+
+ if(key === null) {
+ // reuse previous key
+ key = _key;
+ } else {
+ if(typeof key === 'string') {
+ // convert string into byte buffer
+ key = forge.util.createBuffer(key);
+ } else if(forge.util.isArray(key)) {
+ // convert byte array into byte buffer
+ var tmp = key;
+ key = forge.util.createBuffer();
+ for(var i = 0; i < tmp.length; ++i) {
+ key.putByte(tmp[i]);
+ }
+ }
+
+ // if key is longer than blocksize, hash it
+ var keylen = key.length();
+ if(keylen > _md.blockLength) {
+ _md.start();
+ _md.update(key.bytes());
+ key = _md.digest();
+ }
+
+ // mix key into inner and outer padding
+ // ipadding = [0x36 * blocksize] ^ key
+ // opadding = [0x5C * blocksize] ^ key
+ _ipadding = forge.util.createBuffer();
+ _opadding = forge.util.createBuffer();
+ keylen = key.length();
+ for(var i = 0; i < keylen; ++i) {
+ var tmp = key.at(i);
+ _ipadding.putByte(0x36 ^ tmp);
+ _opadding.putByte(0x5C ^ tmp);
+ }
+
+ // if key is shorter than blocksize, add additional padding
+ if(keylen < _md.blockLength) {
+ var tmp = _md.blockLength - keylen;
+ for(var i = 0; i < tmp; ++i) {
+ _ipadding.putByte(0x36);
+ _opadding.putByte(0x5C);
+ }
+ }
+ _key = key;
+ _ipadding = _ipadding.bytes();
+ _opadding = _opadding.bytes();
+ }
+
+ // digest is done like so: hash(opadding | hash(ipadding | message))
+
+ // prepare to do inner hash
+ // hash(ipadding | message)
+ _md.start();
+ _md.update(_ipadding);
+ };
+
+ /**
+ * Updates the HMAC with the given message bytes.
+ *
+ * @param bytes the bytes to update with.
+ */
+ ctx.update = function(bytes) {
+ _md.update(bytes);
+ };
+
+ /**
+ * Produces the Message Authentication Code (MAC).
+ *
+ * @return a byte buffer containing the digest value.
+ */
+ ctx.getMac = function() {
+ // digest is done like so: hash(opadding | hash(ipadding | message))
+ // here we do the outer hashing
+ var inner = _md.digest().bytes();
+ _md.start();
+ _md.update(_opadding);
+ _md.update(inner);
+ return _md.digest();
+ };
+ // alias for getMac
+ ctx.digest = ctx.getMac;
+
+ return ctx;
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'hmac';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './md', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[51/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
CB-4548 Install new node-firefox-* dependencies in node_modules
Project: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/commit/b2b43200
Tree: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/tree/b2b43200
Diff: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/diff/b2b43200
Branch: refs/heads/master
Commit: b2b43200d94a5ec90e57fec333bf4e25cf34c755
Parents: d26d109
Author: Les Orchard <me...@lmorchard.com>
Authored: Wed Mar 11 13:31:04 2015 -0400
Committer: Les Orchard <me...@lmorchard.com>
Committed: Fri Mar 27 16:13:59 2015 -0400
----------------------------------------------------------------------
node_modules/es6-promise/.release.json | 17 +
node_modules/es6-promise/Brocfile.js | 75 +
node_modules/es6-promise/CHANGELOG.md | 9 +
node_modules/es6-promise/LICENSE | 19 +
node_modules/es6-promise/README.md | 58 +
node_modules/es6-promise/bin/publish_to_s3.js | 28 +
node_modules/es6-promise/bower.json | 29 +
.../es6-promise/config/s3ProjectConfig.js | 26 +
.../es6-promise/config/versionTemplate.txt | 7 +
node_modules/es6-promise/dist/es6-promise.js | 960 +++
.../es6-promise/dist/es6-promise.min.js | 18 +
.../es6-promise/lib/calculateVersion.js | 36 +
node_modules/es6-promise/lib/es6-promise.umd.js | 16 +
.../es6-promise/lib/es6-promise/-internal.js | 251 +
.../es6-promise/lib/es6-promise/asap.js | 82 +
.../es6-promise/lib/es6-promise/enumerator.js | 125 +
.../es6-promise/lib/es6-promise/polyfill.js | 35 +
.../es6-promise/lib/es6-promise/promise.js | 409 +
.../es6-promise/lib/es6-promise/promise/all.js | 52 +
.../es6-promise/lib/es6-promise/promise/race.js | 105 +
.../lib/es6-promise/promise/reject.js | 47 +
.../lib/es6-promise/promise/resolve.js | 49 +
.../es6-promise/lib/es6-promise/utils.js | 39 +
node_modules/es6-promise/package.json | 81 +
node_modules/es6-promise/server/.jshintrc | 3 +
node_modules/es6-promise/server/index.js | 6 +
node_modules/es6-promise/testem.json | 11 +
node_modules/node-firefox-connect/.npmignore | 3 +
node_modules/node-firefox-connect/LICENSE | 10 +
node_modules/node-firefox-connect/README.md | 62 +
.../node-firefox-connect/examples/connect.js | 15 +
.../examples/startAndConnect.js | 21 +
node_modules/node-firefox-connect/gulpfile.js | 3 +
node_modules/node-firefox-connect/index.js | 23 +
.../node_modules/es6-promise/.release.json | 17 +
.../node_modules/es6-promise/Brocfile.js | 75 +
.../node_modules/es6-promise/CHANGELOG.md | 9 +
.../node_modules/es6-promise/LICENSE | 19 +
.../node_modules/es6-promise/README.md | 58 +
.../es6-promise/bin/publish_to_s3.js | 28 +
.../node_modules/es6-promise/bower.json | 29 +
.../es6-promise/config/s3ProjectConfig.js | 26 +
.../es6-promise/config/versionTemplate.txt | 7 +
.../es6-promise/dist/es6-promise.js | 960 +++
.../es6-promise/dist/es6-promise.min.js | 18 +
.../es6-promise/lib/calculateVersion.js | 36 +
.../es6-promise/lib/es6-promise.umd.js | 16 +
.../es6-promise/lib/es6-promise/-internal.js | 251 +
.../es6-promise/lib/es6-promise/asap.js | 82 +
.../es6-promise/lib/es6-promise/enumerator.js | 125 +
.../es6-promise/lib/es6-promise/polyfill.js | 35 +
.../es6-promise/lib/es6-promise/promise.js | 409 +
.../es6-promise/lib/es6-promise/promise/all.js | 52 +
.../es6-promise/lib/es6-promise/promise/race.js | 105 +
.../lib/es6-promise/promise/reject.js | 47 +
.../lib/es6-promise/promise/resolve.js | 49 +
.../es6-promise/lib/es6-promise/utils.js | 39 +
.../node_modules/es6-promise/package.json | 81 +
.../node_modules/es6-promise/server/.jshintrc | 3 +
.../node_modules/es6-promise/server/index.js | 6 +
.../node_modules/es6-promise/testem.json | 11 +
.../node_modules/firefox-client/README.md | 157 +
.../node_modules/firefox-client/index.js | 1 +
.../node_modules/firefox-client/lib/browser.js | 123 +
.../firefox-client/lib/client-methods.js | 115 +
.../node_modules/firefox-client/lib/client.js | 246 +
.../node_modules/firefox-client/lib/console.js | 107 +
.../node_modules/firefox-client/lib/device.js | 29 +
.../node_modules/firefox-client/lib/dom.js | 68 +
.../node_modules/firefox-client/lib/domnode.js | 169 +
.../node_modules/firefox-client/lib/extend.js | 12 +
.../node_modules/firefox-client/lib/jsobject.js | 91 +
.../node_modules/firefox-client/lib/memory.js | 16 +
.../node_modules/firefox-client/lib/network.js | 105 +
.../firefox-client/lib/simulator.js | 22 +
.../firefox-client/lib/stylesheets.js | 96 +
.../node_modules/firefox-client/lib/tab.js | 87 +
.../node_modules/firefox-client/lib/webapps.js | 170 +
.../node_modules/colors/MIT-LICENSE.txt | 19 +
.../node_modules/colors/ReadMe.md | 30 +
.../node_modules/colors/colors.js | 230 +
.../node_modules/colors/example.html | 20 +
.../node_modules/colors/example.js | 20 +
.../node_modules/colors/package.json | 49 +
.../node_modules/js-select/LICENSE | 21 +
.../node_modules/js-select/README.md | 118 +
.../node_modules/js-select/index.js | 197 +
.../node_modules/JSONSelect/.gitmodules | 3 +
.../node_modules/JSONSelect/.npmignore | 5 +
.../node_modules/JSONSelect/JSONSelect.md | 214 +
.../js-select/node_modules/JSONSelect/README.md | 33 +
.../node_modules/JSONSelect/package.json | 49 +
.../JSONSelect/site/css/droid_sans.css | 6 +
.../JSONSelect/site/css/droid_sans.tt | Bin 0 -> 41028 bytes
.../node_modules/JSONSelect/site/css/style.css | 209 +
.../node_modules/JSONSelect/site/index.html | 139 +
.../node_modules/JSONSelect/site/js/demo.js | 64 +
.../JSONSelect/site/js/jquery-1.6.1.min.js | 18 +
.../site/js/jquery.ba-hashchange.min.js | 9 +
.../node_modules/JSONSelect/site/js/json2.js | 480 ++
.../node_modules/JSONSelect/site/js/main.js | 3 +
.../node_modules/JSONSelect/site/js/nav.js | 64 +
.../node_modules/JSONSelect/site/js/showdown.js | 1302 ++++
.../node_modules/JSONSelect/src/Makefile | 73 +
.../JSONSelect/src/build/jshint-check.js | 41 +
.../JSONSelect/src/build/lib/jshint.js | 3854 ++++++++++
.../JSONSelect/src/build/lib/jslint.js | 5504 ++++++++++++++
.../JSONSelect/src/build/lib/parse-js.js | 1319 ++++
.../JSONSelect/src/build/lib/process.js | 1616 ++++
.../JSONSelect/src/build/lib/squeeze-more.js | 22 +
.../JSONSelect/src/build/post-compile.js | 7 +
.../node_modules/JSONSelect/src/build/uglify.js | 199 +
.../JSONSelect/src/dist/jsonselect.js | 522 ++
.../JSONSelect/src/dist/jsonselect.min.js | 1 +
.../JSONSelect/src/dist/jsonselect.min.js.gz | Bin 0 -> 1851 bytes
.../node_modules/JSONSelect/src/jsonselect.js | 522 ++
.../JSONSelect/src/test/conformance_tests.html | 15 +
.../JSONSelect/src/test/css/style.css | 43 +
.../JSONSelect/src/test/js/conf_tests.js | 77 +
.../JSONSelect/src/test/js/doctest.css | 69 +
.../JSONSelect/src/test/js/doctest.js | 1397 ++++
.../JSONSelect/src/test/js/jquery-1.6.1.min.js | 18 +
.../JSONSelect/src/test/lex_test.html | 122 +
.../JSONSelect/src/test/match_test.html | 71 +
.../JSONSelect/src/test/parse_test.html | 98 +
.../node_modules/JSONSelect/src/test/run.js | 85 +
.../JSONSelect/src/test/tests/.npmignore | 1 +
.../JSONSelect/src/test/tests/README.md | 22 +
.../src/test/tests/level_1/basic.json | 31 +
.../test/tests/level_1/basic_first-child.output | 2 +
.../tests/level_1/basic_first-child.selector | 2 +
.../test/tests/level_1/basic_grouping.output | 4 +
.../test/tests/level_1/basic_grouping.selector | 1 +
.../src/test/tests/level_1/basic_id.output | 1 +
.../src/test/tests/level_1/basic_id.selector | 1 +
.../test/tests/level_1/basic_id_multiple.output | 3 +
.../tests/level_1/basic_id_multiple.selector | 1 +
.../test/tests/level_1/basic_id_quotes.output | 2 +
.../test/tests/level_1/basic_id_quotes.selector | 1 +
.../tests/level_1/basic_id_with_type.output | 1 +
.../tests/level_1/basic_id_with_type.selector | 1 +
.../test/tests/level_1/basic_last-child.output | 2 +
.../tests/level_1/basic_last-child.selector | 2 +
.../test/tests/level_1/basic_nth-child-2.output | 4 +
.../tests/level_1/basic_nth-child-2.selector | 1 +
.../test/tests/level_1/basic_nth-child.output | 3 +
.../test/tests/level_1/basic_nth-child.selector | 1 +
.../tests/level_1/basic_nth-last-child.output | 2 +
.../tests/level_1/basic_nth-last-child.selector | 1 +
.../test/tests/level_1/basic_root_pseudo.output | 31 +
.../tests/level_1/basic_root_pseudo.selector | 1 +
.../src/test/tests/level_1/basic_type.output | 14 +
.../src/test/tests/level_1/basic_type.selector | 1 +
.../src/test/tests/level_1/basic_type2.output | 1 +
.../src/test/tests/level_1/basic_type2.selector | 1 +
.../src/test/tests/level_1/basic_type3.output | 47 +
.../src/test/tests/level_1/basic_type3.selector | 1 +
.../test/tests/level_1/basic_universal.output | 85 +
.../test/tests/level_1/basic_universal.selector | 1 +
.../src/test/tests/level_1/collision.json | 6 +
.../test/tests/level_1/collision_nested.output | 1 +
.../tests/level_1/collision_nested.selector | 1 +
.../level_1/collision_quoted-string.output | 1 +
.../level_1/collision_quoted-string.selector | 1 +
.../test/tests/level_1/collision_string.output | 1 +
.../tests/level_1/collision_string.selector | 1 +
.../src/test/tests/level_2/sibling.json | 18 +
.../test/tests/level_2/sibling_childof.output | 1 +
.../test/tests/level_2/sibling_childof.selector | 2 +
.../tests/level_2/sibling_descendantof.output | 3 +
.../tests/level_2/sibling_descendantof.selector | 1 +
.../test/tests/level_2/sibling_unrooted.output | 3 +
.../tests/level_2/sibling_unrooted.selector | 1 +
.../src/test/tests/level_3/basic.json | 31 +
.../tests/level_3/basic_has-multiple.output | 4 +
.../tests/level_3/basic_has-multiple.selector | 1 +
.../tests/level_3/basic_has-root-in-expr.output | 4 +
.../level_3/basic_has-root-in-expr.selector | 1 +
.../level_3/basic_has-sans-first-paren.output | 1 +
.../level_3/basic_has-sans-first-paren.selector | 1 +
.../tests/level_3/basic_has-sans-paren.output | 1 +
.../tests/level_3/basic_has-sans-paren.selector | 2 +
.../tests/level_3/basic_has-whitespace.output | 12 +
.../tests/level_3/basic_has-whitespace.selector | 1 +
.../tests/level_3/basic_has-with-comma.output | 17 +
.../tests/level_3/basic_has-with-comma.selector | 1 +
.../src/test/tests/level_3/basic_has.output | 12 +
.../src/test/tests/level_3/basic_has.selector | 1 +
.../basic_multiple-has-with-strings.output | 5 +
.../basic_multiple-has-with-strings.selector | 1 +
.../JSONSelect/src/test/tests/level_3/expr.json | 9 +
.../src/test/tests/level_3/expr_div.output | 1 +
.../src/test/tests/level_3/expr_div.selector | 1 +
.../test/tests/level_3/expr_ends-with.output | 1 +
.../test/tests/level_3/expr_ends-with.selector | 1 +
.../src/test/tests/level_3/expr_false-eq.output | 3 +
.../test/tests/level_3/expr_false-eq.selector | 4 +
.../test/tests/level_3/expr_greater-than.output | 2 +
.../tests/level_3/expr_greater-than.selector | 1 +
.../test/tests/level_3/expr_less-than.output | 2 +
.../test/tests/level_3/expr_less-than.selector | 1 +
.../src/test/tests/level_3/expr_mod.output | 1 +
.../src/test/tests/level_3/expr_mod.selector | 1 +
.../src/test/tests/level_3/expr_mult.output | 1 +
.../src/test/tests/level_3/expr_mult.selector | 1 +
.../src/test/tests/level_3/expr_null-eq.output | 5 +
.../test/tests/level_3/expr_null-eq.selector | 4 +
.../test/tests/level_3/expr_number-eq.output | 1 +
.../test/tests/level_3/expr_number-eq.selector | 1 +
.../test/tests/level_3/expr_precedence-1.output | 1 +
.../tests/level_3/expr_precedence-1.selector | 1 +
.../test/tests/level_3/expr_precedence-2.output | 1 +
.../tests/level_3/expr_precedence-2.selector | 1 +
.../test/tests/level_3/expr_simple-false.output | 0
.../tests/level_3/expr_simple-false.selector | 1 +
.../src/test/tests/level_3/expr_simple.output | 1 +
.../src/test/tests/level_3/expr_simple.selector | 1 +
.../test/tests/level_3/expr_starts-with.output | 1 +
.../tests/level_3/expr_starts-with.selector | 1 +
.../test/tests/level_3/expr_string-eq.output | 1 +
.../test/tests/level_3/expr_string-eq.selector | 1 +
.../src/test/tests/level_3/expr_true-eq.output | 3 +
.../test/tests/level_3/expr_true-eq.selector | 2 +
.../src/test/tests/level_3/polykids.json | 15 +
.../level_3/polykids_has-with_descendant.output | 1 +
.../polykids_has-with_descendant.selector | 1 +
.../src/test/tests/level_3/polykids_val.output | 2 +
.../test/tests/level_3/polykids_val.selector | 1 +
.../js-select/node_modules/traverse/.npmignore | 1 +
.../js-select/node_modules/traverse/LICENSE | 24 +
.../node_modules/traverse/README.markdown | 273 +
.../node_modules/traverse/examples/json.js | 16 +
.../node_modules/traverse/examples/leaves.js | 15 +
.../node_modules/traverse/examples/negative.js | 8 +
.../node_modules/traverse/examples/scrub.js | 10 +
.../node_modules/traverse/examples/stringify.js | 38 +
.../js-select/node_modules/traverse/index.js | 332 +
.../node_modules/traverse/package.json | 42 +
.../node_modules/traverse/test/circular.js | 114 +
.../node_modules/traverse/test/date.js | 35 +
.../node_modules/traverse/test/equal.js | 219 +
.../node_modules/traverse/test/instance.js | 17 +
.../node_modules/traverse/test/interface.js | 42 +
.../node_modules/traverse/test/json.js | 47 +
.../node_modules/traverse/test/keys.js | 29 +
.../node_modules/traverse/test/leaves.js | 21 +
.../node_modules/traverse/test/mutability.js | 203 +
.../node_modules/traverse/test/negative.js | 20 +
.../js-select/node_modules/traverse/test/obj.js | 15 +
.../node_modules/traverse/test/siblings.js | 35 +
.../node_modules/traverse/test/stop.js | 41 +
.../node_modules/traverse/test/stringify.js | 36 +
.../node_modules/traverse/test/subexpr.js | 34 +
.../node_modules/traverse/test/super_deep.js | 54 +
.../node_modules/js-select/package.json | 51 +
.../node_modules/js-select/select-min.js | 37 +
.../node_modules/js-select/select.js | 1533 ++++
.../node_modules/js-select/test/runner.js | 58 +
.../node_modules/js-select/test/test.js | 161 +
.../node_modules/js-select/test/timeline.js | 1 +
.../node_modules/firefox-client/package.json | 52 +
.../node_modules/firefox-client/test.js | 54 +
.../node_modules/firefox-client/test/README.md | 29 +
.../firefox-client/test/pages/dom.html | 19 +
.../firefox-client/test/pages/index.html | 22 +
.../firefox-client/test/pages/logs.html | 17 +
.../firefox-client/test/pages/network.html | 22 +
.../firefox-client/test/pages/stylesheet1.css | 9 +
.../firefox-client/test/pages/stylesheets.html | 20 +
.../firefox-client/test/pages/test-network.json | 4 +
.../node_modules/firefox-client/test/server.js | 8 +
.../firefox-client/test/test-console.js | 64 +
.../firefox-client/test/test-dom.js | 329 +
.../firefox-client/test/test-jsobject.js | 115 +
.../firefox-client/test/test-logs.js | 106 +
.../firefox-client/test/test-network.js | 88 +
.../firefox-client/test/test-raw.js | 26 +
.../firefox-client/test/test-stylesheets.js | 124 +
.../node_modules/firefox-client/test/utils.js | 35 +
node_modules/node-firefox-connect/package.json | 81 +
node_modules/node-firefox-connect/test/test.js | 157 +
node_modules/node-firefox-find-app/.npmignore | 2 +
node_modules/node-firefox-find-app/LICENSE | 13 +
node_modules/node-firefox-find-app/README.md | 125 +
.../node-firefox-find-app/examples/data/app.js | 3 +
.../examples/data/icons/icon128x128.png | Bin 0 -> 4990 bytes
.../examples/data/icons/icon16x16.png | Bin 0 -> 1111 bytes
.../examples/data/icons/icon48x48.png | Bin 0 -> 2928 bytes
.../examples/data/icons/icon60x60.png | Bin 0 -> 3654 bytes
.../examples/data/index.html | 27 +
.../examples/data/manifest.webapp | 14 +
.../node-firefox-find-app/examples/usage.js | 45 +
node_modules/node-firefox-find-app/gulpfile.js | 4 +
node_modules/node-firefox-find-app/index.js | 70 +
.../node_modules/es6-promise/.release.json | 17 +
.../node_modules/es6-promise/Brocfile.js | 75 +
.../node_modules/es6-promise/CHANGELOG.md | 9 +
.../node_modules/es6-promise/LICENSE | 19 +
.../node_modules/es6-promise/README.md | 58 +
.../es6-promise/bin/publish_to_s3.js | 28 +
.../node_modules/es6-promise/bower.json | 29 +
.../es6-promise/config/s3ProjectConfig.js | 26 +
.../es6-promise/config/versionTemplate.txt | 7 +
.../es6-promise/dist/es6-promise.js | 960 +++
.../es6-promise/dist/es6-promise.min.js | 18 +
.../es6-promise/lib/calculateVersion.js | 36 +
.../es6-promise/lib/es6-promise.umd.js | 16 +
.../es6-promise/lib/es6-promise/-internal.js | 251 +
.../es6-promise/lib/es6-promise/asap.js | 82 +
.../es6-promise/lib/es6-promise/enumerator.js | 125 +
.../es6-promise/lib/es6-promise/polyfill.js | 35 +
.../es6-promise/lib/es6-promise/promise.js | 409 +
.../es6-promise/lib/es6-promise/promise/all.js | 52 +
.../es6-promise/lib/es6-promise/promise/race.js | 105 +
.../lib/es6-promise/promise/reject.js | 47 +
.../lib/es6-promise/promise/resolve.js | 49 +
.../es6-promise/lib/es6-promise/utils.js | 39 +
.../node_modules/es6-promise/package.json | 81 +
.../node_modules/es6-promise/server/.jshintrc | 3 +
.../node_modules/es6-promise/server/index.js | 6 +
.../node_modules/es6-promise/testem.json | 11 +
node_modules/node-firefox-find-app/package.json | 64 +
.../test/sampleapp/build/app.zip | Bin 0 -> 16529 bytes
.../test/sampleapp/fake.webapp | 22 +
.../test/sampleapp/icons/icon.svg | 106 +
.../test/sampleapp/icons/icon128x128.png | Bin 0 -> 6760 bytes
.../test/sampleapp/icons/icon16x16.png | Bin 0 -> 804 bytes
.../test/sampleapp/icons/icon48x48.png | Bin 0 -> 2688 bytes
.../test/sampleapp/icons/icon60x60.png | Bin 0 -> 3344 bytes
.../test/sampleapp/index.html | 12 +
.../test/sampleapp/manifest.webapp | 22 +
node_modules/node-firefox-find-app/test/test.js | 73 +
.../node-firefox-find-devices/.npmignore | 4 +
.../node-firefox-find-devices/.travis.yml | 3 +
node_modules/node-firefox-find-devices/LICENSE | 13 +
.../node-firefox-find-devices/README.md | 78 +
.../node-firefox-find-devices/gulpfile.js | 3 +
node_modules/node-firefox-find-devices/index.js | 41 +
.../node_modules/adbkit/LICENSE | 13 +
.../node_modules/adbkit/README.md | 1089 +++
.../node_modules/adbkit/index.js | 15 +
.../node_modules/adbkit/lib/adb.js | 27 +
.../node_modules/adbkit/lib/adb/auth.js | 81 +
.../node_modules/adbkit/lib/adb/client.js | 552 ++
.../node_modules/adbkit/lib/adb/command.js | 48 +
.../lib/adb/command/host-serial/forward.js | 48 +
.../adb/command/host-serial/getdevicepath.js | 41 +
.../lib/adb/command/host-serial/getserialno.js | 41 +
.../lib/adb/command/host-serial/getstate.js | 41 +
.../lib/adb/command/host-serial/listforwards.js | 59 +
.../adb/command/host-serial/waitfordevice.js | 48 +
.../lib/adb/command/host-transport/clear.js | 47 +
.../adb/command/host-transport/framebuffer.js | 117 +
.../adb/command/host-transport/getfeatures.js | 54 +
.../adb/command/host-transport/getpackages.js | 54 +
.../adb/command/host-transport/getproperties.js | 56 +
.../lib/adb/command/host-transport/install.js | 51 +
.../adb/command/host-transport/isinstalled.js | 50 +
.../lib/adb/command/host-transport/local.js | 39 +
.../lib/adb/command/host-transport/log.js | 39 +
.../lib/adb/command/host-transport/logcat.js | 49 +
.../lib/adb/command/host-transport/monkey.js | 45 +
.../lib/adb/command/host-transport/reboot.js | 39 +
.../lib/adb/command/host-transport/remount.js | 39 +
.../lib/adb/command/host-transport/screencap.js | 57 +
.../lib/adb/command/host-transport/shell.js | 42 +
.../adb/command/host-transport/startactivity.js | 187 +
.../adb/command/host-transport/startservice.js | 36 +
.../lib/adb/command/host-transport/sync.js | 41 +
.../lib/adb/command/host-transport/tcp.js | 39 +
.../lib/adb/command/host-transport/tcpip.js | 51 +
.../lib/adb/command/host-transport/trackjdwp.js | 123 +
.../lib/adb/command/host-transport/uninstall.js | 47 +
.../lib/adb/command/host-transport/usb.js | 51 +
.../command/host-transport/waitbootcomplete.js | 45 +
.../adbkit/lib/adb/command/host/connect.js | 49 +
.../adbkit/lib/adb/command/host/devices.js | 67 +
.../lib/adb/command/host/deviceswithpaths.js | 68 +
.../adbkit/lib/adb/command/host/disconnect.js | 49 +
.../adbkit/lib/adb/command/host/kill.js | 39 +
.../adbkit/lib/adb/command/host/trackdevices.js | 43 +
.../adbkit/lib/adb/command/host/transport.js | 39 +
.../adbkit/lib/adb/command/host/version.js | 45 +
.../node_modules/adbkit/lib/adb/connection.js | 108 +
.../adbkit/lib/adb/framebuffer/rgbtransform.js | 58 +
.../node_modules/adbkit/lib/adb/keycode.js | 228 +
.../adbkit/lib/adb/linetransform.js | 58 +
.../node_modules/adbkit/lib/adb/parser.js | 247 +
.../node_modules/adbkit/lib/adb/proc/stat.js | 140 +
.../node_modules/adbkit/lib/adb/protocol.js | 48 +
.../node_modules/adbkit/lib/adb/sync.js | 337 +
.../node_modules/adbkit/lib/adb/sync/entry.js | 26 +
.../adbkit/lib/adb/sync/pulltransfer.js | 34 +
.../adbkit/lib/adb/sync/pushtransfer.js | 43 +
.../node_modules/adbkit/lib/adb/sync/stats.js | 57 +
.../adbkit/lib/adb/tcpusb/rollingcounter.js | 24 +
.../adbkit/lib/adb/tcpusb/server.js | 72 +
.../adbkit/lib/adb/tcpusb/servicemap.js | 43 +
.../adbkit/lib/adb/tcpusb/socket.js | 391 +
.../node_modules/adbkit/lib/adb/tracker.js | 92 +
.../node_modules/adbkit/lib/adb/util.js | 16 +
.../node_modules/adbkit/lib/cli.js | 42 +
.../adbkit/node_modules/adbkit-logcat/LICENSE | 13 +
.../adbkit/node_modules/adbkit-logcat/README.md | 240 +
.../adbkit/node_modules/adbkit-logcat/index.js | 15 +
.../node_modules/adbkit-logcat/lib/logcat.js | 25 +
.../adbkit-logcat/lib/logcat/entry.js | 76 +
.../adbkit-logcat/lib/logcat/parser.js | 32 +
.../adbkit-logcat/lib/logcat/parser/binary.js | 78 +
.../adbkit-logcat/lib/logcat/priority.js | 89 +
.../adbkit-logcat/lib/logcat/reader.js | 137 +
.../adbkit-logcat/lib/logcat/transform.js | 51 +
.../node_modules/adbkit-logcat/package.json | 75 +
.../adbkit/node_modules/adbkit-monkey/LICENSE | 13 +
.../adbkit/node_modules/adbkit-monkey/README.md | 469 ++
.../adbkit/node_modules/adbkit-monkey/index.js | 15 +
.../node_modules/adbkit-monkey/lib/monkey.js | 29 +
.../adbkit-monkey/lib/monkey/api.js | 276 +
.../adbkit-monkey/lib/monkey/client.js | 98 +
.../adbkit-monkey/lib/monkey/command.js | 17 +
.../adbkit-monkey/lib/monkey/connection.js | 42 +
.../adbkit-monkey/lib/monkey/multi.js | 85 +
.../adbkit-monkey/lib/monkey/parser.js | 66 +
.../adbkit-monkey/lib/monkey/queue.js | 38 +
.../adbkit-monkey/lib/monkey/reply.js | 31 +
.../adbkit-monkey/node_modules/async/LICENSE | 19 +
.../adbkit-monkey/node_modules/async/README.md | 1425 ++++
.../node_modules/async/component.json | 11 +
.../node_modules/async/lib/async.js | 958 +++
.../node_modules/async/package.json | 45 +
.../node_modules/adbkit-monkey/package.json | 79 +
.../adbkit/node_modules/bluebird/.npmignore | 30 +
.../adbkit/node_modules/bluebird/API.md | 1741 +++++
.../node_modules/bluebird/CONTRIBUTING.md | 68 +
.../adbkit/node_modules/bluebird/Gruntfile.js | 725 ++
.../adbkit/node_modules/bluebird/LICENSE | 19 +
.../adbkit/node_modules/bluebird/README.md | 696 ++
.../bluebird/benchmark/package.json | 34 +
.../adbkit/node_modules/bluebird/bower.json | 35 +
.../adbkit/node_modules/bluebird/bundle.js | 0
.../adbkit/node_modules/bluebird/changelog.md | 1135 +++
.../adbkit/node_modules/bluebird/js/main/any.js | 54 +
.../node_modules/bluebird/js/main/assert.js | 83 +
.../node_modules/bluebird/js/main/async.js | 111 +
.../node_modules/bluebird/js/main/bluebird.js | 25 +
.../node_modules/bluebird/js/main/call_get.js | 55 +
.../node_modules/bluebird/js/main/cancel.js | 77 +
.../bluebird/js/main/captured_trace.js | 237 +
.../bluebird/js/main/catch_filter.js | 93 +
.../bluebird/js/main/direct_resolve.js | 83 +
.../node_modules/bluebird/js/main/errors.js | 114 +
.../bluebird/js/main/errors_api_rejection.js | 38 +
.../adbkit/node_modules/bluebird/js/main/es5.js | 89 +
.../node_modules/bluebird/js/main/filter.js | 53 +
.../node_modules/bluebird/js/main/finally.js | 132 +
.../node_modules/bluebird/js/main/generators.js | 56 +
.../node_modules/bluebird/js/main/global.js | 42 +
.../adbkit/node_modules/bluebird/js/main/map.js | 127 +
.../node_modules/bluebird/js/main/nodeify.js | 64 +
.../node_modules/bluebird/js/main/progress.js | 113 +
.../node_modules/bluebird/js/main/promise.js | 1167 +++
.../bluebird/js/main/promise_array.js | 233 +
.../bluebird/js/main/promise_inspection.js | 66 +
.../bluebird/js/main/promise_resolver.js | 152 +
.../bluebird/js/main/promise_spawn.js | 131 +
.../node_modules/bluebird/js/main/promisify.js | 278 +
.../js/main/properties_promise_array.js | 77 +
.../node_modules/bluebird/js/main/props.js | 65 +
.../node_modules/bluebird/js/main/queue.js | 135 +
.../node_modules/bluebird/js/main/race.js | 85 +
.../node_modules/bluebird/js/main/reduce.js | 173 +
.../node_modules/bluebird/js/main/schedule.js | 121 +
.../node_modules/bluebird/js/main/settle.js | 49 +
.../bluebird/js/main/settled_promise_array.js | 60 +
.../node_modules/bluebird/js/main/some.js | 57 +
.../bluebird/js/main/some_promise_array.js | 131 +
.../bluebird/js/main/synchronous_inspection.js | 30 +
.../node_modules/bluebird/js/main/thenables.js | 138 +
.../node_modules/bluebird/js/main/timers.js | 114 +
.../node_modules/bluebird/js/main/util.js | 193 +
.../node_modules/bluebird/js/zalgo/any.js | 54 +
.../node_modules/bluebird/js/zalgo/assert.js | 83 +
.../node_modules/bluebird/js/zalgo/async.js | 111 +
.../node_modules/bluebird/js/zalgo/bluebird.js | 25 +
.../node_modules/bluebird/js/zalgo/call_get.js | 55 +
.../node_modules/bluebird/js/zalgo/cancel.js | 77 +
.../bluebird/js/zalgo/captured_trace.js | 237 +
.../bluebird/js/zalgo/catch_filter.js | 93 +
.../bluebird/js/zalgo/direct_resolve.js | 83 +
.../node_modules/bluebird/js/zalgo/errors.js | 114 +
.../bluebird/js/zalgo/errors_api_rejection.js | 38 +
.../node_modules/bluebird/js/zalgo/es5.js | 89 +
.../node_modules/bluebird/js/zalgo/filter.js | 53 +
.../node_modules/bluebird/js/zalgo/finally.js | 132 +
.../bluebird/js/zalgo/generators.js | 56 +
.../node_modules/bluebird/js/zalgo/global.js | 42 +
.../node_modules/bluebird/js/zalgo/map.js | 127 +
.../node_modules/bluebird/js/zalgo/nodeify.js | 64 +
.../node_modules/bluebird/js/zalgo/progress.js | 111 +
.../node_modules/bluebird/js/zalgo/promise.js | 1167 +++
.../bluebird/js/zalgo/promise_array.js | 233 +
.../bluebird/js/zalgo/promise_inspection.js | 66 +
.../bluebird/js/zalgo/promise_resolver.js | 152 +
.../bluebird/js/zalgo/promise_spawn.js | 131 +
.../node_modules/bluebird/js/zalgo/promisify.js | 278 +
.../js/zalgo/properties_promise_array.js | 77 +
.../node_modules/bluebird/js/zalgo/props.js | 65 +
.../node_modules/bluebird/js/zalgo/queue.js | 135 +
.../node_modules/bluebird/js/zalgo/race.js | 85 +
.../node_modules/bluebird/js/zalgo/reduce.js | 173 +
.../node_modules/bluebird/js/zalgo/schedule.js | 121 +
.../node_modules/bluebird/js/zalgo/settle.js | 49 +
.../bluebird/js/zalgo/settled_promise_array.js | 60 +
.../node_modules/bluebird/js/zalgo/some.js | 57 +
.../bluebird/js/zalgo/some_promise_array.js | 131 +
.../bluebird/js/zalgo/synchronous_inspection.js | 30 +
.../node_modules/bluebird/js/zalgo/thenables.js | 138 +
.../node_modules/bluebird/js/zalgo/timers.js | 114 +
.../node_modules/bluebird/js/zalgo/util.js | 193 +
.../adbkit/node_modules/bluebird/package.json | 85 +
.../adbkit/node_modules/bluebird/zalgo.js | 1 +
.../adbkit/node_modules/commander/History.md | 239 +
.../adbkit/node_modules/commander/LICENSE | 22 +
.../adbkit/node_modules/commander/Readme.md | 311 +
.../adbkit/node_modules/commander/index.js | 1051 +++
.../node_modules/graceful-readlink/.npmignore | 3 +
.../node_modules/graceful-readlink/.travis.yml | 5 +
.../node_modules/graceful-readlink/LICENSE | 22 +
.../node_modules/graceful-readlink/README.md | 17 +
.../node_modules/graceful-readlink/index.js | 12 +
.../node_modules/graceful-readlink/package.json | 48 +
.../adbkit/node_modules/commander/package.json | 74 +
.../adbkit/node_modules/debug/Readme.md | 115 +
.../adbkit/node_modules/debug/debug.js | 137 +
.../adbkit/node_modules/debug/index.js | 5 +
.../adbkit/node_modules/debug/lib/debug.js | 147 +
.../adbkit/node_modules/debug/package.json | 65 +
.../adbkit/node_modules/node-forge/.jscsrc | 64 +
.../node_modules/node-forge/.jshintignore | 6 +
.../adbkit/node_modules/node-forge/.jshintrc | 3 +
.../adbkit/node_modules/node-forge/.npmignore | 22 +
.../adbkit/node_modules/node-forge/.travis.yml | 10 +
.../adbkit/node_modules/node-forge/HACKING.md | 37 +
.../adbkit/node_modules/node-forge/LICENSE | 331 +
.../adbkit/node_modules/node-forge/Makefile.in | 110 +
.../adbkit/node_modules/node-forge/README.md | 1782 +++++
.../adbkit/node_modules/node-forge/bower.json | 15 +
.../node_modules/node-forge/build-flash.xml | 7 +
.../adbkit/node_modules/node-forge/build-setup | 46 +
.../adbkit/node_modules/node-forge/end.frag | 4 +
.../node-forge/flash/PooledSocket.as | 18 +
.../node-forge/flash/SocketEvent.as | 36 +
.../node_modules/node-forge/flash/SocketPool.as | 754 ++
.../adbkit/node_modules/node-forge/js/aes.js | 1146 +++
.../node-forge/js/aesCipherSuites.js | 312 +
.../adbkit/node_modules/node-forge/js/asn1.js | 1114 +++
.../adbkit/node_modules/node-forge/js/cipher.js | 286 +
.../node_modules/node-forge/js/cipherModes.js | 817 ++
.../adbkit/node_modules/node-forge/js/debug.js | 134 +
.../adbkit/node_modules/node-forge/js/des.js | 552 ++
.../adbkit/node_modules/node-forge/js/forge.js | 92 +
.../adbkit/node_modules/node-forge/js/form.js | 157 +
.../adbkit/node_modules/node-forge/js/hmac.js | 200 +
.../adbkit/node_modules/node-forge/js/http.js | 1369 ++++
.../adbkit/node_modules/node-forge/js/jsbn.js | 1321 ++++
.../adbkit/node_modules/node-forge/js/kem.js | 221 +
.../adbkit/node_modules/node-forge/js/log.js | 372 +
.../adbkit/node_modules/node-forge/js/md.js | 75 +
.../adbkit/node_modules/node-forge/js/md5.js | 322 +
.../adbkit/node_modules/node-forge/js/mgf.js | 67 +
.../adbkit/node_modules/node-forge/js/mgf1.js | 112 +
.../adbkit/node_modules/node-forge/js/oids.js | 269 +
.../adbkit/node_modules/node-forge/js/pbe.js | 975 +++
.../adbkit/node_modules/node-forge/js/pbkdf2.js | 214 +
.../adbkit/node_modules/node-forge/js/pem.js | 285 +
.../adbkit/node_modules/node-forge/js/pkcs1.js | 329 +
.../adbkit/node_modules/node-forge/js/pkcs12.js | 1121 +++
.../adbkit/node_modules/node-forge/js/pkcs7.js | 842 ++
.../node_modules/node-forge/js/pkcs7asn1.js | 399 +
.../adbkit/node_modules/node-forge/js/pki.js | 161 +
.../adbkit/node_modules/node-forge/js/prime.js | 337 +
.../node_modules/node-forge/js/prime.worker.js | 165 +
.../adbkit/node_modules/node-forge/js/prng.js | 458 ++
.../adbkit/node_modules/node-forge/js/pss.js | 295 +
.../adbkit/node_modules/node-forge/js/random.js | 237 +
.../adbkit/node_modules/node-forge/js/rc2.js | 470 ++
.../adbkit/node_modules/node-forge/js/rsa.js | 1712 +++++
.../adbkit/node_modules/node-forge/js/sha1.js | 342 +
.../adbkit/node_modules/node-forge/js/sha256.js | 352 +
.../adbkit/node_modules/node-forge/js/sha512.js | 590 ++
.../adbkit/node_modules/node-forge/js/socket.js | 342 +
.../adbkit/node_modules/node-forge/js/ssh.js | 295 +
.../adbkit/node_modules/node-forge/js/task.js | 778 ++
.../adbkit/node_modules/node-forge/js/tls.js | 4316 +++++++++++
.../node_modules/node-forge/js/tlssocket.js | 304 +
.../adbkit/node_modules/node-forge/js/util.js | 2953 +++++++
.../adbkit/node_modules/node-forge/js/x509.js | 3178 ++++++++
.../adbkit/node_modules/node-forge/js/xhr.js | 739 ++
.../adbkit/node_modules/node-forge/minify.js | 10 +
.../node_modules/node-forge/mod_fsp/README | 135 +
.../node_modules/node-forge/mod_fsp/mod_fsp.c | 415 +
.../node_modules/node-forge/nodejs/README.md | 34 +
.../node_modules/node-forge/nodejs/build.js | 8 +
.../node_modules/node-forge/nodejs/minify.js | 8 +
.../node_modules/node-forge/nodejs/package.json | 17 +
.../node_modules/node-forge/nodejs/server.js | 46 +
.../node_modules/node-forge/nodejs/test/aes.js | 1213 +++
.../node_modules/node-forge/nodejs/test/asn1.js | 262 +
.../node-forge/nodejs/test/browser.js | 41 +
.../node_modules/node-forge/nodejs/test/csr.js | 148 +
.../node_modules/node-forge/nodejs/test/des.js | 155 +
.../node_modules/node-forge/nodejs/test/hmac.js | 85 +
.../node_modules/node-forge/nodejs/test/kem.js | 198 +
.../node_modules/node-forge/nodejs/test/md5.js | 117 +
.../node_modules/node-forge/nodejs/test/mgf1.js | 39 +
.../node-forge/nodejs/test/pbkdf2.js | 123 +
.../node_modules/node-forge/nodejs/test/pem.js | 104 +
.../node-forge/nodejs/test/pkcs1.js | 1105 +++
.../node-forge/nodejs/test/pkcs12.js | 650 ++
.../node-forge/nodejs/test/pkcs7.js | 350 +
.../node-forge/nodejs/test/random.js | 70 +
.../node_modules/node-forge/nodejs/test/rc2.js | 109 +
.../node_modules/node-forge/nodejs/test/rsa.js | 602 ++
.../node_modules/node-forge/nodejs/test/sha1.js | 75 +
.../node-forge/nodejs/test/sha256.js | 81 +
.../node-forge/nodejs/test/sha512.js | 174 +
.../node_modules/node-forge/nodejs/test/ssh.js | 193 +
.../node_modules/node-forge/nodejs/test/tls.js | 191 +
.../node_modules/node-forge/nodejs/test/util.js | 406 +
.../node_modules/node-forge/nodejs/test/x509.js | 734 ++
.../node-forge/nodejs/ui/index.html | 12 +
.../node-forge/nodejs/ui/require.js | 35 +
.../node_modules/node-forge/nodejs/ui/test.js | 36 +
.../node-forge/nodejs/ui/test.min.js | 1 +
.../adbkit/node_modules/node-forge/package.json | 113 +
.../node_modules/node-forge/setup/configure.ac | 202 +
.../node_modules/node-forge/setup/install-sh | 269 +
.../node-forge/setup/m4/as-python.m4 | 156 +
.../adbkit/node_modules/node-forge/start.frag | 7 +
.../node_modules/node-forge/tests/aes-speed.js | 54 +
.../node_modules/node-forge/tests/common.html | 84 +
.../node_modules/node-forge/tests/common.js | 2199 ++++++
.../node_modules/node-forge/tests/favicon.ico | 0
.../node_modules/node-forge/tests/flash/Test.as | 96 +
.../node-forge/tests/flash/build-flash.xml | 7 +
.../node-forge/tests/flash/index.html | 27 +
.../tests/forge_ssl/forge/__init__.py | 0
.../node-forge/tests/forge_ssl/forge/_ssl.c | 1770 +++++
.../tests/forge_ssl/forge/socketmodule.h | 268 +
.../node-forge/tests/forge_ssl/forge/ssl.py | 486 ++
.../node-forge/tests/forge_ssl/setup.py | 12 +
.../node_modules/node-forge/tests/form.html | 150 +
.../node_modules/node-forge/tests/form.js | 40 +
.../node_modules/node-forge/tests/heartbleed.js | 55 +
.../node_modules/node-forge/tests/http.html | 229 +
.../node_modules/node-forge/tests/index.html | 64 +
.../node_modules/node-forge/tests/keygen.html | 56 +
.../node_modules/node-forge/tests/login.css | 26 +
.../node-forge/tests/loginDemo.html | 56 +
.../node_modules/node-forge/tests/loginDemo.js | 149 +
.../node-forge/tests/nodejs-create-cert.js | 110 +
.../node-forge/tests/nodejs-create-csr.js | 66 +
.../node-forge/tests/nodejs-create-pkcs12.js | 160 +
.../node-forge/tests/nodejs-imap.js | 46 +
.../node_modules/node-forge/tests/nodejs-tls.js | 189 +
.../node-forge/tests/nodejs-ws-webid.js | 491 ++
.../node_modules/node-forge/tests/nodejs-ws.js | 166 +
.../node-forge/tests/performance.html | 550 ++
.../node-forge/tests/policyserver.py | 112 +
.../node_modules/node-forge/tests/result.txt | 1 +
.../node_modules/node-forge/tests/screen.css | 61 +
.../node_modules/node-forge/tests/server.crt | 26 +
.../node_modules/node-forge/tests/server.key | 27 +
.../node_modules/node-forge/tests/server.py | 184 +
.../node-forge/tests/socketPool.html | 299 +
.../node_modules/node-forge/tests/tasks.html | 53 +
.../node_modules/node-forge/tests/tasks.js | 378 +
.../node_modules/node-forge/tests/tls.html | 426 ++
.../node_modules/node-forge/tests/webid.html | 110 +
.../node_modules/node-forge/tests/webid.js | 313 +
.../node_modules/node-forge/tests/ws-webid.js | 132 +
.../adbkit/node_modules/node-forge/tests/ws.js | 237 +
.../node_modules/node-forge/tests/xhr.html | 87 +
.../adbkit/node_modules/node-forge/tests/xhr.js | 590 ++
.../adbkit/node_modules/split/.npmignore | 3 +
.../adbkit/node_modules/split/.travis.yml | 4 +
.../adbkit/node_modules/split/LICENCE | 22 +
.../node_modules/split/examples/pretty.js | 26 +
.../adbkit/node_modules/split/index.js | 59 +
.../split/node_modules/through/.travis.yml | 5 +
.../split/node_modules/through/LICENSE.APACHE2 | 15 +
.../split/node_modules/through/LICENSE.MIT | 24 +
.../split/node_modules/through/index.js | 108 +
.../split/node_modules/through/package.json | 65 +
.../split/node_modules/through/readme.markdown | 64 +
.../split/node_modules/through/test/async.js | 28 +
.../node_modules/through/test/auto-destroy.js | 30 +
.../node_modules/through/test/buffering.js | 71 +
.../split/node_modules/through/test/end.js | 45 +
.../split/node_modules/through/test/index.js | 117 +
.../adbkit/node_modules/split/package.json | 39 +
.../adbkit/node_modules/split/readme.markdown | 39 +
.../split/test/partitioned_unicode.js | 34 +
.../node_modules/split/test/split.asynct.js | 85 +
.../node_modules/split/test/try_catch.asynct.js | 51 +
.../node_modules/adbkit/package.json | 88 +
.../node-firefox-find-devices/package.json | 61 +
.../tests/unit/test.index.js | 87 +
node_modules/node-firefox-find-ports/.npmignore | 4 +
.../node-firefox-find-ports/.travis.yml | 3 +
node_modules/node-firefox-find-ports/LICENSE | 13 +
node_modules/node-firefox-find-ports/README.md | 185 +
.../examples/findFirefoxOSSimulatorPorts.js | 13 +
.../node-firefox-find-ports/examples/usage.js | 37 +
.../node-firefox-find-ports/gulpfile.js | 3 +
node_modules/node-firefox-find-ports/index.js | 203 +
.../node-firefox-find-ports/lib/parsers.js | 115 +
.../node_modules/.bin/shjs | 1 +
.../node_modules/adbkit/LICENSE | 13 +
.../node_modules/adbkit/README.md | 1089 +++
.../node_modules/adbkit/index.js | 15 +
.../node_modules/adbkit/lib/adb.js | 27 +
.../node_modules/adbkit/lib/adb/auth.js | 81 +
.../node_modules/adbkit/lib/adb/client.js | 552 ++
.../node_modules/adbkit/lib/adb/command.js | 48 +
.../lib/adb/command/host-serial/forward.js | 48 +
.../adb/command/host-serial/getdevicepath.js | 41 +
.../lib/adb/command/host-serial/getserialno.js | 41 +
.../lib/adb/command/host-serial/getstate.js | 41 +
.../lib/adb/command/host-serial/listforwards.js | 59 +
.../adb/command/host-serial/waitfordevice.js | 48 +
.../lib/adb/command/host-transport/clear.js | 47 +
.../adb/command/host-transport/framebuffer.js | 117 +
.../adb/command/host-transport/getfeatures.js | 54 +
.../adb/command/host-transport/getpackages.js | 54 +
.../adb/command/host-transport/getproperties.js | 56 +
.../lib/adb/command/host-transport/install.js | 51 +
.../adb/command/host-transport/isinstalled.js | 50 +
.../lib/adb/command/host-transport/local.js | 39 +
.../lib/adb/command/host-transport/log.js | 39 +
.../lib/adb/command/host-transport/logcat.js | 49 +
.../lib/adb/command/host-transport/monkey.js | 45 +
.../lib/adb/command/host-transport/reboot.js | 39 +
.../lib/adb/command/host-transport/remount.js | 39 +
.../lib/adb/command/host-transport/screencap.js | 57 +
.../lib/adb/command/host-transport/shell.js | 42 +
.../adb/command/host-transport/startactivity.js | 187 +
.../adb/command/host-transport/startservice.js | 36 +
.../lib/adb/command/host-transport/sync.js | 41 +
.../lib/adb/command/host-transport/tcp.js | 39 +
.../lib/adb/command/host-transport/tcpip.js | 51 +
.../lib/adb/command/host-transport/trackjdwp.js | 123 +
.../lib/adb/command/host-transport/uninstall.js | 47 +
.../lib/adb/command/host-transport/usb.js | 51 +
.../command/host-transport/waitbootcomplete.js | 45 +
.../adbkit/lib/adb/command/host/connect.js | 49 +
.../adbkit/lib/adb/command/host/devices.js | 67 +
.../lib/adb/command/host/deviceswithpaths.js | 68 +
.../adbkit/lib/adb/command/host/disconnect.js | 49 +
.../adbkit/lib/adb/command/host/kill.js | 39 +
.../adbkit/lib/adb/command/host/trackdevices.js | 43 +
.../adbkit/lib/adb/command/host/transport.js | 39 +
.../adbkit/lib/adb/command/host/version.js | 45 +
.../node_modules/adbkit/lib/adb/connection.js | 108 +
.../adbkit/lib/adb/framebuffer/rgbtransform.js | 58 +
.../node_modules/adbkit/lib/adb/keycode.js | 228 +
.../adbkit/lib/adb/linetransform.js | 58 +
.../node_modules/adbkit/lib/adb/parser.js | 247 +
.../node_modules/adbkit/lib/adb/proc/stat.js | 140 +
.../node_modules/adbkit/lib/adb/protocol.js | 48 +
.../node_modules/adbkit/lib/adb/sync.js | 337 +
.../node_modules/adbkit/lib/adb/sync/entry.js | 26 +
.../adbkit/lib/adb/sync/pulltransfer.js | 34 +
.../adbkit/lib/adb/sync/pushtransfer.js | 43 +
.../node_modules/adbkit/lib/adb/sync/stats.js | 57 +
.../adbkit/lib/adb/tcpusb/rollingcounter.js | 24 +
.../adbkit/lib/adb/tcpusb/server.js | 72 +
.../adbkit/lib/adb/tcpusb/servicemap.js | 43 +
.../adbkit/lib/adb/tcpusb/socket.js | 391 +
.../node_modules/adbkit/lib/adb/tracker.js | 92 +
.../node_modules/adbkit/lib/adb/util.js | 16 +
.../node_modules/adbkit/lib/cli.js | 42 +
.../adbkit/node_modules/adbkit-logcat/LICENSE | 13 +
.../adbkit/node_modules/adbkit-logcat/README.md | 240 +
.../adbkit/node_modules/adbkit-logcat/index.js | 15 +
.../node_modules/adbkit-logcat/lib/logcat.js | 25 +
.../adbkit-logcat/lib/logcat/entry.js | 76 +
.../adbkit-logcat/lib/logcat/parser.js | 32 +
.../adbkit-logcat/lib/logcat/parser/binary.js | 78 +
.../adbkit-logcat/lib/logcat/priority.js | 89 +
.../adbkit-logcat/lib/logcat/reader.js | 137 +
.../adbkit-logcat/lib/logcat/transform.js | 51 +
.../node_modules/adbkit-logcat/package.json | 75 +
.../adbkit/node_modules/adbkit-monkey/LICENSE | 13 +
.../adbkit/node_modules/adbkit-monkey/README.md | 469 ++
.../adbkit/node_modules/adbkit-monkey/index.js | 15 +
.../node_modules/adbkit-monkey/lib/monkey.js | 29 +
.../adbkit-monkey/lib/monkey/api.js | 276 +
.../adbkit-monkey/lib/monkey/client.js | 98 +
.../adbkit-monkey/lib/monkey/command.js | 17 +
.../adbkit-monkey/lib/monkey/connection.js | 42 +
.../adbkit-monkey/lib/monkey/multi.js | 85 +
.../adbkit-monkey/lib/monkey/parser.js | 66 +
.../adbkit-monkey/lib/monkey/queue.js | 38 +
.../adbkit-monkey/lib/monkey/reply.js | 31 +
.../adbkit-monkey/node_modules/async/LICENSE | 19 +
.../adbkit-monkey/node_modules/async/README.md | 1425 ++++
.../node_modules/async/component.json | 11 +
.../node_modules/async/lib/async.js | 958 +++
.../node_modules/async/package.json | 45 +
.../node_modules/adbkit-monkey/package.json | 79 +
.../adbkit/node_modules/bluebird/.npmignore | 30 +
.../adbkit/node_modules/bluebird/API.md | 1741 +++++
.../node_modules/bluebird/CONTRIBUTING.md | 68 +
.../adbkit/node_modules/bluebird/Gruntfile.js | 725 ++
.../adbkit/node_modules/bluebird/LICENSE | 19 +
.../adbkit/node_modules/bluebird/README.md | 696 ++
.../bluebird/benchmark/package.json | 34 +
.../adbkit/node_modules/bluebird/bower.json | 35 +
.../adbkit/node_modules/bluebird/bundle.js | 0
.../adbkit/node_modules/bluebird/changelog.md | 1135 +++
.../adbkit/node_modules/bluebird/js/main/any.js | 54 +
.../node_modules/bluebird/js/main/assert.js | 83 +
.../node_modules/bluebird/js/main/async.js | 111 +
.../node_modules/bluebird/js/main/bluebird.js | 25 +
.../node_modules/bluebird/js/main/call_get.js | 55 +
.../node_modules/bluebird/js/main/cancel.js | 77 +
.../bluebird/js/main/captured_trace.js | 237 +
.../bluebird/js/main/catch_filter.js | 93 +
.../bluebird/js/main/direct_resolve.js | 83 +
.../node_modules/bluebird/js/main/errors.js | 114 +
.../bluebird/js/main/errors_api_rejection.js | 38 +
.../adbkit/node_modules/bluebird/js/main/es5.js | 89 +
.../node_modules/bluebird/js/main/filter.js | 53 +
.../node_modules/bluebird/js/main/finally.js | 132 +
.../node_modules/bluebird/js/main/generators.js | 56 +
.../node_modules/bluebird/js/main/global.js | 42 +
.../adbkit/node_modules/bluebird/js/main/map.js | 127 +
.../node_modules/bluebird/js/main/nodeify.js | 64 +
.../node_modules/bluebird/js/main/progress.js | 113 +
.../node_modules/bluebird/js/main/promise.js | 1167 +++
.../bluebird/js/main/promise_array.js | 233 +
.../bluebird/js/main/promise_inspection.js | 66 +
.../bluebird/js/main/promise_resolver.js | 152 +
.../bluebird/js/main/promise_spawn.js | 131 +
.../node_modules/bluebird/js/main/promisify.js | 278 +
.../js/main/properties_promise_array.js | 77 +
.../node_modules/bluebird/js/main/props.js | 65 +
.../node_modules/bluebird/js/main/queue.js | 135 +
.../node_modules/bluebird/js/main/race.js | 85 +
.../node_modules/bluebird/js/main/reduce.js | 173 +
.../node_modules/bluebird/js/main/schedule.js | 121 +
.../node_modules/bluebird/js/main/settle.js | 49 +
.../bluebird/js/main/settled_promise_array.js | 60 +
.../node_modules/bluebird/js/main/some.js | 57 +
.../bluebird/js/main/some_promise_array.js | 131 +
.../bluebird/js/main/synchronous_inspection.js | 30 +
.../node_modules/bluebird/js/main/thenables.js | 138 +
.../node_modules/bluebird/js/main/timers.js | 114 +
.../node_modules/bluebird/js/main/util.js | 193 +
.../node_modules/bluebird/js/zalgo/any.js | 54 +
.../node_modules/bluebird/js/zalgo/assert.js | 83 +
.../node_modules/bluebird/js/zalgo/async.js | 111 +
.../node_modules/bluebird/js/zalgo/bluebird.js | 25 +
.../node_modules/bluebird/js/zalgo/call_get.js | 55 +
.../node_modules/bluebird/js/zalgo/cancel.js | 77 +
.../bluebird/js/zalgo/captured_trace.js | 237 +
.../bluebird/js/zalgo/catch_filter.js | 93 +
.../bluebird/js/zalgo/direct_resolve.js | 83 +
.../node_modules/bluebird/js/zalgo/errors.js | 114 +
.../bluebird/js/zalgo/errors_api_rejection.js | 38 +
.../node_modules/bluebird/js/zalgo/es5.js | 89 +
.../node_modules/bluebird/js/zalgo/filter.js | 53 +
.../node_modules/bluebird/js/zalgo/finally.js | 132 +
.../bluebird/js/zalgo/generators.js | 56 +
.../node_modules/bluebird/js/zalgo/global.js | 42 +
.../node_modules/bluebird/js/zalgo/map.js | 127 +
.../node_modules/bluebird/js/zalgo/nodeify.js | 64 +
.../node_modules/bluebird/js/zalgo/progress.js | 111 +
.../node_modules/bluebird/js/zalgo/promise.js | 1167 +++
.../bluebird/js/zalgo/promise_array.js | 233 +
.../bluebird/js/zalgo/promise_inspection.js | 66 +
.../bluebird/js/zalgo/promise_resolver.js | 152 +
.../bluebird/js/zalgo/promise_spawn.js | 131 +
.../node_modules/bluebird/js/zalgo/promisify.js | 278 +
.../js/zalgo/properties_promise_array.js | 77 +
.../node_modules/bluebird/js/zalgo/props.js | 65 +
.../node_modules/bluebird/js/zalgo/queue.js | 135 +
.../node_modules/bluebird/js/zalgo/race.js | 85 +
.../node_modules/bluebird/js/zalgo/reduce.js | 173 +
.../node_modules/bluebird/js/zalgo/schedule.js | 121 +
.../node_modules/bluebird/js/zalgo/settle.js | 49 +
.../bluebird/js/zalgo/settled_promise_array.js | 60 +
.../node_modules/bluebird/js/zalgo/some.js | 57 +
.../bluebird/js/zalgo/some_promise_array.js | 131 +
.../bluebird/js/zalgo/synchronous_inspection.js | 30 +
.../node_modules/bluebird/js/zalgo/thenables.js | 138 +
.../node_modules/bluebird/js/zalgo/timers.js | 114 +
.../node_modules/bluebird/js/zalgo/util.js | 193 +
.../adbkit/node_modules/bluebird/package.json | 85 +
.../adbkit/node_modules/bluebird/zalgo.js | 1 +
.../adbkit/node_modules/commander/History.md | 239 +
.../adbkit/node_modules/commander/LICENSE | 22 +
.../adbkit/node_modules/commander/Readme.md | 311 +
.../adbkit/node_modules/commander/index.js | 1051 +++
.../node_modules/graceful-readlink/.npmignore | 3 +
.../node_modules/graceful-readlink/.travis.yml | 5 +
.../node_modules/graceful-readlink/LICENSE | 22 +
.../node_modules/graceful-readlink/README.md | 17 +
.../node_modules/graceful-readlink/index.js | 12 +
.../node_modules/graceful-readlink/package.json | 48 +
.../adbkit/node_modules/commander/package.json | 74 +
.../adbkit/node_modules/debug/Readme.md | 115 +
.../adbkit/node_modules/debug/debug.js | 137 +
.../adbkit/node_modules/debug/index.js | 5 +
.../adbkit/node_modules/debug/lib/debug.js | 147 +
.../adbkit/node_modules/debug/package.json | 65 +
.../adbkit/node_modules/node-forge/.jscsrc | 64 +
.../node_modules/node-forge/.jshintignore | 6 +
.../adbkit/node_modules/node-forge/.jshintrc | 3 +
.../adbkit/node_modules/node-forge/.npmignore | 22 +
.../adbkit/node_modules/node-forge/.travis.yml | 10 +
.../adbkit/node_modules/node-forge/HACKING.md | 37 +
.../adbkit/node_modules/node-forge/LICENSE | 331 +
.../adbkit/node_modules/node-forge/Makefile.in | 110 +
.../adbkit/node_modules/node-forge/README.md | 1782 +++++
.../adbkit/node_modules/node-forge/bower.json | 15 +
.../node_modules/node-forge/build-flash.xml | 7 +
.../adbkit/node_modules/node-forge/build-setup | 46 +
.../adbkit/node_modules/node-forge/end.frag | 4 +
.../node-forge/flash/PooledSocket.as | 18 +
.../node-forge/flash/SocketEvent.as | 36 +
.../node_modules/node-forge/flash/SocketPool.as | 754 ++
.../adbkit/node_modules/node-forge/js/aes.js | 1146 +++
.../node-forge/js/aesCipherSuites.js | 312 +
.../adbkit/node_modules/node-forge/js/asn1.js | 1114 +++
.../adbkit/node_modules/node-forge/js/cipher.js | 286 +
.../node_modules/node-forge/js/cipherModes.js | 817 ++
.../adbkit/node_modules/node-forge/js/debug.js | 134 +
.../adbkit/node_modules/node-forge/js/des.js | 552 ++
.../adbkit/node_modules/node-forge/js/forge.js | 92 +
.../adbkit/node_modules/node-forge/js/form.js | 157 +
.../adbkit/node_modules/node-forge/js/hmac.js | 200 +
.../adbkit/node_modules/node-forge/js/http.js | 1369 ++++
.../adbkit/node_modules/node-forge/js/jsbn.js | 1321 ++++
.../adbkit/node_modules/node-forge/js/kem.js | 221 +
.../adbkit/node_modules/node-forge/js/log.js | 372 +
.../adbkit/node_modules/node-forge/js/md.js | 75 +
.../adbkit/node_modules/node-forge/js/md5.js | 322 +
.../adbkit/node_modules/node-forge/js/mgf.js | 67 +
.../adbkit/node_modules/node-forge/js/mgf1.js | 112 +
.../adbkit/node_modules/node-forge/js/oids.js | 269 +
.../adbkit/node_modules/node-forge/js/pbe.js | 975 +++
.../adbkit/node_modules/node-forge/js/pbkdf2.js | 214 +
.../adbkit/node_modules/node-forge/js/pem.js | 285 +
.../adbkit/node_modules/node-forge/js/pkcs1.js | 329 +
.../adbkit/node_modules/node-forge/js/pkcs12.js | 1121 +++
.../adbkit/node_modules/node-forge/js/pkcs7.js | 842 ++
.../node_modules/node-forge/js/pkcs7asn1.js | 399 +
.../adbkit/node_modules/node-forge/js/pki.js | 161 +
.../adbkit/node_modules/node-forge/js/prime.js | 337 +
.../node_modules/node-forge/js/prime.worker.js | 165 +
.../adbkit/node_modules/node-forge/js/prng.js | 458 ++
.../adbkit/node_modules/node-forge/js/pss.js | 295 +
.../adbkit/node_modules/node-forge/js/random.js | 237 +
.../adbkit/node_modules/node-forge/js/rc2.js | 470 ++
.../adbkit/node_modules/node-forge/js/rsa.js | 1712 +++++
.../adbkit/node_modules/node-forge/js/sha1.js | 342 +
.../adbkit/node_modules/node-forge/js/sha256.js | 352 +
.../adbkit/node_modules/node-forge/js/sha512.js | 590 ++
.../adbkit/node_modules/node-forge/js/socket.js | 342 +
.../adbkit/node_modules/node-forge/js/ssh.js | 295 +
.../adbkit/node_modules/node-forge/js/task.js | 778 ++
.../adbkit/node_modules/node-forge/js/tls.js | 4316 +++++++++++
.../node_modules/node-forge/js/tlssocket.js | 304 +
.../adbkit/node_modules/node-forge/js/util.js | 2953 +++++++
.../adbkit/node_modules/node-forge/js/x509.js | 3178 ++++++++
.../adbkit/node_modules/node-forge/js/xhr.js | 739 ++
.../adbkit/node_modules/node-forge/minify.js | 10 +
.../node_modules/node-forge/mod_fsp/README | 135 +
.../node_modules/node-forge/mod_fsp/mod_fsp.c | 415 +
.../node_modules/node-forge/nodejs/README.md | 34 +
.../node_modules/node-forge/nodejs/build.js | 8 +
.../node_modules/node-forge/nodejs/minify.js | 8 +
.../node_modules/node-forge/nodejs/package.json | 17 +
.../node_modules/node-forge/nodejs/server.js | 46 +
.../node_modules/node-forge/nodejs/test/aes.js | 1213 +++
.../node_modules/node-forge/nodejs/test/asn1.js | 262 +
.../node-forge/nodejs/test/browser.js | 41 +
.../node_modules/node-forge/nodejs/test/csr.js | 148 +
.../node_modules/node-forge/nodejs/test/des.js | 155 +
.../node_modules/node-forge/nodejs/test/hmac.js | 85 +
.../node_modules/node-forge/nodejs/test/kem.js | 198 +
.../node_modules/node-forge/nodejs/test/md5.js | 117 +
.../node_modules/node-forge/nodejs/test/mgf1.js | 39 +
.../node-forge/nodejs/test/pbkdf2.js | 123 +
.../node_modules/node-forge/nodejs/test/pem.js | 104 +
.../node-forge/nodejs/test/pkcs1.js | 1105 +++
.../node-forge/nodejs/test/pkcs12.js | 650 ++
.../node-forge/nodejs/test/pkcs7.js | 350 +
.../node-forge/nodejs/test/random.js | 70 +
.../node_modules/node-forge/nodejs/test/rc2.js | 109 +
.../node_modules/node-forge/nodejs/test/rsa.js | 602 ++
.../node_modules/node-forge/nodejs/test/sha1.js | 75 +
.../node-forge/nodejs/test/sha256.js | 81 +
.../node-forge/nodejs/test/sha512.js | 174 +
.../node_modules/node-forge/nodejs/test/ssh.js | 193 +
.../node_modules/node-forge/nodejs/test/tls.js | 191 +
.../node_modules/node-forge/nodejs/test/util.js | 406 +
.../node_modules/node-forge/nodejs/test/x509.js | 734 ++
.../node-forge/nodejs/ui/index.html | 12 +
.../node-forge/nodejs/ui/require.js | 35 +
.../node_modules/node-forge/nodejs/ui/test.js | 36 +
.../node-forge/nodejs/ui/test.min.js | 1 +
.../adbkit/node_modules/node-forge/package.json | 113 +
.../node_modules/node-forge/setup/configure.ac | 202 +
.../node_modules/node-forge/setup/install-sh | 269 +
.../node-forge/setup/m4/as-python.m4 | 156 +
.../adbkit/node_modules/node-forge/start.frag | 7 +
.../node_modules/node-forge/tests/aes-speed.js | 54 +
.../node_modules/node-forge/tests/common.html | 84 +
.../node_modules/node-forge/tests/common.js | 2199 ++++++
.../node_modules/node-forge/tests/favicon.ico | 0
.../node_modules/node-forge/tests/flash/Test.as | 96 +
.../node-forge/tests/flash/build-flash.xml | 7 +
.../node-forge/tests/flash/index.html | 27 +
.../tests/forge_ssl/forge/__init__.py | 0
.../node-forge/tests/forge_ssl/forge/_ssl.c | 1770 +++++
.../tests/forge_ssl/forge/socketmodule.h | 268 +
.../node-forge/tests/forge_ssl/forge/ssl.py | 486 ++
.../node-forge/tests/forge_ssl/setup.py | 12 +
.../node_modules/node-forge/tests/form.html | 150 +
.../node_modules/node-forge/tests/form.js | 40 +
.../node_modules/node-forge/tests/heartbleed.js | 55 +
.../node_modules/node-forge/tests/http.html | 229 +
.../node_modules/node-forge/tests/index.html | 64 +
.../node_modules/node-forge/tests/keygen.html | 56 +
.../node_modules/node-forge/tests/login.css | 26 +
.../node-forge/tests/loginDemo.html | 56 +
.../node_modules/node-forge/tests/loginDemo.js | 149 +
.../node-forge/tests/nodejs-create-cert.js | 110 +
.../node-forge/tests/nodejs-create-csr.js | 66 +
.../node-forge/tests/nodejs-create-pkcs12.js | 160 +
.../node-forge/tests/nodejs-imap.js | 46 +
.../node_modules/node-forge/tests/nodejs-tls.js | 189 +
.../node-forge/tests/nodejs-ws-webid.js | 491 ++
.../node_modules/node-forge/tests/nodejs-ws.js | 166 +
.../node-forge/tests/performance.html | 550 ++
.../node-forge/tests/policyserver.py | 112 +
.../node_modules/node-forge/tests/result.txt | 1 +
.../node_modules/node-forge/tests/screen.css | 61 +
.../node_modules/node-forge/tests/server.crt | 26 +
.../node_modules/node-forge/tests/server.key | 27 +
.../node_modules/node-forge/tests/server.py | 184 +
.../node-forge/tests/socketPool.html | 299 +
.../node_modules/node-forge/tests/tasks.html | 53 +
.../node_modules/node-forge/tests/tasks.js | 378 +
.../node_modules/node-forge/tests/tls.html | 426 ++
.../node_modules/node-forge/tests/webid.html | 110 +
.../node_modules/node-forge/tests/webid.js | 313 +
.../node_modules/node-forge/tests/ws-webid.js | 132 +
.../adbkit/node_modules/node-forge/tests/ws.js | 237 +
.../node_modules/node-forge/tests/xhr.html | 87 +
.../adbkit/node_modules/node-forge/tests/xhr.js | 590 ++
.../adbkit/node_modules/split/.npmignore | 3 +
.../adbkit/node_modules/split/.travis.yml | 4 +
.../adbkit/node_modules/split/LICENCE | 22 +
.../node_modules/split/examples/pretty.js | 26 +
.../adbkit/node_modules/split/index.js | 59 +
.../split/node_modules/through/.travis.yml | 5 +
.../split/node_modules/through/LICENSE.APACHE2 | 15 +
.../split/node_modules/through/LICENSE.MIT | 24 +
.../split/node_modules/through/index.js | 108 +
.../split/node_modules/through/package.json | 65 +
.../split/node_modules/through/readme.markdown | 64 +
.../split/node_modules/through/test/async.js | 28 +
.../node_modules/through/test/auto-destroy.js | 30 +
.../node_modules/through/test/buffering.js | 71 +
.../split/node_modules/through/test/end.js | 45 +
.../split/node_modules/through/test/index.js | 117 +
.../adbkit/node_modules/split/package.json | 39 +
.../adbkit/node_modules/split/readme.markdown | 39 +
.../split/test/partitioned_unicode.js | 34 +
.../node_modules/split/test/split.asynct.js | 85 +
.../node_modules/split/test/try_catch.asynct.js | 51 +
.../node_modules/adbkit/package.json | 88 +
.../node_modules/firefox-client/README.md | 157 +
.../node_modules/firefox-client/index.js | 1 +
.../node_modules/firefox-client/lib/browser.js | 123 +
.../firefox-client/lib/client-methods.js | 115 +
.../node_modules/firefox-client/lib/client.js | 246 +
.../node_modules/firefox-client/lib/console.js | 107 +
.../node_modules/firefox-client/lib/device.js | 29 +
.../node_modules/firefox-client/lib/dom.js | 68 +
.../node_modules/firefox-client/lib/domnode.js | 169 +
.../node_modules/firefox-client/lib/extend.js | 12 +
.../node_modules/firefox-client/lib/jsobject.js | 91 +
.../node_modules/firefox-client/lib/memory.js | 16 +
.../node_modules/firefox-client/lib/network.js | 105 +
.../firefox-client/lib/simulator.js | 22 +
.../firefox-client/lib/stylesheets.js | 96 +
.../node_modules/firefox-client/lib/tab.js | 87 +
.../node_modules/firefox-client/lib/webapps.js | 170 +
.../node_modules/colors/MIT-LICENSE.txt | 19 +
.../node_modules/colors/ReadMe.md | 30 +
.../node_modules/colors/colors.js | 230 +
.../node_modules/colors/example.html | 20 +
.../node_modules/colors/example.js | 20 +
.../node_modules/colors/package.json | 49 +
.../node_modules/js-select/LICENSE | 21 +
.../node_modules/js-select/README.md | 118 +
.../node_modules/js-select/index.js | 197 +
.../node_modules/JSONSelect/.gitmodules | 3 +
.../node_modules/JSONSelect/.npmignore | 5 +
.../node_modules/JSONSelect/JSONSelect.md | 214 +
.../js-select/node_modules/JSONSelect/README.md | 33 +
.../node_modules/JSONSelect/package.json | 49 +
.../JSONSelect/site/css/droid_sans.css | 6 +
.../JSONSelect/site/css/droid_sans.tt | Bin 0 -> 41028 bytes
.../node_modules/JSONSelect/site/css/style.css | 209 +
.../node_modules/JSONSelect/site/index.html | 139 +
.../node_modules/JSONSelect/site/js/demo.js | 64 +
.../JSONSelect/site/js/jquery-1.6.1.min.js | 18 +
.../site/js/jquery.ba-hashchange.min.js | 9 +
.../node_modules/JSONSelect/site/js/json2.js | 480 ++
.../node_modules/JSONSelect/site/js/main.js | 3 +
.../node_modules/JSONSelect/site/js/nav.js | 64 +
.../node_modules/JSONSelect/site/js/showdown.js | 1302 ++++
.../node_modules/JSONSelect/src/Makefile | 73 +
.../JSONSelect/src/build/jshint-check.js | 41 +
.../JSONSelect/src/build/lib/jshint.js | 3854 ++++++++++
.../JSONSelect/src/build/lib/jslint.js | 5504 ++++++++++++++
.../JSONSelect/src/build/lib/parse-js.js | 1319 ++++
.../JSONSelect/src/build/lib/process.js | 1616 ++++
.../JSONSelect/src/build/lib/squeeze-more.js | 22 +
.../JSONSelect/src/build/post-compile.js | 7 +
.../node_modules/JSONSelect/src/build/uglify.js | 199 +
.../JSONSelect/src/dist/jsonselect.js | 522 ++
.../JSONSelect/src/dist/jsonselect.min.js | 1 +
.../JSONSelect/src/dist/jsonselect.min.js.gz | Bin 0 -> 1851 bytes
.../node_modules/JSONSelect/src/jsonselect.js | 522 ++
.../JSONSelect/src/test/conformance_tests.html | 15 +
.../JSONSelect/src/test/css/style.css | 43 +
.../JSONSelect/src/test/js/conf_tests.js | 77 +
.../JSONSelect/src/test/js/doctest.css | 69 +
.../JSONSelect/src/test/js/doctest.js | 1397 ++++
.../JSONSelect/src/test/js/jquery-1.6.1.min.js | 18 +
.../JSONSelect/src/test/lex_test.html | 122 +
.../JSONSelect/src/test/match_test.html | 71 +
.../JSONSelect/src/test/parse_test.html | 98 +
.../node_modules/JSONSelect/src/test/run.js | 85 +
.../JSONSelect/src/test/tests/.npmignore | 1 +
.../JSONSelect/src/test/tests/README.md | 22 +
.../src/test/tests/level_1/basic.json | 31 +
.../test/tests/level_1/basic_first-child.output | 2 +
.../tests/level_1/basic_first-child.selector | 2 +
.../test/tests/level_1/basic_grouping.output | 4 +
.../test/tests/level_1/basic_grouping.selector | 1 +
.../src/test/tests/level_1/basic_id.output | 1 +
.../src/test/tests/level_1/basic_id.selector | 1 +
.../test/tests/level_1/basic_id_multiple.output | 3 +
.../tests/level_1/basic_id_multiple.selector | 1 +
.../test/tests/level_1/basic_id_quotes.output | 2 +
.../test/tests/level_1/basic_id_quotes.selector | 1 +
.../tests/level_1/basic_id_with_type.output | 1 +
.../tests/level_1/basic_id_with_type.selector | 1 +
.../test/tests/level_1/basic_last-child.output | 2 +
.../tests/level_1/basic_last-child.selector | 2 +
.../test/tests/level_1/basic_nth-child-2.output | 4 +
.../tests/level_1/basic_nth-child-2.selector | 1 +
.../test/tests/level_1/basic_nth-child.output | 3 +
.../test/tests/level_1/basic_nth-child.selector | 1 +
.../tests/level_1/basic_nth-last-child.output | 2 +
.../tests/level_1/basic_nth-last-child.selector | 1 +
.../test/tests/level_1/basic_root_pseudo.output | 31 +
.../tests/level_1/basic_root_pseudo.selector | 1 +
.../src/test/tests/level_1/basic_type.output | 14 +
.../src/test/tests/level_1/basic_type.selector | 1 +
.../src/test/tests/level_1/basic_type2.output | 1 +
.../src/test/tests/level_1/basic_type2.selector | 1 +
.../src/test/tests/level_1/basic_type3.output | 47 +
.../src/test/tests/level_1/basic_type3.selector | 1 +
.../test/tests/level_1/basic_universal.output | 85 +
.../test/tests/level_1/basic_universal.selector | 1 +
.../src/test/tests/level_1/collision.json | 6 +
.../test/tests/level_1/collision_nested.output | 1 +
.../tests/level_1/collision_nested.selector | 1 +
.../level_1/collision_quoted-string.output | 1 +
.../level_1/collision_quoted-string.selector | 1 +
.../test/tests/level_1/collision_string.output | 1 +
.../tests/level_1/collision_string.selector | 1 +
.../src/test/tests/level_2/sibling.json | 18 +
.../test/tests/level_2/sibling_childof.output | 1 +
.../test/tests/level_2/sibling_childof.selector | 2 +
.../tests/level_2/sibling_descendantof.output | 3 +
.../tests/level_2/sibling_descendantof.selector | 1 +
.../test/tests/level_2/sibling_unrooted.output | 3 +
.../tests/level_2/sibling_unrooted.selector | 1 +
.../src/test/tests/level_3/basic.json | 31 +
.../tests/level_3/basic_has-multiple.output | 4 +
.../tests/level_3/basic_has-multiple.selector | 1 +
.../tests/level_3/basic_has-root-in-expr.output | 4 +
.../level_3/basic_has-root-in-expr.selector | 1 +
.../level_3/basic_has-sans-first-paren.output | 1 +
.../level_3/basic_has-sans-first-paren.selector | 1 +
.../tests/level_3/basic_has-sans-paren.output | 1 +
.../tests/level_3/basic_has-sans-paren.selector | 2 +
.../tests/level_3/basic_has-whitespace.output | 12 +
.../tests/level_3/basic_has-whitespace.selector | 1 +
.../tests/level_3/basic_has-with-comma.output | 17 +
.../tests/level_3/basic_has-with-comma.selector | 1 +
.../src/test/tests/level_3/basic_has.output | 12 +
.../src/test/tests/level_3/basic_has.selector | 1 +
.../basic_multiple-has-with-strings.output | 5 +
.../basic_multiple-has-with-strings.selector | 1 +
.../JSONSelect/src/test/tests/level_3/expr.json | 9 +
.../src/test/tests/level_3/expr_div.output | 1 +
.../src/test/tests/level_3/expr_div.selector | 1 +
.../test/tests/level_3/expr_ends-with.output | 1 +
.../test/tests/level_3/expr_ends-with.selector | 1 +
.../src/test/tests/level_3/expr_false-eq.output | 3 +
.../test/tests/level_3/expr_false-eq.selector | 4 +
.../test/tests/level_3/expr_greater-than.output | 2 +
.../tests/level_3/expr_greater-than.selector | 1 +
.../test/tests/level_3/expr_less-than.output | 2 +
.../test/tests/level_3/expr_less-than.selector | 1 +
.../src/test/tests/level_3/expr_mod.output | 1 +
.../src/test/tests/level_3/expr_mod.selector | 1 +
.../src/test/tests/level_3/expr_mult.output | 1 +
.../src/test/tests/level_3/expr_mult.selector | 1 +
.../src/test/tests/level_3/expr_null-eq.output | 5 +
.../test/tests/level_3/expr_null-eq.selector | 4 +
.../test/tests/level_3/expr_number-eq.output | 1 +
.../test/tests/level_3/expr_number-eq.selector | 1 +
.../test/tests/level_3/expr_precedence-1.output | 1 +
.../tests/level_3/expr_precedence-1.selector | 1 +
.../test/tests/level_3/expr_precedence-2.output | 1 +
.../tests/level_3/expr_precedence-2.selector | 1 +
.../test/tests/level_3/expr_simple-false.output | 0
.../tests/level_3/expr_simple-false.selector | 1 +
.../src/test/tests/level_3/expr_simple.output | 1 +
.../src/test/tests/level_3/expr_simple.selector | 1 +
.../test/tests/level_3/expr_starts-with.output | 1 +
.../tests/level_3/expr_starts-with.selector | 1 +
.../test/tests/level_3/expr_string-eq.output | 1 +
.../test/tests/level_3/expr_string-eq.selector | 1 +
.../src/test/tests/level_3/expr_true-eq.output | 3 +
.../test/tests/level_3/expr_true-eq.selector | 2 +
.../src/test/tests/level_3/polykids.json | 15 +
.../level_3/polykids_has-with_descendant.output | 1 +
.../polykids_has-with_descendant.selector | 1 +
.../src/test/tests/level_3/polykids_val.output | 2 +
.../test/tests/level_3/polykids_val.selector | 1 +
.../js-select/node_modules/traverse/.npmignore | 1 +
.../js-select/node_modules/traverse/LICENSE | 24 +
.../node_modules/traverse/README.markdown | 273 +
.../node_modules/traverse/examples/json.js | 16 +
.../node_modules/traverse/examples/leaves.js | 15 +
.../node_modules/traverse/examples/negative.js | 8 +
.../node_modules/traverse/examples/scrub.js | 10 +
.../node_modules/traverse/examples/stringify.js | 38 +
.../js-select/node_modules/traverse/index.js | 332 +
.../node_modules/traverse/package.json | 42 +
.../node_modules/traverse/test/circular.js | 114 +
.../node_modules/traverse/test/date.js | 35 +
.../node_modules/traverse/test/equal.js | 219 +
.../node_modules/traverse/test/instance.js | 17 +
.../node_modules/traverse/test/interface.js | 42 +
.../node_modules/traverse/test/json.js | 47 +
.../node_modules/traverse/test/keys.js | 29 +
.../node_modules/traverse/test/leaves.js | 21 +
.../node_modules/traverse/test/mutability.js | 203 +
.../node_modules/traverse/test/negative.js | 20 +
.../js-select/node_modules/traverse/test/obj.js | 15 +
.../node_modules/traverse/test/siblings.js | 35 +
.../node_modules/traverse/test/stop.js | 41 +
.../node_modules/traverse/test/stringify.js | 36 +
.../node_modules/traverse/test/subexpr.js | 34 +
.../node_modules/traverse/test/super_deep.js | 54 +
.../node_modules/js-select/package.json | 51 +
.../node_modules/js-select/select-min.js | 37 +
.../node_modules/js-select/select.js | 1533 ++++
.../node_modules/js-select/test/runner.js | 58 +
.../node_modules/js-select/test/test.js | 161 +
.../node_modules/js-select/test/timeline.js | 1 +
.../node_modules/firefox-client/package.json | 52 +
.../node_modules/firefox-client/test.js | 54 +
.../node_modules/firefox-client/test/README.md | 29 +
.../firefox-client/test/pages/dom.html | 19 +
.../firefox-client/test/pages/index.html | 22 +
.../firefox-client/test/pages/logs.html | 17 +
.../firefox-client/test/pages/network.html | 22 +
.../firefox-client/test/pages/stylesheet1.css | 9 +
.../firefox-client/test/pages/stylesheets.html | 20 +
.../firefox-client/test/pages/test-network.json | 4 +
.../node_modules/firefox-client/test/server.js | 8 +
.../firefox-client/test/test-console.js | 64 +
.../firefox-client/test/test-dom.js | 329 +
.../firefox-client/test/test-jsobject.js | 115 +
.../firefox-client/test/test-logs.js | 106 +
.../firefox-client/test/test-network.js | 88 +
.../firefox-client/test/test-raw.js | 26 +
.../firefox-client/test/test-stylesheets.js | 124 +
.../node_modules/firefox-client/test/utils.js | 35 +
.../node_modules/shelljs/.documentup.json | 6 +
.../node_modules/shelljs/.jshintrc | 7 +
.../node_modules/shelljs/.npmignore | 2 +
.../node_modules/shelljs/.travis.yml | 5 +
.../node_modules/shelljs/LICENSE | 26 +
.../node_modules/shelljs/README.md | 569 ++
.../node_modules/shelljs/bin/shjs | 51 +
.../node_modules/shelljs/global.js | 3 +
.../node_modules/shelljs/make.js | 47 +
.../node_modules/shelljs/package.json | 63 +
.../shelljs/scripts/generate-docs.js | 21 +
.../node_modules/shelljs/scripts/run-tests.js | 50 +
.../node_modules/shelljs/shell.js | 157 +
.../node_modules/shelljs/src/cat.js | 43 +
.../node_modules/shelljs/src/cd.js | 19 +
.../node_modules/shelljs/src/chmod.js | 208 +
.../node_modules/shelljs/src/common.js | 203 +
.../node_modules/shelljs/src/cp.js | 201 +
.../node_modules/shelljs/src/dirs.js | 191 +
.../node_modules/shelljs/src/echo.js | 20 +
.../node_modules/shelljs/src/error.js | 10 +
.../node_modules/shelljs/src/exec.js | 181 +
.../node_modules/shelljs/src/find.js | 51 +
.../node_modules/shelljs/src/grep.js | 52 +
.../node_modules/shelljs/src/ln.js | 53 +
.../node_modules/shelljs/src/ls.js | 126 +
.../node_modules/shelljs/src/mkdir.js | 68 +
.../node_modules/shelljs/src/mv.js | 80 +
.../node_modules/shelljs/src/popd.js | 1 +
.../node_modules/shelljs/src/pushd.js | 1 +
.../node_modules/shelljs/src/pwd.js | 11 +
.../node_modules/shelljs/src/rm.js | 145 +
.../node_modules/shelljs/src/sed.js | 43 +
.../node_modules/shelljs/src/tempdir.js | 56 +
.../node_modules/shelljs/src/test.js | 85 +
.../node_modules/shelljs/src/to.js | 29 +
.../node_modules/shelljs/src/toEnd.js | 29 +
.../node_modules/shelljs/src/which.js | 83 +
.../node-firefox-find-ports/package.json | 73 +
.../tests/unit/data/darwin-firefox.txt | 6 +
.../tests/unit/data/darwin-no-runtimes.txt | 5 +
.../tests/unit/data/darwin-simulator.txt | 10 +
.../tests/unit/data/linux-firefox.txt | 17 +
.../tests/unit/data/linux-no-runtimes.txt | 14 +
.../tests/unit/data/linux-simulator.txt | 16 +
.../tests/unit/data/win32-firefox-netstat.txt | 35 +
.../tests/unit/data/win32-firefox-tasklist.txt | 28 +
.../unit/data/win32-no-runtimes-netstat.txt | 33 +
.../unit/data/win32-no-runtimes-tasklist.txt | 27 +
.../tests/unit/data/win32-simulator-netstat.txt | 35 +
.../unit/data/win32-simulator-tasklist.txt | 28 +
.../tests/unit/test.index.js | 144 +
.../tests/unit/test.parsers.js | 188 +
.../node-firefox-find-simulators/.editorconfig | 13 +
.../node-firefox-find-simulators/.npmignore | 3 +
.../node-firefox-find-simulators/.travis.yml | 6 +
.../node-firefox-find-simulators/LICENSE | 13 +
.../node-firefox-find-simulators/README.md | 115 +
.../examples/findAllSimulators.js | 9 +
.../examples/findCertainVersions.js | 17 +
.../node-firefox-find-simulators/gulpfile.js | 4 +
.../node-firefox-find-simulators/index.js | 107 +
.../lib/platform.js | 81 +
.../node_modules/es6-promise/.release.json | 17 +
.../node_modules/es6-promise/Brocfile.js | 75 +
.../node_modules/es6-promise/CHANGELOG.md | 9 +
.../node_modules/es6-promise/LICENSE | 19 +
.../node_modules/es6-promise/README.md | 58 +
.../es6-promise/bin/publish_to_s3.js | 28 +
.../node_modules/es6-promise/bower.json | 29 +
.../es6-promise/config/s3ProjectConfig.js | 26 +
.../es6-promise/config/versionTemplate.txt | 7 +
.../es6-promise/dist/es6-promise.js | 960 +++
.../es6-promise/dist/es6-promise.min.js | 18 +
.../es6-promise/lib/calculateVersion.js | 36 +
.../es6-promise/lib/es6-promise.umd.js | 16 +
.../es6-promise/lib/es6-promise/-internal.js | 251 +
.../es6-promise/lib/es6-promise/asap.js | 82 +
.../es6-promise/lib/es6-promise/enumerator.js | 125 +
.../es6-promise/lib/es6-promise/polyfill.js | 35 +
.../es6-promise/lib/es6-promise/promise.js | 409 +
.../es6-promise/lib/es6-promise/promise/all.js | 52 +
.../es6-promise/lib/es6-promise/promise/race.js | 105 +
.../lib/es6-promise/promise/reject.js | 47 +
.../lib/es6-promise/promise/resolve.js | 49 +
.../es6-promise/lib/es6-promise/utils.js | 39 +
.../node_modules/es6-promise/package.json | 81 +
.../node_modules/es6-promise/server/.jshintrc | 3 +
.../node_modules/es6-promise/server/index.js | 6 +
.../node_modules/es6-promise/testem.json | 11 +
.../node-firefox-find-simulators/package.json | 86 +
.../data/mac64/B2G.app/Contents/MacOS/b2g-bin | 1 +
.../b2g/B2G.app/Contents/MacOS/b2g-bin | 1 +
.../b2g/B2G.app/Contents/MacOS/b2g-bin | 1 +
.../b2g/B2G.app/Contents/MacOS/b2g-bin | 1 +
.../b2g/B2G.app/Contents/MacOS/b2g-bin | 1 +
.../b2g/B2G.app/Contents/MacOS/b2g-bin | 1 +
.../fxos_1_3_simulator/data/linux/b2g/b2g-bin | 1 +
.../fxos_1_3_simulator/data/linux64/b2g/b2g-bin | 1 +
.../fxos_2_0_simulator@mozilla.org/b2g/b2g-bin | 1 +
.../fxos_1_4_simulator@mozilla.org/b2g/b2g-bin | 1 +
.../fxos_2_1_simulator@mozilla.org/b2g/b2g-bin | 1 +
.../fxos_1_5_simulator@mozilla.org/b2g/b2g-bin | 1 +
.../fxos_2_2_simulator@mozilla.org/b2g/b2g-bin | 1 +
.../b2g/b2g-bin.exe | 1 +
.../b2g/b2g-bin.exe | 1 +
.../b2g/b2g-bin.exe | 1 +
.../b2g/b2g-bin.exe | 1 +
.../b2g/b2g-bin.exe | 1 +
.../b2g/b2g-bin.exe | 1 +
.../tests/unit/test.index.js | 71 +
.../tests/unit/test.platform.js | 54 +
.../node-firefox-forward-ports/.npmignore | 4 +
.../node-firefox-forward-ports/.travis.yml | 3 +
node_modules/node-firefox-forward-ports/LICENSE | 13 +
.../node-firefox-forward-ports/README.md | 144 +
.../node-firefox-forward-ports/gulpfile.js | 3 +
.../node-firefox-forward-ports/index.js | 115 +
.../node_modules/adbkit/LICENSE | 13 +
.../node_modules/adbkit/README.md | 1089 +++
.../node_modules/adbkit/index.js | 15 +
.../node_modules/adbkit/lib/adb.js | 27 +
.../node_modules/adbkit/lib/adb/auth.js | 81 +
.../node_modules/adbkit/lib/adb/client.js | 552 ++
.../node_modules/adbkit/lib/adb/command.js | 48 +
.../lib/adb/command/host-serial/forward.js | 48 +
.../adb/command/host-serial/getdevicepath.js | 41 +
.../lib/adb/command/host-serial/getserialno.js | 41 +
.../lib/adb/command/host-serial/getstate.js | 41 +
.../lib/adb/command/host-serial/listforwards.js | 59 +
.../adb/command/host-serial/waitfordevice.js | 48 +
.../lib/adb/command/host-transport/clear.js | 47 +
.../adb/command/host-transport/framebuffer.js | 117 +
.../adb/command/host-transport/getfeatures.js | 54 +
.../adb/command/host-transport/getpackages.js | 54 +
.../adb/command/host-transport/getproperties.js | 56 +
.../lib/adb/command/host-transport/install.js | 51 +
.../adb/command/host-transport/isinstalled.js | 50 +
.../lib/adb/command/host-transport/local.js | 39 +
.../lib/adb/command/host-transport/log.js | 39 +
.../lib/adb/command/host-transport/logcat.js | 49 +
.../lib/adb/command/host-transport/monkey.js | 45 +
.../lib/adb/command/host-transport/reboot.js | 39 +
.../lib/adb/command/host-transport/remount.js | 39 +
.../lib/adb/command/host-transport/screencap.js | 57 +
.../lib/adb/command/host-transport/shell.js | 42 +
.../adb/command/host-transport/startactivity.js | 187 +
.../adb/command/host-transport/startservice.js | 36 +
.../lib/adb/command/host-transport/sync.js | 41 +
.../lib/adb/command/host-transport/tcp.js | 39 +
.../lib/adb/command/host-transport/tcpip.js | 51 +
.../lib/adb/command/host-transport/trackjdwp.js | 123 +
.../lib/adb/command/host-transport/uninstall.js | 47 +
.../lib/adb/command/host-transport/usb.js | 51 +
.../command/host-transport/waitbootcomplete.js | 45 +
.../adbkit/lib/adb/command/host/connect.js | 49 +
.../adbkit/lib/adb/command/host/devices.js | 67 +
.../lib/adb/command/host/deviceswithpaths.js | 68 +
.../adbkit/lib/adb/command/host/disconnect.js | 49 +
.../adbkit/lib/adb/command/host/kill.js | 39 +
.../adbkit/lib/adb/command/host/trackdevices.js | 43 +
.../adbkit/lib/adb/command/host/transport.js | 39 +
.../adbkit/lib/adb/command/host/version.js | 45 +
.../node_modules/adbkit/lib/adb/connection.js | 108 +
.../adbkit/lib/adb/framebuffer/rgbtransform.js | 58 +
.../node_modules/adbkit/lib/adb/keycode.js | 228 +
.../adbkit/lib/adb/linetransform.js | 58 +
.../node_modules/adbkit/lib/adb/parser.js | 247 +
.../node_modules/adbkit/lib/adb/proc/stat.js | 140 +
.../node_modules/adbkit/lib/adb/protocol.js | 48 +
.../node_modules/adbkit/lib/adb/sync.js | 337 +
.../node_modules/adbkit/lib/adb/sync/entry.js | 26 +
.../adbkit/lib/adb/sync/pulltransfer.js | 34 +
.../adbkit/lib/adb/sync/pushtransfer.js | 43 +
.../node_modules/adbkit/lib/adb/sync/stats.js | 57 +
.../adbkit/lib/adb/tcpusb/rollingcounter.js | 24 +
.../adbkit/lib/adb/tcpusb/server.js | 72 +
.../adbkit/lib/adb/tcpusb/servicemap.js | 43 +
.../adbkit/lib/adb/tcpusb/socket.js | 391 +
.../node_modules/adbkit/lib/adb/tracker.js | 92 +
.../node_modules/adbkit/lib/adb/util.js | 16 +
.../node_modules/adbkit/lib/cli.js | 42 +
.../adbkit/node_modules/adbkit-logcat/LICENSE | 13 +
.../adbkit/node_modules/adbkit-logcat/README.md | 240 +
.../adbkit/node_modules/adbkit-logcat/index.js | 15 +
.../node_modules/adbkit-logcat/lib/logcat.js | 25 +
.../adbkit-logcat/lib/logcat/entry.js | 76 +
.../adbkit-logcat/lib/logcat/parser.js | 32 +
.../adbkit-logcat/lib/logcat/parser/binary.js | 78 +
.../adbkit-logcat/lib/logcat/priority.js | 89 +
.../adbkit-logcat/lib/logcat/reader.js | 137 +
.../adbkit-logcat/lib/logcat/transform.js | 51 +
.../node_modules/adbkit-logcat/package.json | 75 +
.../adbkit/node_modules/adbkit-monkey/LICENSE | 13 +
.../adbkit/node_modules/adbkit-monkey/README.md | 469 ++
.../adbkit/node_modules/adbkit-monkey/index.js | 15 +
.../node_modules/adbkit-monkey/lib/monkey.js | 29 +
.../adbkit-monkey/lib/monkey/api.js | 276 +
.../adbkit-monkey/lib/monkey/client.js | 98 +
.../adbkit-monkey/lib/monkey/command.js | 17 +
.../adbkit-monkey/lib/monkey/connection.js | 42 +
.../adbkit-monkey/lib/monkey/multi.js | 85 +
.../adbkit-monkey/lib/monkey/parser.js | 66 +
.../adbkit-monkey/lib/monkey/queue.js | 38 +
.../adbkit-monkey/lib/monkey/reply.js | 31 +
.../adbkit-monkey/node_modules/async/LICENSE | 19 +
.../adbkit-monkey/node_modules/async/README.md | 1425 ++++
.../node_modules/async/component.json | 11 +
.../node_modules/async/lib/async.js | 958 +++
.../node_modules/async/package.json | 45 +
.../node_modules/adbkit-monkey/package.json | 79 +
.../adbkit/node_modules/bluebird/.npmignore | 30 +
.../adbkit/node_modules/bluebird/API.md | 1741 +++++
.../node_modules/bluebird/CONTRIBUTING.md | 68 +
.../adbkit/node_modules/bluebird/Gruntfile.js | 725 ++
.../adbkit/node_modules/bluebird/LICENSE | 19 +
.../adbkit/node_modules/bluebird/README.md | 696 ++
.../bluebird/benchmark/package.json | 34 +
.../adbkit/node_modules/bluebird/bower.json | 35 +
.../adbkit/node_modules/bluebird/bundle.js | 0
.../adbkit/node_modules/bluebird/changelog.md | 1135 +++
.../adbkit/node_modules/bluebird/js/main/any.js | 54 +
.../node_modules/bluebird/js/main/assert.js | 83 +
.../node_modules/bluebird/js/main/async.js | 111 +
.../node_modules/bluebird/js/main/bluebird.js | 25 +
.../node_modules/bluebird/js/main/call_get.js | 55 +
.../node_modules/bluebird/js/main/cancel.js | 77 +
.../bluebird/js/main/captured_trace.js | 237 +
.../bluebird/js/main/catch_filter.js | 93 +
.../bluebird/js/main/direct_resolve.js | 83 +
.../node_modules/bluebird/js/main/errors.js | 114 +
.../bluebird/js/main/errors_api_rejection.js | 38 +
.../adbkit/node_modules/bluebird/js/main/es5.js | 89 +
.../node_modules/bluebird/js/main/filter.js | 53 +
.../node_modules/bluebird/js/main/finally.js | 132 +
.../node_modules/bluebird/js/main/generators.js | 56 +
.../node_modules/bluebird/js/main/global.js | 42 +
.../adbkit/node_modules/bluebird/js/main/map.js | 127 +
.../node_modules/bluebird/js/main/nodeify.js | 64 +
.../node_modules/bluebird/js/main/progress.js | 113 +
.../node_modules/bluebird/js/main/promise.js | 1167 +++
.../bluebird/js/main/promise_array.js | 233 +
.../bluebird/js/main/promise_inspection.js | 66 +
.../bluebird/js/main/promise_resolver.js | 152 +
.../bluebird/js/main/promise_spawn.js | 131 +
.../node_modules/bluebird/js/main/promisify.js | 278 +
.../js/main/properties_promise_array.js | 77 +
.../node_modules/bluebird/js/main/props.js | 65 +
.../node_modules/bluebird/js/main/queue.js | 135 +
.../node_modules/bluebird/js/main/race.js | 85 +
.../node_modules/bluebird/js/main/reduce.js | 173 +
.../node_modules/bluebird/js/main/schedule.js | 121 +
.../node_modules/bluebird/js/main/settle.js | 49 +
.../bluebird/js/main/settled_promise_array.js | 60 +
.../node_modules/bluebird/js/main/some.js | 57 +
.../bluebird/js/main/some_promise_array.js | 131 +
.../bluebird/js/main/synchronous_inspection.js | 30 +
.../node_modules/bluebird/js/main/thenables.js | 138 +
.../node_modules/bluebird/js/main/timers.js | 114 +
.../node_modules/bluebird/js/main/util.js | 193 +
.../node_modules/bluebird/js/zalgo/any.js | 54 +
.../node_modules/bluebird/js/zalgo/assert.js | 83 +
.../node_modules/bluebird/js/zalgo/async.js | 111 +
.../node_modules/bluebird/js/zalgo/bluebird.js | 25 +
.../node_modules/bluebird/js/zalgo/call_get.js | 55 +
.../node_modules/bluebird/js/zalgo/cancel.js | 77 +
.../bluebird/js/zalgo/captured_trace.js | 237 +
.../bluebird/js/zalgo/catch_filter.js | 93 +
.../bluebird/js/zalgo/direct_resolve.js | 83 +
.../node_modules/bluebird/js/zalgo/errors.js | 114 +
.../bluebird/js/zalgo/errors_api_rejection.js | 38 +
.../node_modules/bluebird/js/zalgo/es5.js | 89 +
.../node_modules/bluebird/js/zalgo/filter.js | 53 +
.../node_modules/bluebird/js/zalgo/finally.js | 132 +
.../bluebird/js/zalgo/generators.js | 56 +
.../node_modules/bluebird/js/zalgo/global.js | 42 +
.../node_modules/bluebird/js/zalgo/map.js | 127 +
.../node_modules/bluebird/js/zalgo/nodeify.js | 64 +
.../node_modules/bluebird/js/zalgo/progress.js | 111 +
.../node_modules/bluebird/js/zalgo/promise.js | 1167 +++
.../bluebird/js/zalgo/promise_array.js | 233 +
.../bluebird/js/zalgo/promise_inspection.js | 66 +
.../bluebird/js/zalgo/promise_resolver.js | 152 +
.../bluebird/js/zalgo/promise_spawn.js | 131 +
.../node_modules/bluebird/js/zalgo/promisify.js | 278 +
.../js/zalgo/properties_promise_array.js | 77 +
.../node_modules/bluebird/js/zalgo/props.js | 65 +
.../node_modules/bluebird/js/zalgo/queue.js | 135 +
.../node_modules/bluebird/js/zalgo/race.js | 85 +
.../node_modules/bluebird/js/zalgo/reduce.js | 173 +
.../node_modules/bluebird/js/zalgo/schedule.js | 121 +
.../node_modules/bluebird/js/zalgo/settle.js | 49 +
.../bluebird/js/zalgo/settled_promise_array.js | 60 +
.../node_modules/bluebird/js/zalgo/some.js | 57 +
.../bluebird/js/zalgo/some_promise_array.js | 131 +
.../bluebird/js/zalgo/synchronous_inspection.js | 30 +
.../node_modules/bluebird/js/zalgo/thenables.js | 138 +
.../node_modules/bluebird/js/zalgo/timers.js | 114 +
.../node_modules/bluebird/js/zalgo/util.js | 193 +
.../adbkit/node_modules/bluebird/package.json | 85 +
.../adbkit/node_modules/bluebird/zalgo.js | 1 +
.../adbkit/node_modules/commander/History.md | 239 +
.../adbkit/node_modules/commander/LICENSE | 22 +
.../adbkit/node_modules/commander/Readme.md | 311 +
.../adbkit/node_modules/commander/index.js | 1051 +++
.../node_modules/graceful-readlink/.npmignore | 3 +
.../node_modules/graceful-readlink/.travis.yml | 5 +
.../node_modules/graceful-readlink/LICENSE | 22 +
.../node_modules/graceful-readlink/README.md | 17 +
.../node_modules/graceful-readlink/index.js | 12 +
.../node_modules/graceful-readlink/package.json | 48 +
.../adbkit/node_modules/commander/package.json | 74 +
.../adbkit/node_modules/debug/Readme.md | 115 +
.../adbkit/node_modules/debug/debug.js | 137 +
.../adbkit/node_modules/debug/index.js | 5 +
.../adbkit/node_modules/debug/lib/debug.js | 147 +
.../adbkit/node_modules/debug/package.json | 65 +
.../adbkit/node_modules/node-forge/.jscsrc | 64 +
.../node_modules/node-forge/.jshintignore | 6 +
.../adbkit/node_modules/node-forge/.jshintrc | 3 +
.../adbkit/node_modules/node-forge/.npmignore | 22 +
.../adbkit/node_modules/node-forge/.travis.yml | 10 +
.../adbkit/node_modules/node-forge/HACKING.md | 37 +
.../adbkit/node_modules/node-forge/LICENSE | 331 +
.../adbkit/node_modules/node-forge/Makefile.in | 110 +
.../adbkit/node_modules/node-forge/README.md | 1782 +++++
.../adbkit/node_modules/node-forge/bower.json | 15 +
.../node_modules/node-forge/build-flash.xml | 7 +
.../adbkit/node_modules/node-forge/build-setup | 46 +
.../adbkit/node_modules/node-forge/end.frag | 4 +
.../node-forge/flash/PooledSocket.as | 18 +
.../node-forge/flash/SocketEvent.as | 36 +
.../node_modules/node-forge/flash/SocketPool.as | 754 ++
.../adbkit/node_modules/node-forge/js/aes.js | 1146 +++
.../node-forge/js/aesCipherSuites.js | 312 +
.../adbkit/node_modules/node-forge/js/asn1.js | 1114 +++
.../adbkit/node_modules/node-forge/js/cipher.js | 286 +
.../node_modules/node-forge/js/cipherModes.js | 817 ++
.../adbkit/node_modules/node-forge/js/debug.js | 134 +
.../adbkit/node_modules/node-forge/js/des.js | 552 ++
.../adbkit/node_modules/node-forge/js/forge.js | 92 +
.../adbkit/node_modules/node-forge/js/form.js | 157 +
.../adbkit/node_modules/node-forge/js/hmac.js | 200 +
.../adbkit/node_modules/node-forge/js/http.js | 1369 ++++
.../adbkit/node_modules/node-forge/js/jsbn.js | 1321 ++++
.../adbkit/node_modules/node-forge/js/kem.js | 221 +
.../adbkit/node_modules/node-forge/js/log.js | 372 +
.../adbkit/node_modules/node-forge/js/md.js | 75 +
.../adbkit/node_modules/node-forge/js/md5.js | 322 +
.../adbkit/node_modules/node-forge/js/mgf.js | 67 +
.../adbkit/node_modules/node-forge/js/mgf1.js | 112 +
.../adbkit/node_modules/node-forge/js/oids.js | 269 +
.../adbkit/node_modules/node-forge/js/pbe.js | 975 +++
.../adbkit/node_modules/node-forge/js/pbkdf2.js | 214 +
.../adbkit/node_modules/node-forge/js/pem.js | 285 +
.../adbkit/node_modules/node-forge/js/pkcs1.js | 329 +
.../adbkit/node_modules/node-forge/js/pkcs12.js | 1121 +++
.../adbkit/node_modules/node-forge/js/pkcs7.js | 842 ++
.../node_modules/node-forge/js/pkcs7asn1.js | 399 +
.../adbkit/node_modules/node-forge/js/pki.js | 161 +
.../adbkit/node_modules/node-forge/js/prime.js | 337 +
.../node_modules/node-forge/js/prime.worker.js | 165 +
.../adbkit/node_modules/node-forge/js/prng.js | 458 ++
.../adbkit/node_modules/node-forge/js/pss.js | 295 +
.../adbkit/node_modules/node-forge/js/random.js | 237 +
.../adbkit/node_modules/node-forge/js/rc2.js | 470 ++
.../adbkit/node_modules/node-forge/js/rsa.js | 1712 +++++
.../adbkit/node_modules/node-forge/js/sha1.js | 342 +
.../adbkit/node_modules/node-forge/js/sha256.js | 352 +
.../adbkit/node_modules/node-forge/js/sha512.js | 590 ++
.../adbkit/node_modules/node-forge/js/socket.js | 342 +
.../adbkit/node_modules/node-forge/js/ssh.js | 295 +
.../adbkit/node_modules/node-forge/js/task.js | 778 ++
.../adbkit/node_modules/node-forge/js/tls.js | 4316 +++++++++++
.../node_modules/node-forge/js/tlssocket.js | 304 +
.../adbkit/node_modules/node-forge/js/util.js | 2953 +++++++
.../adbkit/node_modules/node-forge/js/x509.js | 3178 ++++++++
.../adbkit/node_modules/node-forge/js/xhr.js | 739 ++
.../adbkit/node_modules/node-forge/minify.js | 10 +
.../node_modules/node-forge/mod_fsp/README | 135 +
.../node_modules/node-forge/mod_fsp/mod_fsp.c | 415 +
.../node_modules/node-forge/nodejs/README.md | 34 +
.../node_modules/node-forge/nodejs/build.js | 8 +
.../node_modules/node-forge/nodejs/minify.js | 8 +
.../node_modules/node-forge/nodejs/package.json | 17 +
.../node_modules/node-forge/nodejs/server.js | 46 +
.../node_modules/node-forge/nodejs/test/aes.js | 1213 +++
.../node_modules/node-forge/nodejs/test/asn1.js | 262 +
.../node-forge/nodejs/test/browser.js | 41 +
.../node_modules/node-forge/nodejs/test/csr.js | 148 +
.../node_modules/node-forge/nodejs/test/des.js | 155 +
.../node_modules/node-forge/nodejs/test/hmac.js | 85 +
.../node_modules/node-forge/nodejs/test/kem.js | 198 +
.../node_modules/node-forge/nodejs/test/md5.js | 117 +
.../node_modules/node-forge/nodejs/test/mgf1.js | 39 +
.../node-forge/nodejs/test/pbkdf2.js | 123 +
.../node_modules/node-forge/nodejs/test/pem.js | 104 +
.../node-forge/nodejs/test/pkcs1.js | 1105 +++
.../node-forge/nodejs/test/pkcs12.js | 650 ++
.../node-forge/nodejs/test/pkcs7.js | 350 +
.../node-forge/nodejs/test/random.js | 70 +
.../node_modules/node-forge/nodejs/test/rc2.js | 109 +
.../node_modules/node-forge/nodejs/test/rsa.js | 602 ++
.../node_modules/node-forge/nodejs/test/sha1.js | 75 +
.../node-forge/nodejs/test/sha256.js | 81 +
.../node-forge/nodejs/test/sha512.js | 174 +
.../node_modules/node-forge/nodejs/test/ssh.js | 193 +
.../node_modules/node-forge/nodejs/test/tls.js | 191 +
.../node_modules/node-forge/nodejs/test/util.js | 406 +
.../node_modules/node-forge/nodejs/test/x509.js | 734 ++
.../node-forge/nodejs/ui/index.html | 12 +
.../node-forge/nodejs/ui/require.js | 35 +
.../node_modules/node-forge/nodejs/ui/test.js | 36 +
.../node-forge/nodejs/ui/test.min.js | 1 +
.../adbkit/node_modules/node-forge/package.json | 113 +
.../node_modules/node-forge/setup/configure.ac | 202 +
.../node_modules/node-forge/setup/install-sh | 269 +
.../node-forge/setup/m4/as-python.m4 | 156 +
.../adbkit/node_modules/node-forge/start.frag | 7 +
.../node_modules/node-forge/tests/aes-speed.js | 54 +
.../node_modules/node-forge/tests/common.html | 84 +
.../node_modules/node-forge/tests/common.js | 2199 ++++++
.../node_modules/node-forge/tests/favicon.ico | 0
.../node_modules/node-forge/tests/flash/Test.as | 96 +
.../node-forge/tests/flash/build-flash.xml | 7 +
.../node-forge/tests/flash/index.html | 27 +
.../tests/forge_ssl/forge/__init__.py | 0
.../node-forge/tests/forge_ssl/forge/_ssl.c | 1770 +++++
.../tests/forge_ssl/forge/socketmodule.h | 268 +
.../node-forge/tests/forge_ssl/forge/ssl.py | 486 ++
.../node-forge/tests/forge_ssl/setup.py | 12 +
.../node_modules/node-forge/tests/form.html | 150 +
.../node_modules/node-forge/tests/form.js | 40 +
.../node_modules/node-forge/tests/heartbleed.js | 55 +
.../node_modules/node-forge/tests/http.html | 229 +
.../node_modules/node-forge/tests/index.html | 64 +
.../node_modules/node-forge/tests/keygen.html | 56 +
.../node_modules/node-forge/tests/login.css | 26 +
.../node-forge/tests/loginDemo.html | 56 +
.../node_modules/node-forge/tests/loginDemo.js | 149 +
.../node-forge/tests/nodejs-create-cert.js | 110 +
.../node-forge/tests/nodejs-create-csr.js | 66 +
.../node-forge/tests/nodejs-create-pkcs12.js | 160 +
.../node-forge/tests/nodejs-imap.js | 46 +
.../node_modules/node-forge/tests/nodejs-tls.js | 189 +
.../node-forge/tests/nodejs-ws-webid.js | 491 ++
.../node_modules/node-forge/tests/nodejs-ws.js | 166 +
.../node-forge/tests/performance.html | 550 ++
.../node-forge/tests/policyserver.py | 112 +
.../node_modules/node-forge/tests/result.txt | 1 +
.../node_modules/node-forge/tests/screen.css | 61 +
.../node_modules/node-forge/tests/server.crt | 26 +
.../node_modules/node-forge/tests/server.key | 27 +
.../node_modules/node-forge/tests/server.py | 184 +
.../node-forge/tests/socketPool.html | 299 +
.../node_modules/node-forge/tests/tasks.html | 53 +
.../node_modules/node-forge/tests/tasks.js | 378 +
.../node_modules/node-forge/tests/tls.html | 426 ++
.../node_modules/node-forge/tests/webid.html | 110 +
.../node_modules/node-forge/tests/webid.js | 313 +
.../node_modules/node-forge/tests/ws-webid.js | 132 +
.../adbkit/node_modules/node-forge/tests/ws.js | 237 +
.../node_modules/node-forge/tests/xhr.html | 87 +
.../adbkit/node_modules/node-forge/tests/xhr.js | 590 ++
.../adbkit/node_modules/split/.npmignore | 3 +
.../adbkit/node_modules/split/.travis.yml | 4 +
.../adbkit/node_modules/split/LICENCE | 22 +
.../node_modules/split/examples/pretty.js | 26 +
.../adbkit/node_modules/split/index.js | 59 +
.../split/node_modules/through/.travis.yml | 5 +
.../split/node_modules/through/LICENSE.APACHE2 | 15 +
.../split/node_modules/through/LICENSE.MIT | 24 +
.../split/node_modules/through/index.js | 108 +
.../split/node_modules/through/package.json | 65 +
.../split/node_modules/through/readme.markdown | 64 +
.../split/node_modules/through/test/async.js | 28 +
.../node_modules/through/test/auto-destroy.js | 30 +
.../node_modules/through/test/buffering.js | 71 +
.../split/node_modules/through/test/end.js | 45 +
.../split/node_modules/through/test/index.js | 117 +
.../adbkit/node_modules/split/package.json | 39 +
.../adbkit/node_modules/split/readme.markdown | 39 +
.../split/test/partitioned_unicode.js | 34 +
.../node_modules/split/test/split.asynct.js | 85 +
.../node_modules/split/test/try_catch.asynct.js | 51 +
.../node_modules/adbkit/package.json | 88 +
.../node_modules/portfinder/.npmignore | 2 +
.../node_modules/portfinder/.travis.yml | 21 +
.../node_modules/portfinder/LICENSE | 22 +
.../node_modules/portfinder/README.md | 38 +
.../node_modules/portfinder/lib/portfinder.js | 218 +
.../portfinder/node_modules/.bin/mkdirp | 1 +
.../portfinder/node_modules/async/.travis.yml | 3 +
.../portfinder/node_modules/async/LICENSE | 19 +
.../portfinder/node_modules/async/README.md | 1646 ++++
.../node_modules/async/component.json | 11 +
.../portfinder/node_modules/async/lib/async.js | 1123 +++
.../portfinder/node_modules/async/package.json | 59 +
.../portfinder/node_modules/mkdirp/.npmignore | 2 +
.../portfinder/node_modules/mkdirp/.travis.yml | 5 +
.../portfinder/node_modules/mkdirp/LICENSE | 21 +
.../portfinder/node_modules/mkdirp/bin/cmd.js | 33 +
.../node_modules/mkdirp/bin/usage.txt | 12 +
.../node_modules/mkdirp/examples/pow.js | 6 +
.../portfinder/node_modules/mkdirp/index.js | 97 +
.../mkdirp/node_modules/minimist/.travis.yml | 4 +
.../mkdirp/node_modules/minimist/LICENSE | 18 +
.../node_modules/minimist/example/parse.js | 2 +
.../mkdirp/node_modules/minimist/index.js | 187 +
.../mkdirp/node_modules/minimist/package.json | 66 +
.../node_modules/minimist/readme.markdown | 73 +
.../mkdirp/node_modules/minimist/test/dash.js | 24 +
.../node_modules/minimist/test/default_bool.js | 20 +
.../mkdirp/node_modules/minimist/test/dotted.js | 16 +
.../mkdirp/node_modules/minimist/test/long.js | 31 +
.../mkdirp/node_modules/minimist/test/parse.js | 318 +
.../minimist/test/parse_modified.js | 9 +
.../mkdirp/node_modules/minimist/test/short.js | 67 +
.../node_modules/minimist/test/whitespace.js | 8 +
.../portfinder/node_modules/mkdirp/package.json | 59 +
.../node_modules/mkdirp/readme.markdown | 100 +
.../node_modules/mkdirp/test/chmod.js | 38 +
.../node_modules/mkdirp/test/clobber.js | 37 +
.../node_modules/mkdirp/test/mkdirp.js | 26 +
.../node_modules/mkdirp/test/opts_fs.js | 27 +
.../node_modules/mkdirp/test/opts_fs_sync.js | 25 +
.../portfinder/node_modules/mkdirp/test/perm.js | 30 +
.../node_modules/mkdirp/test/perm_sync.js | 34 +
.../portfinder/node_modules/mkdirp/test/race.js | 40 +
.../portfinder/node_modules/mkdirp/test/rel.js | 30 +
.../node_modules/mkdirp/test/return.js | 25 +
.../node_modules/mkdirp/test/return_sync.js | 24 +
.../portfinder/node_modules/mkdirp/test/root.js | 18 +
.../portfinder/node_modules/mkdirp/test/sync.js | 30 +
.../node_modules/mkdirp/test/umask.js | 26 +
.../node_modules/mkdirp/test/umask_sync.js | 30 +
.../node_modules/portfinder/package.json | 60 +
.../portfinder/test/fixtures/.gitkeep | 0
.../test/port-finder-multiple-test.js | 67 +
.../portfinder/test/port-finder-socket-test.js | 92 +
.../portfinder/test/port-finder-test.js | 67 +
.../node-firefox-forward-ports/package.json | 72 +
.../tests/unit/test.index.js | 179 +
.../node-firefox-install-app/.npmignore | 2 +
node_modules/node-firefox-install-app/LICENSE | 13 +
node_modules/node-firefox-install-app/README.md | 112 +
.../examples/sampleApp/app.js | 3 +
.../examples/sampleApp/icons/icon128x128.png | Bin 0 -> 4990 bytes
.../examples/sampleApp/icons/icon16x16.png | Bin 0 -> 1111 bytes
.../examples/sampleApp/icons/icon48x48.png | Bin 0 -> 2928 bytes
.../examples/sampleApp/icons/icon60x60.png | Bin 0 -> 3654 bytes
.../examples/sampleApp/index.html | 27 +
.../examples/sampleApp/manifest.webapp | 11 +
.../node-firefox-install-app/examples/usage.js | 25 +
.../node-firefox-install-app/gulpfile.js | 4 +
node_modules/node-firefox-install-app/index.js | 95 +
.../node_modules/.bin/uuid | 1 +
.../node_modules/es6-promise/.release.json | 17 +
.../node_modules/es6-promise/Brocfile.js | 75 +
.../node_modules/es6-promise/CHANGELOG.md | 9 +
.../node_modules/es6-promise/LICENSE | 19 +
.../node_modules/es6-promise/README.md | 58 +
.../es6-promise/bin/publish_to_s3.js | 28 +
.../node_modules/es6-promise/bower.json | 29 +
.../es6-promise/config/s3ProjectConfig.js | 26 +
.../es6-promise/config/versionTemplate.txt | 7 +
.../es6-promise/dist/es6-promise.js | 960 +++
.../es6-promise/dist/es6-promise.min.js | 18 +
.../es6-promise/lib/calculateVersion.js | 36 +
.../es6-promise/lib/es6-promise.umd.js | 16 +
.../es6-promise/lib/es6-promise/-internal.js | 251 +
.../es6-promise/lib/es6-promise/asap.js | 82 +
.../es6-promise/lib/es6-promise/enumerator.js | 125 +
.../es6-promise/lib/es6-promise/polyfill.js | 35 +
.../es6-promise/lib/es6-promise/promise.js | 409 +
.../es6-promise/lib/es6-promise/promise/all.js | 52 +
.../es6-promise/lib/es6-promise/promise/race.js | 105 +
.../lib/es6-promise/promise/reject.js | 47 +
.../lib/es6-promise/promise/resolve.js | 49 +
.../es6-promise/lib/es6-promise/utils.js | 39 +
.../node_modules/es6-promise/package.json | 81 +
.../node_modules/es6-promise/server/.jshintrc | 3 +
.../node_modules/es6-promise/server/index.js | 6 +
.../node_modules/es6-promise/testem.json | 11 +
.../node_modules/node-uuid/.npmignore | 2 +
.../node_modules/node-uuid/LICENSE.md | 21 +
.../node_modules/node-uuid/README.md | 243 +
.../node_modules/node-uuid/benchmark/README.md | 53 +
.../node_modules/node-uuid/benchmark/bench.gnu | 174 +
.../node_modules/node-uuid/benchmark/bench.sh | 34 +
.../node-uuid/benchmark/benchmark-native.c | 34 +
.../node-uuid/benchmark/benchmark.js | 84 +
.../node_modules/node-uuid/bin/uuid | 26 +
.../node_modules/node-uuid/bower.json | 23 +
.../node_modules/node-uuid/component.json | 18 +
.../node_modules/node-uuid/package.json | 65 +
.../node_modules/node-uuid/test/compare_v1.js | 63 +
.../node_modules/node-uuid/test/test.html | 17 +
.../node_modules/node-uuid/test/test.js | 228 +
.../node_modules/node-uuid/uuid.js | 247 +
.../node_modules/temporary/.npmignore | 22 +
.../node_modules/temporary/.travis.yml | 6 +
.../node_modules/temporary/History.md | 24 +
.../node_modules/temporary/Makefile | 11 +
.../node_modules/temporary/Readme.md | 81 +
.../node_modules/temporary/examples/dir.js | 18 +
.../node_modules/temporary/examples/file.js | 26 +
.../node_modules/temporary/index.js | 26 +
.../node_modules/temporary/lib/base.js | 80 +
.../node_modules/temporary/lib/detector.js | 66 +
.../node_modules/temporary/lib/dir.js | 57 +
.../node_modules/temporary/lib/file.js | 113 +
.../node_modules/temporary/lib/generator.js | 48 +
.../temporary/node_modules/package/.npmignore | 22 +
.../temporary/node_modules/package/.travis.yml | 3 +
.../temporary/node_modules/package/History.md | 0
.../temporary/node_modules/package/Makefile | 12 +
.../temporary/node_modules/package/Readme.md | 54 +
.../package/examples/custom_path.js | 14 +
.../node_modules/package/examples/module.js | 14 +
.../node_modules/package/lib/package.js | 64 +
.../temporary/node_modules/package/package.json | 35 +
.../node_modules/package/test/index.test.js | 42 +
.../package/test/nested/two/nested.test.js | 22 +
.../node_modules/package/test/package.json | 5 +
.../package/test/support/package.json | 5 +
.../node_modules/temporary/package.json | 60 +
.../node_modules/temporary/test/base.test.js | 57 +
.../temporary/test/detector.test.js | 42 +
.../node_modules/temporary/test/dir.test.js | 44 +
.../node_modules/temporary/test/file.test.js | 126 +
.../temporary/test/generator.test.js | 29 +
.../node_modules/zip-folder/.npmignore | 2 +
.../node_modules/zip-folder/README.md | 22 +
.../node_modules/zip-folder/index.js | 25 +
.../node_modules/archiver/LICENSE-MIT | 22 +
.../zip-folder/node_modules/archiver/README.md | 166 +
.../node_modules/archiver/lib/archiver.js | 42 +
.../archiver/lib/modules/core/index.js | 319 +
.../archiver/lib/modules/json/index.js | 71 +
.../archiver/lib/modules/tar/index.js | 84 +
.../archiver/lib/modules/zip/index.js | 39 +
.../node_modules/archiver/lib/util/file.js | 206 +
.../node_modules/archiver/lib/util/index.js | 103 +
.../archiver/node_modules/async/.travis.yml | 3 +
.../archiver/node_modules/async/LICENSE | 19 +
.../archiver/node_modules/async/README.md | 1646 ++++
.../archiver/node_modules/async/component.json | 11 +
.../archiver/node_modules/async/lib/async.js | 1123 +++
.../archiver/node_modules/async/package.json | 43 +
.../node_modules/buffer-crc32/.npmignore | 1 +
.../node_modules/buffer-crc32/.travis.yml | 8 +
.../archiver/node_modules/buffer-crc32/LICENSE | 19 +
.../node_modules/buffer-crc32/README.md | 47 +
.../archiver/node_modules/buffer-crc32/index.js | 91 +
.../node_modules/buffer-crc32/package.json | 65 +
.../node_modules/buffer-crc32/tests/crc.test.js | 89 +
.../archiver/node_modules/glob/.npmignore | 2 +
.../archiver/node_modules/glob/.travis.yml | 3 +
.../archiver/node_modules/glob/LICENSE | 27 +
.../archiver/node_modules/glob/README.md | 250 +
.../archiver/node_modules/glob/examples/g.js | 9 +
.../node_modules/glob/examples/usr-local.js | 9 +
.../archiver/node_modules/glob/glob.js | 728 ++
.../glob/node_modules/inherits/LICENSE | 16 +
.../glob/node_modules/inherits/README.md | 42 +
.../glob/node_modules/inherits/inherits.js | 1 +
.../node_modules/inherits/inherits_browser.js | 23 +
.../glob/node_modules/inherits/package.json | 33 +
.../glob/node_modules/inherits/test.js | 25 +
.../glob/node_modules/minimatch/.npmignore | 1 +
.../glob/node_modules/minimatch/LICENSE | 23 +
.../glob/node_modules/minimatch/README.md | 218 +
.../glob/node_modules/minimatch/minimatch.js | 1061 +++
.../minimatch/node_modules/lru-cache/.npmignore | 1 +
.../node_modules/lru-cache/CONTRIBUTORS | 14 +
.../minimatch/node_modules/lru-cache/LICENSE | 23 +
.../minimatch/node_modules/lru-cache/README.md | 97 +
.../node_modules/lru-cache/lib/lru-cache.js | 252 +
.../node_modules/lru-cache/package.json | 33 +
.../node_modules/lru-cache/test/basic.js | 369 +
.../node_modules/lru-cache/test/foreach.js | 52 +
.../node_modules/lru-cache/test/memory-leak.js | 50 +
.../minimatch/node_modules/sigmund/LICENSE | 27 +
.../minimatch/node_modules/sigmund/README.md | 53 +
.../minimatch/node_modules/sigmund/bench.js | 283 +
.../minimatch/node_modules/sigmund/package.json | 42 +
.../minimatch/node_modules/sigmund/sigmund.js | 39 +
.../node_modules/sigmund/test/basic.js | 24 +
.../glob/node_modules/minimatch/package.json | 58 +
.../glob/node_modules/minimatch/test/basic.js | 399 +
.../node_modules/minimatch/test/brace-expand.js | 33 +
.../glob/node_modules/minimatch/test/caching.js | 14 +
.../node_modules/minimatch/test/defaults.js | 274 +
.../test/extglob-ending-with-state-char.js | 8 +
.../archiver/node_modules/glob/package.json | 40 +
.../archiver/node_modules/glob/test/00-setup.js | 176 +
.../node_modules/glob/test/bash-comparison.js | 63 +
.../node_modules/glob/test/bash-results.json | 351 +
.../archiver/node_modules/glob/test/cwd-test.js | 55 +
.../node_modules/glob/test/globstar-match.js | 19 +
.../archiver/node_modules/glob/test/mark.js | 118 +
.../glob/test/new-glob-optional-options.js | 10 +
.../node_modules/glob/test/nocase-nomagic.js | 113 +
.../node_modules/glob/test/pause-resume.js | 73 +
.../node_modules/glob/test/readme-issue.js | 36 +
.../node_modules/glob/test/root-nomount.js | 39 +
.../archiver/node_modules/glob/test/root.js | 46 +
.../archiver/node_modules/glob/test/stat.js | 32 +
.../node_modules/glob/test/zz-cleanup.js | 11 +
.../archiver/node_modules/lazystream/.npmignore | 3 +
.../node_modules/lazystream/.travis.yml | 5 +
.../node_modules/lazystream/LICENSE-MIT | 23 +
.../archiver/node_modules/lazystream/README.md | 100 +
.../node_modules/lazystream/lib/lazystream.js | 52 +
.../node_modules/lazystream/package.json | 43 +
.../node_modules/lazystream/test/data.md | 13 +
.../node_modules/lazystream/test/fs_test.js | 69 +
.../node_modules/lazystream/test/helper.js | 39 +
.../node_modules/lazystream/test/pipe_test.js | 36 +
.../lazystream/test/readable_test.js | 88 +
.../lazystream/test/writable_test.js | 59 +
.../archiver/node_modules/lodash/LICENSE.txt | 22 +
.../archiver/node_modules/lodash/README.md | 163 +
.../node_modules/lodash/dist/lodash.compat.js | 7157 +++++++++++++++++
.../lodash/dist/lodash.compat.min.js | 61 +
.../archiver/node_modules/lodash/dist/lodash.js | 6785 +++++++++++++++++
.../node_modules/lodash/dist/lodash.min.js | 56 +
.../lodash/dist/lodash.underscore.js | 4979 ++++++++++++
.../lodash/dist/lodash.underscore.min.js | 39 +
.../archiver/node_modules/lodash/lodash.js | 7179 ++++++++++++++++++
.../archiver/node_modules/lodash/package.json | 103 +
.../node_modules/readable-stream/.npmignore | 5 +
.../node_modules/readable-stream/LICENSE | 18 +
.../node_modules/readable-stream/README.md | 15 +
.../node_modules/readable-stream/duplex.js | 1 +
.../readable-stream/lib/_stream_duplex.js | 89 +
.../readable-stream/lib/_stream_passthrough.js | 46 +
.../readable-stream/lib/_stream_readable.js | 982 +++
.../readable-stream/lib/_stream_transform.js | 210 +
.../readable-stream/lib/_stream_writable.js | 386 +
.../node_modules/core-util-is/README.md | 3 +
.../node_modules/core-util-is/float.patch | 604 ++
.../node_modules/core-util-is/lib/util.js | 107 +
.../node_modules/core-util-is/package.json | 36 +
.../node_modules/core-util-is/util.js | 106 +
.../node_modules/inherits/LICENSE | 16 +
.../node_modules/inherits/README.md | 42 +
.../node_modules/inherits/inherits.js | 1 +
.../node_modules/inherits/inherits_browser.js | 23 +
.../node_modules/inherits/package.json | 33 +
.../node_modules/inherits/test.js | 25 +
.../node_modules/isarray/README.md | 54 +
.../node_modules/isarray/build/build.js | 209 +
.../node_modules/isarray/component.json | 19 +
.../node_modules/isarray/index.js | 3 +
.../node_modules/isarray/package.json | 54 +
.../node_modules/string_decoder/.npmignore | 2 +
.../node_modules/string_decoder/LICENSE | 20 +
.../node_modules/string_decoder/README.md | 7 +
.../node_modules/string_decoder/index.js | 221 +
.../node_modules/string_decoder/package.json | 54 +
.../node_modules/readable-stream/package.json | 70 +
.../node_modules/readable-stream/passthrough.js | 1 +
.../node_modules/readable-stream/readable.js | 8 +
.../node_modules/readable-stream/transform.js | 1 +
.../node_modules/readable-stream/writable.js | 1 +
.../archiver/node_modules/tar-stream/.npmignore | 2 +
.../node_modules/tar-stream/.travis.yml | 6 +
.../archiver/node_modules/tar-stream/LICENSE | 21 +
.../archiver/node_modules/tar-stream/README.md | 128 +
.../archiver/node_modules/tar-stream/extract.js | 194 +
.../archiver/node_modules/tar-stream/headers.js | 221 +
.../archiver/node_modules/tar-stream/index.js | 2 +
.../tar-stream/node_modules/bl/.jshintrc | 59 +
.../tar-stream/node_modules/bl/.npmignore | 1 +
.../tar-stream/node_modules/bl/.travis.yml | 11 +
.../tar-stream/node_modules/bl/LICENSE.md | 13 +
.../tar-stream/node_modules/bl/README.md | 198 +
.../tar-stream/node_modules/bl/bl.js | 216 +
.../tar-stream/node_modules/bl/package.json | 62 +
.../node_modules/bl/test/basic-test.js | 541 ++
.../tar-stream/node_modules/bl/test/sauce.js | 38 +
.../tar-stream/node_modules/bl/test/test.js | 9 +
.../node_modules/end-of-stream/.npmignore | 1 +
.../node_modules/end-of-stream/LICENSE | 21 +
.../node_modules/end-of-stream/README.md | 47 +
.../node_modules/end-of-stream/index.js | 83 +
.../end-of-stream/node_modules/once/LICENSE | 27 +
.../end-of-stream/node_modules/once/README.md | 51 +
.../once/node_modules/wrappy/LICENSE | 15 +
.../once/node_modules/wrappy/README.md | 36 +
.../once/node_modules/wrappy/package.json | 52 +
.../once/node_modules/wrappy/test/basic.js | 51 +
.../once/node_modules/wrappy/wrappy.js | 33 +
.../end-of-stream/node_modules/once/once.js | 21 +
.../node_modules/once/package.json | 60 +
.../node_modules/once/test/once.js | 23 +
.../node_modules/end-of-stream/package.json | 56 +
.../node_modules/end-of-stream/test.js | 77 +
.../tar-stream/node_modules/xtend/.jshintrc | 30 +
.../tar-stream/node_modules/xtend/.npmignore | 1 +
.../tar-stream/node_modules/xtend/LICENCE | 19 +
.../tar-stream/node_modules/xtend/Makefile | 4 +
.../tar-stream/node_modules/xtend/README.md | 32 +
.../tar-stream/node_modules/xtend/immutable.js | 17 +
.../tar-stream/node_modules/xtend/mutable.js | 15 +
.../tar-stream/node_modules/xtend/package.json | 88 +
.../tar-stream/node_modules/xtend/test.js | 63 +
.../archiver/node_modules/tar-stream/pack.js | 194 +
.../node_modules/tar-stream/package.json | 75 +
.../node_modules/tar-stream/test/extract.js | 437 ++
.../tar-stream/test/fixtures/index.js | 11 +
.../tar-stream/test/fixtures/invalid.tgz | Bin 0 -> 59510 bytes
.../tar-stream/test/fixtures/long-name.tar | Bin 0 -> 2048 bytes
.../tar-stream/test/fixtures/multi-file.tar | Bin 0 -> 3072 bytes
.../tar-stream/test/fixtures/name-is-100.tar | Bin 0 -> 10240 bytes
.../tar-stream/test/fixtures/one-file.tar | Bin 0 -> 2048 bytes
.../tar-stream/test/fixtures/space.tar | Bin 0 -> 10240 bytes
.../tar-stream/test/fixtures/types.tar | Bin 0 -> 2048 bytes
.../tar-stream/test/fixtures/unicode-bsd.tar | Bin 0 -> 10240 bytes
.../tar-stream/test/fixtures/unicode.tar | Bin 0 -> 3072 bytes
.../node_modules/tar-stream/test/pack.js | 144 +
.../node_modules/zip-stream/LICENSE-MIT | 22 +
.../archiver/node_modules/zip-stream/README.md | 105 +
.../node_modules/zip-stream/lib/util/index.js | 103 +
.../node_modules/zip-stream/lib/zip-stream.js | 110 +
.../node_modules/compress-commons/LICENSE-MIT | 22 +
.../node_modules/compress-commons/README.md | 26 +
.../lib/archivers/archive-entry.js | 16 +
.../lib/archivers/archive-output-stream.js | 113 +
.../lib/archivers/zip/constants.js | 67 +
.../lib/archivers/zip/general-purpose-bit.js | 101 +
.../compress-commons/lib/archivers/zip/util.js | 71 +
.../lib/archivers/zip/zip-archive-entry.js | 223 +
.../archivers/zip/zip-archive-output-stream.js | 337 +
.../compress-commons/lib/compress-commons.js | 13 +
.../compress-commons/lib/util/index.js | 30 +
.../node_modules/crc32-stream/CHANGELOG | 18 +
.../node_modules/crc32-stream/LICENSE-MIT | 22 +
.../node_modules/crc32-stream/README.md | 81 +
.../crc32-stream/lib/crc32-stream.js | 42 +
.../crc32-stream/lib/deflate-crc32-stream.js | 67 +
.../node_modules/crc32-stream/lib/index.js | 10 +
.../node_modules/crc32-stream/package.json | 71 +
.../node_modules/compress-commons/package.json | 72 +
.../node_modules/zip-stream/package.json | 73 +
.../node_modules/archiver/package.json | 81 +
.../node_modules/zip-folder/package.json | 56 +
.../node_modules/zip-folder/tests.js | 99 +
.../node-firefox-install-app/package.json | 68 +
.../test/sampleapp/build/app.zip | Bin 0 -> 16529 bytes
.../test/sampleapp/icons/icon.svg | 106 +
.../test/sampleapp/icons/icon128x128.png | Bin 0 -> 6760 bytes
.../test/sampleapp/icons/icon16x16.png | Bin 0 -> 804 bytes
.../test/sampleapp/icons/icon48x48.png | Bin 0 -> 2688 bytes
.../test/sampleapp/icons/icon60x60.png | Bin 0 -> 3344 bytes
.../test/sampleapp/index.html | 12 +
.../test/sampleapp/manifest.webapp | 22 +
.../node-firefox-install-app/test/test.js | 70 +
.../node-firefox-launch-app/.editorconfig | 13 +
node_modules/node-firefox-launch-app/.npmignore | 4 +
.../node-firefox-launch-app/.travis.yml | 3 +
node_modules/node-firefox-launch-app/LICENSE | 13 +
node_modules/node-firefox-launch-app/README.md | 108 +
.../examples/sampleApp/app.js | 3 +
.../examples/sampleApp/icons/icon128x128.png | Bin 0 -> 4990 bytes
.../examples/sampleApp/icons/icon16x16.png | Bin 0 -> 1111 bytes
.../examples/sampleApp/icons/icon48x48.png | Bin 0 -> 2928 bytes
.../examples/sampleApp/icons/icon60x60.png | Bin 0 -> 3654 bytes
.../examples/sampleApp/index.html | 27 +
.../examples/sampleApp/manifest.webapp | 11 +
.../node-firefox-launch-app/examples/usage.js | 55 +
.../node-firefox-launch-app/gulpfile.js | 4 +
node_modules/node-firefox-launch-app/index.js | 59 +
.../node-firefox-launch-app/package.json | 77 +
.../tests/unit/test.index.js | 61 +
.../node-firefox-start-simulator/.npmignore | 3 +
.../node-firefox-start-simulator/.travis.yml | 3 +
.../node-firefox-start-simulator/LICENSE | 10 +
.../node-firefox-start-simulator/README.md | 137 +
.../examples/startAndListApps.js | 29 +
.../examples/startDetached.js | 15 +
.../examples/startSpecificSimulatorVersion.js | 17 +
.../node-firefox-start-simulator/gulpfile.js | 4 +
.../node-firefox-start-simulator/index.js | 263 +
.../node_modules/es6-promise/.release.json | 17 +
.../node_modules/es6-promise/Brocfile.js | 75 +
.../node_modules/es6-promise/CHANGELOG.md | 9 +
.../node_modules/es6-promise/LICENSE | 19 +
.../node_modules/es6-promise/README.md | 58 +
.../es6-promise/bin/publish_to_s3.js | 28 +
.../node_modules/es6-promise/bower.json | 29 +
.../es6-promise/config/s3ProjectConfig.js | 26 +
.../es6-promise/config/versionTemplate.txt | 7 +
.../es6-promise/dist/es6-promise.js | 960 +++
.../es6-promise/dist/es6-promise.min.js | 18 +
.../es6-promise/lib/calculateVersion.js | 36 +
.../es6-promise/lib/es6-promise.umd.js | 16 +
.../es6-promise/lib/es6-promise/-internal.js | 251 +
.../es6-promise/lib/es6-promise/asap.js | 82 +
.../es6-promise/lib/es6-promise/enumerator.js | 125 +
.../es6-promise/lib/es6-promise/polyfill.js | 35 +
.../es6-promise/lib/es6-promise/promise.js | 409 +
.../es6-promise/lib/es6-promise/promise/all.js | 52 +
.../es6-promise/lib/es6-promise/promise/race.js | 105 +
.../lib/es6-promise/promise/reject.js | 47 +
.../lib/es6-promise/promise/resolve.js | 49 +
.../es6-promise/lib/es6-promise/utils.js | 39 +
.../node_modules/es6-promise/package.json | 81 +
.../node_modules/es6-promise/server/.jshintrc | 3 +
.../node_modules/es6-promise/server/index.js | 6 +
.../node_modules/es6-promise/testem.json | 11 +
.../node_modules/firefox-client/README.md | 157 +
.../node_modules/firefox-client/index.js | 1 +
.../node_modules/firefox-client/lib/browser.js | 123 +
.../firefox-client/lib/client-methods.js | 115 +
.../node_modules/firefox-client/lib/client.js | 246 +
.../node_modules/firefox-client/lib/console.js | 107 +
.../node_modules/firefox-client/lib/device.js | 29 +
.../node_modules/firefox-client/lib/dom.js | 68 +
.../node_modules/firefox-client/lib/domnode.js | 169 +
.../node_modules/firefox-client/lib/extend.js | 12 +
.../node_modules/firefox-client/lib/jsobject.js | 91 +
.../node_modules/firefox-client/lib/memory.js | 16 +
.../node_modules/firefox-client/lib/network.js | 105 +
.../firefox-client/lib/simulator.js | 22 +
.../firefox-client/lib/stylesheets.js | 96 +
.../node_modules/firefox-client/lib/tab.js | 87 +
.../node_modules/firefox-client/lib/webapps.js | 170 +
.../node_modules/colors/MIT-LICENSE.txt | 19 +
.../node_modules/colors/ReadMe.md | 30 +
.../node_modules/colors/colors.js | 230 +
.../node_modules/colors/example.html | 20 +
.../node_modules/colors/example.js | 20 +
.../node_modules/colors/package.json | 49 +
.../node_modules/js-select/LICENSE | 21 +
.../node_modules/js-select/README.md | 118 +
.../node_modules/js-select/index.js | 197 +
.../node_modules/JSONSelect/.gitmodules | 3 +
.../node_modules/JSONSelect/.npmignore | 5 +
.../node_modules/JSONSelect/JSONSelect.md | 214 +
.../js-select/node_modules/JSONSelect/README.md | 33 +
.../node_modules/JSONSelect/package.json | 49 +
.../JSONSelect/site/css/droid_sans.css | 6 +
.../JSONSelect/site/css/droid_sans.tt | Bin 0 -> 41028 bytes
.../node_modules/JSONSelect/site/css/style.css | 209 +
.../node_modules/JSONSelect/site/index.html | 139 +
.../node_modules/JSONSelect/site/js/demo.js | 64 +
.../JSONSelect/site/js/jquery-1.6.1.min.js | 18 +
.../site/js/jquery.ba-hashchange.min.js | 9 +
.../node_modules/JSONSelect/site/js/json2.js | 480 ++
.../node_modules/JSONSelect/site/js/main.js | 3 +
.../node_modules/JSONSelect/site/js/nav.js | 64 +
.../node_modules/JSONSelect/site/js/showdown.js | 1302 ++++
.../node_modules/JSONSelect/src/Makefile | 73 +
.../JSONSelect/src/build/jshint-check.js | 41 +
.../JSONSelect/src/build/lib/jshint.js | 3854 ++++++++++
.../JSONSelect/src/build/lib/jslint.js | 5504 ++++++++++++++
.../JSONSelect/src/build/lib/parse-js.js | 1319 ++++
.../JSONSelect/src/build/lib/process.js | 1616 ++++
.../JSONSelect/src/build/lib/squeeze-more.js | 22 +
.../JSONSelect/src/build/post-compile.js | 7 +
.../node_modules/JSONSelect/src/build/uglify.js | 199 +
.../JSONSelect/src/dist/jsonselect.js | 522 ++
.../JSONSelect/src/dist/jsonselect.min.js | 1 +
.../JSONSelect/src/dist/jsonselect.min.js.gz | Bin 0 -> 1851 bytes
.../node_modules/JSONSelect/src/jsonselect.js | 522 ++
.../JSONSelect/src/test/conformance_tests.html | 15 +
.../JSONSelect/src/test/css/style.css | 43 +
.../JSONSelect/src/test/js/conf_tests.js | 77 +
.../JSONSelect/src/test/js/doctest.css | 69 +
.../JSONSelect/src/test/js/doctest.js | 1397 ++++
.../JSONSelect/src/test/js/jquery-1.6.1.min.js | 18 +
.../JSONSelect/src/test/lex_test.html | 122 +
.../JSONSelect/src/test/match_test.html | 71 +
.../JSONSelect/src/test/parse_test.html | 98 +
.../node_modules/JSONSelect/src/test/run.js | 85 +
.../JSONSelect/src/test/tests/.npmignore | 1 +
.../JSONSelect/src/test/tests/README.md | 22 +
.../src/test/tests/level_1/basic.json | 31 +
.../test/tests/level_1/basic_first-child.output | 2 +
.../tests/level_1/basic_first-child.selector | 2 +
.../test/tests/level_1/basic_grouping.output | 4 +
.../test/tests/level_1/basic_grouping.selector | 1 +
.../src/test/tests/level_1/basic_id.output | 1 +
.../src/test/tests/level_1/basic_id.selector | 1 +
.../test/tests/level_1/basic_id_multiple.output | 3 +
.../tests/level_1/basic_id_multiple.selector | 1 +
.../test/tests/level_1/basic_id_quotes.output | 2 +
.../test/tests/level_1/basic_id_quotes.selector | 1 +
.../tests/level_1/basic_id_with_type.output | 1 +
.../tests/level_1/basic_id_with_type.selector | 1 +
.../test/tests/level_1/basic_last-child.output | 2 +
.../tests/level_1/basic_last-child.selector | 2 +
.../test/tests/level_1/basic_nth-child-2.output | 4 +
.../tests/level_1/basic_nth-child-2.selector | 1 +
.../test/tests/level_1/basic_nth-child.output | 3 +
.../test/tests/level_1/basic_nth-child.selector | 1 +
.../tests/level_1/basic_nth-last-child.output | 2 +
.../tests/level_1/basic_nth-last-child.selector | 1 +
.../test/tests/level_1/basic_root_pseudo.output | 31 +
.../tests/level_1/basic_root_pseudo.selector | 1 +
.../src/test/tests/level_1/basic_type.output | 14 +
.../src/test/tests/level_1/basic_type.selector | 1 +
.../src/test/tests/level_1/basic_type2.output | 1 +
.../src/test/tests/level_1/basic_type2.selector | 1 +
.../src/test/tests/level_1/basic_type3.output | 47 +
.../src/test/tests/level_1/basic_type3.selector | 1 +
.../test/tests/level_1/basic_universal.output | 85 +
.../test/tests/level_1/basic_universal.selector | 1 +
.../src/test/tests/level_1/collision.json | 6 +
.../test/tests/level_1/collision_nested.output | 1 +
.../tests/level_1/collision_nested.selector | 1 +
.../level_1/collision_quoted-string.output | 1 +
.../level_1/collision_quoted-string.selector | 1 +
.../test/tests/level_1/collision_string.output | 1 +
.../tests/level_1/collision_string.selector | 1 +
.../src/test/tests/level_2/sibling.json | 18 +
.../test/tests/level_2/sibling_childof.output | 1 +
.../test/tests/level_2/sibling_childof.selector | 2 +
.../tests/level_2/sibling_descendantof.output | 3 +
.../tests/level_2/sibling_descendantof.selector | 1 +
.../test/tests/level_2/sibling_unrooted.output | 3 +
.../tests/level_2/sibling_unrooted.selector | 1 +
.../src/test/tests/level_3/basic.json | 31 +
.../tests/level_3/basic_has-multiple.output | 4 +
.../tests/level_3/basic_has-multiple.selector | 1 +
.../tests/level_3/basic_has-root-in-expr.output | 4 +
.../level_3/basic_has-root-in-expr.selector | 1 +
.../level_3/basic_has-sans-first-paren.output | 1 +
.../level_3/basic_has-sans-first-paren.selector | 1 +
.../tests/level_3/basic_has-sans-paren.output | 1 +
.../tests/level_3/basic_has-sans-paren.selector | 2 +
.../tests/level_3/basic_has-whitespace.output | 12 +
.../tests/level_3/basic_has-whitespace.selector | 1 +
.../tests/level_3/basic_has-with-comma.output | 17 +
.../tests/level_3/basic_has-with-comma.selector | 1 +
.../src/test/tests/level_3/basic_has.output | 12 +
.../src/test/tests/level_3/basic_has.selector | 1 +
.../basic_multiple-has-with-strings.output | 5 +
.../basic_multiple-has-with-strings.selector | 1 +
.../JSONSelect/src/test/tests/level_3/expr.json | 9 +
.../src/test/tests/level_3/expr_div.output | 1 +
.../src/test/tests/level_3/expr_div.selector | 1 +
.../test/tests/level_3/expr_ends-with.output | 1 +
.../test/tests/level_3/expr_ends-with.selector | 1 +
.../src/test/tests/level_3/expr_false-eq.output | 3 +
.../test/tests/level_3/expr_false-eq.selector | 4 +
.../test/tests/level_3/expr_greater-than.output | 2 +
.../tests/level_3/expr_greater-than.selector | 1 +
.../test/tests/level_3/expr_less-than.output | 2 +
.../test/tests/level_3/expr_less-than.selector | 1 +
.../src/test/tests/level_3/expr_mod.output | 1 +
.../src/test/tests/level_3/expr_mod.selector | 1 +
.../src/test/tests/level_3/expr_mult.output | 1 +
.../src/test/tests/level_3/expr_mult.selector | 1 +
.../src/test/tests/level_3/expr_null-eq.output | 5 +
.../test/tests/level_3/expr_null-eq.selector | 4 +
.../test/tests/level_3/expr_number-eq.output | 1 +
.../test/tests/level_3/expr_number-eq.selector | 1 +
.../test/tests/level_3/expr_precedence-1.output | 1 +
.../tests/level_3/expr_precedence-1.selector | 1 +
.../test/tests/level_3/expr_precedence-2.output | 1 +
.../tests/level_3/expr_precedence-2.selector | 1 +
.../test/tests/level_3/expr_simple-false.output | 0
.../tests/level_3/expr_simple-false.selector | 1 +
.../src/test/tests/level_3/expr_simple.output | 1 +
.../src/test/tests/level_3/expr_simple.selector | 1 +
.../test/tests/level_3/expr_starts-with.output | 1 +
.../tests/level_3/expr_starts-with.selector | 1 +
.../test/tests/level_3/expr_string-eq.output | 1 +
.../test/tests/level_3/expr_string-eq.selector | 1 +
.../src/test/tests/level_3/expr_true-eq.output | 3 +
.../test/tests/level_3/expr_true-eq.selector | 2 +
.../src/test/tests/level_3/polykids.json | 15 +
.../level_3/polykids_has-with_descendant.output | 1 +
.../polykids_has-with_descendant.selector | 1 +
.../src/test/tests/level_3/polykids_val.output | 2 +
.../test/tests/level_3/polykids_val.selector | 1 +
.../js-select/node_modules/traverse/.npmignore | 1 +
.../js-select/node_modules/traverse/LICENSE | 24 +
.../node_modules/traverse/README.markdown | 273 +
.../node_modules/traverse/examples/json.js | 16 +
.../node_modules/traverse/examples/leaves.js | 15 +
.../node_modules/traverse/examples/negative.js | 8 +
.../node_modules/traverse/examples/scrub.js | 10 +
.../node_modules/traverse/examples/stringify.js | 38 +
.../js-select/node_modules/traverse/index.js | 332 +
.../node_modules/traverse/package.json | 42 +
.../node_modules/traverse/test/circular.js | 114 +
.../node_modules/traverse/test/date.js | 35 +
.../node_modules/traverse/test/equal.js | 219 +
.../node_modules/traverse/test/instance.js | 17 +
.../node_modules/traverse/test/interface.js | 42 +
.../node_modules/traverse/test/json.js | 47 +
.../node_modules/traverse/test/keys.js | 29 +
.../node_modules/traverse/test/leaves.js | 21 +
.../node_modules/traverse/test/mutability.js | 203 +
.../node_modules/traverse/test/negative.js | 20 +
.../js-select/node_modules/traverse/test/obj.js | 15 +
.../node_modules/traverse/test/siblings.js | 35 +
.../node_modules/traverse/test/stop.js | 41 +
.../node_modules/traverse/test/stringify.js | 36 +
.../node_modules/traverse/test/subexpr.js | 34 +
.../node_modules/traverse/test/super_deep.js | 54 +
.../node_modules/js-select/package.json | 51 +
.../node_modules/js-select/select-min.js | 37 +
.../node_modules/js-select/select.js | 1533 ++++
.../node_modules/js-select/test/runner.js | 58 +
.../node_modules/js-select/test/test.js | 161 +
.../node_modules/js-select/test/timeline.js | 1 +
.../node_modules/firefox-client/package.json | 52 +
.../node_modules/firefox-client/test.js | 54 +
.../node_modules/firefox-client/test/README.md | 29 +
.../firefox-client/test/pages/dom.html | 19 +
.../firefox-client/test/pages/index.html | 22 +
.../firefox-client/test/pages/logs.html | 17 +
.../firefox-client/test/pages/network.html | 22 +
.../firefox-client/test/pages/stylesheet1.css | 9 +
.../firefox-client/test/pages/stylesheets.html | 20 +
.../firefox-client/test/pages/test-network.json | 4 +
.../node_modules/firefox-client/test/server.js | 8 +
.../firefox-client/test/test-console.js | 64 +
.../firefox-client/test/test-dom.js | 329 +
.../firefox-client/test/test-jsobject.js | 115 +
.../firefox-client/test/test-logs.js | 106 +
.../firefox-client/test/test-network.js | 88 +
.../firefox-client/test/test-raw.js | 26 +
.../firefox-client/test/test-stylesheets.js | 124 +
.../node_modules/firefox-client/test/utils.js | 35 +
.../node_modules/portfinder/.npmignore | 2 +
.../node_modules/portfinder/README.md | 37 +
.../node_modules/portfinder/lib/portfinder.js | 187 +
.../node_modules/mkdirp/.gitignore.orig | 2 +
.../node_modules/mkdirp/.gitignore.rej | 5 +
.../portfinder/node_modules/mkdirp/.npmignore | 2 +
.../portfinder/node_modules/mkdirp/LICENSE | 21 +
.../node_modules/mkdirp/README.markdown | 21 +
.../node_modules/mkdirp/examples/pow.js | 6 +
.../node_modules/mkdirp/examples/pow.js.orig | 6 +
.../node_modules/mkdirp/examples/pow.js.rej | 19 +
.../portfinder/node_modules/mkdirp/index.js | 20 +
.../portfinder/node_modules/mkdirp/package.json | 37 +
.../node_modules/mkdirp/test/mkdirp.js | 28 +
.../portfinder/node_modules/mkdirp/test/race.js | 41 +
.../portfinder/node_modules/mkdirp/test/rel.js | 32 +
.../node_modules/portfinder/package.json | 60 +
.../portfinder/test/fixtures/.gitkeep | 0
.../portfinder/test/port-finder-socket-test.js | 92 +
.../portfinder/test/port-finder-test.js | 67 +
.../node-firefox-start-simulator/package.json | 95 +
.../node-firefox-start-simulator/test/test.js | 70 +
.../node-firefox-uninstall-app/.npmignore | 2 +
node_modules/node-firefox-uninstall-app/LICENSE | 13 +
.../node-firefox-uninstall-app/README.md | 106 +
.../examples/sampleApp/app.js | 3 +
.../examples/sampleApp/icons/icon128x128.png | Bin 0 -> 4990 bytes
.../examples/sampleApp/icons/icon16x16.png | Bin 0 -> 1111 bytes
.../examples/sampleApp/icons/icon48x48.png | Bin 0 -> 2928 bytes
.../examples/sampleApp/icons/icon60x60.png | Bin 0 -> 3654 bytes
.../examples/sampleApp/index.html | 27 +
.../examples/sampleApp/manifest.webapp | 11 +
.../examples/usage.js | 55 +
.../node-firefox-uninstall-app/gulpfile.js | 4 +
.../node-firefox-uninstall-app/index.js | 61 +
.../node_modules/es6-promise/.release.json | 17 +
.../node_modules/es6-promise/Brocfile.js | 75 +
.../node_modules/es6-promise/CHANGELOG.md | 9 +
.../node_modules/es6-promise/LICENSE | 19 +
.../node_modules/es6-promise/README.md | 58 +
.../es6-promise/bin/publish_to_s3.js | 28 +
.../node_modules/es6-promise/bower.json | 29 +
.../es6-promise/config/s3ProjectConfig.js | 26 +
.../es6-promise/config/versionTemplate.txt | 7 +
.../es6-promise/dist/es6-promise.js | 960 +++
.../es6-promise/dist/es6-promise.min.js | 18 +
.../es6-promise/lib/calculateVersion.js | 36 +
.../es6-promise/lib/es6-promise.umd.js | 16 +
.../es6-promise/lib/es6-promise/-internal.js | 251 +
.../es6-promise/lib/es6-promise/asap.js | 82 +
.../es6-promise/lib/es6-promise/enumerator.js | 125 +
.../es6-promise/lib/es6-promise/polyfill.js | 35 +
.../es6-promise/lib/es6-promise/promise.js | 409 +
.../es6-promise/lib/es6-promise/promise/all.js | 52 +
.../es6-promise/lib/es6-promise/promise/race.js | 105 +
.../lib/es6-promise/promise/reject.js | 47 +
.../lib/es6-promise/promise/resolve.js | 49 +
.../es6-promise/lib/es6-promise/utils.js | 39 +
.../node_modules/es6-promise/package.json | 81 +
.../node_modules/es6-promise/server/.jshintrc | 3 +
.../node_modules/es6-promise/server/index.js | 6 +
.../node_modules/es6-promise/testem.json | 11 +
.../node-firefox-uninstall-app/package.json | 65 +
2498 files changed, 405565 insertions(+)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[46/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/jquery-1.6.1.min.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/jquery-1.6.1.min.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/jquery-1.6.1.min.js
new file mode 100644
index 0000000..b2ac174
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/jquery-1.6.1.min.js
@@ -0,0 +1,18 @@
+/*!
+ * jQuery JavaScript Library v1.6.1
+ * http://jquery.com/
+ *
+ * Copyright 2011, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2011, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Thu May 12 15:04:36 2011 -0400
+ */
+(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!cj[a]){var b=f("<"+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),c.body.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write("<!doctype><html><body></body></html>");b=cl.createElement(a),cl.body.appendChild(b),d=f.css(b,"display"),c.body.removeChild(ck)}cj[a]=d}return cj[a]}function cu(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function ct(){cq=b}function cs(){setTimeout(ct,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h
in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function ca(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function b_(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bF.test(a)?d(a,e):b_(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)b_(a+"["+e+"]",b[e],c,d);els
e d(a,b)}function b$(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bU,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=b$(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=b$(a,c,d,e,"*",g));return l}function bZ(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bQ),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bD(a,b,c){var d=b==="width"?bx:by,e=b==="width"?a.offsetWidth:a.offsetHeight;if(c==="border")return e;f.each(d,function(){c||(e-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?e+=parseFloat(f.css(a,"margin"+this))||0:e-=parseFloat(f.css(a,"border"+this+"Width"))||0});return e}function bn(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bf,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)
}function bm(a){f.nodeName(a,"input")?bl(a):a.getElementsByTagName&&f.grep(a.getElementsByTagName("input"),bl)}function bl(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bk(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bj(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bi(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(v
ar i=0,j=g[h].length;i<j;i++)f.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function bh(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function X(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(S.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function W(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function O(a,b){return(a&&a!=="*"?a+".":"")+b.replace(A,"`").replace(B,"&")}function N(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\
\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;i<s.length;i++)g=s[i],g.origType.replace(y,"")===a.type?q.push(g.selector):s.splice(i--,1);e=f(a.target).closest(q,a.currentTarget);for(j=0,k=e.length;j<k;j++){m=e[j];for(i=0;i<s.length;i++){g=s[i];if(m.selector===g.selector&&(!n||n.test(g.namespace))&&!m.elem.disabled){h=m.elem,d=null;if(g.preType==="mouseenter"||g.preType==="mouseleave")a.type=g.preType,d=f(a.relatedTarget).closest(g.selector)[0],d&&f.contains(h,d)&&(d=h);(!d||d!==h)&&p.push({elem:h,handleObj:g,level:m.level})}}}for(j=0,k=p.length;j<k;j++){e=p[j];if(c&&e.level>c)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function L(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefaul
t()}function F(){return!0}function E(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function H(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(H,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,
p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=d.userAgent,x,y,z,A=Object.prototype.toString,B=Object.prototype.hasOwnProperty,C=Array.prototype.push,D=Array.prototype.slice,E=String.prototype.trim,F=Array.prototype.indexOf,G={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment(
[g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.1",length:0,size:function(){return this.length},toArray:function(){return D.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?C.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),y.done(a);return this},eq:function(a){return a===
-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(D.apply(this,arguments),"slice",D.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:C,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:fu
nction(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;y.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!y){y=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",z,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",z),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&H()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):G[A.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type
(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!B.call(a,"constructor")&&!B.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||B.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,
c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:E?function(a){return a==null?"":E.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?C.call(c,a):e.merge(c,a)}return c},inArray:function(a,b){if(F)return F.call(b,a);for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanc
eof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=D.call(arguments,2),g=function(){return a.apply(c,f.concat(D.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)e.access(a,j,c[j],f,g,d);return a}if(d!==b){f=!h&&f&&e.isFunction(d);for(var k=0;k<i;k++)g(a[k],c,f?d.call(a[k],k,g(a[k],c)):d,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=s.exec(a)||t.exec(a)||u.exec(a)||a.indexOf("compatible")<0&&v.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=
a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){G["[object "+b+"]"]=b.toLowerCase()}),x=e.uaMatch(w),x.browser&&(e.browser[x.browser]=!0,e.browser.version=x.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?z=function(){c.removeEventListener("DOMContentLoaded",z,!1),e.ready()}:c.attachEvent&&(z=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",z),e.ready())});return e}(),g="done fail isResolved isRejected promise then always pipe".split(" "),h=[].slice;f.extend({_Deferred:function(){var a=[],b,c,d,e={done:function(){if(!d){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=f.type(i),j==="array"?e.done.apply(e,i
):j==="function"&&a.push(i);k&&e.resolveWith(k[0],k[1])}return this},resolveWith:function(e,f){if(!d&&!b&&!c){f=f||[],c=1;try{while(a[0])a.shift().apply(e,f)}finally{b=[e,f],c=0}}return this},resolve:function(){e.resolveWith(this,arguments);return this},isResolved:function(){return!!c||!!b},cancel:function(){d=1,a=[];return this}};return e},Deferred:function(a){var b=f._Deferred(),c=f._Deferred(),d;f.extend(b,{then:function(a,c){b.done(a).fail(c);return this},always:function(){return b.done.apply(b,arguments).fail.apply(this,arguments)},fail:c.done,rejectWith:c.resolveWith,reject:c.resolve,isRejected:c.isResolved,pipe:function(a,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[c,"reject"]},function(a,c){var e=c[0],g=c[1],h;f.isFunction(e)?b[a](function(){h=e.apply(this,arguments),h&&f.isFunction(h.promise)?h.promise().then(d.resolve,d.reject):d[g](h)}):b[a](d[g])})}).promise()},promise:function(a){if(a==null){if(d)return d;d=a={}}var c=g.length;while(c--)a[g[c]]=b[g
[c]];return a}}),b.done(c.cancel).fail(b.cancel),delete b.cancel,a&&a.call(b,b);return b},when:function(a){function i(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c<d;c++)b[c]&&f.isFunction(b[c].promise)?b[c].promise().then(i(c),g.reject):--e;e||g.resolveWith(g,b)}else g!==a&&g.resolveWith(g,d?[a]:[]);return g.promise()}}),f.support=function(){var a=c.createElement("div"),b=c.documentElement,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;a.setAttribute("className","t"),a.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};f=c.createElement("select"),g=f.appendChild(c.createElement("option")),h=a.getElementsByTagName("input")[0],j={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getEl
ementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},h.checked=!0,j.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,j.optDisabled=!g.disabled;try{delete a.test}catch(s){j.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function b(){j.noCloneEvent=!1,a.detachEvent("onclick",b)}),a.cloneNode(!0).fireEvent("onclick")),h=c.createElement("input"),h.value="t",h.setAttribute("type","radio"),j.radioValue=h.value==="t",h.setAttribute("checked","checked"),a.appendChild(h),k=c.createDocumentFragment(),k.appendChild(a.firstChild),j.c
heckClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",l=c.createElement("body"),m={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};for(q in m)l.style[q]=m[q];l.appendChild(a),b.insertBefore(l,b.firstChild),j.appendChecked=h.checked,j.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,j.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="<div style='width:4px;'></div>",j.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>",n=a.getElementsByTagName("td"),r=n[0].offsetHeight===0,n[0].style.display="",n[1].style.display="none",j.reliableHiddenOffsets=r&&n[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(i=c.createElement("div"),i.style.width="0",i.style.marginRight="0",a.appendChild(i),j.reliableMarginRight=(parseInt((c.defaultView.get
ComputedStyle(i,null)||{marginRight:0}).marginRight,10)||0)===0),l.innerHTML="",b.removeChild(l);if(a.attachEvent)for(q in{submit:1,change:1,focusin:1})p="on"+q,r=p in a,r||(a.setAttribute(p,"return;"),r=typeof a[p]=="function"),j[q+"Bubbles"]=r;return j}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g])
,d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h<i;h++)g=e[h].name,g.indexOf("data-")===0&&(g=f.camelCas
e(g.substring(5)),k(this[0],g,d[g]))}}return d}if(typeof a=="object")return this.each(function(){f.data(this,a)});var j=a.split(".");j[1]=j[1]?"."+j[1]:"";if(c===b){d=this.triggerHandler("getData"+j[1]+"!",[j[0]]),d===b&&this.length&&(d=f.data(this[0],a),d=k(this[0],a,d));return d===b&&j[1]?this.data(j[0]):d}return this.each(function(){var b=f(this),d=[j[0],c];b.triggerHandler("setData"+j[1]+"!",d),f.data(this,a,c),b.triggerHandler("changeData"+j[1]+"!",d)})},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,c){a&&(c=(c||"fx")+"mark",f.data(a,c,(f.data(a,c,b,!0)||0)+1,!0))},_unmark:function(a,c,d){a!==!0&&(d=c,c=a,a=!1);if(c){d=d||"fx";var e=d+"mark",g=a?0:(f.data(c,e,b,!0)||1)-1;g?f.data(c,e,g,!0):(f.removeData(c,e,!0),m(c,d,"mark"))}},queue:function(a,c,d){if(a){c=(c||"fx")+"queue";var e=f.data(a,c,b,!0);d&&(!e||f.isArray(d)?e=f.data(a,c,f.makeArray(d),!0):e.push(d));return e||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(
a,b),d=c.shift(),e;d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),d.call(a,function(){f.dequeue(a,b)})),c.length||(f.removeData(a,b+"queue",!0),m(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){typeof a!="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(){var c=this;setTimeout(function(){f.dequeue(c,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f._Deferred(),!0))h++,l.done(m);m();return d.promise()}});var n=/[\
n\t\r]/g,o=/\s+/,p=/\r/g,q=/^(?:button|input)$/i,r=/^(?:button|input|object|select|textarea)$/i,s=/^a(?:rea)?$/i,t=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,u=/\:/,v,w;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,a,b,!0,f.prop)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.addClass(a.call(this,b,c.attr("class")||""))});if(a&&typeof a=="string"){var b=(a||"").split(o);for(var c=0,d=this.length;c<d;c++){var e=this[c];if(e.nodeType===1)if(!e.className)e.className=a;else{var g=" "+e.className+" ",h=e.className;for(var i=0,j=b.length;i<j;i++)g.indexOf(" "+b[i]+" ")<0&&(h+=" "+b[i]);e.className=f.trim(h)}}}return this},r
emoveClass:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.removeClass(a.call(this,b,c.attr("class")))});if(a&&typeof a=="string"||a===b){var c=(a||"").split(o);for(var d=0,e=this.length;d<e;d++){var g=this[d];if(g.nodeType===1&&g.className)if(a){var h=(" "+g.className+" ").replace(n," ");for(var i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){var d=f(this);d.toggleClass(a.call(this,c,d.attr("class"),b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(o);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ";for(var c=0,d=this.
length;c<d;c++)if((" "+this[c].className+" ").replace(n," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;return(e.value||"").replace(p,"")}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h<i;h++){var j=e[h];if(j.selected&&(f.support.optDisabled?!j.disabled:j.getAttribute("d
isabled")===null)&&(!j.parentNode.disabled||!f.nodeName(j.parentNode,"optgroup"))){b=f(j).val();if(g)return b;d.push(b)}}if(g&&!d.length&&e.length)return f(e[c]).val();return d},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);c=j&&f.attrFix[c]||c,i=f.attrHooks[c],i||(!t.test(c)||typeof d!="boolean"&&d!==b&&d.toLowerCase()!==c.toLowerCase()?v&&(f.nodeName(a,"form")||u.test(c))&&(i=v):i=w);if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j)return i.get(a,c);h=a.getAttribute(c);ret
urn h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var
g,h,i=e!==1||!f.isXMLDoc(a);c=i&&f.propFix[c]||c,h=f.propHooks[c];return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),w={get:function(a,c){return a[f.propFix[c]||c]?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=b),a.setAttribute(c,c.toLowerCase()));return c}},f.attrHooks.value={get:function(a,b){if(v&&f.nodeName(a,"button"))return v.get(a,b);return a.value},set:function(a,b,c){if(v&&f.nodeName(a,"button"))return v.set(a,b,c);a.value=b}},f.support.getSetAttribute||(f.attrFix=f.propFix,v=f.attrHooks.name=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each
(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var x=Object.prototype.hasOwnProperty,y=/\.(.*)$/,z=/^(?:textarea|input|select)$/i,A=/\./g,B=/ /g,C=/[^\w\s.|`]/g,D=function(a){return a.replace(C,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.no
deType!==8){if(d===!1)d=E;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=E);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)re
turn;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),D).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j<p.length;j++){q=p[j];if(l||n.test(q.namespace))f.event.remove(a,r,q.handler,j),p.splice(j--,1)}continue}o=f.event.special[h]||{};for(j=e||0;j<p.length;j++){q=p[j];if(d.guid===q.guid){if(l||n.test(q.namespace))e==null&&p.splice(j--,1),o.remove&&o.remove.call(a,q);if(e!=null)break}}if(p.length===0||e!=null&&p.length===1)(!o.teardown||o.teardown.call(a,m)===!1)&&f.removeEvent(a,h,s.handle),g=null,delete t[h]}if(f.isEmptyObject(t)){var u=s.handle;u&&(u.elem=null),delete s.events,delete s.handle,f.isEmptyObject(s)&&f.removeData(a,b,!0)}}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){var h=c.type||c,i=[],j;h.ind
exOf("!")>=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem
+)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h<i;h++){var j=d[h];if(e||c.namespace_re.test(j.namespace)){c.handler=j.handler,c.data=j
.data,c.handleObj=j;var k=j.handler.apply(this,g);k!==b&&(c.result=k,k===!1&&(c.preventDefault(),c.stopPropagation()));if(c.isImmediatePropagationStopped())break}}return c.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[f.expando])return a;var d=a;a=f.Event(d);for(var e=this.props.length,g;e;)g=this.props[--e],a[g]=d[g];a.target||(a.target=a.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement);if(a.pageX==null&&a.clientX!=null){var h=a.target.ownerDocument||c,i=h.documentElement,j=h.body;a.pageX=a.clientX+(i&&i.scrollLeft||j&&j.scrollLeft||0)-(i&&i.cli
entLeft||j&&j.clientLeft||0),a.pageY=a.clientY+(i&&i.scrollTop||j&&j.scrollTop||0)-(i&&i.clientTop||j&&j.clientTop||0)}a.which==null&&(a.charCode!=null||a.keyCode!=null)&&(a.which=a.charCode!=null?a.charCode:a.keyCode),!a.metaKey&&a.ctrlKey&&(a.metaKey=a.ctrlKey),!a.which&&a.button!==b&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a},guid:1e8,proxy:f.proxy,special:{ready:{setup:f.bindReady,teardown:f.noop},live:{add:function(a){f.event.add(this,O(a.origType,a.selector),f.extend({},a,{handler:N,guid:a.handler.guid}))},remove:function(a){f.event.remove(this,O(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}}},f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!this.preventDefault)return new f.Event(a,b);a&
&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?F:E):this.type=a,b&&f.extend(this,b),this.timeStamp=f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=F;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=F;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=F,this.stopPropagation()},isDefaultPrevented:E,isPropagationStopped:E,isImmediatePropagationStopped:E};var G=function(a){var b=a.relatedTarget;a.type=a.data;try{if(b&&b!==c&&!b.parentNode)return;while(b&&b!==this)b=b.parentNode;b!==this&&f.event.handle.apply(this,arguments)}catch(d){}},H=function(a){a.type=a.data,f.event.handle.apply(this,arguments)};f.each({mouseenter:"mouseover",mouselea
ve:"mouseout"},function(a,b){f.event.special[a]={setup:function(c){f.event.add(this,b,c&&c.selector?H:G,a)},teardown:function(a){f.event.remove(this,b,a&&a.selector?H:G)}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(a,b){if(!f.nodeName(this,"form"))f.event.add(this,"click.specialSubmit",function(a){var b=a.target,c=b.type;(c==="submit"||c==="image")&&f(b).closest("form").length&&L("submit",this,arguments)}),f.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,c=b.type;(c==="text"||c==="password")&&f(b).closest("form").length&&a.keyCode===13&&L("submit",this,arguments)});else return!1},teardown:function(a){f.event.remove(this,".specialSubmit")}});if(!f.support.changeBubbles){var I,J=function(a){var b=a.type,c=a.value;b==="radio"||b==="checkbox"?c=a.checked:b==="select-multiple"?c=a.selectedIndex>-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},K=function(c){var d=c.target,e,g;i
f(!!z.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=J(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:K,beforedeactivate:K,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&K.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&K.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",J(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in I)f.event.add(this,c+".specialChange",I[c]);return z.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return z.test(this.nodeName)}},I=f.event.special.change.filters,I.focus=I.before
activate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i<j;i++)f.event.add(this[i],a,g,d);return this}}),f.fn.extend({unbind:function(a,b){if(typeof a=="object"&&!a.preventDefault)for(var c in a)this.unbind(c,a[c]);else for(var d=0,e=this.length;d<e;d++)f.event.remove(this[d],a,b);return this},delegate:function(a,b,c,d){
return this.live(b,c,d,a)},undelegate:function(a,b,c){return arguments.length===0?this.unbind("live"):this.die(b,null,c,a)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f.data(this,"lastToggle"+a.guid)||0)%d;f.data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var M={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};f.each(["live","die"],function(a,c){f.fn[c]=function(a,d,e,g){var h,i=0,j,k,l,m=g||this.selector,n=g?this:f(this.context);if(typeof a=="object"&&!a.preventDefault){for(var o in a)n[c](o,d,a[o],m);return this}if(c==="die"&&!a&&g&&g.charAt(0)==="."){n.unbind(g);return this}if(d===!1||f.isF
unction(d))e=d||E,d=b;a=(a||"").split(" ");while((h=a[i++])!=null){j=y.exec(h),k="",j&&(k=j[0],h=h.replace(y,""));if(h==="hover"){a.push("mouseenter"+k,"mouseleave"+k);continue}l=h,M[h]?(a.push(M[h]+k),h=h+k):h=(M[h]||h)+k;if(c==="live")for(var p=0,q=n.length;p<q;p++)f.event.add(n[p],"live."+O(h,m),{data:d,selector:m,handler:e,origType:h,origHandler:e,preType:l});else n.unbind("live."+O(h,m),e)}return this}}),f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}if(i.nodeType===1){f||(i.sizcache=c,i.sizset=g);if(typeof b!="string"){if(i===b){
j=!0;break}}else if(k.filter(b,[i]).length>0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}i.nodeType===1&&!f&&(i.sizcache=c,i.sizset=g);if(i.nodeName.toLowerCase()===b){j=i;break}i=i[a]}d[g]=j}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{
!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},k.matches=function(a,b){return k(a,null,null,b)},k.matchesSelector=function(a,b){return k(b,null,null,[a]).l
ength>0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e<f;e++){var g,h=l.order[e];if(g=l.leftMatch[h].exec(a)){var j=g[1];g.splice(1,1);if(j.substr(j.length-1)!=="\\"){g[1]=(g[1]||"").replace(i,""),d=l.find[h](g,b,c);if(d!=null){a=a.replace(l.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},k.filter=function(a,c,d,e){var f,g,h=a,i=[],j=c,m=c&&c[0]&&k.isXML(c[0]);while(a&&c.length){for(var n in l.filter)if((f=l.leftMatch[n].exec(a))!=null&&f[2]){var o,p,q=l.filter[n],r=f[1];g=!1,f.splice(1,1);if(r.substr(r.length-1)==="\\")continue;j===i&&(i=[]);if(l.preFilter[n]){f=l.preFilter[n](f,j,d,i,e,m);if(!f)g=o=!0;else if(f===!0)continue}if(f)for(var s=0;(p=j[s])!=null;s++)if(p){o=q(p,f,s,j);var t=e^!!o;d&&o!=null?t?g=!0:j[s]=!1:t&&(i.push(p),g=!0)}if(o!==b){d||(j=i),a=a.replace(l.match[n],"");if(!g)return[];break}}if(a===h)if(g==null)k.error(a);else break;h=a}return j},k.error=function(a)
{throw"Syntax error, unrecognized expression: "+a};var l=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!j.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)
&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&k.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&k.filter(b,a,!0)}},"":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("parentNode",b,f,a,e,c)},"~":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("previousSibling",b,f,a,e,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTa
gName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(i,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,
!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()
==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerT
ext||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}k.error(e)},CHILD:function(a,b){var c=b[1],d=a;switch(c){case"only":case"first":while(d=d.previousSibling)if(d.nodeType===1)return!1;if(c==="first")return!0;d=a;case"last":while(d=d.nextSibling)if(d.nodeType===1)return!1;return!0;case"nth":var e=b[2],f=b[3];if(e===1&&f===0)return!0;var g=b[0],h=a.parentNode;if(h&&(h.sizcache!==g||!a.nodeIndex)){var i=0;for(d=h.firstChild;d;d=d.nextSibling)d.nodeType===1&&(d.nodeIndex=++i);h.sizcache=g}var j=a.nodeIndex-f;return e===0?j===0:j%e===0&&j/e>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?
f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c<f;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var r,s;c.documentElement.compareDocumentPosition?r=function
(a,b){if(a===b){g=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(r=function(a,b){if(a===b){g=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],h=a.parentNode,i=b.parentNode,j=h;if(h===i)return s(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return s(e[k],f[k]);return k===c?s(a,f[k],-1):s(e[k],b,1)},s=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),k.getText=function(a){var b="",c;for(var d=0;a[d];d++)c=a[d],c.nodeType===3||c.nodeType===4?b+=c.nodeValue:c.nodeType!==8&&(b+=k.getText(c.childNodes));return b},function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.fi
rstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST
'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.
mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentP
osition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g<h;g++)k(a,f[g],d);return k.filter(e,d)};f.find=k,f.expr=k.selectors,f.expr[":"]=f.expr.filters,f.unique=k.uniqueSort,f.text=k.getText,f.isXMLDoc=k.isXML,f.contains=k.contains}();var P=/Until$/,Q=/^(?:parents|prevUntil|prevAll)/,R=/,/,S=/^.[^:#\[\.,]*$/,T=Array.prototype.slice,U=f.expr.match.POS,V={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=
g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(X(this,a,!1),"not",a)},filter:function(a){return this.pushStack(X(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d<e;d++)i=a[d],j[i]||(j[i]=U.test(i)?f(i,b||this.context):i);while(g&&g.ownerDocument&&g!==b){for(i in j)h=j[i],(h.jquery?h.index(g)>-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=U.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(l?l.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)
break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(W(c[0])||W(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.par
entNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=T.call(arguments);P.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!V[a]?f.unique(e):e,(this.length>1||R.test(d))&&Q.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var Y=/ jQuery\d+="(?:\d+|null)"/g,Z=/^\s+/,$=/<(?!area|br
|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,_=/<([\w:]+)/,ba=/<tbody/i,bb=/<|&#?\w+;/,bc=/<(?:script|object|embed|option|style)/i,bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*<!(?:\[CDATA\[|\-\-)/,bg={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function
(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return t
his.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0
]&&this[0].nodeType===1?this[0].innerHTML.replace(Y,""):null;if(typeof a=="string"&&!bc.test(a)&&(f.support.leadingWhitespace||!Z.test(a))&&!bg[(_.exec(a)||["",""])[1].toLowerCase()]){a=a.replace($,"<$1></$2>");try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else f.isFunction(a)?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];
if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bd.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bh(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,bn)}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i=b&&b[0]?b[0].ownerDocument||b[0]:c;a.length===1&&typeof a[0]=="string"&&a[0].length<512&&i===c&&a[0].charAt(0)==="<"&&!bc.test(a[0])&&(f.support.checkClone||!bd.test(a[0]))&&(g=!0,h=f.fragments[a[0]],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[a[0]]=h?e:1);return
{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bj(a,d),e=bk(a),g=bk(d);for(h=0;e[h];++h)bj(e[h],g[h])}if(b){bi(a,d);if(c){e=bk(a),g=bk(d);for(h=0;e[h];++h)bi(e[h],g[h])}}return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||
+b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!bb.test(k))k=b.createTextNode(k);else{k=k.replace($,"<$1></$2>");var l=(_.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=ba.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]==="<table>"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Z.test(k)&&o.insertBefore(b.createTextNode(Z.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i<r;i++)bm(k[i]);else bm(k);k.nodeType?h.push(k):h=f.merge(h,k)}if(d){g=function(a){return!a.type||be.test(a.type)};for(j=0;h[j];j++)if(e&&f.nodeName(h[j],"script")&&(!h[j].type||h[j].type.toLowerCase()===
"text/javascript"))e.push(h[j].parentNode?h[j].parentNode.removeChild(h[j]):h[j]);else{if(h[j].nodeType===1){var s=f.grep(h[j].getElementsByTagName("script"),g);h.splice.apply(h,[j+1,0].concat(s))}d.appendChild(h[j])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.expando,g=f.event.special,h=f.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&f.noData[j.nodeName.toLowerCase()])continue;c=j[f.expando];if(c){b=d[c]&&d[c][e];if(b&&b.events){for(var k in b.events)g[k]?f.event.remove(j,k):f.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[f.expando]:j.removeAttribute&&j.removeAttribute(f.expando),delete d[c]}}}});var bo=/alpha\([^)]*\)/i,bp=/opacity=([^)]*)/,bq=/-([a-z])/ig,br=/([A-Z]|^ms)/g,bs=/^-?\d+(?:px)?$/i,bt=/^-?\d/,bu=/^[+\-]=/,bv=/[^+\-\.\de]+/g,bw={position:"absolute",visibility:"hidden",display:"block"},bx=["Left","Right"],by=["Top","Bottom"],bz,bA,bB,bC=function(a,b){return b.toUpperCase()};f.fn.css=function(a,c){if(arguments.len
gth===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)})},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bz(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{zIndex:!0,fontWeight:!0,opacity:!0,zoom:!0,lineHeight:!0,widows:!0,orphans:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d;if(h==="number"&&isNaN(d)||d==null)return;h==="string"&&bu.test(d)&&(d=+d.replace(bv,"")+parseFloat(f.css(a,c))),h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;i
f(bz)return bz(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]},camelCase:function(a){return a.replace(bq,bC)}}),f.curCSS=f.css,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){var e;if(c){a.offsetWidth!==0?e=bD(a,b,d):f.swap(a,bw,function(){e=bD(a,b,d)});if(e<=0){e=bz(a,b,b),e==="0px"&&bB&&(e=bB(a,b,b));if(e!=null)return e===""||e==="auto"?"0px":e}if(e<0||e==null){e=a.style[b];return e===""||e==="auto"?"0px":e}return typeof e=="string"?e:e+"px"}},set:function(a,b){if(!bs.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bp.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bo.test(g)?g.replace(bo,e):g+" "+e}}),f(functio
n(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,c){var d,e,g;c=c.replace(br,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bs.test(d)&&bt.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a
.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bE=/%20/g,bF=/\[\]$/,bG=/\r?\n/g,bH=/#.*$/,bI=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bJ=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bK=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bL=/^(?:GET|HEAD)$/,bM=/^\/\//,bN=/\?/,bO=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bP=/^(?:select|textarea)/i,bQ=/\s+/,bR=/([?&])_=[^&]*/,bS=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bT=f.fn.load,bU={},bV={},bW,bX;try{bW=e.href}catch(bY){bW=c.createElement("a"),bW.href="",bW=bW.href}bX=bS.exec(bW.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bT)return bT.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="PO
ST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bO,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bP.test(this.nodeName)||bJ.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bG,"\r\n")}}):{name:b.name,value:c.replace(bG,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dat
aType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bW,isLocal:bK.test(bX[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bZ(bU),ajaxTransport:bZ(bV),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?ca(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifMo
dified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=cb(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bI.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCa
se()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bH,"").replace(bM,bX[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bQ),d.crossDomain==null&&(r=bS.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bX[1]&&r[2]==bX[2]&&(r[3]||(r[1]==="http:"?80:443))==(bX[3]||(bX[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bU,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bL.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bN.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bR,"$1_="+x);d.url=y
+(y===d.url?(bN.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bV,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"=
"+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bE,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g|
|f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,
1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o
){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq,cr=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),e===""&&f.css(d,"display")==="none"&&f._data(d,"olddisplay",cv(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||"
"}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(cu("hide",3),a,b,c);for(var d=0,e=this.length;d<e;d++)if(this[d].style){var g=f.css(this[d],"display");g!=="none"&&!f._data(this[d],"olddisplay")&&f._data(this[d],"olddisplay",g)}for(d=0;d<e;d++)this[d].style&&(this[d].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(cu("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return this[e.queue===!1?"each":"queue"](function(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n
,o;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]),h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(f.support.inlineBlockNeedsLayout?(j=cv(this.nodeName),j==="inline"?this.style.display="inline-block":(this.style.display="inline",this.style.zoom=1)):this.style.display="inline-block"))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)k=new f.fx(this,b,i),h=a[i],cm.test(h)?k[h==="toggle"?d?"show":"hide":h]():(l=cn.exec(h),m=k.cur(),l?(n=parseFloat(l[2]),o=l[3]||(f.cssNumber[i]?"":"px"),o!=="px"&&(f.style(this,i,(n||1)+o),m=(n||1)/k.cur()*m,f.style(this,i,m+o)),l[1]&&(n=(l[1]==="-="?-1:1)*n+m),k.custom(m,n,o)):k.custo
m(m,h,""));return!0})},stop:function(a,b){a&&this.queue([]),this.each(function(){var a=f.timers,c=a.length;b||f._unmark(!0,this);while(c--)a[c].elem===this&&(b&&a[c](!0),a.splice(c,1))}),b||this.dequeue();return this}}),f.each({slideDown:cu("show",1),slideUp:cu("hide",1),slideToggle:cu("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default,d.old=d.complete,d.complete=function(a){d.queue!==!1?f.dequeue(this):a!==!1&&f._unmark(this),f.isFunction(d.old)&&d.old.call(this)};return d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},t
imers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,b,c){function h(a){return d.step(a)}var d=this,e=f.fx,g;this.startTime=cq||cs(),this.start=a,this.end=b,this.unit=c||this.unit||(f.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,h.elem=this.elem,h()&&f.timers.push(h)&&!co&&(cr?(co=1,g=function(){co&&(cr(g),e.tick())},cr(g)):co=setInterval(e.tick,e.interval))},show:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide
:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b=cq||cs(),c=!0,d=this.elem,e=this.options,g,h;if(a||b>=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b<a.length;++b)a[b]()||a.splice(b--,1);a.length||f.fx.stop()},interval:13,stop:funct
ion(){clearInterval(co),co=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit:a.elem[a.prop]=a.now}}}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cw=/^t(?:able|d|h)$/i,cx=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?f.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(d){}var e=b.ownerDocument,g=e.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=e.body,i=cy(e),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||f.support.boxMod
el&&g.scrollTop||h.scrollTop,m=i.pageXOffset||f.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:f.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);f.offset.initialize();var c,d=b.offsetParent,e=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(f.offset.supportsFixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===d&&(l+=b.offsetTop,m+=b.offsetLeft,f.offset.doesNotAddBorder&&(!f.offset.doesAddBorderForTableAndCells||!cw.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),f.offset.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&
&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;f.offset.supportsFixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},f.offset={initialize:function(){var a=c.body,b=c.createElement("div"),d,e,g,h,i=parseFloat(f.css(a,"marginTop"))||0,j="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.
doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.
<TRUNCATED>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[35/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/select-min.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/select-min.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/select-min.js
new file mode 100644
index 0000000..466ccf7
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/select-min.js
@@ -0,0 +1,37 @@
+var select=function(){var c=function(j,f){var d=c.resolve(j,f||"/"),l=c.modules[d];if(!l)throw Error("Failed to resolve module "+j+", tried "+d);return(d=c.cache[d])?d.exports:l()};c.paths=[];c.modules={};c.cache={};c.extensions=[".js",".coffee"];c._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0};c.resolve=function(j,f){function d(b){b=h.normalize(b);if(c.modules[b])return b;for(var a=0;a<c.extensions.length;a++){var e=c.extensions[a];if(c.modules[b+e])return b+e}}function l(b){var b=b.replace(/\/+$/,
+""),a=h.normalize(b+"/package.json");if(c.modules[a]){var a=c.modules[a](),e=a.browserify;if("object"===typeof e&&e.main){if(a=d(h.resolve(b,e.main)))return a}else if("string"===typeof e){if(a=d(h.resolve(b,e)))return a}else if(a.main&&(a=d(h.resolve(b,a.main))))return a}return d(b+"/index")}f||(f="/");if(c._core[j])return j;var h=c.modules.path(),a=(f=h.resolve("/",f))||"/";if(j.match(/^(?:\.\.?\/|\/)/)){var e=d(h.resolve(a,j))||l(h.resolve(a,j));if(e)return e}a:{for(var e="/"===a?[""]:h.normalize(a).split("/"),
+a=[],g=e.length-1;0<=g;g--)if("node_modules"!==e[g]){var b=e.slice(0,g+1).join("/")+"/node_modules";a.push(b)}for(e=0;e<a.length;e++){g=a[e];if(b=d(g+"/"+j)){a=b;break a}if(g=l(g+"/"+j)){a=g;break a}}a=(b=d(j))?b:void 0}if(a)return a;throw Error("Cannot find module '"+j+"'");};c.alias=function(j,f){var d=c.modules.path(),l=null;try{l=c.resolve(j+"/package.json","/")}catch(h){l=c.resolve(j,"/")}for(var d=d.dirname(l),l=(Object.keys||function(a){var b=[],e;for(e in a)b.push(e);return b})(c.modules),
+a=0;a<l.length;a++){var e=l[a];e.slice(0,d.length+1)===d+"/"?(e=e.slice(d.length),c.modules[f+e]=c.modules[d+e]):e===d&&(c.modules[f]=c.modules[d])}};var u={};c.define=function(j,f){c.modules.__browserify_process&&(u=c.modules.__browserify_process());var d=c._core[j]?"":c.modules.path().dirname(j),l=function(a){var e=c(a,d);if((a=c.cache[c.resolve(a,d)])&&null===a.parent)a.parent=h;return e};l.resolve=function(a){return c.resolve(a,d)};l.modules=c.modules;l.define=c.define;l.cache=c.cache;var h={id:j,
+filename:j,exports:{},loaded:!1,parent:null};c.modules[j]=function(){c.cache[j]=h;f.call(h.exports,l,h,h.exports,d,j,u);h.loaded=!0;return h.exports}};c.define("path",function(c,f,d,l,h,a){function e(a,b){for(var e=[],g=0;g<a.length;g++)b(a[g],g,a)&&e.push(a[g]);return e}function g(a,b){for(var e=0,g=a.length;0<=g;g--){var d=a[g];"."==d?a.splice(g,1):".."===d?(a.splice(g,1),e++):e&&(a.splice(g,1),e--)}if(b)for(;e--;e)a.unshift("..");return a}var b=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;d.resolve=
+function(){for(var b="",o=!1,d=arguments.length;-1<=d&&!o;d--){var c=0<=d?arguments[d]:a.cwd();"string"===typeof c&&c&&(b=c+"/"+b,o="/"===c.charAt(0))}b=g(e(b.split("/"),function(a){return!!a}),!o).join("/");return(o?"/":"")+b||"."};d.normalize=function(a){var b="/"===a.charAt(0),d="/"===a.slice(-1),a=g(e(a.split("/"),function(a){return!!a}),!b).join("/");!a&&!b&&(a=".");a&&d&&(a+="/");return(b?"/":"")+a};d.join=function(){var a=Array.prototype.slice.call(arguments,0);return d.normalize(e(a,function(a){return a&&
+"string"===typeof a}).join("/"))};d.dirname=function(a){return(a=b.exec(a)[1]||"")?1===a.length?a:a.substring(0,a.length-1):"."};d.basename=function(a,e){var g=b.exec(a)[2]||"";e&&g.substr(-1*e.length)===e&&(g=g.substr(0,g.length-e.length));return g};d.extname=function(a){return b.exec(a)[3]||""}});c.define("__browserify_process",function(c,f,d,l,h,a){var f=a=f.exports={},e=[],g="undefined"!==typeof window&&window.postMessage&&window.addEventListener;g&&window.addEventListener("message",function(a){a.source===
+window&&"browserify-tick"===a.data&&(a.stopPropagation(),0<e.length&&e.shift()())},!0);f.nextTick=function(a){g?(e.push(a),window.postMessage("browserify-tick","*")):setTimeout(a,0)};a.title="browser";a.browser=!0;a.env={};a.argv=[];a.binding=function(a){if("evals"===a)return c("vm");throw Error("No such module. (Possibly not yet loaded)");};var b="/",t;a.cwd=function(){return b};a.chdir=function(a){t||(t=c("path"));b=t.resolve(a,b)}});c.define("vm",function(c,f){f.exports=c("vm-browserify")});c.define("/node_modules/vm-browserify/package.json",
+function(c,f){f.exports={main:"index.js"}});c.define("/node_modules/vm-browserify/index.js",function(c,f,d){var l=function(a){if(Object.keys)return Object.keys(a);var g=[],b;for(b in a)g.push(b);return g},h=function(a,g){if(a.forEach)return a.forEach(g);for(var b=0;b<a.length;b++)g(a[b],b,a)},a=d.Script=function(e){if(!(this instanceof a))return new a(e);this.code=e};a.prototype.runInNewContext=function(a){a||(a={});var g=document.createElement("iframe");g.style||(g.style={});g.style.display="none";
+document.body.appendChild(g);var b=g.contentWindow;h(l(a),function(g){b[g]=a[g]});!b.eval&&b.execScript&&b.execScript("null");var d=b.eval(this.code);h(l(b),function(g){a[g]=b[g]});document.body.removeChild(g);return d};a.prototype.runInThisContext=function(){return eval(this.code)};a.prototype.runInContext=function(a){return this.runInNewContext(a)};h(l(a.prototype),function(e){d[e]=a[e]=function(g){var b=a(g);return b[e].apply(b,[].slice.call(arguments,1))}});d.createScript=function(a){return d.Script(a)};
+d.createContext=a.createContext=function(a){var g={};"object"===typeof a&&h(l(a),function(b){g[b]=a[b]});return g}});c.define("/package.json",function(c,f){f.exports={main:"./index"}});c.define("js-select",function(c,f){function d(a){a=e._parse(a||"*")[1];return","==a[0]?a.slice(1):[a]}function l(a,e){for(var g=0;g<a.length;g++){var d;a:{d=a[g];for(var c=e,l=c.parents.concat([c]),j=l.length-1,f=d.length-1,r=!0;0<=f&&0<=j;){var q=d[f],c=l[j];if(">"==q)f--,r=!0;else{if(h(q,c))f--;else if(r){d=!1;break a}j--;
+r=!1}}d=-1==f}if(d)return!0}return!1}function h(b,e){var d=e.key,c=e.node,h=e.parent;if(b.id&&d!=b.id)return!1;if(b.type){var f=b.type;if("null"==f&&null!==c||"array"==f&&!g(c)||"object"==f&&("object"!=typeof c||null===c||g(c))||("boolean"==f||"string"==f||"number"==f)&&f!=typeof c)return!1}if(":nth-child"==b.pf&&(f=parseInt(d)+1,0==b.a&&f!==b.b||1==b.a&&!(f>=-b.b)||-1==b.a&&!(f<=b.b)||2==b.a&&f%2!=b.b)||":nth-last-child"==b.pf&&(!h||d!=h.node.length-b.b)||":only-child"==b.pc&&(!h||1!=h.node.length)||
+":root"==b.pc&&void 0!==d)return!1;if(b.has){var j=","==b.has[0][0]?b.has[0].slice(1):[b.has[0]],p=!1;a(c).forEach(function(){l(j,this)&&(p=!0)});if(!p)return!1}return b.expr&&(f=b.expr,d=f[0],h=f[1],f=f[2],"string"!=typeof c||!d&&"="==h&&c!=f||!d&&"*="==h&&-1==c.indexOf(f))?!1:!0}var a=c("traverse"),e=c("JSONSelect");f.exports=function(b,e){var g=d(e);return{nodes:function(){var a=[];this.forEach(function(b){a.push(b)});return a},update:function(a){this.forEach(function(b){this.update("function"==
+typeof a?a(b):a)})},remove:function(){this.forEach(function(){this.remove()})},condense:function(){a(b).forEach(function(){if(this.parent)if(this.parent.keep)this.keep=!0;else{var a=l(g,this);(this.keep=a)?this.parent.keep_child=!0:this.isLeaf?this.remove():this.after(function(){this.keep_child&&(this.parent.keep_child=!0);!this.keep&&!this.keep_child&&this.remove()})}})},forEach:function(e){a(b).forEach(function(a){l(g,this)&&(this.matches=function(a){return l(d(a),this)},e.call(this,a))})}}};var g=
+Array.isArray||function(a){return"[object Array]"===toString.call(a)}});c.define("/node_modules/traverse/package.json",function(c,f){f.exports={main:"./index"}});c.define("/node_modules/traverse/index.js",function(c,f){function d(a){if(!(this instanceof d))return new d(a);this.value=a}function l(a,e,g){var b=[],d=[],c=!0;return function x(a){var f=g?h(a):a,l,j,q,v,n=!0,i={node:f,node_:a,path:[].concat(b),parent:d[d.length-1],parents:d,key:b.slice(-1)[0],isRoot:0===b.length,level:b.length,circular:null,
+update:function(a,b){i.isRoot||(i.parent.node[i.key]=a);i.node=a;b&&(n=!1)},"delete":function(){delete i.parent.node[i.key]},remove:function(){Array.isArray(i.parent.node)?i.parent.node.splice(i.key,1):delete i.parent.node[i.key]},keys:null,before:function(a){l=a},after:function(a){j=a},pre:function(a){q=a},post:function(a){v=a},stop:function(){c=!1},block:function(){n=!1}};if(!c)return i;if("object"===typeof f&&null!==f){i.keys=Object.keys(f);i.isLeaf=0==i.keys.length;for(f=0;f<d.length;f++)if(d[f].node_===
+a){i.circular=d[f];break}}else i.isLeaf=!0;i.notLeaf=!i.isLeaf;i.notRoot=!i.isRoot;a=e.call(i,i.node);void 0!==a&&i.update&&i.update(a);l&&l.call(i,i.node);if(!n)return i;"object"==typeof i.node&&(null!==i.node&&!i.circular)&&(d.push(i),i.keys.forEach(function(a,e){b.push(a);q&&q.call(i,i.node[a],a);var d=x(i.node[a]);g&&Object.hasOwnProperty.call(i.node,a)&&(i.node[a]=d.node);d.isLast=e==i.keys.length-1;d.isFirst=0==e;v&&v.call(i,d);b.pop()}),d.pop());j&&j.call(i,i.node);return i}(a).node}function h(a){if("object"===
+typeof a&&null!==a){var e;e=Array.isArray(a)?[]:a instanceof Date?new Date(a):a instanceof Boolean?new Boolean(a):a instanceof Number?new Number(a):a instanceof String?new String(a):Object.create(Object.getPrototypeOf(a));Object.keys(a).forEach(function(d){e[d]=a[d]});return e}return a}f.exports=d;d.prototype.get=function(a){for(var e=this.value,d=0;d<a.length;d++){var b=a[d];if(!Object.hasOwnProperty.call(e,b)){e=void 0;break}e=e[b]}return e};d.prototype.set=function(a,e){for(var d=this.value,b=
+0;b<a.length-1;b++){var c=a[b];Object.hasOwnProperty.call(d,c)||(d[c]={});d=d[c]}return d[a[b]]=e};d.prototype.map=function(a){return l(this.value,a,!0)};d.prototype.forEach=function(a){return this.value=l(this.value,a,!1)};d.prototype.reduce=function(a,d){var c=1===arguments.length,b=c?this.value:d;this.forEach(function(d){if(!this.isRoot||!c)b=a.call(this,b,d)});return b};d.prototype.deepEqual=function(a){if(1!==arguments.length)throw Error("deepEqual requires exactly one object to compare against");
+var e=!0,c=a;this.forEach(function(b){var f=function(){e=!1}.bind(this);if(!this.isRoot){if("object"!==typeof c)return f();c=c[this.key]}var h=c;this.post(function(){c=h});if(this.circular)d(a).get(this.circular.path)!==h&&f();else if(typeof h!==typeof b)f();else if(null===h||null===b||void 0===h||void 0===b)h!==b&&f();else if(h.__proto__!==b.__proto__)f();else if(h!==b)if("function"===typeof h)h instanceof RegExp?h.toString()!=b.toString()&&f():h!==b&&f();else if("object"===typeof h)if("[object Arguments]"===
+Object.prototype.toString.call(b)||"[object Arguments]"===Object.prototype.toString.call(h))Object.prototype.toString.call(h)!==Object.prototype.toString.call(b)&&f();else if(h instanceof Date||b instanceof Date)(!(h instanceof Date)||!(b instanceof Date)||h.getTime()!==b.getTime())&&f();else{var l=Object.keys(h),j=Object.keys(b);if(l.length!==j.length)return f();for(j=0;j<l.length;j++)Object.hasOwnProperty.call(b,l[j])||f()}});return e};d.prototype.paths=function(){var a=[];this.forEach(function(){a.push(this.path)});
+return a};d.prototype.nodes=function(){var a=[];this.forEach(function(){a.push(this.node)});return a};d.prototype.clone=function(){var a=[],d=[];return function b(c){for(var f=0;f<a.length;f++)if(a[f]===c)return d[f];if("object"===typeof c&&null!==c){var j=h(c);a.push(c);d.push(j);Object.keys(c).forEach(function(a){j[a]=b(c[a])});a.pop();d.pop();return j}return c}(this.value)};Object.keys(d.prototype).forEach(function(a){d[a]=function(c){var f=[].slice.call(arguments,1),b=d(c);return b[a].apply(b,
+f)}})});c.define("/node_modules/JSONSelect/package.json",function(c,f){f.exports={main:"src/jsonselect"}});c.define("/node_modules/JSONSelect/src/jsonselect.js",function(c,f,d){var c="undefined"===typeof d?window.JSONSelect={}:d,l=function(a){try{return JSON&&JSON.parse?JSON.parse(a):(new Function("return "+a))()}catch(b){h("ijs",b.message)}},h=function(a,b){throw Error(v[a]+(b&&" in '"+b+"'"));},a=function(a,b){b||(b=0);var d=i.exec(a.substr(b));if(d){var b=b+d[0].length,c;d[1]?c=[b," "]:d[2]?c=
+[b,d[0]]:d[3]?c=[b,n.typ,d[0]]:d[4]?c=[b,n.psc,d[0]]:d[5]?c=[b,n.psf,d[0]]:d[6]?h("upc",a):d[8]?c=[b,d[7]?n.ide:n.str,l(d[8])]:d[9]?h("ujs",a):d[10]&&(c=[b,n.ide,d[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")]);return c}},e=function(a,b){return typeof a===b},g=function(a,b){var d,c=B.exec(a.substr(b));if(c)return b+=c[0].length,d=c[1]||c[2]||c[3]||c[5]||c[6],c[1]||c[2]||c[3]?[b,0,l(d)]:c[4]?[b,0,void 0]:[b,d]},b=function(a,d){d||(d=0);var c=g(a,d),e;c&&"("===c[1]?(e=b(a,c[0]),c=g(a,e[0]),(!c||")"!==
+c[1])&&h("epex",a),d=c[0],e=["(",e[1]]):!c||c[1]&&"x"!=c[1]?h("ee",a+" - "+(c[1]&&c[1])):(e="x"===c[1]?void 0:c[2],d=c[0]);c=g(a,d);if(!c||")"==c[1])return[d,e];("x"==c[1]||!c[1])&&h("bop",a+" - "+(c[1]&&c[1]));var f=b(a,c[0]),d=f[0],f=f[1],l;if("object"!==typeof f||"("===f[0]||w[c[1]][0]<w[f[1]][0])l=[e,c[1],f];else{for(l=f;"object"===typeof f[0]&&"("!=f[0][0]&&w[c[1]][0]>=w[f[0][1]][0];)f=f[0];f[0]=[e,c[1],f[0]]}return[d,l]},t=function(a,c){function d(a){return"object"!==typeof a||null===a?a:"("===
+a[0]?d(a[1]):[d(a[0]),a[1],d(a[2])]}var e=b(a,c?c:0);return[e[0],d(e[1])]},o=function(a,c){if(void 0===a)return c;if(null===a||"object"!==typeof a)return a;var b=o(a[0],c),d=o(a[2],c);return w[a[1]][1](b,d)},y=function(c,b,d,e){d||(e={});var f=[],g,l;for(b||(b=0);;){var m;m=c;var i=b,b=i,j={},k=a(m,i);k&&" "===k[1]&&(b=i=k[0],k=a(m,i));k&&k[1]===n.typ?(j.type=k[2],k=a(m,i=k[0])):k&&"*"===k[1]&&(k=a(m,i=k[0]));for(;void 0!==k;){if(k[1]===n.ide)j.id&&h("nmi",k[1]),j.id=k[2];else if(k[1]===n.psc)(j.pc||
+j.pf)&&h("mpc",k[1]),":first-child"===k[2]?(j.pf=":nth-child",j.a=0,j.b=1):":last-child"===k[2]?(j.pf=":nth-last-child",j.a=0,j.b=1):j.pc=k[2];else if(k[1]===n.psf)":val"===k[2]||":contains"===k[2]?(j.expr=[void 0,":val"===k[2]?"=":"*=",void 0],(k=a(m,k[0]))&&" "===k[1]&&(k=a(m,k[0])),(!k||"("!==k[1])&&h("pex",m),(k=a(m,k[0]))&&" "===k[1]&&(k=a(m,k[0])),(!k||k[1]!==n.str)&&h("sex",m),j.expr[2]=k[2],(k=a(m,k[0]))&&" "===k[1]&&(k=a(m,k[0])),(!k||")"!==k[1])&&h("epex",m)):":has"===k[2]?((k=a(m,k[0]))&&
+" "===k[1]&&(k=a(m,k[0])),(!k||"("!==k[1])&&h("pex",m),i=y(m,k[0],!0),k[0]=i[0],j.has||(j.has=[]),j.has.push(i[1])):":expr"===k[2]?(j.expr&&h("mexp",m),i=t(m,k[0]),k[0]=i[0],j.expr=i[1]):((j.pc||j.pf)&&h("mpc",m),j.pf=k[2],(i=A.exec(m.substr(k[0])))||h("mepf",m),i[5]?(j.a=2,j.b="odd"===i[5]?1:0):i[6]?(j.a=0,j.b=parseInt(i[6],10)):(j.a=parseInt((i[1]?i[1]:"+")+(i[2]?i[2]:"1"),10),j.b=i[3]?parseInt(i[3]+i[4],10):0),k[0]+=i[0].length);else break;k=a(m,i=k[0])}b===i&&h("se",m);m=[i,j];f.push(m[1]);(m=
+a(c,b=m[0]))&&" "===m[1]&&(m=a(c,b=m[0]));if(!m)break;if(">"===m[1]||"~"===m[1])"~"===m[1]&&(e.usesSiblingOp=!0),f.push(m[1]),b=m[0];else if(","===m[1])void 0===g?g=[",",f]:g.push(f),f=[],b=m[0];else if(")"===m[1]){d||h("ucp",m[1]);l=1;b=m[0];break}}d&&!l&&h("mcp",c);g&&g.push(f);var s;if(!d&&e.usesSiblingOp)if(c=g?g:f,","===c[0]){for(d=[","];s<c.length;s++)var o=x(o[s]),d=d.concat(","===o[0]?o.slice(1):o);s=d}else s=x(c);else s=g?g:f;return[b,s]},x=function(a){for(var c=[],b,d=0;d<a.length;d++)if("~"===
+a[d]){if(2>d||">"!=a[d-2])b=a.slice(0,d-1),b=b.concat([{has:[[{pc:":root"},">",a[d-1]]]},">"]),b=b.concat(a.slice(d+1)),c.push(b);if(1<d){var e=">"===a[d-2]?d-3:d-2;b=a.slice(0,e);var f={},g;for(g in a[e])a[e].hasOwnProperty(g)&&(f[g]=a[e][g]);f.has||(f.has=[]);f.has.push([{pc:":root"},">",a[d-1]]);b=b.concat(f,">",a.slice(d+1));c.push(b)}break}return d==a.length?a:1<c.length?[","].concat(c):c[0]},u=function(a){return Array.isArray?Array.isArray(a):"[object Array]"===q.call(a)},z=function(a,b,c,d,
+e){var f=[],g=">"===b[0]?b[1]:b[0],h=!0;if(g.type&&h){var h=g.type,i;null===a?i="null":(i=typeof a,"object"===i&&u(a)&&(i="array"));h=h===i}g.id&&(h=h&&g.id===c);h&&g.pf&&(":nth-last-child"===g.pf?d=e-d:d++,0===g.a?h=g.b===d:(c=(d-g.b)%g.a,h=!c&&0<=d*g.a+g.b));if(h&&g.has){d=function(){throw 42;};for(c=0;c<g.has.length;c++){try{p(g.has[c],a,d)}catch(j){if(42===j)continue}h=!1;break}}h&&g.expr&&(h=o(g.expr,a));">"!==b[0]&&":root"!==b[0].pc&&f.push(b);h&&(">"===b[0]?2<b.length&&(h=!1,f.push(b.slice(2))):
+1<b.length&&(h=!1,f.push(b.slice(1))));return[h,f]},p=function(a,b,c,d,e,f){for(var a=","===a[0]?a.slice(1):[a],g=[],h=!1,i=0,j=0,k,l,i=0;i<a.length;i++){l=z(b,a[i],d,e,f);l[0]&&(h=!0);for(j=0;j<l[1].length;j++)g.push(l[1][j])}if(g.length&&"object"===typeof b)if(1<=g.length&&g.unshift(","),u(b))for(i=0;i<b.length;i++)p(g,b[i],c,void 0,i,b.length);else for(k in b)b.hasOwnProperty(k)&&p(g,b[k],c,k);h&&c&&c(b)},r=function(a){return{sel:y(a)[1],match:function(a){var b=[];p(this.sel,a,function(a){b.push(a)});
+return b},forEach:function(a,b){return p(this.sel,a,b)}}},q=Object.prototype.toString,v={bop:"binary operator expected",ee:"expression expected",epex:"closing paren expected ')'",ijs:"invalid json string",mcp:"missing closing paren",mepf:"malformed expression in pseudo-function",mexp:"multiple expressions not allowed",mpc:"multiple pseudo classes (:xxx) not allowed",nmi:"multiple ids not allowed",pex:"opening paren expected '('",se:"selector expected",sex:"string expected",sra:"string required after '.'",
+uc:"unrecognized char",ucp:"unexpected closing paren",ujs:"unclosed json string",upc:"unrecognized pseudo class"},n={psc:1,psf:2,typ:3,str:4,ide:5},i=RegExp('^(?:([\\r\\n\\t\\ ]+)|([~*,>\\)\\(])|(string|boolean|null|array|object|number)|(:(?:root|first-child|last-child|only-child))|(:(?:nth-child|nth-last-child|has|expr|val|contains))|(:\\w+)|(?:(\\.)?(\\"(?:[^\\\\\\"]|\\\\[^\\"])*\\"))|(\\")|\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*))'),
+A=/^\s*\(\s*(?:([+\-]?)([0-9]*)n\s*(?:([+\-])\s*([0-9]))?|(odd|even)|([+\-]?[0-9]+))\s*\)/,B=RegExp('^\\s*(?:(true|false|null)|(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|("(?:[^\\]|\\[^"])*")|(x)|(&&|\\|\\||[\\$\\^<>!\\*]=|[=+\\-*/%<>])|([\\(\\)]))'),w={"*":[9,function(a,b){return a*b}],"/":[9,function(a,b){return a/b}],"%":[9,function(a,b){return a%b}],"+":[7,function(a,b){return a+b}],"-":[7,function(a,b){return a-b}],"<=":[5,function(a,b){return e(a,"number")&&e(b,"number")&&a<=b}],">=":[5,function(a,
+b){return e(a,"number")&&e(b,"number")&&a>=b}],"$=":[5,function(a,b){return e(a,"string")&&e(b,"string")&&a.lastIndexOf(b)===a.length-b.length}],"^=":[5,function(a,b){return e(a,"string")&&e(b,"string")&&0===a.indexOf(b)}],"*=":[5,function(a,b){return e(a,"string")&&e(b,"string")&&-1!==a.indexOf(b)}],">":[5,function(a,b){return e(a,"number")&&e(b,"number")&&a>b}],"<":[5,function(a,b){return e(a,"number")&&e(b,"number")&&a<b}],"=":[3,function(a,b){return a===b}],"!=":[3,function(a,b){return a!==b}],
+"&&":[2,function(a,b){return a&&b}],"||":[1,function(a,b){return a||b}]};c._lex=a;c._parse=y;c.match=function(a,b){return r(a).match(b)};c.forEach=function(a,b,c){return r(a).forEach(b,c)};c.compile=r});return c("js-select")}();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/select.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/select.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/select.js
new file mode 100644
index 0000000..2a5cb31
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/select.js
@@ -0,0 +1,1533 @@
+var select = (function() {
+ var require = function (file, cwd) {
+ var resolved = require.resolve(file, cwd || '/');
+ var mod = require.modules[resolved];
+ if (!mod) throw new Error(
+ 'Failed to resolve module ' + file + ', tried ' + resolved
+ );
+ var cached = require.cache[resolved];
+ var res = cached? cached.exports : mod();
+ return res;
+ };
+
+ require.paths = [];
+ require.modules = {};
+ require.cache = {};
+ require.extensions = [".js",".coffee"];
+
+ require._core = {
+ 'assert': true,
+ 'events': true,
+ 'fs': true,
+ 'path': true,
+ 'vm': true
+ };
+
+ require.resolve = (function () {
+ return function (x, cwd) {
+ if (!cwd) cwd = '/';
+
+ if (require._core[x]) return x;
+ var path = require.modules.path();
+ cwd = path.resolve('/', cwd);
+ var y = cwd || '/';
+
+ if (x.match(/^(?:\.\.?\/|\/)/)) {
+ var m = loadAsFileSync(path.resolve(y, x))
+ || loadAsDirectorySync(path.resolve(y, x));
+ if (m) return m;
+ }
+
+ var n = loadNodeModulesSync(x, y);
+ if (n) return n;
+
+ throw new Error("Cannot find module '" + x + "'");
+
+ function loadAsFileSync (x) {
+ x = path.normalize(x);
+ if (require.modules[x]) {
+ return x;
+ }
+
+ for (var i = 0; i < require.extensions.length; i++) {
+ var ext = require.extensions[i];
+ if (require.modules[x + ext]) return x + ext;
+ }
+ }
+
+ function loadAsDirectorySync (x) {
+ x = x.replace(/\/+$/, '');
+ var pkgfile = path.normalize(x + '/package.json');
+ if (require.modules[pkgfile]) {
+ var pkg = require.modules[pkgfile]();
+ var b = pkg.browserify;
+ if (typeof b === 'object' && b.main) {
+ var m = loadAsFileSync(path.resolve(x, b.main));
+ if (m) return m;
+ }
+ else if (typeof b === 'string') {
+ var m = loadAsFileSync(path.resolve(x, b));
+ if (m) return m;
+ }
+ else if (pkg.main) {
+ var m = loadAsFileSync(path.resolve(x, pkg.main));
+ if (m) return m;
+ }
+ }
+
+ return loadAsFileSync(x + '/index');
+ }
+
+ function loadNodeModulesSync (x, start) {
+ var dirs = nodeModulesPathsSync(start);
+ for (var i = 0; i < dirs.length; i++) {
+ var dir = dirs[i];
+ var m = loadAsFileSync(dir + '/' + x);
+ if (m) return m;
+ var n = loadAsDirectorySync(dir + '/' + x);
+ if (n) return n;
+ }
+
+ var m = loadAsFileSync(x);
+ if (m) return m;
+ }
+
+ function nodeModulesPathsSync (start) {
+ var parts;
+ if (start === '/') parts = [ '' ];
+ else parts = path.normalize(start).split('/');
+
+ var dirs = [];
+ for (var i = parts.length - 1; i >= 0; i--) {
+ if (parts[i] === 'node_modules') continue;
+ var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
+ dirs.push(dir);
+ }
+
+ return dirs;
+ }
+ };
+ })();
+
+ require.alias = function (from, to) {
+ var path = require.modules.path();
+ var res = null;
+ try {
+ res = require.resolve(from + '/package.json', '/');
+ }
+ catch (err) {
+ res = require.resolve(from, '/');
+ }
+ var basedir = path.dirname(res);
+
+ var keys = (Object.keys || function (obj) {
+ var res = [];
+ for (var key in obj) res.push(key);
+ return res;
+ })(require.modules);
+
+ for (var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ if (key.slice(0, basedir.length + 1) === basedir + '/') {
+ var f = key.slice(basedir.length);
+ require.modules[to + f] = require.modules[basedir + f];
+ }
+ else if (key === basedir) {
+ require.modules[to] = require.modules[basedir];
+ }
+ }
+ };
+
+ (function () {
+ var process = {};
+
+ require.define = function (filename, fn) {
+ if (require.modules.__browserify_process) {
+ process = require.modules.__browserify_process();
+ }
+
+ var dirname = require._core[filename]
+ ? ''
+ : require.modules.path().dirname(filename)
+ ;
+
+ var require_ = function (file) {
+ var requiredModule = require(file, dirname);
+ var cached = require.cache[require.resolve(file, dirname)];
+
+ if (cached && cached.parent === null) {
+ cached.parent = module_;
+ }
+
+ return requiredModule;
+ };
+ require_.resolve = function (name) {
+ return require.resolve(name, dirname);
+ };
+ require_.modules = require.modules;
+ require_.define = require.define;
+ require_.cache = require.cache;
+ var module_ = {
+ id : filename,
+ filename: filename,
+ exports : {},
+ loaded : false,
+ parent: null
+ };
+
+ require.modules[filename] = function () {
+ require.cache[filename] = module_;
+ fn.call(
+ module_.exports,
+ require_,
+ module_,
+ module_.exports,
+ dirname,
+ filename,
+ process
+ );
+ module_.loaded = true;
+ return module_.exports;
+ };
+ };
+ })();
+
+
+ require.define("path",function(require,module,exports,__dirname,__filename,process){function filter (xs, fn) {
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ if (fn(xs[i], i, xs)) res.push(xs[i]);
+ }
+ return res;
+ }
+
+ // resolves . and .. elements in a path array with directory names there
+ // must be no slashes, empty elements, or device names (c:\) in the array
+ // (so also no leading and trailing slashes - it does not distinguish
+ // relative and absolute paths)
+ function normalizeArray(parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length; i >= 0; i--) {
+ var last = parts[i];
+ if (last == '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+
+ return parts;
+ }
+
+ // Regex to split a filename into [*, dir, basename, ext]
+ // posix version
+ var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
+
+ // path.resolve([from ...], to)
+ // posix version
+ exports.resolve = function() {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+
+ for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0)
+ ? arguments[i]
+ : process.cwd();
+
+ // Skip empty and invalid entries
+ if (typeof path !== 'string' || !path) {
+ continue;
+ }
+
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+
+ // Normalize the path
+ resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ };
+
+ // path.normalize(path)
+ // posix version
+ exports.normalize = function(path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.slice(-1) === '/';
+
+ // Normalize the path
+ path = normalizeArray(filter(path.split('/'), function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+
+ return (isAbsolute ? '/' : '') + path;
+ };
+
+
+ // posix version
+ exports.join = function() {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return exports.normalize(filter(paths, function(p, index) {
+ return p && typeof p === 'string';
+ }).join('/'));
+ };
+
+
+ exports.dirname = function(path) {
+ var dir = splitPathRe.exec(path)[1] || '';
+ var isWindows = false;
+ if (!dir) {
+ // No dirname
+ return '.';
+ } else if (dir.length === 1 ||
+ (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
+ // It is just a slash or a drive letter with a slash
+ return dir;
+ } else {
+ // It is a full dirname, strip trailing slash
+ return dir.substring(0, dir.length - 1);
+ }
+ };
+
+
+ exports.basename = function(path, ext) {
+ var f = splitPathRe.exec(path)[2] || '';
+ // TODO: make this comparison case-insensitive on windows?
+ if (ext && f.substr(-1 * ext.length) === ext) {
+ f = f.substr(0, f.length - ext.length);
+ }
+ return f;
+ };
+
+
+ exports.extname = function(path) {
+ return splitPathRe.exec(path)[3] || '';
+ };
+ });
+
+ require.define("__browserify_process",function(require,module,exports,__dirname,__filename,process){var process = module.exports = {};
+
+ process.nextTick = (function () {
+ var queue = [];
+ var canPost = typeof window !== 'undefined'
+ && window.postMessage && window.addEventListener
+ ;
+
+ if (canPost) {
+ window.addEventListener('message', function (ev) {
+ if (ev.source === window && ev.data === 'browserify-tick') {
+ ev.stopPropagation();
+ if (queue.length > 0) {
+ var fn = queue.shift();
+ fn();
+ }
+ }
+ }, true);
+ }
+
+ return function (fn) {
+ if (canPost) {
+ queue.push(fn);
+ window.postMessage('browserify-tick', '*');
+ }
+ else setTimeout(fn, 0);
+ };
+ })();
+
+ process.title = 'browser';
+ process.browser = true;
+ process.env = {};
+ process.argv = [];
+
+ process.binding = function (name) {
+ if (name === 'evals') return (require)('vm')
+ else throw new Error('No such module. (Possibly not yet loaded)')
+ };
+
+ (function () {
+ var cwd = '/';
+ var path;
+ process.cwd = function () { return cwd };
+ process.chdir = function (dir) {
+ if (!path) path = require('path');
+ cwd = path.resolve(dir, cwd);
+ };
+ })();
+ });
+
+ require.define("vm",function(require,module,exports,__dirname,__filename,process){module.exports = require("vm-browserify")});
+
+ require.define("/node_modules/vm-browserify/package.json",function(require,module,exports,__dirname,__filename,process){module.exports = {"main":"index.js"}});
+
+ require.define("/node_modules/vm-browserify/index.js",function(require,module,exports,__dirname,__filename,process){var Object_keys = function (obj) {
+ if (Object.keys) return Object.keys(obj)
+ else {
+ var res = [];
+ for (var key in obj) res.push(key)
+ return res;
+ }
+ };
+
+ var forEach = function (xs, fn) {
+ if (xs.forEach) return xs.forEach(fn)
+ else for (var i = 0; i < xs.length; i++) {
+ fn(xs[i], i, xs);
+ }
+ };
+
+ var Script = exports.Script = function NodeScript (code) {
+ if (!(this instanceof Script)) return new Script(code);
+ this.code = code;
+ };
+
+ Script.prototype.runInNewContext = function (context) {
+ if (!context) context = {};
+
+ var iframe = document.createElement('iframe');
+ if (!iframe.style) iframe.style = {};
+ iframe.style.display = 'none';
+
+ document.body.appendChild(iframe);
+
+ var win = iframe.contentWindow;
+
+ forEach(Object_keys(context), function (key) {
+ win[key] = context[key];
+ });
+
+ if (!win.eval && win.execScript) {
+ // win.eval() magically appears when this is called in IE:
+ win.execScript('null');
+ }
+
+ var res = win.eval(this.code);
+
+ forEach(Object_keys(win), function (key) {
+ context[key] = win[key];
+ });
+
+ document.body.removeChild(iframe);
+
+ return res;
+ };
+
+ Script.prototype.runInThisContext = function () {
+ return eval(this.code); // maybe...
+ };
+
+ Script.prototype.runInContext = function (context) {
+ // seems to be just runInNewContext on magical context objects which are
+ // otherwise indistinguishable from objects except plain old objects
+ // for the parameter segfaults node
+ return this.runInNewContext(context);
+ };
+
+ forEach(Object_keys(Script.prototype), function (name) {
+ exports[name] = Script[name] = function (code) {
+ var s = Script(code);
+ return s[name].apply(s, [].slice.call(arguments, 1));
+ };
+ });
+
+ exports.createScript = function (code) {
+ return exports.Script(code);
+ };
+
+ exports.createContext = Script.createContext = function (context) {
+ // not really sure what this one does
+ // seems to just make a shallow copy
+ var copy = {};
+ if(typeof context === 'object') {
+ forEach(Object_keys(context), function (key) {
+ copy[key] = context[key];
+ });
+ }
+ return copy;
+ };
+ });
+
+ require.define("/package.json",function(require,module,exports,__dirname,__filename,process){module.exports = {"main":"./index"}});
+
+ require.define("js-select",function(require,module,exports,__dirname,__filename,process){var traverse = require("traverse"),
+ JSONSelect = require("JSONSelect");
+
+ module.exports = function(obj, string) {
+ var sels = parseSelectors(string);
+
+ return {
+ nodes: function() {
+ var nodes = [];
+ this.forEach(function(node) {
+ nodes.push(node);
+ });
+ return nodes;
+ },
+
+ update: function(cb) {
+ this.forEach(function(node) {
+ this.update(typeof cb == "function" ? cb(node) : cb);
+ });
+ },
+
+ remove: function() {
+ this.forEach(function(node) {
+ this.remove();
+ })
+ },
+
+ condense: function() {
+ traverse(obj).forEach(function(node) {
+ if (!this.parent) return;
+
+ if (this.parent.keep) {
+ this.keep = true;
+ } else {
+ var match = matchesAny(sels, this);
+ this.keep = match;
+ if (!match) {
+ if (this.isLeaf) {
+ this.remove();
+ } else {
+ this.after(function() {
+ if (this.keep_child) {
+ this.parent.keep_child = true;
+ }
+ if (!this.keep && !this.keep_child) {
+ this.remove();
+ }
+ });
+ }
+ } else {
+ this.parent.keep_child = true;
+ }
+ }
+ });
+ },
+
+ forEach: function(cb) {
+ traverse(obj).forEach(function(node) {
+ if (matchesAny(sels, this)) {
+ this.matches = function(string) {
+ return matchesAny(parseSelectors(string), this);
+ };
+ // inherit context from js-traverse
+ cb.call(this, node);
+ }
+ });
+ }
+ };
+ }
+
+ function parseSelectors(string) {
+ var parsed = JSONSelect._parse(string || "*")[1];
+ return getSelectors(parsed);
+ }
+
+ function getSelectors(parsed) {
+ if (parsed[0] == ",") { // "selector1, selector2"
+ return parsed.slice(1);
+ }
+ return [parsed];
+ }
+
+ function matchesAny(sels, context) {
+ for (var i = 0; i < sels.length; i++) {
+ if (matches(sels[i], context)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function matches(sel, context) {
+ var path = context.parents.concat([context]),
+ i = path.length - 1,
+ j = sel.length - 1;
+
+ // walk up the ancestors
+ var must = true;
+ while(j >= 0 && i >= 0) {
+ var part = sel[j],
+ context = path[i];
+
+ if (part == ">") {
+ j--;
+ must = true;
+ continue;
+ }
+
+ if (matchesKey(part, context)) {
+ j--;
+ }
+ else if (must) {
+ return false;
+ }
+
+ i--;
+ must = false;
+ }
+ return j == -1;
+ }
+
+ function matchesKey(part, context) {
+ var key = context.key,
+ node = context.node,
+ parent = context.parent;
+
+ if (part.id && key != part.id) {
+ return false;
+ }
+ if (part.type) {
+ var type = part.type;
+
+ if (type == "null" && node !== null) {
+ return false;
+ }
+ else if (type == "array" && !isArray(node)) {
+ return false;
+ }
+ else if (type == "object" && (typeof node != "object"
+ || node === null || isArray(node))) {
+ return false;
+ }
+ else if ((type == "boolean" || type == "string" || type == "number")
+ && type != typeof node) {
+ return false;
+ }
+ }
+ if (part.pf == ":nth-child") {
+ var index = parseInt(key) + 1;
+ if ((part.a == 0 && index !== part.b) // :nth-child(i)
+ || (part.a == 1 && !(index >= -part.b)) // :nth-child(n)
+ || (part.a == -1 && !(index <= part.b)) // :nth-child(-n + 1)
+ || (part.a == 2 && index % 2 != part.b)) { // :nth-child(even)
+ return false;
+ }
+ }
+ if (part.pf == ":nth-last-child"
+ && (!parent || key != parent.node.length - part.b)) {
+ return false;
+ }
+ if (part.pc == ":only-child"
+ && (!parent || parent.node.length != 1)) {
+ return false;
+ }
+ if (part.pc == ":root" && key !== undefined) {
+ return false;
+ }
+ if (part.has) {
+ var sels = getSelectors(part.has[0]),
+ match = false;
+ traverse(node).forEach(function(child) {
+ if (matchesAny(sels, this)) {
+ match = true;
+ }
+ });
+ if (!match) {
+ return false;
+ }
+ }
+ if (part.expr) {
+ var expr = part.expr, lhs = expr[0], op = expr[1], rhs = expr[2];
+ if (typeof node != "string"
+ || (!lhs && op == "=" && node != rhs) // :val("str")
+ || (!lhs && op == "*=" && node.indexOf(rhs) == -1)) { // :contains("substr")
+ return false;
+ }
+ }
+ return true;
+ }
+
+ var isArray = Array.isArray || function(obj) {
+ return toString.call(obj) === '[object Array]';
+ }
+ });
+
+ require.define("/node_modules/traverse/package.json",function(require,module,exports,__dirname,__filename,process){module.exports = {"main":"./index"}});
+
+ require.define("/node_modules/traverse/index.js",function(require,module,exports,__dirname,__filename,process){module.exports = Traverse;
+ function Traverse (obj) {
+ if (!(this instanceof Traverse)) return new Traverse(obj);
+ this.value = obj;
+ }
+
+ Traverse.prototype.get = function (ps) {
+ var node = this.value;
+ for (var i = 0; i < ps.length; i ++) {
+ var key = ps[i];
+ if (!Object.hasOwnProperty.call(node, key)) {
+ node = undefined;
+ break;
+ }
+ node = node[key];
+ }
+ return node;
+ };
+
+ Traverse.prototype.set = function (ps, value) {
+ var node = this.value;
+ for (var i = 0; i < ps.length - 1; i ++) {
+ var key = ps[i];
+ if (!Object.hasOwnProperty.call(node, key)) node[key] = {};
+ node = node[key];
+ }
+ node[ps[i]] = value;
+ return value;
+ };
+
+ Traverse.prototype.map = function (cb) {
+ return walk(this.value, cb, true);
+ };
+
+ Traverse.prototype.forEach = function (cb) {
+ this.value = walk(this.value, cb, false);
+ return this.value;
+ };
+
+ Traverse.prototype.reduce = function (cb, init) {
+ var skip = arguments.length === 1;
+ var acc = skip ? this.value : init;
+ this.forEach(function (x) {
+ if (!this.isRoot || !skip) {
+ acc = cb.call(this, acc, x);
+ }
+ });
+ return acc;
+ };
+
+ Traverse.prototype.deepEqual = function (obj) {
+ if (arguments.length !== 1) {
+ throw new Error(
+ 'deepEqual requires exactly one object to compare against'
+ );
+ }
+
+ var equal = true;
+ var node = obj;
+
+ this.forEach(function (y) {
+ var notEqual = (function () {
+ equal = false;
+ //this.stop();
+ return undefined;
+ }).bind(this);
+
+ //if (node === undefined || node === null) return notEqual();
+
+ if (!this.isRoot) {
+ /*
+ if (!Object.hasOwnProperty.call(node, this.key)) {
+ return notEqual();
+ }
+ */
+ if (typeof node !== 'object') return notEqual();
+ node = node[this.key];
+ }
+
+ var x = node;
+
+ this.post(function () {
+ node = x;
+ });
+
+ var toS = function (o) {
+ return Object.prototype.toString.call(o);
+ };
+
+ if (this.circular) {
+ if (Traverse(obj).get(this.circular.path) !== x) notEqual();
+ }
+ else if (typeof x !== typeof y) {
+ notEqual();
+ }
+ else if (x === null || y === null || x === undefined || y === undefined) {
+ if (x !== y) notEqual();
+ }
+ else if (x.__proto__ !== y.__proto__) {
+ notEqual();
+ }
+ else if (x === y) {
+ // nop
+ }
+ else if (typeof x === 'function') {
+ if (x instanceof RegExp) {
+ // both regexps on account of the __proto__ check
+ if (x.toString() != y.toString()) notEqual();
+ }
+ else if (x !== y) notEqual();
+ }
+ else if (typeof x === 'object') {
+ if (toS(y) === '[object Arguments]'
+ || toS(x) === '[object Arguments]') {
+ if (toS(x) !== toS(y)) {
+ notEqual();
+ }
+ }
+ else if (x instanceof Date || y instanceof Date) {
+ if (!(x instanceof Date) || !(y instanceof Date)
+ || x.getTime() !== y.getTime()) {
+ notEqual();
+ }
+ }
+ else {
+ var kx = Object.keys(x);
+ var ky = Object.keys(y);
+ if (kx.length !== ky.length) return notEqual();
+ for (var i = 0; i < kx.length; i++) {
+ var k = kx[i];
+ if (!Object.hasOwnProperty.call(y, k)) {
+ notEqual();
+ }
+ }
+ }
+ }
+ });
+
+ return equal;
+ };
+
+ Traverse.prototype.paths = function () {
+ var acc = [];
+ this.forEach(function (x) {
+ acc.push(this.path);
+ });
+ return acc;
+ };
+
+ Traverse.prototype.nodes = function () {
+ var acc = [];
+ this.forEach(function (x) {
+ acc.push(this.node);
+ });
+ return acc;
+ };
+
+ Traverse.prototype.clone = function () {
+ var parents = [], nodes = [];
+
+ return (function clone (src) {
+ for (var i = 0; i < parents.length; i++) {
+ if (parents[i] === src) {
+ return nodes[i];
+ }
+ }
+
+ if (typeof src === 'object' && src !== null) {
+ var dst = copy(src);
+
+ parents.push(src);
+ nodes.push(dst);
+
+ Object.keys(src).forEach(function (key) {
+ dst[key] = clone(src[key]);
+ });
+
+ parents.pop();
+ nodes.pop();
+ return dst;
+ }
+ else {
+ return src;
+ }
+ })(this.value);
+ };
+
+ function walk (root, cb, immutable) {
+ var path = [];
+ var parents = [];
+ var alive = true;
+
+ return (function walker (node_) {
+ var node = immutable ? copy(node_) : node_;
+ var modifiers = {};
+
+ var keepGoing = true;
+
+ var state = {
+ node : node,
+ node_ : node_,
+ path : [].concat(path),
+ parent : parents[parents.length - 1],
+ parents : parents,
+ key : path.slice(-1)[0],
+ isRoot : path.length === 0,
+ level : path.length,
+ circular : null,
+ update : function (x, stopHere) {
+ if (!state.isRoot) {
+ state.parent.node[state.key] = x;
+ }
+ state.node = x;
+ if (stopHere) keepGoing = false;
+ },
+ 'delete' : function () {
+ delete state.parent.node[state.key];
+ },
+ remove : function () {
+ if (Array.isArray(state.parent.node)) {
+ state.parent.node.splice(state.key, 1);
+ }
+ else {
+ delete state.parent.node[state.key];
+ }
+ },
+ keys : null,
+ before : function (f) { modifiers.before = f },
+ after : function (f) { modifiers.after = f },
+ pre : function (f) { modifiers.pre = f },
+ post : function (f) { modifiers.post = f },
+ stop : function () { alive = false },
+ block : function () { keepGoing = false }
+ };
+
+ if (!alive) return state;
+
+ if (typeof node === 'object' && node !== null) {
+ state.keys = Object.keys(node);
+
+ state.isLeaf = state.keys.length == 0;
+
+ for (var i = 0; i < parents.length; i++) {
+ if (parents[i].node_ === node_) {
+ state.circular = parents[i];
+ break;
+ }
+ }
+ }
+ else {
+ state.isLeaf = true;
+ }
+
+ state.notLeaf = !state.isLeaf;
+ state.notRoot = !state.isRoot;
+
+ // use return values to update if defined
+ var ret = cb.call(state, state.node);
+ if (ret !== undefined && state.update) state.update(ret);
+
+ if (modifiers.before) modifiers.before.call(state, state.node);
+
+ if (!keepGoing) return state;
+
+ if (typeof state.node == 'object'
+ && state.node !== null && !state.circular) {
+ parents.push(state);
+
+ state.keys.forEach(function (key, i) {
+ path.push(key);
+
+ if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);
+
+ var child = walker(state.node[key]);
+ if (immutable && Object.hasOwnProperty.call(state.node, key)) {
+ state.node[key] = child.node;
+ }
+
+ child.isLast = i == state.keys.length - 1;
+ child.isFirst = i == 0;
+
+ if (modifiers.post) modifiers.post.call(state, child);
+
+ path.pop();
+ });
+ parents.pop();
+ }
+
+ if (modifiers.after) modifiers.after.call(state, state.node);
+
+ return state;
+ })(root).node;
+ }
+
+ Object.keys(Traverse.prototype).forEach(function (key) {
+ Traverse[key] = function (obj) {
+ var args = [].slice.call(arguments, 1);
+ var t = Traverse(obj);
+ return t[key].apply(t, args);
+ };
+ });
+
+ function copy (src) {
+ if (typeof src === 'object' && src !== null) {
+ var dst;
+
+ if (Array.isArray(src)) {
+ dst = [];
+ }
+ else if (src instanceof Date) {
+ dst = new Date(src);
+ }
+ else if (src instanceof Boolean) {
+ dst = new Boolean(src);
+ }
+ else if (src instanceof Number) {
+ dst = new Number(src);
+ }
+ else if (src instanceof String) {
+ dst = new String(src);
+ }
+ else {
+ dst = Object.create(Object.getPrototypeOf(src));
+ }
+
+ Object.keys(src).forEach(function (key) {
+ dst[key] = src[key];
+ });
+ return dst;
+ }
+ else return src;
+ }
+ });
+
+ require.define("/node_modules/JSONSelect/package.json",function(require,module,exports,__dirname,__filename,process){module.exports = {"main":"src/jsonselect"}});
+
+ require.define("/node_modules/JSONSelect/src/jsonselect.js",function(require,module,exports,__dirname,__filename,process){/*! Copyright (c) 2011, Lloyd Hilaiel, ISC License */
+ /*
+ * This is the JSONSelect reference implementation, in javascript.
+ */
+ (function(exports) {
+
+ var // localize references
+ toString = Object.prototype.toString;
+
+ function jsonParse(str) {
+ try {
+ if(JSON && JSON.parse){
+ return JSON.parse(str);
+ }
+ return (new Function("return " + str))();
+ } catch(e) {
+ te("ijs", e.message);
+ }
+ }
+
+ // emitted error codes.
+ var errorCodes = {
+ "bop": "binary operator expected",
+ "ee": "expression expected",
+ "epex": "closing paren expected ')'",
+ "ijs": "invalid json string",
+ "mcp": "missing closing paren",
+ "mepf": "malformed expression in pseudo-function",
+ "mexp": "multiple expressions not allowed",
+ "mpc": "multiple pseudo classes (:xxx) not allowed",
+ "nmi": "multiple ids not allowed",
+ "pex": "opening paren expected '('",
+ "se": "selector expected",
+ "sex": "string expected",
+ "sra": "string required after '.'",
+ "uc": "unrecognized char",
+ "ucp": "unexpected closing paren",
+ "ujs": "unclosed json string",
+ "upc": "unrecognized pseudo class"
+ };
+
+ // throw an error message
+ function te(ec, context) {
+ throw new Error(errorCodes[ec] + ( context && " in '" + context + "'"));
+ }
+
+ // THE LEXER
+ var toks = {
+ psc: 1, // pseudo class
+ psf: 2, // pseudo class function
+ typ: 3, // type
+ str: 4, // string
+ ide: 5 // identifiers (or "classes", stuff after a dot)
+ };
+
+ // The primary lexing regular expression in jsonselect
+ var pat = new RegExp(
+ "^(?:" +
+ // (1) whitespace
+ "([\\r\\n\\t\\ ]+)|" +
+ // (2) one-char ops
+ "([~*,>\\)\\(])|" +
+ // (3) types names
+ "(string|boolean|null|array|object|number)|" +
+ // (4) pseudo classes
+ "(:(?:root|first-child|last-child|only-child))|" +
+ // (5) pseudo functions
+ "(:(?:nth-child|nth-last-child|has|expr|val|contains))|" +
+ // (6) bogusly named pseudo something or others
+ "(:\\w+)|" +
+ // (7 & 8) identifiers and JSON strings
+ "(?:(\\.)?(\\\"(?:[^\\\\\\\"]|\\\\[^\\\"])*\\\"))|" +
+ // (8) bogus JSON strings missing a trailing quote
+ "(\\\")|" +
+ // (9) identifiers (unquoted)
+ "\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*)" +
+ ")"
+ );
+
+ // A regular expression for matching "nth expressions" (see grammar, what :nth-child() eats)
+ var nthPat = /^\s*\(\s*(?:([+\-]?)([0-9]*)n\s*(?:([+\-])\s*([0-9]))?|(odd|even)|([+\-]?[0-9]+))\s*\)/;
+ function lex(str, off) {
+ if (!off) off = 0;
+ var m = pat.exec(str.substr(off));
+ if (!m) return undefined;
+ off+=m[0].length;
+ var a;
+ if (m[1]) a = [off, " "];
+ else if (m[2]) a = [off, m[0]];
+ else if (m[3]) a = [off, toks.typ, m[0]];
+ else if (m[4]) a = [off, toks.psc, m[0]];
+ else if (m[5]) a = [off, toks.psf, m[0]];
+ else if (m[6]) te("upc", str);
+ else if (m[8]) a = [off, m[7] ? toks.ide : toks.str, jsonParse(m[8])];
+ else if (m[9]) te("ujs", str);
+ else if (m[10]) a = [off, toks.ide, m[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")];
+ return a;
+ }
+
+ // THE EXPRESSION SUBSYSTEM
+
+ var exprPat = new RegExp(
+ // skip and don't capture leading whitespace
+ "^\\s*(?:" +
+ // (1) simple vals
+ "(true|false|null)|" +
+ // (2) numbers
+ "(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|" +
+ // (3) strings
+ "(\"(?:[^\\]|\\[^\"])*\")|" +
+ // (4) the 'x' value placeholder
+ "(x)|" +
+ // (5) binops
+ "(&&|\\|\\||[\\$\\^<>!\\*]=|[=+\\-*/%<>])|" +
+ // (6) parens
+ "([\\(\\)])" +
+ ")"
+ );
+
+ function is(o, t) { return typeof o === t; }
+ var operators = {
+ '*': [ 9, function(lhs, rhs) { return lhs * rhs; } ],
+ '/': [ 9, function(lhs, rhs) { return lhs / rhs; } ],
+ '%': [ 9, function(lhs, rhs) { return lhs % rhs; } ],
+ '+': [ 7, function(lhs, rhs) { return lhs + rhs; } ],
+ '-': [ 7, function(lhs, rhs) { return lhs - rhs; } ],
+ '<=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs <= rhs; } ],
+ '>=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs >= rhs; } ],
+ '$=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.lastIndexOf(rhs) === lhs.length - rhs.length; } ],
+ '^=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) === 0; } ],
+ '*=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) !== -1; } ],
+ '>': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs > rhs; } ],
+ '<': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs < rhs; } ],
+ '=': [ 3, function(lhs, rhs) { return lhs === rhs; } ],
+ '!=': [ 3, function(lhs, rhs) { return lhs !== rhs; } ],
+ '&&': [ 2, function(lhs, rhs) { return lhs && rhs; } ],
+ '||': [ 1, function(lhs, rhs) { return lhs || rhs; } ]
+ };
+
+ function exprLex(str, off) {
+ var v, m = exprPat.exec(str.substr(off));
+ if (m) {
+ off += m[0].length;
+ v = m[1] || m[2] || m[3] || m[5] || m[6];
+ if (m[1] || m[2] || m[3]) return [off, 0, jsonParse(v)];
+ else if (m[4]) return [off, 0, undefined];
+ return [off, v];
+ }
+ }
+
+ function exprParse2(str, off) {
+ if (!off) off = 0;
+ // first we expect a value or a '('
+ var l = exprLex(str, off),
+ lhs;
+ if (l && l[1] === '(') {
+ lhs = exprParse2(str, l[0]);
+ var p = exprLex(str, lhs[0]);
+ if (!p || p[1] !== ')') te('epex', str);
+ off = p[0];
+ lhs = [ '(', lhs[1] ];
+ } else if (!l || (l[1] && l[1] != 'x')) {
+ te("ee", str + " - " + ( l[1] && l[1] ));
+ } else {
+ lhs = ((l[1] === 'x') ? undefined : l[2]);
+ off = l[0];
+ }
+
+ // now we expect a binary operator or a ')'
+ var op = exprLex(str, off);
+ if (!op || op[1] == ')') return [off, lhs];
+ else if (op[1] == 'x' || !op[1]) {
+ te('bop', str + " - " + ( op[1] && op[1] ));
+ }
+
+ // tail recursion to fetch the rhs expression
+ var rhs = exprParse2(str, op[0]);
+ off = rhs[0];
+ rhs = rhs[1];
+
+ // and now precedence! how shall we put everything together?
+ var v;
+ if (typeof rhs !== 'object' || rhs[0] === '(' || operators[op[1]][0] < operators[rhs[1]][0] ) {
+ v = [lhs, op[1], rhs];
+ }
+ else {
+ v = rhs;
+ while (typeof rhs[0] === 'object' && rhs[0][0] != '(' && operators[op[1]][0] >= operators[rhs[0][1]][0]) {
+ rhs = rhs[0];
+ }
+ rhs[0] = [lhs, op[1], rhs[0]];
+ }
+ return [off, v];
+ }
+
+ function exprParse(str, off) {
+ function deparen(v) {
+ if (typeof v !== 'object' || v === null) return v;
+ else if (v[0] === '(') return deparen(v[1]);
+ else return [deparen(v[0]), v[1], deparen(v[2])];
+ }
+ var e = exprParse2(str, off ? off : 0);
+ return [e[0], deparen(e[1])];
+ }
+
+ function exprEval(expr, x) {
+ if (expr === undefined) return x;
+ else if (expr === null || typeof expr !== 'object') {
+ return expr;
+ }
+ var lhs = exprEval(expr[0], x),
+ rhs = exprEval(expr[2], x);
+ return operators[expr[1]][1](lhs, rhs);
+ }
+
+ // THE PARSER
+
+ function parse(str, off, nested, hints) {
+ if (!nested) hints = {};
+
+ var a = [], am, readParen;
+ if (!off) off = 0;
+
+ while (true) {
+ var s = parse_selector(str, off, hints);
+ a.push(s[1]);
+ s = lex(str, off = s[0]);
+ if (s && s[1] === " ") s = lex(str, off = s[0]);
+ if (!s) break;
+ // now we've parsed a selector, and have something else...
+ if (s[1] === ">" || s[1] === "~") {
+ if (s[1] === "~") hints.usesSiblingOp = true;
+ a.push(s[1]);
+ off = s[0];
+ } else if (s[1] === ",") {
+ if (am === undefined) am = [ ",", a ];
+ else am.push(a);
+ a = [];
+ off = s[0];
+ } else if (s[1] === ")") {
+ if (!nested) te("ucp", s[1]);
+ readParen = 1;
+ off = s[0];
+ break;
+ }
+ }
+ if (nested && !readParen) te("mcp", str);
+ if (am) am.push(a);
+ var rv;
+ if (!nested && hints.usesSiblingOp) {
+ rv = normalize(am ? am : a);
+ } else {
+ rv = am ? am : a;
+ }
+ return [off, rv];
+ }
+
+ function normalizeOne(sel) {
+ var sels = [], s;
+ for (var i = 0; i < sel.length; i++) {
+ if (sel[i] === '~') {
+ // `A ~ B` maps to `:has(:root > A) > B`
+ // `Z A ~ B` maps to `Z :has(:root > A) > B, Z:has(:root > A) > B`
+ // This first clause, takes care of the first case, and the first half of the latter case.
+ if (i < 2 || sel[i-2] != '>') {
+ s = sel.slice(0,i-1);
+ s = s.concat([{has:[[{pc: ":root"}, ">", sel[i-1]]]}, ">"]);
+ s = s.concat(sel.slice(i+1));
+ sels.push(s);
+ }
+ // here we take care of the second half of above:
+ // (`Z A ~ B` maps to `Z :has(:root > A) > B, Z :has(:root > A) > B`)
+ // and a new case:
+ // Z > A ~ B maps to Z:has(:root > A) > B
+ if (i > 1) {
+ var at = sel[i-2] === '>' ? i-3 : i-2;
+ s = sel.slice(0,at);
+ var z = {};
+ for (var k in sel[at]) if (sel[at].hasOwnProperty(k)) z[k] = sel[at][k];
+ if (!z.has) z.has = [];
+ z.has.push([{pc: ":root"}, ">", sel[i-1]]);
+ s = s.concat(z, '>', sel.slice(i+1));
+ sels.push(s);
+ }
+ break;
+ }
+ }
+ if (i == sel.length) return sel;
+ return sels.length > 1 ? [','].concat(sels) : sels[0];
+ }
+
+ function normalize(sels) {
+ if (sels[0] === ',') {
+ var r = [","];
+ for (var i = i; i < sels.length; i++) {
+ var s = normalizeOne(s[i]);
+ r = r.concat(s[0] === "," ? s.slice(1) : s);
+ }
+ return r;
+ } else {
+ return normalizeOne(sels);
+ }
+ }
+
+ function parse_selector(str, off, hints) {
+ var soff = off;
+ var s = { };
+ var l = lex(str, off);
+ // skip space
+ if (l && l[1] === " ") { soff = off = l[0]; l = lex(str, off); }
+ if (l && l[1] === toks.typ) {
+ s.type = l[2];
+ l = lex(str, (off = l[0]));
+ } else if (l && l[1] === "*") {
+ // don't bother representing the universal sel, '*' in the
+ // parse tree, cause it's the default
+ l = lex(str, (off = l[0]));
+ }
+
+ // now support either an id or a pc
+ while (true) {
+ if (l === undefined) {
+ break;
+ } else if (l[1] === toks.ide) {
+ if (s.id) te("nmi", l[1]);
+ s.id = l[2];
+ } else if (l[1] === toks.psc) {
+ if (s.pc || s.pf) te("mpc", l[1]);
+ // collapse first-child and last-child into nth-child expressions
+ if (l[2] === ":first-child") {
+ s.pf = ":nth-child";
+ s.a = 0;
+ s.b = 1;
+ } else if (l[2] === ":last-child") {
+ s.pf = ":nth-last-child";
+ s.a = 0;
+ s.b = 1;
+ } else {
+ s.pc = l[2];
+ }
+ } else if (l[1] === toks.psf) {
+ if (l[2] === ":val" || l[2] === ":contains") {
+ s.expr = [ undefined, l[2] === ":val" ? "=" : "*=", undefined];
+ // any amount of whitespace, followed by paren, string, paren
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== "(") te("pex", str);
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== toks.str) te("sex", str);
+ s.expr[2] = l[2];
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== ")") te("epex", str);
+ } else if (l[2] === ":has") {
+ // any amount of whitespace, followed by paren
+ l = lex(str, (off = l[0]));
+ if (l && l[1] === " ") l = lex(str, off = l[0]);
+ if (!l || l[1] !== "(") te("pex", str);
+ var h = parse(str, l[0], true);
+ l[0] = h[0];
+ if (!s.has) s.has = [];
+ s.has.push(h[1]);
+ } else if (l[2] === ":expr") {
+ if (s.expr) te("mexp", str);
+ var e = exprParse(str, l[0]);
+ l[0] = e[0];
+ s.expr = e[1];
+ } else {
+ if (s.pc || s.pf ) te("mpc", str);
+ s.pf = l[2];
+ var m = nthPat.exec(str.substr(l[0]));
+ if (!m) te("mepf", str);
+ if (m[5]) {
+ s.a = 2;
+ s.b = (m[5] === "odd") ? 1 : 0;
+ } else if (m[6]) {
+ s.a = 0;
+ s.b = parseInt(m[6], 10);
+ } else {
+ s.a = parseInt((m[1] ? m[1] : "+") + (m[2] ? m[2] : "1"),10);
+ s.b = m[3] ? parseInt(m[3] + m[4],10) : 0;
+ }
+ l[0] += m[0].length;
+ }
+ } else {
+ break;
+ }
+ l = lex(str, (off = l[0]));
+ }
+
+ // now if we didn't actually parse anything it's an error
+ if (soff === off) te("se", str);
+
+ return [off, s];
+ }
+
+ // THE EVALUATOR
+
+ function isArray(o) {
+ return Array.isArray ? Array.isArray(o) :
+ toString.call(o) === "[object Array]";
+ }
+
+ function mytypeof(o) {
+ if (o === null) return "null";
+ var to = typeof o;
+ if (to === "object" && isArray(o)) to = "array";
+ return to;
+ }
+
+ function mn(node, sel, id, num, tot) {
+ var sels = [];
+ var cs = (sel[0] === ">") ? sel[1] : sel[0];
+ var m = true, mod;
+ if (cs.type) m = m && (cs.type === mytypeof(node));
+ if (cs.id) m = m && (cs.id === id);
+ if (m && cs.pf) {
+ if (cs.pf === ":nth-last-child") num = tot - num;
+ else num++;
+ if (cs.a === 0) {
+ m = cs.b === num;
+ } else {
+ mod = ((num - cs.b) % cs.a);
+
+ m = (!mod && ((num*cs.a + cs.b) >= 0));
+ }
+ }
+ if (m && cs.has) {
+ // perhaps we should augment forEach to handle a return value
+ // that indicates "client cancels traversal"?
+ var bail = function() { throw 42; };
+ for (var i = 0; i < cs.has.length; i++) {
+ try {
+ forEach(cs.has[i], node, bail);
+ } catch (e) {
+ if (e === 42) continue;
+ }
+ m = false;
+ break;
+ }
+ }
+ if (m && cs.expr) {
+ m = exprEval(cs.expr, node);
+ }
+ // should we repeat this selector for descendants?
+ if (sel[0] !== ">" && sel[0].pc !== ":root") sels.push(sel);
+
+ if (m) {
+ // is there a fragment that we should pass down?
+ if (sel[0] === ">") { if (sel.length > 2) { m = false; sels.push(sel.slice(2)); } }
+ else if (sel.length > 1) { m = false; sels.push(sel.slice(1)); }
+ }
+
+ return [m, sels];
+ }
+
+ function forEach(sel, obj, fun, id, num, tot) {
+ var a = (sel[0] === ",") ? sel.slice(1) : [sel],
+ a0 = [],
+ call = false,
+ i = 0, j = 0, k, x;
+ for (i = 0; i < a.length; i++) {
+ x = mn(obj, a[i], id, num, tot);
+ if (x[0]) {
+ call = true;
+ }
+ for (j = 0; j < x[1].length; j++) {
+ a0.push(x[1][j]);
+ }
+ }
+ if (a0.length && typeof obj === "object") {
+ if (a0.length >= 1) {
+ a0.unshift(",");
+ }
+ if (isArray(obj)) {
+ for (i = 0; i < obj.length; i++) {
+ forEach(a0, obj[i], fun, undefined, i, obj.length);
+ }
+ } else {
+ for (k in obj) {
+ if (obj.hasOwnProperty(k)) {
+ forEach(a0, obj[k], fun, k);
+ }
+ }
+ }
+ }
+ if (call && fun) {
+ fun(obj);
+ }
+ }
+
+ function match(sel, obj) {
+ var a = [];
+ forEach(sel, obj, function(x) {
+ a.push(x);
+ });
+ return a;
+ }
+
+ function compile(sel) {
+ return {
+ sel: parse(sel)[1],
+ match: function(obj){
+ return match(this.sel, obj);
+ },
+ forEach: function(obj, fun) {
+ return forEach(this.sel, obj, fun);
+ }
+ };
+ }
+
+ exports._lex = lex;
+ exports._parse = parse;
+ exports.match = function (sel, obj) {
+ return compile(sel).match(obj);
+ };
+ exports.forEach = function(sel, obj, fun) {
+ return compile(sel).forEach(obj, fun);
+ };
+ exports.compile = compile;
+ })(typeof exports === "undefined" ? (window.JSONSelect = {}) : exports);
+ });
+
+ return require('js-select');
+})();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/runner.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/runner.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/runner.js
new file mode 100644
index 0000000..9d90ac0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/runner.js
@@ -0,0 +1,58 @@
+/* node runner for the JSONSelect conformance tests
+ https://github.com/lloyd/JSONSelectTests */
+
+var assert = require("assert"),
+ fs = require("fs"),
+ path = require("path"),
+ colors = require("colors"),
+ traverse = require("traverse")
+ select = require("../index");
+
+var options = require("nomnom").opts({
+ directory: {
+ abbr: 'd',
+ help: 'directory of tests to run',
+ metavar: 'PATH',
+ default: __dirname + "/level_1"
+ }
+}).parseArgs();
+
+var directory = options.directory,
+ files = fs.readdirSync(directory);
+
+var jsonFiles = files.filter(function(file) {
+ return path.extname(file) == ".json";
+});
+
+jsonFiles.forEach(function(file) {
+ var jsonName = file.replace(/\..*$/, ""),
+ json = JSON.parse(fs.readFileSync(path.join(directory, file), "utf-8"));
+
+ var selFiles = files.filter(function(file) {
+ return file.indexOf(jsonName) == 0 && path.extname(file) == ".selector"
+ })
+
+ selFiles.forEach(function(file) {
+ var test = file.replace(/\..*$/, "");
+ var selector = fs.readFileSync(path.join(directory, file), "utf-8");
+ var output = fs.readFileSync(path.join(directory, test + ".output"), "utf-8");
+
+ var expected = JSON.parse(output).sort(sort);
+ var got = select(json, selector).nodes().sort(sort);
+ try {
+ assert.deepEqual(got, expected);
+ }
+ catch(AssertionError) {
+ console.log("\nfail".red + " " + test + "\ngot: ".blue + JSON.stringify(got)
+ + "\n\expected: ".blue + JSON.stringify(expected) + "\n")
+ };
+ console.log("pass".green + " " + test);
+ });
+});
+
+function sort(a, b) {
+ if (JSON.stringify(a) < JSON.stringify(b)) {
+ return -1;
+ }
+ return 1;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/test.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/test.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/test.js
new file mode 100644
index 0000000..2a215da
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/test/test.js
@@ -0,0 +1,161 @@
+var assert = require("assert"),
+ fs = require("fs"),
+ traverse = require("traverse")
+ select = require("../index");
+
+var people = {
+ "george": {
+ age : 35,
+ movies: [{
+ name: "Repo Man",
+ stars: 5
+ }]
+ },
+ "mary": {
+ age: 15,
+ movies: [{
+ name: "Twilight",
+ stars: 3
+ },
+ {
+ name: "Trudy",
+ stars: 2
+ },
+ {
+ name: "The Fighter",
+ stars: 4
+ }]
+ },
+ "chris" : {
+ car: null,
+ male: true
+ }
+};
+
+var people2, obj;
+
+assert.deepEqual(select(people, "*").nodes(), [{"george":{"age":35,"movies":[{"name":"Repo Man","stars":5}]},"mary":{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},"chris":{"car":null,"male":true}},{"age":35,"movies":[{"name":"Repo Man","stars":5}]},35,[{"name":"Repo Man","stars":5}],{"name":"Repo Man","stars":5},"Repo Man",5,{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},15,[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}],{"name":"Twilight","stars":3},"Twilight",3,{"name":"Trudy","stars":2},"Trudy",2,{"name":"The Fighter","stars":4},"The Fighter",4,{"car":null,"male":true},null,true]);
+assert.deepEqual(select(people, ".george").nodes(), [{"age":35,"movies":[{"name":"Repo Man","stars":5}]}]);
+assert.deepEqual(select(people, ".george .age").nodes(), [35]);
+assert.deepEqual(select(people, ".george .name").nodes(), ["Repo Man"]);
+assert.deepEqual(select(people, ".george *").nodes(), [35,[{"name":"Repo Man","stars":5}],{"name":"Repo Man","stars":5},"Repo Man",5])
+
+assert.deepEqual(select(people, ".george > *").nodes(), [35,[{"name":"Repo Man","stars":5}]]);
+assert.deepEqual(select(people, ".george > .name").nodes(), []);
+
+assert.deepEqual(select(people, ":first-child").nodes(), [{"name":"Repo Man","stars":5},{"name":"Twilight","stars":3}]);
+assert.deepEqual(select(people, ":nth-child(1)").nodes(), select(people, ":first-child").nodes());
+assert.deepEqual(select(people, ":nth-child(2)").nodes(), [{"name":"Trudy","stars":2}]);
+assert.deepEqual(select(people, ":nth-child(odd)").nodes(), [{"name":"Repo Man","stars":5},{"name":"Twilight","stars":3},{"name":"The Fighter","stars":4}]);
+assert.deepEqual(select(people, ":nth-child(even)").nodes(), [{"name":"Trudy","stars":2}]);
+
+assert.deepEqual(select(people, ":nth-child(-n+1)").nodes(), select(people, ":first-child").nodes());
+assert.deepEqual(select(people, ":nth-child(-n+2)").nodes(), [{"name":"Repo Man","stars":5},{"name":"Twilight","stars":3},{"name":"Trudy","stars":2}]);
+assert.deepEqual(select(people, ":nth-child(n)").nodes(), [{"name":"Repo Man","stars":5},{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]);
+assert.deepEqual(select(people, ":nth-child(n-1)").nodes(), select(people, ":nth-child(n)").nodes());
+assert.deepEqual(select(people, ":nth-child(n-2)").nodes(), [{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]);
+
+assert.deepEqual(select(people, ":last-child").nodes(), [{"name":"Repo Man","stars":5},{"name":"The Fighter","stars":4}]);
+assert.deepEqual(select(people, ":nth-last-child(1)").nodes(), select(people, ":last-child").nodes());
+assert.deepEqual(select(people, ":nth-last-child(2)").nodes(), [{"name":"Trudy","stars":2}]);
+assert.deepEqual(select(people, ":only-child").nodes(), [{"name":"Repo Man","stars":5}]);
+assert.deepEqual(select(people, ":root").nodes(),[{"george":{"age":35,"movies":[{"name":"Repo Man","stars":5}]},"mary":{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},"chris":{"car":null,"male":true}}])
+
+assert.deepEqual(select(people, "string").nodes(),["Repo Man","Twilight","Trudy","The Fighter"]);
+assert.deepEqual(select(people, "number").nodes(),[35,5,15,3,2,4]);
+assert.deepEqual(select(people, "boolean").nodes(),[true]);
+assert.deepEqual(select(people, "object").nodes(),[{"george":{"age":35,"movies":[{"name":"Repo Man","stars":5}]},"mary":{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},"chris":{"car":null,"male":true}},{"age":35,"movies":[{"name":"Repo Man","stars":5}]},{"name":"Repo Man","stars":5},{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4},{"car":null,"male":true}]);
+assert.deepEqual(select(people, "array").nodes(),[[{"name":"Repo Man","stars":5}],[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]]);
+assert.deepEqual(select(people, "null").nodes(),[null]);
+
+assert.deepEqual(select(people, "number, string, boolean").nodes(), [35,"Repo Man",5,15,"Twilight",3,"Trudy",2,"The Fighter",4,true])
+
+assert.deepEqual(select(people, ":has(.car) > .male").nodes(), [true]);
+assert.deepEqual(select(people, ".male ~ .car").nodes(), [null])
+
+assert.deepEqual(select(people, ':val("Twilight")').nodes(), ["Twilight"])
+assert.deepEqual(select(people, ':val("Twi")').nodes(), [])
+assert.deepEqual(select(people, ':contains("Twi")').nodes(), ["Twilight"])
+assert.deepEqual(select(people, ':contains("weif")').nodes(), [])
+
+// invalid
+assert.deepEqual(select(people, ".hmmm").nodes(), []);
+assert.throws(function() {
+ select(people, "afcjwiojwe9q28*C@!(# (!#R($R)))").nodes();
+});
+
+// update()
+people2 = traverse.clone(people);
+
+select(people2, ".age").update(function(age) {
+ return age - 5;
+})
+assert.deepEqual(select(people2, ".age").nodes(), [30, 10]);
+
+obj = select(people2, ".age").update(3)
+assert.deepEqual(select(people2, ".age").nodes(), [3, 3]);
+assert.deepEqual(obj, people2);
+
+// remove()
+people2 = traverse.clone(people);
+
+obj = select(people2, ".age").remove();
+assert.deepEqual(select(people2, ".age").nodes(), []);
+assert.deepEqual(obj, people2);
+
+// condense()
+people2 = traverse.clone(people);
+select(people2, ".george").condense();
+assert.deepEqual(people2, {"george": {age: 35, movies: [{name: "Repo Man", stars: 5}]}});
+
+people2 = traverse.clone(people);
+select(people2, ".hmmm").condense();
+assert.deepEqual(people2, {});
+
+people2 = traverse.clone(people);
+obj = select(people2, ".stars").condense();
+assert.deepEqual(people2, {"george": {movies: [{stars: 5}]}, "mary": {movies: [{stars: 3},{stars: 2},{stars: 4}]}});
+assert.deepEqual(obj, people2);
+
+// forEach()
+people2 = traverse.clone(people);
+
+obj = select(people2, ".age").forEach(function(age) {
+ this.update(age - 5);
+})
+assert.deepEqual(select(people2, ".age").nodes(), [30, 10]);
+assert.deepEqual(obj, people2);
+
+
+// this.matches()
+people2 = traverse.clone(people);
+select(people2).forEach(function(node) {
+ if (this.matches(".age")) {
+ this.update(node + 10);
+ }
+});
+assert.deepEqual(select(people2, ".age").nodes(), [45, 25])
+
+
+// bigger stuff
+var timeline = require("./timeline.js");
+
+console.time("select time");
+assert.equal(select(timeline, ".bug .id").nodes().length, 126);
+assert.equal(select(timeline, ".id").nodes().length, 141);
+assert.equal(select(timeline, ".comments .id").nodes().length, 115);
+assert.equal(select(timeline, ":nth-child(n-2)").nodes().length, 335);
+assert.equal(select(timeline, "object").nodes().length, 927);
+assert.equal(select(timeline, "*").nodes().length, 3281);
+console.timeEnd("select time")
+
+var sel = require("JSONSelect");
+
+console.time("JSONSelect time")
+assert.equal(sel.match(".bug .id", timeline).length, 126);
+assert.equal(sel.match(".id", timeline).length, 141);
+assert.equal(sel.match(".comments .id", timeline).length, 115);
+assert.equal(sel.match(":nth-child(n-2)", timeline).length, 335);
+assert.equal(sel.match("object", timeline).length, 927);
+assert.equal(sel.match("*", timeline).length, 3281);
+console.timeEnd("JSONSelect time")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[44/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
new file mode 100644
index 0000000..6c34fbe
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jshint.js
@@ -0,0 +1,3854 @@
+/*
+ * JSHint, by JSHint Community.
+ *
+ * Licensed under the same slightly modified MIT license that JSLint is.
+ * It stops evil-doers everywhere.
+ *
+ * JSHint is a derivative work of JSLint:
+ *
+ * Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * The Software shall be used for Good, not Evil.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * JSHint was forked from 2010-12-16 edition of JSLint.
+ *
+ */
+
+/*
+ JSHINT is a global function. It takes two parameters.
+
+ var myResult = JSHINT(source, option);
+
+ The first parameter is either a string or an array of strings. If it is a
+ string, it will be split on '\n' or '\r'. If it is an array of strings, it
+ is assumed that each string represents one line. The source can be a
+ JavaScript text or a JSON text.
+
+ The second parameter is an optional object of options which control the
+ operation of JSHINT. Most of the options are booleans: They are all
+ optional and have a default value of false. One of the options, predef,
+ can be an array of names, which will be used to declare global variables,
+ or an object whose keys are used as global names, with a boolean value
+ that determines if they are assignable.
+
+ If it checks out, JSHINT returns true. Otherwise, it returns false.
+
+ If false, you can inspect JSHINT.errors to find out the problems.
+ JSHINT.errors is an array of objects containing these members:
+
+ {
+ line : The line (relative to 0) at which the lint was found
+ character : The character (relative to 0) at which the lint was found
+ reason : The problem
+ evidence : The text line in which the problem occurred
+ raw : The raw message before the details were inserted
+ a : The first detail
+ b : The second detail
+ c : The third detail
+ d : The fourth detail
+ }
+
+ If a fatal error was found, a null will be the last element of the
+ JSHINT.errors array.
+
+ You can request a Function Report, which shows all of the functions
+ and the parameters and vars that they use. This can be used to find
+ implied global variables and other problems. The report is in HTML and
+ can be inserted in an HTML <body>.
+
+ var myReport = JSHINT.report(limited);
+
+ If limited is true, then the report will be limited to only errors.
+
+ You can request a data structure which contains JSHint's results.
+
+ var myData = JSHINT.data();
+
+ It returns a structure with this form:
+
+ {
+ errors: [
+ {
+ line: NUMBER,
+ character: NUMBER,
+ reason: STRING,
+ evidence: STRING
+ }
+ ],
+ functions: [
+ name: STRING,
+ line: NUMBER,
+ last: NUMBER,
+ param: [
+ STRING
+ ],
+ closure: [
+ STRING
+ ],
+ var: [
+ STRING
+ ],
+ exception: [
+ STRING
+ ],
+ outer: [
+ STRING
+ ],
+ unused: [
+ STRING
+ ],
+ global: [
+ STRING
+ ],
+ label: [
+ STRING
+ ]
+ ],
+ globals: [
+ STRING
+ ],
+ member: {
+ STRING: NUMBER
+ },
+ unuseds: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ implieds: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ urls: [
+ STRING
+ ],
+ json: BOOLEAN
+ }
+
+ Empty arrays will not be included.
+
+*/
+
+/*jshint
+ evil: true, nomen: false, onevar: false, regexp: false, strict: true, boss: true
+*/
+
+/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
+ "(begin)", "(breakage)", "(context)", "(error)", "(global)",
+ "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
+ "(params)", "(scope)", "(statement)", "(verb)", "*", "+", "++", "-",
+ "--", "\/", "<", "<=", "==", "===", ">", ">=", $, $$, $A, $F, $H, $R, $break,
+ $continue, $w, Abstract, Ajax, __filename, __dirname, ActiveXObject, Array,
+ ArrayBuffer, ArrayBufferView, Autocompleter, Assets, Boolean, Builder,
+ Buffer, Browser, COM, CScript, Canvas, CustomAnimation, Class, Control,
+ Chain, Color, Cookie, Core, DataView, Date, Debug, Draggable, Draggables,
+ Droppables, Document, DomReady, DOMReady, Drag, E, Enumerator, Enumerable,
+ Element, Elements, Error, Effect, EvalError, Event, Events, FadeAnimation,
+ Field, Flash, Float32Array, Float64Array, Form, FormField, Frame, Function,
+ Fx, Group, Hash, HotKey, HTMLElement, HtmlTable, Iframe, IframeShim, Image,
+ Int16Array, Int32Array, Int8Array, Insertion, InputValidator, JSON, Keyboard,
+ Locale, LN10, LN2, LOG10E, LOG2E, MAX_VALUE, MIN_VALUE, Mask, Math, MenuItem,
+ MoveAnimation, MooTools, Native, NEGATIVE_INFINITY, Number, Object,
+ ObjectRange, Option, Options, OverText, PI, POSITIVE_INFINITY,
+ PeriodicalExecuter, Point, Position, Prototype, RangeError, Rectangle,
+ ReferenceError, RegExp, ResizeAnimation, Request, RotateAnimation, SQRT1_2,
+ SQRT2, ScrollBar, Scriptaculous, Scroller, Slick, Slider, Selector, String,
+ Style, SyntaxError, Sortable, Sortables, SortableObserver, Sound, Spinner,
+ System, Swiff, Text, TextArea, Template, Timer, Tips, Type, TypeError,
+ Toggle, Try, URI, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
+ XMLHttpRequest, XPathEvaluator, XPathException, XPathExpression,
+ XPathNamespace, XPathNSResolver, XPathResult, "\\", a, addEventListener,
+ address, alert, apply, applicationCache, arguments, arity, asi, b, bitwise,
+ block, blur, boolOptions, boss, browser, c, call, callee, caller, cases,
+ charAt, charCodeAt, character, clearInterval, clearTimeout, close, closed,
+ closure, comment, condition, confirm, console, constructor, content, couch,
+ create, css, curly, d, data, datalist, dd, debug, decodeURI,
+ decodeURIComponent, defaultStatus, defineClass, deserialize, devel,
+ document, edition, else, emit, encodeURI, encodeURIComponent, entityify,
+ eqeqeq, eqnull, errors, es5, escape, eval, event, evidence, evil, ex,
+ exception, exec, exps, expr, exports, FileReader, first, floor, focus,
+ forin, fragment, frames, from, fromCharCode, fud, funct, function, functions,
+ g, gc, getComputedStyle, getRow, GLOBAL, global, globals, globalstrict,
+ hasOwnProperty, help, history, i, id, identifier, immed, implieds,
+ include, indent, indexOf, init, ins, instanceOf, isAlpha,
+ isApplicationRunning, isArray, isDigit, isFinite, isNaN, join, jshint,
+ JSHINT, json, jquery, jQuery, keys, label, labelled, last, laxbreak,
+ latedef, lbp, led, left, length, line, load, loadClass, localStorage,
+ location, log, loopfunc, m, match, maxerr, maxlen, member,message, meta,
+ module, moveBy, moveTo, mootools, name, navigator, new, newcap, noarg,
+ node, noempty, nomen, nonew, nud, onbeforeunload, onblur, onerror, onevar,
+ onfocus, onload, onresize, onunload, open, openDatabase, openURL, opener,
+ opera, outer, param, parent, parseFloat, parseInt, passfail, plusplus,
+ predef, print, process, prompt, prototype, prototypejs, push, quit, range,
+ raw, reach, reason, regexp, readFile, readUrl, removeEventListener, replace,
+ report, require, reserved, resizeBy, resizeTo, resolvePath, resumeUpdates,
+ respond, rhino, right, runCommand, scroll, screen, scrollBy, scrollTo,
+ scrollbar, search, seal, send, serialize, setInterval, setTimeout, shift,
+ slice, sort,spawn, split, stack, status, start, strict, sub, substr, supernew,
+ shadow, supplant, sum, sync, test, toLowerCase, toString, toUpperCase, toint32,
+ token, top, type, typeOf, Uint16Array, Uint32Array, Uint8Array, undef,
+ unused, urls, value, valueOf, var, version, WebSocket, white, window, Worker
+*/
+
+/*global exports: false */
+
+// We build the application inside a function so that we produce only a single
+// global variable. That function will be invoked immediately, and its return
+// value is the JSHINT function itself.
+
+var JSHINT = (function () {
+ "use strict";
+
+ var anonname, // The guessed name for anonymous functions.
+
+// These are operators that should not be used with the ! operator.
+
+ bang = {
+ '<' : true,
+ '<=' : true,
+ '==' : true,
+ '===': true,
+ '!==': true,
+ '!=' : true,
+ '>' : true,
+ '>=' : true,
+ '+' : true,
+ '-' : true,
+ '*' : true,
+ '/' : true,
+ '%' : true
+ },
+
+// These are the JSHint boolean options.
+
+ boolOptions = {
+ asi : true, // if automatic semicolon insertion should be tolerated
+ bitwise : true, // if bitwise operators should not be allowed
+ boss : true, // if advanced usage of assignments should be allowed
+ browser : true, // if the standard browser globals should be predefined
+ couch : true, // if CouchDB globals should be predefined
+ curly : true, // if curly braces around blocks should be required (even in if/for/while)
+ debug : true, // if debugger statements should be allowed
+ devel : true, // if logging globals should be predefined (console, alert, etc.)
+ eqeqeq : true, // if === should be required
+ eqnull : true, // if == null comparisons should be tolerated
+ es5 : true, // if ES5 syntax should be allowed
+ evil : true, // if eval should be allowed
+ expr : true, // if ExpressionStatement should be allowed as Programs
+ forin : true, // if for in statements must filter
+ globalstrict: true, // if global "use strict"; should be allowed (also enables 'strict')
+ immed : true, // if immediate invocations must be wrapped in parens
+ jquery : true, // if jQuery globals should be predefined
+ latedef : true, // if the use before definition should not be tolerated
+ laxbreak : true, // if line breaks should not be checked
+ loopfunc : true, // if functions should be allowed to be defined within loops
+ mootools : true, // if MooTools globals should be predefined
+ newcap : true, // if constructor names must be capitalized
+ noarg : true, // if arguments.caller and arguments.callee should be disallowed
+ node : true, // if the Node.js environment globals should be predefined
+ noempty : true, // if empty blocks should be disallowed
+ nonew : true, // if using `new` for side-effects should be disallowed
+ nomen : true, // if names should be checked
+ onevar : true, // if only one var statement per function should be allowed
+ passfail : true, // if the scan should stop on first error
+ plusplus : true, // if increment/decrement should not be allowed
+ prototypejs : true, // if Prototype and Scriptaculous globals shoudl be predefined
+ regexp : true, // if the . should not be allowed in regexp literals
+ rhino : true, // if the Rhino environment globals should be predefined
+ undef : true, // if variables should be declared before used
+ shadow : true, // if variable shadowing should be tolerated
+ strict : true, // require the "use strict"; pragma
+ sub : true, // if all forms of subscript notation are tolerated
+ supernew : true, // if `new function () { ... };` and `new Object;` should be tolerated
+ white : true // if strict whitespace rules apply
+ },
+
+// browser contains a set of global names which are commonly provided by a
+// web browser environment.
+
+ browser = {
+ ArrayBuffer : false,
+ ArrayBufferView : false,
+ addEventListener: false,
+ applicationCache: false,
+ blur : false,
+ clearInterval : false,
+ clearTimeout : false,
+ close : false,
+ closed : false,
+ DataView : false,
+ defaultStatus : false,
+ document : false,
+ event : false,
+ FileReader : false,
+ Float32Array : false,
+ Float64Array : false,
+ focus : false,
+ frames : false,
+ getComputedStyle: false,
+ HTMLElement : false,
+ history : false,
+ Int16Array : false,
+ Int32Array : false,
+ Int8Array : false,
+ Image : false,
+ length : false,
+ localStorage : false,
+ location : false,
+ moveBy : false,
+ moveTo : false,
+ name : false,
+ navigator : false,
+ onbeforeunload : true,
+ onblur : true,
+ onerror : true,
+ onfocus : true,
+ onload : true,
+ onresize : true,
+ onunload : true,
+ open : false,
+ openDatabase : false,
+ opener : false,
+ Option : false,
+ parent : false,
+ print : false,
+ removeEventListener: false,
+ resizeBy : false,
+ resizeTo : false,
+ screen : false,
+ scroll : false,
+ scrollBy : false,
+ scrollTo : false,
+ setInterval : false,
+ setTimeout : false,
+ status : false,
+ top : false,
+ Uint16Array : false,
+ Uint32Array : false,
+ Uint8Array : false,
+ WebSocket : false,
+ window : false,
+ Worker : false,
+ XMLHttpRequest : false,
+ XPathEvaluator : false,
+ XPathException : false,
+ XPathExpression : false,
+ XPathNamespace : false,
+ XPathNSResolver : false,
+ XPathResult : false
+ },
+
+ couch = {
+ "require" : false,
+ respond : false,
+ getRow : false,
+ emit : false,
+ send : false,
+ start : false,
+ sum : false,
+ log : false,
+ exports : false,
+ module : false
+ },
+
+ devel = {
+ alert : false,
+ confirm : false,
+ console : false,
+ Debug : false,
+ opera : false,
+ prompt : false
+ },
+
+ escapes = {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '/' : '\\/',
+ '\\': '\\\\'
+ },
+
+ funct, // The current function
+
+ functionicity = [
+ 'closure', 'exception', 'global', 'label',
+ 'outer', 'unused', 'var'
+ ],
+
+ functions, // All of the functions
+
+ global, // The global scope
+ implied, // Implied globals
+ inblock,
+ indent,
+ jsonmode,
+
+ jquery = {
+ '$' : false,
+ jQuery : false
+ },
+
+ lines,
+ lookahead,
+ member,
+ membersOnly,
+
+ mootools = {
+ '$' : false,
+ '$$' : false,
+ Assets : false,
+ Browser : false,
+ Chain : false,
+ Class : false,
+ Color : false,
+ Cookie : false,
+ Core : false,
+ Document : false,
+ DomReady : false,
+ DOMReady : false,
+ Drag : false,
+ Element : false,
+ Elements : false,
+ Event : false,
+ Events : false,
+ Fx : false,
+ Group : false,
+ Hash : false,
+ HtmlTable : false,
+ Iframe : false,
+ IframeShim : false,
+ InputValidator : false,
+ instanceOf : false,
+ Keyboard : false,
+ Locale : false,
+ Mask : false,
+ MooTools : false,
+ Native : false,
+ Options : false,
+ OverText : false,
+ Request : false,
+ Scroller : false,
+ Slick : false,
+ Slider : false,
+ Sortables : false,
+ Spinner : false,
+ Swiff : false,
+ Tips : false,
+ Type : false,
+ typeOf : false,
+ URI : false,
+ Window : false
+ },
+
+ nexttoken,
+
+ node = {
+ __filename : false,
+ __dirname : false,
+ exports : false,
+ Buffer : false,
+ GLOBAL : false,
+ global : false,
+ module : false,
+ process : false,
+ require : false
+ },
+
+ noreach,
+ option,
+ predefined, // Global variables defined by option
+ prereg,
+ prevtoken,
+
+ prototypejs = {
+ '$' : false,
+ '$$' : false,
+ '$A' : false,
+ '$F' : false,
+ '$H' : false,
+ '$R' : false,
+ '$break' : false,
+ '$continue' : false,
+ '$w' : false,
+ Abstract : false,
+ Ajax : false,
+ Class : false,
+ Enumerable : false,
+ Element : false,
+ Event : false,
+ Field : false,
+ Form : false,
+ Hash : false,
+ Insertion : false,
+ ObjectRange : false,
+ PeriodicalExecuter: false,
+ Position : false,
+ Prototype : false,
+ Selector : false,
+ Template : false,
+ Toggle : false,
+ Try : false,
+ Autocompleter : false,
+ Builder : false,
+ Control : false,
+ Draggable : false,
+ Draggables : false,
+ Droppables : false,
+ Effect : false,
+ Sortable : false,
+ SortableObserver : false,
+ Sound : false,
+ Scriptaculous : false
+ },
+
+ rhino = {
+ defineClass : false,
+ deserialize : false,
+ gc : false,
+ help : false,
+ load : false,
+ loadClass : false,
+ print : false,
+ quit : false,
+ readFile : false,
+ readUrl : false,
+ runCommand : false,
+ seal : false,
+ serialize : false,
+ spawn : false,
+ sync : false,
+ toint32 : false,
+ version : false
+ },
+
+ scope, // The current scope
+ src,
+ stack,
+
+// standard contains the global names that are provided by the
+// ECMAScript standard.
+
+ standard = {
+ Array : false,
+ Boolean : false,
+ Date : false,
+ decodeURI : false,
+ decodeURIComponent : false,
+ encodeURI : false,
+ encodeURIComponent : false,
+ Error : false,
+ 'eval' : false,
+ EvalError : false,
+ Function : false,
+ hasOwnProperty : false,
+ isFinite : false,
+ isNaN : false,
+ JSON : false,
+ Math : false,
+ Number : false,
+ Object : false,
+ parseInt : false,
+ parseFloat : false,
+ RangeError : false,
+ ReferenceError : false,
+ RegExp : false,
+ String : false,
+ SyntaxError : false,
+ TypeError : false,
+ URIError : false
+ },
+
+ standard_member = {
+ E : true,
+ LN2 : true,
+ LN10 : true,
+ LOG2E : true,
+ LOG10E : true,
+ MAX_VALUE : true,
+ MIN_VALUE : true,
+ NEGATIVE_INFINITY : true,
+ PI : true,
+ POSITIVE_INFINITY : true,
+ SQRT1_2 : true,
+ SQRT2 : true
+ },
+
+ strict_mode,
+ syntax = {},
+ tab,
+ token,
+ urls,
+ warnings,
+
+// Regular expressions. Some of these are stupidly long.
+
+// unsafe comment or string
+ ax = /@cc|<\/?|script|\]\s*\]|<\s*!|</i,
+// unsafe characters that are silently deleted by one or more browsers
+ cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
+// token
+ tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jshint|jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
+// characters in strings that need escapement
+ nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
+ nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+// star slash
+ lx = /\*\/|\/\*/,
+// identifier
+ ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
+// javascript url
+ jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
+// catches /* falls through */ comments
+ ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/;
+
+ function F() {} // Used by Object.create
+
+ function is_own(object, name) {
+
+// The object.hasOwnProperty method fails when the property under consideration
+// is named 'hasOwnProperty'. So we have to use this more convoluted form.
+
+ return Object.prototype.hasOwnProperty.call(object, name);
+ }
+
+// Provide critical ES5 functions to ES3.
+
+ if (typeof Array.isArray !== 'function') {
+ Array.isArray = function (o) {
+ return Object.prototype.toString.apply(o) === '[object Array]';
+ };
+ }
+
+ if (typeof Object.create !== 'function') {
+ Object.create = function (o) {
+ F.prototype = o;
+ return new F();
+ };
+ }
+
+ if (typeof Object.keys !== 'function') {
+ Object.keys = function (o) {
+ var a = [], k;
+ for (k in o) {
+ if (is_own(o, k)) {
+ a.push(k);
+ }
+ }
+ return a;
+ };
+ }
+
+// Non standard methods
+
+ if (typeof String.prototype.entityify !== 'function') {
+ String.prototype.entityify = function () {
+ return this
+ .replace(/&/g, '&')
+ .replace(/</g, '<')
+ .replace(/>/g, '>');
+ };
+ }
+
+ if (typeof String.prototype.isAlpha !== 'function') {
+ String.prototype.isAlpha = function () {
+ return (this >= 'a' && this <= 'z\uffff') ||
+ (this >= 'A' && this <= 'Z\uffff');
+ };
+ }
+
+ if (typeof String.prototype.isDigit !== 'function') {
+ String.prototype.isDigit = function () {
+ return (this >= '0' && this <= '9');
+ };
+ }
+
+ if (typeof String.prototype.supplant !== 'function') {
+ String.prototype.supplant = function (o) {
+ return this.replace(/\{([^{}]*)\}/g, function (a, b) {
+ var r = o[b];
+ return typeof r === 'string' || typeof r === 'number' ? r : a;
+ });
+ };
+ }
+
+ if (typeof String.prototype.name !== 'function') {
+ String.prototype.name = function () {
+
+// If the string looks like an identifier, then we can return it as is.
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can simply slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe
+// sequences.
+
+ if (ix.test(this)) {
+ return this;
+ }
+ if (nx.test(this)) {
+ return '"' + this.replace(nxg, function (a) {
+ var c = escapes[a];
+ if (c) {
+ return c;
+ }
+ return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
+ }) + '"';
+ }
+ return '"' + this + '"';
+ };
+ }
+
+
+ function combine(t, o) {
+ var n;
+ for (n in o) {
+ if (is_own(o, n)) {
+ t[n] = o[n];
+ }
+ }
+ }
+
+ function assume() {
+ if (option.couch)
+ combine(predefined, couch);
+
+ if (option.rhino)
+ combine(predefined, rhino);
+
+ if (option.prototypejs)
+ combine(predefined, prototypejs);
+
+ if (option.node)
+ combine(predefined, node);
+
+ if (option.devel)
+ combine(predefined, devel);
+
+ if (option.browser)
+ combine(predefined, browser);
+
+ if (option.jquery)
+ combine(predefined, jquery);
+
+ if (option.mootools)
+ combine(predefined, mootools);
+
+ if (option.globalstrict)
+ option.strict = true;
+ }
+
+
+// Produce an error warning.
+
+ function quit(m, l, ch) {
+ throw {
+ name: 'JSHintError',
+ line: l,
+ character: ch,
+ message: m + " (" + Math.floor((l / lines.length) * 100) +
+ "% scanned)."
+ };
+ }
+
+ function warning(m, t, a, b, c, d) {
+ var ch, l, w;
+ t = t || nexttoken;
+ if (t.id === '(end)') { // `~
+ t = token;
+ }
+ l = t.line || 0;
+ ch = t.from || 0;
+ w = {
+ id: '(error)',
+ raw: m,
+ evidence: lines[l - 1] || '',
+ line: l,
+ character: ch,
+ a: a,
+ b: b,
+ c: c,
+ d: d
+ };
+ w.reason = m.supplant(w);
+ JSHINT.errors.push(w);
+ if (option.passfail) {
+ quit('Stopping. ', l, ch);
+ }
+ warnings += 1;
+ if (warnings >= option.maxerr) {
+ quit("Too many errors.", l, ch);
+ }
+ return w;
+ }
+
+ function warningAt(m, l, ch, a, b, c, d) {
+ return warning(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+ function error(m, t, a, b, c, d) {
+ var w = warning(m, t, a, b, c, d);
+ quit("Stopping, unable to continue.", w.line, w.character);
+ }
+
+ function errorAt(m, l, ch, a, b, c, d) {
+ return error(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+
+
+// lexical analysis and token construction
+
+ var lex = (function lex() {
+ var character, from, line, s;
+
+// Private lex methods
+
+ function nextLine() {
+ var at,
+ tw; // trailing whitespace check
+
+ if (line >= lines.length)
+ return false;
+
+ character = 1;
+ s = lines[line];
+ line += 1;
+ at = s.search(/ \t/);
+
+ if (at >= 0)
+ warningAt("Mixed spaces and tabs.", line, at + 1);
+
+ s = s.replace(/\t/g, tab);
+ at = s.search(cx);
+
+ if (at >= 0)
+ warningAt("Unsafe character.", line, at);
+
+ if (option.maxlen && option.maxlen < s.length)
+ warningAt("Line too long.", line, s.length);
+
+ // Check for trailing whitespaces
+ tw = s.search(/\s+$/);
+ if (option.white && ~tw)
+ warningAt("Trailing whitespace.", line, tw);
+
+ return true;
+ }
+
+// Produce a token object. The token inherits from a syntax symbol.
+
+ function it(type, value) {
+ var i, t;
+ if (type === '(color)' || type === '(range)') {
+ t = {type: type};
+ } else if (type === '(punctuator)' ||
+ (type === '(identifier)' && is_own(syntax, value))) {
+ t = syntax[value] || syntax['(error)'];
+ } else {
+ t = syntax[type];
+ }
+ t = Object.create(t);
+ if (type === '(string)' || type === '(range)') {
+ if (jx.test(value)) {
+ warningAt("Script URL.", line, from);
+ }
+ }
+ if (type === '(identifier)') {
+ t.identifier = true;
+ if (value === '__iterator__' || value === '__proto__') {
+ errorAt("Reserved name '{a}'.",
+ line, from, value);
+ } else if (option.nomen &&
+ (value.charAt(0) === '_' ||
+ value.charAt(value.length - 1) === '_')) {
+ warningAt("Unexpected {a} in '{b}'.", line, from,
+ "dangling '_'", value);
+ }
+ }
+ t.value = value;
+ t.line = line;
+ t.character = character;
+ t.from = from;
+ i = t.id;
+ if (i !== '(endline)') {
+ prereg = i &&
+ (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
+ i === 'return');
+ }
+ return t;
+ }
+
+// Public lex methods
+
+ return {
+ init: function (source) {
+ if (typeof source === 'string') {
+ lines = source
+ .replace(/\r\n/g, '\n')
+ .replace(/\r/g, '\n')
+ .split('\n');
+ } else {
+ lines = source;
+ }
+
+ // If the first line is a shebang (#!), make it a blank and move on.
+ // Shebangs are used by Node scripts.
+ if (lines[0] && lines[0].substr(0, 2) == '#!')
+ lines[0] = '';
+
+ line = 0;
+ nextLine();
+ from = 1;
+ },
+
+ range: function (begin, end) {
+ var c, value = '';
+ from = character;
+ if (s.charAt(0) !== begin) {
+ errorAt("Expected '{a}' and instead saw '{b}'.",
+ line, character, begin, s.charAt(0));
+ }
+ for (;;) {
+ s = s.slice(1);
+ character += 1;
+ c = s.charAt(0);
+ switch (c) {
+ case '':
+ errorAt("Missing '{a}'.", line, character, c);
+ break;
+ case end:
+ s = s.slice(1);
+ character += 1;
+ return it('(range)', value);
+ case '\\':
+ warningAt("Unexpected '{a}'.", line, character, c);
+ }
+ value += c;
+ }
+
+ },
+
+// token -- this is called by advance to get the next token.
+
+ token: function () {
+ var b, c, captures, d, depth, high, i, l, low, q, t;
+
+ function match(x) {
+ var r = x.exec(s), r1;
+ if (r) {
+ l = r[0].length;
+ r1 = r[1];
+ c = r1.charAt(0);
+ s = s.substr(l);
+ from = character + l - r1.length;
+ character += l;
+ return r1;
+ }
+ }
+
+ function string(x) {
+ var c, j, r = '';
+
+ if (jsonmode && x !== '"') {
+ warningAt("Strings must use doublequote.",
+ line, character);
+ }
+
+ function esc(n) {
+ var i = parseInt(s.substr(j + 1, n), 16);
+ j += n;
+ if (i >= 32 && i <= 126 &&
+ i !== 34 && i !== 92 && i !== 39) {
+ warningAt("Unnecessary escapement.", line, character);
+ }
+ character += n;
+ c = String.fromCharCode(i);
+ }
+ j = 0;
+ for (;;) {
+ while (j >= s.length) {
+ j = 0;
+ if (!nextLine()) {
+ errorAt("Unclosed string.", line, from);
+ }
+ }
+ c = s.charAt(j);
+ if (c === x) {
+ character += 1;
+ s = s.substr(j + 1);
+ return it('(string)', r, x);
+ }
+ if (c < ' ') {
+ if (c === '\n' || c === '\r') {
+ break;
+ }
+ warningAt("Control character in string: {a}.",
+ line, character + j, s.slice(0, j));
+ } else if (c === '\\') {
+ j += 1;
+ character += 1;
+ c = s.charAt(j);
+ switch (c) {
+ case '\\':
+ case '"':
+ case '/':
+ break;
+ case '\'':
+ if (jsonmode) {
+ warningAt("Avoid \\'.", line, character);
+ }
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'u':
+ esc(4);
+ break;
+ case 'v':
+ if (jsonmode) {
+ warningAt("Avoid \\v.", line, character);
+ }
+ c = '\v';
+ break;
+ case 'x':
+ if (jsonmode) {
+ warningAt("Avoid \\x-.", line, character);
+ }
+ esc(2);
+ break;
+ default:
+ warningAt("Bad escapement.", line, character);
+ }
+ }
+ r += c;
+ character += 1;
+ j += 1;
+ }
+ }
+
+ for (;;) {
+ if (!s) {
+ return it(nextLine() ? '(endline)' : '(end)', '');
+ }
+ t = match(tx);
+ if (!t) {
+ t = '';
+ c = '';
+ while (s && s < '!') {
+ s = s.substr(1);
+ }
+ if (s) {
+ errorAt("Unexpected '{a}'.", line, character, s.substr(0, 1));
+ }
+ } else {
+
+ // identifier
+
+ if (c.isAlpha() || c === '_' || c === '$') {
+ return it('(identifier)', t);
+ }
+
+ // number
+
+ if (c.isDigit()) {
+ if (!isFinite(Number(t))) {
+ warningAt("Bad number '{a}'.",
+ line, character, t);
+ }
+ if (s.substr(0, 1).isAlpha()) {
+ warningAt("Missing space after '{a}'.",
+ line, character, t);
+ }
+ if (c === '0') {
+ d = t.substr(1, 1);
+ if (d.isDigit()) {
+ if (token.id !== '.') {
+ warningAt("Don't use extra leading zeros '{a}'.",
+ line, character, t);
+ }
+ } else if (jsonmode && (d === 'x' || d === 'X')) {
+ warningAt("Avoid 0x-. '{a}'.",
+ line, character, t);
+ }
+ }
+ if (t.substr(t.length - 1) === '.') {
+ warningAt(
+"A trailing decimal point can be confused with a dot '{a}'.", line, character, t);
+ }
+ return it('(number)', t);
+ }
+ switch (t) {
+
+ // string
+
+ case '"':
+ case "'":
+ return string(t);
+
+ // // comment
+
+ case '//':
+ if (src) {
+ warningAt("Unexpected comment.", line, character);
+ }
+ s = '';
+ token.comment = true;
+ break;
+
+ // /* comment
+
+ case '/*':
+ if (src) {
+ warningAt("Unexpected comment.", line, character);
+ }
+ for (;;) {
+ i = s.search(lx);
+ if (i >= 0) {
+ break;
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed comment.", line, character);
+ }
+ }
+ character += i + 2;
+ if (s.substr(i, 1) === '/') {
+ errorAt("Nested comment.", line, character);
+ }
+ s = s.substr(i + 2);
+ token.comment = true;
+ break;
+
+ // /*members /*jshint /*global
+
+ case '/*members':
+ case '/*member':
+ case '/*jshint':
+ case '/*jslint':
+ case '/*global':
+ case '*/':
+ return {
+ value: t,
+ type: 'special',
+ line: line,
+ character: character,
+ from: from
+ };
+
+ case '':
+ break;
+ // /
+ case '/':
+ if (token.id === '/=') {
+ errorAt(
+"A regular expression literal can be confused with '/='.", line, from);
+ }
+ if (prereg) {
+ depth = 0;
+ captures = 0;
+ l = 0;
+ for (;;) {
+ b = true;
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '':
+ errorAt("Unclosed regular expression.",
+ line, from);
+ return;
+ case '/':
+ if (depth > 0) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, '/');
+ }
+ c = s.substr(0, l - 1);
+ q = {
+ g: true,
+ i: true,
+ m: true
+ };
+ while (q[s.charAt(l)] === true) {
+ q[s.charAt(l)] = false;
+ l += 1;
+ }
+ character += l;
+ s = s.substr(l);
+ q = s.charAt(0);
+ if (q === '/' || q === '*') {
+ errorAt("Confusing regular expression.",
+ line, from);
+ }
+ return it('(regexp)', c);
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+ break;
+ case '(':
+ depth += 1;
+ b = false;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ switch (s.charAt(l)) {
+ case ':':
+ case '=':
+ case '!':
+ l += 1;
+ break;
+ default:
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
+ }
+ } else {
+ captures += 1;
+ }
+ break;
+ case '|':
+ b = false;
+ break;
+ case ')':
+ if (depth === 0) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, ')');
+ } else {
+ depth -= 1;
+ }
+ break;
+ case ' ':
+ q = 1;
+ while (s.charAt(l) === ' ') {
+ l += 1;
+ q += 1;
+ }
+ if (q > 1) {
+ warningAt(
+"Spaces are hard to count. Use {{a}}.", line, from + l, q);
+ }
+ break;
+ case '[':
+ c = s.charAt(l);
+ if (c === '^') {
+ l += 1;
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.",
+ line, from + l, c);
+ } else if (s.charAt(l) === ']') {
+ errorAt("Unescaped '{a}'.",
+ line, from + l, '^');
+ }
+ }
+ q = false;
+ if (c === ']') {
+ warningAt("Empty class.", line,
+ from + l - 1);
+ q = true;
+ }
+klass: do {
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '[':
+ case '^':
+ warningAt("Unescaped '{a}'.",
+ line, from + l, c);
+ q = true;
+ break;
+ case '-':
+ if (q) {
+ q = false;
+ } else {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, '-');
+ q = true;
+ }
+ break;
+ case ']':
+ if (!q) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '-');
+ }
+ break klass;
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+ q = true;
+ break;
+ case '/':
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '/');
+ q = true;
+ break;
+ case '<':
+ q = true;
+ break;
+ default:
+ q = true;
+ }
+ } while (c);
+ break;
+ case '.':
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.", line,
+ from + l, c);
+ }
+ break;
+ case ']':
+ case '?':
+ case '{':
+ case '}':
+ case '+':
+ case '*':
+ warningAt("Unescaped '{a}'.", line,
+ from + l, c);
+ }
+ if (b) {
+ switch (s.charAt(l)) {
+ case '?':
+ case '+':
+ case '*':
+ l += 1;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ break;
+ case '{':
+ l += 1;
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ warningAt(
+"Expected a number and instead saw '{a}'.", line, from + l, c);
+ }
+ l += 1;
+ low = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ low = +c + (low * 10);
+ }
+ high = low;
+ if (c === ',') {
+ l += 1;
+ high = Infinity;
+ c = s.charAt(l);
+ if (c >= '0' && c <= '9') {
+ l += 1;
+ high = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ high = +c + (high * 10);
+ }
+ }
+ }
+ if (s.charAt(l) !== '}') {
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
+ } else {
+ l += 1;
+ }
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ if (low > high) {
+ warningAt(
+"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
+ }
+ }
+ }
+ }
+ c = s.substr(0, l - 1);
+ character += l;
+ s = s.substr(l);
+ return it('(regexp)', c);
+ }
+ return it('(punctuator)', t);
+
+ // punctuator
+
+ case '#':
+ return it('(punctuator)', t);
+ default:
+ return it('(punctuator)', t);
+ }
+ }
+ }
+ }
+ };
+ }());
+
+
+ function addlabel(t, type) {
+
+ if (t === 'hasOwnProperty') {
+ warning("'hasOwnProperty' is a really bad name.");
+ }
+
+// Define t in the current function in the current scope.
+
+ if (is_own(funct, t) && !funct['(global)']) {
+ if (funct[t] === true) {
+ if (option.latedef)
+ warning("'{a}' was used before it was defined.", nexttoken, t);
+ } else {
+ if (!option.shadow)
+ warning("'{a}' is already defined.", nexttoken, t);
+ }
+ }
+
+ funct[t] = type;
+ if (funct['(global)']) {
+ global[t] = funct;
+ if (is_own(implied, t)) {
+ if (option.latedef)
+ warning("'{a}' was used before it was defined.", nexttoken, t);
+ delete implied[t];
+ }
+ } else {
+ scope[t] = funct;
+ }
+ }
+
+
+ function doOption() {
+ var b, obj, filter, o = nexttoken.value, t, v;
+ switch (o) {
+ case '*/':
+ error("Unbegun comment.");
+ break;
+ case '/*members':
+ case '/*member':
+ o = '/*members';
+ if (!membersOnly) {
+ membersOnly = {};
+ }
+ obj = membersOnly;
+ break;
+ case '/*jshint':
+ case '/*jslint':
+ obj = option;
+ filter = boolOptions;
+ break;
+ case '/*global':
+ obj = predefined;
+ break;
+ default:
+ error("What?");
+ }
+ t = lex.token();
+loop: for (;;) {
+ for (;;) {
+ if (t.type === 'special' && t.value === '*/') {
+ break loop;
+ }
+ if (t.id !== '(endline)' && t.id !== ',') {
+ break;
+ }
+ t = lex.token();
+ }
+ if (t.type !== '(string)' && t.type !== '(identifier)' &&
+ o !== '/*members') {
+ error("Bad option.", t);
+ }
+ v = lex.token();
+ if (v.id === ':') {
+ v = lex.token();
+ if (obj === membersOnly) {
+ error("Expected '{a}' and instead saw '{b}'.",
+ t, '*/', ':');
+ }
+ if (t.value === 'indent' && (o === '/*jshint' || o === '/*jslint')) {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.white = true;
+ obj.indent = b;
+ } else if (t.value === 'maxerr' && (o === '/*jshint' || o === '/*jslint')) {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxerr = b;
+ } else if (t.value === 'maxlen' && (o === '/*jshint' || o === '/*jslint')) {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxlen = b;
+ } else if (v.value === 'true') {
+ obj[t.value] = true;
+ } else if (v.value === 'false') {
+ obj[t.value] = false;
+ } else {
+ error("Bad option value.", v);
+ }
+ t = lex.token();
+ } else {
+ if (o === '/*jshint' || o === '/*jslint') {
+ error("Missing option value.", t);
+ }
+ obj[t.value] = false;
+ t = v;
+ }
+ }
+ if (filter) {
+ assume();
+ }
+ }
+
+
+// We need a peek function. If it has an argument, it peeks that much farther
+// ahead. It is used to distinguish
+// for ( var i in ...
+// from
+// for ( var i = ...
+
+ function peek(p) {
+ var i = p || 0, j = 0, t;
+
+ while (j <= i) {
+ t = lookahead[j];
+ if (!t) {
+ t = lookahead[j] = lex.token();
+ }
+ j += 1;
+ }
+ return t;
+ }
+
+
+
+// Produce the next token. It looks for programming errors.
+
+ function advance(id, t) {
+ switch (token.id) {
+ case '(number)':
+ if (nexttoken.id === '.') {
+ warning("A dot following a number can be confused with a decimal point.", token);
+ }
+ break;
+ case '-':
+ if (nexttoken.id === '-' || nexttoken.id === '--') {
+ warning("Confusing minusses.");
+ }
+ break;
+ case '+':
+ if (nexttoken.id === '+' || nexttoken.id === '++') {
+ warning("Confusing plusses.");
+ }
+ break;
+ }
+ if (token.type === '(string)' || token.identifier) {
+ anonname = token.value;
+ }
+
+ if (id && nexttoken.id !== id) {
+ if (t) {
+ if (nexttoken.id === '(end)') {
+ warning("Unmatched '{a}'.", t, t.id);
+ } else {
+ warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
+ nexttoken, id, t.id, t.line, nexttoken.value);
+ }
+ } else if (nexttoken.type !== '(identifier)' ||
+ nexttoken.value !== id) {
+ warning("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, id, nexttoken.value);
+ }
+ }
+ prevtoken = token;
+ token = nexttoken;
+ for (;;) {
+ nexttoken = lookahead.shift() || lex.token();
+ if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
+ return;
+ }
+ if (nexttoken.type === 'special') {
+ doOption();
+ } else {
+ if (nexttoken.id !== '(endline)') {
+ break;
+ }
+ }
+ }
+ }
+
+
+// This is the heart of JSHINT, the Pratt parser. In addition to parsing, it
+// is looking for ad hoc lint patterns. We add .fud to Pratt's model, which is
+// like .nud except that it is only used on the first token of a statement.
+// Having .fud makes it much easier to define statement-oriented languages like
+// JavaScript. I retained Pratt's nomenclature.
+
+// .nud Null denotation
+// .fud First null denotation
+// .led Left denotation
+// lbp Left binding power
+// rbp Right binding power
+
+// They are elements of the parsing method called Top Down Operator Precedence.
+
+ function expression(rbp, initial) {
+ var left, isArray = false;
+
+ if (nexttoken.id === '(end)')
+ error("Unexpected early end of program.", token);
+
+ advance();
+ if (initial) {
+ anonname = 'anonymous';
+ funct['(verb)'] = token.value;
+ }
+ if (initial === true && token.fud) {
+ left = token.fud();
+ } else {
+ if (token.nud) {
+ left = token.nud();
+ } else {
+ if (nexttoken.type === '(number)' && token.id === '.') {
+ warning("A leading decimal point can be confused with a dot: '.{a}'.",
+ token, nexttoken.value);
+ advance();
+ return token;
+ } else {
+ error("Expected an identifier and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ while (rbp < nexttoken.lbp) {
+ isArray = token.value == 'Array';
+ advance();
+ if (isArray && token.id == '(' && nexttoken.id == ')')
+ warning("Use the array literal notation [].", token);
+ if (token.led) {
+ left = token.led(left);
+ } else {
+ error("Expected an operator and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ }
+ return left;
+ }
+
+
+// Functions for conformance of style.
+
+ function adjacent(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white) {
+ if (left.character !== right.from && left.line === right.line) {
+ warning("Unexpected space after '{a}'.", right, left.value);
+ }
+ }
+ }
+
+ function nobreak(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white && (left.character !== right.from || left.line !== right.line)) {
+ warning("Unexpected space before '{a}'.", right, right.value);
+ }
+ }
+
+ function nospace(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white && !left.comment) {
+ if (left.line === right.line) {
+ adjacent(left, right);
+ }
+ }
+ }
+
+ function nonadjacent(left, right) {
+ if (option.white) {
+ left = left || token;
+ right = right || nexttoken;
+ if (left.line === right.line && left.character === right.from) {
+ warning("Missing space after '{a}'.",
+ nexttoken, left.value);
+ }
+ }
+ }
+
+ function nobreaknonadjacent(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (!option.laxbreak && left.line !== right.line) {
+ warning("Bad line breaking before '{a}'.", right, right.id);
+ } else if (option.white) {
+ left = left || token;
+ right = right || nexttoken;
+ if (left.character === right.from) {
+ warning("Missing space after '{a}'.",
+ nexttoken, left.value);
+ }
+ }
+ }
+
+ function indentation(bias) {
+ var i;
+ if (option.white && nexttoken.id !== '(end)') {
+ i = indent + (bias || 0);
+ if (nexttoken.from !== i) {
+ warning(
+"Expected '{a}' to have an indentation at {b} instead at {c}.",
+ nexttoken, nexttoken.value, i, nexttoken.from);
+ }
+ }
+ }
+
+ function nolinebreak(t) {
+ t = t || token;
+ if (t.line !== nexttoken.line) {
+ warning("Line breaking error '{a}'.", t, t.value);
+ }
+ }
+
+
+ function comma() {
+ if (token.line !== nexttoken.line) {
+ if (!option.laxbreak) {
+ warning("Bad line breaking before '{a}'.", token, nexttoken.id);
+ }
+ } else if (token.character !== nexttoken.from && option.white) {
+ warning("Unexpected space after '{a}'.", nexttoken, token.value);
+ }
+ advance(',');
+ nonadjacent(token, nexttoken);
+ }
+
+
+// Functional constructors for making the symbols that will be inherited by
+// tokens.
+
+ function symbol(s, p) {
+ var x = syntax[s];
+ if (!x || typeof x !== 'object') {
+ syntax[s] = x = {
+ id: s,
+ lbp: p,
+ value: s
+ };
+ }
+ return x;
+ }
+
+
+ function delim(s) {
+ return symbol(s, 0);
+ }
+
+
+ function stmt(s, f) {
+ var x = delim(s);
+ x.identifier = x.reserved = true;
+ x.fud = f;
+ return x;
+ }
+
+
+ function blockstmt(s, f) {
+ var x = stmt(s, f);
+ x.block = true;
+ return x;
+ }
+
+
+ function reserveName(x) {
+ var c = x.id.charAt(0);
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
+ x.identifier = x.reserved = true;
+ }
+ return x;
+ }
+
+
+ function prefix(s, f) {
+ var x = symbol(s, 150);
+ reserveName(x);
+ x.nud = (typeof f === 'function') ? f : function () {
+ this.right = expression(150);
+ this.arity = 'unary';
+ if (this.id === '++' || this.id === '--') {
+ if (option.plusplus) {
+ warning("Unexpected use of '{a}'.", this, this.id);
+ } else if ((!this.right.identifier || this.right.reserved) &&
+ this.right.id !== '.' && this.right.id !== '[') {
+ warning("Bad operand.", this);
+ }
+ }
+ return this;
+ };
+ return x;
+ }
+
+
+ function type(s, f) {
+ var x = delim(s);
+ x.type = s;
+ x.nud = f;
+ return x;
+ }
+
+
+ function reserve(s, f) {
+ var x = type(s, f);
+ x.identifier = x.reserved = true;
+ return x;
+ }
+
+
+ function reservevar(s, v) {
+ return reserve(s, function () {
+ if (typeof v === 'function') {
+ v(this);
+ }
+ return this;
+ });
+ }
+
+
+ function infix(s, f, p, w) {
+ var x = symbol(s, p);
+ reserveName(x);
+ x.led = function (left) {
+ if (!w) {
+ nobreaknonadjacent(prevtoken, token);
+ nonadjacent(token, nexttoken);
+ }
+ if (typeof f === 'function') {
+ return f(left, this);
+ } else {
+ this.left = left;
+ this.right = expression(p);
+ return this;
+ }
+ };
+ return x;
+ }
+
+
+ function relation(s, f) {
+ var x = symbol(s, 100);
+ x.led = function (left) {
+ nobreaknonadjacent(prevtoken, token);
+ nonadjacent(token, nexttoken);
+ var right = expression(100);
+ if ((left && left.id === 'NaN') || (right && right.id === 'NaN')) {
+ warning("Use the isNaN function to compare with NaN.", this);
+ } else if (f) {
+ f.apply(this, [left, right]);
+ }
+ if (left.id === '!') {
+ warning("Confusing use of '{a}'.", left, '!');
+ }
+ if (right.id === '!') {
+ warning("Confusing use of '{a}'.", left, '!');
+ }
+ this.left = left;
+ this.right = right;
+ return this;
+ };
+ return x;
+ }
+
+
+ function isPoorRelation(node) {
+ return node &&
+ ((node.type === '(number)' && +node.value === 0) ||
+ (node.type === '(string)' && node.value === '') ||
+ (node.type === 'null' && !option.eqnull) ||
+ node.type === 'true' ||
+ node.type === 'false' ||
+ node.type === 'undefined');
+ }
+
+
+ function assignop(s, f) {
+ symbol(s, 20).exps = true;
+ return infix(s, function (left, that) {
+ var l;
+ that.left = left;
+ if (predefined[left.value] === false &&
+ scope[left.value]['(global)'] === true) {
+ warning("Read only.", left);
+ } else if (left['function']) {
+ warning("'{a}' is a function.", left, left.value);
+ }
+ if (left) {
+ if (left.id === '.' || left.id === '[') {
+ if (!left.left || left.left.value === 'arguments') {
+ warning('Bad assignment.', that);
+ }
+ that.right = expression(19);
+ return that;
+ } else if (left.identifier && !left.reserved) {
+ if (funct[left.value] === 'exception') {
+ warning("Do not assign to the exception parameter.", left);
+ }
+ that.right = expression(19);
+ return that;
+ }
+ if (left === syntax['function']) {
+ warning(
+"Expected an identifier in an assignment and instead saw a function invocation.",
+ token);
+ }
+ }
+ error("Bad assignment.", that);
+ }, 20);
+ }
+
+
+ function bitwise(s, f, p) {
+ var x = symbol(s, p);
+ reserveName(x);
+ x.led = (typeof f === 'function') ? f : function (left) {
+ if (option.bitwise) {
+ warning("Unexpected use of '{a}'.", this, this.id);
+ }
+ this.left = left;
+ this.right = expression(p);
+ return this;
+ };
+ return x;
+ }
+
+
+ function bitwiseassignop(s) {
+ symbol(s, 20).exps = true;
+ return infix(s, function (left, that) {
+ if (option.bitwise) {
+ warning("Unexpected use of '{a}'.", that, that.id);
+ }
+ nonadjacent(prevtoken, token);
+ nonadjacent(token, nexttoken);
+ if (left) {
+ if (left.id === '.' || left.id === '[' ||
+ (left.identifier && !left.reserved)) {
+ expression(19);
+ return that;
+ }
+ if (left === syntax['function']) {
+ warning(
+"Expected an identifier in an assignment, and instead saw a function invocation.",
+ token);
+ }
+ return that;
+ }
+ error("Bad assignment.", that);
+ }, 20);
+ }
+
+
+ function suffix(s, f) {
+ var x = symbol(s, 150);
+ x.led = function (left) {
+ if (option.plusplus) {
+ warning("Unexpected use of '{a}'.", this, this.id);
+ } else if ((!left.identifier || left.reserved) &&
+ left.id !== '.' && left.id !== '[') {
+ warning("Bad operand.", this);
+ }
+ this.left = left;
+ return this;
+ };
+ return x;
+ }
+
+
+ // fnparam means that this identifier is being defined as a function
+ // argument (see identifier())
+ function optionalidentifier(fnparam) {
+ if (nexttoken.identifier) {
+ advance();
+ if (token.reserved && !option.es5) {
+ // `undefined` as a function param is a common pattern to protect
+ // against the case when somebody does `undefined = true` and
+ // help with minification. More info: https://gist.github.com/315916
+ if (!fnparam || token.value != 'undefined') {
+ warning("Expected an identifier and instead saw '{a}' (a reserved word).",
+ token, token.id);
+ }
+ }
+ return token.value;
+ }
+ }
+
+ // fnparam means that this identifier is being defined as a function
+ // argument
+ function identifier(fnparam) {
+ var i = optionalidentifier(fnparam);
+ if (i) {
+ return i;
+ }
+ if (token.id === 'function' && nexttoken.id === '(') {
+ warning("Missing name in function declaration.");
+ } else {
+ error("Expected an identifier and instead saw '{a}'.",
+ nexttoken, nexttoken.value);
+ }
+ }
+
+
+ function reachable(s) {
+ var i = 0, t;
+ if (nexttoken.id !== ';' || noreach) {
+ return;
+ }
+ for (;;) {
+ t = peek(i);
+ if (t.reach) {
+ return;
+ }
+ if (t.id !== '(endline)') {
+ if (t.id === 'function') {
+ warning(
+"Inner functions should be listed at the top of the outer function.", t);
+ break;
+ }
+ warning("Unreachable '{a}' after '{b}'.", t, t.value, s);
+ break;
+ }
+ i += 1;
+ }
+ }
+
+
+ function statement(noindent) {
+ var i = indent, r, s = scope, t = nexttoken;
+
+// We don't like the empty statement.
+
+ if (t.id === ';') {
+ warning("Unnecessary semicolon.", t);
+ advance(';');
+ return;
+ }
+
+// Is this a labelled statement?
+
+ if (t.identifier && !t.reserved && peek().id === ':') {
+ advance();
+ advance(':');
+ scope = Object.create(s);
+ addlabel(t.value, 'label');
+ if (!nexttoken.labelled) {
+ warning("Label '{a}' on {b} statement.",
+ nexttoken, t.value, nexttoken.value);
+ }
+ if (jx.test(t.value + ':')) {
+ warning("Label '{a}' looks like a javascript url.",
+ t, t.value);
+ }
+ nexttoken.label = t.value;
+ t = nexttoken;
+ }
+
+// Parse the statement.
+
+ if (!noindent) {
+ indentation();
+ }
+ r = expression(0, true);
+
+// Look for the final semicolon.
+
+ if (!t.block) {
+ if (!option.expr && (!r || !r.exps)) {
+ warning("Expected an assignment or function call and instead saw an expression.", token);
+ } else if (option.nonew && r.id === '(' && r.left.id === 'new') {
+ warning("Do not use 'new' for side effects.");
+ }
+ if (nexttoken.id !== ';') {
+ if (!option.asi) {
+ warningAt("Missing semicolon.", token.line, token.from + token.value.length);
+ }
+ } else {
+ adjacent(token, nexttoken);
+ advance(';');
+ nonadjacent(token, nexttoken);
+ }
+ }
+
+// Restore the indentation.
+
+ indent = i;
+ scope = s;
+ return r;
+ }
+
+
+ function use_strict() {
+ if (nexttoken.value === 'use strict') {
+ if (strict_mode) {
+ warning("Unnecessary \"use strict\".");
+ }
+ advance();
+ advance(';');
+ strict_mode = true;
+ option.newcap = true;
+ option.undef = true;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ function statements(begin) {
+ var a = [], f, p;
+
+ while (!nexttoken.reach && nexttoken.id !== '(end)') {
+ if (nexttoken.id === ';') {
+ warning("Unnecessary semicolon.");
+ advance(';');
+ } else {
+ a.push(statement());
+ }
+ }
+ return a;
+ }
+
+
+ /*
+ * Parses a single block. A block is a sequence of statements wrapped in
+ * braces.
+ *
+ * ordinary - true for everything but function bodies and try blocks.
+ * stmt - true if block can be a single statement (e.g. in if/for/while).
+ */
+ function block(ordinary, stmt) {
+ var a,
+ b = inblock,
+ old_indent = indent,
+ m = strict_mode,
+ s = scope,
+ t;
+
+ inblock = ordinary;
+ scope = Object.create(scope);
+ nonadjacent(token, nexttoken);
+ t = nexttoken;
+
+ if (nexttoken.id === '{') {
+ advance('{');
+ if (nexttoken.id !== '}' || token.line !== nexttoken.line) {
+ indent += option.indent;
+ while (!ordinary && nexttoken.from > indent) {
+ indent += option.indent;
+ }
+ if (!ordinary && !use_strict() && !m && option.strict &&
+ funct['(context)']['(global)']) {
+ warning("Missing \"use strict\" statement.");
+ }
+ a = statements();
+ strict_mode = m;
+ indent -= option.indent;
+ indentation();
+ }
+ advance('}', t);
+ indent = old_indent;
+ } else if (!ordinary) {
+ error("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, '{', nexttoken.value);
+ } else {
+ if (!stmt || option.curly)
+ warning("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, '{', nexttoken.value);
+
+ noreach = true;
+ a = [statement()];
+ noreach = false;
+ }
+ funct['(verb)'] = null;
+ scope = s;
+ inblock = b;
+ if (ordinary && option.noempty && (!a || a.length === 0)) {
+ warning("Empty block.");
+ }
+ return a;
+ }
+
+
+ function countMember(m) {
+ if (membersOnly && typeof membersOnly[m] !== 'boolean') {
+ warning("Unexpected /*member '{a}'.", token, m);
+ }
+ if (typeof member[m] === 'number') {
+ member[m] += 1;
+ } else {
+ member[m] = 1;
+ }
+ }
+
+
+ function note_implied(token) {
+ var name = token.value, line = token.line, a = implied[name];
+ if (typeof a === 'function') {
+ a = false;
+ }
+ if (!a) {
+ a = [line];
+ implied[name] = a;
+ } else if (a[a.length - 1] !== line) {
+ a.push(line);
+ }
+ }
+
+// Build the syntax table by declaring the syntactic elements of the language.
+
+ type('(number)', function () {
+ return this;
+ });
+ type('(string)', function () {
+ return this;
+ });
+
+ syntax['(identifier)'] = {
+ type: '(identifier)',
+ lbp: 0,
+ identifier: true,
+ nud: function () {
+ var v = this.value,
+ s = scope[v],
+ f;
+ if (typeof s === 'function') {
+
+// Protection against accidental inheritance.
+
+ s = undefined;
+ } else if (typeof s === 'boolean') {
+ f = funct;
+ funct = functions[0];
+ addlabel(v, 'var');
+ s = funct;
+ funct = f;
+ }
+
+// The name is in scope and defined in the current function.
+
+ if (funct === s) {
+
+// Change 'unused' to 'var', and reject labels.
+
+ switch (funct[v]) {
+ case 'unused':
+ funct[v] = 'var';
+ break;
+ case 'unction':
+ funct[v] = 'function';
+ this['function'] = true;
+ break;
+ case 'function':
+ this['function'] = true;
+ break;
+ case 'label':
+ warning("'{a}' is a statement label.", token, v);
+ break;
+ }
+
+// The name is not defined in the function. If we are in the global scope,
+// then we have an undefined variable.
+//
+// Operators typeof and delete do not raise runtime errors even if the base
+// object of a reference is null so no need to display warning if we're
+// inside of typeof or delete.
+
+ } else if (funct['(global)']) {
+ if (anonname != 'typeof' && anonname != 'delete' &&
+ option.undef && typeof predefined[v] !== 'boolean') {
+ warning("'{a}' is not defined.", token, v);
+ }
+ note_implied(token);
+
+// If the name is already defined in the current
+// function
<TRUNCATED>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[38/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/jquery-1.6.1.min.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/jquery-1.6.1.min.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/jquery-1.6.1.min.js
new file mode 100644
index 0000000..b2ac174
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/jquery-1.6.1.min.js
@@ -0,0 +1,18 @@
+/*!
+ * jQuery JavaScript Library v1.6.1
+ * http://jquery.com/
+ *
+ * Copyright 2011, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2011, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Thu May 12 15:04:36 2011 -0400
+ */
+(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!cj[a]){var b=f("<"+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),c.body.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write("<!doctype><html><body></body></html>");b=cl.createElement(a),cl.body.appendChild(b),d=f.css(b,"display"),c.body.removeChild(ck)}cj[a]=d}return cj[a]}function cu(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function ct(){cq=b}function cs(){setTimeout(ct,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h
in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function ca(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function b_(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bF.test(a)?d(a,e):b_(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)b_(a+"["+e+"]",b[e],c,d);els
e d(a,b)}function b$(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bU,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=b$(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=b$(a,c,d,e,"*",g));return l}function bZ(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bQ),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bD(a,b,c){var d=b==="width"?bx:by,e=b==="width"?a.offsetWidth:a.offsetHeight;if(c==="border")return e;f.each(d,function(){c||(e-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?e+=parseFloat(f.css(a,"margin"+this))||0:e-=parseFloat(f.css(a,"border"+this+"Width"))||0});return e}function bn(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bf,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)
}function bm(a){f.nodeName(a,"input")?bl(a):a.getElementsByTagName&&f.grep(a.getElementsByTagName("input"),bl)}function bl(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bk(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bj(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bi(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(v
ar i=0,j=g[h].length;i<j;i++)f.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function bh(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function X(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(S.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function W(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function O(a,b){return(a&&a!=="*"?a+".":"")+b.replace(A,"`").replace(B,"&")}function N(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\
\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;i<s.length;i++)g=s[i],g.origType.replace(y,"")===a.type?q.push(g.selector):s.splice(i--,1);e=f(a.target).closest(q,a.currentTarget);for(j=0,k=e.length;j<k;j++){m=e[j];for(i=0;i<s.length;i++){g=s[i];if(m.selector===g.selector&&(!n||n.test(g.namespace))&&!m.elem.disabled){h=m.elem,d=null;if(g.preType==="mouseenter"||g.preType==="mouseleave")a.type=g.preType,d=f(a.relatedTarget).closest(g.selector)[0],d&&f.contains(h,d)&&(d=h);(!d||d!==h)&&p.push({elem:h,handleObj:g,level:m.level})}}}for(j=0,k=p.length;j<k;j++){e=p[j];if(c&&e.level>c)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function L(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefaul
t()}function F(){return!0}function E(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function H(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(H,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,
p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=d.userAgent,x,y,z,A=Object.prototype.toString,B=Object.prototype.hasOwnProperty,C=Array.prototype.push,D=Array.prototype.slice,E=String.prototype.trim,F=Array.prototype.indexOf,G={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment(
[g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.1",length:0,size:function(){return this.length},toArray:function(){return D.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?C.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),y.done(a);return this},eq:function(a){return a===
-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(D.apply(this,arguments),"slice",D.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:C,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:fu
nction(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;y.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!y){y=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",z,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",z),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&H()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):G[A.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type
(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!B.call(a,"constructor")&&!B.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||B.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,
c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:E?function(a){return a==null?"":E.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?C.call(c,a):e.merge(c,a)}return c},inArray:function(a,b){if(F)return F.call(b,a);for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanc
eof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=D.call(arguments,2),g=function(){return a.apply(c,f.concat(D.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)e.access(a,j,c[j],f,g,d);return a}if(d!==b){f=!h&&f&&e.isFunction(d);for(var k=0;k<i;k++)g(a[k],c,f?d.call(a[k],k,g(a[k],c)):d,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=s.exec(a)||t.exec(a)||u.exec(a)||a.indexOf("compatible")<0&&v.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=
a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){G["[object "+b+"]"]=b.toLowerCase()}),x=e.uaMatch(w),x.browser&&(e.browser[x.browser]=!0,e.browser.version=x.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?z=function(){c.removeEventListener("DOMContentLoaded",z,!1),e.ready()}:c.attachEvent&&(z=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",z),e.ready())});return e}(),g="done fail isResolved isRejected promise then always pipe".split(" "),h=[].slice;f.extend({_Deferred:function(){var a=[],b,c,d,e={done:function(){if(!d){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=f.type(i),j==="array"?e.done.apply(e,i
):j==="function"&&a.push(i);k&&e.resolveWith(k[0],k[1])}return this},resolveWith:function(e,f){if(!d&&!b&&!c){f=f||[],c=1;try{while(a[0])a.shift().apply(e,f)}finally{b=[e,f],c=0}}return this},resolve:function(){e.resolveWith(this,arguments);return this},isResolved:function(){return!!c||!!b},cancel:function(){d=1,a=[];return this}};return e},Deferred:function(a){var b=f._Deferred(),c=f._Deferred(),d;f.extend(b,{then:function(a,c){b.done(a).fail(c);return this},always:function(){return b.done.apply(b,arguments).fail.apply(this,arguments)},fail:c.done,rejectWith:c.resolveWith,reject:c.resolve,isRejected:c.isResolved,pipe:function(a,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[c,"reject"]},function(a,c){var e=c[0],g=c[1],h;f.isFunction(e)?b[a](function(){h=e.apply(this,arguments),h&&f.isFunction(h.promise)?h.promise().then(d.resolve,d.reject):d[g](h)}):b[a](d[g])})}).promise()},promise:function(a){if(a==null){if(d)return d;d=a={}}var c=g.length;while(c--)a[g[c]]=b[g
[c]];return a}}),b.done(c.cancel).fail(b.cancel),delete b.cancel,a&&a.call(b,b);return b},when:function(a){function i(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c<d;c++)b[c]&&f.isFunction(b[c].promise)?b[c].promise().then(i(c),g.reject):--e;e||g.resolveWith(g,b)}else g!==a&&g.resolveWith(g,d?[a]:[]);return g.promise()}}),f.support=function(){var a=c.createElement("div"),b=c.documentElement,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;a.setAttribute("className","t"),a.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};f=c.createElement("select"),g=f.appendChild(c.createElement("option")),h=a.getElementsByTagName("input")[0],j={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getEl
ementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},h.checked=!0,j.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,j.optDisabled=!g.disabled;try{delete a.test}catch(s){j.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function b(){j.noCloneEvent=!1,a.detachEvent("onclick",b)}),a.cloneNode(!0).fireEvent("onclick")),h=c.createElement("input"),h.value="t",h.setAttribute("type","radio"),j.radioValue=h.value==="t",h.setAttribute("checked","checked"),a.appendChild(h),k=c.createDocumentFragment(),k.appendChild(a.firstChild),j.c
heckClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",l=c.createElement("body"),m={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};for(q in m)l.style[q]=m[q];l.appendChild(a),b.insertBefore(l,b.firstChild),j.appendChecked=h.checked,j.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,j.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="<div style='width:4px;'></div>",j.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>",n=a.getElementsByTagName("td"),r=n[0].offsetHeight===0,n[0].style.display="",n[1].style.display="none",j.reliableHiddenOffsets=r&&n[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(i=c.createElement("div"),i.style.width="0",i.style.marginRight="0",a.appendChild(i),j.reliableMarginRight=(parseInt((c.defaultView.get
ComputedStyle(i,null)||{marginRight:0}).marginRight,10)||0)===0),l.innerHTML="",b.removeChild(l);if(a.attachEvent)for(q in{submit:1,change:1,focusin:1})p="on"+q,r=p in a,r||(a.setAttribute(p,"return;"),r=typeof a[p]=="function"),j[q+"Bubbles"]=r;return j}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g])
,d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h<i;h++)g=e[h].name,g.indexOf("data-")===0&&(g=f.camelCas
e(g.substring(5)),k(this[0],g,d[g]))}}return d}if(typeof a=="object")return this.each(function(){f.data(this,a)});var j=a.split(".");j[1]=j[1]?"."+j[1]:"";if(c===b){d=this.triggerHandler("getData"+j[1]+"!",[j[0]]),d===b&&this.length&&(d=f.data(this[0],a),d=k(this[0],a,d));return d===b&&j[1]?this.data(j[0]):d}return this.each(function(){var b=f(this),d=[j[0],c];b.triggerHandler("setData"+j[1]+"!",d),f.data(this,a,c),b.triggerHandler("changeData"+j[1]+"!",d)})},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,c){a&&(c=(c||"fx")+"mark",f.data(a,c,(f.data(a,c,b,!0)||0)+1,!0))},_unmark:function(a,c,d){a!==!0&&(d=c,c=a,a=!1);if(c){d=d||"fx";var e=d+"mark",g=a?0:(f.data(c,e,b,!0)||1)-1;g?f.data(c,e,g,!0):(f.removeData(c,e,!0),m(c,d,"mark"))}},queue:function(a,c,d){if(a){c=(c||"fx")+"queue";var e=f.data(a,c,b,!0);d&&(!e||f.isArray(d)?e=f.data(a,c,f.makeArray(d),!0):e.push(d));return e||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(
a,b),d=c.shift(),e;d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),d.call(a,function(){f.dequeue(a,b)})),c.length||(f.removeData(a,b+"queue",!0),m(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){typeof a!="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(){var c=this;setTimeout(function(){f.dequeue(c,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f._Deferred(),!0))h++,l.done(m);m();return d.promise()}});var n=/[\
n\t\r]/g,o=/\s+/,p=/\r/g,q=/^(?:button|input)$/i,r=/^(?:button|input|object|select|textarea)$/i,s=/^a(?:rea)?$/i,t=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,u=/\:/,v,w;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,a,b,!0,f.prop)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.addClass(a.call(this,b,c.attr("class")||""))});if(a&&typeof a=="string"){var b=(a||"").split(o);for(var c=0,d=this.length;c<d;c++){var e=this[c];if(e.nodeType===1)if(!e.className)e.className=a;else{var g=" "+e.className+" ",h=e.className;for(var i=0,j=b.length;i<j;i++)g.indexOf(" "+b[i]+" ")<0&&(h+=" "+b[i]);e.className=f.trim(h)}}}return this},r
emoveClass:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.removeClass(a.call(this,b,c.attr("class")))});if(a&&typeof a=="string"||a===b){var c=(a||"").split(o);for(var d=0,e=this.length;d<e;d++){var g=this[d];if(g.nodeType===1&&g.className)if(a){var h=(" "+g.className+" ").replace(n," ");for(var i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){var d=f(this);d.toggleClass(a.call(this,c,d.attr("class"),b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(o);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ";for(var c=0,d=this.
length;c<d;c++)if((" "+this[c].className+" ").replace(n," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;return(e.value||"").replace(p,"")}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h<i;h++){var j=e[h];if(j.selected&&(f.support.optDisabled?!j.disabled:j.getAttribute("d
isabled")===null)&&(!j.parentNode.disabled||!f.nodeName(j.parentNode,"optgroup"))){b=f(j).val();if(g)return b;d.push(b)}}if(g&&!d.length&&e.length)return f(e[c]).val();return d},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);c=j&&f.attrFix[c]||c,i=f.attrHooks[c],i||(!t.test(c)||typeof d!="boolean"&&d!==b&&d.toLowerCase()!==c.toLowerCase()?v&&(f.nodeName(a,"form")||u.test(c))&&(i=v):i=w);if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j)return i.get(a,c);h=a.getAttribute(c);ret
urn h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var
g,h,i=e!==1||!f.isXMLDoc(a);c=i&&f.propFix[c]||c,h=f.propHooks[c];return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),w={get:function(a,c){return a[f.propFix[c]||c]?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=b),a.setAttribute(c,c.toLowerCase()));return c}},f.attrHooks.value={get:function(a,b){if(v&&f.nodeName(a,"button"))return v.get(a,b);return a.value},set:function(a,b,c){if(v&&f.nodeName(a,"button"))return v.set(a,b,c);a.value=b}},f.support.getSetAttribute||(f.attrFix=f.propFix,v=f.attrHooks.name=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each
(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var x=Object.prototype.hasOwnProperty,y=/\.(.*)$/,z=/^(?:textarea|input|select)$/i,A=/\./g,B=/ /g,C=/[^\w\s.|`]/g,D=function(a){return a.replace(C,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.no
deType!==8){if(d===!1)d=E;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=E);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)re
turn;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),D).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j<p.length;j++){q=p[j];if(l||n.test(q.namespace))f.event.remove(a,r,q.handler,j),p.splice(j--,1)}continue}o=f.event.special[h]||{};for(j=e||0;j<p.length;j++){q=p[j];if(d.guid===q.guid){if(l||n.test(q.namespace))e==null&&p.splice(j--,1),o.remove&&o.remove.call(a,q);if(e!=null)break}}if(p.length===0||e!=null&&p.length===1)(!o.teardown||o.teardown.call(a,m)===!1)&&f.removeEvent(a,h,s.handle),g=null,delete t[h]}if(f.isEmptyObject(t)){var u=s.handle;u&&(u.elem=null),delete s.events,delete s.handle,f.isEmptyObject(s)&&f.removeData(a,b,!0)}}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){var h=c.type||c,i=[],j;h.ind
exOf("!")>=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem
+)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h<i;h++){var j=d[h];if(e||c.namespace_re.test(j.namespace)){c.handler=j.handler,c.data=j
.data,c.handleObj=j;var k=j.handler.apply(this,g);k!==b&&(c.result=k,k===!1&&(c.preventDefault(),c.stopPropagation()));if(c.isImmediatePropagationStopped())break}}return c.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[f.expando])return a;var d=a;a=f.Event(d);for(var e=this.props.length,g;e;)g=this.props[--e],a[g]=d[g];a.target||(a.target=a.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement);if(a.pageX==null&&a.clientX!=null){var h=a.target.ownerDocument||c,i=h.documentElement,j=h.body;a.pageX=a.clientX+(i&&i.scrollLeft||j&&j.scrollLeft||0)-(i&&i.cli
entLeft||j&&j.clientLeft||0),a.pageY=a.clientY+(i&&i.scrollTop||j&&j.scrollTop||0)-(i&&i.clientTop||j&&j.clientTop||0)}a.which==null&&(a.charCode!=null||a.keyCode!=null)&&(a.which=a.charCode!=null?a.charCode:a.keyCode),!a.metaKey&&a.ctrlKey&&(a.metaKey=a.ctrlKey),!a.which&&a.button!==b&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a},guid:1e8,proxy:f.proxy,special:{ready:{setup:f.bindReady,teardown:f.noop},live:{add:function(a){f.event.add(this,O(a.origType,a.selector),f.extend({},a,{handler:N,guid:a.handler.guid}))},remove:function(a){f.event.remove(this,O(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}}},f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!this.preventDefault)return new f.Event(a,b);a&
&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?F:E):this.type=a,b&&f.extend(this,b),this.timeStamp=f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=F;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=F;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=F,this.stopPropagation()},isDefaultPrevented:E,isPropagationStopped:E,isImmediatePropagationStopped:E};var G=function(a){var b=a.relatedTarget;a.type=a.data;try{if(b&&b!==c&&!b.parentNode)return;while(b&&b!==this)b=b.parentNode;b!==this&&f.event.handle.apply(this,arguments)}catch(d){}},H=function(a){a.type=a.data,f.event.handle.apply(this,arguments)};f.each({mouseenter:"mouseover",mouselea
ve:"mouseout"},function(a,b){f.event.special[a]={setup:function(c){f.event.add(this,b,c&&c.selector?H:G,a)},teardown:function(a){f.event.remove(this,b,a&&a.selector?H:G)}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(a,b){if(!f.nodeName(this,"form"))f.event.add(this,"click.specialSubmit",function(a){var b=a.target,c=b.type;(c==="submit"||c==="image")&&f(b).closest("form").length&&L("submit",this,arguments)}),f.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,c=b.type;(c==="text"||c==="password")&&f(b).closest("form").length&&a.keyCode===13&&L("submit",this,arguments)});else return!1},teardown:function(a){f.event.remove(this,".specialSubmit")}});if(!f.support.changeBubbles){var I,J=function(a){var b=a.type,c=a.value;b==="radio"||b==="checkbox"?c=a.checked:b==="select-multiple"?c=a.selectedIndex>-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},K=function(c){var d=c.target,e,g;i
f(!!z.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=J(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:K,beforedeactivate:K,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&K.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&K.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",J(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in I)f.event.add(this,c+".specialChange",I[c]);return z.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return z.test(this.nodeName)}},I=f.event.special.change.filters,I.focus=I.before
activate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i<j;i++)f.event.add(this[i],a,g,d);return this}}),f.fn.extend({unbind:function(a,b){if(typeof a=="object"&&!a.preventDefault)for(var c in a)this.unbind(c,a[c]);else for(var d=0,e=this.length;d<e;d++)f.event.remove(this[d],a,b);return this},delegate:function(a,b,c,d){
return this.live(b,c,d,a)},undelegate:function(a,b,c){return arguments.length===0?this.unbind("live"):this.die(b,null,c,a)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f.data(this,"lastToggle"+a.guid)||0)%d;f.data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var M={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};f.each(["live","die"],function(a,c){f.fn[c]=function(a,d,e,g){var h,i=0,j,k,l,m=g||this.selector,n=g?this:f(this.context);if(typeof a=="object"&&!a.preventDefault){for(var o in a)n[c](o,d,a[o],m);return this}if(c==="die"&&!a&&g&&g.charAt(0)==="."){n.unbind(g);return this}if(d===!1||f.isF
unction(d))e=d||E,d=b;a=(a||"").split(" ");while((h=a[i++])!=null){j=y.exec(h),k="",j&&(k=j[0],h=h.replace(y,""));if(h==="hover"){a.push("mouseenter"+k,"mouseleave"+k);continue}l=h,M[h]?(a.push(M[h]+k),h=h+k):h=(M[h]||h)+k;if(c==="live")for(var p=0,q=n.length;p<q;p++)f.event.add(n[p],"live."+O(h,m),{data:d,selector:m,handler:e,origType:h,origHandler:e,preType:l});else n.unbind("live."+O(h,m),e)}return this}}),f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}if(i.nodeType===1){f||(i.sizcache=c,i.sizset=g);if(typeof b!="string"){if(i===b){
j=!0;break}}else if(k.filter(b,[i]).length>0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}i.nodeType===1&&!f&&(i.sizcache=c,i.sizset=g);if(i.nodeName.toLowerCase()===b){j=i;break}i=i[a]}d[g]=j}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{
!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},k.matches=function(a,b){return k(a,null,null,b)},k.matchesSelector=function(a,b){return k(b,null,null,[a]).l
ength>0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e<f;e++){var g,h=l.order[e];if(g=l.leftMatch[h].exec(a)){var j=g[1];g.splice(1,1);if(j.substr(j.length-1)!=="\\"){g[1]=(g[1]||"").replace(i,""),d=l.find[h](g,b,c);if(d!=null){a=a.replace(l.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},k.filter=function(a,c,d,e){var f,g,h=a,i=[],j=c,m=c&&c[0]&&k.isXML(c[0]);while(a&&c.length){for(var n in l.filter)if((f=l.leftMatch[n].exec(a))!=null&&f[2]){var o,p,q=l.filter[n],r=f[1];g=!1,f.splice(1,1);if(r.substr(r.length-1)==="\\")continue;j===i&&(i=[]);if(l.preFilter[n]){f=l.preFilter[n](f,j,d,i,e,m);if(!f)g=o=!0;else if(f===!0)continue}if(f)for(var s=0;(p=j[s])!=null;s++)if(p){o=q(p,f,s,j);var t=e^!!o;d&&o!=null?t?g=!0:j[s]=!1:t&&(i.push(p),g=!0)}if(o!==b){d||(j=i),a=a.replace(l.match[n],"");if(!g)return[];break}}if(a===h)if(g==null)k.error(a);else break;h=a}return j},k.error=function(a)
{throw"Syntax error, unrecognized expression: "+a};var l=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!j.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)
&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&k.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&k.filter(b,a,!0)}},"":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("parentNode",b,f,a,e,c)},"~":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("previousSibling",b,f,a,e,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTa
gName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(i,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,
!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()
==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerT
ext||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}k.error(e)},CHILD:function(a,b){var c=b[1],d=a;switch(c){case"only":case"first":while(d=d.previousSibling)if(d.nodeType===1)return!1;if(c==="first")return!0;d=a;case"last":while(d=d.nextSibling)if(d.nodeType===1)return!1;return!0;case"nth":var e=b[2],f=b[3];if(e===1&&f===0)return!0;var g=b[0],h=a.parentNode;if(h&&(h.sizcache!==g||!a.nodeIndex)){var i=0;for(d=h.firstChild;d;d=d.nextSibling)d.nodeType===1&&(d.nodeIndex=++i);h.sizcache=g}var j=a.nodeIndex-f;return e===0?j===0:j%e===0&&j/e>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?
f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c<f;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var r,s;c.documentElement.compareDocumentPosition?r=function
(a,b){if(a===b){g=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(r=function(a,b){if(a===b){g=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],h=a.parentNode,i=b.parentNode,j=h;if(h===i)return s(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return s(e[k],f[k]);return k===c?s(a,f[k],-1):s(e[k],b,1)},s=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),k.getText=function(a){var b="",c;for(var d=0;a[d];d++)c=a[d],c.nodeType===3||c.nodeType===4?b+=c.nodeValue:c.nodeType!==8&&(b+=k.getText(c.childNodes));return b},function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.fi
rstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST
'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.
mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentP
osition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g<h;g++)k(a,f[g],d);return k.filter(e,d)};f.find=k,f.expr=k.selectors,f.expr[":"]=f.expr.filters,f.unique=k.uniqueSort,f.text=k.getText,f.isXMLDoc=k.isXML,f.contains=k.contains}();var P=/Until$/,Q=/^(?:parents|prevUntil|prevAll)/,R=/,/,S=/^.[^:#\[\.,]*$/,T=Array.prototype.slice,U=f.expr.match.POS,V={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=
g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(X(this,a,!1),"not",a)},filter:function(a){return this.pushStack(X(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d<e;d++)i=a[d],j[i]||(j[i]=U.test(i)?f(i,b||this.context):i);while(g&&g.ownerDocument&&g!==b){for(i in j)h=j[i],(h.jquery?h.index(g)>-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=U.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(l?l.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)
break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(W(c[0])||W(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.par
entNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=T.call(arguments);P.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!V[a]?f.unique(e):e,(this.length>1||R.test(d))&&Q.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var Y=/ jQuery\d+="(?:\d+|null)"/g,Z=/^\s+/,$=/<(?!area|br
|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,_=/<([\w:]+)/,ba=/<tbody/i,bb=/<|&#?\w+;/,bc=/<(?:script|object|embed|option|style)/i,bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*<!(?:\[CDATA\[|\-\-)/,bg={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function
(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return t
his.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0
]&&this[0].nodeType===1?this[0].innerHTML.replace(Y,""):null;if(typeof a=="string"&&!bc.test(a)&&(f.support.leadingWhitespace||!Z.test(a))&&!bg[(_.exec(a)||["",""])[1].toLowerCase()]){a=a.replace($,"<$1></$2>");try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else f.isFunction(a)?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];
if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bd.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bh(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,bn)}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i=b&&b[0]?b[0].ownerDocument||b[0]:c;a.length===1&&typeof a[0]=="string"&&a[0].length<512&&i===c&&a[0].charAt(0)==="<"&&!bc.test(a[0])&&(f.support.checkClone||!bd.test(a[0]))&&(g=!0,h=f.fragments[a[0]],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[a[0]]=h?e:1);return
{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bj(a,d),e=bk(a),g=bk(d);for(h=0;e[h];++h)bj(e[h],g[h])}if(b){bi(a,d);if(c){e=bk(a),g=bk(d);for(h=0;e[h];++h)bi(e[h],g[h])}}return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||
+b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!bb.test(k))k=b.createTextNode(k);else{k=k.replace($,"<$1></$2>");var l=(_.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=ba.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]==="<table>"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Z.test(k)&&o.insertBefore(b.createTextNode(Z.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i<r;i++)bm(k[i]);else bm(k);k.nodeType?h.push(k):h=f.merge(h,k)}if(d){g=function(a){return!a.type||be.test(a.type)};for(j=0;h[j];j++)if(e&&f.nodeName(h[j],"script")&&(!h[j].type||h[j].type.toLowerCase()===
"text/javascript"))e.push(h[j].parentNode?h[j].parentNode.removeChild(h[j]):h[j]);else{if(h[j].nodeType===1){var s=f.grep(h[j].getElementsByTagName("script"),g);h.splice.apply(h,[j+1,0].concat(s))}d.appendChild(h[j])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.expando,g=f.event.special,h=f.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&f.noData[j.nodeName.toLowerCase()])continue;c=j[f.expando];if(c){b=d[c]&&d[c][e];if(b&&b.events){for(var k in b.events)g[k]?f.event.remove(j,k):f.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[f.expando]:j.removeAttribute&&j.removeAttribute(f.expando),delete d[c]}}}});var bo=/alpha\([^)]*\)/i,bp=/opacity=([^)]*)/,bq=/-([a-z])/ig,br=/([A-Z]|^ms)/g,bs=/^-?\d+(?:px)?$/i,bt=/^-?\d/,bu=/^[+\-]=/,bv=/[^+\-\.\de]+/g,bw={position:"absolute",visibility:"hidden",display:"block"},bx=["Left","Right"],by=["Top","Bottom"],bz,bA,bB,bC=function(a,b){return b.toUpperCase()};f.fn.css=function(a,c){if(arguments.len
gth===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)})},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bz(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{zIndex:!0,fontWeight:!0,opacity:!0,zoom:!0,lineHeight:!0,widows:!0,orphans:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d;if(h==="number"&&isNaN(d)||d==null)return;h==="string"&&bu.test(d)&&(d=+d.replace(bv,"")+parseFloat(f.css(a,c))),h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;i
f(bz)return bz(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]},camelCase:function(a){return a.replace(bq,bC)}}),f.curCSS=f.css,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){var e;if(c){a.offsetWidth!==0?e=bD(a,b,d):f.swap(a,bw,function(){e=bD(a,b,d)});if(e<=0){e=bz(a,b,b),e==="0px"&&bB&&(e=bB(a,b,b));if(e!=null)return e===""||e==="auto"?"0px":e}if(e<0||e==null){e=a.style[b];return e===""||e==="auto"?"0px":e}return typeof e=="string"?e:e+"px"}},set:function(a,b){if(!bs.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bp.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bo.test(g)?g.replace(bo,e):g+" "+e}}),f(functio
n(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,c){var d,e,g;c=c.replace(br,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bs.test(d)&&bt.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a
.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bE=/%20/g,bF=/\[\]$/,bG=/\r?\n/g,bH=/#.*$/,bI=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bJ=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bK=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bL=/^(?:GET|HEAD)$/,bM=/^\/\//,bN=/\?/,bO=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bP=/^(?:select|textarea)/i,bQ=/\s+/,bR=/([?&])_=[^&]*/,bS=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bT=f.fn.load,bU={},bV={},bW,bX;try{bW=e.href}catch(bY){bW=c.createElement("a"),bW.href="",bW=bW.href}bX=bS.exec(bW.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bT)return bT.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="PO
ST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bO,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bP.test(this.nodeName)||bJ.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bG,"\r\n")}}):{name:b.name,value:c.replace(bG,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dat
aType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bW,isLocal:bK.test(bX[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bZ(bU),ajaxTransport:bZ(bV),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?ca(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifMo
dified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=cb(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bI.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCa
se()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bH,"").replace(bM,bX[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bQ),d.crossDomain==null&&(r=bS.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bX[1]&&r[2]==bX[2]&&(r[3]||(r[1]==="http:"?80:443))==(bX[3]||(bX[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bU,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bL.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bN.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bR,"$1_="+x);d.url=y
+(y===d.url?(bN.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bV,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"=
"+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bE,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g|
|f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,
1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o
){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq,cr=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),e===""&&f.css(d,"display")==="none"&&f._data(d,"olddisplay",cv(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||"
"}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(cu("hide",3),a,b,c);for(var d=0,e=this.length;d<e;d++)if(this[d].style){var g=f.css(this[d],"display");g!=="none"&&!f._data(this[d],"olddisplay")&&f._data(this[d],"olddisplay",g)}for(d=0;d<e;d++)this[d].style&&(this[d].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(cu("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return this[e.queue===!1?"each":"queue"](function(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n
,o;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]),h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(f.support.inlineBlockNeedsLayout?(j=cv(this.nodeName),j==="inline"?this.style.display="inline-block":(this.style.display="inline",this.style.zoom=1)):this.style.display="inline-block"))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)k=new f.fx(this,b,i),h=a[i],cm.test(h)?k[h==="toggle"?d?"show":"hide":h]():(l=cn.exec(h),m=k.cur(),l?(n=parseFloat(l[2]),o=l[3]||(f.cssNumber[i]?"":"px"),o!=="px"&&(f.style(this,i,(n||1)+o),m=(n||1)/k.cur()*m,f.style(this,i,m+o)),l[1]&&(n=(l[1]==="-="?-1:1)*n+m),k.custom(m,n,o)):k.custo
m(m,h,""));return!0})},stop:function(a,b){a&&this.queue([]),this.each(function(){var a=f.timers,c=a.length;b||f._unmark(!0,this);while(c--)a[c].elem===this&&(b&&a[c](!0),a.splice(c,1))}),b||this.dequeue();return this}}),f.each({slideDown:cu("show",1),slideUp:cu("hide",1),slideToggle:cu("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default,d.old=d.complete,d.complete=function(a){d.queue!==!1?f.dequeue(this):a!==!1&&f._unmark(this),f.isFunction(d.old)&&d.old.call(this)};return d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},t
imers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,b,c){function h(a){return d.step(a)}var d=this,e=f.fx,g;this.startTime=cq||cs(),this.start=a,this.end=b,this.unit=c||this.unit||(f.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,h.elem=this.elem,h()&&f.timers.push(h)&&!co&&(cr?(co=1,g=function(){co&&(cr(g),e.tick())},cr(g)):co=setInterval(e.tick,e.interval))},show:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide
:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b=cq||cs(),c=!0,d=this.elem,e=this.options,g,h;if(a||b>=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b<a.length;++b)a[b]()||a.splice(b--,1);a.length||f.fx.stop()},interval:13,stop:funct
ion(){clearInterval(co),co=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit:a.elem[a.prop]=a.now}}}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cw=/^t(?:able|d|h)$/i,cx=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?f.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(d){}var e=b.ownerDocument,g=e.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=e.body,i=cy(e),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||f.support.boxMod
el&&g.scrollTop||h.scrollTop,m=i.pageXOffset||f.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:f.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);f.offset.initialize();var c,d=b.offsetParent,e=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(f.offset.supportsFixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===d&&(l+=b.offsetTop,m+=b.offsetLeft,f.offset.doesNotAddBorder&&(!f.offset.doesAddBorderForTableAndCells||!cw.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),f.offset.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&
&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;f.offset.supportsFixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},f.offset={initialize:function(){var a=c.body,b=c.createElement("div"),d,e,g,h,i=parseFloat(f.css(a,"marginTop"))||0,j="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.
doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.over
<TRUNCATED>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[33/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-dom.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-dom.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-dom.js
new file mode 100644
index 0000000..9206561
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-dom.js
@@ -0,0 +1,329 @@
+var assert = require("assert"),
+ utils = require("./utils");
+
+var doc;
+var DOM;
+var node;
+var firstNode;
+var lastNode;
+
+before(function(done) {
+ utils.loadTab('dom.html', function(aTab) {
+ DOM = aTab.DOM;
+ DOM.document(function(err, aDoc) {
+ doc = aDoc;
+ DOM.querySelectorAll(".item", function(err, list) {
+ list.items(function(err, items) {
+ firstNode = items[0];
+ node = items[1];
+ lastNode = items[2];
+ done();
+ })
+ })
+ })
+ });
+});
+
+// DOM - document(), documentElement()
+
+describe('document()', function() {
+ it('should get document node', function(done) {
+ DOM.document(function(err, doc) {
+ assert.strictEqual(err, null);
+ assert.equal(doc.nodeName, "#document");
+ assert.equal(doc.nodeType, 9);
+ done();
+ })
+ })
+})
+
+
+describe('documentElement()', function() {
+ it('should get documentElement node', function(done) {
+ DOM.documentElement(function(err, elem) {
+ assert.strictEqual(err, null);
+ assert.equal(elem.nodeName, "HTML");
+ assert.equal(elem.nodeType, 1);
+ done();
+ })
+ })
+})
+
+describe('querySelector()', function() {
+ it('should get first item node', function(done) {
+ DOM.querySelector(".item", function(err, child) {
+ assert.strictEqual(err, null);
+ assert.equal(child.getAttribute("id"), "test1");
+ assert.ok(child.querySelector, "node has node methods");
+ done();
+ })
+ })
+})
+
+describe('querySelector()', function() {
+ it('should get all item nodes', function(done) {
+ DOM.querySelectorAll(".item", function(err, list) {
+ assert.strictEqual(err, null);
+ assert.equal(list.length, 3);
+
+ list.items(function(err, children) {
+ assert.strictEqual(err, null);
+ var ids = children.map(function(child) {
+ assert.ok(child.querySelector, "list item has node methods");
+ return child.getAttribute("id");
+ })
+ assert.deepEqual(ids, ["test1","test2","test3"]);
+ done();
+ })
+ })
+ })
+})
+
+// Node - parentNode(), parent(), siblings(), nextSibling(), previousSibling(),
+// querySelector(), querySelectorAll(), innerHTML(), outerHTML(), getAttribute(),
+// setAttribute()
+
+describe('parentNode()', function() {
+ it('should get parent node', function(done) {
+ node.parentNode(function(err, parent) {
+ assert.strictEqual(err, null);
+ assert.equal(parent.nodeName, "SECTION");
+ assert.ok(parent.querySelector, "parent has node methods");
+ done();
+ })
+ })
+
+ it('should be null for document parentNode', function(done) {
+ doc.parentNode(function(err, parent) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(parent, null);
+ done();
+ })
+ })
+})
+
+describe('parents()', function() {
+ it('should get ancestor nodes', function(done) {
+ node.parents(function(err, ancestors) {
+ assert.strictEqual(err, null);
+ var names = ancestors.map(function(ancestor) {
+ assert.ok(ancestor.querySelector, "ancestor has node methods");
+ return ancestor.nodeName;
+ })
+ assert.deepEqual(names, ["SECTION","MAIN","BODY","HTML","#document"]);
+ done();
+ })
+ })
+})
+
+describe('children()', function() {
+ it('should get child nodes', function(done) {
+ node.children(function(err, children) {
+ assert.strictEqual(err, null);
+ var ids = children.map(function(child) {
+ assert.ok(child.querySelector, "child has node methods");
+ return child.getAttribute("id");
+ })
+ assert.deepEqual(ids, ["child1","child2"]);
+ done();
+ })
+ })
+})
+
+describe('siblings()', function() {
+ it('should get sibling nodes', function(done) {
+ node.siblings(function(err, siblings) {
+ assert.strictEqual(err, null);
+ var ids = siblings.map(function(sibling) {
+ assert.ok(sibling.querySelector, "sibling has node methods");
+ return sibling.getAttribute("id");
+ })
+ assert.deepEqual(ids, ["test1","test2","test3"]);
+ done();
+ })
+ })
+})
+
+describe('nextSibling()', function() {
+ it('should get next sibling node', function(done) {
+ node.nextSibling(function(err, sibling) {
+ assert.strictEqual(err, null);
+ assert.equal(sibling.getAttribute("id"), "test3");
+ assert.ok(sibling.querySelector, "next sibling has node methods");
+ done();
+ })
+ })
+
+ it('should be null if no next sibling', function(done) {
+ lastNode.nextSibling(function(err, sibling) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(sibling, null);
+ done();
+ })
+ })
+})
+
+describe('previousSibling()', function() {
+ it('should get next sibling node', function(done) {
+ node.previousSibling(function(err, sibling) {
+ assert.strictEqual(err, null);
+ assert.equal(sibling.getAttribute("id"), "test1");
+ assert.ok(sibling.querySelector, "next sibling has node methods");
+ done();
+ })
+ })
+
+ it('should be null if no prev sibling', function(done) {
+ firstNode.previousSibling(function(err, sibling) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(sibling, null);
+ done();
+ })
+ })
+})
+
+describe('querySelector()', function() {
+ it('should get first child node', function(done) {
+ node.querySelector("*", function(err, child) {
+ assert.strictEqual(err, null);
+ assert.equal(child.getAttribute("id"), "child1");
+ assert.ok(child.querySelector, "node has node methods");
+ done();
+ })
+ })
+
+ it('should be null if no nodes with selector', function(done) {
+ node.querySelector("blarg", function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.strictEqual(resp, null);
+ done();
+ })
+ })
+})
+
+describe('querySelectorAll()', function() {
+ it('should get all child nodes', function(done) {
+ node.querySelectorAll("*", function(err, list) {
+ assert.strictEqual(err, null);
+ assert.equal(list.length, 2);
+
+ list.items(function(err, children) {
+ assert.strictEqual(err, null);
+ var ids = children.map(function(child) {
+ assert.ok(child.querySelector, "list item has node methods");
+ return child.getAttribute("id");
+ })
+ assert.deepEqual(ids, ["child1", "child2"]);
+ done();
+ })
+ })
+ })
+
+ it('should get nodes from "start" to "end"', function(done) {
+ doc.querySelectorAll(".item", function(err, list) {
+ assert.strictEqual(err, null);
+ assert.equal(list.length, 3);
+
+ list.items(1, 2, function(err, items) {
+ assert.strictEqual(err, null);
+ assert.equal(items.length, 1);
+ assert.deepEqual(items[0].getAttribute("id"), "test2")
+ done();
+ })
+ })
+ })
+
+ it('should get nodes from "start"', function(done) {
+ doc.querySelectorAll(".item", function(err, list) {
+ assert.strictEqual(err, null);
+ assert.equal(list.length, 3);
+
+ list.items(1, function(err, items) {
+ assert.strictEqual(err, null);
+ assert.equal(items.length, 2);
+ var ids = items.map(function(item) {
+ assert.ok(item.querySelector, "list item has node methods");
+ return item.getAttribute("id");
+ })
+ assert.deepEqual(ids, ["test2","test3"]);
+ done();
+ })
+ })
+ })
+
+ it('should be empty list if no nodes with selector', function(done) {
+ node.querySelectorAll("blarg", function(err, list) {
+ assert.strictEqual(err, null);
+ assert.equal(list.length, 0);
+
+ list.items(function(err, items) {
+ assert.strictEqual(err, null);
+ assert.deepEqual(items, []);
+ done();
+ })
+ })
+ })
+})
+
+describe('innerHTML()', function() {
+ it('should get innerHTML of node', function(done) {
+ node.innerHTML(function(err, text) {
+ assert.strictEqual(err, null);
+ assert.equal(text, '\n <div id="child1"></div>\n'
+ + ' <div id="child2"></div>\n ');
+ done();
+ })
+ })
+})
+
+describe('outerHTML()', function() {
+ it('should get outerHTML of node', function(done) {
+ node.outerHTML(function(err, text) {
+ assert.strictEqual(err, null);
+ assert.equal(text, '<div id="test2" class="item">\n'
+ + ' <div id="child1"></div>\n'
+ + ' <div id="child2"></div>\n '
+ + '</div>');
+ done();
+ })
+ })
+})
+
+describe('highlight()', function() {
+ it('should highlight node', function(done) {
+ node.highlight(function(err, resp) {
+ assert.strictEqual(err, null);
+ done();
+ })
+ })
+})
+
+/* MUST BE LAST */
+describe('remove()', function() {
+ it('should remove node', function(done) {
+ node.remove(function(err, nextSibling) {
+ assert.strictEqual(err, null);
+ assert.equal(nextSibling.getAttribute("id"), "test3");
+
+ doc.querySelectorAll(".item", function(err, list) {
+ assert.strictEqual(err, null);
+ assert.equal(list.length, 2);
+ done();
+ })
+ })
+ })
+
+ it("should err if performing further operations after release()", function(done) {
+ node.release(function(err) {
+ assert.strictEqual(err, null);
+
+ node.innerHTML(function(err, text) {
+ assert.equal(err.message, "TypeError: node is null")
+ assert.equal(err.toString(), "unknownError: TypeError: node is null");
+ done();
+ })
+ })
+ })
+})
+
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-jsobject.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-jsobject.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-jsobject.js
new file mode 100644
index 0000000..f416674
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-jsobject.js
@@ -0,0 +1,115 @@
+var assert = require("assert"),
+ utils = require("./utils");
+
+var Console;
+var obj;
+var func;
+
+before(function(done) {
+ utils.loadTab('dom.html', function(aTab) {
+ Console = aTab.Console;
+ Console.evaluateJS('x = {a: 2, b: {c: 3}, get d() {return 4;}}', function(err, resp) {
+ obj = resp.result;
+
+ var input = 'y = function testfunc(a, b) { return a + b; }';
+ Console.evaluateJS(input, function(err, resp) {
+ func = resp.result;
+ done();
+ })
+ });
+ });
+});
+
+// JSObject - ownPropertyNames(), ownPropertyDescriptor(), prototype(), properties()
+
+describe('ownPropertyNames()', function() {
+ it('should fetch property names', function(done) {
+ obj.ownPropertyNames(function(err, names) {
+ assert.strictEqual(err, null);
+ assert.deepEqual(names, ['a', 'b', 'd']);
+ done();
+ })
+ })
+});
+
+describe('ownPropertyDescriptor()', function() {
+ it('should fetch descriptor for property', function(done) {
+ obj.ownPropertyDescriptor('a', function(err, desc) {
+ assert.strictEqual(err, null);
+ testDescriptor(desc);
+ assert.equal(desc.value, 2);
+ done();
+ })
+ })
+
+ /* TODO: doesn't call callback if not defined property - Server side problem
+ it('should be undefined for nonexistent property', function(done) {
+ obj.ownPropertyDescriptor('g', function(desc) {
+ console.log("desc", desc);
+ done();
+ })
+ }) */
+})
+
+describe('ownProperties()', function() {
+ it('should fetch all own properties and descriptors', function(done) {
+ obj.ownProperties(function(err, props) {
+ assert.strictEqual(err, null);
+ testDescriptor(props.a);
+ assert.equal(props.a.value, 2);
+
+ testDescriptor(props.b);
+ assert.ok(props.b.value.ownProperties, "prop value has JSObject methods");
+ done();
+ })
+ })
+})
+
+describe('prototype()', function() {
+ it('should fetch prototype as an object', function(done) {
+ obj.prototype(function(err, proto) {
+ assert.strictEqual(err, null);
+ assert.ok(proto.ownProperties, "prototype has JSObject methods");
+ done();
+ })
+ })
+})
+
+describe('ownPropertiesAndPrototype()', function() {
+ it('should fetch properties, prototype, and getters', function(done) {
+ obj.ownPropertiesAndPrototype(function(err, resp) {
+ assert.strictEqual(err, null);
+
+ // own properties
+ var props = resp.ownProperties;
+ assert.equal(Object.keys(props).length, 3);
+
+ testDescriptor(props.a);
+ assert.equal(props.a.value, 2);
+
+ // prototype
+ assert.ok(resp.prototype.ownProperties,
+ "prototype has JSObject methods");
+
+ // getters
+ var getters = resp.safeGetterValues;
+ assert.equal(Object.keys(getters).length, 0);
+
+ done();
+ })
+ })
+})
+
+describe('Function objects', function() {
+ it('sould have correct properties', function() {
+ assert.equal(func.class, "Function");
+ assert.equal(func.name, "testfunc");
+ assert.ok(func.ownProperties, "function has JSObject methods")
+ })
+})
+
+function testDescriptor(desc) {
+ assert.strictEqual(desc.configurable, true);
+ assert.strictEqual(desc.enumerable, true);
+ assert.strictEqual(desc.writable, true);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-logs.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-logs.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-logs.js
new file mode 100644
index 0000000..2c076a6
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-logs.js
@@ -0,0 +1,106 @@
+var assert = require("assert"),
+ utils = require("./utils");
+
+var tab;
+var Console;
+
+before(function(done) {
+ utils.loadTab('logs.html', function(aTab) {
+ tab = aTab;
+ Console = aTab.Console;
+
+ Console.startListening(function() {
+ done();
+ })
+ });
+});
+
+// Console - startLogging(), stopLogging(), getCachedMessages(),
+// clearCachedMessages(), event:page-error, event:console-api-call
+
+describe('getCachedMessages()', function() {
+ it('should get messages from before listening', function(done) {
+ Console.getCachedLogs(function(err, messages) {
+ assert.strictEqual(err, null);
+
+ var hasLog = messages.some(function(message) {
+ return message.level == "log";
+ })
+ assert.ok(hasLog);
+
+ var hasDir = messages.some(function(message) {
+ return message.level == "dir";
+ })
+ assert.ok(hasDir);
+
+ var hasError = messages.some(function(message) {
+ return message.errorMessage == "ReferenceError: foo is not defined";
+ })
+ assert.ok(hasError);
+ done();
+ });
+ })
+})
+
+describe('clearCachedMessages()', function() {
+ it('should clear cached messages', function(done) {
+ Console.clearCachedLogs(function() {
+ Console.getCachedLogs(function(err, messages) {
+ assert.strictEqual(err, null);
+ // The error message should be left
+ assert.equal(messages.length, 1);
+ assert.equal(messages[0].errorMessage, "ReferenceError: foo is not defined")
+ done();
+ })
+ });
+ })
+})
+
+describe('"page-error" event', function() {
+ it('should receive "page-error" event with message', function(done) {
+ Console.once('page-error', function(event) {
+ assert.equal(event.errorMessage, "ReferenceError: foo is not defined");
+ assert.ok(event.sourceName.indexOf("logs.html") > 0);
+ assert.equal(event.lineNumber, 10);
+ assert.equal(event.columnNumber, 0);
+ assert.ok(event.exception);
+
+ done();
+ });
+
+ tab.reload();
+ })
+})
+
+describe('"console-api-call" event', function() {
+ it('should receive "console-api-call" for console.log', function(done) {
+ Console.on('console-api-call', function(event) {
+ if (event.level == "log") {
+ assert.deepEqual(event.arguments, ["hi"]);
+
+ Console.removeAllListeners('console-api-call');
+ done();
+ }
+ });
+
+ tab.reload();
+ })
+
+ it('should receive "console-api-call" for console.dir', function(done) {
+ Console.on('console-api-call', function(event) {
+ if (event.level == "dir") {
+ var obj = event.arguments[0];
+ assert.ok(obj.ownPropertyNames, "dir argument has JSObject methods");
+
+ Console.removeAllListeners('console-api-call');
+ done();
+ }
+ });
+
+ tab.reload();
+ })
+})
+
+after(function() {
+ Console.stopListening();
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-network.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-network.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-network.js
new file mode 100644
index 0000000..969ec63
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-network.js
@@ -0,0 +1,88 @@
+var assert = require("assert"),
+ path = require("path"),
+ utils = require("./utils");
+
+var tab;
+var Network;
+var Console;
+
+before(function(done) {
+ utils.loadTab('network.html', function(aTab) {
+ tab = aTab;
+ Network = aTab.Network;
+ Console = aTab.Console;
+
+ Network.startLogging(function(err) {
+ assert.strictEqual(err, null);
+ done();
+ })
+ });
+});
+
+// Network - startLogging(), stopLogging(), sendHTTPRequest(), event:network-event
+
+describe('"network-event" event', function() {
+ it('should receive "network-event" event with message', function(done) {
+ Network.once('network-event', function(event) {
+ assert.equal(event.method, "GET");
+ assert.equal(path.basename(event.url), "test-network.json");
+ assert.ok(event.isXHR);
+ assert.ok(event.getResponseHeaders, "event has NetworkEvent methods")
+ done();
+ });
+
+ Console.evaluateJS("sendRequest()")
+ })
+})
+
+describe('sendHTTPRequest()', function() {
+ it('should send a new XHR request from page', function(done) {
+ var request = {
+ url: "test-network.json",
+ method: "GET",
+ headers: [{name: "test-header", value: "test-value"}]
+ };
+
+ Network.sendHTTPRequest(request, function(err, netEvent) {
+ assert.strictEqual(err, null);
+ assert.ok(netEvent.getResponseHeaders, "event has NetworkEvent methods");
+ done();
+ });
+ })
+})
+
+// NetworkEvent - getRequestHeaders(), getRequestCookies(), getRequestPostData(),
+// getResponseHeaders(), getResponseCookies(), getResponseContent(), getEventTimings()
+// event:update
+
+
+describe('getRequestHeaders(', function() {
+ it('should get request headers', function(done) {
+ Network.on('network-event', function(netEvent) {
+ netEvent.on("request-headers", function(event) {
+ assert.ok(event.headers);
+ assert.ok(event.headersSize);
+
+ netEvent.getRequestHeaders(function(err, resp) {
+ assert.strictEqual(err, null);
+
+ var found = resp.headers.some(function(header) {
+ return header.name == "test-header" &&
+ header.value == "test-value";
+ });
+ assert.ok(found, "contains that header we sent");
+ done();
+ })
+ })
+ });
+ Console.evaluateJS("sendRequest()");
+ })
+})
+
+// TODO: NetworkEvent tests
+
+after(function() {
+ Network.stopLogging(function(err) {
+ assert.strictEqual(err, null);
+ });
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-raw.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-raw.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-raw.js
new file mode 100644
index 0000000..433eede
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-raw.js
@@ -0,0 +1,26 @@
+var assert = require("assert"),
+ FirefoxClient = require("../index");
+
+var client = new FirefoxClient();
+
+before(function(done) {
+ client.connect(function() {
+ done();
+ })
+});
+
+describe('makeRequest()', function() {
+ it('should do listTabs request', function(done) {
+ var message = {
+ to: 'root',
+ type: 'listTabs'
+ };
+
+ client.client.makeRequest(message, function(resp) {
+ assert.equal(resp.from, "root");
+ assert.ok(resp.tabs);
+ assert.ok(resp.profilerActor)
+ done();
+ })
+ })
+})
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-stylesheets.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-stylesheets.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-stylesheets.js
new file mode 100644
index 0000000..86af8d0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/test-stylesheets.js
@@ -0,0 +1,124 @@
+var assert = require("assert"),
+ path = require("path"),
+ utils = require("./utils");
+
+var StyleSheets;
+var styleSheet;
+
+var SS_TEXT = [
+"main {",
+" font-family: Georgia, sans-serif;",
+" color: black;",
+"}",
+"",
+"* {",
+" padding: 0;",
+" margin: 0;",
+"}"
+].join("\n");
+
+before(function(done) {
+ utils.loadTab('stylesheets.html', function(aTab) {
+ StyleSheets = aTab.StyleSheets;
+ StyleSheets.getStyleSheets(function(err, sheets) {
+ assert.strictEqual(err, null);
+ styleSheet = sheets[1];
+ done();
+ })
+ });
+});
+
+// Stylesheets - getStyleSheets(), addStyleSheet()
+
+describe('getStyleSheets()', function() {
+ it('should list all the stylesheets', function(done) {
+ StyleSheets.getStyleSheets(function(err, sheets) {
+ assert.strictEqual(err, null);
+
+ var hrefs = sheets.map(function(sheet) {
+ assert.ok(sheet.update, "sheet has Stylesheet methods");
+ return path.basename(sheet.href);
+ });
+ assert.deepEqual(hrefs, ["null", "stylesheet1.css"]);
+ done();
+ })
+ })
+})
+
+describe('addStyleSheet()', function() {
+ it('should add a new stylesheet', function(done) {
+ var text = "div { font-weight: bold; }";
+
+ StyleSheets.addStyleSheet(text, function(err, sheet) {
+ assert.strictEqual(err, null);
+ assert.ok(sheet.update, "sheet has Stylesheet methods");
+ assert.equal(sheet.ruleCount, 1);
+ done();
+ })
+ })
+})
+
+// StyleSheet - update(), toggleDisabled()
+
+describe('StyleSheet', function() {
+ it('should have the correct properties', function() {
+ assert.equal(path.basename(styleSheet.href), "stylesheet1.css");
+ assert.strictEqual(styleSheet.disabled, false);
+ assert.equal(styleSheet.ruleCount, 2);
+ })
+})
+
+describe('StyleSheet.getText()', function() {
+ it('should get the text of the style sheet', function(done) {
+ styleSheet.getText(function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.equal(resp, SS_TEXT);
+ done();
+ })
+ })
+});
+
+describe('StyleSheet.update()', function() {
+ it('should update stylesheet', function(done) {
+ var text = "main { color: red; }";
+
+ styleSheet.update(text, function(err, resp) {
+ assert.strictEqual(err, null);
+ // TODO: assert.equal(styleSheet.ruleCount, 1);
+ done();
+ })
+ })
+})
+
+describe('StyleSheet.toggleDisabled()', function() {
+ it('should toggle disabled attribute', function(done) {
+ assert.deepEqual(styleSheet.disabled, false);
+
+ styleSheet.toggleDisabled(function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.deepEqual(styleSheet.disabled, true);
+ done();
+ })
+ })
+
+ it('should fire disabled-changed event', function(done) {
+ styleSheet.toggleDisabled(function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.deepEqual(styleSheet.disabled, false);
+ })
+ styleSheet.on("disabled-changed", function(disabled) {
+ assert.strictEqual(disabled, false);
+ done();
+ })
+ })
+})
+
+describe('StyleSheet.getOriginalSources()', function() {
+ it('should get no original sources', function(done) {
+ styleSheet.getOriginalSources(function(err, resp) {
+ assert.strictEqual(err, null);
+ assert.deepEqual(resp, []);
+ done();
+ })
+ })
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/test/utils.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/test/utils.js b/node_modules/node-firefox-connect/node_modules/firefox-client/test/utils.js
new file mode 100644
index 0000000..45dc191
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/test/utils.js
@@ -0,0 +1,35 @@
+var assert = require('assert'),
+ FirefoxClient = require("../index");
+
+var tab;
+
+exports.loadTab = function(url, callback) {
+ getFirstTab(function(tab) {
+ tab.navigateTo(url);
+
+ tab.once("navigate", function() {
+ callback(tab);
+ });
+ })
+};
+
+
+function getFirstTab(callback) {
+ if (tab) {
+ return callback(tab);
+ }
+ var client = new FirefoxClient({log: true});
+
+ client.connect(function() {
+ client.listTabs(function(err, tabs) {
+ if (err) throw err;
+
+ tab = tabs[0];
+
+ tab.attach(function(err) {
+ if (err) throw err;
+ callback(tab);
+ })
+ });
+ });
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/package.json b/node_modules/node-firefox-connect/package.json
new file mode 100644
index 0000000..9a4c9c0
--- /dev/null
+++ b/node_modules/node-firefox-connect/package.json
@@ -0,0 +1,81 @@
+{
+ "name": "node-firefox-connect",
+ "version": "1.0.0",
+ "description": "Connect to a Firefox simulator",
+ "main": "index.js",
+ "dependencies": {
+ "es6-promise": "^2.0.1",
+ "firefox-client": "^0.3.0"
+ },
+ "devDependencies": {
+ "gulp": "^3.8.10",
+ "node-firefox-build-tools": "^0.1.0",
+ "node-firefox-start-simulator": "^1.0.0",
+ "should": "^4.0.4"
+ },
+ "scripts": {
+ "gulp": "gulp",
+ "test": "gulp test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/mozilla/node-firefox-connect.git"
+ },
+ "keywords": [
+ "firefox",
+ "developer tools",
+ "b2g",
+ "firefox os",
+ "firefoxos",
+ "fxos",
+ "connect"
+ ],
+ "author": {
+ "name": "Mozilla",
+ "url": "https://mozilla.org/"
+ },
+ "contributors": [
+ {
+ "name": "Nicola Greco",
+ "email": "me@nicola.io",
+ "url": "http://nicolagreco.com/"
+ },
+ {
+ "name": "Brittany Storoz",
+ "email": "bstoroz@mozilla.com"
+ },
+ {
+ "name": "Soledad Penadés",
+ "email": "listas@soledadpenades.com",
+ "url": "http://soledadpenades.com/"
+ }
+ ],
+ "license": "Apache 2.0",
+ "bugs": {
+ "url": "https://github.com/mozilla/node-firefox-connect/issues"
+ },
+ "homepage": "https://github.com/mozilla/node-firefox-connect",
+ "gitHead": "5d4e4f060ea7e90444ded97a4c99e34462ac22cc",
+ "_id": "node-firefox-connect@1.0.0",
+ "_shasum": "3624bbde9ec407a3d75eb9783703e3a02a6ea2b0",
+ "_from": "node-firefox-connect@",
+ "_npmVersion": "2.1.6",
+ "_nodeVersion": "0.10.33",
+ "_npmUser": {
+ "name": "sole",
+ "email": "listas@soledadpenades.com"
+ },
+ "maintainers": [
+ {
+ "name": "sole",
+ "email": "listas@soledadpenades.com"
+ }
+ ],
+ "dist": {
+ "shasum": "3624bbde9ec407a3d75eb9783703e3a02a6ea2b0",
+ "tarball": "http://registry.npmjs.org/node-firefox-connect/-/node-firefox-connect-1.0.0.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/node-firefox-connect/-/node-firefox-connect-1.0.0.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/test/test.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/test/test.js b/node_modules/node-firefox-connect/test/test.js
new file mode 100644
index 0000000..f7bd584
--- /dev/null
+++ b/node_modules/node-firefox-connect/test/test.js
@@ -0,0 +1,157 @@
+var assert = require("assert");
+var should = require("should");
+var Connect = require("../");
+var Start = require("fxos-start");
+var Ports = require("fx-ports");
+var Q = require('q');
+
+
+describe('fxos-connect', function(){
+ this.timeout(10000);
+ afterEach(function() {
+ Ports({b2g:true}, function(err, instances) {
+ instances.forEach(function(i) {
+ process.kill(i.pid);
+ });
+ });
+ });
+
+ describe('when no simulator is open', function(){
+
+ it('should start a simulator', function(done) {
+ Connect()
+ .then(function(sim) {
+ sim.pid.should.be.type('number');
+ sim.port.should.be.type('number');
+ sim.release.should.be.type('string');
+ })
+ .then(done)
+ .fail(done);
+ });
+
+ it('should match given release', function(done) {
+ Connect({release:['2.1']})
+ .then(function(sim) {
+ sim.release.should.equal('2.1');
+ })
+ .then(done)
+ .fail(done);
+ });
+
+ it('should match given port', function(done) {
+ Connect({port:8081})
+ .then(function(sim) {
+ sim.port.should.equal(8081);
+ })
+ .then(done)
+ .fail(done);
+ });
+ });
+
+ describe('when a simulator is open', function(){
+
+ it('should find a simulator', function(done) {
+ var starting = Start({
+ connect:false,
+ force:true
+ });
+ var connecting = starting.then(function(sim) {
+ return Connect();
+ });
+
+ Q.all([connecting, starting])
+ .spread(function(sim1, sim2) {
+ sim1.pid.should.equal(sim2.pid);
+ })
+ .then(done)
+ .fail(done);
+ });
+
+ it('should reuse if release matches', function(done) {
+ var starting = Start({
+ connect:false,
+ force: true,
+ release: ['2.1']
+ });
+ var connecting = starting.then(function(sim) {
+ return Connect();
+ });
+
+ Q.all([connecting, starting])
+ .spread(function(sim1, sim2) {
+ var regex = new RegExp("^(" + sim2.release + ")");
+ assert(regex.exec(sim1.release));
+ })
+ .then(done)
+ .fail(done);
+ });
+
+
+ it('should reuse if port matches', function(done) {
+ var starting = Start({
+ connect:false,
+ force: true,
+ port: 8081
+ });
+ var connecting = starting.then(function(sim) {
+ return Connect();
+ });
+
+ Q.all([connecting, starting])
+ .spread(function(sim1, sim2) {
+ sim1.port.should.equal(sim2.port);
+ })
+ .then(done)
+ .fail(done);
+ });
+
+ it('should start new sim if port not matching', function(done) {
+ var starting = Start({
+ connect:false,
+ force: true,
+ port: 8081
+ }).fail(done);
+ var connecting = starting.then(function(sim) {
+ return Connect({force:true, port:8082});
+ }).fail(done);
+
+ Q.all([connecting, starting])
+ .spread(function(sim1, sim2) {
+ sim1.pid.should.not.equal(sim2.pid);
+ sim1.port.should.equal(8082);
+ })
+ .then(done)
+ .fail(done);
+ });
+ });
+
+ describe('opts.connect', function(){
+ it('should return a simulator obj with client instance', function(done) {
+ Connect({connect: true})
+ .then(function(sim) {
+ sim.client.disconnect();
+ should.exist(sim.client);
+ })
+ .then(done)
+ .fail(done);
+ });
+ });
+
+ describe('callback', function(){
+ it('should return a simulator obj with client instance', function(done) {
+ Connect(function(err, sim) {
+ sim.client.disconnect();
+ should.exist(sim.client);
+ done();
+ });
+ });
+
+ it('should return a simulator obj', function(done) {
+ Connect({port:8081}, function(err, sim) {
+ sim.port.should.equal(8081);
+ done();
+ });
+ });
+ });
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/.npmignore b/node_modules/node-firefox-find-app/.npmignore
new file mode 100644
index 0000000..fd4f2b0
--- /dev/null
+++ b/node_modules/node-firefox-find-app/.npmignore
@@ -0,0 +1,2 @@
+node_modules
+.DS_Store
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/LICENSE b/node_modules/node-firefox-find-app/LICENSE
new file mode 100644
index 0000000..a7c6b5e
--- /dev/null
+++ b/node_modules/node-firefox-find-app/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2015 Mozilla
+
+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.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/README.md b/node_modules/node-firefox-find-app/README.md
new file mode 100644
index 0000000..197b2d4
--- /dev/null
+++ b/node_modules/node-firefox-find-app/README.md
@@ -0,0 +1,125 @@
+# node-firefox-find-app [](http://travis-ci.org/mozilla/node-firefox-find-app)
+
+> Find if an app is installed on a runtime.
+
+This is part of the [node-firefox](https://github.com/mozilla/node-firefox) project.
+
+## Current limitations
+
+We do not support Windows yet. But there are placeholders in the code marked with `TODO: Windows` that indicate where the Windows code would need to be added. If you want to contribute, those are the *gaps* that need to be filled in order for this to work on Windows.
+
+**NOTE**
+
+*This is a work in progress. Things will probably be missing and broken while we move from `fxos-findapp` to `node-firefox-find-app`. Please have a look at the [existing issues](https://github.com/mozilla/node-firefox-find-app/issues), and/or [file more](https://github.com/mozilla/node-firefox-find-app/issues/new) if you find any! :-)*
+
+## Installation
+
+### From git
+
+```bash
+git clone https://github.com/mozilla/node-firefox-find-app.git
+cd node-firefox-find-app
+npm install
+```
+
+If you want to update later on:
+
+```bash
+cd node-firefox-find-app
+git pull origin master
+npm install
+```
+
+### npm
+
+<!--
+```bash
+npm install node-firefox-find-app
+```
+-->
+
+This module is not on npm yet.
+
+## Usage
+
+```javascript
+findApp(options) // returns a Promise
+```
+
+where `options` is a plain `Object` which must contain the following:
+
+* `manifest`: the manifest contents, in JSON format
+* `client`: the remote client where we want to find if this app is installed
+
+If no `options` are provided, or if `options` is an empty `Object` (`{}`), then `findApp` will fail (how can you find *you don't know what app exactly* in *you don't know where*?)
+
+
+### Finding apps in simulators, using the manifest JSON contents
+
+```javascript
+var findApp = require('node-firefox-find-app');
+var startSimulator = require('node-firefox-start-simulator');
+var connect = require('node-firefox-connect');
+var manifest = loadJSON('/path/to/manifest.webapp'));
+
+startSimulator().then(function(simulator) {
+
+ connect(simulator.port).then(function(client) {
+
+ findApp({
+ manifest: manifest,
+ client: client
+ }).then(function(result) {
+
+ if (result.length === 0) {
+ console.log('App is not installed');
+ } else {
+ console.log('Found app!', result);
+ }
+
+ client.disconnect();
+ stopSimulator(simulator);
+
+ });
+
+ });
+
+});
+
+
+```
+
+You can have a look at the `examples` folder for a complete example.
+
+## Running the tests
+
+After installing, you can simply run the following from the module folder:
+
+```bash
+npm test
+```
+
+To add a new unit test file, create a new file in the `tests/unit` folder. Any file that matches `test.*.js` will be run as a test by the appropriate test runner, based on the folder location.
+
+We use `gulp` behind the scenes to run the test; if you don't have it installed globally you can use `npm gulp` from inside the project's root folder to run `gulp`.
+
+### Code quality and style
+
+Because we have multiple contributors working on our projects, we value consistent code styles. It makes it easier to read code written by many people! :-)
+
+Our tests include unit tests as well as code quality ("linting") tests that make sure our test pass a style guide and [JSHint](http://jshint.com/). Instead of submitting code with the wrong indentation or a different style, run the tests and you will be told where your code quality/style differs from ours and instructions on how to fix it.
+
+## History
+
+This is based on initial work on [fxos-findapp](https://github.com/nicola/fxos-findapp) by Nicola Greco.
+
+## License
+
+This program is free software; it is distributed under an
+[Apache License](https://github.com/mozilla/node-firefox-find-app/blob/master/LICENSE).
+
+## Copyright
+
+Copyright (c) 2015 [Mozilla](https://mozilla.org)
+([Contributors](https://github.com/mozilla/node-firefox-find-app/graphs/contributors)).
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/examples/data/app.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/examples/data/app.js b/node_modules/node-firefox-find-app/examples/data/app.js
new file mode 100644
index 0000000..dc7e45e
--- /dev/null
+++ b/node_modules/node-firefox-find-app/examples/data/app.js
@@ -0,0 +1,3 @@
+window.addEventListener("load", function() {
+ console.log("Hello World!");
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/examples/data/icons/icon128x128.png
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/examples/data/icons/icon128x128.png b/node_modules/node-firefox-find-app/examples/data/icons/icon128x128.png
new file mode 100644
index 0000000..7db00d7
Binary files /dev/null and b/node_modules/node-firefox-find-app/examples/data/icons/icon128x128.png differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/examples/data/icons/icon16x16.png
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/examples/data/icons/icon16x16.png b/node_modules/node-firefox-find-app/examples/data/icons/icon16x16.png
new file mode 100644
index 0000000..1e751ce
Binary files /dev/null and b/node_modules/node-firefox-find-app/examples/data/icons/icon16x16.png differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/examples/data/icons/icon48x48.png
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/examples/data/icons/icon48x48.png b/node_modules/node-firefox-find-app/examples/data/icons/icon48x48.png
new file mode 100644
index 0000000..acc33ff
Binary files /dev/null and b/node_modules/node-firefox-find-app/examples/data/icons/icon48x48.png differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/examples/data/icons/icon60x60.png
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/examples/data/icons/icon60x60.png b/node_modules/node-firefox-find-app/examples/data/icons/icon60x60.png
new file mode 100644
index 0000000..bc14314
Binary files /dev/null and b/node_modules/node-firefox-find-app/examples/data/icons/icon60x60.png differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/examples/data/index.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/examples/data/index.html b/node_modules/node-firefox-find-app/examples/data/index.html
new file mode 100644
index 0000000..238e891
--- /dev/null
+++ b/node_modules/node-firefox-find-app/examples/data/index.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1">
+
+ <title>node-firefox-find-app</title>
+
+ <style>
+ body {
+ border: 1px solid black;
+ }
+ </style>
+
+ <!-- Inline scripts are forbidden in Firefox OS apps (CSP restrictions),
+ so we use a script file. -->
+ <script src="app.js" defer></script>
+
+ </head>
+
+ <body>
+ <!-- This code is in the public domain. Enjoy! -->
+ <h1><tt>node-firefox-find-app</tt></h1>
+ <p>This is a simple test app for demonstrating how to use this module.</p>
+ </body>
+
+</html>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/examples/data/manifest.webapp
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/examples/data/manifest.webapp b/node_modules/node-firefox-find-app/examples/data/manifest.webapp
new file mode 100644
index 0000000..3edadc2
--- /dev/null
+++ b/node_modules/node-firefox-find-app/examples/data/manifest.webapp
@@ -0,0 +1,14 @@
+{
+ "name": "node-firefox-find-app",
+ "description": "A test app for this module",
+ "launch_path": "/index.html",
+ "icons": {
+ "16": "/icons/icon16x16.png",
+ "48": "/icons/icon48x48.png",
+ "60": "/icons/icon60x60.png",
+ "128": "/icons/icon128x128.png"
+ },
+ "type": "privileged",
+ "permissions": {
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/examples/usage.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/examples/usage.js b/node_modules/node-firefox-find-app/examples/usage.js
new file mode 100644
index 0000000..4184f76
--- /dev/null
+++ b/node_modules/node-firefox-find-app/examples/usage.js
@@ -0,0 +1,45 @@
+'use strict';
+
+var fs = require('fs');
+var path = require('path');
+var findApp = require('../index.js');
+var startSimulator = require('node-firefox-start-simulator');
+var connect = require('node-firefox-connect');
+
+var manifest = loadJSON(path.join(__dirname, 'data/manifest.webapp'));
+
+startSimulator().then(function(simulator) {
+
+ connect(simulator.port).then(function(client) {
+
+ findApp({
+ manifest: manifest,
+ client: client
+ }).then(function(result) {
+
+ if (result.length === 0) {
+ console.log('App is not installed');
+ } else {
+ console.log('Found app!', result);
+ }
+
+ client.disconnect();
+ stopSimulator(simulator);
+
+ });
+
+ });
+
+});
+
+
+function loadJSON(path) {
+ var data = fs.readFileSync(path, 'utf8');
+ return JSON.parse(data);
+}
+
+
+function stopSimulator(simulator) {
+ process.kill(simulator.pid);
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/gulpfile.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/gulpfile.js b/node_modules/node-firefox-find-app/gulpfile.js
new file mode 100644
index 0000000..75941db
--- /dev/null
+++ b/node_modules/node-firefox-find-app/gulpfile.js
@@ -0,0 +1,4 @@
+var gulp = require('gulp');
+var buildTools = require('node-firefox-build-tools');
+
+buildTools.loadGulpTasks(gulp);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/index.js b/node_modules/node-firefox-find-app/index.js
new file mode 100644
index 0000000..766b334
--- /dev/null
+++ b/node_modules/node-firefox-find-app/index.js
@@ -0,0 +1,70 @@
+'use strict';
+
+// See https://github.com/jshint/jshint/issues/1747 for context
+/* global -Promise */
+var Promise = require('es6-Promise').Promise;
+
+module.exports = findApp;
+
+function findApp(options) {
+
+ options = options || {};
+
+ var client = options.client;
+ var manifest = options.manifest;
+
+ return new Promise(function(resolve, reject) {
+
+ if (client === undefined || manifest === undefined) {
+ return reject(new Error('We need a client and a manifest to find an app'));
+ }
+
+ getWebAppsActor(client)
+ .then(listInstalledApps)
+ .then(function(installedApps) {
+ // And we filter the installed apps down to
+ // just the apps with the same name as in the manifest
+ var name = manifest.name;
+
+ resolve(installedApps.filter(function(app) {
+ return app.name === name;
+ }));
+ });
+
+ });
+
+}
+
+
+function getWebAppsActor(client) {
+ return new Promise(function(resolve, reject) {
+
+ client.getWebapps(function(err, webapps) {
+ if (err) {
+ return reject(err);
+ }
+
+ resolve(webapps);
+
+ });
+
+ });
+}
+
+
+function listInstalledApps(webAppsActor) {
+ return new Promise(function(resolve, reject) {
+
+ webAppsActor.getInstalledApps(function(err, apps) {
+
+ if (err) {
+ return reject(err);
+ }
+
+ resolve(apps);
+
+ });
+
+ });
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/.release.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/.release.json b/node_modules/node-firefox-find-app/node_modules/es6-promise/.release.json
new file mode 100644
index 0000000..dee8cbc
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/.release.json
@@ -0,0 +1,17 @@
+{
+ "non-interactive": true,
+ "dry-run": false,
+ "verbose": false,
+ "force": false,
+ "pkgFiles": ["package.json", "bower.json"],
+ "increment": "patch",
+ "commitMessage": "Release %s",
+ "tagName": "%s",
+ "tagAnnotation": "Release %s",
+ "buildCommand": "npm run-script build-all",
+ "distRepo": "git@github.com:components/rsvp.js.git",
+ "distStageDir": "tmp/stage",
+ "distBase": "dist",
+ "distFiles": ["**/*", "../package.json", "../bower.json"],
+ "publish": false
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/Brocfile.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/Brocfile.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/Brocfile.js
new file mode 100644
index 0000000..d34f458
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/Brocfile.js
@@ -0,0 +1,75 @@
+/* jshint node:true, undef:true, unused:true */
+var AMDFormatter = require('es6-module-transpiler-amd-formatter');
+var closureCompiler = require('broccoli-closure-compiler');
+var compileModules = require('broccoli-compile-modules');
+var mergeTrees = require('broccoli-merge-trees');
+var moveFile = require('broccoli-file-mover');
+var es3Recast = require('broccoli-es3-safe-recast');
+var concat = require('broccoli-concat');
+var replace = require('broccoli-string-replace');
+var calculateVersion = require('./lib/calculateVersion');
+var path = require('path');
+var trees = [];
+var env = process.env.EMBER_ENV || 'development';
+
+var bundle = compileModules('lib', {
+ inputFiles: ['es6-promise.umd.js'],
+ output: '/es6-promise.js',
+ formatter: 'bundle',
+});
+
+trees.push(bundle);
+trees.push(compileModules('lib', {
+ inputFiles: ['**/*.js'],
+ output: '/amd/',
+ formatter: new AMDFormatter()
+}));
+
+if (env === 'production') {
+ trees.push(closureCompiler(moveFile(bundle, {
+ srcFile: 'es6-promise.js',
+ destFile: 'es6-promise.min.js'
+ }), {
+ compilation_level: 'ADVANCED_OPTIMIZATIONS',
+ externs: ['node'],
+ }));
+}
+
+var distTree = mergeTrees(trees.concat('config'));
+var distTrees = [];
+
+distTrees.push(concat(distTree, {
+ inputFiles: [
+ 'versionTemplate.txt',
+ 'es6-promise.js'
+ ],
+ outputFile: '/es6-promise.js'
+}));
+
+if (env === 'production') {
+ distTrees.push(concat(distTree, {
+ inputFiles: [
+ 'versionTemplate.txt',
+ 'es6-promise.min.js'
+ ],
+ outputFile: '/es6-promise.min.js'
+ }));
+}
+
+if (env !== 'development') {
+ distTrees = distTrees.map(es3Recast);
+}
+
+distTree = mergeTrees(distTrees);
+var distTree = replace(distTree, {
+ files: [
+ 'es6-promise.js',
+ 'es6-promise.min.js'
+ ],
+ pattern: {
+ match: /VERSION_PLACEHOLDER_STRING/g,
+ replacement: calculateVersion()
+ }
+});
+
+module.exports = distTree;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/CHANGELOG.md b/node_modules/node-firefox-find-app/node_modules/es6-promise/CHANGELOG.md
new file mode 100644
index 0000000..e06b496
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/CHANGELOG.md
@@ -0,0 +1,9 @@
+# Master
+
+# 2.0.0
+
+* re-sync with RSVP. Many large performance improvements and bugfixes.
+
+# 1.0.0
+
+* first subset of RSVP
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/LICENSE b/node_modules/node-firefox-find-app/node_modules/es6-promise/LICENSE
new file mode 100644
index 0000000..954ec59
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/README.md b/node_modules/node-firefox-find-app/node_modules/es6-promise/README.md
new file mode 100644
index 0000000..b974ce4
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/README.md
@@ -0,0 +1,58 @@
+# ES6-Promise (subset of [rsvp.js](https://github.com/tildeio/rsvp.js))
+
+This is a polyfill of the [ES6 Promise](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-constructor). The implementation is a subset of [rsvp.js](https://github.com/tildeio/rsvp.js), if you're wanting extra features and more debugging options, check out the [full library](https://github.com/tildeio/rsvp.js).
+
+For API details and how to use promises, see the <a href="http://www.html5rocks.com/en/tutorials/es6/promises/">JavaScript Promises HTML5Rocks article</a>.
+
+## Downloads
+
+* [es6-promise](https://es6-promises.s3.amazonaws.com/es6-promise-2.0.1.js)
+* [es6-promise-min](https://es6-promises.s3.amazonaws.com/es6-promise-2.0.1.min.js) (~2.2k gzipped)
+
+## Node.js
+
+To install:
+
+```sh
+npm install es6-promise
+```
+
+To use:
+
+```js
+var Promise = require('es6-promise').Promise;
+```
+
+## Usage in IE<9
+
+`catch` is a reserved word in IE<9, meaning `promise.catch(func)` throws a syntax error. To work around this, you can use a string to access the property as shown in the following example.
+
+However, please remember that such technique is already provided by most common minifiers, making the resulting code safe for old browsers and production:
+
+```js
+promise['catch'](function(err) {
+ // ...
+});
+```
+
+Or use `.then` instead:
+
+```js
+promise.then(undefined, function(err) {
+ // ...
+});
+```
+
+## Auto-polyfill
+
+To polyfill the global environment (either in Node or in the browser via CommonJS) use the following code snippet:
+
+```js
+require('es6-promise').polyfill();
+```
+
+Notice that we don't assign the result of `polyfill()` to any variable. The `polyfill()` method will patch the global environment (in this case to the `Promise` name) when called.
+
+## Building & Testing
+
+* `npm run build-all && npm test` - Run Mocha tests through Node and PhantomJS.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/bin/publish_to_s3.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/bin/publish_to_s3.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/bin/publish_to_s3.js
new file mode 100755
index 0000000..7daf49a
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/bin/publish_to_s3.js
@@ -0,0 +1,28 @@
+#!/usr/bin/env node
+
+// To invoke this from the commandline you need the following to env vars to exist:
+//
+// S3_BUCKET_NAME
+// TRAVIS_BRANCH
+// TRAVIS_TAG
+// TRAVIS_COMMIT
+// S3_SECRET_ACCESS_KEY
+// S3_ACCESS_KEY_ID
+//
+// Once you have those you execute with the following:
+//
+// ```sh
+// ./bin/publish_to_s3.js
+// ```
+var S3Publisher = require('ember-publisher');
+var configPath = require('path').join(__dirname, '../config/s3ProjectConfig.js');
+publisher = new S3Publisher({ projectConfigPath: configPath });
+
+// Always use wildcard section of project config.
+// This is useful when the including library does not
+// require channels (like in ember.js / ember-data).
+publisher.currentBranch = function() {
+ return (process.env.TRAVIS_BRANCH === 'master') ? 'wildcard' : 'no-op';
+};
+publisher.publish();
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/bower.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/bower.json b/node_modules/node-firefox-find-app/node_modules/es6-promise/bower.json
new file mode 100644
index 0000000..84ec5ad
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/bower.json
@@ -0,0 +1,29 @@
+{
+ "name": "es6-promise",
+ "namespace": "Promise",
+ "version": "2.0.1",
+ "description": "A polyfill for ES6-style Promises, tracking rsvp",
+ "authors": [
+ "Stefan Penner <st...@gmail.com>"
+ ],
+ "main": "dist/es6-promise.js",
+ "keywords": [
+ "promise"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jakearchibald/ES6-Promises.git"
+ },
+ "bugs": {
+ "url": "https://github.com/jakearchibald/ES6-Promises/issues"
+ },
+ "license": "MIT",
+ "ignore": [
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests",
+ "vendor",
+ "tasks"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/config/s3ProjectConfig.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/config/s3ProjectConfig.js b/node_modules/node-firefox-find-app/node_modules/es6-promise/config/s3ProjectConfig.js
new file mode 100644
index 0000000..5f3349a
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/config/s3ProjectConfig.js
@@ -0,0 +1,26 @@
+/*
+ * Using wildcard because es6-promise does not currently have a
+ * channel system in place.
+ */
+module.exports = function(revision,tag,date){
+ return {
+ 'es6-promise.js':
+ { contentType: 'text/javascript',
+ destinations: {
+ wildcard: [
+ 'es6-promise-latest.js',
+ 'es6-promise-' + revision + '.js'
+ ]
+ }
+ },
+ 'es6-promise.min.js':
+ { contentType: 'text/javascript',
+ destinations: {
+ wildcard: [
+ 'es6-promise-latest.min.js',
+ 'es6-promise-' + revision + '.min.js'
+ ]
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/node_modules/es6-promise/config/versionTemplate.txt
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/node_modules/es6-promise/config/versionTemplate.txt b/node_modules/node-firefox-find-app/node_modules/es6-promise/config/versionTemplate.txt
new file mode 100644
index 0000000..999a5fc
--- /dev/null
+++ b/node_modules/node-firefox-find-app/node_modules/es6-promise/config/versionTemplate.txt
@@ -0,0 +1,7 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version VERSION_PLACEHOLDER_STRING
+ */
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[18/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/Readme.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/Readme.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/Readme.md
new file mode 100644
index 0000000..4e091d2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/Readme.md
@@ -0,0 +1,311 @@
+# Commander.js
+
+
+[](http://travis-ci.org/tj/commander.js)
+[](https://www.npmjs.org/package/commander)
+[](https://www.npmjs.org/package/commander)
+[](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
+ The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/tj/commander).
+ [API documentation](http://tj.github.com/commander.js/)
+
+
+## Installation
+
+ $ npm install commander
+
+## Option parsing
+
+ Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.
+
+```js
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var program = require('commander');
+
+program
+ .version('0.0.1')
+ .option('-p, --peppers', 'Add peppers')
+ .option('-P, --pineapple', 'Add pineapple')
+ .option('-b, --bbq', 'Add bbq sauce')
+ .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
+ .parse(process.argv);
+
+console.log('you ordered a pizza with:');
+if (program.peppers) console.log(' - peppers');
+if (program.pineapple) console.log(' - pineapple');
+if (program.bbq) console.log(' - bbq');
+console.log(' - %s cheese', program.cheese);
+```
+
+ Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc.
+
+
+## Coercion
+
+```js
+function range(val) {
+ return val.split('..').map(Number);
+}
+
+function list(val) {
+ return val.split(',');
+}
+
+function collect(val, memo) {
+ memo.push(val);
+ return memo;
+}
+
+function increaseVerbosity(v, total) {
+ return total + 1;
+}
+
+program
+ .version('0.0.1')
+ .usage('[options] <file ...>')
+ .option('-i, --integer <n>', 'An integer argument', parseInt)
+ .option('-f, --float <n>', 'A float argument', parseFloat)
+ .option('-r, --range <a>..<b>', 'A range', range)
+ .option('-l, --list <items>', 'A list', list)
+ .option('-o, --optional [value]', 'An optional value')
+ .option('-c, --collect [value]', 'A repeatable value', collect, [])
+ .option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)
+ .parse(process.argv);
+
+console.log(' int: %j', program.integer);
+console.log(' float: %j', program.float);
+console.log(' optional: %j', program.optional);
+program.range = program.range || [];
+console.log(' range: %j..%j', program.range[0], program.range[1]);
+console.log(' list: %j', program.list);
+console.log(' collect: %j', program.collect);
+console.log(' verbosity: %j', program.verbose);
+console.log(' args: %j', program.args);
+```
+
+## Regular Expression
+```js
+program
+ .version('0.0.1')
+ .option('-s --size <size>', 'Pizza size', /^(large|medium|small)$/i, 'medium')
+ .option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i)
+ .parse(process.argv);
+
+console.log(' size: %j', program.size);
+console.log(' drink: %j', program.drink);
+```
+
+## Variadic arguments
+
+ The last argument of a command can be variadic, and only the last argument. To make an argument variadic you have to
+ append `...` to the argument name. Here is an example:
+
+```js
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var program = require('commander');
+
+program
+ .version('0.0.1')
+ .command('rmdir <dir> [otherDirs...]')
+ .action(function (dir, otherDirs) {
+ console.log('rmdir %s', dir);
+ if (otherDirs) {
+ otherDirs.forEach(function (oDir) {
+ console.log('rmdir %s', oDir);
+ });
+ }
+ });
+
+program.parse(process.argv);
+```
+
+ An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed
+ to your action as demonstrated above.
+
+## Git-style sub-commands
+
+```js
+// file: ./examples/pm
+var program = require('..');
+
+program
+ .version('0.0.1')
+ .command('install [name]', 'install one or more packages')
+ .command('search [query]', 'search with optional query')
+ .command('list', 'list packages installed')
+ .parse(process.argv);
+```
+
+When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.
+The commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`.
+
+If the program is designed to installed globally, make sure the executables have proper modes, like `755`.
+
+## Automated --help
+
+ The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:
+
+```
+ $ ./examples/pizza --help
+
+ Usage: pizza [options]
+
+ An application for pizzas ordering
+
+ Options:
+
+ -h, --help output usage information
+ -V, --version output the version number
+ -p, --peppers Add peppers
+ -P, --pineapple Add pineapple
+ -b, --bbq Add bbq sauce
+ -c, --cheese <type> Add the specified type of cheese [marble]
+ -C, --no-cheese You do not want any cheese
+
+```
+
+## Custom help
+
+ You can display arbitrary `-h, --help` information
+ by listening for "--help". Commander will automatically
+ exit once you are done so that the remainder of your program
+ does not execute causing undesired behaviours, for example
+ in the following executable "stuff" will not output when
+ `--help` is used.
+
+```js
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var program = require('commander');
+
+program
+ .version('0.0.1')
+ .option('-f, --foo', 'enable some foo')
+ .option('-b, --bar', 'enable some bar')
+ .option('-B, --baz', 'enable some baz');
+
+// must be before .parse() since
+// node's emit() is immediate
+
+program.on('--help', function(){
+ console.log(' Examples:');
+ console.log('');
+ console.log(' $ custom-help --help');
+ console.log(' $ custom-help -h');
+ console.log('');
+});
+
+program.parse(process.argv);
+
+console.log('stuff');
+```
+
+Yields the following help output when `node script-name.js -h` or `node script-name.js --help` are run:
+
+```
+
+Usage: custom-help [options]
+
+Options:
+
+ -h, --help output usage information
+ -V, --version output the version number
+ -f, --foo enable some foo
+ -b, --bar enable some bar
+ -B, --baz enable some baz
+
+Examples:
+
+ $ custom-help --help
+ $ custom-help -h
+
+```
+
+## .outputHelp()
+
+Output help information without exiting.
+
+If you want to display help by default (e.g. if no command was provided), you can use something like:
+
+```js
+var program = require('commander');
+
+program
+ .version('0.0.1')
+ .command('getstream [url]', 'get stream URL')
+ .parse(process.argv);
+
+ if (!process.argv.slice(2).length) {
+ program.outputHelp();
+ }
+```
+
+## .help()
+
+ Output help information and exit immediately.
+
+## Examples
+
+```js
+var program = require('commander');
+
+program
+ .version('0.0.1')
+ .option('-C, --chdir <path>', 'change the working directory')
+ .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
+ .option('-T, --no-tests', 'ignore test hook')
+
+program
+ .command('setup [env]')
+ .description('run setup commands for all envs')
+ .option("-s, --setup_mode [mode]", "Which setup mode to use")
+ .action(function(env, options){
+ var mode = options.setup_mode || "normal";
+ env = env || 'all';
+ console.log('setup for %s env(s) with %s mode', env, mode);
+ });
+
+program
+ .command('exec <cmd>')
+ .alias('ex')
+ .description('execute the given remote cmd')
+ .option("-e, --exec_mode <mode>", "Which exec mode to use")
+ .action(function(cmd, options){
+ console.log('exec "%s" using %s mode', cmd, options.exec_mode);
+ }).on('--help', function() {
+ console.log(' Examples:');
+ console.log();
+ console.log(' $ deploy exec sequential');
+ console.log(' $ deploy exec async');
+ console.log();
+ });
+
+program
+ .command('*')
+ .action(function(env){
+ console.log('deploying "%s"', env);
+ });
+
+program.parse(process.argv);
+```
+
+More Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
+
+## License
+
+MIT
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/index.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/index.js
new file mode 100644
index 0000000..1abf4df
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/index.js
@@ -0,0 +1,1051 @@
+
+/**
+ * Module dependencies.
+ */
+
+var EventEmitter = require('events').EventEmitter;
+var spawn = require('child_process').spawn;
+var readlink = require('graceful-readlink').readlinkSync;
+var path = require('path');
+var dirname = path.dirname;
+var basename = path.basename;
+var fs = require('fs');
+
+/**
+ * Expose the root command.
+ */
+
+exports = module.exports = new Command();
+
+/**
+ * Expose `Command`.
+ */
+
+exports.Command = Command;
+
+/**
+ * Expose `Option`.
+ */
+
+exports.Option = Option;
+
+/**
+ * Initialize a new `Option` with the given `flags` and `description`.
+ *
+ * @param {String} flags
+ * @param {String} description
+ * @api public
+ */
+
+function Option(flags, description) {
+ this.flags = flags;
+ this.required = ~flags.indexOf('<');
+ this.optional = ~flags.indexOf('[');
+ this.bool = !~flags.indexOf('-no-');
+ flags = flags.split(/[ ,|]+/);
+ if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
+ this.long = flags.shift();
+ this.description = description || '';
+}
+
+/**
+ * Return option name.
+ *
+ * @return {String}
+ * @api private
+ */
+
+Option.prototype.name = function() {
+ return this.long
+ .replace('--', '')
+ .replace('no-', '');
+};
+
+/**
+ * Check if `arg` matches the short or long flag.
+ *
+ * @param {String} arg
+ * @return {Boolean}
+ * @api private
+ */
+
+Option.prototype.is = function(arg) {
+ return arg == this.short || arg == this.long;
+};
+
+/**
+ * Initialize a new `Command`.
+ *
+ * @param {String} name
+ * @api public
+ */
+
+function Command(name) {
+ this.commands = [];
+ this.options = [];
+ this._execs = [];
+ this._allowUnknownOption = false;
+ this._args = [];
+ this._name = name;
+}
+
+/**
+ * Inherit from `EventEmitter.prototype`.
+ */
+
+Command.prototype.__proto__ = EventEmitter.prototype;
+
+/**
+ * Add command `name`.
+ *
+ * The `.action()` callback is invoked when the
+ * command `name` is specified via __ARGV__,
+ * and the remaining arguments are applied to the
+ * function for access.
+ *
+ * When the `name` is "*" an un-matched command
+ * will be passed as the first arg, followed by
+ * the rest of __ARGV__ remaining.
+ *
+ * Examples:
+ *
+ * program
+ * .version('0.0.1')
+ * .option('-C, --chdir <path>', 'change the working directory')
+ * .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
+ * .option('-T, --no-tests', 'ignore test hook')
+ *
+ * program
+ * .command('setup')
+ * .description('run remote setup commands')
+ * .action(function() {
+ * console.log('setup');
+ * });
+ *
+ * program
+ * .command('exec <cmd>')
+ * .description('run the given remote command')
+ * .action(function(cmd) {
+ * console.log('exec "%s"', cmd);
+ * });
+ *
+ * program
+ * .command('teardown <dir> [otherDirs...]')
+ * .description('run teardown commands')
+ * .action(function(dir, otherDirs) {
+ * console.log('dir "%s"', dir);
+ * if (otherDirs) {
+ * otherDirs.forEach(function (oDir) {
+ * console.log('dir "%s"', oDir);
+ * });
+ * }
+ * });
+ *
+ * program
+ * .command('*')
+ * .description('deploy the given env')
+ * .action(function(env) {
+ * console.log('deploying "%s"', env);
+ * });
+ *
+ * program.parse(process.argv);
+ *
+ * @param {String} name
+ * @param {String} [desc] for git-style sub-commands
+ * @return {Command} the new command
+ * @api public
+ */
+
+Command.prototype.command = function(name, desc) {
+ var args = name.split(/ +/);
+ var cmd = new Command(args.shift());
+
+ if (desc) {
+ cmd.description(desc);
+ this.executables = true;
+ this._execs[cmd._name] = true;
+ }
+
+ this.commands.push(cmd);
+ cmd.parseExpectedArgs(args);
+ cmd.parent = this;
+
+ if (desc) return this;
+ return cmd;
+};
+
+/**
+ * Add an implicit `help [cmd]` subcommand
+ * which invokes `--help` for the given command.
+ *
+ * @api private
+ */
+
+Command.prototype.addImplicitHelpCommand = function() {
+ this.command('help [cmd]', 'display help for [cmd]');
+};
+
+/**
+ * Parse expected `args`.
+ *
+ * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
+ *
+ * @param {Array} args
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.parseExpectedArgs = function(args) {
+ if (!args.length) return;
+ var self = this;
+ args.forEach(function(arg) {
+ var argDetails = {
+ required: false,
+ name: '',
+ variadic: false
+ };
+
+ switch (arg[0]) {
+ case '<':
+ argDetails.required = true;
+ argDetails.name = arg.slice(1, -1);
+ break;
+ case '[':
+ argDetails.name = arg.slice(1, -1);
+ break;
+ }
+
+ if (argDetails.name.length > 3 && argDetails.name.slice(-3) === '...') {
+ argDetails.variadic = true;
+ argDetails.name = argDetails.name.slice(0, -3);
+ }
+ if (argDetails.name) {
+ self._args.push(argDetails);
+ }
+ });
+ return this;
+};
+
+/**
+ * Register callback `fn` for the command.
+ *
+ * Examples:
+ *
+ * program
+ * .command('help')
+ * .description('display verbose help')
+ * .action(function() {
+ * // output help here
+ * });
+ *
+ * @param {Function} fn
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.action = function(fn) {
+ var self = this;
+ var listener = function(args, unknown) {
+ // Parse any so-far unknown options
+ args = args || [];
+ unknown = unknown || [];
+
+ var parsed = self.parseOptions(unknown);
+
+ // Output help if necessary
+ outputHelpIfNecessary(self, parsed.unknown);
+
+ // If there are still any unknown options, then we simply
+ // die, unless someone asked for help, in which case we give it
+ // to them, and then we die.
+ if (parsed.unknown.length > 0) {
+ self.unknownOption(parsed.unknown[0]);
+ }
+
+ // Leftover arguments need to be pushed back. Fixes issue #56
+ if (parsed.args.length) args = parsed.args.concat(args);
+
+ self._args.forEach(function(arg, i) {
+ if (arg.required && null == args[i]) {
+ self.missingArgument(arg.name);
+ } else if (arg.variadic) {
+ if (i !== self._args.length - 1) {
+ self.variadicArgNotLast(arg.name);
+ }
+
+ args[i] = args.splice(i);
+ }
+ });
+
+ // Always append ourselves to the end of the arguments,
+ // to make sure we match the number of arguments the user
+ // expects
+ if (self._args.length) {
+ args[self._args.length] = self;
+ } else {
+ args.push(self);
+ }
+
+ fn.apply(self, args);
+ };
+ this.parent.on(this._name, listener);
+ if (this._alias) this.parent.on(this._alias, listener);
+ return this;
+};
+
+/**
+ * Define option with `flags`, `description` and optional
+ * coercion `fn`.
+ *
+ * The `flags` string should contain both the short and long flags,
+ * separated by comma, a pipe or space. The following are all valid
+ * all will output this way when `--help` is used.
+ *
+ * "-p, --pepper"
+ * "-p|--pepper"
+ * "-p --pepper"
+ *
+ * Examples:
+ *
+ * // simple boolean defaulting to false
+ * program.option('-p, --pepper', 'add pepper');
+ *
+ * --pepper
+ * program.pepper
+ * // => Boolean
+ *
+ * // simple boolean defaulting to true
+ * program.option('-C, --no-cheese', 'remove cheese');
+ *
+ * program.cheese
+ * // => true
+ *
+ * --no-cheese
+ * program.cheese
+ * // => false
+ *
+ * // required argument
+ * program.option('-C, --chdir <path>', 'change the working directory');
+ *
+ * --chdir /tmp
+ * program.chdir
+ * // => "/tmp"
+ *
+ * // optional argument
+ * program.option('-c, --cheese [type]', 'add cheese [marble]');
+ *
+ * @param {String} flags
+ * @param {String} description
+ * @param {Function|Mixed} fn or default
+ * @param {Mixed} defaultValue
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.option = function(flags, description, fn, defaultValue) {
+ var self = this
+ , option = new Option(flags, description)
+ , oname = option.name()
+ , name = camelcase(oname);
+
+ // default as 3rd arg
+ if (typeof fn != 'function') {
+ if (fn instanceof RegExp) {
+ var regex = fn;
+ fn = function(val, def) {
+ var m = regex.exec(val);
+ return m ? m[0] : def;
+ }
+ }
+ else {
+ defaultValue = fn;
+ fn = null;
+ }
+ }
+
+ // preassign default value only for --no-*, [optional], or <required>
+ if (false == option.bool || option.optional || option.required) {
+ // when --no-* we make sure default is true
+ if (false == option.bool) defaultValue = true;
+ // preassign only if we have a default
+ if (undefined !== defaultValue) self[name] = defaultValue;
+ }
+
+ // register the option
+ this.options.push(option);
+
+ // when it's passed assign the value
+ // and conditionally invoke the callback
+ this.on(oname, function(val) {
+ // coercion
+ if (null !== val && fn) val = fn(val, undefined === self[name]
+ ? defaultValue
+ : self[name]);
+
+ // unassigned or bool
+ if ('boolean' == typeof self[name] || 'undefined' == typeof self[name]) {
+ // if no value, bool true, and we have a default, then use it!
+ if (null == val) {
+ self[name] = option.bool
+ ? defaultValue || true
+ : false;
+ } else {
+ self[name] = val;
+ }
+ } else if (null !== val) {
+ // reassign
+ self[name] = val;
+ }
+ });
+
+ return this;
+};
+
+/**
+ * Allow unknown options on the command line.
+ *
+ * @param {Boolean} arg if `true` or omitted, no error will be thrown
+ * for unknown options.
+ * @api public
+ */
+Command.prototype.allowUnknownOption = function(arg) {
+ this._allowUnknownOption = arguments.length === 0 || arg;
+ return this;
+};
+
+/**
+ * Parse `argv`, settings options and invoking commands when defined.
+ *
+ * @param {Array} argv
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.parse = function(argv) {
+ // implicit help
+ if (this.executables) this.addImplicitHelpCommand();
+
+ // store raw args
+ this.rawArgs = argv;
+
+ // guess name
+ this._name = this._name || basename(argv[1], '.js');
+
+ // process argv
+ var parsed = this.parseOptions(this.normalize(argv.slice(2)));
+ var args = this.args = parsed.args;
+
+ var result = this.parseArgs(this.args, parsed.unknown);
+
+ // executable sub-commands
+ var name = result.args[0];
+ if (this._execs[name] && typeof this._execs[name] != "function") {
+ return this.executeSubCommand(argv, args, parsed.unknown);
+ }
+
+ return result;
+};
+
+/**
+ * Execute a sub-command executable.
+ *
+ * @param {Array} argv
+ * @param {Array} args
+ * @param {Array} unknown
+ * @api private
+ */
+
+Command.prototype.executeSubCommand = function(argv, args, unknown) {
+ args = args.concat(unknown);
+
+ if (!args.length) this.help();
+ if ('help' == args[0] && 1 == args.length) this.help();
+
+ // <cmd> --help
+ if ('help' == args[0]) {
+ args[0] = args[1];
+ args[1] = '--help';
+ }
+
+ // executable
+ var f = argv[1];
+ var link = readlink(f);
+ if (link !== f && link.charAt(0) !== '/') {
+ link = path.join(dirname(f), link)
+ }
+ var dir = dirname(link);
+ var bin = basename(f, '.js') + '-' + args[0];
+
+ // prefer local `./<bin>` to bin in the $PATH
+ var local = path.join(dir, bin);
+ try {
+ // for versions before node v0.8 when there weren't `fs.existsSync`
+ if (fs.statSync(local).isFile()) {
+ bin = local;
+ }
+ } catch (e) {}
+
+ // run it
+ args = args.slice(1);
+
+ var proc;
+ if (process.platform !== 'win32') {
+ proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
+ } else {
+ args.unshift(local);
+ proc = spawn(process.execPath, args, { stdio: 'inherit'});
+ }
+
+ proc.on('close', process.exit.bind(process));
+ proc.on('error', function(err) {
+ if (err.code == "ENOENT") {
+ console.error('\n %s(1) does not exist, try --help\n', bin);
+ } else if (err.code == "EACCES") {
+ console.error('\n %s(1) not executable. try chmod or run with root\n', bin);
+ }
+ process.exit(1);
+ });
+
+ this.runningCommand = proc;
+};
+
+/**
+ * Normalize `args`, splitting joined short flags. For example
+ * the arg "-abc" is equivalent to "-a -b -c".
+ * This also normalizes equal sign and splits "--abc=def" into "--abc def".
+ *
+ * @param {Array} args
+ * @return {Array}
+ * @api private
+ */
+
+Command.prototype.normalize = function(args) {
+ var ret = []
+ , arg
+ , lastOpt
+ , index;
+
+ for (var i = 0, len = args.length; i < len; ++i) {
+ arg = args[i];
+ if (i > 0) {
+ lastOpt = this.optionFor(args[i-1]);
+ }
+
+ if (arg === '--') {
+ // Honor option terminator
+ ret = ret.concat(args.slice(i));
+ break;
+ } else if (lastOpt && lastOpt.required) {
+ ret.push(arg);
+ } else if (arg.length > 1 && '-' == arg[0] && '-' != arg[1]) {
+ arg.slice(1).split('').forEach(function(c) {
+ ret.push('-' + c);
+ });
+ } else if (/^--/.test(arg) && ~(index = arg.indexOf('='))) {
+ ret.push(arg.slice(0, index), arg.slice(index + 1));
+ } else {
+ ret.push(arg);
+ }
+ }
+
+ return ret;
+};
+
+/**
+ * Parse command `args`.
+ *
+ * When listener(s) are available those
+ * callbacks are invoked, otherwise the "*"
+ * event is emitted and those actions are invoked.
+ *
+ * @param {Array} args
+ * @return {Command} for chaining
+ * @api private
+ */
+
+Command.prototype.parseArgs = function(args, unknown) {
+ var name;
+
+ if (args.length) {
+ name = args[0];
+ if (this.listeners(name).length) {
+ this.emit(args.shift(), args, unknown);
+ } else {
+ this.emit('*', args);
+ }
+ } else {
+ outputHelpIfNecessary(this, unknown);
+
+ // If there were no args and we have unknown options,
+ // then they are extraneous and we need to error.
+ if (unknown.length > 0) {
+ this.unknownOption(unknown[0]);
+ }
+ }
+
+ return this;
+};
+
+/**
+ * Return an option matching `arg` if any.
+ *
+ * @param {String} arg
+ * @return {Option}
+ * @api private
+ */
+
+Command.prototype.optionFor = function(arg) {
+ for (var i = 0, len = this.options.length; i < len; ++i) {
+ if (this.options[i].is(arg)) {
+ return this.options[i];
+ }
+ }
+};
+
+/**
+ * Parse options from `argv` returning `argv`
+ * void of these options.
+ *
+ * @param {Array} argv
+ * @return {Array}
+ * @api public
+ */
+
+Command.prototype.parseOptions = function(argv) {
+ var args = []
+ , len = argv.length
+ , literal
+ , option
+ , arg;
+
+ var unknownOptions = [];
+
+ // parse options
+ for (var i = 0; i < len; ++i) {
+ arg = argv[i];
+
+ // literal args after --
+ if ('--' == arg) {
+ literal = true;
+ continue;
+ }
+
+ if (literal) {
+ args.push(arg);
+ continue;
+ }
+
+ // find matching Option
+ option = this.optionFor(arg);
+
+ // option is defined
+ if (option) {
+ // requires arg
+ if (option.required) {
+ arg = argv[++i];
+ if (null == arg) return this.optionMissingArgument(option);
+ this.emit(option.name(), arg);
+ // optional arg
+ } else if (option.optional) {
+ arg = argv[i+1];
+ if (null == arg || ('-' == arg[0] && '-' != arg)) {
+ arg = null;
+ } else {
+ ++i;
+ }
+ this.emit(option.name(), arg);
+ // bool
+ } else {
+ this.emit(option.name());
+ }
+ continue;
+ }
+
+ // looks like an option
+ if (arg.length > 1 && '-' == arg[0]) {
+ unknownOptions.push(arg);
+
+ // If the next argument looks like it might be
+ // an argument for this option, we pass it on.
+ // If it isn't, then it'll simply be ignored
+ if (argv[i+1] && '-' != argv[i+1][0]) {
+ unknownOptions.push(argv[++i]);
+ }
+ continue;
+ }
+
+ // arg
+ args.push(arg);
+ }
+
+ return { args: args, unknown: unknownOptions };
+};
+
+/**
+ * Return an object containing options as key-value pairs
+ *
+ * @return {Object}
+ * @api public
+ */
+Command.prototype.opts = function() {
+ var result = {}
+ , len = this.options.length;
+
+ for (var i = 0 ; i < len; i++) {
+ var key = camelcase(this.options[i].name());
+ result[key] = key === 'version' ? this._version : this[key];
+ }
+ return result;
+};
+
+/**
+ * Argument `name` is missing.
+ *
+ * @param {String} name
+ * @api private
+ */
+
+Command.prototype.missingArgument = function(name) {
+ console.error();
+ console.error(" error: missing required argument `%s'", name);
+ console.error();
+ process.exit(1);
+};
+
+/**
+ * `Option` is missing an argument, but received `flag` or nothing.
+ *
+ * @param {String} option
+ * @param {String} flag
+ * @api private
+ */
+
+Command.prototype.optionMissingArgument = function(option, flag) {
+ console.error();
+ if (flag) {
+ console.error(" error: option `%s' argument missing, got `%s'", option.flags, flag);
+ } else {
+ console.error(" error: option `%s' argument missing", option.flags);
+ }
+ console.error();
+ process.exit(1);
+};
+
+/**
+ * Unknown option `flag`.
+ *
+ * @param {String} flag
+ * @api private
+ */
+
+Command.prototype.unknownOption = function(flag) {
+ if (this._allowUnknownOption) return;
+ console.error();
+ console.error(" error: unknown option `%s'", flag);
+ console.error();
+ process.exit(1);
+};
+
+/**
+ * Variadic argument with `name` is not the last argument as required.
+ *
+ * @param {String} name
+ * @api private
+ */
+
+Command.prototype.variadicArgNotLast = function(name) {
+ console.error();
+ console.error(" error: variadic arguments must be last `%s'", name);
+ console.error();
+ process.exit(1);
+};
+
+/**
+ * Set the program version to `str`.
+ *
+ * This method auto-registers the "-V, --version" flag
+ * which will print the version number when passed.
+ *
+ * @param {String} str
+ * @param {String} flags
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.version = function(str, flags) {
+ if (0 == arguments.length) return this._version;
+ this._version = str;
+ flags = flags || '-V, --version';
+ this.option(flags, 'output the version number');
+ this.on('version', function() {
+ process.stdout.write(str + '\n');
+ process.exit(0);
+ });
+ return this;
+};
+
+/**
+ * Set the description to `str`.
+ *
+ * @param {String} str
+ * @return {String|Command}
+ * @api public
+ */
+
+Command.prototype.description = function(str) {
+ if (0 == arguments.length) return this._description;
+ this._description = str;
+ return this;
+};
+
+/**
+ * Set an alias for the command
+ *
+ * @param {String} alias
+ * @return {String|Command}
+ * @api public
+ */
+
+Command.prototype.alias = function(alias) {
+ if (0 == arguments.length) return this._alias;
+ this._alias = alias;
+ return this;
+};
+
+/**
+ * Set / get the command usage `str`.
+ *
+ * @param {String} str
+ * @return {String|Command}
+ * @api public
+ */
+
+Command.prototype.usage = function(str) {
+ var args = this._args.map(function(arg) {
+ return humanReadableArgName(arg);
+ });
+
+ var usage = '[options]'
+ + (this.commands.length ? ' [command]' : '')
+ + (this._args.length ? ' ' + args.join(' ') : '');
+
+ if (0 == arguments.length) return this._usage || usage;
+ this._usage = str;
+
+ return this;
+};
+
+/**
+ * Get the name of the command
+ *
+ * @param {String} name
+ * @return {String|Command}
+ * @api public
+ */
+
+Command.prototype.name = function() {
+ return this._name;
+};
+
+/**
+ * Return the largest option length.
+ *
+ * @return {Number}
+ * @api private
+ */
+
+Command.prototype.largestOptionLength = function() {
+ return this.options.reduce(function(max, option) {
+ return Math.max(max, option.flags.length);
+ }, 0);
+};
+
+/**
+ * Return help for options.
+ *
+ * @return {String}
+ * @api private
+ */
+
+Command.prototype.optionHelp = function() {
+ var width = this.largestOptionLength();
+
+ // Prepend the help information
+ return [pad('-h, --help', width) + ' ' + 'output usage information']
+ .concat(this.options.map(function(option) {
+ return pad(option.flags, width) + ' ' + option.description;
+ }))
+ .join('\n');
+};
+
+/**
+ * Return command help documentation.
+ *
+ * @return {String}
+ * @api private
+ */
+
+Command.prototype.commandHelp = function() {
+ if (!this.commands.length) return '';
+
+ var commands = this.commands.map(function(cmd) {
+ var args = cmd._args.map(function(arg) {
+ return humanReadableArgName(arg);
+ }).join(' ');
+
+ return [
+ cmd._name
+ + (cmd._alias
+ ? '|' + cmd._alias
+ : '')
+ + (cmd.options.length
+ ? ' [options]'
+ : '')
+ + ' ' + args
+ , cmd.description()
+ ];
+ });
+
+ var width = commands.reduce(function(max, command) {
+ return Math.max(max, command[0].length);
+ }, 0);
+
+ return [
+ ''
+ , ' Commands:'
+ , ''
+ , commands.map(function(cmd) {
+ return pad(cmd[0], width) + ' ' + cmd[1];
+ }).join('\n').replace(/^/gm, ' ')
+ , ''
+ ].join('\n');
+};
+
+/**
+ * Return program help documentation.
+ *
+ * @return {String}
+ * @api private
+ */
+
+Command.prototype.helpInformation = function() {
+ var desc = [];
+ if (this._description) {
+ desc = [
+ ' ' + this._description
+ , ''
+ ];
+ }
+
+ var cmdName = this._name;
+ if (this._alias) {
+ cmdName = cmdName + '|' + this._alias;
+ }
+ var usage = [
+ ''
+ ,' Usage: ' + cmdName + ' ' + this.usage()
+ , ''
+ ];
+
+ var cmds = [];
+ var commandHelp = this.commandHelp();
+ if (commandHelp) cmds = [commandHelp];
+
+ var options = [
+ ' Options:'
+ , ''
+ , '' + this.optionHelp().replace(/^/gm, ' ')
+ , ''
+ , ''
+ ];
+
+ return usage
+ .concat(cmds)
+ .concat(desc)
+ .concat(options)
+ .join('\n');
+};
+
+/**
+ * Output help information for this command
+ *
+ * @api public
+ */
+
+Command.prototype.outputHelp = function() {
+ process.stdout.write(this.helpInformation());
+ this.emit('--help');
+};
+
+/**
+ * Output help information and exit.
+ *
+ * @api public
+ */
+
+Command.prototype.help = function() {
+ this.outputHelp();
+ process.exit();
+};
+
+/**
+ * Camel-case the given `flag`
+ *
+ * @param {String} flag
+ * @return {String}
+ * @api private
+ */
+
+function camelcase(flag) {
+ return flag.split('-').reduce(function(str, word) {
+ return str + word[0].toUpperCase() + word.slice(1);
+ });
+}
+
+/**
+ * Pad `str` to `width`.
+ *
+ * @param {String} str
+ * @param {Number} width
+ * @return {String}
+ * @api private
+ */
+
+function pad(str, width) {
+ var len = Math.max(0, width - str.length);
+ return str + Array(len + 1).join(' ');
+}
+
+/**
+ * Output help information if necessary
+ *
+ * @param {Command} command to output help for
+ * @param {Array} array of options to search for -h or --help
+ * @api private
+ */
+
+function outputHelpIfNecessary(cmd, options) {
+ options = options || [];
+ for (var i = 0; i < options.length; i++) {
+ if (options[i] == '--help' || options[i] == '-h') {
+ cmd.outputHelp();
+ process.exit(0);
+ }
+ }
+}
+
+/**
+ * Takes an argument an returns its human readable equivalent for help usage.
+ *
+ * @param {Object} arg
+ * @return {String}
+ * @api private
+ */
+
+function humanReadableArgName(arg) {
+ var nameOutput = arg.name + (arg.variadic === true ? '...' : '');
+
+ return arg.required
+ ? '<' + nameOutput + '>'
+ : '[' + nameOutput + ']'
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/.npmignore b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/.npmignore
new file mode 100644
index 0000000..3ac7d16
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/.npmignore
@@ -0,0 +1,3 @@
+.idea/
+.DS_Store
+node_modules/
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/.travis.yml
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/.travis.yml b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/.travis.yml
new file mode 100644
index 0000000..baf9be7
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - "0.10"
+ - "0.12"
+ - "io.js"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/LICENSE b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/LICENSE
new file mode 100644
index 0000000..d1f842f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Zhiye Li
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/README.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/README.md
new file mode 100644
index 0000000..fc63b50
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/README.md
@@ -0,0 +1,17 @@
+# graceful-readlink
+[](https://www.npmjs.org/package/graceful-readlink)
+[](https://www.npmjs.org/package/graceful-readlink)
+
+
+## Usage
+
+```js
+var readlinkSync = require('graceful-readlink').readlinkSync;
+console.log(readlinkSync(f));
+// output
+// the file pointed to when `f` is a symbolic link
+// the `f` itself when `f` is not a symbolic link
+```
+## Licence
+
+MIT License
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/index.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/index.js
new file mode 100644
index 0000000..7e9fc70
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/index.js
@@ -0,0 +1,12 @@
+var fs = require('fs')
+ , lstat = fs.lstatSync;
+
+exports.readlinkSync = function (p) {
+ if (lstat(p).isSymbolicLink()) {
+ return fs.readlinkSync(p);
+ } else {
+ return p;
+ }
+};
+
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/package.json
new file mode 100644
index 0000000..00bc841
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/node_modules/graceful-readlink/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "graceful-readlink",
+ "version": "1.0.1",
+ "description": "graceful fs.readlink",
+ "main": "index.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/zhiyelee/graceful-readlink.git"
+ },
+ "homepage": "https://github.com/zhiyelee/graceful-readlink",
+ "bugs": {
+ "url": "https://github.com/zhiyelee/graceful-readlink/issues"
+ },
+ "keywords": [
+ "fs.readlink",
+ "readlink"
+ ],
+ "author": {
+ "name": "zhiyelee"
+ },
+ "license": "MIT",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "gitHead": "f6655275bebef706fb63fd01b5f062a7052419a5",
+ "_id": "graceful-readlink@1.0.1",
+ "_shasum": "4cafad76bc62f02fa039b2f94e9a3dd3a391a725",
+ "_from": "graceful-readlink@>= 1.0.0",
+ "_npmVersion": "2.1.17",
+ "_nodeVersion": "0.11.14",
+ "_npmUser": {
+ "name": "zhiyelee",
+ "email": "zhiyelee@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "zhiyelee",
+ "email": "zhiyelee@gmail.com"
+ }
+ ],
+ "dist": {
+ "shasum": "4cafad76bc62f02fa039b2f94e9a3dd3a391a725",
+ "tarball": "http://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/package.json
new file mode 100644
index 0000000..d39156f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/package.json
@@ -0,0 +1,74 @@
+{
+ "name": "commander",
+ "version": "2.7.1",
+ "description": "the complete solution for node.js command-line programs",
+ "keywords": [
+ "command",
+ "option",
+ "parser"
+ ],
+ "author": {
+ "name": "TJ Holowaychuk",
+ "email": "tj@vision-media.ca"
+ },
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/tj/commander.js.git"
+ },
+ "devDependencies": {
+ "should": ">= 0.0.1"
+ },
+ "scripts": {
+ "test": "make test"
+ },
+ "main": "index",
+ "engines": {
+ "node": ">= 0.6.x"
+ },
+ "files": [
+ "index.js"
+ ],
+ "dependencies": {
+ "graceful-readlink": ">= 1.0.0"
+ },
+ "gitHead": "103654f8f32c010ad1e62cefc9ab92d7c8d18c8e",
+ "bugs": {
+ "url": "https://github.com/tj/commander.js/issues"
+ },
+ "homepage": "https://github.com/tj/commander.js",
+ "_id": "commander@2.7.1",
+ "_shasum": "5d419a2bbed2c32ee3e4dca9bb45ab83ecc3065a",
+ "_from": "commander@^2.3.0",
+ "_npmVersion": "2.1.17",
+ "_nodeVersion": "0.11.14",
+ "_npmUser": {
+ "name": "zhiyelee",
+ "email": "zhiyelee@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "tjholowaychuk",
+ "email": "tj@vision-media.ca"
+ },
+ {
+ "name": "somekittens",
+ "email": "rkoutnik@gmail.com"
+ },
+ {
+ "name": "zhiyelee",
+ "email": "zhiyelee@gmail.com"
+ },
+ {
+ "name": "thethomaseffect",
+ "email": "thethomaseffect@gmail.com"
+ }
+ ],
+ "dist": {
+ "shasum": "5d419a2bbed2c32ee3e4dca9bb45ab83ecc3065a",
+ "tarball": "http://registry.npmjs.org/commander/-/commander-2.7.1.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/commander/-/commander-2.7.1.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/Readme.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/Readme.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/Readme.md
new file mode 100644
index 0000000..c5a34e8
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/Readme.md
@@ -0,0 +1,115 @@
+# debug
+
+ tiny node.js debugging utility modelled after node core's debugging technique.
+
+## Installation
+
+```
+$ npm install debug
+```
+
+## Usage
+
+ With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.
+
+Example _app.js_:
+
+```js
+var debug = require('debug')('http')
+ , http = require('http')
+ , name = 'My App';
+
+// fake app
+
+debug('booting %s', name);
+
+http.createServer(function(req, res){
+ debug(req.method + ' ' + req.url);
+ res.end('hello\n');
+}).listen(3000, function(){
+ debug('listening');
+});
+
+// fake worker of some kind
+
+require('./worker');
+```
+
+Example _worker.js_:
+
+```js
+var debug = require('debug')('worker');
+
+setInterval(function(){
+ debug('doing some work');
+}, 1000);
+```
+
+ The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:
+
+ 
+
+ 
+
+## Millisecond diff
+
+ When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
+
+ 
+
+ When stderr is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
+ _(NOTE: Debug now uses stderr instead of stdout, so the correct shell command for this example is actually `DEBUG=* node example/worker 2> out &`)_
+
+ 
+
+## Conventions
+
+ If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser".
+
+## Wildcards
+
+ The "*" character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
+
+ You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=* -connect:*` would include all debuggers except those starting with "connect:".
+
+## Browser support
+
+ Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`.
+
+```js
+a = debug('worker:a');
+b = debug('worker:b');
+
+setInterval(function(){
+ a('doing some work');
+}, 1000);
+
+setInterval(function(){
+ a('doing some work');
+}, 1200);
+```
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/debug.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/debug.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/debug.js
new file mode 100644
index 0000000..509dc0d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/debug.js
@@ -0,0 +1,137 @@
+
+/**
+ * Expose `debug()` as the module.
+ */
+
+module.exports = debug;
+
+/**
+ * Create a debugger with the given `name`.
+ *
+ * @param {String} name
+ * @return {Type}
+ * @api public
+ */
+
+function debug(name) {
+ if (!debug.enabled(name)) return function(){};
+
+ return function(fmt){
+ fmt = coerce(fmt);
+
+ var curr = new Date;
+ var ms = curr - (debug[name] || curr);
+ debug[name] = curr;
+
+ fmt = name
+ + ' '
+ + fmt
+ + ' +' + debug.humanize(ms);
+
+ // This hackery is required for IE8
+ // where `console.log` doesn't have 'apply'
+ window.console
+ && console.log
+ && Function.prototype.apply.call(console.log, console, arguments);
+ }
+}
+
+/**
+ * The currently active debug mode names.
+ */
+
+debug.names = [];
+debug.skips = [];
+
+/**
+ * Enables a debug mode by name. This can include modes
+ * separated by a colon and wildcards.
+ *
+ * @param {String} name
+ * @api public
+ */
+
+debug.enable = function(name) {
+ try {
+ localStorage.debug = name;
+ } catch(e){}
+
+ var split = (name || '').split(/[\s,]+/)
+ , len = split.length;
+
+ for (var i = 0; i < len; i++) {
+ name = split[i].replace('*', '.*?');
+ if (name[0] === '-') {
+ debug.skips.push(new RegExp('^' + name.substr(1) + '$'));
+ }
+ else {
+ debug.names.push(new RegExp('^' + name + '$'));
+ }
+ }
+};
+
+/**
+ * Disable debug output.
+ *
+ * @api public
+ */
+
+debug.disable = function(){
+ debug.enable('');
+};
+
+/**
+ * Humanize the given `ms`.
+ *
+ * @param {Number} m
+ * @return {String}
+ * @api private
+ */
+
+debug.humanize = function(ms) {
+ var sec = 1000
+ , min = 60 * 1000
+ , hour = 60 * min;
+
+ if (ms >= hour) return (ms / hour).toFixed(1) + 'h';
+ if (ms >= min) return (ms / min).toFixed(1) + 'm';
+ if (ms >= sec) return (ms / sec | 0) + 's';
+ return ms + 'ms';
+};
+
+/**
+ * Returns true if the given mode name is enabled, false otherwise.
+ *
+ * @param {String} name
+ * @return {Boolean}
+ * @api public
+ */
+
+debug.enabled = function(name) {
+ for (var i = 0, len = debug.skips.length; i < len; i++) {
+ if (debug.skips[i].test(name)) {
+ return false;
+ }
+ }
+ for (var i = 0, len = debug.names.length; i < len; i++) {
+ if (debug.names[i].test(name)) {
+ return true;
+ }
+ }
+ return false;
+};
+
+/**
+ * Coerce `val`.
+ */
+
+function coerce(val) {
+ if (val instanceof Error) return val.stack || val.message;
+ return val;
+}
+
+// persist
+
+try {
+ if (window.localStorage) debug.enable(localStorage.debug);
+} catch(e){}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/index.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/index.js
new file mode 100644
index 0000000..e02c13b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/index.js
@@ -0,0 +1,5 @@
+if ('undefined' == typeof window) {
+ module.exports = require('./lib/debug');
+} else {
+ module.exports = require('./debug');
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/lib/debug.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/lib/debug.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/lib/debug.js
new file mode 100644
index 0000000..3b0a918
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/lib/debug.js
@@ -0,0 +1,147 @@
+/**
+ * Module dependencies.
+ */
+
+var tty = require('tty');
+
+/**
+ * Expose `debug()` as the module.
+ */
+
+module.exports = debug;
+
+/**
+ * Enabled debuggers.
+ */
+
+var names = []
+ , skips = [];
+
+(process.env.DEBUG || '')
+ .split(/[\s,]+/)
+ .forEach(function(name){
+ name = name.replace('*', '.*?');
+ if (name[0] === '-') {
+ skips.push(new RegExp('^' + name.substr(1) + '$'));
+ } else {
+ names.push(new RegExp('^' + name + '$'));
+ }
+ });
+
+/**
+ * Colors.
+ */
+
+var colors = [6, 2, 3, 4, 5, 1];
+
+/**
+ * Previous debug() call.
+ */
+
+var prev = {};
+
+/**
+ * Previously assigned color.
+ */
+
+var prevColor = 0;
+
+/**
+ * Is stdout a TTY? Colored output is disabled when `true`.
+ */
+
+var isatty = tty.isatty(2);
+
+/**
+ * Select a color.
+ *
+ * @return {Number}
+ * @api private
+ */
+
+function color() {
+ return colors[prevColor++ % colors.length];
+}
+
+/**
+ * Humanize the given `ms`.
+ *
+ * @param {Number} m
+ * @return {String}
+ * @api private
+ */
+
+function humanize(ms) {
+ var sec = 1000
+ , min = 60 * 1000
+ , hour = 60 * min;
+
+ if (ms >= hour) return (ms / hour).toFixed(1) + 'h';
+ if (ms >= min) return (ms / min).toFixed(1) + 'm';
+ if (ms >= sec) return (ms / sec | 0) + 's';
+ return ms + 'ms';
+}
+
+/**
+ * Create a debugger with the given `name`.
+ *
+ * @param {String} name
+ * @return {Type}
+ * @api public
+ */
+
+function debug(name) {
+ function disabled(){}
+ disabled.enabled = false;
+
+ var match = skips.some(function(re){
+ return re.test(name);
+ });
+
+ if (match) return disabled;
+
+ match = names.some(function(re){
+ return re.test(name);
+ });
+
+ if (!match) return disabled;
+ var c = color();
+
+ function colored(fmt) {
+ fmt = coerce(fmt);
+
+ var curr = new Date;
+ var ms = curr - (prev[name] || curr);
+ prev[name] = curr;
+
+ fmt = ' \u001b[9' + c + 'm' + name + ' '
+ + '\u001b[3' + c + 'm\u001b[90m'
+ + fmt + '\u001b[3' + c + 'm'
+ + ' +' + humanize(ms) + '\u001b[0m';
+
+ console.error.apply(this, arguments);
+ }
+
+ function plain(fmt) {
+ fmt = coerce(fmt);
+
+ fmt = new Date().toUTCString()
+ + ' ' + name + ' ' + fmt;
+ console.error.apply(this, arguments);
+ }
+
+ colored.enabled = plain.enabled = true;
+
+ return isatty || process.env.DEBUG_COLORS
+ ? colored
+ : plain;
+}
+
+/**
+ * Coerce `val`.
+ */
+
+function coerce(val) {
+ if (val instanceof Error) return val.stack || val.message;
+ return val;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/package.json
new file mode 100644
index 0000000..a88241d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/debug/package.json
@@ -0,0 +1,65 @@
+{
+ "name": "debug",
+ "version": "0.7.4",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/visionmedia/debug.git"
+ },
+ "description": "small debugging utility",
+ "keywords": [
+ "debug",
+ "log",
+ "debugger"
+ ],
+ "author": {
+ "name": "TJ Holowaychuk",
+ "email": "tj@vision-media.ca"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "mocha": "*"
+ },
+ "main": "lib/debug.js",
+ "browser": "./debug.js",
+ "engines": {
+ "node": "*"
+ },
+ "files": [
+ "lib/debug.js",
+ "debug.js",
+ "index.js"
+ ],
+ "component": {
+ "scripts": {
+ "debug/index.js": "index.js",
+ "debug/debug.js": "debug.js"
+ }
+ },
+ "bugs": {
+ "url": "https://github.com/visionmedia/debug/issues"
+ },
+ "homepage": "https://github.com/visionmedia/debug",
+ "_id": "debug@0.7.4",
+ "dist": {
+ "shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39",
+ "tarball": "http://registry.npmjs.org/debug/-/debug-0.7.4.tgz"
+ },
+ "_from": "debug@~0.7.4",
+ "_npmVersion": "1.3.13",
+ "_npmUser": {
+ "name": "tjholowaychuk",
+ "email": "tj@vision-media.ca"
+ },
+ "maintainers": [
+ {
+ "name": "tjholowaychuk",
+ "email": "tj@vision-media.ca"
+ }
+ ],
+ "directories": {},
+ "_shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39",
+ "_resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz",
+ "readme": "# debug\n\n tiny node.js debugging utility modelled after node core's debugging technique.\n\n## Installation\n\n```\n$ npm install debug\n```\n\n## Usage\n\n With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.\n \nExample _app.js_:\n\n```js\nvar debug = require('debug')('http')\n , http = require('http')\n , name = 'My App';\n\n// fake app\n\ndebug('booting %s', name);\n\nhttp.createServer(function(req, res){\n debug(req.method + ' ' + req.url);\n res.end('hello\\n');\n}).listen(3000, function(){\n debug('listening');\n});\n\n// fake worker of some kind\n\nrequire('./worker');\n```\n\nExample _worker.js_:\n\n```js\nvar debug = require('debug')('worker');\n\nsetInterval(function(){\n debug('doing some w
ork');\n}, 1000);\n```\n\n The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:\n\n \n\n \n\n## Millisecond diff\n\n When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the \"+NNNms\" will show you how much time was spent between calls.\n\n \n\n When stderr is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:\n _(NOTE: Debug now uses stderr instead of stdout, so the correct shell command for this example is actually `DEBUG=* node example/worker 2> out &`)_\n \n \n \n## Conventions\n\n If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use \":\" to separate features. For example \"bodyParser\" from Connect would then be \"connect:bodyParser\". \n\n## Wildcards\n\n The \"*\" character may be used as a wildcard. Suppose for example your library has debuggers named \"connect:bodyParser\", \"connect:compress\", \"connect:session\", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.\n\n You can also exclude specific debuggers by prefixing them with a \"-\" character. For example, `DEBUG=* -connect:*` would include all debuggers except those s
tarting with \"connect:\".\n\n## Browser support\n\n Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`. \n\n```js\na = debug('worker:a');\nb = debug('worker:b');\n\nsetInterval(function(){\n a('doing some work');\n}, 1000);\n\nsetInterval(function(){\n a('doing some work');\n}, 1200);\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to
whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
+ "readmeFilename": "Readme.md",
+ "scripts": {}
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jscsrc
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jscsrc b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jscsrc
new file mode 100644
index 0000000..06245e6
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jscsrc
@@ -0,0 +1,64 @@
+{
+ "excludeFiles": [
+ "./js/forge.bundle.js",
+ "./js/forge.min.js",
+ "./js/jsbn.js",
+ "./nodejs/ui/require.js",
+ "./nodejs/ui/test.min.js"
+ ],
+ "disallowKeywords": ["with"],
+ "disallowKeywordsOnNewLine": ["else", "catch"],
+ // FIXME: enable this?
+ //"disallowImplicitTypeConversion": ["string"],
+ "disallowMixedSpacesAndTabs": true,
+ "disallowMultipleLineBreaks": true,
+ // FIXME: enable this or do we prefer to
+ // use w/angular directive templates?
+ //"disallowMultipleLineStrings": true,
+ "disallowNewlineBeforeBlockStatements": true,
+ "disallowSpaceAfterObjectKeys": true,
+ "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
+ "disallowSpaceBeforeBinaryOperators": [","],
+ "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
+ "disallowSpacesInAnonymousFunctionExpression": {
+ "beforeOpeningRoundBrace": true
+ },
+ "disallowSpacesInFunctionDeclaration": {
+ "beforeOpeningRoundBrace": true
+ },
+ "disallowSpacesInNamedFunctionExpression": {
+ "beforeOpeningRoundBrace": true
+ },
+ "disallowSpacesInsideParentheses": true,
+ "disallowTrailingComma": true,
+ "disallowTrailingWhitespace": true,
+ "requireCommaBeforeLineBreak": true,
+ "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
+ "requireLineFeedAtFileEnd": true,
+ "requireSpaceAfterBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
+ "requireSpaceBeforeBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
+ "requireSpaceAfterKeywords": [
+ "else",
+ "do",
+ "return",
+ "try"
+ ],
+ "requireSpaceBeforeBlockStatements": true,
+ "requireSpacesInConditionalExpression": {
+ "afterTest": true,
+ "beforeConsequent": true,
+ "afterConsequent": true,
+ "beforeAlternate": true
+ },
+ "requireSpacesInFunction": {
+ "beforeOpeningCurlyBrace": true
+ },
+ "safeContextKeyword": "self",
+ "validateLineBreaks": "LF",
+ // FIXME: enable doc checks (update to use newer jscs jsdoc module)
+ //"validateJSDoc": {
+ // "checkParamNames": true,
+ // "requireParamTypes": true
+ //},
+ "validateParameterSeparator": ", "
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jshintignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jshintignore b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jshintignore
new file mode 100644
index 0000000..c50f474
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jshintignore
@@ -0,0 +1,6 @@
+js/forge.bundle.js
+minify.js
+nodejs/build.js
+nodejs/minify.js
+nodejs/ui/require.js
+nodejs/ui/test.min.js
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jshintrc
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jshintrc b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jshintrc
new file mode 100644
index 0000000..26d261c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "sub": true
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.npmignore b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.npmignore
new file mode 100644
index 0000000..50980d3
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.npmignore
@@ -0,0 +1,22 @@
+*.py[co]
+*.sw[nop]
+*~
+.bower.json
+.cdtproject
+.classpath
+.cproject
+.project
+.settings
+Makefile
+TAGS
+aclocal.m4
+autom4te.cache
+build
+config.log
+config.status
+configure
+dist
+js/forge.bundle.js
+js/forge.min.js
+node_modules
+tests/forge
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.travis.yml
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.travis.yml b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.travis.yml
new file mode 100644
index 0000000..c4aa766
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/.travis.yml
@@ -0,0 +1,10 @@
+language: node_js
+node_js:
+ - "0.10"
+install: (cd nodejs && npm install)
+script:
+ - (cd nodejs && npm test)
+notifications:
+ email:
+ on_success: change
+ on_failure: change
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/HACKING.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/HACKING.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/HACKING.md
new file mode 100644
index 0000000..762dfe1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/HACKING.md
@@ -0,0 +1,37 @@
+Hacking on forge
+================
+
+Want to hack on forge? Great! Here are a few notes:
+
+Code
+----
+
+* In general, follow a common [Node.js Style Guide][].
+* Use version X.Y.Z-dev in dev mode.
+* Use version X.Y.Z for releases.
+
+Versioning
+----------
+
+* Follow the [Semantic Versioning][] guidelines.
+
+Release Process
+---------------
+
+* commit changes
+* `$EDITOR package.json`: update to release version and remove `-dev` suffix.
+* `git commit package.json -m "Release {version}."`
+* `git tag {version}`
+* `$EDITOR package.json`: update to next version and add `-dev` suffix.
+* `git commit package.json -m "Start {next-version}."`
+* `git push`
+* `git push --tags`
+
+To ensure a clean upload, use a clean updated checkout, and run the following:
+
+* `git checkout {version}`
+* `npm publish`
+
+[Node.js Style Guide]: http://nodeguide.com/style.html
+[jshint]: http://www.jshint.com/install/
+[Semantic Versioning]: http://semver.org/
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/LICENSE b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/LICENSE
new file mode 100644
index 0000000..1bba5ce
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/LICENSE
@@ -0,0 +1,331 @@
+You may use the Forge project under the terms of either the BSD License or the
+GNU General Public License (GPL) Version 2.
+
+The BSD License is recommended for most projects. It is simple and easy to
+understand and it places almost no restrictions on what you can do with the
+Forge project.
+
+If the GPL suits your project better you are also free to use Forge under
+that license.
+
+You don't have to do anything special to choose one license or the other and
+you don't have to notify anyone which license you are using. You are free to
+use this project in commercial projects as long as the copyright header is
+left intact.
+
+If you are a commercial entity and use this set of libraries in your
+commercial software then reasonable payment to Digital Bazaar, if you can
+afford it, is not required but is expected and would be appreciated. If this
+library saves you time, then it's saving you money. The cost of developing
+the Forge software was on the order of several hundred hours and tens of
+thousands of dollars. We are attempting to strike a balance between helping
+the development community while not being taken advantage of by lucrative
+commercial entities for our efforts.
+
+-------------------------------------------------------------------------------
+New BSD License (3-clause)
+Copyright (c) 2010, Digital Bazaar, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Digital Bazaar, Inc. nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL DIGITAL BAZAAR BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------------------
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[31/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/sampleapp/manifest.webapp
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/sampleapp/manifest.webapp b/node_modules/node-firefox-find-app/test/sampleapp/manifest.webapp
new file mode 100644
index 0000000..d5ceca3
--- /dev/null
+++ b/node_modules/node-firefox-find-app/test/sampleapp/manifest.webapp
@@ -0,0 +1,22 @@
+{
+ "version": "0.1.0",
+ "name": "fxos-findapp-sample",
+ "description": "Sample app",
+ "launch_path": "/index.html",
+ "icons": {
+ "16": "/icons/icon16x16.png",
+ "48": "/icons/icon48x48.png",
+ "60": "/icons/icon60x60.png",
+ "128": "/icons/icon128x128.png"
+ },
+ "developer": {
+ "name": "Your name",
+ "url": "http://example.com"
+ },
+ "type": "privileged",
+ "permissions": {},
+ "installs_allowed_from": [
+ "*"
+ ],
+ "default_locale": "en"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-app/test/test.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-app/test/test.js b/node_modules/node-firefox-find-app/test/test.js
new file mode 100644
index 0000000..378418e
--- /dev/null
+++ b/node_modules/node-firefox-find-app/test/test.js
@@ -0,0 +1,73 @@
+var assert = require("assert");
+var should = require("should");
+var FindApp = require("../");
+var Ports = require("fx-ports");
+var Start = require("fxos-start");
+var Deploy = require("fxos-deploy/command");
+var Q = require('q');
+
+
+describe('fxos-findapp', function(){
+ this.timeout(10000);
+
+ afterEach(function() {
+ Ports({b2g:true}, function(err, instances) {
+ instances.forEach(function(i) {
+ process.kill(i.pid);
+ });
+ });
+ });
+
+ describe('when no open simulator', function(){
+
+ it('should find app manifest', function(done) {
+ Start({connect:true, force: true})
+ .then(function(sim) {
+ return FindApp({
+ manifestURL: './test/sampleapp/manifest.webapp',
+ client: sim.client
+ });
+ })
+ .then(function(app) {
+ app.manifest.should.be.ok;
+ app.manifest.name.should.be.type('string');
+ })
+ .then(done)
+ .fail(done);
+ });
+
+ it('should throw error if not existing', function(done) {
+ Start({connect:true, force: true})
+ .then(function(sim) {
+ return FindApp({
+ manifestURL: './test/sampleapp/fake.webapp',
+ client: sim.client
+ });
+ })
+ .fail(function(err) {
+ err.should.be.ok;
+ done();
+ });
+ });
+
+ it('should throw reuse existing client', function(done) {
+ Start({connect:true, force: true})
+ .then(function(sim) {
+
+ return FindApp({
+ manifestURL: './test/sampleapp/manifest.webapp',
+ client: sim.client
+ })
+ .then(function(app) {
+ app.manifest.should.be.ok;
+ app.manifest.name.should.be.type('string');
+ });
+
+ }).then(done)
+ .fail(done);
+
+ });
+
+ });
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/.npmignore b/node_modules/node-firefox-find-devices/.npmignore
new file mode 100644
index 0000000..ae7e1e3
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/.npmignore
@@ -0,0 +1,4 @@
+node_modules
+npm-debug.log
+.DS_Store
+*.sw?
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/.travis.yml
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/.travis.yml b/node_modules/node-firefox-find-devices/.travis.yml
new file mode 100644
index 0000000..0394ba7
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/.travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+- 0.10
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/LICENSE b/node_modules/node-firefox-find-devices/LICENSE
new file mode 100644
index 0000000..a7c6b5e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2015 Mozilla
+
+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.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/README.md b/node_modules/node-firefox-find-devices/README.md
new file mode 100644
index 0000000..ee94d94
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/README.md
@@ -0,0 +1,78 @@
+# node-firefox-find-devices [](http://travis-ci.org/mozilla/node-firefox-find-devices)
+
+> Find attached FirefoxOS devices using ADB.
+
+[](https://nodei.co/npm/node-firefox-find-devices/)
+
+This is part of the [node-firefox](https://github.com/mozilla/node-firefox) project.
+
+When Firefox OS devices are plugged in via USB, they can be found using the
+Android Debug Bridge. Once found, a test for the presence of Firefox OS on the
+device can separate them from normal Android devices.
+
+## Installation
+
+### From git
+
+```bash
+git clone https://github.com/mozilla/node-firefox-find-devices.git
+cd node-firefox-find-devices
+npm install
+```
+
+If you want to update later on:
+
+```bash
+cd node-firefox-find-devices
+git pull origin master
+npm install
+```
+
+### npm
+
+```bash
+npm install node-firefox-find-devices
+```
+
+## Usage
+
+```javascript
+findDevices() // returns a Promise
+```
+
+### Finding devices
+
+```javascript
+var findDevices = require('node-firefox-find-devices');
+
+// Return all listening runtimes
+findDevices().then(function(results) {
+ console.log(results);
+});
+```
+
+## Running the tests
+
+After installing, you can simply run the following from the module folder:
+
+```bash
+npm test
+```
+
+To add a new unit test file, create a new file in the `tests/unit` folder. Any file that matches `test.*.js` will be run as a test by the appropriate test runner, based on the folder location.
+
+We use `gulp` behind the scenes to run the test; if you don't have it installed globally you can use `npm gulp` from inside the project's root folder to run `gulp`.
+
+### Code quality and style
+
+Because we have multiple contributors working on our projects, we value consistent code styles. It makes it easier to read code written by many people! :-)
+
+Our tests include unit tests as well as code quality ("linting") tests that make sure our test pass a style guide and [JSHint](http://jshint.com/). Instead of submitting code with the wrong indentation or a different style, run the tests and you will be told where your code quality/style differs from ours and instructions on how to fix it.
+
+This program is free software; it is distributed under an
+[Apache License](https://github.com/mozilla/node-firefox-find-devices/blob/master/LICENSE).
+
+## Copyright
+
+Copyright (c) 2015 [Mozilla](https://mozilla.org)
+([Contributors](https://github.com/mozilla/node-firefox-find-devices/graphs/contributors)).
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/gulpfile.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/gulpfile.js b/node_modules/node-firefox-find-devices/gulpfile.js
new file mode 100644
index 0000000..f5e5ab9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/gulpfile.js
@@ -0,0 +1,3 @@
+var gulp = require('gulp');
+
+require('node-firefox-build-tools').loadGulpTasks(gulp);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/index.js b/node_modules/node-firefox-find-devices/index.js
new file mode 100644
index 0000000..723d44c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/index.js
@@ -0,0 +1,41 @@
+'use strict';
+
+// See https://github.com/jshint/jshint/issues/1747 for context
+/* global -Promise */
+var Promise = require('es6-promise').Promise;
+var adb = require('adbkit');
+
+module.exports = findDevices;
+
+// Stolen from the ADB Helper add-on
+// https://github.com/mozilla/adbhelper/blob/36559184f122f410a4e571f6217e6ed8ca4fa33e/scanner.js#L114
+var B2G_TEST_COMMAND = 'test -f /system/b2g/b2g; echo $?';
+
+function findDevices() {
+ var client = adb.createClient();
+
+ return client.listDevices().then(function(devices) {
+
+ return Promise.all(devices.map(function(device) {
+
+ // Test for Firefox OS on devices, annotate the device list with result.
+ return client.shell(device.id, B2G_TEST_COMMAND)
+ .then(adb.util.readAll)
+ .then(function(output) {
+ // This is counterintuitive: The command result is the exit code,
+ // which is 1 for failure, which means Firefox OS was *not* detected.
+ device.isFirefoxOS = (output.toString('utf8').charAt(0) === '0');
+ return device;
+ });
+
+ }));
+
+ }).then(function(devices) {
+
+ // Filter out all but the Firefox OS devices
+ return devices.filter(function(device) {
+ return device.isFirefoxOS;
+ });
+
+ });
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/LICENSE b/node_modules/node-firefox-find-devices/node_modules/adbkit/LICENSE
new file mode 100644
index 0000000..2ffff3d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/LICENSE
@@ -0,0 +1,13 @@
+Copyright © CyberAgent, Inc. All Rights Reserved.
+
+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.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/README.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/README.md
new file mode 100644
index 0000000..c8557ce
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/README.md
@@ -0,0 +1,1089 @@
+# adbkit
+
+**adbkit** is a pure [Node.js][nodejs] client for the [Android Debug Bridge][adb-site] server. It can be used either as a library in your own application, or simply as a convenient utility for playing with your device.
+
+Most of the `adb` command line tool's functionality is supported (including pushing/pulling files, installing APKs and processing logs), with some added functionality such as being able to generate touch/key events and take screenshots. Some shims are provided for older devices, but we have not and will not test anything below Android 2.3.
+
+Internally, we use this library to drive a multitude of Android devices from a variety of manufacturers, so we can say with a fairly high degree of confidence that it will most likely work with your device(s), too.
+
+## Requirements
+
+* [Node.js][nodejs] >= 0.10
+* The `adb` command line tool
+
+Please note that although it may happen at some point, **this project is NOT an implementation of the ADB _server_**. The target host (where the devices are connected) must still have ADB installed and either already running (e.g. via `adb start-server`) or available in `$PATH`. An attempt will be made to start the server locally via the aforementioned command if the initial connection fails. This is the only case where we fall back to the `adb` binary.
+
+When targeting a remote host, starting the server is entirely your responsibility.
+
+Alternatively, you may want to consider using the Chrome [ADB][chrome-adb] extension, as it includes the ADB server and can be started/stopped quite easily.
+
+## Getting started
+
+Install via NPM:
+
+```bash
+npm install --save adbkit
+```
+
+We use [debug][node-debug], and our debug namespace is `adb`. Some of the dependencies may provide debug output of their own. To see the debug output, set the `DEBUG` environment variable. For example, run your program with `DEBUG=adb:* node app.js`.
+
+Note that even though the module is written in [CoffeeScript][coffeescript], only the compiled JavaScript is published to [NPM][npm], which means that it can easily be used with pure JavaScript codebases, too.
+
+### Examples
+
+The examples may be a bit verbose, but that's because we're trying to keep them as close to real-life code as possible, with flow control and error handling taken care of.
+
+#### Checking for NFC support
+
+```js
+var Promise = require('bluebird')
+var adb = require('adbkit')
+var client = adb.createClient()
+
+client.listDevices()
+ .then(function(devices) {
+ return Promise.filter(devices, function(device) {
+ return client.getFeatures(device.id)
+ .then(function(features) {
+ return features['android.hardware.nfc']
+ })
+ })
+ })
+ .then(function(supportedDevices) {
+ console.log('The following devices support NFC:', supportedDevices)
+ })
+ .catch(function(err) {
+ console.error('Something went wrong:', err.stack)
+ })
+```
+
+#### Installing an APK
+
+```js
+var Promise = require('bluebird')
+var adb = require('adbkit')
+var client = adb.createClient()
+var apk = 'vendor/app.apk'
+
+client.listDevices()
+ .then(function(devices) {
+ return Promise.map(devices, function(device) {
+ return client.install(device.id, apk)
+ })
+ })
+ .then(function() {
+ console.log('Installed %s on all connected devices', apk)
+ })
+ .catch(function(err) {
+ console.error('Something went wrong:', err.stack)
+ })
+```
+
+#### Tracking devices
+
+```js
+var adb = require('adbkit')
+var client = adb.createClient()
+
+client.trackDevices()
+ .then(function(tracker) {
+ tracker.on('add', function(device) {
+ console.log('Device %s was plugged in', device.id)
+ })
+ tracker.on('remove', function(device) {
+ console.log('Device %s was unplugged', device.id)
+ })
+ tracker.on('end', function() {
+ console.log('Tracking stopped')
+ })
+ })
+ .catch(function(err) {
+ console.error('Something went wrong:', err.stack)
+ })
+```
+
+#### Pulling a file from all connected devices
+
+```js
+var Promise = require('bluebird')
+var fs = require('fs')
+var adb = require('adbkit')
+var client = adb.createClient()
+
+client.listDevices()
+ .then(function(devices) {
+ return Promise.map(devices, function(device) {
+ return client.pull(device.id, '/system/build.prop')
+ .then(function(transfer) {
+ return new Promise(function(resolve, reject) {
+ var fn = '/tmp/' + device.id + '.build.prop'
+ transfer.on('progress', function(stats) {
+ console.log('[%s] Pulled %d bytes so far',
+ device.id,
+ stats.bytesTransferred)
+ })
+ transfer.on('end', function() {
+ console.log('[%s] Pull complete', device.id)
+ resolve(device.id)
+ })
+ transfer.on('error', reject)
+ transfer.pipe(fs.createWriteStream(fn))
+ })
+ })
+ })
+ })
+ .then(function() {
+ console.log('Done pulling /system/build.prop from all connected devices')
+ })
+ .catch(function(err) {
+ console.error('Something went wrong:', err.stack)
+ })
+```
+
+#### Pushing a file to all connected devices
+
+```js
+var Promise = require('bluebird')
+var adb = require('adbkit')
+var client = adb.createClient()
+
+client.listDevices()
+ .then(function(devices) {
+ return Promise.map(devices, function(device) {
+ return client.push(device.id, 'temp/foo.txt', '/data/local/tmp/foo.txt')
+ .then(function(transfer) {
+ return new Promise(function(resolve, reject) {
+ transfer.on('progress', function(stats) {
+ console.log('[%s] Pushed %d bytes so far',
+ device.id,
+ stats.bytesTransferred)
+ })
+ transfer.on('end', function() {
+ console.log('[%s] Push complete', device.id)
+ resolve()
+ })
+ transfer.on('error', reject)
+ })
+ })
+ })
+ })
+ .then(function() {
+ console.log('Done pushing foo.txt to all connected devices')
+ })
+ .catch(function(err) {
+ console.error('Something went wrong:', err.stack)
+ })
+```
+
+#### List files in a folder
+
+```js
+var Promise = require('bluebird')
+var adb = require('adbkit')
+var client = adb.createClient()
+
+client.listDevices()
+ .then(function(devices) {
+ return Promise.map(devices, function(device) {
+ return client.readdir(device.id, '/sdcard')
+ .then(function(files) {
+ // Synchronous, so we don't have to care about returning at the
+ // right time
+ files.forEach(function(file) {
+ if (file.isFile()) {
+ console.log('[%s] Found file "%s"', device.id, file.name)
+ }
+ })
+ })
+ })
+ })
+ .then(function() {
+ console.log('Done checking /sdcard files on connected devices')
+ })
+ .catch(function(err) {
+ console.error('Something went wrong:', err.stack)
+ })
+```
+
+## API
+
+### ADB
+
+#### adb.createClient([options])
+
+Creates a client instance with the provided options. Note that this will not automatically establish a connection, it will only be done when necessary.
+
+* **options** An object compatible with [Net.connect][net-connect]'s options:
+ - **port** The port where the ADB server is listening. Defaults to `5037`.
+ - **host** The host of the ADB server. Defaults to `'localhost'`.
+ - **bin** As the sole exception, this option provides the path to the `adb` binary, used for starting the server locally if initial connection fails. Defaults to `'adb'`.
+* Returns: The client instance.
+
+#### adb.util.parsePublicKey(androidKey[, callback])
+
+Parses an Android-formatted mincrypt public key (e.g. `~/.android/adbkey.pub`).
+
+* **androidKey** The key String or [`Buffer`][node-buffer] to parse. Not a filename.
+* **callback(err, output)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **key** The key as a [forge.pki](https://github.com/digitalbazaar/forge#rsa) public key. You may need [node-forge](https://github.com/digitalbazaar/forge) for complicated operations. Additionally the following properties are present:
+ * **fingerprint** The key fingerprint, like it would display on a device. Note that this is different than the one you'd get from `forge.ssh.getPublicKeyFingerprint(key)`, because the device fingerprint is based on the original format.
+ * **comment** The key comment, if any.
+* Returns: `Promise`
+* Resolves with: `key` (see callback)
+
+#### adb.util.readAll(stream[, callback])
+
+Takes a [`Stream`][node-stream] and reads everything it outputs until the stream ends. Then it resolves with the collected output. Convenient with `client.shell()`.
+
+* **stream** The [`Stream`][node-stream] to read.
+* **callback(err, output)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **output** All the output as a [`Buffer`][node-buffer]. Use `output.toString('utf-8')` to get a readable string from it.
+* Returns: `Promise`
+* Resolves with: `output` (see callback)
+
+### Client
+
+#### client.clear(serial, pkg[, callback])
+
+Deletes all data associated with a package from the device. This is roughly analogous to `adb shell pm clear <pkg>`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **pkg** The package name. This is NOT the APK.
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.connect(host[, port][, callback])
+
+Connects to the given device, which must have its ADB daemon running in tcp mode (see `client.tcpip()`) and be accessible on the same network. Same as `adb connect <host>:<port>`.
+
+* **host** The target host. Can also contain the port, in which case the port argument is not used and can be skipped.
+* **port** Optional. The target port. Defaults to `5555`.
+* **callback(err, id)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **id** The connected device ID. Can be used as `serial` in other commands.
+* Returns: `Promise`
+* Resolves with: `id` (see callback)
+
+##### Example - switch to TCP mode and set up a forward for Chrome devtools
+
+Note: be careful with using `client.listDevices()` together with `client.tcpip()` and other similar methods that modify the connection with ADB. You might have the same device twice in your device list (i.e. one device connected via both USB and TCP), which can cause havoc if run simultaneously.
+
+```javascript
+var Promise = require('bluebird')
+var client = require('adbkit').createClient()
+
+client.listDevices()
+ .then(function(devices) {
+ return Promise.map(devices, function(device) {
+ return client.tcpip(device.id)
+ .then(function(port) {
+ // Switching to TCP mode causes ADB to lose the device for a
+ // moment, so let's just wait till we get it back.
+ return client.waitForDevice(device.id).return(port)
+ })
+ .then(function(port) {
+ return client.getDHCPIpAddress(device.id)
+ .then(function(ip) {
+ return client.connect(ip, port)
+ })
+ .then(function(id) {
+ // It can take a moment for the connection to happen.
+ return client.waitForDevice(id)
+ })
+ .then(function(id) {
+ return client.forward(id, 'tcp:9222', 'localabstract:chrome_devtools_remote')
+ .then(function() {
+ console.log('Setup devtools on "%s"', id)
+ })
+ })
+ })
+ })
+ })
+```
+
+#### client.disconnect(host[, port][, callback])
+
+Disconnects from the given device, which should have been connected via `client.connect()` or just `adb connect <host>:<port>`.
+
+* **host** The target host. Can also contain the port, in which case the port argument is not used and can be skipped. In other words you can just put the `id` you got from `client.connect()` here and it will be fine.
+* **port** Optional. The target port. Defaults to `5555`.
+* **callback(err, id)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **id** The disconnected device ID. Will no longer be usable as a `serial` in other commands until you've connected again.
+* Returns: `Promise`
+* Resolves with: `id` (see callback)
+
+#### client.forward(serial, local, remote[, callback])
+
+Forwards socket connections from the ADB server host (local) to the device (remote). This is analogous to `adb forward <local> <remote>`. It's important to note that if you are connected to a remote ADB server, the forward will be created on that host.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **local** A string representing the local endpoint on the ADB host. At time of writing, can be one of:
+ - `tcp:<port>`
+ - `localabstract:<unix domain socket name>`
+ - `localreserved:<unix domain socket name>`
+ - `localfilesystem:<unix domain socket name>`
+ - `dev:<character device name>`
+* **remote** A string representing the remote endpoint on the device. At time of writing, can be one of:
+ - Any value accepted by the `local` argument
+ - `jdwp:<process pid>`
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.framebuffer(serial[, format][, callback])
+
+Fetches the current **raw** framebuffer (i.e. what is visible on the screen) from the device, and optionally converts it into something more usable by using [GraphicsMagick][graphicsmagick]'s `gm` command, which must be available in `$PATH` if conversion is desired. Note that we don't bother supporting really old framebuffer formats such as RGB_565. If for some mysterious reason you happen to run into a `>=2.3` device that uses RGB_565, let us know.
+
+Note that high-resolution devices can have quite massive framebuffers. For example, a device with a resolution of 1920x1080 and 32 bit colors would have a roughly 8MB (`1920*1080*4` byte) RGBA framebuffer. Empirical tests point to about 5MB/s bandwidth limit for the ADB USB connection, which means that it can take ~1.6 seconds for the raw data to arrive, or even more if the USB connection is already congested. Using a conversion will further slow down completion.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **format** The desired output format. Any output format supported by [GraphicsMagick][graphicsmagick] (such as `'png'`) is supported. Defaults to `'raw'` for raw framebuffer data.
+* **callback(err, framebuffer)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **framebuffer** The possibly converted framebuffer stream. The stream also has a `meta` property with the following values:
+ * **version** The framebuffer version. Useful for patching possible backwards-compatibility issues.
+ * **bpp** Bits per pixel (i.e. color depth).
+ * **size** The raw byte size of the framebuffer.
+ * **width** The horizontal resolution of the framebuffer. This SHOULD always be the same as screen width. We have not encountered any device with incorrect framebuffer metadata, but according to rumors there might be some.
+ * **height** The vertical resolution of the framebuffer. This SHOULD always be the same as screen height.
+ * **red_offset** The bit offset of the red color in a pixel.
+ * **red_length** The bit length of the red color in a pixel.
+ * **blue_offset** The bit offset of the blue color in a pixel.
+ * **blue_length** The bit length of the blue color in a pixel.
+ * **green_offset** The bit offset of the green color in a pixel.
+ * **green_length** The bit length of the green color in a pixel.
+ * **alpha_offset** The bit offset of alpha in a pixel.
+ * **alpha_length** The bit length of alpha in a pixel. `0` when not available.
+ * **format** The framebuffer format for convenience. This can be one of `'bgr'`, `'bgra'`, `'rgb'`, `'rgba'`.
+* Returns: `Promise`
+* Resolves with: `framebuffer` (see callback)
+
+#### client.getDevicePath(serial[, callback])
+
+Gets the device path of the device identified by the given serial number.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, path)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **path** The device path. This corresponds to the device path in `client.listDevicesWithPaths()`.
+* Returns: `Promise`
+* Resolves with: `path` (see callback)
+
+#### client.getDHCPIpAddress(serial[, iface][, callback])
+
+Attemps to retrieve the IP address of the device. Roughly analogous to `adb shell getprop dhcp.<iface>.ipaddress`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **iface** Optional. The network interface. Defaults to `'wlan0'`.
+* **callback(err, ip)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **ip** The IP address as a `String`.
+* Returns: `Promise`
+* Resolves with: `ip` (see callback)
+
+#### client.getFeatures(serial[, callback])
+
+Retrieves the features of the device identified by the given serial number. This is analogous to `adb shell pm list features`. Useful for checking whether hardware features such as NFC are available (you'd check for `'android.hardware.nfc'`).
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, features)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **features** An object of device features. Each key corresponds to a device feature, with the value being either `true` for a boolean feature, or the feature value as a string (e.g. `'0x20000'` for `reqGlEsVersion`).
+* Returns: `Promise`
+* Resolves with: `features` (see callback)
+
+#### client.getPackages(serial[, callback])
+
+Retrieves the list of packages present on the device. This is analogous to `adb shell pm list packages`. If you just want to see if something's installed, consider using `client.isInstalled()` instead.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, packages)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **packages** An array of package names.
+* Returns: `Promise`
+* Resolves with: `packages` (see callback)
+
+#### client.getProperties(serial[, callback])
+
+Retrieves the properties of the device identified by the given serial number. This is analogous to `adb shell getprop`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, properties)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **properties** An object of device properties. Each key corresponds to a device property. Convenient for accessing things like `'ro.product.model'`.
+* Returns: `Promise`
+* Resolves with: `properties` (see callback)
+
+#### client.getSerialNo(serial[, callback])
+
+Gets the serial number of the device identified by the given serial number. With our API this doesn't really make much sense, but it has been implemented for completeness. _FYI: in the raw ADB protocol you can specify a device in other ways, too._
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, serial)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **serial** The serial number of the device.
+* Returns: `Promise`
+* Resolves with: `serial` (see callback)
+
+#### client.getState(serial[, callback])
+
+Gets the state of the device identified by the given serial number.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, state)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **state** The device state. This corresponds to the device type in `client.listDevices()`.
+* Returns: `Promise`
+* Resolves with: `state` (see callback)
+
+#### client.install(serial, apk[, callback])
+
+Installs the APK on the device, replacing any previously installed version. This is roughly analogous to `adb install -r <apk>`.
+
+Note that if the call seems to stall, you may have to accept a dialog on the phone first.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **apk** When `String`, interpreted as a path to an APK file. When [`Stream`][node-stream], installs directly from the stream, which must be a valid APK.
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise. It may have a `.code` property containing the error code reported by the device.
+* Returns: `Promise`
+* Resolves with: `true`
+
+##### Example - install an APK from a URL
+
+This example requires the [request](https://www.npmjs.org/package/request) module. It also doesn't do any error handling (404 responses, timeouts, invalid URLs etc).
+
+```javascript
+var client = require('adbkit').createClient()
+var request = require('request')
+var Readable = require('stream').Readable
+
+// The request module implements old-style streams, so we have to wrap it.
+client.install('<serial>', new Readable().wrap(request('http://example.org/app.apk')))
+ .then(function() {
+ console.log('Installed')
+ })
+```
+
+#### client.installRemote(serial, apk[, callback])
+
+Installs an APK file which must already be located on the device file system, and replaces any previously installed version. Useful if you've previously pushed the file to the device for some reason (perhaps to have direct access to `client.push()`'s transfer stats). This is roughly analogous to `adb shell pm install -r <apk>` followed by `adb shell rm -f <apk>`.
+
+Note that if the call seems to stall, you may have to accept a dialog on the phone first.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **apk** The path to the APK file on the device. The file will be removed when the command completes.
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.isInstalled(serial, pkg[, callback])
+
+Tells you if the specific package is installed or not. This is analogous to `adb shell pm path <pkg>` and some output parsing.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **pkg** The package name. This is NOT the APK.
+* **callback(err, installed)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **installed** `true` if the package is installed, `false` otherwise.
+* Returns: `Promise`
+* Resolves with: `installed` (see callback)
+
+#### client.kill([callback])
+
+This kills the ADB server. Note that the next connection will attempt to start the server again when it's unable to connect.
+
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.listDevices([callback])
+
+Gets the list of currently connected devices and emulators.
+
+* **callback(err, devices)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **devices** An array of device objects. The device objects are plain JavaScript objects with two properties: `id` and `type`.
+ * **id** The ID of the device. For real devices, this is usually the USB identifier.
+ * **type** The device type. Values include `'emulator'` for emulators, `'device'` for devices, and `'offline'` for offline devices. `'offline'` can occur for example during boot, in low-battery conditions or when the ADB connection has not yet been approved on the device.
+* Returns: `Promise`
+* Resolves with: `devices` (see callback)
+
+#### client.listDevicesWithPaths([callback])
+
+Like `client.listDevices()`, but includes the "path" of every device.
+
+* **callback(err, devices)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **devices** An array of device objects. The device objects are plain JavaScript objects with the following properties:
+ * **id** See `client.listDevices()`.
+ * **type** See `client.listDevices()`.
+ * **path** The device path. This can be something like `usb:FD120000` for real devices.
+* Returns: `Promise`
+* Resolves with: `devices` (see callback)
+
+#### client.listForwards(serial[, callback])
+
+Lists forwarded connections on the device. This is analogous to `adb forward --list`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, forwards)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **forwards** An array of forward objects with the following properties:
+ * **serial** The device serial.
+ * **local** The local endpoint. Same format as `client.forward()`'s `local` argument.
+ * **remote** The remote endpoint on the device. Same format as `client.forward()`'s `remote` argument.
+* Returns: `Promise`
+* Resolves with: `forwards` (see callback)
+
+#### client.openLocal(serial, path[, callback])
+
+Opens a direct connection to a unix domain socket in the given path.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **path** The path to the socket. Prefixed with `'localfilesystem:'` by default, include another prefix (e.g. `'localabstract:'`) in the path to override.
+* **callback(err, conn)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **conn** The connection (i.e. [`net.Socket`][node-net]). Read and write as you please. Call `conn.end()` to end the connection.
+* Returns: `Promise`
+* Resolves with: `conn` (see callback)
+
+#### client.openLog(serial, name[, callback])
+
+Opens a direct connection to a binary log file, providing access to the raw log data. Note that it is usually much more convenient to use the `client.openLogcat()` method, described separately.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **name** The name of the log. Available logs include `'main'`, `'system'`, `'radio'` and `'events'`.
+* **callback(err, log)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **log** The binary log stream. Call `log.end()` when you wish to stop receiving data.
+* Returns: `Promise`
+* Resolves with: `log` (see callback)
+
+#### client.openLogcat(serial[, options][, callback])
+
+Calls the `logcat` utility on the device and hands off the connection to [adbkit-logcat][adbkit-logcat], a pure Node.js Logcat client. This is analogous to `adb logcat -B`, but the event stream will be parsed for you and a separate event will be emitted for every log entry, allowing for easy processing.
+
+For more information, check out the [adbkit-logcat][adbkit-logcat] documentation.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **options** Optional. The following options are supported:
+ - **clear** When `true`, clears logcat before opening the reader. Not set by default.
+* **callback(err, logcat)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **logcat** The Logcat client. Please see the [adbkit-logcat][adbkit-logcat] documentation for details.
+* Returns: `Promise`
+* Resolves with: `logcat` (see callback)
+
+#### client.openMonkey(serial[, port][, callback])
+
+Starts the built-in `monkey` utility on the device, connects to it using `client.openTcp()` and hands the connection to [adbkit-monkey][adbkit-monkey], a pure Node.js Monkey client. This allows you to create touch and key events, among other things.
+
+For more information, check out the [adbkit-monkey][adbkit-monkey] documentation.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **port** Optional. The device port where you'd like Monkey to run at. Defaults to `1080`.
+* **callback(err, monkey)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **monkey** The Monkey client. Please see the [adbkit-monkey][adbkit-monkey] documentation for details.
+* Returns: `Promise`
+* Resolves with: `monkey` (see callback)
+
+#### client.openProcStat(serial[, callback])
+
+Tracks `/proc/stat` and emits useful information, such as CPU load. A single sync service instance is used to download the `/proc/stat` file for processing. While doing this does consume some resources, it is very light and should not be a problem.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, stats)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **stats** The `/proc/stat` tracker, which is an [`EventEmitter`][node-events]. Call `stat.end()` to stop tracking. The following events are available:
+ * **load** **(loads)** Emitted when a CPU load calculation is available.
+ - **loads** CPU loads of **online** CPUs. Each key is a CPU id (e.g. `'cpu0'`, `'cpu1'`) and the value an object with the following properties:
+ * **user** Percentage (0-100) of ticks spent on user programs.
+ * **nice** Percentage (0-100) of ticks spent on `nice`d user programs.
+ * **system** Percentage (0-100) of ticks spent on system programs.
+ * **idle** Percentage (0-100) of ticks spent idling.
+ * **iowait** Percentage (0-100) of ticks spent waiting for IO.
+ * **irq** Percentage (0-100) of ticks spent on hardware interrupts.
+ * **softirq** Percentage (0-100) of ticks spent on software interrupts.
+ * **steal** Percentage (0-100) of ticks stolen by others.
+ * **guest** Percentage (0-100) of ticks spent by a guest.
+ * **guestnice** Percentage (0-100) of ticks spent by a `nice`d guest.
+ * **total** Total. Always 100.
+* Returns: `Promise`
+* Resolves with: `stats` (see callback)
+
+#### client.openTcp(serial, port[, host][, callback])
+
+Opens a direct TCP connection to a port on the device, without any port forwarding required.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **port** The port number to connect to.
+* **host** Optional. The host to connect to. Allegedly this is supposed to establish a connection to the given host from the device, but we have not been able to get it to work at all. Skip the host and everything works great.
+* **callback(err, conn)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **conn** The TCP connection (i.e. [`net.Socket`][node-net]). Read and write as you please. Call `conn.end()` to end the connection.
+* Returns: `Promise`
+* Resolves with: `conn` (see callback)
+
+#### client.pull(serial, path[, callback])
+
+A convenience shortcut for `sync.pull()`, mainly for one-off use cases. The connection cannot be reused, resulting in poorer performance over multiple calls. However, the Sync client will be closed automatically for you, so that's one less thing to worry about.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **path** See `sync.pull()` for details.
+* **callback(err, transfer)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **transfer** A `PullTransfer` instance (see below)
+* Returns: `Promise`
+* Resolves with: `transfer` (see callback)
+
+#### client.push(serial, contents, path[, mode][, callback])
+
+A convenience shortcut for `sync.push()`, mainly for one-off use cases. The connection cannot be reused, resulting in poorer performance over multiple calls. However, the Sync client will be closed automatically for you, so that's one less thing to worry about.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **contents** See `sync.push()` for details.
+* **path** See `sync.push()` for details.
+* **mode** See `sync.push()` for details.
+* **callback(err, transfer)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **transfer** A `PushTransfer` instance (see below)
+* Returns: `Promise`
+* Resolves with: `transfer` (see callback)
+
+#### client.readdir(serial, path[, callback])
+
+A convenience shortcut for `sync.readdir()`, mainly for one-off use cases. The connection cannot be reused, resulting in poorer performance over multiple calls. However, the Sync client will be closed automatically for you, so that's one less thing to worry about.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **path** See `sync.readdir()` for details.
+* **callback(err, files)** Optional. Use this or the returned `Promise`. See `sync.readdir()` for details.
+* Returns: `Promise`
+* Resolves with: See `sync.readdir()` for details.
+
+#### client.reboot(serial[, callback])
+
+Reboots the device. Similar to `adb reboot`. Note that the method resolves when ADB reports that the device has been rebooted (i.e. the reboot command was successful), not when the device becomes available again.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.remount(serial[, callback])
+
+Attempts to remount the `/system` partition in read-write mode. This will usually only work on emulators and developer devices.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.screencap(serial[, callback])
+
+Takes a screenshot in PNG format using the built-in `screencap` utility. This is analogous to `adb shell screencap -p`. Sadly, the utility is not available on most Android `<=2.3` devices, but a silent fallback to the `client.framebuffer()` command in PNG mode is attempted, so you should have its dependencies installed just in case.
+
+Generating the PNG on the device naturally requires considerably more processing time on that side. However, as the data transferred over USB easily decreases by ~95%, and no conversion being required on the host, this method is usually several times faster than using the framebuffer. Naturally, this benefit does not apply if we're forced to fall back to the framebuffer.
+
+For convenience purposes, if the screencap command fails (e.g. because it doesn't exist on older Androids), we fall back to `client.framebuffer(serial, 'png')`, which is slower and has additional installation requirements.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, screencap)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **screencap** The PNG stream.
+* Returns: `Promise`
+* Resolves with: `screencap` (see callback)
+
+#### client.shell(serial, command[, callback])
+
+Runs a shell command on the device. Note that you'll be limited to the permissions of the `shell` user, which ADB uses.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **command** The shell command to execute. When `String`, the command is run as-is. When `Array`, the elements will be rudimentarily escaped (for convenience, not security) and joined to form a command.
+* **callback(err, output)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **output** A Buffer containing all the output. Call `output.toString('utf-8')` to get a readable String from it.
+* Returns: `Promise`
+* Resolves with: `output` (see callback)
+
+##### Example
+
+```js
+var Promise = require('bluebird')
+var adb = require('adbkit')
+var client = adb.createClient()
+
+client.listDevices()
+ .then(function(devices) {
+ return Promise.map(devices, function(device) {
+ return client.shell(device.id, 'echo $RANDOM')
+ // Use the readAll() utility to read all the content without
+ // having to deal with the events. `output` will be a Buffer
+ // containing all the output.
+ .then(adb.util.readAll)
+ .then(function(output) {
+ console.log('[%s] %s', device.id, output.toString().trim())
+ })
+ })
+ })
+ .then(function() {
+ console.log('Done.')
+ })
+ .catch(function(err) {
+ console.error('Something went wrong:', err.stack)
+ })
+```
+
+#### client.startActivity(serial, options[, callback])
+
+Starts the configured activity on the device. Roughly analogous to `adb shell am start <options>`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **options** The activity configuration. The following options are available:
+ - **debug** Set to `true` to enable debugging.
+ - **wait** Set to `true` to wait for the activity to launch.
+ - **user** The user to run as. Not set by default. If the option is unsupported by the device, an attempt will be made to run the same command again without the user option.
+ - **action** The action.
+ - **data** The data URI, if any.
+ - **mimeType** The mime type, if any.
+ - **category** The category. For multiple categories, pass an `Array`.
+ - **component** The component.
+ - **flags** Numeric flags.
+ - **extras** Any extra data.
+ * When an `Array`, each item must be an `Object` the following properties:
+ - **key** The key name.
+ - **type** The type, which can be one of `'string'`, `'null'`, `'bool'`, `'int'`, `'long'`, `'float'`, `'uri'`, `'component'`.
+ - **value** The value. Optional and unused if type is `'null'`. If an `Array`, type is automatically set to be an array of `<type>`.
+ * When an `Object`, each key is treated as the key name. Simple values like `null`, `String`, `Boolean` and `Number` are type-mapped automatically (`Number` maps to `'int'`) and can be used as-is. For more complex types, like arrays and URIs, set the value to be an `Object` like in the Array syntax (see above), but leave out the `key` property.
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.startService(serial, options[, callback])
+
+Starts the configured service on the device. Roughly analogous to `adb shell am startservice <options>`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **options** The service configuration. The following options are available:
+ - **user** The user to run as. Defaults to `0`. If the option is unsupported by the device, an attempt will be made to run the same command again without the user option.
+ - **action** See `client.startActivity()` for details.
+ - **data** See `client.startActivity()` for details.
+ - **mimeType** See `client.startActivity()` for details.
+ - **category** See `client.startActivity()` for details.
+ - **component** See `client.startActivity()` for details.
+ - **flags** See `client.startActivity()` for details.
+ - **extras** See `client.startActivity()` for details.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.stat(serial, path[, callback])
+
+A convenience shortcut for `sync.stat()`, mainly for one-off use cases. The connection cannot be reused, resulting in poorer performance over multiple calls. However, the Sync client will be closed automatically for you, so that's one less thing to worry about.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **path** See `sync.stat()` for details.
+* **callback(err, stats)** Optional. Use this or the returned `Promise`. See `sync.stat()` for details.
+* Returns: `Promise`
+* Resolves with: See `sync.stat()` for details.
+
+#### client.syncService(serial[, callback])
+
+Establishes a new Sync connection that can be used to push and pull files. This method provides the most freedom and the best performance for repeated use, but can be a bit cumbersome to use. For simple use cases, consider using `client.stat()`, `client.push()` and `client.pull()`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, sync)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **sync** The Sync client. See below for details. Call `sync.end()` when done.
+* Returns: `Promise`
+* Resolves with: `sync` (see callback)
+
+#### client.tcpip(serial, port[, callback])
+
+Puts the device's ADB daemon into tcp mode, allowing you to use `adb connect` or `client.connect()` to connect to it. Note that the device will still be visible to ADB as a regular USB-connected device until you unplug it. Same as `adb tcpip <port>`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **port** Optional. The port the device should listen on. Defaults to `5555`.
+* **callback(err, port)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **port** The port the device started listening on.
+* Returns: `Promise`
+* Resolves with: `port` (see callback)
+
+#### client.trackDevices([callback])
+
+Gets a device tracker. Events will be emitted when devices are added, removed, or their type changes (i.e. to/from `offline`). Note that the same events will be emitted for the initially connected devices also, so that you don't need to use both `client.listDevices()` and `client.trackDevices()`.
+
+Note that as the tracker will keep a connection open, you must call `tracker.end()` if you wish to stop tracking devices.
+
+* **callback(err, tracker)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **tracker** The device tracker, which is an [`EventEmitter`][node-events]. The following events are available:
+ * **add** **(device)** Emitted when a new device is connected, once per device. See `client.listDevices()` for details on the device object.
+ * **remove** **(device)** Emitted when a device is unplugged, once per device. This does not include `offline` devices, those devices are connected but unavailable to ADB. See `client.listDevices()` for details on the device object.
+ * **change** **(device)** Emitted when the `type` property of a device changes, once per device. The current value of `type` is the new value. This event usually occurs the type changes from `'device'` to `'offline'` or the other way around. See `client.listDevices()` for details on the device object and the `'offline'` type.
+ * **changeSet** **(changes)** Emitted once for all changes reported by ADB in a single run. Multiple changes can occur when, for example, a USB hub is connected/unplugged and the device list changes quickly. If you wish to process all changes at once, use this event instead of the once-per-device ones. Keep in mind that the other events will still be emitted, though.
+ - **changes** An object with the following properties always present:
+ * **added** An array of added device objects, each one as in the `add` event. Empty if none.
+ * **removed** An array of removed device objects, each one as in the `remove` event. Empty if none.
+ * **changed** An array of changed device objects, each one as in the `change` event. Empty if none.
+ * **end** Emitted when the underlying connection ends.
+ * **error** **(err)** Emitted if there's an error.
+* Returns: `Promise`
+* Resolves with: `tracker` (see callback)
+
+#### client.trackJdwp(serial[, callback])
+
+Starts a JDWP tracker for the given device.
+
+Note that as the tracker will keep a connection open, you must call `tracker.end()` if you wish to stop tracking JDWP processes.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, tracker)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **tracker** The JDWP tracker, which is an [`EventEmitter`][node-events]. The following events are available:
+ * **add** **(pid)** Emitted when a new JDWP process becomes available, once per pid.
+ * **remove** **(pid)** Emitted when a JDWP process becomes unavailable, once per pid.
+ * **changeSet** **(changes, pids)** All changes in a single event.
+ - **changes** An object with the following properties always present:
+ * **added** An array of pids that were added. Empty if none.
+ * **removed** An array of pids that were removed. Empty if none.
+ - **pids** All currently active pids (including pids from previous runs).
+ * **end** Emitted when the underlying connection ends.
+ * **error** **(err)** Emitted if there's an error.
+* Returns: `Promise`
+* Resolves with: `tracker` (see callback)
+
+#### client.uninstall(serial, pkg[, callback])
+
+Uninstalls the package from the device. This is roughly analogous to `adb uninstall <pkg>`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **pkg** The package name. This is NOT the APK.
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.usb(serial[, callback])
+
+Puts the device's ADB daemon back into USB mode. Reverses `client.tcpip()`. Same as `adb usb`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.version([callback])
+
+Queries the ADB server for its version. This is mainly useful for backwards-compatibility purposes.
+
+* **callback(err, version)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **version** The version of the ADB server.
+* Returns: `Promise`
+* Resolves with: `version` (see callback)
+
+#### client.waitBootComplete(serial[, callback])
+
+Waits until the device has finished booting. Note that the device must already be seen by ADB. This is roughly analogous to periodically checking `adb shell getprop sys.boot_completed`.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err)** Optional. Use this or the returned `Promise`.
+ - **err** `null` if the device has completed booting, `Error` otherwise (can occur if the connection dies while checking).
+* Returns: `Promise`
+* Resolves with: `true`
+
+#### client.waitForDevice(serial[, callback])
+
+Waits until ADB can see the device. Note that you must know the serial in advance. Other than that, works like `adb -s serial wait-for-device`. If you're planning on reacting to random devices being plugged in and out, consider using `client.trackDevices()` instead.
+
+* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
+* **callback(err, id)** Optional. Use this or the returned `Promise`.
+ - **err** `null` if the device has completed booting, `Error` otherwise (can occur if the connection dies while checking).
+ - **id** The device ID. Can be useful for chaining.
+* Returns: `Promise`
+* Resolves with: `id` (see callback)
+
+### Sync
+
+#### sync.end()
+
+Closes the Sync connection, allowing Node to quit (assuming nothing else is keeping it alive, of course).
+
+* Returns: The sync instance.
+
+#### sync.pull(path)
+
+Pulls a file from the device as a `PullTransfer` [`Stream`][node-stream].
+
+* **path** The path to pull from.
+* Returns: A `PullTransfer` instance. See below for details.
+
+#### sync.push(contents, path[, mode])
+
+Attempts to identify `contents` and calls the appropriate `push*` method for it.
+
+* **contents** When `String`, treated as a local file path and forwarded to `sync.pushFile()`. Otherwise, treated as a [`Stream`][node-stream] and forwarded to `sync.pushStream()`.
+* **path** The path to push to.
+* **mode** Optional. The mode of the file. Defaults to `0644`.
+* Returns: A `PushTransfer` instance. See below for details.
+
+#### sync.pushFile(file, path[, mode])
+
+Pushes a local file to the given path. Note that the path must be writable by the ADB user (usually `shell`). When in doubt, use `'/data/local/tmp'` with an appropriate filename.
+
+* **file** The local file path.
+* **path** See `sync.push()` for details.
+* **mode** See `sync.push()` for details.
+* Returns: See `sync.push()` for details.
+
+#### sync.pushStream(stream, path[, mode])
+
+Pushes a [`Stream`][node-stream] to the given path. Note that the path must be writable by the ADB user (usually `shell`). When in doubt, use `'/data/local/tmp'` with an appropriate filename.
+
+* **stream** The readable stream.
+* **path** See `sync.push()` for details.
+* **mode** See `sync.push()` for details.
+* Returns: See `sync.push()` for details.
+
+#### sync.readdir(path[, callback])
+
+Retrieves a list of directory entries (e.g. files) in the given path, not including the `.` and `..` entries, just like [`fs.readdir`][node-fs]. If given a non-directory path, no entries are returned.
+
+* **path** The path.
+* **callback(err, files)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **files** An `Array` of [`fs.Stats`][node-fs-stats]-compatible instances. While the `stats.is*` methods are available, only the following properties are supported (in addition to the `name` field which contains the filename):
+ * **name** The filename.
+ * **mode** The raw mode.
+ * **size** The file size.
+ * **mtime** The time of last modification as a `Date`.
+* Returns: `Promise`
+* Resolves with: `files` (see callback)
+
+#### sync.stat(path[, callback])
+
+Retrieves information about the given path.
+
+* **path** The path.
+* **callback(err, stats)** Optional. Use this or the returned `Promise`.
+ - **err** `null` when successful, `Error` otherwise.
+ - **stats** An [`fs.Stats`][node-fs-stats] instance. While the `stats.is*` methods are available, only the following properties are supported:
+ * **mode** The raw mode.
+ * **size** The file size.
+ * **mtime** The time of last modification as a `Date`.
+* Returns: `Promise`
+* Resolves with: `stats` (see callback)
+
+#### sync.tempFile(path)
+
+A simple helper method for creating appropriate temporary filenames for pushing files. This is essentially the same as taking the basename of the file and appending it to `'/data/local/tmp/'`.
+
+* **path** The path of the file.
+* Returns: An appropriate temporary file path.
+
+### PushTransfer
+
+A simple EventEmitter, mainly for keeping track of the progress.
+
+List of events:
+
+* **progress** **(stats)** Emitted when a chunk has been flushed to the ADB connection.
+ - **stats** An object with the following stats about the transfer:
+ * **bytesTransferred** The number of bytes transferred so far.
+* **error** **(err)** Emitted on error.
+ - **err** An `Error`.
+* **end** Emitted when the transfer has successfully completed.
+
+#### pushTransfer.cancel()
+
+Cancels the transfer by ending both the stream that is being pushed and the sync connection. This will most likely end up creating a broken file on your device. **Use at your own risk.** Also note that you must create a new sync connection if you wish to continue using the sync service.
+
+* Returns: The pushTransfer instance.
+
+### PullTransfer
+
+`PullTransfer` is a [`Stream`][node-stream]. Use [`fs.createWriteStream()`][node-fs] to pipe the stream to a file if necessary.
+
+List of events:
+
+* **progress** **(stats)** Emitted when a new chunk is received.
+ - **stats** An object with the following stats about the transfer:
+ * **bytesTransferred** The number of bytes transferred so far.
+* **error** **(err)** Emitted on error.
+ - **err** An `Error`.
+* **end** Emitted when the transfer has successfully completed.
+
+#### pullTransfer.cancel()
+
+Cancels the transfer by ending the connection. Can be useful for reading endless streams of data, such as `/dev/urandom` or `/dev/zero`, perhaps for benchmarking use. Note that you must create a new sync connection if you wish to continue using the sync service.
+
+* Returns: The pullTransfer instance.
+
+# Incompatible changes in version 2.x
+
+Previously, we made extensive use of callbacks in almost every feature. While this normally works okay, ADB connections can be quite fickle, and it was starting to become difficult to handle every possible error. For example, we'd often fail to properly clean up after ourselves when a connection suddenly died in an unexpected place, causing memory and resource leaks.
+
+In version 2, we've replaced nearly all callbacks with [Promises](http://promisesaplus.com/) (using [Bluebird](https://github.com/petkaantonov/bluebird)), allowing for much more reliable error propagation and resource cleanup (thanks to `.finally()`). Additionally, many commands can now be cancelled on the fly, and although unimplemented at this point, we'll also be able to report progress on long-running commands without any changes to the API.
+
+Unfortunately, some API changes were required for this change. `client.framebuffer()`'s callback, for example, previously accepted more than one argument, which doesn't translate into Promises so well. Thankfully, it made sense to combine the arguments anyway, and we were able to do it quite cleanly.
+
+Furthermore, most API methods were returning the current instance for chaining purposes. While perhaps useful in some contexts, most of the time it probably didn't quite do what users expected, as chained calls were run in parallel rather than in serial fashion. Now every applicable API method returns a Promise, which is an incompatible but welcome change. This will also allow you to hook into `yield` and coroutines in Node 0.12.
+
+**However, all methods still accept (and will accept in the future) callbacks for those who prefer them.**
+
+Test coverage was also massively improved, although we've still got ways to go.
+
+## More information
+
+* [Android Debug Bridge][adb-site]
+ - [SERVICES.TXT][adb-services] (ADB socket protocol)
+* [Android ADB Protocols][adb-protocols] (a blog post explaining the protocol)
+* [adb.js][adb-js] (another Node.js ADB implementation)
+* [ADB Chrome extension][chrome-adb]
+
+## Contributing
+
+See [CONTRIBUTING.md](CONTRIBUTING.md).
+
+## License
+
+See [LICENSE](LICENSE).
+
+Copyright © CyberAgent, Inc. All Rights Reserved.
+
+[nodejs]: <http://nodejs.org/>
+[coffeescript]: <http://coffeescript.org/>
+[npm]: <https://npmjs.org/>
+[adb-js]: <https://github.com/flier/adb.js>
+[adb-site]: <http://developer.android.com/tools/help/adb.html>
+[adb-services]: <https://github.com/android/platform_system_core/blob/master/adb/SERVICES.TXT>
+[adb-protocols]: <http://blogs.kgsoft.co.uk/2013_03_15_prg.htm>
+[file_sync_service.h]: <https://github.com/android/platform_system_core/blob/master/adb/file_sync_service.h>
+[chrome-adb]: <https://chrome.google.com/webstore/detail/adb/dpngiggdglpdnjdoaefidgiigpemgage>
+[node-debug]: <https://npmjs.org/package/debug>
+[net-connect]: <http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener>
+[node-events]: <http://nodejs.org/api/events.html>
+[node-stream]: <http://nodejs.org/api/stream.html>
+[node-buffer]: <http://nodejs.org/api/buffer.html>
+[node-net]: <http://nodejs.org/api/net.html>
+[node-fs]: <http://nodejs.org/api/fs.html>
+[node-fs-stats]: <http://nodejs.org/api/fs.html#fs_class_fs_stats>
+[node-gm]: <https://github.com/aheckmann/gm>
+[graphicsmagick]: <http://www.graphicsmagick.org/>
+[imagemagick]: <http://www.imagemagick.org/>
+[adbkit-logcat]: <https://npmjs.org/package/adbkit-logcat>
+[adbkit-monkey]: <https://npmjs.org/package/adbkit-monkey>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/index.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/index.js
new file mode 100644
index 0000000..a4c08ac
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/index.js
@@ -0,0 +1,15 @@
+(function() {
+ var Path;
+
+ Path = require('path');
+
+ module.exports = (function() {
+ switch (Path.extname(__filename)) {
+ case '.coffee':
+ return require('./src/adb');
+ default:
+ return require('./lib/adb');
+ }
+ })();
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb.js
new file mode 100644
index 0000000..50e8e1b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb.js
@@ -0,0 +1,27 @@
+(function() {
+ var Adb, Client, Keycode, util;
+
+ Client = require('./adb/client');
+
+ Keycode = require('./adb/keycode');
+
+ util = require('./adb/util');
+
+ Adb = (function() {
+ function Adb() {}
+
+ Adb.createClient = function(options) {
+ return new Client(options);
+ };
+
+ return Adb;
+
+ })();
+
+ Adb.Keycode = Keycode;
+
+ Adb.util = util;
+
+ module.exports = Adb;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/auth.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/auth.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/auth.js
new file mode 100644
index 0000000..868ed63
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/auth.js
@@ -0,0 +1,81 @@
+(function() {
+ var Auth, BigInteger, Promise, forge;
+
+ Promise = require('bluebird');
+
+ forge = require('node-forge');
+
+ BigInteger = forge.jsbn.BigInteger;
+
+
+ /*
+ The stucture of an ADB RSAPublicKey is as follows:
+
+ *define RSANUMBYTES 256 // 2048 bit key length
+ *define RSANUMWORDS (RSANUMBYTES / sizeof(uint32_t))
+
+ typedef struct RSAPublicKey {
+ int len; // Length of n[] in number of uint32_t
+ uint32_t n0inv; // -1 / n[0] mod 2^32
+ uint32_t n[RSANUMWORDS]; // modulus as little endian array
+ uint32_t rr[RSANUMWORDS]; // R^2 as little endian array
+ int exponent; // 3 or 65537
+ } RSAPublicKey;
+ */
+
+ Auth = (function() {
+ var RE, readPublicKeyFromStruct;
+
+ function Auth() {}
+
+ RE = /^((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?) (.*)$/;
+
+ readPublicKeyFromStruct = function(struct, comment) {
+ var e, key, len, md, n, offset;
+ if (!struct.length) {
+ throw new Error("Invalid public key");
+ }
+ offset = 0;
+ len = struct.readUInt32LE(offset) * 4;
+ offset += 4;
+ if (struct.length !== 4 + 4 + len + len + 4) {
+ throw new Error("Invalid public key");
+ }
+ offset += 4;
+ n = new Buffer(len);
+ struct.copy(n, 0, offset, offset + len);
+ [].reverse.call(n);
+ offset += len;
+ offset += len;
+ e = struct.readUInt32LE(offset);
+ if (!(e === 3 || e === 65537)) {
+ throw new Error("Invalid exponent " + e + ", only 3 and 65537 are supported");
+ }
+ key = forge.pki.setRsaPublicKey(new BigInteger(n.toString('hex'), 16), new BigInteger(e.toString(), 10));
+ md = forge.md.md5.create();
+ md.update(struct.toString('binary'));
+ key.fingerprint = md.digest().toHex().match(/../g).join(':');
+ key.comment = comment;
+ return key;
+ };
+
+ Auth.parsePublicKey = function(buffer) {
+ return new Promise(function(resolve, reject) {
+ var comment, match, struct;
+ if (match = RE.exec(buffer)) {
+ struct = new Buffer(match[1], 'base64');
+ comment = match[2];
+ return resolve(readPublicKeyFromStruct(struct, comment));
+ } else {
+ return reject(new Error("Unrecognizable public key format"));
+ }
+ });
+ };
+
+ return Auth;
+
+ })();
+
+ module.exports = Auth;
+
+}).call(this);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[41/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/process.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/process.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/process.js
new file mode 100644
index 0000000..09cbc2a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/process.js
@@ -0,0 +1,1616 @@
+/***********************************************************************
+
+ A JavaScript tokenizer / parser / beautifier / compressor.
+
+ This version is suitable for Node.js. With minimal changes (the
+ exports stuff) it should work on any JS platform.
+
+ This file implements some AST processors. They work on data built
+ by parse-js.
+
+ Exported functions:
+
+ - ast_mangle(ast, options) -- mangles the variable/function names
+ in the AST. Returns an AST.
+
+ - ast_squeeze(ast) -- employs various optimizations to make the
+ final generated code even smaller. Returns an AST.
+
+ - gen_code(ast, options) -- generates JS code from the AST. Pass
+ true (or an object, see the code for some options) as second
+ argument to get "pretty" (indented) code.
+
+ -------------------------------- (C) ---------------------------------
+
+ Author: Mihai Bazon
+ <mi...@gmail.com>
+ http://mihai.bazon.net/blog
+
+ Distributed under the BSD license:
+
+ Copyright 2010 (c) Mihai Bazon <mi...@gmail.com>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ * Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the following
+ disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials
+ provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ ***********************************************************************/
+
+var jsp = require("./parse-js"),
+ slice = jsp.slice,
+ member = jsp.member,
+ PRECEDENCE = jsp.PRECEDENCE,
+ OPERATORS = jsp.OPERATORS;
+
+/* -----[ helper for AST traversal ]----- */
+
+function ast_walker(ast) {
+ function _vardefs(defs) {
+ return [ this[0], MAP(defs, function(def){
+ var a = [ def[0] ];
+ if (def.length > 1)
+ a[1] = walk(def[1]);
+ return a;
+ }) ];
+ };
+ var walkers = {
+ "string": function(str) {
+ return [ this[0], str ];
+ },
+ "num": function(num) {
+ return [ this[0], num ];
+ },
+ "name": function(name) {
+ return [ this[0], name ];
+ },
+ "toplevel": function(statements) {
+ return [ this[0], MAP(statements, walk) ];
+ },
+ "block": function(statements) {
+ var out = [ this[0] ];
+ if (statements != null)
+ out.push(MAP(statements, walk));
+ return out;
+ },
+ "var": _vardefs,
+ "const": _vardefs,
+ "try": function(t, c, f) {
+ return [
+ this[0],
+ MAP(t, walk),
+ c != null ? [ c[0], MAP(c[1], walk) ] : null,
+ f != null ? MAP(f, walk) : null
+ ];
+ },
+ "throw": function(expr) {
+ return [ this[0], walk(expr) ];
+ },
+ "new": function(ctor, args) {
+ return [ this[0], walk(ctor), MAP(args, walk) ];
+ },
+ "switch": function(expr, body) {
+ return [ this[0], walk(expr), MAP(body, function(branch){
+ return [ branch[0] ? walk(branch[0]) : null,
+ MAP(branch[1], walk) ];
+ }) ];
+ },
+ "break": function(label) {
+ return [ this[0], label ];
+ },
+ "continue": function(label) {
+ return [ this[0], label ];
+ },
+ "conditional": function(cond, t, e) {
+ return [ this[0], walk(cond), walk(t), walk(e) ];
+ },
+ "assign": function(op, lvalue, rvalue) {
+ return [ this[0], op, walk(lvalue), walk(rvalue) ];
+ },
+ "dot": function(expr) {
+ return [ this[0], walk(expr) ].concat(slice(arguments, 1));
+ },
+ "call": function(expr, args) {
+ return [ this[0], walk(expr), MAP(args, walk) ];
+ },
+ "function": function(name, args, body) {
+ return [ this[0], name, args.slice(), MAP(body, walk) ];
+ },
+ "defun": function(name, args, body) {
+ return [ this[0], name, args.slice(), MAP(body, walk) ];
+ },
+ "if": function(conditional, t, e) {
+ return [ this[0], walk(conditional), walk(t), walk(e) ];
+ },
+ "for": function(init, cond, step, block) {
+ return [ this[0], walk(init), walk(cond), walk(step), walk(block) ];
+ },
+ "for-in": function(vvar, key, hash, block) {
+ return [ this[0], walk(vvar), walk(key), walk(hash), walk(block) ];
+ },
+ "while": function(cond, block) {
+ return [ this[0], walk(cond), walk(block) ];
+ },
+ "do": function(cond, block) {
+ return [ this[0], walk(cond), walk(block) ];
+ },
+ "return": function(expr) {
+ return [ this[0], walk(expr) ];
+ },
+ "binary": function(op, left, right) {
+ return [ this[0], op, walk(left), walk(right) ];
+ },
+ "unary-prefix": function(op, expr) {
+ return [ this[0], op, walk(expr) ];
+ },
+ "unary-postfix": function(op, expr) {
+ return [ this[0], op, walk(expr) ];
+ },
+ "sub": function(expr, subscript) {
+ return [ this[0], walk(expr), walk(subscript) ];
+ },
+ "object": function(props) {
+ return [ this[0], MAP(props, function(p){
+ return p.length == 2
+ ? [ p[0], walk(p[1]) ]
+ : [ p[0], walk(p[1]), p[2] ]; // get/set-ter
+ }) ];
+ },
+ "regexp": function(rx, mods) {
+ return [ this[0], rx, mods ];
+ },
+ "array": function(elements) {
+ return [ this[0], MAP(elements, walk) ];
+ },
+ "stat": function(stat) {
+ return [ this[0], walk(stat) ];
+ },
+ "seq": function() {
+ return [ this[0] ].concat(MAP(slice(arguments), walk));
+ },
+ "label": function(name, block) {
+ return [ this[0], name, walk(block) ];
+ },
+ "with": function(expr, block) {
+ return [ this[0], walk(expr), walk(block) ];
+ },
+ "atom": function(name) {
+ return [ this[0], name ];
+ }
+ };
+
+ var user = {};
+ var stack = [];
+ function walk(ast) {
+ if (ast == null)
+ return null;
+ try {
+ stack.push(ast);
+ var type = ast[0];
+ var gen = user[type];
+ if (gen) {
+ var ret = gen.apply(ast, ast.slice(1));
+ if (ret != null)
+ return ret;
+ }
+ gen = walkers[type];
+ return gen.apply(ast, ast.slice(1));
+ } finally {
+ stack.pop();
+ }
+ };
+
+ function with_walkers(walkers, cont){
+ var save = {}, i;
+ for (i in walkers) if (HOP(walkers, i)) {
+ save[i] = user[i];
+ user[i] = walkers[i];
+ }
+ var ret = cont();
+ for (i in save) if (HOP(save, i)) {
+ if (!save[i]) delete user[i];
+ else user[i] = save[i];
+ }
+ return ret;
+ };
+
+ return {
+ walk: walk,
+ with_walkers: with_walkers,
+ parent: function() {
+ return stack[stack.length - 2]; // last one is current node
+ },
+ stack: function() {
+ return stack;
+ }
+ };
+};
+
+/* -----[ Scope and mangling ]----- */
+
+function Scope(parent) {
+ this.names = {}; // names defined in this scope
+ this.mangled = {}; // mangled names (orig.name => mangled)
+ this.rev_mangled = {}; // reverse lookup (mangled => orig.name)
+ this.cname = -1; // current mangled name
+ this.refs = {}; // names referenced from this scope
+ this.uses_with = false; // will become TRUE if with() is detected in this or any subscopes
+ this.uses_eval = false; // will become TRUE if eval() is detected in this or any subscopes
+ this.parent = parent; // parent scope
+ this.children = []; // sub-scopes
+ if (parent) {
+ this.level = parent.level + 1;
+ parent.children.push(this);
+ } else {
+ this.level = 0;
+ }
+};
+
+var base54 = (function(){
+ var DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_";
+ return function(num) {
+ var ret = "";
+ do {
+ ret = DIGITS.charAt(num % 54) + ret;
+ num = Math.floor(num / 54);
+ } while (num > 0);
+ return ret;
+ };
+})();
+
+Scope.prototype = {
+ has: function(name) {
+ for (var s = this; s; s = s.parent)
+ if (HOP(s.names, name))
+ return s;
+ },
+ has_mangled: function(mname) {
+ for (var s = this; s; s = s.parent)
+ if (HOP(s.rev_mangled, mname))
+ return s;
+ },
+ toJSON: function() {
+ return {
+ names: this.names,
+ uses_eval: this.uses_eval,
+ uses_with: this.uses_with
+ };
+ },
+
+ next_mangled: function() {
+ // we must be careful that the new mangled name:
+ //
+ // 1. doesn't shadow a mangled name from a parent
+ // scope, unless we don't reference the original
+ // name from this scope OR from any sub-scopes!
+ // This will get slow.
+ //
+ // 2. doesn't shadow an original name from a parent
+ // scope, in the event that the name is not mangled
+ // in the parent scope and we reference that name
+ // here OR IN ANY SUBSCOPES!
+ //
+ // 3. doesn't shadow a name that is referenced but not
+ // defined (possibly global defined elsewhere).
+ for (;;) {
+ var m = base54(++this.cname), prior;
+
+ // case 1.
+ prior = this.has_mangled(m);
+ if (prior && this.refs[prior.rev_mangled[m]] === prior)
+ continue;
+
+ // case 2.
+ prior = this.has(m);
+ if (prior && prior !== this && this.refs[m] === prior && !prior.has_mangled(m))
+ continue;
+
+ // case 3.
+ if (HOP(this.refs, m) && this.refs[m] == null)
+ continue;
+
+ // I got "do" once. :-/
+ if (!is_identifier(m))
+ continue;
+
+ return m;
+ }
+ },
+ get_mangled: function(name, newMangle) {
+ if (this.uses_eval || this.uses_with) return name; // no mangle if eval or with is in use
+ var s = this.has(name);
+ if (!s) return name; // not in visible scope, no mangle
+ if (HOP(s.mangled, name)) return s.mangled[name]; // already mangled in this scope
+ if (!newMangle) return name; // not found and no mangling requested
+
+ var m = s.next_mangled();
+ s.rev_mangled[m] = name;
+ return s.mangled[name] = m;
+ },
+ define: function(name) {
+ if (name != null)
+ return this.names[name] = name;
+ }
+};
+
+function ast_add_scope(ast) {
+
+ var current_scope = null;
+ var w = ast_walker(), walk = w.walk;
+ var having_eval = [];
+
+ function with_new_scope(cont) {
+ current_scope = new Scope(current_scope);
+ var ret = current_scope.body = cont();
+ ret.scope = current_scope;
+ current_scope = current_scope.parent;
+ return ret;
+ };
+
+ function define(name) {
+ return current_scope.define(name);
+ };
+
+ function reference(name) {
+ current_scope.refs[name] = true;
+ };
+
+ function _lambda(name, args, body) {
+ return [ this[0], this[0] == "defun" ? define(name) : name, args, with_new_scope(function(){
+ MAP(args, define);
+ return MAP(body, walk);
+ })];
+ };
+
+ return with_new_scope(function(){
+ // process AST
+ var ret = w.with_walkers({
+ "function": _lambda,
+ "defun": _lambda,
+ "with": function(expr, block) {
+ for (var s = current_scope; s; s = s.parent)
+ s.uses_with = true;
+ },
+ "var": function(defs) {
+ MAP(defs, function(d){ define(d[0]) });
+ },
+ "const": function(defs) {
+ MAP(defs, function(d){ define(d[0]) });
+ },
+ "try": function(t, c, f) {
+ if (c != null) return [
+ this[0],
+ MAP(t, walk),
+ [ define(c[0]), MAP(c[1], walk) ],
+ f != null ? MAP(f, walk) : null
+ ];
+ },
+ "name": function(name) {
+ if (name == "eval")
+ having_eval.push(current_scope);
+ reference(name);
+ }
+ }, function(){
+ return walk(ast);
+ });
+
+ // the reason why we need an additional pass here is
+ // that names can be used prior to their definition.
+
+ // scopes where eval was detected and their parents
+ // are marked with uses_eval, unless they define the
+ // "eval" name.
+ MAP(having_eval, function(scope){
+ if (!scope.has("eval")) while (scope) {
+ scope.uses_eval = true;
+ scope = scope.parent;
+ }
+ });
+
+ // for referenced names it might be useful to know
+ // their origin scope. current_scope here is the
+ // toplevel one.
+ function fixrefs(scope, i) {
+ // do children first; order shouldn't matter
+ for (i = scope.children.length; --i >= 0;)
+ fixrefs(scope.children[i]);
+ for (i in scope.refs) if (HOP(scope.refs, i)) {
+ // find origin scope and propagate the reference to origin
+ for (var origin = scope.has(i), s = scope; s; s = s.parent) {
+ s.refs[i] = origin;
+ if (s === origin) break;
+ }
+ }
+ };
+ fixrefs(current_scope);
+
+ return ret;
+ });
+
+};
+
+/* -----[ mangle names ]----- */
+
+function ast_mangle(ast, options) {
+ var w = ast_walker(), walk = w.walk, scope;
+ options = options || {};
+
+ function get_mangled(name, newMangle) {
+ if (!options.toplevel && !scope.parent) return name; // don't mangle toplevel
+ if (options.except && member(name, options.except))
+ return name;
+ return scope.get_mangled(name, newMangle);
+ };
+
+ function _lambda(name, args, body) {
+ if (name) name = get_mangled(name);
+ body = with_scope(body.scope, function(){
+ args = MAP(args, function(name){ return get_mangled(name) });
+ return MAP(body, walk);
+ });
+ return [ this[0], name, args, body ];
+ };
+
+ function with_scope(s, cont) {
+ var _scope = scope;
+ scope = s;
+ for (var i in s.names) if (HOP(s.names, i)) {
+ get_mangled(i, true);
+ }
+ var ret = cont();
+ ret.scope = s;
+ scope = _scope;
+ return ret;
+ };
+
+ function _vardefs(defs) {
+ return [ this[0], MAP(defs, function(d){
+ return [ get_mangled(d[0]), walk(d[1]) ];
+ }) ];
+ };
+
+ return w.with_walkers({
+ "function": _lambda,
+ "defun": function() {
+ // move function declarations to the top when
+ // they are not in some block.
+ var ast = _lambda.apply(this, arguments);
+ switch (w.parent()[0]) {
+ case "toplevel":
+ case "function":
+ case "defun":
+ return MAP.at_top(ast);
+ }
+ return ast;
+ },
+ "var": _vardefs,
+ "const": _vardefs,
+ "name": function(name) {
+ return [ this[0], get_mangled(name) ];
+ },
+ "try": function(t, c, f) {
+ return [ this[0],
+ MAP(t, walk),
+ c != null ? [ get_mangled(c[0]), MAP(c[1], walk) ] : null,
+ f != null ? MAP(f, walk) : null ];
+ },
+ "toplevel": function(body) {
+ var self = this;
+ return with_scope(self.scope, function(){
+ return [ self[0], MAP(body, walk) ];
+ });
+ }
+ }, function() {
+ return walk(ast_add_scope(ast));
+ });
+};
+
+/* -----[
+ - compress foo["bar"] into foo.bar,
+ - remove block brackets {} where possible
+ - join consecutive var declarations
+ - various optimizations for IFs:
+ - if (cond) foo(); else bar(); ==> cond?foo():bar();
+ - if (cond) foo(); ==> cond&&foo();
+ - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); // also for throw
+ - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()}
+ ]----- */
+
+var warn = function(){};
+
+function best_of(ast1, ast2) {
+ return gen_code(ast1).length > gen_code(ast2[0] == "stat" ? ast2[1] : ast2).length ? ast2 : ast1;
+};
+
+function last_stat(b) {
+ if (b[0] == "block" && b[1] && b[1].length > 0)
+ return b[1][b[1].length - 1];
+ return b;
+}
+
+function aborts(t) {
+ if (t) {
+ t = last_stat(t);
+ if (t[0] == "return" || t[0] == "break" || t[0] == "continue" || t[0] == "throw")
+ return true;
+ }
+};
+
+function boolean_expr(expr) {
+ return ( (expr[0] == "unary-prefix"
+ && member(expr[1], [ "!", "delete" ])) ||
+
+ (expr[0] == "binary"
+ && member(expr[1], [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ])) ||
+
+ (expr[0] == "binary"
+ && member(expr[1], [ "&&", "||" ])
+ && boolean_expr(expr[2])
+ && boolean_expr(expr[3])) ||
+
+ (expr[0] == "conditional"
+ && boolean_expr(expr[2])
+ && boolean_expr(expr[3])) ||
+
+ (expr[0] == "assign"
+ && expr[1] === true
+ && boolean_expr(expr[3])) ||
+
+ (expr[0] == "seq"
+ && boolean_expr(expr[expr.length - 1]))
+ );
+};
+
+function make_conditional(c, t, e) {
+ if (c[0] == "unary-prefix" && c[1] == "!") {
+ return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ];
+ } else {
+ return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ];
+ }
+};
+
+function empty(b) {
+ return !b || (b[0] == "block" && (!b[1] || b[1].length == 0));
+};
+
+function is_string(node) {
+ return (node[0] == "string" ||
+ node[0] == "unary-prefix" && node[1] == "typeof" ||
+ node[0] == "binary" && node[1] == "+" &&
+ (is_string(node[2]) || is_string(node[3])));
+};
+
+var when_constant = (function(){
+
+ var $NOT_CONSTANT = {};
+
+ // this can only evaluate constant expressions. If it finds anything
+ // not constant, it throws $NOT_CONSTANT.
+ function evaluate(expr) {
+ switch (expr[0]) {
+ case "string":
+ case "num":
+ return expr[1];
+ case "name":
+ case "atom":
+ switch (expr[1]) {
+ case "true": return true;
+ case "false": return false;
+ }
+ break;
+ case "unary-prefix":
+ switch (expr[1]) {
+ case "!": return !evaluate(expr[2]);
+ case "typeof": return typeof evaluate(expr[2]);
+ case "~": return ~evaluate(expr[2]);
+ case "-": return -evaluate(expr[2]);
+ case "+": return +evaluate(expr[2]);
+ }
+ break;
+ case "binary":
+ var left = expr[2], right = expr[3];
+ switch (expr[1]) {
+ case "&&" : return evaluate(left) && evaluate(right);
+ case "||" : return evaluate(left) || evaluate(right);
+ case "|" : return evaluate(left) | evaluate(right);
+ case "&" : return evaluate(left) & evaluate(right);
+ case "^" : return evaluate(left) ^ evaluate(right);
+ case "+" : return evaluate(left) + evaluate(right);
+ case "*" : return evaluate(left) * evaluate(right);
+ case "/" : return evaluate(left) / evaluate(right);
+ case "-" : return evaluate(left) - evaluate(right);
+ case "<<" : return evaluate(left) << evaluate(right);
+ case ">>" : return evaluate(left) >> evaluate(right);
+ case ">>>" : return evaluate(left) >>> evaluate(right);
+ case "==" : return evaluate(left) == evaluate(right);
+ case "===" : return evaluate(left) === evaluate(right);
+ case "!=" : return evaluate(left) != evaluate(right);
+ case "!==" : return evaluate(left) !== evaluate(right);
+ case "<" : return evaluate(left) < evaluate(right);
+ case "<=" : return evaluate(left) <= evaluate(right);
+ case ">" : return evaluate(left) > evaluate(right);
+ case ">=" : return evaluate(left) >= evaluate(right);
+ case "in" : return evaluate(left) in evaluate(right);
+ case "instanceof" : return evaluate(left) instanceof evaluate(right);
+ }
+ }
+ throw $NOT_CONSTANT;
+ };
+
+ return function(expr, yes, no) {
+ try {
+ var val = evaluate(expr), ast;
+ switch (typeof val) {
+ case "string": ast = [ "string", val ]; break;
+ case "number": ast = [ "num", val ]; break;
+ case "boolean": ast = [ "name", String(val) ]; break;
+ default: throw new Error("Can't handle constant of type: " + (typeof val));
+ }
+ return yes.call(expr, ast, val);
+ } catch(ex) {
+ if (ex === $NOT_CONSTANT) {
+ if (expr[0] == "binary"
+ && (expr[1] == "===" || expr[1] == "!==")
+ && ((is_string(expr[2]) && is_string(expr[3]))
+ || (boolean_expr(expr[2]) && boolean_expr(expr[3])))) {
+ expr[1] = expr[1].substr(0, 2);
+ }
+ return no ? no.call(expr, expr) : null;
+ }
+ else throw ex;
+ }
+ };
+
+})();
+
+function warn_unreachable(ast) {
+ if (!empty(ast))
+ warn("Dropping unreachable code: " + gen_code(ast, true));
+};
+
+function ast_squeeze(ast, options) {
+ options = defaults(options, {
+ make_seqs : true,
+ dead_code : true,
+ keep_comps : true,
+ no_warnings : false
+ });
+
+ var w = ast_walker(), walk = w.walk, scope;
+
+ function negate(c) {
+ var not_c = [ "unary-prefix", "!", c ];
+ switch (c[0]) {
+ case "unary-prefix":
+ return c[1] == "!" && boolean_expr(c[2]) ? c[2] : not_c;
+ case "seq":
+ c = slice(c);
+ c[c.length - 1] = negate(c[c.length - 1]);
+ return c;
+ case "conditional":
+ return best_of(not_c, [ "conditional", c[1], negate(c[2]), negate(c[3]) ]);
+ case "binary":
+ var op = c[1], left = c[2], right = c[3];
+ if (!options.keep_comps) switch (op) {
+ case "<=" : return [ "binary", ">", left, right ];
+ case "<" : return [ "binary", ">=", left, right ];
+ case ">=" : return [ "binary", "<", left, right ];
+ case ">" : return [ "binary", "<=", left, right ];
+ }
+ switch (op) {
+ case "==" : return [ "binary", "!=", left, right ];
+ case "!=" : return [ "binary", "==", left, right ];
+ case "===" : return [ "binary", "!==", left, right ];
+ case "!==" : return [ "binary", "===", left, right ];
+ case "&&" : return best_of(not_c, [ "binary", "||", negate(left), negate(right) ]);
+ case "||" : return best_of(not_c, [ "binary", "&&", negate(left), negate(right) ]);
+ }
+ break;
+ }
+ return not_c;
+ };
+
+ function with_scope(s, cont) {
+ var _scope = scope;
+ scope = s;
+ var ret = cont();
+ ret.scope = s;
+ scope = _scope;
+ return ret;
+ };
+
+ function rmblock(block) {
+ if (block != null && block[0] == "block" && block[1]) {
+ if (block[1].length == 1)
+ block = block[1][0];
+ else if (block[1].length == 0)
+ block = [ "block" ];
+ }
+ return block;
+ };
+
+ function _lambda(name, args, body) {
+ return [ this[0], name, args, with_scope(body.scope, function(){
+ return tighten(MAP(body, walk), "lambda");
+ }) ];
+ };
+
+ // we get here for blocks that have been already transformed.
+ // this function does a few things:
+ // 1. discard useless blocks
+ // 2. join consecutive var declarations
+ // 3. remove obviously dead code
+ // 4. transform consecutive statements using the comma operator
+ // 5. if block_type == "lambda" and it detects constructs like if(foo) return ... - rewrite like if (!foo) { ... }
+ function tighten(statements, block_type) {
+ statements = statements.reduce(function(a, stat){
+ if (stat[0] == "block") {
+ if (stat[1]) {
+ a.push.apply(a, stat[1]);
+ }
+ } else {
+ a.push(stat);
+ }
+ return a;
+ }, []);
+
+ statements = (function(a, prev){
+ statements.forEach(function(cur){
+ if (prev && ((cur[0] == "var" && prev[0] == "var") ||
+ (cur[0] == "const" && prev[0] == "const"))) {
+ prev[1] = prev[1].concat(cur[1]);
+ } else {
+ a.push(cur);
+ prev = cur;
+ }
+ });
+ return a;
+ })([]);
+
+ if (options.dead_code) statements = (function(a, has_quit){
+ statements.forEach(function(st){
+ if (has_quit) {
+ if (member(st[0], [ "function", "defun" , "var", "const" ])) {
+ a.push(st);
+ }
+ else if (!options.no_warnings)
+ warn_unreachable(st);
+ }
+ else {
+ a.push(st);
+ if (member(st[0], [ "return", "throw", "break", "continue" ]))
+ has_quit = true;
+ }
+ });
+ return a;
+ })([]);
+
+ if (options.make_seqs) statements = (function(a, prev) {
+ statements.forEach(function(cur){
+ if (prev && prev[0] == "stat" && cur[0] == "stat") {
+ prev[1] = [ "seq", prev[1], cur[1] ];
+ } else {
+ a.push(cur);
+ prev = cur;
+ }
+ });
+ return a;
+ })([]);
+
+ if (block_type == "lambda") statements = (function(i, a, stat){
+ while (i < statements.length) {
+ stat = statements[i++];
+ if (stat[0] == "if" && !stat[3]) {
+ if (stat[2][0] == "return" && stat[2][1] == null) {
+ a.push(make_if(negate(stat[1]), [ "block", statements.slice(i) ]));
+ break;
+ }
+ var last = last_stat(stat[2]);
+ if (last[0] == "return" && last[1] == null) {
+ a.push(make_if(stat[1], [ "block", stat[2][1].slice(0, -1) ], [ "block", statements.slice(i) ]));
+ break;
+ }
+ }
+ a.push(stat);
+ }
+ return a;
+ })(0, []);
+
+ return statements;
+ };
+
+ function make_if(c, t, e) {
+ return when_constant(c, function(ast, val){
+ if (val) {
+ warn_unreachable(e);
+ return t;
+ } else {
+ warn_unreachable(t);
+ return e;
+ }
+ }, function() {
+ return make_real_if(c, t, e);
+ });
+ };
+
+ function make_real_if(c, t, e) {
+ c = walk(c);
+ t = walk(t);
+ e = walk(e);
+
+ if (empty(t)) {
+ c = negate(c);
+ t = e;
+ e = null;
+ } else if (empty(e)) {
+ e = null;
+ } else {
+ // if we have both else and then, maybe it makes sense to switch them?
+ (function(){
+ var a = gen_code(c);
+ var n = negate(c);
+ var b = gen_code(n);
+ if (b.length < a.length) {
+ var tmp = t;
+ t = e;
+ e = tmp;
+ c = n;
+ }
+ })();
+ }
+ if (empty(e) && empty(t))
+ return [ "stat", c ];
+ var ret = [ "if", c, t, e ];
+ if (t[0] == "if" && empty(t[3]) && empty(e)) {
+ ret = best_of(ret, walk([ "if", [ "binary", "&&", c, t[1] ], t[2] ]));
+ }
+ else if (t[0] == "stat") {
+ if (e) {
+ if (e[0] == "stat") {
+ ret = best_of(ret, [ "stat", make_conditional(c, t[1], e[1]) ]);
+ }
+ }
+ else {
+ ret = best_of(ret, [ "stat", make_conditional(c, t[1]) ]);
+ }
+ }
+ else if (e && t[0] == e[0] && (t[0] == "return" || t[0] == "throw") && t[1] && e[1]) {
+ ret = best_of(ret, [ t[0], make_conditional(c, t[1], e[1] ) ]);
+ }
+ else if (e && aborts(t)) {
+ ret = [ [ "if", c, t ] ];
+ if (e[0] == "block") {
+ if (e[1]) ret = ret.concat(e[1]);
+ }
+ else {
+ ret.push(e);
+ }
+ ret = walk([ "block", ret ]);
+ }
+ else if (t && aborts(e)) {
+ ret = [ [ "if", negate(c), e ] ];
+ if (t[0] == "block") {
+ if (t[1]) ret = ret.concat(t[1]);
+ } else {
+ ret.push(t);
+ }
+ ret = walk([ "block", ret ]);
+ }
+ return ret;
+ };
+
+ function _do_while(cond, body) {
+ return when_constant(cond, function(cond, val){
+ if (!val) {
+ warn_unreachable(body);
+ return [ "block" ];
+ } else {
+ return [ "for", null, null, null, walk(body) ];
+ }
+ });
+ };
+
+ return w.with_walkers({
+ "sub": function(expr, subscript) {
+ if (subscript[0] == "string") {
+ var name = subscript[1];
+ if (is_identifier(name))
+ return [ "dot", walk(expr), name ];
+ else if (/^[1-9][0-9]*$/.test(name) || name === "0")
+ return [ "sub", walk(expr), [ "num", parseInt(name, 10) ] ];
+ }
+ },
+ "if": make_if,
+ "toplevel": function(body) {
+ return [ "toplevel", with_scope(this.scope, function(){
+ return tighten(MAP(body, walk));
+ }) ];
+ },
+ "switch": function(expr, body) {
+ var last = body.length - 1;
+ return [ "switch", walk(expr), MAP(body, function(branch, i){
+ var block = tighten(MAP(branch[1], walk));
+ if (i == last && block.length > 0) {
+ var node = block[block.length - 1];
+ if (node[0] == "break" && !node[1])
+ block.pop();
+ }
+ return [ branch[0] ? walk(branch[0]) : null, block ];
+ }) ];
+ },
+ "function": function() {
+ var ret = _lambda.apply(this, arguments);
+ if (ret[1] && !HOP(scope.refs, ret[1])) {
+ ret[1] = null;
+ }
+ return ret;
+ },
+ "defun": _lambda,
+ "block": function(body) {
+ if (body) return rmblock([ "block", tighten(MAP(body, walk)) ]);
+ },
+ "binary": function(op, left, right) {
+ return when_constant([ "binary", op, walk(left), walk(right) ], function yes(c){
+ return best_of(walk(c), this);
+ }, function no() {
+ return this;
+ });
+ },
+ "conditional": function(c, t, e) {
+ return make_conditional(walk(c), walk(t), walk(e));
+ },
+ "try": function(t, c, f) {
+ return [
+ "try",
+ tighten(MAP(t, walk)),
+ c != null ? [ c[0], tighten(MAP(c[1], walk)) ] : null,
+ f != null ? tighten(MAP(f, walk)) : null
+ ];
+ },
+ "unary-prefix": function(op, expr) {
+ expr = walk(expr);
+ var ret = [ "unary-prefix", op, expr ];
+ if (op == "!")
+ ret = best_of(ret, negate(expr));
+ return when_constant(ret, function(ast, val){
+ return walk(ast); // it's either true or false, so minifies to !0 or !1
+ }, function() { return ret });
+ },
+ "name": function(name) {
+ switch (name) {
+ case "true": return [ "unary-prefix", "!", [ "num", 0 ]];
+ case "false": return [ "unary-prefix", "!", [ "num", 1 ]];
+ }
+ },
+ "new": function(ctor, args) {
+ if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) {
+ if (args.length != 1) {
+ return [ "array", args ];
+ } else {
+ return [ "call", [ "name", "Array" ], args ];
+ }
+ }
+ },
+ "call": function(expr, args) {
+ if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
+ return [ "array", args ];
+ }
+ },
+ "while": _do_while,
+ "do": _do_while
+ }, function() {
+ return walk(ast_add_scope(ast));
+ });
+};
+
+/* -----[ re-generate code from the AST ]----- */
+
+var DOT_CALL_NO_PARENS = jsp.array_to_hash([
+ "name",
+ "array",
+ "object",
+ "string",
+ "dot",
+ "sub",
+ "call",
+ "regexp"
+]);
+
+function make_string(str, ascii_only) {
+ var dq = 0, sq = 0;
+ str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029]/g, function(s){
+ switch (s) {
+ case "\\": return "\\\\";
+ case "\b": return "\\b";
+ case "\f": return "\\f";
+ case "\n": return "\\n";
+ case "\r": return "\\r";
+ case "\t": return "\\t";
+ case "\u2028": return "\\u2028";
+ case "\u2029": return "\\u2029";
+ case '"': ++dq; return '"';
+ case "'": ++sq; return "'";
+ }
+ return s;
+ });
+ if (ascii_only) str = to_ascii(str);
+ if (dq > sq) return "'" + str.replace(/\x27/g, "\\'") + "'";
+ else return '"' + str.replace(/\x22/g, '\\"') + '"';
+};
+
+function to_ascii(str) {
+ return str.replace(/[\u0080-\uffff]/g, function(ch) {
+ var code = ch.charCodeAt(0).toString(16);
+ while (code.length < 4) code = "0" + code;
+ return "\\u" + code;
+ });
+};
+
+function gen_code(ast, options) {
+ options = defaults(options, {
+ indent_start : 0,
+ indent_level : 4,
+ quote_keys : false,
+ space_colon : false,
+ beautify : false,
+ ascii_only : false
+ });
+ var beautify = !!options.beautify;
+ var indentation = 0,
+ newline = beautify ? "\n" : "",
+ space = beautify ? " " : "";
+
+ function encode_string(str) {
+ return make_string(str, options.ascii_only);
+ };
+
+ function make_name(name) {
+ name = name.toString();
+ if (options.ascii_only)
+ name = to_ascii(name);
+ return name;
+ };
+
+ function indent(line) {
+ if (line == null)
+ line = "";
+ if (beautify)
+ line = repeat_string(" ", options.indent_start + indentation * options.indent_level) + line;
+ return line;
+ };
+
+ function with_indent(cont, incr) {
+ if (incr == null) incr = 1;
+ indentation += incr;
+ try { return cont.apply(null, slice(arguments, 1)); }
+ finally { indentation -= incr; }
+ };
+
+ function add_spaces(a) {
+ if (beautify)
+ return a.join(" ");
+ var b = [];
+ for (var i = 0; i < a.length; ++i) {
+ var next = a[i + 1];
+ b.push(a[i]);
+ if (next &&
+ ((/[a-z0-9_\x24]$/i.test(a[i].toString()) && /^[a-z0-9_\x24]/i.test(next.toString())) ||
+ (/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) {
+ b.push(" ");
+ }
+ }
+ return b.join("");
+ };
+
+ function add_commas(a) {
+ return a.join("," + space);
+ };
+
+ function parenthesize(expr) {
+ var gen = make(expr);
+ for (var i = 1; i < arguments.length; ++i) {
+ var el = arguments[i];
+ if ((el instanceof Function && el(expr)) || expr[0] == el)
+ return "(" + gen + ")";
+ }
+ return gen;
+ };
+
+ function best_of(a) {
+ if (a.length == 1) {
+ return a[0];
+ }
+ if (a.length == 2) {
+ var b = a[1];
+ a = a[0];
+ return a.length <= b.length ? a : b;
+ }
+ return best_of([ a[0], best_of(a.slice(1)) ]);
+ };
+
+ function needs_parens(expr) {
+ if (expr[0] == "function" || expr[0] == "object") {
+ // dot/call on a literal function requires the
+ // function literal itself to be parenthesized
+ // only if it's the first "thing" in a
+ // statement. This means that the parent is
+ // "stat", but it could also be a "seq" and
+ // we're the first in this "seq" and the
+ // parent is "stat", and so on. Messy stuff,
+ // but it worths the trouble.
+ var a = slice($stack), self = a.pop(), p = a.pop();
+ while (p) {
+ if (p[0] == "stat") return true;
+ if (((p[0] == "seq" || p[0] == "call" || p[0] == "dot" || p[0] == "sub" || p[0] == "conditional") && p[1] === self) ||
+ ((p[0] == "binary" || p[0] == "assign" || p[0] == "unary-postfix") && p[2] === self)) {
+ self = p;
+ p = a.pop();
+ } else {
+ return false;
+ }
+ }
+ }
+ return !HOP(DOT_CALL_NO_PARENS, expr[0]);
+ };
+
+ function make_num(num) {
+ var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m;
+ if (Math.floor(num) === num) {
+ a.push("0x" + num.toString(16).toLowerCase(), // probably pointless
+ "0" + num.toString(8)); // same.
+ if ((m = /^(.*?)(0+)$/.exec(num))) {
+ a.push(m[1] + "e" + m[2].length);
+ }
+ } else if ((m = /^0?\.(0+)(.*)$/.exec(num))) {
+ a.push(m[2] + "e-" + (m[1].length + m[2].length),
+ str.substr(str.indexOf(".")));
+ }
+ return best_of(a);
+ };
+
+ var generators = {
+ "string": encode_string,
+ "num": make_num,
+ "name": make_name,
+ "toplevel": function(statements) {
+ return make_block_statements(statements)
+ .join(newline + newline);
+ },
+ "block": make_block,
+ "var": function(defs) {
+ return "var " + add_commas(MAP(defs, make_1vardef)) + ";";
+ },
+ "const": function(defs) {
+ return "const " + add_commas(MAP(defs, make_1vardef)) + ";";
+ },
+ "try": function(tr, ca, fi) {
+ var out = [ "try", make_block(tr) ];
+ if (ca) out.push("catch", "(" + ca[0] + ")", make_block(ca[1]));
+ if (fi) out.push("finally", make_block(fi));
+ return add_spaces(out);
+ },
+ "throw": function(expr) {
+ return add_spaces([ "throw", make(expr) ]) + ";";
+ },
+ "new": function(ctor, args) {
+ args = args.length > 0 ? "(" + add_commas(MAP(args, make)) + ")" : "";
+ return add_spaces([ "new", parenthesize(ctor, "seq", "binary", "conditional", "assign", function(expr){
+ var w = ast_walker(), has_call = {};
+ try {
+ w.with_walkers({
+ "call": function() { throw has_call },
+ "function": function() { return this }
+ }, function(){
+ w.walk(expr);
+ });
+ } catch(ex) {
+ if (ex === has_call)
+ return true;
+ throw ex;
+ }
+ }) + args ]);
+ },
+ "switch": function(expr, body) {
+ return add_spaces([ "switch", "(" + make(expr) + ")", make_switch_block(body) ]);
+ },
+ "break": function(label) {
+ var out = "break";
+ if (label != null)
+ out += " " + make_name(label);
+ return out + ";";
+ },
+ "continue": function(label) {
+ var out = "continue";
+ if (label != null)
+ out += " " + make_name(label);
+ return out + ";";
+ },
+ "conditional": function(co, th, el) {
+ return add_spaces([ parenthesize(co, "assign", "seq", "conditional"), "?",
+ parenthesize(th, "seq"), ":",
+ parenthesize(el, "seq") ]);
+ },
+ "assign": function(op, lvalue, rvalue) {
+ if (op && op !== true) op += "=";
+ else op = "=";
+ return add_spaces([ make(lvalue), op, parenthesize(rvalue, "seq") ]);
+ },
+ "dot": function(expr) {
+ var out = make(expr), i = 1;
+ if (expr[0] == "num") {
+ if (!/\./.test(expr[1]))
+ out += ".";
+ } else if (needs_parens(expr))
+ out = "(" + out + ")";
+ while (i < arguments.length)
+ out += "." + make_name(arguments[i++]);
+ return out;
+ },
+ "call": function(func, args) {
+ var f = make(func);
+ if (needs_parens(func))
+ f = "(" + f + ")";
+ return f + "(" + add_commas(MAP(args, function(expr){
+ return parenthesize(expr, "seq");
+ })) + ")";
+ },
+ "function": make_function,
+ "defun": make_function,
+ "if": function(co, th, el) {
+ var out = [ "if", "(" + make(co) + ")", el ? make_then(th) : make(th) ];
+ if (el) {
+ out.push("else", make(el));
+ }
+ return add_spaces(out);
+ },
+ "for": function(init, cond, step, block) {
+ var out = [ "for" ];
+ init = (init != null ? make(init) : "").replace(/;*\s*$/, ";" + space);
+ cond = (cond != null ? make(cond) : "").replace(/;*\s*$/, ";" + space);
+ step = (step != null ? make(step) : "").replace(/;*\s*$/, "");
+ var args = init + cond + step;
+ if (args == "; ; ") args = ";;";
+ out.push("(" + args + ")", make(block));
+ return add_spaces(out);
+ },
+ "for-in": function(vvar, key, hash, block) {
+ return add_spaces([ "for", "(" +
+ (vvar ? make(vvar).replace(/;+$/, "") : make(key)),
+ "in",
+ make(hash) + ")", make(block) ]);
+ },
+ "while": function(condition, block) {
+ return add_spaces([ "while", "(" + make(condition) + ")", make(block) ]);
+ },
+ "do": function(condition, block) {
+ return add_spaces([ "do", make(block), "while", "(" + make(condition) + ")" ]) + ";";
+ },
+ "return": function(expr) {
+ var out = [ "return" ];
+ if (expr != null) out.push(make(expr));
+ return add_spaces(out) + ";";
+ },
+ "binary": function(operator, lvalue, rvalue) {
+ var left = make(lvalue), right = make(rvalue);
+ // XXX: I'm pretty sure other cases will bite here.
+ // we need to be smarter.
+ // adding parens all the time is the safest bet.
+ if (member(lvalue[0], [ "assign", "conditional", "seq" ]) ||
+ lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]]) {
+ left = "(" + left + ")";
+ }
+ if (member(rvalue[0], [ "assign", "conditional", "seq" ]) ||
+ rvalue[0] == "binary" && PRECEDENCE[operator] >= PRECEDENCE[rvalue[1]] &&
+ !(rvalue[1] == operator && member(operator, [ "&&", "||", "*" ]))) {
+ right = "(" + right + ")";
+ }
+ return add_spaces([ left, operator, right ]);
+ },
+ "unary-prefix": function(operator, expr) {
+ var val = make(expr);
+ if (!(expr[0] == "num" || (expr[0] == "unary-prefix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr)))
+ val = "(" + val + ")";
+ return operator + (jsp.is_alphanumeric_char(operator.charAt(0)) ? " " : "") + val;
+ },
+ "unary-postfix": function(operator, expr) {
+ var val = make(expr);
+ if (!(expr[0] == "num" || (expr[0] == "unary-postfix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr)))
+ val = "(" + val + ")";
+ return val + operator;
+ },
+ "sub": function(expr, subscript) {
+ var hash = make(expr);
+ if (needs_parens(expr))
+ hash = "(" + hash + ")";
+ return hash + "[" + make(subscript) + "]";
+ },
+ "object": function(props) {
+ if (props.length == 0)
+ return "{}";
+ return "{" + newline + with_indent(function(){
+ return MAP(props, function(p){
+ if (p.length == 3) {
+ // getter/setter. The name is in p[0], the arg.list in p[1][2], the
+ // body in p[1][3] and type ("get" / "set") in p[2].
+ return indent(make_function(p[0], p[1][2], p[1][3], p[2]));
+ }
+ var key = p[0], val = make(p[1]);
+ if (options.quote_keys) {
+ key = encode_string(key);
+ } else if ((typeof key == "number" || !beautify && +key + "" == key)
+ && parseFloat(key) >= 0) {
+ key = make_num(+key);
+ } else if (!is_identifier(key)) {
+ key = encode_string(key);
+ }
+ return indent(add_spaces(beautify && options.space_colon
+ ? [ key, ":", val ]
+ : [ key + ":", val ]));
+ }).join("," + newline);
+ }) + newline + indent("}");
+ },
+ "regexp": function(rx, mods) {
+ return "/" + rx + "/" + mods;
+ },
+ "array": function(elements) {
+ if (elements.length == 0) return "[]";
+ return add_spaces([ "[", add_commas(MAP(elements, function(el){
+ if (!beautify && el[0] == "atom" && el[1] == "undefined") return "";
+ return parenthesize(el, "seq");
+ })), "]" ]);
+ },
+ "stat": function(stmt) {
+ return make(stmt).replace(/;*\s*$/, ";");
+ },
+ "seq": function() {
+ return add_commas(MAP(slice(arguments), make));
+ },
+ "label": function(name, block) {
+ return add_spaces([ make_name(name), ":", make(block) ]);
+ },
+ "with": function(expr, block) {
+ return add_spaces([ "with", "(" + make(expr) + ")", make(block) ]);
+ },
+ "atom": function(name) {
+ return make_name(name);
+ }
+ };
+
+ // The squeezer replaces "block"-s that contain only a single
+ // statement with the statement itself; technically, the AST
+ // is correct, but this can create problems when we output an
+ // IF having an ELSE clause where the THEN clause ends in an
+ // IF *without* an ELSE block (then the outer ELSE would refer
+ // to the inner IF). This function checks for this case and
+ // adds the block brackets if needed.
+ function make_then(th) {
+ if (th[0] == "do") {
+ // https://github.com/mishoo/UglifyJS/issues/#issue/57
+ // IE croaks with "syntax error" on code like this:
+ // if (foo) do ... while(cond); else ...
+ // we need block brackets around do/while
+ return make([ "block", [ th ]]);
+ }
+ var b = th;
+ while (true) {
+ var type = b[0];
+ if (type == "if") {
+ if (!b[3])
+ // no else, we must add the block
+ return make([ "block", [ th ]]);
+ b = b[3];
+ }
+ else if (type == "while" || type == "do") b = b[2];
+ else if (type == "for" || type == "for-in") b = b[4];
+ else break;
+ }
+ return make(th);
+ };
+
+ function make_function(name, args, body, keyword) {
+ var out = keyword || "function";
+ if (name) {
+ out += " " + make_name(name);
+ }
+ out += "(" + add_commas(MAP(args, make_name)) + ")";
+ return add_spaces([ out, make_block(body) ]);
+ };
+
+ function make_block_statements(statements) {
+ for (var a = [], last = statements.length - 1, i = 0; i <= last; ++i) {
+ var stat = statements[i];
+ var code = make(stat);
+ if (code != ";") {
+ if (!beautify && i == last) {
+ if ((stat[0] == "while" && empty(stat[2])) ||
+ (member(stat[0], [ "for", "for-in"] ) && empty(stat[4])) ||
+ (stat[0] == "if" && empty(stat[2]) && !stat[3]) ||
+ (stat[0] == "if" && stat[3] && empty(stat[3]))) {
+ code = code.replace(/;*\s*$/, ";");
+ } else {
+ code = code.replace(/;+\s*$/, "");
+ }
+ }
+ a.push(code);
+ }
+ }
+ return MAP(a, indent);
+ };
+
+ function make_switch_block(body) {
+ var n = body.length;
+ if (n == 0) return "{}";
+ return "{" + newline + MAP(body, function(branch, i){
+ var has_body = branch[1].length > 0, code = with_indent(function(){
+ return indent(branch[0]
+ ? add_spaces([ "case", make(branch[0]) + ":" ])
+ : "default:");
+ }, 0.5) + (has_body ? newline + with_indent(function(){
+ return make_block_statements(branch[1]).join(newline);
+ }) : "");
+ if (!beautify && has_body && i < n - 1)
+ code += ";";
+ return code;
+ }).join(newline) + newline + indent("}");
+ };
+
+ function make_block(statements) {
+ if (!statements) return ";";
+ if (statements.length == 0) return "{}";
+ return "{" + newline + with_indent(function(){
+ return make_block_statements(statements).join(newline);
+ }) + newline + indent("}");
+ };
+
+ function make_1vardef(def) {
+ var name = def[0], val = def[1];
+ if (val != null)
+ name = add_spaces([ make_name(name), "=", parenthesize(val, "seq") ]);
+ return name;
+ };
+
+ var $stack = [];
+
+ function make(node) {
+ var type = node[0];
+ var gen = generators[type];
+ if (!gen)
+ throw new Error("Can't find generator for \"" + type + "\"");
+ $stack.push(node);
+ var ret = gen.apply(type, node.slice(1));
+ $stack.pop();
+ return ret;
+ };
+
+ return make(ast);
+};
+
+function split_lines(code, max_line_length) {
+ var splits = [ 0 ];
+ jsp.parse(function(){
+ var next_token = jsp.tokenizer(code);
+ var last_split = 0;
+ var prev_token;
+ function current_length(tok) {
+ return tok.pos - last_split;
+ };
+ function split_here(tok) {
+ last_split = tok.pos;
+ splits.push(last_split);
+ };
+ function custom(){
+ var tok = next_token.apply(this, arguments);
+ out: {
+ if (prev_token) {
+ if (prev_token.type == "keyword") break out;
+ }
+ if (current_length(tok) > max_line_length) {
+ switch (tok.type) {
+ case "keyword":
+ case "atom":
+ case "name":
+ case "punc":
+ split_here(tok);
+ break out;
+ }
+ }
+ }
+ prev_token = tok;
+ return tok;
+ };
+ custom.context = function() {
+ return next_token.context.apply(this, arguments);
+ };
+ return custom;
+ }());
+ return splits.map(function(pos, i){
+ return code.substring(pos, splits[i + 1] || code.length);
+ }).join("\n");
+};
+
+/* -----[ Utilities ]----- */
+
+function repeat_string(str, i) {
+ if (i <= 0) return "";
+ if (i == 1) return str;
+ var d = repeat_string(str, i >> 1);
+ d += d;
+ if (i & 1) d += str;
+ return d;
+};
+
+function defaults(args, defs) {
+ var ret = {};
+ if (args === true)
+ args = {};
+ for (var i in defs) if (HOP(defs, i)) {
+ ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
+ }
+ return ret;
+};
+
+function is_identifier(name) {
+ return /^[a-z_$][a-z0-9_$]*$/i.test(name)
+ && name != "this"
+ && !HOP(jsp.KEYWORDS_ATOM, name)
+ && !HOP(jsp.RESERVED_WORDS, name)
+ && !HOP(jsp.KEYWORDS, name);
+};
+
+function HOP(obj, prop) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
+};
+
+// some utilities
+
+var MAP;
+
+(function(){
+ MAP = function(a, f, o) {
+ var ret = [];
+ for (var i = 0; i < a.length; ++i) {
+ var val = f.call(o, a[i], i);
+ if (val instanceof AtTop) ret.unshift(val.v);
+ else ret.push(val);
+ }
+ return ret;
+ };
+ MAP.at_top = function(val) { return new AtTop(val) };
+ function AtTop(val) { this.v = val };
+})();
+
+/* -----[ Exports ]----- */
+
+exports.ast_walker = ast_walker;
+exports.ast_mangle = ast_mangle;
+exports.ast_squeeze = ast_squeeze;
+exports.gen_code = gen_code;
+exports.ast_add_scope = ast_add_scope;
+exports.set_logger = function(logger) { warn = logger };
+exports.make_string = make_string;
+exports.split_lines = split_lines;
+exports.MAP = MAP;
+
+// keep this last!
+exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/squeeze-more.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/squeeze-more.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/squeeze-more.js
new file mode 100644
index 0000000..12380af
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/squeeze-more.js
@@ -0,0 +1,22 @@
+var jsp = require("./parse-js"),
+ pro = require("./process"),
+ slice = jsp.slice,
+ member = jsp.member,
+ PRECEDENCE = jsp.PRECEDENCE,
+ OPERATORS = jsp.OPERATORS;
+
+function ast_squeeze_more(ast) {
+ var w = pro.ast_walker(), walk = w.walk;
+ return w.with_walkers({
+ "call": function(expr, args) {
+ if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
+ // foo.toString() ==> foo+""
+ return [ "binary", "+", expr[1], [ "string", "" ]];
+ }
+ }
+ }, function() {
+ return walk(ast);
+ });
+};
+
+exports.ast_squeeze_more = ast_squeeze_more;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/post-compile.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/post-compile.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/post-compile.js
new file mode 100644
index 0000000..4bcafe8
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/post-compile.js
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+var print = require("sys").print,
+ src = require("fs").readFileSync(process.argv[2], "utf8");
+
+// Previously done in sed but reimplemented here due to portability issues
+print(src.replace(/^(\s*\*\/)(.+)/m, "$1\n$2;"));
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/uglify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/uglify.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/uglify.js
new file mode 100644
index 0000000..943ddd8
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/uglify.js
@@ -0,0 +1,199 @@
+#! /usr/bin/env node
+// -*- js2 -*-
+
+global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
+var fs = require("fs"),
+ jsp = require("./lib/parse-js"),
+ pro = require("./lib/process");
+
+pro.set_logger(function(msg){
+ sys.debug(msg);
+});
+
+var options = {
+ ast: false,
+ mangle: true,
+ mangle_toplevel: false,
+ squeeze: true,
+ make_seqs: true,
+ dead_code: true,
+ beautify: false,
+ verbose: false,
+ show_copyright: true,
+ out_same_file: false,
+ extra: false,
+ unsafe: false, // XXX: extra & unsafe? but maybe we don't want both, so....
+ beautify_options: {
+ indent_level: 4,
+ indent_start: 0,
+ quote_keys: false,
+ space_colon: false
+ },
+ output: true // stdout
+};
+
+var args = jsp.slice(process.argv, 2);
+var filename;
+
+out: while (args.length > 0) {
+ var v = args.shift();
+ switch (v) {
+ case "-b":
+ case "--beautify":
+ options.beautify = true;
+ break;
+ case "-i":
+ case "--indent":
+ options.beautify_options.indent_level = args.shift();
+ break;
+ case "-q":
+ case "--quote-keys":
+ options.beautify_options.quote_keys = true;
+ break;
+ case "-mt":
+ case "--mangle-toplevel":
+ options.mangle_toplevel = true;
+ break;
+ case "--no-mangle":
+ case "-nm":
+ options.mangle = false;
+ break;
+ case "--no-squeeze":
+ case "-ns":
+ options.squeeze = false;
+ break;
+ case "--no-seqs":
+ options.make_seqs = false;
+ break;
+ case "--no-dead-code":
+ options.dead_code = false;
+ break;
+ case "--no-copyright":
+ case "-nc":
+ options.show_copyright = false;
+ break;
+ case "-o":
+ case "--output":
+ options.output = args.shift();
+ break;
+ case "--overwrite":
+ options.out_same_file = true;
+ break;
+ case "-v":
+ case "--verbose":
+ options.verbose = true;
+ break;
+ case "--ast":
+ options.ast = true;
+ break;
+ case "--extra":
+ options.extra = true;
+ break;
+ case "--unsafe":
+ options.unsafe = true;
+ break;
+ default:
+ filename = v;
+ break out;
+ }
+}
+
+if (filename) {
+ fs.readFile(filename, "utf8", function(err, text){
+ if (err) {
+ throw err;
+ }
+ output(squeeze_it(text));
+ });
+} else {
+ var stdin = process.openStdin();
+ stdin.setEncoding("utf8");
+ var text = "";
+ stdin.on("data", function(chunk){
+ text += chunk;
+ });
+ stdin.on("end", function() {
+ output(squeeze_it(text));
+ });
+}
+
+function output(text) {
+ var out;
+ if (options.out_same_file && filename)
+ options.output = filename;
+ if (options.output === true) {
+ out = process.stdout;
+ } else {
+ out = fs.createWriteStream(options.output, {
+ flags: "w",
+ encoding: "utf8",
+ mode: 0644
+ });
+ }
+ out.write(text);
+ out.end();
+};
+
+// --------- main ends here.
+
+function show_copyright(comments) {
+ var ret = "";
+ for (var i = 0; i < comments.length; ++i) {
+ var c = comments[i];
+ if (c.type == "comment1") {
+ ret += "//" + c.value + "\n";
+ } else {
+ ret += "/*" + c.value + "*/";
+ }
+ }
+ return ret;
+};
+
+function squeeze_it(code) {
+ var result = "";
+ if (options.show_copyright) {
+ var initial_comments = [];
+ // keep first comment
+ var tok = jsp.tokenizer(code, false), c;
+ c = tok();
+ var prev = null;
+ while (/^comment/.test(c.type) && (!prev || prev == c.type)) {
+ initial_comments.push(c);
+ prev = c.type;
+ c = tok();
+ }
+ result += show_copyright(initial_comments);
+ }
+ try {
+ var ast = time_it("parse", function(){ return jsp.parse(code); });
+ if (options.mangle)
+ ast = time_it("mangle", function(){ return pro.ast_mangle(ast, options.mangle_toplevel); });
+ if (options.squeeze)
+ ast = time_it("squeeze", function(){
+ ast = pro.ast_squeeze(ast, {
+ make_seqs : options.make_seqs,
+ dead_code : options.dead_code,
+ extra : options.extra
+ });
+ if (options.unsafe)
+ ast = pro.ast_squeeze_more(ast);
+ return ast;
+ });
+ if (options.ast)
+ return sys.inspect(ast, null, null);
+ result += time_it("generate", function(){ return pro.gen_code(ast, options.beautify && options.beautify_options) });
+ return result;
+ } catch(ex) {
+ sys.debug(ex.stack);
+ sys.debug(sys.inspect(ex));
+ sys.debug(JSON.stringify(ex));
+ }
+};
+
+function time_it(name, cont) {
+ if (!options.verbose)
+ return cont();
+ var t1 = new Date().getTime();
+ try { return cont(); }
+ finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
+};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[19/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promisify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promisify.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promisify.js
new file mode 100644
index 0000000..a550fd0
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promisify.js
@@ -0,0 +1,278 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var THIS = {};
+var util = require("./util.js");
+var es5 = require("./es5.js");
+var nodebackForPromise = require("./promise_resolver.js")
+ ._nodebackForPromise;
+var withAppended = util.withAppended;
+var maybeWrapAsError = util.maybeWrapAsError;
+var canEvaluate = util.canEvaluate;
+var notEnumerableProp = util.notEnumerableProp;
+var deprecated = util.deprecated;
+var roriginal = new RegExp("__beforePromisified__" + "$");
+var hasProp = {}.hasOwnProperty;
+function isPromisified(fn) {
+ return fn.__isPromisified__ === true;
+}
+var inheritedMethods = (function() {
+ if (es5.isES5) {
+ var create = Object.create;
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
+ return function(cur) {
+ var original = cur;
+ var ret = [];
+ var visitedKeys = create(null);
+ while (cur !== null) {
+ var keys = es5.keys(cur);
+ for (var i = 0, len = keys.length; i < len; ++i) {
+ var key = keys[i];
+ if (visitedKeys[key] ||
+ roriginal.test(key) ||
+ hasProp.call(original, key + "__beforePromisified__")
+ ) {
+ continue;
+ }
+ visitedKeys[key] = true;
+ var desc = getOwnPropertyDescriptor(cur, key);
+ if (desc != null &&
+ typeof desc.value === "function" &&
+ !isPromisified(desc.value)) {
+ ret.push(key, desc.value);
+ }
+ }
+ cur = es5.getPrototypeOf(cur);
+ }
+ return ret;
+ };
+ }
+ else {
+ return function(obj) {
+ var ret = [];
+ /*jshint forin:false */
+ for (var key in obj) {
+ if (roriginal.test(key) ||
+ hasProp.call(obj, key + "__beforePromisified__")) {
+ continue;
+ }
+ var fn = obj[key];
+ if (typeof fn === "function" &&
+ !isPromisified(fn)) {
+ ret.push(key, fn);
+ }
+ }
+ return ret;
+ };
+ }
+})();
+
+function switchCaseArgumentOrder(likelyArgumentCount) {
+ var ret = [likelyArgumentCount];
+ var min = Math.max(0, likelyArgumentCount - 1 - 5);
+ for(var i = likelyArgumentCount - 1; i >= min; --i) {
+ if (i === likelyArgumentCount) continue;
+ ret.push(i);
+ }
+ for(var i = likelyArgumentCount + 1; i <= 5; ++i) {
+ ret.push(i);
+ }
+ return ret;
+}
+
+function parameterDeclaration(parameterCount) {
+ var ret = new Array(parameterCount);
+ for(var i = 0; i < ret.length; ++i) {
+ ret[i] = "_arg" + i;
+ }
+ return ret.join(", ");
+}
+
+function parameterCount(fn) {
+ if (typeof fn.length === "number") {
+ return Math.max(Math.min(fn.length, 1023 + 1), 0);
+ }
+ return 0;
+}
+
+function propertyAccess(id) {
+ var rident = /^[a-z$_][a-z$_0-9]*$/i;
+
+ if (rident.test(id)) {
+ return "." + id;
+ }
+ else return "['" + id.replace(/(['\\])/g, "\\$1") + "']";
+}
+
+function makeNodePromisifiedEval(callback, receiver, originalName, fn) {
+ var newParameterCount = Math.max(0, parameterCount(fn) - 1);
+ var argumentOrder = switchCaseArgumentOrder(newParameterCount);
+
+ var callbackName = (typeof originalName === "string" ?
+ originalName + "Async" :
+ "promisified");
+
+ function generateCallForArgumentCount(count) {
+ var args = new Array(count);
+ for (var i = 0, len = args.length; i < len; ++i) {
+ args[i] = "arguments[" + i + "]";
+ }
+ var comma = count > 0 ? "," : "";
+
+ if (typeof callback === "string" &&
+ receiver === THIS) {
+ return "this" + propertyAccess(callback) + "("+args.join(",") +
+ comma +" fn);"+
+ "break;";
+ }
+ return (receiver === void 0
+ ? "callback("+args.join(",")+ comma +" fn);"
+ : "callback.call("+(receiver === THIS
+ ? "this"
+ : "receiver")+", "+args.join(",") + comma + " fn);") +
+ "break;";
+ }
+
+ function generateArgumentSwitchCase() {
+ var ret = "";
+ for(var i = 0; i < argumentOrder.length; ++i) {
+ ret += "case " + argumentOrder[i] +":" +
+ generateCallForArgumentCount(argumentOrder[i]);
+ }
+ ret += "default: var args = new Array(len + 1);" +
+ "var i = 0;" +
+ "for (var i = 0; i < len; ++i) { " +
+ " args[i] = arguments[i];" +
+ "}" +
+ "args[i] = fn;" +
+
+ (typeof callback === "string"
+ ? "this" + propertyAccess(callback) + ".apply("
+ : "callback.apply(") +
+
+ (receiver === THIS ? "this" : "receiver") +
+ ", args); break;";
+ return ret;
+ }
+
+ return new Function("Promise", "callback", "receiver",
+ "withAppended", "maybeWrapAsError", "nodebackForPromise",
+ "INTERNAL",
+ "var ret = function " + callbackName +
+ "(" + parameterDeclaration(newParameterCount) + ") {\"use strict\";" +
+ "var len = arguments.length;" +
+ "var promise = new Promise(INTERNAL);"+
+ "promise._setTrace(" + callbackName + ", void 0);" +
+ "var fn = nodebackForPromise(promise);"+
+ "try {" +
+ "switch(len) {" +
+ generateArgumentSwitchCase() +
+ "}" +
+ "}" +
+ "catch(e){ " +
+ "var wrapped = maybeWrapAsError(e);" +
+ "promise._attachExtraTrace(wrapped);" +
+ "promise._reject(wrapped);" +
+ "}" +
+ "return promise;" +
+ "" +
+ "}; ret.__isPromisified__ = true; return ret;"
+ )(Promise, callback, receiver, withAppended,
+ maybeWrapAsError, nodebackForPromise, INTERNAL);
+}
+
+function makeNodePromisifiedClosure(callback, receiver) {
+ function promisified() {
+ var _receiver = receiver;
+ if (receiver === THIS) _receiver = this;
+ if (typeof callback === "string") {
+ callback = _receiver[callback];
+ }
+ var promise = new Promise(INTERNAL);
+ promise._setTrace(promisified, void 0);
+ var fn = nodebackForPromise(promise);
+ try {
+ callback.apply(_receiver, withAppended(arguments, fn));
+ }
+ catch(e) {
+ var wrapped = maybeWrapAsError(e);
+ promise._attachExtraTrace(wrapped);
+ promise._reject(wrapped);
+ }
+ return promise;
+ }
+ promisified.__isPromisified__ = true;
+ return promisified;
+}
+
+var makeNodePromisified = canEvaluate
+ ? makeNodePromisifiedEval
+ : makeNodePromisifiedClosure;
+
+function _promisify(callback, receiver, isAll) {
+ if (isAll) {
+ var methods = inheritedMethods(callback);
+ for (var i = 0, len = methods.length; i < len; i+= 2) {
+ var key = methods[i];
+ var fn = methods[i+1];
+ var originalKey = key + "__beforePromisified__";
+ var promisifiedKey = key + "Async";
+ notEnumerableProp(callback, originalKey, fn);
+ callback[promisifiedKey] =
+ makeNodePromisified(originalKey, THIS,
+ key, fn);
+ }
+ util.toFastProperties(callback);
+ return callback;
+ }
+ else {
+ return makeNodePromisified(callback, receiver, void 0, callback);
+ }
+}
+
+Promise.promisify = function Promise$Promisify(fn, receiver) {
+ if (typeof fn === "object" && fn !== null) {
+ deprecated("Promise.promisify for promisifying entire objects is deprecated. Use Promise.promisifyAll instead.");
+ return _promisify(fn, receiver, true);
+ }
+ if (typeof fn !== "function") {
+ throw new TypeError("fn must be a function");
+ }
+ if (isPromisified(fn)) {
+ return fn;
+ }
+ return _promisify(
+ fn,
+ arguments.length < 2 ? THIS : receiver,
+ false);
+};
+
+Promise.promisifyAll = function Promise$PromisifyAll(target) {
+ if (typeof target !== "function" && typeof target !== "object") {
+ throw new TypeError("the target of promisifyAll must be an object or a function");
+ }
+ return _promisify(target, void 0, true);
+};
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/properties_promise_array.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/properties_promise_array.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/properties_promise_array.js
new file mode 100644
index 0000000..85f5990
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/properties_promise_array.js
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, PromiseArray) {
+var util = require("./util.js");
+var inherits = util.inherits;
+var es5 = require("./es5.js");
+
+function PropertiesPromiseArray(obj, caller, boundTo) {
+ var keys = es5.keys(obj);
+ var values = new Array(keys.length);
+ for (var i = 0, len = values.length; i < len; ++i) {
+ values[i] = obj[keys[i]];
+ }
+ this.constructor$(values, caller, boundTo);
+ if (!this._isResolved()) {
+ for (var i = 0, len = keys.length; i < len; ++i) {
+ values.push(keys[i]);
+ }
+ }
+}
+inherits(PropertiesPromiseArray, PromiseArray);
+
+PropertiesPromiseArray.prototype._init =
+function PropertiesPromiseArray$_init() {
+ this._init$(void 0, -3) ;
+};
+
+PropertiesPromiseArray.prototype._promiseFulfilled =
+function PropertiesPromiseArray$_promiseFulfilled(value, index) {
+ if (this._isResolved()) return;
+ this._values[index] = value;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ var val = {};
+ var keyOffset = this.length();
+ for (var i = 0, len = this.length(); i < len; ++i) {
+ val[this._values[i + keyOffset]] = this._values[i];
+ }
+ this._resolve(val);
+ }
+};
+
+PropertiesPromiseArray.prototype._promiseProgressed =
+function PropertiesPromiseArray$_promiseProgressed(value, index) {
+ if (this._isResolved()) return;
+
+ this._promise._progress({
+ key: this._values[index + this.length()],
+ value: value
+ });
+};
+
+PromiseArray.PropertiesPromiseArray = PropertiesPromiseArray;
+
+return PropertiesPromiseArray;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/props.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/props.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/props.js
new file mode 100644
index 0000000..3cdba43
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/props.js
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, PromiseArray) {
+ var PropertiesPromiseArray = require("./properties_promise_array.js")(
+ Promise, PromiseArray);
+ var util = require("./util.js");
+ var apiRejection = require("./errors_api_rejection")(Promise);
+ var isObject = util.isObject;
+
+ function Promise$_Props(promises, useBound, caller) {
+ var ret;
+ var castValue = Promise._cast(promises, caller, void 0);
+
+ if (!isObject(castValue)) {
+ return apiRejection("cannot await properties of a non-object");
+ }
+ else if (Promise.is(castValue)) {
+ ret = castValue._then(Promise.props, void 0, void 0,
+ void 0, void 0, caller);
+ }
+ else {
+ ret = new PropertiesPromiseArray(
+ castValue,
+ caller,
+ useBound === true && castValue._isBound()
+ ? castValue._boundTo
+ : void 0
+ ).promise();
+ useBound = false;
+ }
+ if (useBound === true && castValue._isBound()) {
+ ret._setBoundTo(castValue._boundTo);
+ }
+ return ret;
+ }
+
+ Promise.prototype.props = function Promise$props() {
+ return Promise$_Props(this, true, this.props);
+ };
+
+ Promise.props = function Promise$Props(promises) {
+ return Promise$_Props(promises, false, Promise.props);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/queue.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/queue.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/queue.js
new file mode 100644
index 0000000..bbd3f1b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/queue.js
@@ -0,0 +1,135 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+function arrayCopy(src, srcIndex, dst, dstIndex, len) {
+ for (var j = 0; j < len; ++j) {
+ dst[j + dstIndex] = src[j + srcIndex];
+ }
+}
+
+function pow2AtLeast(n) {
+ n = n >>> 0;
+ n = n - 1;
+ n = n | (n >> 1);
+ n = n | (n >> 2);
+ n = n | (n >> 4);
+ n = n | (n >> 8);
+ n = n | (n >> 16);
+ return n + 1;
+}
+
+function getCapacity(capacity) {
+ if (typeof capacity !== "number") return 16;
+ return pow2AtLeast(
+ Math.min(
+ Math.max(16, capacity), 1073741824)
+ );
+}
+
+function Queue(capacity) {
+ this._capacity = getCapacity(capacity);
+ this._length = 0;
+ this._front = 0;
+ this._makeCapacity();
+}
+
+Queue.prototype._willBeOverCapacity =
+function Queue$_willBeOverCapacity(size) {
+ return this._capacity < size;
+};
+
+Queue.prototype._pushOne = function Queue$_pushOne(arg) {
+ var length = this.length();
+ this._checkCapacity(length + 1);
+ var i = (this._front + length) & (this._capacity - 1);
+ this[i] = arg;
+ this._length = length + 1;
+};
+
+Queue.prototype.push = function Queue$push(fn, receiver, arg) {
+ var length = this.length() + 3;
+ if (this._willBeOverCapacity(length)) {
+ this._pushOne(fn);
+ this._pushOne(receiver);
+ this._pushOne(arg);
+ return;
+ }
+ var j = this._front + length - 3;
+ this._checkCapacity(length);
+ var wrapMask = this._capacity - 1;
+ this[(j + 0) & wrapMask] = fn;
+ this[(j + 1) & wrapMask] = receiver;
+ this[(j + 2) & wrapMask] = arg;
+ this._length = length;
+};
+
+Queue.prototype.shift = function Queue$shift() {
+ var front = this._front,
+ ret = this[front];
+
+ this[front] = void 0;
+ this._front = (front + 1) & (this._capacity - 1);
+ this._length--;
+ return ret;
+};
+
+Queue.prototype.length = function Queue$length() {
+ return this._length;
+};
+
+Queue.prototype._makeCapacity = function Queue$_makeCapacity() {
+ var len = this._capacity;
+ for (var i = 0; i < len; ++i) {
+ this[i] = void 0;
+ }
+};
+
+Queue.prototype._checkCapacity = function Queue$_checkCapacity(size) {
+ if (this._capacity < size) {
+ this._resizeTo(this._capacity << 3);
+ }
+};
+
+Queue.prototype._resizeTo = function Queue$_resizeTo(capacity) {
+ var oldFront = this._front;
+ var oldCapacity = this._capacity;
+ var oldQueue = new Array(oldCapacity);
+ var length = this.length();
+
+ arrayCopy(this, 0, oldQueue, 0, oldCapacity);
+ this._capacity = capacity;
+ this._makeCapacity();
+ this._front = 0;
+ if (oldFront + length <= oldCapacity) {
+ arrayCopy(oldQueue, oldFront, this, 0, length);
+ }
+ else { var lengthBeforeWrapping =
+ length - ((oldFront + length) & (oldCapacity - 1));
+
+ arrayCopy(oldQueue, oldFront, this, 0, lengthBeforeWrapping);
+ arrayCopy(oldQueue, 0, this, lengthBeforeWrapping,
+ length - lengthBeforeWrapping);
+ }
+};
+
+module.exports = Queue;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/race.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/race.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/race.js
new file mode 100644
index 0000000..82b8ce1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/race.js
@@ -0,0 +1,85 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+ var apiRejection = require("./errors_api_rejection.js")(Promise);
+ var isArray = require("./util.js").isArray;
+
+ var raceLater = function Promise$_raceLater(promise) {
+ return promise.then(function Promise$_lateRacer(array) {
+ return Promise$_Race(array, Promise$_lateRacer, promise);
+ });
+ };
+
+ var hasOwn = {}.hasOwnProperty;
+ function Promise$_Race(promises, caller, parent) {
+ var maybePromise = Promise._cast(promises, caller, void 0);
+
+ if (Promise.is(maybePromise)) {
+ return raceLater(maybePromise);
+ }
+ else if (!isArray(promises)) {
+ return apiRejection("expecting an array, a promise or a thenable");
+ }
+
+ var ret = new Promise(INTERNAL);
+ ret._setTrace(caller, parent);
+ if (parent !== void 0) {
+ if (parent._isBound()) {
+ ret._setBoundTo(parent._boundTo);
+ }
+ if (parent._cancellable()) {
+ ret._setCancellable();
+ ret._cancellationParent = parent;
+ }
+ }
+ var fulfill = ret._fulfill;
+ var reject = ret._reject;
+ for (var i = 0, len = promises.length; i < len; ++i) {
+ var val = promises[i];
+
+ if (val === void 0 && !(hasOwn.call(promises, i))) {
+ continue;
+ }
+
+ Promise.cast(val)._then(
+ fulfill,
+ reject,
+ void 0,
+ ret,
+ null,
+ caller
+ );
+ }
+ return ret;
+ }
+
+ Promise.race = function Promise$Race(promises) {
+ return Promise$_Race(promises, Promise.race, void 0);
+ };
+
+ Promise.prototype.race = function Promise$race() {
+ return Promise$_Race(this, this.race, void 0);
+ };
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/reduce.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/reduce.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/reduce.js
new file mode 100644
index 0000000..e9ef95b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/reduce.js
@@ -0,0 +1,173 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(
+ Promise, Promise$_CreatePromiseArray,
+ PromiseArray, apiRejection, INTERNAL) {
+
+ function Reduction(callback, index, accum, items, receiver) {
+ this.promise = new Promise(INTERNAL);
+ this.index = index;
+ this.length = items.length;
+ this.items = items;
+ this.callback = callback;
+ this.receiver = receiver;
+ this.accum = accum;
+ }
+
+ Reduction.prototype.reject = function Reduction$reject(e) {
+ this.promise._reject(e);
+ };
+
+ Reduction.prototype.fulfill = function Reduction$fulfill(value, index) {
+ this.accum = value;
+ this.index = index + 1;
+ this.iterate();
+ };
+
+ Reduction.prototype.iterate = function Reduction$iterate() {
+ var i = this.index;
+ var len = this.length;
+ var items = this.items;
+ var result = this.accum;
+ var receiver = this.receiver;
+ var callback = this.callback;
+ var iterate = this.iterate;
+
+ for(; i < len; ++i) {
+ result = Promise._cast(
+ callback.call(
+ receiver,
+ result,
+ items[i],
+ i,
+ len
+ ),
+ iterate,
+ void 0
+ );
+
+ if (result instanceof Promise) {
+ result._then(
+ this.fulfill, this.reject, void 0, this, i, iterate);
+ return;
+ }
+ }
+ this.promise._fulfill(result);
+ };
+
+ function Promise$_reducer(fulfilleds, initialValue) {
+ var fn = this;
+ var receiver = void 0;
+ if (typeof fn !== "function") {
+ receiver = fn.receiver;
+ fn = fn.fn;
+ }
+ var len = fulfilleds.length;
+ var accum = void 0;
+ var startIndex = 0;
+
+ if (initialValue !== void 0) {
+ accum = initialValue;
+ startIndex = 0;
+ }
+ else {
+ startIndex = 1;
+ if (len > 0) accum = fulfilleds[0];
+ }
+ var i = startIndex;
+
+ if (i >= len) {
+ return accum;
+ }
+
+ var reduction = new Reduction(fn, i, accum, fulfilleds, receiver);
+ reduction.iterate();
+ return reduction.promise;
+ }
+
+ function Promise$_unpackReducer(fulfilleds) {
+ var fn = this.fn;
+ var initialValue = this.initialValue;
+ return Promise$_reducer.call(fn, fulfilleds, initialValue);
+ }
+
+ function Promise$_slowReduce(
+ promises, fn, initialValue, useBound, caller) {
+ return initialValue._then(function callee(initialValue) {
+ return Promise$_Reduce(
+ promises, fn, initialValue, useBound, callee);
+ }, void 0, void 0, void 0, void 0, caller);
+ }
+
+ function Promise$_Reduce(promises, fn, initialValue, useBound, caller) {
+ if (typeof fn !== "function") {
+ return apiRejection("fn must be a function");
+ }
+
+ if (useBound === true && promises._isBound()) {
+ fn = {
+ fn: fn,
+ receiver: promises._boundTo
+ };
+ }
+
+ if (initialValue !== void 0) {
+ if (Promise.is(initialValue)) {
+ if (initialValue.isFulfilled()) {
+ initialValue = initialValue._settledValue;
+ }
+ else {
+ return Promise$_slowReduce(promises,
+ fn, initialValue, useBound, caller);
+ }
+ }
+
+ return Promise$_CreatePromiseArray(promises, PromiseArray, caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0)
+ .promise()
+ ._then(Promise$_unpackReducer, void 0, void 0, {
+ fn: fn,
+ initialValue: initialValue
+ }, void 0, Promise.reduce);
+ }
+ return Promise$_CreatePromiseArray(promises, PromiseArray, caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0).promise()
+ ._then(Promise$_reducer, void 0, void 0, fn, void 0, caller);
+ }
+
+
+ Promise.reduce = function Promise$Reduce(promises, fn, initialValue) {
+ return Promise$_Reduce(promises, fn,
+ initialValue, false, Promise.reduce);
+ };
+
+ Promise.prototype.reduce = function Promise$reduce(fn, initialValue) {
+ return Promise$_Reduce(this, fn, initialValue,
+ true, this.reduce);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/schedule.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/schedule.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/schedule.js
new file mode 100644
index 0000000..ae2271e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/schedule.js
@@ -0,0 +1,121 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var global = require("./global.js");
+var schedule;
+if (typeof process !== "undefined" && process !== null &&
+ typeof process.cwd === "function" &&
+ typeof process.nextTick === "function" &&
+ typeof process.version === "string") {
+ schedule = function Promise$_Scheduler(fn) {
+ process.nextTick(fn);
+ };
+}
+else if ((typeof global.MutationObserver === "function" ||
+ typeof global.WebkitMutationObserver === "function" ||
+ typeof global.WebKitMutationObserver === "function") &&
+ typeof document !== "undefined" &&
+ typeof document.createElement === "function") {
+
+
+ schedule = (function(){
+ var MutationObserver = global.MutationObserver ||
+ global.WebkitMutationObserver ||
+ global.WebKitMutationObserver;
+ var div = document.createElement("div");
+ var queuedFn = void 0;
+ var observer = new MutationObserver(
+ function Promise$_Scheduler() {
+ var fn = queuedFn;
+ queuedFn = void 0;
+ fn();
+ }
+ );
+ observer.observe(div, {
+ attributes: true
+ });
+ return function Promise$_Scheduler(fn) {
+ queuedFn = fn;
+ div.setAttribute("class", "foo");
+ };
+
+ })();
+}
+else if (typeof global.postMessage === "function" &&
+ typeof global.importScripts !== "function" &&
+ typeof global.addEventListener === "function" &&
+ typeof global.removeEventListener === "function") {
+
+ var MESSAGE_KEY = "bluebird_message_key_" + Math.random();
+ schedule = (function(){
+ var queuedFn = void 0;
+
+ function Promise$_Scheduler(e) {
+ if (e.source === global &&
+ e.data === MESSAGE_KEY) {
+ var fn = queuedFn;
+ queuedFn = void 0;
+ fn();
+ }
+ }
+
+ global.addEventListener("message", Promise$_Scheduler, false);
+
+ return function Promise$_Scheduler(fn) {
+ queuedFn = fn;
+ global.postMessage(
+ MESSAGE_KEY, "*"
+ );
+ };
+
+ })();
+}
+else if (typeof global.MessageChannel === "function") {
+ schedule = (function(){
+ var queuedFn = void 0;
+
+ var channel = new global.MessageChannel();
+ channel.port1.onmessage = function Promise$_Scheduler() {
+ var fn = queuedFn;
+ queuedFn = void 0;
+ fn();
+ };
+
+ return function Promise$_Scheduler(fn) {
+ queuedFn = fn;
+ channel.port2.postMessage(null);
+ };
+ })();
+}
+else if (global.setTimeout) {
+ schedule = function Promise$_Scheduler(fn) {
+ setTimeout(fn, 4);
+ };
+}
+else {
+ schedule = function Promise$_Scheduler(fn) {
+ fn();
+ };
+}
+
+module.exports = schedule;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/settle.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/settle.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/settle.js
new file mode 100644
index 0000000..863882f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/settle.js
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports =
+ function(Promise, Promise$_CreatePromiseArray, PromiseArray) {
+
+ var SettledPromiseArray = require("./settled_promise_array.js")(
+ Promise, PromiseArray);
+
+ function Promise$_Settle(promises, useBound, caller) {
+ return Promise$_CreatePromiseArray(
+ promises,
+ SettledPromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ ).promise();
+ }
+
+ Promise.settle = function Promise$Settle(promises) {
+ return Promise$_Settle(promises, false, Promise.settle);
+ };
+
+ Promise.prototype.settle = function Promise$settle() {
+ return Promise$_Settle(this, true, this.settle);
+ };
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/settled_promise_array.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/settled_promise_array.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/settled_promise_array.js
new file mode 100644
index 0000000..fd25d4d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/settled_promise_array.js
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, PromiseArray) {
+var PromiseInspection = require("./promise_inspection.js");
+var util = require("./util.js");
+var inherits = util.inherits;
+function SettledPromiseArray(values, caller, boundTo) {
+ this.constructor$(values, caller, boundTo);
+}
+inherits(SettledPromiseArray, PromiseArray);
+
+SettledPromiseArray.prototype._promiseResolved =
+function SettledPromiseArray$_promiseResolved(index, inspection) {
+ this._values[index] = inspection;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ this._resolve(this._values);
+ }
+};
+
+SettledPromiseArray.prototype._promiseFulfilled =
+function SettledPromiseArray$_promiseFulfilled(value, index) {
+ if (this._isResolved()) return;
+ var ret = new PromiseInspection();
+ ret._bitField = 268435456;
+ ret._settledValue = value;
+ this._promiseResolved(index, ret);
+};
+SettledPromiseArray.prototype._promiseRejected =
+function SettledPromiseArray$_promiseRejected(reason, index) {
+ if (this._isResolved()) return;
+ var ret = new PromiseInspection();
+ ret._bitField = 134217728;
+ ret._settledValue = reason;
+ this._promiseResolved(index, ret);
+};
+
+return SettledPromiseArray;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/some.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/some.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/some.js
new file mode 100644
index 0000000..21c4ecd
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/some.js
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports =
+function(Promise, Promise$_CreatePromiseArray, PromiseArray, apiRejection) {
+
+ var SomePromiseArray = require("./some_promise_array.js")(PromiseArray);
+ function Promise$_Some(promises, howMany, useBound, caller) {
+ if ((howMany | 0) !== howMany || howMany < 0) {
+ return apiRejection("expecting a positive integer");
+ }
+ var ret = Promise$_CreatePromiseArray(
+ promises,
+ SomePromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ );
+ var promise = ret.promise();
+ if (promise.isRejected()) {
+ return promise;
+ }
+ ret.setHowMany(howMany);
+ ret.init();
+ return promise;
+ }
+
+ Promise.some = function Promise$Some(promises, howMany) {
+ return Promise$_Some(promises, howMany, false, Promise.some);
+ };
+
+ Promise.prototype.some = function Promise$some(count) {
+ return Promise$_Some(this, count, true, this.some);
+ };
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/some_promise_array.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/some_promise_array.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/some_promise_array.js
new file mode 100644
index 0000000..d3b89d4
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/some_promise_array.js
@@ -0,0 +1,131 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function (PromiseArray) {
+var util = require("./util.js");
+var RangeError = require("./errors.js").RangeError;
+var inherits = util.inherits;
+var isArray = util.isArray;
+
+function SomePromiseArray(values, caller, boundTo) {
+ this.constructor$(values, caller, boundTo);
+ this._howMany = 0;
+ this._unwrap = false;
+ this._initialized = false;
+}
+inherits(SomePromiseArray, PromiseArray);
+
+SomePromiseArray.prototype._init = function SomePromiseArray$_init() {
+ if (!this._initialized) {
+ return;
+ }
+ if (this._howMany === 0) {
+ this._resolve([]);
+ return;
+ }
+ this._init$(void 0, -2);
+ var isArrayResolved = isArray(this._values);
+ this._holes = isArrayResolved ? this._values.length - this.length() : 0;
+
+ if (!this._isResolved() &&
+ isArrayResolved &&
+ this._howMany > this._canPossiblyFulfill()) {
+ var message = "(Promise.some) input array contains less than " +
+ this._howMany + " promises";
+ this._reject(new RangeError(message));
+ }
+};
+
+SomePromiseArray.prototype.init = function SomePromiseArray$init() {
+ this._initialized = true;
+ this._init();
+};
+
+SomePromiseArray.prototype.setUnwrap = function SomePromiseArray$setUnwrap() {
+ this._unwrap = true;
+};
+
+SomePromiseArray.prototype.howMany = function SomePromiseArray$howMany() {
+ return this._howMany;
+};
+
+SomePromiseArray.prototype.setHowMany =
+function SomePromiseArray$setHowMany(count) {
+ if (this._isResolved()) return;
+ this._howMany = count;
+};
+
+SomePromiseArray.prototype._promiseFulfilled =
+function SomePromiseArray$_promiseFulfilled(value) {
+ if (this._isResolved()) return;
+ this._addFulfilled(value);
+ if (this._fulfilled() === this.howMany()) {
+ this._values.length = this.howMany();
+ if (this.howMany() === 1 && this._unwrap) {
+ this._resolve(this._values[0]);
+ }
+ else {
+ this._resolve(this._values);
+ }
+ }
+
+};
+SomePromiseArray.prototype._promiseRejected =
+function SomePromiseArray$_promiseRejected(reason) {
+ if (this._isResolved()) return;
+ this._addRejected(reason);
+ if (this.howMany() > this._canPossiblyFulfill()) {
+ if (this._values.length === this.length()) {
+ this._reject([]);
+ }
+ else {
+ this._reject(this._values.slice(this.length() + this._holes));
+ }
+ }
+};
+
+SomePromiseArray.prototype._fulfilled = function SomePromiseArray$_fulfilled() {
+ return this._totalResolved;
+};
+
+SomePromiseArray.prototype._rejected = function SomePromiseArray$_rejected() {
+ return this._values.length - this.length() - this._holes;
+};
+
+SomePromiseArray.prototype._addRejected =
+function SomePromiseArray$_addRejected(reason) {
+ this._values.push(reason);
+};
+
+SomePromiseArray.prototype._addFulfilled =
+function SomePromiseArray$_addFulfilled(value) {
+ this._values[this._totalResolved++] = value;
+};
+
+SomePromiseArray.prototype._canPossiblyFulfill =
+function SomePromiseArray$_canPossiblyFulfill() {
+ return this.length() - this._rejected();
+};
+
+return SomePromiseArray;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/synchronous_inspection.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/synchronous_inspection.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/synchronous_inspection.js
new file mode 100644
index 0000000..dcbdc90
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/synchronous_inspection.js
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+ var PromiseInspection = require("./promise_inspection.js");
+
+ Promise.prototype.inspect = function Promise$inspect() {
+ return new PromiseInspection(this);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/thenables.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/thenables.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/thenables.js
new file mode 100644
index 0000000..510da18
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/thenables.js
@@ -0,0 +1,138 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+ var util = require("./util.js");
+ var canAttach = require("./errors.js").canAttach;
+ var errorObj = util.errorObj;
+ var isObject = util.isObject;
+
+ function getThen(obj) {
+ try {
+ return obj.then;
+ }
+ catch(e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+ }
+
+ function Promise$_Cast(obj, caller, originalPromise) {
+ if (isObject(obj)) {
+ if (obj instanceof Promise) {
+ return obj;
+ }
+ else if (isAnyBluebirdPromise(obj)) {
+ var ret = new Promise(INTERNAL);
+ ret._setTrace(caller, void 0);
+ obj._then(
+ ret._fulfillUnchecked,
+ ret._rejectUncheckedCheckError,
+ ret._progressUnchecked,
+ ret,
+ null,
+ void 0
+ );
+ ret._setFollowing();
+ return ret;
+ }
+ var then = getThen(obj);
+ if (then === errorObj) {
+ caller = typeof caller === "function" ? caller : Promise$_Cast;
+ if (originalPromise !== void 0 && canAttach(then.e)) {
+ originalPromise._attachExtraTrace(then.e);
+ }
+ return Promise.reject(then.e, caller);
+ }
+ else if (typeof then === "function") {
+ caller = typeof caller === "function" ? caller : Promise$_Cast;
+ return Promise$_doThenable(obj, then, caller, originalPromise);
+ }
+ }
+ return obj;
+ }
+
+ var hasProp = {}.hasOwnProperty;
+ function isAnyBluebirdPromise(obj) {
+ return hasProp.call(obj, "_promise0");
+ }
+
+ function Promise$_doThenable(x, then, caller, originalPromise) {
+ var resolver = Promise.defer(caller);
+ var called = false;
+ try {
+ then.call(
+ x,
+ Promise$_resolveFromThenable,
+ Promise$_rejectFromThenable,
+ Promise$_progressFromThenable
+ );
+ }
+ catch(e) {
+ if (!called) {
+ called = true;
+ var trace = canAttach(e) ? e : new Error(e + "");
+ if (originalPromise !== void 0) {
+ originalPromise._attachExtraTrace(trace);
+ }
+ resolver.promise._reject(e, trace);
+ }
+ }
+ return resolver.promise;
+
+ function Promise$_resolveFromThenable(y) {
+ if (called) return;
+ called = true;
+
+ if (x === y) {
+ var e = Promise._makeSelfResolutionError();
+ if (originalPromise !== void 0) {
+ originalPromise._attachExtraTrace(e);
+ }
+ resolver.promise._reject(e, void 0);
+ return;
+ }
+ resolver.resolve(y);
+ }
+
+ function Promise$_rejectFromThenable(r) {
+ if (called) return;
+ called = true;
+ var trace = canAttach(r) ? r : new Error(r + "");
+ if (originalPromise !== void 0) {
+ originalPromise._attachExtraTrace(trace);
+ }
+ resolver.promise._reject(r, trace);
+ }
+
+ function Promise$_progressFromThenable(v) {
+ if (called) return;
+ var promise = resolver.promise;
+ if (typeof promise._progress === "function") {
+ promise._progress(v);
+ }
+ }
+ }
+
+ Promise._cast = Promise$_Cast;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/timers.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/timers.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/timers.js
new file mode 100644
index 0000000..8edcac2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/timers.js
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+
+var global = require("./global.js");
+var setTimeout = function(fn, time) {
+ var $_len = arguments.length;var args = new Array($_len - 2); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];}
+ global.setTimeout(function() {
+ fn.apply(void 0, args);
+ }, time);
+};
+
+var pass = {};
+global.setTimeout( function(_) {
+ if(_ === pass) {
+ setTimeout = global.setTimeout;
+ }
+}, 1, pass);
+
+module.exports = function(Promise, INTERNAL) {
+ var util = require("./util.js");
+ var errors = require("./errors.js");
+ var apiRejection = require("./errors_api_rejection")(Promise);
+ var TimeoutError = Promise.TimeoutError;
+
+ var afterTimeout = function Promise$_afterTimeout(promise, message, ms) {
+ if (!promise.isPending()) return;
+ if (typeof message !== "string") {
+ message = "operation timed out after" + " " + ms + " ms"
+ }
+ var err = new TimeoutError(message);
+ errors.markAsOriginatingFromRejection(err);
+ promise._attachExtraTrace(err);
+ promise._rejectUnchecked(err);
+ };
+
+ var afterDelay = function Promise$_afterDelay(value, promise) {
+ promise._fulfill(value);
+ };
+
+ Promise.delay = function Promise$Delay(value, ms, caller) {
+ if (ms === void 0) {
+ ms = value;
+ value = void 0;
+ }
+ ms = +ms;
+ if (typeof caller !== "function") {
+ caller = Promise.delay;
+ }
+ var maybePromise = Promise._cast(value, caller, void 0);
+ var promise = new Promise(INTERNAL);
+
+ if (Promise.is(maybePromise)) {
+ if (maybePromise._isBound()) {
+ promise._setBoundTo(maybePromise._boundTo);
+ }
+ if (maybePromise._cancellable()) {
+ promise._setCancellable();
+ promise._cancellationParent = maybePromise;
+ }
+ promise._setTrace(caller, maybePromise);
+ promise._follow(maybePromise);
+ return promise.then(function(value) {
+ return Promise.delay(value, ms);
+ });
+ }
+ else {
+ promise._setTrace(caller, void 0);
+ setTimeout(afterDelay, ms, value, promise);
+ }
+ return promise;
+ };
+
+ Promise.prototype.delay = function Promise$delay(ms) {
+ return Promise.delay(this, ms, this.delay);
+ };
+
+ Promise.prototype.timeout = function Promise$timeout(ms, message) {
+ ms = +ms;
+
+ var ret = new Promise(INTERNAL);
+ ret._setTrace(this.timeout, this);
+
+ if (this._isBound()) ret._setBoundTo(this._boundTo);
+ if (this._cancellable()) {
+ ret._setCancellable();
+ ret._cancellationParent = this;
+ }
+ ret._follow(this);
+ setTimeout(afterTimeout, ms, ret, message, ms);
+ return ret;
+ };
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/util.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/util.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/util.js
new file mode 100644
index 0000000..fbd34e9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/util.js
@@ -0,0 +1,193 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var global = require("./global.js");
+var es5 = require("./es5.js");
+var haveGetters = (function(){
+ try {
+ var o = {};
+ es5.defineProperty(o, "f", {
+ get: function () {
+ return 3;
+ }
+ });
+ return o.f === 3;
+ }
+ catch (e) {
+ return false;
+ }
+
+})();
+
+var canEvaluate = (function() {
+ if (typeof window !== "undefined" && window !== null &&
+ typeof window.document !== "undefined" &&
+ typeof navigator !== "undefined" && navigator !== null &&
+ typeof navigator.appName === "string" &&
+ window === global) {
+ return false;
+ }
+ return true;
+})();
+
+function deprecated(msg) {
+ if (typeof console !== "undefined" && console !== null &&
+ typeof console.warn === "function") {
+ console.warn("Bluebird: " + msg);
+ }
+}
+
+var errorObj = {e: {}};
+function tryCatch1(fn, receiver, arg) {
+ try {
+ return fn.call(receiver, arg);
+ }
+ catch (e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+}
+
+function tryCatch2(fn, receiver, arg, arg2) {
+ try {
+ return fn.call(receiver, arg, arg2);
+ }
+ catch (e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+}
+
+function tryCatchApply(fn, args, receiver) {
+ try {
+ return fn.apply(receiver, args);
+ }
+ catch (e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+}
+
+var inherits = function(Child, Parent) {
+ var hasProp = {}.hasOwnProperty;
+
+ function T() {
+ this.constructor = Child;
+ this.constructor$ = Parent;
+ for (var propertyName in Parent.prototype) {
+ if (hasProp.call(Parent.prototype, propertyName) &&
+ propertyName.charAt(propertyName.length-1) !== "$"
+ ) {
+ this[propertyName + "$"] = Parent.prototype[propertyName];
+ }
+ }
+ }
+ T.prototype = Parent.prototype;
+ Child.prototype = new T();
+ return Child.prototype;
+};
+
+function asString(val) {
+ return typeof val === "string" ? val : ("" + val);
+}
+
+function isPrimitive(val) {
+ return val == null || val === true || val === false ||
+ typeof val === "string" || typeof val === "number";
+
+}
+
+function isObject(value) {
+ return !isPrimitive(value);
+}
+
+function maybeWrapAsError(maybeError) {
+ if (!isPrimitive(maybeError)) return maybeError;
+
+ return new Error(asString(maybeError));
+}
+
+function withAppended(target, appendee) {
+ var len = target.length;
+ var ret = new Array(len + 1);
+ var i;
+ for (i = 0; i < len; ++i) {
+ ret[i] = target[i];
+ }
+ ret[i] = appendee;
+ return ret;
+}
+
+
+function notEnumerableProp(obj, name, value) {
+ if (isPrimitive(obj)) return obj;
+ var descriptor = {
+ value: value,
+ configurable: true,
+ enumerable: false,
+ writable: true
+ };
+ es5.defineProperty(obj, name, descriptor);
+ return obj;
+}
+
+
+var wrapsPrimitiveReceiver = (function() {
+ return this !== "string";
+}).call("string");
+
+function thrower(r) {
+ throw r;
+}
+
+
+function toFastProperties(obj) {
+ /*jshint -W027*/
+ function f() {}
+ f.prototype = obj;
+ return f;
+ eval(obj);
+}
+
+var ret = {
+ thrower: thrower,
+ isArray: es5.isArray,
+ haveGetters: haveGetters,
+ notEnumerableProp: notEnumerableProp,
+ isPrimitive: isPrimitive,
+ isObject: isObject,
+ canEvaluate: canEvaluate,
+ deprecated: deprecated,
+ errorObj: errorObj,
+ tryCatch1: tryCatch1,
+ tryCatch2: tryCatch2,
+ tryCatchApply: tryCatchApply,
+ inherits: inherits,
+ withAppended: withAppended,
+ asString: asString,
+ maybeWrapAsError: maybeWrapAsError,
+ wrapsPrimitiveReceiver: wrapsPrimitiveReceiver,
+ toFastProperties: toFastProperties
+};
+
+module.exports = ret;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/package.json
new file mode 100644
index 0000000..5980304
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/package.json
@@ -0,0 +1,85 @@
+{
+ "name": "bluebird",
+ "description": "Full featured Promises/A+ implementation with exceptionally good performance",
+ "version": "1.1.1",
+ "keywords": [
+ "promise",
+ "performance",
+ "promises",
+ "promises-a",
+ "promises-aplus",
+ "async",
+ "await",
+ "deferred",
+ "deferreds",
+ "future",
+ "flow control",
+ "dsl",
+ "fluent interface"
+ ],
+ "scripts": {
+ "test": "grunt test"
+ },
+ "homepage": "https://github.com/petkaantonov/bluebird",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/petkaantonov/bluebird.git"
+ },
+ "bugs": {
+ "url": "http://github.com/petkaantonov/bluebird/issues"
+ },
+ "license": "MIT",
+ "author": {
+ "name": "Petka Antonov",
+ "email": "petka_antonov@hotmail.com",
+ "url": "http://github.com/petkaantonov/"
+ },
+ "devDependencies": {
+ "grunt": "~0.4.1",
+ "grunt-contrib-jshint": "~0.6.4",
+ "grunt-contrib-watch": "latest",
+ "grunt-contrib-connect": "latest",
+ "grunt-saucelabs": "latest",
+ "acorn": "~0.3.1",
+ "mocha": "~1.12.1",
+ "q": "~0.9.7",
+ "when": "~2.4.0",
+ "deferred": "~0.6.5",
+ "rsvp": "~2.0.4",
+ "avow": "~2.0.1",
+ "jsdom": "~0.8.4",
+ "jquery-browserify": "~1.8.1",
+ "sinon": "~1.7.3",
+ "kew": "~0.2.2",
+ "browserify": "~2.35.0",
+ "concurrent": "~0.3.2",
+ "text-table": "~0.2.0",
+ "grunt-cli": "~0.1.9",
+ "jshint-stylish": "~0.1.3",
+ "semver-utils": "~1.1.0",
+ "rimraf": "~2.2.6",
+ "mkdirp": "~0.3.5"
+ },
+ "main": "./js/main/bluebird.js",
+ "_id": "bluebird@1.1.1",
+ "dist": {
+ "shasum": "744e9980145e2ebc41a9e34826f913096667fb33",
+ "tarball": "http://registry.npmjs.org/bluebird/-/bluebird-1.1.1.tgz"
+ },
+ "_from": "bluebird@~1.1.0",
+ "_npmVersion": "1.4.3",
+ "_npmUser": {
+ "name": "esailija",
+ "email": "petka_antonov@hotmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "esailija",
+ "email": "petka_antonov@hotmail.com"
+ }
+ ],
+ "directories": {},
+ "_shasum": "744e9980145e2ebc41a9e34826f913096667fb33",
+ "_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-1.1.1.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/zalgo.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/zalgo.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/zalgo.js
new file mode 100644
index 0000000..1357352
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/zalgo.js
@@ -0,0 +1 @@
+module.exports = require('./js/zalgo/bluebird.js');
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/History.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/History.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/History.md
new file mode 100644
index 0000000..3a69559
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/History.md
@@ -0,0 +1,239 @@
+
+2.7.1 / 2015-03-11
+==================
+
+ * Revert #347 (fix collisions when option and first arg have same name) which causes a bug in #367.
+
+2.7.0 / 2015-03-09
+==================
+
+ * Fix git-style bug when installed globally. Close #335 #349 @zhiyelee
+ * Fix collisions when option and first arg have same name. Close #346 #347 @tonylukasavage
+ * Add support for camelCase on `opts()`. Close #353 @nkzawa
+ * Add node.js 0.12 and io.js to travis.yml
+ * Allow RegEx options. #337 @palanik
+ * Fixes exit code when sub-command failing. Close #260 #332 @pirelenito
+ * git-style `bin` files in $PATH make sense. Close #196 #327 @zhiyelee
+
+2.6.0 / 2014-12-30
+==================
+
+ * added `Command#allowUnknownOption` method. Close #138 #318 @doozr @zhiyelee
+ * Add application description to the help msg. Close #112 @dalssoft
+
+2.5.1 / 2014-12-15
+==================
+
+ * fixed two bugs incurred by variadic arguments. Close #291 @Quentin01 #302 @zhiyelee
+
+2.5.0 / 2014-10-24
+==================
+
+ * add support for variadic arguments. Closes #277 @whitlockjc
+
+2.4.0 / 2014-10-17
+==================
+
+ * fixed a bug on executing the coercion function of subcommands option. Closes #270
+ * added `Command.prototype.name` to retrieve command name. Closes #264 #266 @tonylukasavage
+ * added `Command.prototype.opts` to retrieve all the options as a simple object of key-value pairs. Closes #262 @tonylukasavage
+ * fixed a bug on subcommand name. Closes #248 @jonathandelgado
+ * fixed function normalize doesn’t honor option terminator. Closes #216 @abbr
+
+2.3.0 / 2014-07-16
+==================
+
+ * add command alias'. Closes PR #210
+ * fix: Typos. Closes #99
+ * fix: Unused fs module. Closes #217
+
+2.2.0 / 2014-03-29
+==================
+
+ * add passing of previous option value
+ * fix: support subcommands on windows. Closes #142
+ * Now the defaultValue passed as the second argument of the coercion function.
+
+2.1.0 / 2013-11-21
+==================
+
+ * add: allow cflag style option params, unit test, fixes #174
+
+2.0.0 / 2013-07-18
+==================
+
+ * remove input methods (.prompt, .confirm, etc)
+
+1.3.2 / 2013-07-18
+==================
+
+ * add support for sub-commands to co-exist with the original command
+
+1.3.1 / 2013-07-18
+==================
+
+ * add quick .runningCommand hack so you can opt-out of other logic when running a sub command
+
+1.3.0 / 2013-07-09
+==================
+
+ * add EACCES error handling
+ * fix sub-command --help
+
+1.2.0 / 2013-06-13
+==================
+
+ * allow "-" hyphen as an option argument
+ * support for RegExp coercion
+
+1.1.1 / 2012-11-20
+==================
+
+ * add more sub-command padding
+ * fix .usage() when args are present. Closes #106
+
+1.1.0 / 2012-11-16
+==================
+
+ * add git-style executable subcommand support. Closes #94
+
+1.0.5 / 2012-10-09
+==================
+
+ * fix `--name` clobbering. Closes #92
+ * fix examples/help. Closes #89
+
+1.0.4 / 2012-09-03
+==================
+
+ * add `outputHelp()` method.
+
+1.0.3 / 2012-08-30
+==================
+
+ * remove invalid .version() defaulting
+
+1.0.2 / 2012-08-24
+==================
+
+ * add `--foo=bar` support [arv]
+ * fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus]
+
+1.0.1 / 2012-08-03
+==================
+
+ * fix issue #56
+ * fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode())
+
+1.0.0 / 2012-07-05
+==================
+
+ * add support for optional option descriptions
+ * add defaulting of `.version()` to package.json's version
+
+0.6.1 / 2012-06-01
+==================
+
+ * Added: append (yes or no) on confirmation
+ * Added: allow node.js v0.7.x
+
+0.6.0 / 2012-04-10
+==================
+
+ * Added `.prompt(obj, callback)` support. Closes #49
+ * Added default support to .choose(). Closes #41
+ * Fixed the choice example
+
+0.5.1 / 2011-12-20
+==================
+
+ * Fixed `password()` for recent nodes. Closes #36
+
+0.5.0 / 2011-12-04
+==================
+
+ * Added sub-command option support [itay]
+
+0.4.3 / 2011-12-04
+==================
+
+ * Fixed custom help ordering. Closes #32
+
+0.4.2 / 2011-11-24
+==================
+
+ * Added travis support
+ * Fixed: line-buffered input automatically trimmed. Closes #31
+
+0.4.1 / 2011-11-18
+==================
+
+ * Removed listening for "close" on --help
+
+0.4.0 / 2011-11-15
+==================
+
+ * Added support for `--`. Closes #24
+
+0.3.3 / 2011-11-14
+==================
+
+ * Fixed: wait for close event when writing help info [Jerry Hamlet]
+
+0.3.2 / 2011-11-01
+==================
+
+ * Fixed long flag definitions with values [felixge]
+
+0.3.1 / 2011-10-31
+==================
+
+ * Changed `--version` short flag to `-V` from `-v`
+ * Changed `.version()` so it's configurable [felixge]
+
+0.3.0 / 2011-10-31
+==================
+
+ * Added support for long flags only. Closes #18
+
+0.2.1 / 2011-10-24
+==================
+
+ * "node": ">= 0.4.x < 0.7.0". Closes #20
+
+0.2.0 / 2011-09-26
+==================
+
+ * Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs]
+
+0.1.0 / 2011-08-24
+==================
+
+ * Added support for custom `--help` output
+
+0.0.5 / 2011-08-18
+==================
+
+ * Changed: when the user enters nothing prompt for password again
+ * Fixed issue with passwords beginning with numbers [NuckChorris]
+
+0.0.4 / 2011-08-15
+==================
+
+ * Fixed `Commander#args`
+
+0.0.3 / 2011-08-15
+==================
+
+ * Added default option value support
+
+0.0.2 / 2011-08-15
+==================
+
+ * Added mask support to `Command#password(str[, mask], fn)`
+ * Added `Command#password(str, fn)`
+
+0.0.1 / 2010-01-03
+==================
+
+ * Initial release
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/LICENSE b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/LICENSE
new file mode 100644
index 0000000..10f997a
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/commander/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2011 TJ Holowaychuk <tj...@vision-media.ca>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[42/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/parse-js.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/parse-js.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/parse-js.js
new file mode 100644
index 0000000..9f90dfe
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/parse-js.js
@@ -0,0 +1,1319 @@
+/***********************************************************************
+
+ A JavaScript tokenizer / parser / beautifier / compressor.
+
+ This version is suitable for Node.js. With minimal changes (the
+ exports stuff) it should work on any JS platform.
+
+ This file contains the tokenizer/parser. It is a port to JavaScript
+ of parse-js [1], a JavaScript parser library written in Common Lisp
+ by Marijn Haverbeke. Thank you Marijn!
+
+ [1] http://marijn.haverbeke.nl/parse-js/
+
+ Exported functions:
+
+ - tokenizer(code) -- returns a function. Call the returned
+ function to fetch the next token.
+
+ - parse(code) -- returns an AST of the given JavaScript code.
+
+ -------------------------------- (C) ---------------------------------
+
+ Author: Mihai Bazon
+ <mi...@gmail.com>
+ http://mihai.bazon.net/blog
+
+ Distributed under the BSD license:
+
+ Copyright 2010 (c) Mihai Bazon <mi...@gmail.com>
+ Based on parse-js (http://marijn.haverbeke.nl/parse-js/).
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ * Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the following
+ disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials
+ provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ ***********************************************************************/
+
+/* -----[ Tokenizer (constants) ]----- */
+
+var KEYWORDS = array_to_hash([
+ "break",
+ "case",
+ "catch",
+ "const",
+ "continue",
+ "default",
+ "delete",
+ "do",
+ "else",
+ "finally",
+ "for",
+ "function",
+ "if",
+ "in",
+ "instanceof",
+ "new",
+ "return",
+ "switch",
+ "throw",
+ "try",
+ "typeof",
+ "var",
+ "void",
+ "while",
+ "with"
+]);
+
+var RESERVED_WORDS = array_to_hash([
+ "abstract",
+ "boolean",
+ "byte",
+ "char",
+ "class",
+ "debugger",
+ "double",
+ "enum",
+ "export",
+ "extends",
+ "final",
+ "float",
+ "goto",
+ "implements",
+ "import",
+ "int",
+ "interface",
+ "long",
+ "native",
+ "package",
+ "private",
+ "protected",
+ "public",
+ "short",
+ "static",
+ "super",
+ "synchronized",
+ "throws",
+ "transient",
+ "volatile"
+]);
+
+var KEYWORDS_BEFORE_EXPRESSION = array_to_hash([
+ "return",
+ "new",
+ "delete",
+ "throw",
+ "else",
+ "case"
+]);
+
+var KEYWORDS_ATOM = array_to_hash([
+ "false",
+ "null",
+ "true",
+ "undefined"
+]);
+
+var OPERATOR_CHARS = array_to_hash(characters("+-*&%=<>!?|~^"));
+
+var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
+var RE_OCT_NUMBER = /^0[0-7]+$/;
+var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
+
+var OPERATORS = array_to_hash([
+ "in",
+ "instanceof",
+ "typeof",
+ "new",
+ "void",
+ "delete",
+ "++",
+ "--",
+ "+",
+ "-",
+ "!",
+ "~",
+ "&",
+ "|",
+ "^",
+ "*",
+ "/",
+ "%",
+ ">>",
+ "<<",
+ ">>>",
+ "<",
+ ">",
+ "<=",
+ ">=",
+ "==",
+ "===",
+ "!=",
+ "!==",
+ "?",
+ "=",
+ "+=",
+ "-=",
+ "/=",
+ "*=",
+ "%=",
+ ">>=",
+ "<<=",
+ ">>>=",
+ "|=",
+ "^=",
+ "&=",
+ "&&",
+ "||"
+]);
+
+var WHITESPACE_CHARS = array_to_hash(characters(" \n\r\t\u200b"));
+
+var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:"));
+
+var PUNC_CHARS = array_to_hash(characters("[]{}(),;:"));
+
+var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy"));
+
+/* -----[ Tokenizer ]----- */
+
+// regexps adapted from http://xregexp.com/plugins/#unicode
+var UNICODE = {
+ letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\
u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105
A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC
6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\u
AA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),
+ non_spacing_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u
0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\
uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),
+ space_combining_mark: new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u
1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"),
+ connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")
+};
+
+function is_letter(ch) {
+ return UNICODE.letter.test(ch);
+};
+
+function is_digit(ch) {
+ ch = ch.charCodeAt(0);
+ return ch >= 48 && ch <= 57; //XXX: find out if "UnicodeDigit" means something else than 0..9
+};
+
+function is_alphanumeric_char(ch) {
+ return is_digit(ch) || is_letter(ch);
+};
+
+function is_unicode_combining_mark(ch) {
+ return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch);
+};
+
+function is_unicode_connector_punctuation(ch) {
+ return UNICODE.connector_punctuation.test(ch);
+};
+
+function is_identifier_start(ch) {
+ return ch == "$" || ch == "_" || is_letter(ch);
+};
+
+function is_identifier_char(ch) {
+ return is_identifier_start(ch)
+ || is_unicode_combining_mark(ch)
+ || is_digit(ch)
+ || is_unicode_connector_punctuation(ch)
+ || ch == "\u200c" // zero-width non-joiner <ZWNJ>
+ || ch == "\u200d" // zero-width joiner <ZWJ> (in my ECMA-262 PDF, this is also 200c)
+ ;
+};
+
+function parse_js_number(num) {
+ if (RE_HEX_NUMBER.test(num)) {
+ return parseInt(num.substr(2), 16);
+ } else if (RE_OCT_NUMBER.test(num)) {
+ return parseInt(num.substr(1), 8);
+ } else if (RE_DEC_NUMBER.test(num)) {
+ return parseFloat(num);
+ }
+};
+
+function JS_Parse_Error(message, line, col, pos) {
+ this.message = message;
+ this.line = line;
+ this.col = col;
+ this.pos = pos;
+ try {
+ ({})();
+ } catch(ex) {
+ this.stack = ex.stack;
+ };
+};
+
+JS_Parse_Error.prototype.toString = function() {
+ return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack;
+};
+
+function js_error(message, line, col, pos) {
+ throw new JS_Parse_Error(message, line, col, pos);
+};
+
+function is_token(token, type, val) {
+ return token.type == type && (val == null || token.value == val);
+};
+
+var EX_EOF = {};
+
+function tokenizer($TEXT) {
+
+ var S = {
+ text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''),
+ pos : 0,
+ tokpos : 0,
+ line : 0,
+ tokline : 0,
+ col : 0,
+ tokcol : 0,
+ newline_before : false,
+ regex_allowed : false,
+ comments_before : []
+ };
+
+ function peek() { return S.text.charAt(S.pos); };
+
+ function next(signal_eof) {
+ var ch = S.text.charAt(S.pos++);
+ if (signal_eof && !ch)
+ throw EX_EOF;
+ if (ch == "\n") {
+ S.newline_before = true;
+ ++S.line;
+ S.col = 0;
+ } else {
+ ++S.col;
+ }
+ return ch;
+ };
+
+ function eof() {
+ return !S.peek();
+ };
+
+ function find(what, signal_eof) {
+ var pos = S.text.indexOf(what, S.pos);
+ if (signal_eof && pos == -1) throw EX_EOF;
+ return pos;
+ };
+
+ function start_token() {
+ S.tokline = S.line;
+ S.tokcol = S.col;
+ S.tokpos = S.pos;
+ };
+
+ function token(type, value, is_comment) {
+ S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) ||
+ (type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) ||
+ (type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value)));
+ var ret = {
+ type : type,
+ value : value,
+ line : S.tokline,
+ col : S.tokcol,
+ pos : S.tokpos,
+ nlb : S.newline_before
+ };
+ if (!is_comment) {
+ ret.comments_before = S.comments_before;
+ S.comments_before = [];
+ }
+ S.newline_before = false;
+ return ret;
+ };
+
+ function skip_whitespace() {
+ while (HOP(WHITESPACE_CHARS, peek()))
+ next();
+ };
+
+ function read_while(pred) {
+ var ret = "", ch = peek(), i = 0;
+ while (ch && pred(ch, i++)) {
+ ret += next();
+ ch = peek();
+ }
+ return ret;
+ };
+
+ function parse_error(err) {
+ js_error(err, S.tokline, S.tokcol, S.tokpos);
+ };
+
+ function read_num(prefix) {
+ var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".";
+ var num = read_while(function(ch, i){
+ if (ch == "x" || ch == "X") {
+ if (has_x) return false;
+ return has_x = true;
+ }
+ if (!has_x && (ch == "E" || ch == "e")) {
+ if (has_e) return false;
+ return has_e = after_e = true;
+ }
+ if (ch == "-") {
+ if (after_e || (i == 0 && !prefix)) return true;
+ return false;
+ }
+ if (ch == "+") return after_e;
+ after_e = false;
+ if (ch == ".") {
+ if (!has_dot && !has_x)
+ return has_dot = true;
+ return false;
+ }
+ return is_alphanumeric_char(ch);
+ });
+ if (prefix)
+ num = prefix + num;
+ var valid = parse_js_number(num);
+ if (!isNaN(valid)) {
+ return token("num", valid);
+ } else {
+ parse_error("Invalid syntax: " + num);
+ }
+ };
+
+ function read_escaped_char() {
+ var ch = next(true);
+ switch (ch) {
+ case "n" : return "\n";
+ case "r" : return "\r";
+ case "t" : return "\t";
+ case "b" : return "\b";
+ case "v" : return "\v";
+ case "f" : return "\f";
+ case "0" : return "\0";
+ case "x" : return String.fromCharCode(hex_bytes(2));
+ case "u" : return String.fromCharCode(hex_bytes(4));
+ default : return ch;
+ }
+ };
+
+ function hex_bytes(n) {
+ var num = 0;
+ for (; n > 0; --n) {
+ var digit = parseInt(next(true), 16);
+ if (isNaN(digit))
+ parse_error("Invalid hex-character pattern in string");
+ num = (num << 4) | digit;
+ }
+ return num;
+ };
+
+ function read_string() {
+ return with_eof_error("Unterminated string constant", function(){
+ var quote = next(), ret = "";
+ for (;;) {
+ var ch = next(true);
+ if (ch == "\\") ch = read_escaped_char();
+ else if (ch == quote) break;
+ ret += ch;
+ }
+ return token("string", ret);
+ });
+ };
+
+ function read_line_comment() {
+ next();
+ var i = find("\n"), ret;
+ if (i == -1) {
+ ret = S.text.substr(S.pos);
+ S.pos = S.text.length;
+ } else {
+ ret = S.text.substring(S.pos, i);
+ S.pos = i;
+ }
+ return token("comment1", ret, true);
+ };
+
+ function read_multiline_comment() {
+ next();
+ return with_eof_error("Unterminated multiline comment", function(){
+ var i = find("*/", true),
+ text = S.text.substring(S.pos, i),
+ tok = token("comment2", text, true);
+ S.pos = i + 2;
+ S.line += text.split("\n").length - 1;
+ S.newline_before = text.indexOf("\n") >= 0;
+
+ // https://github.com/mishoo/UglifyJS/issues/#issue/100
+ if (/^@cc_on/i.test(text)) {
+ warn("WARNING: at line " + S.line);
+ warn("*** Found \"conditional comment\": " + text);
+ warn("*** UglifyJS DISCARDS ALL COMMENTS. This means your code might no longer work properly in Internet Explorer.");
+ }
+
+ return tok;
+ });
+ };
+
+ function read_name() {
+ var backslash = false, name = "", ch;
+ while ((ch = peek()) != null) {
+ if (!backslash) {
+ if (ch == "\\") backslash = true, next();
+ else if (is_identifier_char(ch)) name += next();
+ else break;
+ }
+ else {
+ if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX");
+ ch = read_escaped_char();
+ if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier");
+ name += ch;
+ backslash = false;
+ }
+ }
+ return name;
+ };
+
+ function read_regexp() {
+ return with_eof_error("Unterminated regular expression", function(){
+ var prev_backslash = false, regexp = "", ch, in_class = false;
+ while ((ch = next(true))) if (prev_backslash) {
+ regexp += "\\" + ch;
+ prev_backslash = false;
+ } else if (ch == "[") {
+ in_class = true;
+ regexp += ch;
+ } else if (ch == "]" && in_class) {
+ in_class = false;
+ regexp += ch;
+ } else if (ch == "/" && !in_class) {
+ break;
+ } else if (ch == "\\") {
+ prev_backslash = true;
+ } else {
+ regexp += ch;
+ }
+ var mods = read_name();
+ return token("regexp", [ regexp, mods ]);
+ });
+ };
+
+ function read_operator(prefix) {
+ function grow(op) {
+ if (!peek()) return op;
+ var bigger = op + peek();
+ if (HOP(OPERATORS, bigger)) {
+ next();
+ return grow(bigger);
+ } else {
+ return op;
+ }
+ };
+ return token("operator", grow(prefix || next()));
+ };
+
+ function handle_slash() {
+ next();
+ var regex_allowed = S.regex_allowed;
+ switch (peek()) {
+ case "/":
+ S.comments_before.push(read_line_comment());
+ S.regex_allowed = regex_allowed;
+ return next_token();
+ case "*":
+ S.comments_before.push(read_multiline_comment());
+ S.regex_allowed = regex_allowed;
+ return next_token();
+ }
+ return S.regex_allowed ? read_regexp() : read_operator("/");
+ };
+
+ function handle_dot() {
+ next();
+ return is_digit(peek())
+ ? read_num(".")
+ : token("punc", ".");
+ };
+
+ function read_word() {
+ var word = read_name();
+ return !HOP(KEYWORDS, word)
+ ? token("name", word)
+ : HOP(OPERATORS, word)
+ ? token("operator", word)
+ : HOP(KEYWORDS_ATOM, word)
+ ? token("atom", word)
+ : token("keyword", word);
+ };
+
+ function with_eof_error(eof_error, cont) {
+ try {
+ return cont();
+ } catch(ex) {
+ if (ex === EX_EOF) parse_error(eof_error);
+ else throw ex;
+ }
+ };
+
+ function next_token(force_regexp) {
+ if (force_regexp)
+ return read_regexp();
+ skip_whitespace();
+ start_token();
+ var ch = peek();
+ if (!ch) return token("eof");
+ if (is_digit(ch)) return read_num();
+ if (ch == '"' || ch == "'") return read_string();
+ if (HOP(PUNC_CHARS, ch)) return token("punc", next());
+ if (ch == ".") return handle_dot();
+ if (ch == "/") return handle_slash();
+ if (HOP(OPERATOR_CHARS, ch)) return read_operator();
+ if (ch == "\\" || is_identifier_start(ch)) return read_word();
+ parse_error("Unexpected character '" + ch + "'");
+ };
+
+ next_token.context = function(nc) {
+ if (nc) S = nc;
+ return S;
+ };
+
+ return next_token;
+
+};
+
+/* -----[ Parser (constants) ]----- */
+
+var UNARY_PREFIX = array_to_hash([
+ "typeof",
+ "void",
+ "delete",
+ "--",
+ "++",
+ "!",
+ "~",
+ "-",
+ "+"
+]);
+
+var UNARY_POSTFIX = array_to_hash([ "--", "++" ]);
+
+var ASSIGNMENT = (function(a, ret, i){
+ while (i < a.length) {
+ ret[a[i]] = a[i].substr(0, a[i].length - 1);
+ i++;
+ }
+ return ret;
+})(
+ ["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&="],
+ { "=": true },
+ 0
+);
+
+var PRECEDENCE = (function(a, ret){
+ for (var i = 0, n = 1; i < a.length; ++i, ++n) {
+ var b = a[i];
+ for (var j = 0; j < b.length; ++j) {
+ ret[b[j]] = n;
+ }
+ }
+ return ret;
+})(
+ [
+ ["||"],
+ ["&&"],
+ ["|"],
+ ["^"],
+ ["&"],
+ ["==", "===", "!=", "!=="],
+ ["<", ">", "<=", ">=", "in", "instanceof"],
+ [">>", "<<", ">>>"],
+ ["+", "-"],
+ ["*", "/", "%"]
+ ],
+ {}
+);
+
+var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]);
+
+var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]);
+
+/* -----[ Parser ]----- */
+
+function NodeWithToken(str, start, end) {
+ this.name = str;
+ this.start = start;
+ this.end = end;
+};
+
+NodeWithToken.prototype.toString = function() { return this.name; };
+
+function parse($TEXT, exigent_mode, embed_tokens) {
+
+ var S = {
+ input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT,
+ token : null,
+ prev : null,
+ peeked : null,
+ in_function : 0,
+ in_loop : 0,
+ labels : []
+ };
+
+ S.token = next();
+
+ function is(type, value) {
+ return is_token(S.token, type, value);
+ };
+
+ function peek() { return S.peeked || (S.peeked = S.input()); };
+
+ function next() {
+ S.prev = S.token;
+ if (S.peeked) {
+ S.token = S.peeked;
+ S.peeked = null;
+ } else {
+ S.token = S.input();
+ }
+ return S.token;
+ };
+
+ function prev() {
+ return S.prev;
+ };
+
+ function croak(msg, line, col, pos) {
+ var ctx = S.input.context();
+ js_error(msg,
+ line != null ? line : ctx.tokline,
+ col != null ? col : ctx.tokcol,
+ pos != null ? pos : ctx.tokpos);
+ };
+
+ function token_error(token, msg) {
+ croak(msg, token.line, token.col);
+ };
+
+ function unexpected(token) {
+ if (token == null)
+ token = S.token;
+ token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
+ };
+
+ function expect_token(type, val) {
+ if (is(type, val)) {
+ return next();
+ }
+ token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type);
+ };
+
+ function expect(punc) { return expect_token("punc", punc); };
+
+ function can_insert_semicolon() {
+ return !exigent_mode && (
+ S.token.nlb || is("eof") || is("punc", "}")
+ );
+ };
+
+ function semicolon() {
+ if (is("punc", ";")) next();
+ else if (!can_insert_semicolon()) unexpected();
+ };
+
+ function as() {
+ return slice(arguments);
+ };
+
+ function parenthesised() {
+ expect("(");
+ var ex = expression();
+ expect(")");
+ return ex;
+ };
+
+ function add_tokens(str, start, end) {
+ return str instanceof NodeWithToken ? str : new NodeWithToken(str, start, end);
+ };
+
+ var statement = embed_tokens ? function() {
+ var start = S.token;
+ var ast = $statement.apply(this, arguments);
+ ast[0] = add_tokens(ast[0], start, prev());
+ return ast;
+ } : $statement;
+
+ function $statement() {
+ if (is("operator", "/")) {
+ S.peeked = null;
+ S.token = S.input(true); // force regexp
+ }
+ switch (S.token.type) {
+ case "num":
+ case "string":
+ case "regexp":
+ case "operator":
+ case "atom":
+ return simple_statement();
+
+ case "name":
+ return is_token(peek(), "punc", ":")
+ ? labeled_statement(prog1(S.token.value, next, next))
+ : simple_statement();
+
+ case "punc":
+ switch (S.token.value) {
+ case "{":
+ return as("block", block_());
+ case "[":
+ case "(":
+ return simple_statement();
+ case ";":
+ next();
+ return as("block");
+ default:
+ unexpected();
+ }
+
+ case "keyword":
+ switch (prog1(S.token.value, next)) {
+ case "break":
+ return break_cont("break");
+
+ case "continue":
+ return break_cont("continue");
+
+ case "debugger":
+ semicolon();
+ return as("debugger");
+
+ case "do":
+ return (function(body){
+ expect_token("keyword", "while");
+ return as("do", prog1(parenthesised, semicolon), body);
+ })(in_loop(statement));
+
+ case "for":
+ return for_();
+
+ case "function":
+ return function_(true);
+
+ case "if":
+ return if_();
+
+ case "return":
+ if (S.in_function == 0)
+ croak("'return' outside of function");
+ return as("return",
+ is("punc", ";")
+ ? (next(), null)
+ : can_insert_semicolon()
+ ? null
+ : prog1(expression, semicolon));
+
+ case "switch":
+ return as("switch", parenthesised(), switch_block_());
+
+ case "throw":
+ return as("throw", prog1(expression, semicolon));
+
+ case "try":
+ return try_();
+
+ case "var":
+ return prog1(var_, semicolon);
+
+ case "const":
+ return prog1(const_, semicolon);
+
+ case "while":
+ return as("while", parenthesised(), in_loop(statement));
+
+ case "with":
+ return as("with", parenthesised(), statement());
+
+ default:
+ unexpected();
+ }
+ }
+ };
+
+ function labeled_statement(label) {
+ S.labels.push(label);
+ var start = S.token, stat = statement();
+ if (exigent_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0]))
+ unexpected(start);
+ S.labels.pop();
+ return as("label", label, stat);
+ };
+
+ function simple_statement() {
+ return as("stat", prog1(expression, semicolon));
+ };
+
+ function break_cont(type) {
+ var name = is("name") ? S.token.value : null;
+ if (name != null) {
+ next();
+ if (!member(name, S.labels))
+ croak("Label " + name + " without matching loop or statement");
+ }
+ else if (S.in_loop == 0)
+ croak(type + " not inside a loop or switch");
+ semicolon();
+ return as(type, name);
+ };
+
+ function for_() {
+ expect("(");
+ var init = null;
+ if (!is("punc", ";")) {
+ init = is("keyword", "var")
+ ? (next(), var_(true))
+ : expression(true, true);
+ if (is("operator", "in"))
+ return for_in(init);
+ }
+ return regular_for(init);
+ };
+
+ function regular_for(init) {
+ expect(";");
+ var test = is("punc", ";") ? null : expression();
+ expect(";");
+ var step = is("punc", ")") ? null : expression();
+ expect(")");
+ return as("for", init, test, step, in_loop(statement));
+ };
+
+ function for_in(init) {
+ var lhs = init[0] == "var" ? as("name", init[1][0]) : init;
+ next();
+ var obj = expression();
+ expect(")");
+ return as("for-in", init, lhs, obj, in_loop(statement));
+ };
+
+ var function_ = embed_tokens ? function() {
+ var start = prev();
+ var ast = $function_.apply(this, arguments);
+ ast[0] = add_tokens(ast[0], start, prev());
+ return ast;
+ } : $function_;
+
+ function $function_(in_statement) {
+ var name = is("name") ? prog1(S.token.value, next) : null;
+ if (in_statement && !name)
+ unexpected();
+ expect("(");
+ return as(in_statement ? "defun" : "function",
+ name,
+ // arguments
+ (function(first, a){
+ while (!is("punc", ")")) {
+ if (first) first = false; else expect(",");
+ if (!is("name")) unexpected();
+ a.push(S.token.value);
+ next();
+ }
+ next();
+ return a;
+ })(true, []),
+ // body
+ (function(){
+ ++S.in_function;
+ var loop = S.in_loop;
+ S.in_loop = 0;
+ var a = block_();
+ --S.in_function;
+ S.in_loop = loop;
+ return a;
+ })());
+ };
+
+ function if_() {
+ var cond = parenthesised(), body = statement(), belse;
+ if (is("keyword", "else")) {
+ next();
+ belse = statement();
+ }
+ return as("if", cond, body, belse);
+ };
+
+ function block_() {
+ expect("{");
+ var a = [];
+ while (!is("punc", "}")) {
+ if (is("eof")) unexpected();
+ a.push(statement());
+ }
+ next();
+ return a;
+ };
+
+ var switch_block_ = curry(in_loop, function(){
+ expect("{");
+ var a = [], cur = null;
+ while (!is("punc", "}")) {
+ if (is("eof")) unexpected();
+ if (is("keyword", "case")) {
+ next();
+ cur = [];
+ a.push([ expression(), cur ]);
+ expect(":");
+ }
+ else if (is("keyword", "default")) {
+ next();
+ expect(":");
+ cur = [];
+ a.push([ null, cur ]);
+ }
+ else {
+ if (!cur) unexpected();
+ cur.push(statement());
+ }
+ }
+ next();
+ return a;
+ });
+
+ function try_() {
+ var body = block_(), bcatch, bfinally;
+ if (is("keyword", "catch")) {
+ next();
+ expect("(");
+ if (!is("name"))
+ croak("Name expected");
+ var name = S.token.value;
+ next();
+ expect(")");
+ bcatch = [ name, block_() ];
+ }
+ if (is("keyword", "finally")) {
+ next();
+ bfinally = block_();
+ }
+ if (!bcatch && !bfinally)
+ croak("Missing catch/finally blocks");
+ return as("try", body, bcatch, bfinally);
+ };
+
+ function vardefs(no_in) {
+ var a = [];
+ for (;;) {
+ if (!is("name"))
+ unexpected();
+ var name = S.token.value;
+ next();
+ if (is("operator", "=")) {
+ next();
+ a.push([ name, expression(false, no_in) ]);
+ } else {
+ a.push([ name ]);
+ }
+ if (!is("punc", ","))
+ break;
+ next();
+ }
+ return a;
+ };
+
+ function var_(no_in) {
+ return as("var", vardefs(no_in));
+ };
+
+ function const_() {
+ return as("const", vardefs());
+ };
+
+ function new_() {
+ var newexp = expr_atom(false), args;
+ if (is("punc", "(")) {
+ next();
+ args = expr_list(")");
+ } else {
+ args = [];
+ }
+ return subscripts(as("new", newexp, args), true);
+ };
+
+ function expr_atom(allow_calls) {
+ if (is("operator", "new")) {
+ next();
+ return new_();
+ }
+ if (is("operator") && HOP(UNARY_PREFIX, S.token.value)) {
+ return make_unary("unary-prefix",
+ prog1(S.token.value, next),
+ expr_atom(allow_calls));
+ }
+ if (is("punc")) {
+ switch (S.token.value) {
+ case "(":
+ next();
+ return subscripts(prog1(expression, curry(expect, ")")), allow_calls);
+ case "[":
+ next();
+ return subscripts(array_(), allow_calls);
+ case "{":
+ next();
+ return subscripts(object_(), allow_calls);
+ }
+ unexpected();
+ }
+ if (is("keyword", "function")) {
+ next();
+ return subscripts(function_(false), allow_calls);
+ }
+ if (HOP(ATOMIC_START_TOKEN, S.token.type)) {
+ var atom = S.token.type == "regexp"
+ ? as("regexp", S.token.value[0], S.token.value[1])
+ : as(S.token.type, S.token.value);
+ return subscripts(prog1(atom, next), allow_calls);
+ }
+ unexpected();
+ };
+
+ function expr_list(closing, allow_trailing_comma, allow_empty) {
+ var first = true, a = [];
+ while (!is("punc", closing)) {
+ if (first) first = false; else expect(",");
+ if (allow_trailing_comma && is("punc", closing)) break;
+ if (is("punc", ",") && allow_empty) {
+ a.push([ "atom", "undefined" ]);
+ } else {
+ a.push(expression(false));
+ }
+ }
+ next();
+ return a;
+ };
+
+ function array_() {
+ return as("array", expr_list("]", !exigent_mode, true));
+ };
+
+ function object_() {
+ var first = true, a = [];
+ while (!is("punc", "}")) {
+ if (first) first = false; else expect(",");
+ if (!exigent_mode && is("punc", "}"))
+ // allow trailing comma
+ break;
+ var type = S.token.type;
+ var name = as_property_name();
+ if (type == "name" && (name == "get" || name == "set") && !is("punc", ":")) {
+ a.push([ as_name(), function_(false), name ]);
+ } else {
+ expect(":");
+ a.push([ name, expression(false) ]);
+ }
+ }
+ next();
+ return as("object", a);
+ };
+
+ function as_property_name() {
+ switch (S.token.type) {
+ case "num":
+ case "string":
+ return prog1(S.token.value, next);
+ }
+ return as_name();
+ };
+
+ function as_name() {
+ switch (S.token.type) {
+ case "name":
+ case "operator":
+ case "keyword":
+ case "atom":
+ return prog1(S.token.value, next);
+ default:
+ unexpected();
+ }
+ };
+
+ function subscripts(expr, allow_calls) {
+ if (is("punc", ".")) {
+ next();
+ return subscripts(as("dot", expr, as_name()), allow_calls);
+ }
+ if (is("punc", "[")) {
+ next();
+ return subscripts(as("sub", expr, prog1(expression, curry(expect, "]"))), allow_calls);
+ }
+ if (allow_calls && is("punc", "(")) {
+ next();
+ return subscripts(as("call", expr, expr_list(")")), true);
+ }
+ if (allow_calls && is("operator") && HOP(UNARY_POSTFIX, S.token.value)) {
+ return prog1(curry(make_unary, "unary-postfix", S.token.value, expr),
+ next);
+ }
+ return expr;
+ };
+
+ function make_unary(tag, op, expr) {
+ if ((op == "++" || op == "--") && !is_assignable(expr))
+ croak("Invalid use of " + op + " operator");
+ return as(tag, op, expr);
+ };
+
+ function expr_op(left, min_prec, no_in) {
+ var op = is("operator") ? S.token.value : null;
+ if (op && op == "in" && no_in) op = null;
+ var prec = op != null ? PRECEDENCE[op] : null;
+ if (prec != null && prec > min_prec) {
+ next();
+ var right = expr_op(expr_atom(true), prec, no_in);
+ return expr_op(as("binary", op, left, right), min_prec, no_in);
+ }
+ return left;
+ };
+
+ function expr_ops(no_in) {
+ return expr_op(expr_atom(true), 0, no_in);
+ };
+
+ function maybe_conditional(no_in) {
+ var expr = expr_ops(no_in);
+ if (is("operator", "?")) {
+ next();
+ var yes = expression(false);
+ expect(":");
+ return as("conditional", expr, yes, expression(false, no_in));
+ }
+ return expr;
+ };
+
+ function is_assignable(expr) {
+ if (!exigent_mode) return true;
+ switch (expr[0]) {
+ case "dot":
+ case "sub":
+ case "new":
+ case "call":
+ return true;
+ case "name":
+ return expr[1] != "this";
+ }
+ };
+
+ function maybe_assign(no_in) {
+ var left = maybe_conditional(no_in), val = S.token.value;
+ if (is("operator") && HOP(ASSIGNMENT, val)) {
+ if (is_assignable(left)) {
+ next();
+ return as("assign", ASSIGNMENT[val], left, maybe_assign(no_in));
+ }
+ croak("Invalid assignment");
+ }
+ return left;
+ };
+
+ function expression(commas, no_in) {
+ if (arguments.length == 0)
+ commas = true;
+ var expr = maybe_assign(no_in);
+ if (commas && is("punc", ",")) {
+ next();
+ return as("seq", expr, expression(true, no_in));
+ }
+ return expr;
+ };
+
+ function in_loop(cont) {
+ try {
+ ++S.in_loop;
+ return cont();
+ } finally {
+ --S.in_loop;
+ }
+ };
+
+ return as("toplevel", (function(a){
+ while (!is("eof"))
+ a.push(statement());
+ return a;
+ })([]));
+
+};
+
+/* -----[ Utilities ]----- */
+
+function curry(f) {
+ var args = slice(arguments, 1);
+ return function() { return f.apply(this, args.concat(slice(arguments))); };
+};
+
+function prog1(ret) {
+ if (ret instanceof Function)
+ ret = ret();
+ for (var i = 1, n = arguments.length; --n > 0; ++i)
+ arguments[i]();
+ return ret;
+};
+
+function array_to_hash(a) {
+ var ret = {};
+ for (var i = 0; i < a.length; ++i)
+ ret[a[i]] = true;
+ return ret;
+};
+
+function slice(a, start) {
+ return Array.prototype.slice.call(a, start == null ? 0 : start);
+};
+
+function characters(str) {
+ return str.split("");
+};
+
+function member(name, array) {
+ for (var i = array.length; --i >= 0;)
+ if (array[i] === name)
+ return true;
+ return false;
+};
+
+function HOP(obj, prop) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
+};
+
+var warn = function() {};
+
+/* -----[ Exports ]----- */
+
+exports.tokenizer = tokenizer;
+exports.parse = parse;
+exports.slice = slice;
+exports.curry = curry;
+exports.member = member;
+exports.array_to_hash = array_to_hash;
+exports.PRECEDENCE = PRECEDENCE;
+exports.KEYWORDS_ATOM = KEYWORDS_ATOM;
+exports.RESERVED_WORDS = RESERVED_WORDS;
+exports.KEYWORDS = KEYWORDS;
+exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN;
+exports.OPERATORS = OPERATORS;
+exports.is_alphanumeric_char = is_alphanumeric_char;
+exports.set_logger = function(logger) {
+ warn = logger;
+};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[27/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/reply.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/reply.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/reply.js
new file mode 100644
index 0000000..349c920
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/reply.js
@@ -0,0 +1,31 @@
+(function() {
+ var Reply;
+
+ Reply = (function() {
+ Reply.ERROR = 'ERROR';
+
+ Reply.OK = 'OK';
+
+ function Reply(type, value) {
+ this.type = type;
+ this.value = value;
+ }
+
+ Reply.prototype.isError = function() {
+ return this.type === Reply.ERROR;
+ };
+
+ Reply.prototype.toError = function() {
+ if (!this.isError()) {
+ throw new Error('toError() cannot be called for non-errors');
+ }
+ return new Error(this.value);
+ };
+
+ return Reply;
+
+ })();
+
+ module.exports = Reply;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/LICENSE b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/LICENSE
new file mode 100644
index 0000000..b7f9d50
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010 Caolan McMahon
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/README.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/README.md
new file mode 100644
index 0000000..951f76e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/README.md
@@ -0,0 +1,1425 @@
+# Async.js
+
+Async is a utility module which provides straight-forward, powerful functions
+for working with asynchronous JavaScript. Although originally designed for
+use with [node.js](http://nodejs.org), it can also be used directly in the
+browser. Also supports [component](https://github.com/component/component).
+
+Async provides around 20 functions that include the usual 'functional'
+suspects (map, reduce, filter, each…) as well as some common patterns
+for asynchronous control flow (parallel, series, waterfall…). All these
+functions assume you follow the node.js convention of providing a single
+callback as the last argument of your async function.
+
+
+## Quick Examples
+
+```javascript
+async.map(['file1','file2','file3'], fs.stat, function(err, results){
+ // results is now an array of stats for each file
+});
+
+async.filter(['file1','file2','file3'], fs.exists, function(results){
+ // results now equals an array of the existing files
+});
+
+async.parallel([
+ function(){ ... },
+ function(){ ... }
+], callback);
+
+async.series([
+ function(){ ... },
+ function(){ ... }
+]);
+```
+
+There are many more functions available so take a look at the docs below for a
+full list. This module aims to be comprehensive, so if you feel anything is
+missing please create a GitHub issue for it.
+
+## Common Pitfalls
+
+### Binding a context to an iterator
+
+This section is really about bind, not about async. If you are wondering how to
+make async execute your iterators in a given context, or are confused as to why
+a method of another library isn't working as an iterator, study this example:
+
+```js
+// Here is a simple object with an (unnecessarily roundabout) squaring method
+var AsyncSquaringLibrary = {
+ squareExponent: 2,
+ square: function(number, callback){
+ var result = Math.pow(number, this.squareExponent);
+ setTimeout(function(){
+ callback(null, result);
+ }, 200);
+ }
+};
+
+async.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result){
+ // result is [NaN, NaN, NaN]
+ // This fails because the `this.squareExponent` expression in the square
+ // function is not evaluated in the context of AsyncSquaringLibrary, and is
+ // therefore undefined.
+});
+
+async.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result){
+ // result is [1, 4, 9]
+ // With the help of bind we can attach a context to the iterator before
+ // passing it to async. Now the square function will be executed in its
+ // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent`
+ // will be as expected.
+});
+```
+
+## Download
+
+The source is available for download from
+[GitHub](http://github.com/caolan/async).
+Alternatively, you can install using Node Package Manager (npm):
+
+ npm install async
+
+__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 29.6kb Uncompressed
+
+## In the Browser
+
+So far it's been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. Usage:
+
+```html
+<script type="text/javascript" src="async.js"></script>
+<script type="text/javascript">
+
+ async.map(data, asyncProcess, function(err, results){
+ alert(results);
+ });
+
+</script>
+```
+
+## Documentation
+
+### Collections
+
+* [each](#each)
+* [eachSeries](#eachSeries)
+* [eachLimit](#eachLimit)
+* [map](#map)
+* [mapSeries](#mapSeries)
+* [mapLimit](#mapLimit)
+* [filter](#filter)
+* [filterSeries](#filterSeries)
+* [reject](#reject)
+* [rejectSeries](#rejectSeries)
+* [reduce](#reduce)
+* [reduceRight](#reduceRight)
+* [detect](#detect)
+* [detectSeries](#detectSeries)
+* [sortBy](#sortBy)
+* [some](#some)
+* [every](#every)
+* [concat](#concat)
+* [concatSeries](#concatSeries)
+
+### Control Flow
+
+* [series](#series)
+* [parallel](#parallel)
+* [parallelLimit](#parallellimittasks-limit-callback)
+* [whilst](#whilst)
+* [doWhilst](#doWhilst)
+* [until](#until)
+* [doUntil](#doUntil)
+* [forever](#forever)
+* [waterfall](#waterfall)
+* [compose](#compose)
+* [applyEach](#applyEach)
+* [applyEachSeries](#applyEachSeries)
+* [queue](#queue)
+* [cargo](#cargo)
+* [auto](#auto)
+* [iterator](#iterator)
+* [apply](#apply)
+* [nextTick](#nextTick)
+* [times](#times)
+* [timesSeries](#timesSeries)
+
+### Utils
+
+* [memoize](#memoize)
+* [unmemoize](#unmemoize)
+* [log](#log)
+* [dir](#dir)
+* [noConflict](#noConflict)
+
+
+## Collections
+
+<a name="forEach" />
+<a name="each" />
+### each(arr, iterator, callback)
+
+Applies an iterator function to each item in an array, in parallel.
+The iterator is called with an item from the list and a callback for when it
+has finished. If the iterator passes an error to this callback, the main
+callback for the each function is immediately called with the error.
+
+Note, that since this function applies the iterator to each item in parallel
+there is no guarantee that the iterator functions will complete in order.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* iterator(item, callback) - A function to apply to each item in the array.
+ The iterator is passed a callback(err) which must be called once it has
+ completed. If no error has occured, the callback should be run without
+ arguments or with an explicit null argument.
+* callback(err) - A callback which is called after all the iterator functions
+ have finished, or an error has occurred.
+
+__Example__
+
+```js
+// assuming openFiles is an array of file names and saveFile is a function
+// to save the modified contents of that file:
+
+async.each(openFiles, saveFile, function(err){
+ // if any of the saves produced an error, err would equal that error
+});
+```
+
+---------------------------------------
+
+<a name="forEachSeries" />
+<a name="eachSeries" />
+### eachSeries(arr, iterator, callback)
+
+The same as each only the iterator is applied to each item in the array in
+series. The next iterator is only called once the current one has completed
+processing. This means the iterator functions will complete in order.
+
+
+---------------------------------------
+
+<a name="forEachLimit" />
+<a name="eachLimit" />
+### eachLimit(arr, limit, iterator, callback)
+
+The same as each only no more than "limit" iterators will be simultaneously
+running at any time.
+
+Note that the items are not processed in batches, so there is no guarantee that
+ the first "limit" iterator functions will complete before any others are
+started.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* limit - The maximum number of iterators to run at any time.
+* iterator(item, callback) - A function to apply to each item in the array.
+ The iterator is passed a callback(err) which must be called once it has
+ completed. If no error has occured, the callback should be run without
+ arguments or with an explicit null argument.
+* callback(err) - A callback which is called after all the iterator functions
+ have finished, or an error has occurred.
+
+__Example__
+
+```js
+// Assume documents is an array of JSON objects and requestApi is a
+// function that interacts with a rate-limited REST api.
+
+async.eachLimit(documents, 20, requestApi, function(err){
+ // if any of the saves produced an error, err would equal that error
+});
+```
+
+---------------------------------------
+
+<a name="map" />
+### map(arr, iterator, callback)
+
+Produces a new array of values by mapping each value in the given array through
+the iterator function. The iterator is called with an item from the array and a
+callback for when it has finished processing. The callback takes 2 arguments,
+an error and the transformed item from the array. If the iterator passes an
+error to this callback, the main callback for the map function is immediately
+called with the error.
+
+Note, that since this function applies the iterator to each item in parallel
+there is no guarantee that the iterator functions will complete in order, however
+the results array will be in the same order as the original array.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* iterator(item, callback) - A function to apply to each item in the array.
+ The iterator is passed a callback(err, transformed) which must be called once
+ it has completed with an error (which can be null) and a transformed item.
+* callback(err, results) - A callback which is called after all the iterator
+ functions have finished, or an error has occurred. Results is an array of the
+ transformed items from the original array.
+
+__Example__
+
+```js
+async.map(['file1','file2','file3'], fs.stat, function(err, results){
+ // results is now an array of stats for each file
+});
+```
+
+---------------------------------------
+
+<a name="mapSeries" />
+### mapSeries(arr, iterator, callback)
+
+The same as map only the iterator is applied to each item in the array in
+series. The next iterator is only called once the current one has completed
+processing. The results array will be in the same order as the original.
+
+
+---------------------------------------
+
+<a name="mapLimit" />
+### mapLimit(arr, limit, iterator, callback)
+
+The same as map only no more than "limit" iterators will be simultaneously
+running at any time.
+
+Note that the items are not processed in batches, so there is no guarantee that
+ the first "limit" iterator functions will complete before any others are
+started.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* limit - The maximum number of iterators to run at any time.
+* iterator(item, callback) - A function to apply to each item in the array.
+ The iterator is passed a callback(err, transformed) which must be called once
+ it has completed with an error (which can be null) and a transformed item.
+* callback(err, results) - A callback which is called after all the iterator
+ functions have finished, or an error has occurred. Results is an array of the
+ transformed items from the original array.
+
+__Example__
+
+```js
+async.mapLimit(['file1','file2','file3'], 1, fs.stat, function(err, results){
+ // results is now an array of stats for each file
+});
+```
+
+---------------------------------------
+
+<a name="filter" />
+### filter(arr, iterator, callback)
+
+__Alias:__ select
+
+Returns a new array of all the values which pass an async truth test.
+_The callback for each iterator call only accepts a single argument of true or
+false, it does not accept an error argument first!_ This is in-line with the
+way node libraries work with truth tests like fs.exists. This operation is
+performed in parallel, but the results array will be in the same order as the
+original.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* iterator(item, callback) - A truth test to apply to each item in the array.
+ The iterator is passed a callback(truthValue) which must be called with a
+ boolean argument once it has completed.
+* callback(results) - A callback which is called after all the iterator
+ functions have finished.
+
+__Example__
+
+```js
+async.filter(['file1','file2','file3'], fs.exists, function(results){
+ // results now equals an array of the existing files
+});
+```
+
+---------------------------------------
+
+<a name="filterSeries" />
+### filterSeries(arr, iterator, callback)
+
+__alias:__ selectSeries
+
+The same as filter only the iterator is applied to each item in the array in
+series. The next iterator is only called once the current one has completed
+processing. The results array will be in the same order as the original.
+
+---------------------------------------
+
+<a name="reject" />
+### reject(arr, iterator, callback)
+
+The opposite of filter. Removes values that pass an async truth test.
+
+---------------------------------------
+
+<a name="rejectSeries" />
+### rejectSeries(arr, iterator, callback)
+
+The same as reject, only the iterator is applied to each item in the array
+in series.
+
+
+---------------------------------------
+
+<a name="reduce" />
+### reduce(arr, memo, iterator, callback)
+
+__aliases:__ inject, foldl
+
+Reduces a list of values into a single value using an async iterator to return
+each successive step. Memo is the initial state of the reduction. This
+function only operates in series. For performance reasons, it may make sense to
+split a call to this function into a parallel map, then use the normal
+Array.prototype.reduce on the results. This function is for situations where
+each step in the reduction needs to be async, if you can get the data before
+reducing it then it's probably a good idea to do so.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* memo - The initial state of the reduction.
+* iterator(memo, item, callback) - A function applied to each item in the
+ array to produce the next step in the reduction. The iterator is passed a
+ callback(err, reduction) which accepts an optional error as its first
+ argument, and the state of the reduction as the second. If an error is
+ passed to the callback, the reduction is stopped and the main callback is
+ immediately called with the error.
+* callback(err, result) - A callback which is called after all the iterator
+ functions have finished. Result is the reduced value.
+
+__Example__
+
+```js
+async.reduce([1,2,3], 0, function(memo, item, callback){
+ // pointless async:
+ process.nextTick(function(){
+ callback(null, memo + item)
+ });
+}, function(err, result){
+ // result is now equal to the last value of memo, which is 6
+});
+```
+
+---------------------------------------
+
+<a name="reduceRight" />
+### reduceRight(arr, memo, iterator, callback)
+
+__Alias:__ foldr
+
+Same as reduce, only operates on the items in the array in reverse order.
+
+
+---------------------------------------
+
+<a name="detect" />
+### detect(arr, iterator, callback)
+
+Returns the first value in a list that passes an async truth test. The
+iterator is applied in parallel, meaning the first iterator to return true will
+fire the detect callback with that result. That means the result might not be
+the first item in the original array (in terms of order) that passes the test.
+
+If order within the original array is important then look at detectSeries.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* iterator(item, callback) - A truth test to apply to each item in the array.
+ The iterator is passed a callback(truthValue) which must be called with a
+ boolean argument once it has completed.
+* callback(result) - A callback which is called as soon as any iterator returns
+ true, or after all the iterator functions have finished. Result will be
+ the first item in the array that passes the truth test (iterator) or the
+ value undefined if none passed.
+
+__Example__
+
+```js
+async.detect(['file1','file2','file3'], fs.exists, function(result){
+ // result now equals the first file in the list that exists
+});
+```
+
+---------------------------------------
+
+<a name="detectSeries" />
+### detectSeries(arr, iterator, callback)
+
+The same as detect, only the iterator is applied to each item in the array
+in series. This means the result is always the first in the original array (in
+terms of array order) that passes the truth test.
+
+
+---------------------------------------
+
+<a name="sortBy" />
+### sortBy(arr, iterator, callback)
+
+Sorts a list by the results of running each value through an async iterator.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* iterator(item, callback) - A function to apply to each item in the array.
+ The iterator is passed a callback(err, sortValue) which must be called once it
+ has completed with an error (which can be null) and a value to use as the sort
+ criteria.
+* callback(err, results) - A callback which is called after all the iterator
+ functions have finished, or an error has occurred. Results is the items from
+ the original array sorted by the values returned by the iterator calls.
+
+__Example__
+
+```js
+async.sortBy(['file1','file2','file3'], function(file, callback){
+ fs.stat(file, function(err, stats){
+ callback(err, stats.mtime);
+ });
+}, function(err, results){
+ // results is now the original array of files sorted by
+ // modified date
+});
+```
+
+---------------------------------------
+
+<a name="some" />
+### some(arr, iterator, callback)
+
+__Alias:__ any
+
+Returns true if at least one element in the array satisfies an async test.
+_The callback for each iterator call only accepts a single argument of true or
+false, it does not accept an error argument first!_ This is in-line with the
+way node libraries work with truth tests like fs.exists. Once any iterator
+call returns true, the main callback is immediately called.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* iterator(item, callback) - A truth test to apply to each item in the array.
+ The iterator is passed a callback(truthValue) which must be called with a
+ boolean argument once it has completed.
+* callback(result) - A callback which is called as soon as any iterator returns
+ true, or after all the iterator functions have finished. Result will be
+ either true or false depending on the values of the async tests.
+
+__Example__
+
+```js
+async.some(['file1','file2','file3'], fs.exists, function(result){
+ // if result is true then at least one of the files exists
+});
+```
+
+---------------------------------------
+
+<a name="every" />
+### every(arr, iterator, callback)
+
+__Alias:__ all
+
+Returns true if every element in the array satisfies an async test.
+_The callback for each iterator call only accepts a single argument of true or
+false, it does not accept an error argument first!_ This is in-line with the
+way node libraries work with truth tests like fs.exists.
+
+__Arguments__
+
+* arr - An array to iterate over.
+* iterator(item, callback) - A truth test to apply to each item in the array.
+ The iterator is passed a callback(truthValue) which must be called with a
+ boolean argument once it has completed.
+* callback(result) - A callback which is called after all the iterator
+ functions have finished. Result will be either true or false depending on
+ the values of the async tests.
+
+__Example__
+
+```js
+async.every(['file1','file2','file3'], fs.exists, function(result){
+ // if result is true then every file exists
+});
+```
+
+---------------------------------------
+
+<a name="concat" />
+### concat(arr, iterator, callback)
+
+Applies an iterator to each item in a list, concatenating the results. Returns the
+concatenated list. The iterators are called in parallel, and the results are
+concatenated as they return. There is no guarantee that the results array will
+be returned in the original order of the arguments passed to the iterator function.
+
+__Arguments__
+
+* arr - An array to iterate over
+* iterator(item, callback) - A function to apply to each item in the array.
+ The iterator is passed a callback(err, results) which must be called once it
+ has completed with an error (which can be null) and an array of results.
+* callback(err, results) - A callback which is called after all the iterator
+ functions have finished, or an error has occurred. Results is an array containing
+ the concatenated results of the iterator function.
+
+__Example__
+
+```js
+async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){
+ // files is now a list of filenames that exist in the 3 directories
+});
+```
+
+---------------------------------------
+
+<a name="concatSeries" />
+### concatSeries(arr, iterator, callback)
+
+Same as async.concat, but executes in series instead of parallel.
+
+
+## Control Flow
+
+<a name="series" />
+### series(tasks, [callback])
+
+Run an array of functions in series, each one running once the previous
+function has completed. If any functions in the series pass an error to its
+callback, no more functions are run and the callback for the series is
+immediately called with the value of the error. Once the tasks have completed,
+the results are passed to the final callback as an array.
+
+It is also possible to use an object instead of an array. Each property will be
+run as a function and the results will be passed to the final callback as an object
+instead of an array. This can be a more readable way of handling results from
+async.series.
+
+
+__Arguments__
+
+* tasks - An array or object containing functions to run, each function is passed
+ a callback(err, result) it must call on completion with an error (which can
+ be null) and an optional result value.
+* callback(err, results) - An optional callback to run once all the functions
+ have completed. This function gets a results array (or object) containing all
+ the result arguments passed to the task callbacks.
+
+__Example__
+
+```js
+async.series([
+ function(callback){
+ // do some stuff ...
+ callback(null, 'one');
+ },
+ function(callback){
+ // do some more stuff ...
+ callback(null, 'two');
+ }
+],
+// optional callback
+function(err, results){
+ // results is now equal to ['one', 'two']
+});
+
+
+// an example using an object instead of an array
+async.series({
+ one: function(callback){
+ setTimeout(function(){
+ callback(null, 1);
+ }, 200);
+ },
+ two: function(callback){
+ setTimeout(function(){
+ callback(null, 2);
+ }, 100);
+ }
+},
+function(err, results) {
+ // results is now equal to: {one: 1, two: 2}
+});
+```
+
+---------------------------------------
+
+<a name="parallel" />
+### parallel(tasks, [callback])
+
+Run an array of functions in parallel, without waiting until the previous
+function has completed. If any of the functions pass an error to its
+callback, the main callback is immediately called with the value of the error.
+Once the tasks have completed, the results are passed to the final callback as an
+array.
+
+It is also possible to use an object instead of an array. Each property will be
+run as a function and the results will be passed to the final callback as an object
+instead of an array. This can be a more readable way of handling results from
+async.parallel.
+
+
+__Arguments__
+
+* tasks - An array or object containing functions to run, each function is passed
+ a callback(err, result) it must call on completion with an error (which can
+ be null) and an optional result value.
+* callback(err, results) - An optional callback to run once all the functions
+ have completed. This function gets a results array (or object) containing all
+ the result arguments passed to the task callbacks.
+
+__Example__
+
+```js
+async.parallel([
+ function(callback){
+ setTimeout(function(){
+ callback(null, 'one');
+ }, 200);
+ },
+ function(callback){
+ setTimeout(function(){
+ callback(null, 'two');
+ }, 100);
+ }
+],
+// optional callback
+function(err, results){
+ // the results array will equal ['one','two'] even though
+ // the second function had a shorter timeout.
+});
+
+
+// an example using an object instead of an array
+async.parallel({
+ one: function(callback){
+ setTimeout(function(){
+ callback(null, 1);
+ }, 200);
+ },
+ two: function(callback){
+ setTimeout(function(){
+ callback(null, 2);
+ }, 100);
+ }
+},
+function(err, results) {
+ // results is now equals to: {one: 1, two: 2}
+});
+```
+
+---------------------------------------
+
+<a name="parallel" />
+### parallelLimit(tasks, limit, [callback])
+
+The same as parallel only the tasks are executed in parallel with a maximum of "limit"
+tasks executing at any time.
+
+Note that the tasks are not executed in batches, so there is no guarantee that
+the first "limit" tasks will complete before any others are started.
+
+__Arguments__
+
+* tasks - An array or object containing functions to run, each function is passed
+ a callback(err, result) it must call on completion with an error (which can
+ be null) and an optional result value.
+* limit - The maximum number of tasks to run at any time.
+* callback(err, results) - An optional callback to run once all the functions
+ have completed. This function gets a results array (or object) containing all
+ the result arguments passed to the task callbacks.
+
+---------------------------------------
+
+<a name="whilst" />
+### whilst(test, fn, callback)
+
+Repeatedly call fn, while test returns true. Calls the callback when stopped,
+or an error occurs.
+
+__Arguments__
+
+* test() - synchronous truth test to perform before each execution of fn.
+* fn(callback) - A function to call each time the test passes. The function is
+ passed a callback(err) which must be called once it has completed with an
+ optional error argument.
+* callback(err) - A callback which is called after the test fails and repeated
+ execution of fn has stopped.
+
+__Example__
+
+```js
+var count = 0;
+
+async.whilst(
+ function () { return count < 5; },
+ function (callback) {
+ count++;
+ setTimeout(callback, 1000);
+ },
+ function (err) {
+ // 5 seconds have passed
+ }
+);
+```
+
+---------------------------------------
+
+<a name="doWhilst" />
+### doWhilst(fn, test, callback)
+
+The post check version of whilst. To reflect the difference in the order of operations `test` and `fn` arguments are switched. `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
+
+---------------------------------------
+
+<a name="until" />
+### until(test, fn, callback)
+
+Repeatedly call fn, until test returns true. Calls the callback when stopped,
+or an error occurs.
+
+The inverse of async.whilst.
+
+---------------------------------------
+
+<a name="doUntil" />
+### doUntil(fn, test, callback)
+
+Like doWhilst except the test is inverted. Note the argument ordering differs from `until`.
+
+---------------------------------------
+
+<a name="forever" />
+### forever(fn, callback)
+
+Calls the asynchronous function 'fn' repeatedly, in series, indefinitely.
+If an error is passed to fn's callback then 'callback' is called with the
+error, otherwise it will never be called.
+
+---------------------------------------
+
+<a name="waterfall" />
+### waterfall(tasks, [callback])
+
+Runs an array of functions in series, each passing their results to the next in
+the array. However, if any of the functions pass an error to the callback, the
+next function is not executed and the main callback is immediately called with
+the error.
+
+__Arguments__
+
+* tasks - An array of functions to run, each function is passed a
+ callback(err, result1, result2, ...) it must call on completion. The first
+ argument is an error (which can be null) and any further arguments will be
+ passed as arguments in order to the next task.
+* callback(err, [results]) - An optional callback to run once all the functions
+ have completed. This will be passed the results of the last task's callback.
+
+
+
+__Example__
+
+```js
+async.waterfall([
+ function(callback){
+ callback(null, 'one', 'two');
+ },
+ function(arg1, arg2, callback){
+ callback(null, 'three');
+ },
+ function(arg1, callback){
+ // arg1 now equals 'three'
+ callback(null, 'done');
+ }
+], function (err, result) {
+ // result now equals 'done'
+});
+```
+
+---------------------------------------
+<a name="compose" />
+### compose(fn1, fn2...)
+
+Creates a function which is a composition of the passed asynchronous
+functions. Each function consumes the return value of the function that
+follows. Composing functions f(), g() and h() would produce the result of
+f(g(h())), only this version uses callbacks to obtain the return values.
+
+Each function is executed with the `this` binding of the composed function.
+
+__Arguments__
+
+* functions... - the asynchronous functions to compose
+
+
+__Example__
+
+```js
+function add1(n, callback) {
+ setTimeout(function () {
+ callback(null, n + 1);
+ }, 10);
+}
+
+function mul3(n, callback) {
+ setTimeout(function () {
+ callback(null, n * 3);
+ }, 10);
+}
+
+var add1mul3 = async.compose(mul3, add1);
+
+add1mul3(4, function (err, result) {
+ // result now equals 15
+});
+```
+
+---------------------------------------
+<a name="applyEach" />
+### applyEach(fns, args..., callback)
+
+Applies the provided arguments to each function in the array, calling the
+callback after all functions have completed. If you only provide the first
+argument then it will return a function which lets you pass in the
+arguments as if it were a single function call.
+
+__Arguments__
+
+* fns - the asynchronous functions to all call with the same arguments
+* args... - any number of separate arguments to pass to the function
+* callback - the final argument should be the callback, called when all
+ functions have completed processing
+
+
+__Example__
+
+```js
+async.applyEach([enableSearch, updateSchema], 'bucket', callback);
+
+// partial application example:
+async.each(
+ buckets,
+ async.applyEach([enableSearch, updateSchema]),
+ callback
+);
+```
+
+---------------------------------------
+
+<a name="applyEachSeries" />
+### applyEachSeries(arr, iterator, callback)
+
+The same as applyEach only the functions are applied in series.
+
+---------------------------------------
+
+<a name="queue" />
+### queue(worker, concurrency)
+
+Creates a queue object with the specified concurrency. Tasks added to the
+queue will be processed in parallel (up to the concurrency limit). If all
+workers are in progress, the task is queued until one is available. Once
+a worker has completed a task, the task's callback is called.
+
+__Arguments__
+
+* worker(task, callback) - An asynchronous function for processing a queued
+ task, which must call its callback(err) argument when finished, with an
+ optional error as an argument.
+* concurrency - An integer for determining how many worker functions should be
+ run in parallel.
+
+__Queue objects__
+
+The queue object returned by this function has the following properties and
+methods:
+
+* length() - a function returning the number of items waiting to be processed.
+* concurrency - an integer for determining how many worker functions should be
+ run in parallel. This property can be changed after a queue is created to
+ alter the concurrency on-the-fly.
+* push(task, [callback]) - add a new task to the queue, the callback is called
+ once the worker has finished processing the task.
+ instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.
+* unshift(task, [callback]) - add a new task to the front of the queue.
+* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued
+* empty - a callback that is called when the last item from the queue is given to a worker
+* drain - a callback that is called when the last item from the queue has returned from the worker
+
+__Example__
+
+```js
+// create a queue object with concurrency 2
+
+var q = async.queue(function (task, callback) {
+ console.log('hello ' + task.name);
+ callback();
+}, 2);
+
+
+// assign a callback
+q.drain = function() {
+ console.log('all items have been processed');
+}
+
+// add some items to the queue
+
+q.push({name: 'foo'}, function (err) {
+ console.log('finished processing foo');
+});
+q.push({name: 'bar'}, function (err) {
+ console.log('finished processing bar');
+});
+
+// add some items to the queue (batch-wise)
+
+q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) {
+ console.log('finished processing bar');
+});
+
+// add some items to the front of the queue
+
+q.unshift({name: 'bar'}, function (err) {
+ console.log('finished processing bar');
+});
+```
+
+---------------------------------------
+
+<a name="cargo" />
+### cargo(worker, [payload])
+
+Creates a cargo object with the specified payload. Tasks added to the
+cargo will be processed altogether (up to the payload limit). If the
+worker is in progress, the task is queued until it is available. Once
+the worker has completed some tasks, each callback of those tasks is called.
+
+__Arguments__
+
+* worker(tasks, callback) - An asynchronous function for processing an array of
+ queued tasks, which must call its callback(err) argument when finished, with
+ an optional error as an argument.
+* payload - An optional integer for determining how many tasks should be
+ processed per round; if omitted, the default is unlimited.
+
+__Cargo objects__
+
+The cargo object returned by this function has the following properties and
+methods:
+
+* length() - a function returning the number of items waiting to be processed.
+* payload - an integer for determining how many tasks should be
+ process per round. This property can be changed after a cargo is created to
+ alter the payload on-the-fly.
+* push(task, [callback]) - add a new task to the queue, the callback is called
+ once the worker has finished processing the task.
+ instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.
+* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued
+* empty - a callback that is called when the last item from the queue is given to a worker
+* drain - a callback that is called when the last item from the queue has returned from the worker
+
+__Example__
+
+```js
+// create a cargo object with payload 2
+
+var cargo = async.cargo(function (tasks, callback) {
+ for(var i=0; i<tasks.length; i++){
+ console.log('hello ' + tasks[i].name);
+ }
+ callback();
+}, 2);
+
+
+// add some items
+
+cargo.push({name: 'foo'}, function (err) {
+ console.log('finished processing foo');
+});
+cargo.push({name: 'bar'}, function (err) {
+ console.log('finished processing bar');
+});
+cargo.push({name: 'baz'}, function (err) {
+ console.log('finished processing baz');
+});
+```
+
+---------------------------------------
+
+<a name="auto" />
+### auto(tasks, [callback])
+
+Determines the best order for running functions based on their requirements.
+Each function can optionally depend on other functions being completed first,
+and each function is run as soon as its requirements are satisfied. If any of
+the functions pass an error to their callback, that function will not complete
+(so any other functions depending on it will not run) and the main callback
+will be called immediately with the error. Functions also receive an object
+containing the results of functions which have completed so far.
+
+Note, all functions are called with a results object as a second argument,
+so it is unsafe to pass functions in the tasks object which cannot handle the
+extra argument. For example, this snippet of code:
+
+```js
+async.auto({
+ readData: async.apply(fs.readFile, 'data.txt', 'utf-8')
+}, callback);
+```
+
+will have the effect of calling readFile with the results object as the last
+argument, which will fail:
+
+```js
+fs.readFile('data.txt', 'utf-8', cb, {});
+```
+
+Instead, wrap the call to readFile in a function which does not forward the
+results object:
+
+```js
+async.auto({
+ readData: function(cb, results){
+ fs.readFile('data.txt', 'utf-8', cb);
+ }
+}, callback);
+```
+
+__Arguments__
+
+* tasks - An object literal containing named functions or an array of
+ requirements, with the function itself the last item in the array. The key
+ used for each function or array is used when specifying requirements. The
+ function receives two arguments: (1) a callback(err, result) which must be
+ called when finished, passing an error (which can be null) and the result of
+ the function's execution, and (2) a results object, containing the results of
+ the previously executed functions.
+* callback(err, results) - An optional callback which is called when all the
+ tasks have been completed. The callback will receive an error as an argument
+ if any tasks pass an error to their callback. Results will always be passed
+ but if an error occurred, no other tasks will be performed, and the results
+ object will only contain partial results.
+
+
+__Example__
+
+```js
+async.auto({
+ get_data: function(callback){
+ // async code to get some data
+ },
+ make_folder: function(callback){
+ // async code to create a directory to store a file in
+ // this is run at the same time as getting the data
+ },
+ write_file: ['get_data', 'make_folder', function(callback){
+ // once there is some data and the directory exists,
+ // write the data to a file in the directory
+ callback(null, filename);
+ }],
+ email_link: ['write_file', function(callback, results){
+ // once the file is written let's email a link to it...
+ // results.write_file contains the filename returned by write_file.
+ }]
+});
+```
+
+This is a fairly trivial example, but to do this using the basic parallel and
+series functions would look like this:
+
+```js
+async.parallel([
+ function(callback){
+ // async code to get some data
+ },
+ function(callback){
+ // async code to create a directory to store a file in
+ // this is run at the same time as getting the data
+ }
+],
+function(err, results){
+ async.series([
+ function(callback){
+ // once there is some data and the directory exists,
+ // write the data to a file in the directory
+ },
+ function(callback){
+ // once the file is written let's email a link to it...
+ }
+ ]);
+});
+```
+
+For a complicated series of async tasks using the auto function makes adding
+new tasks much easier and makes the code more readable.
+
+
+---------------------------------------
+
+<a name="iterator" />
+### iterator(tasks)
+
+Creates an iterator function which calls the next function in the array,
+returning a continuation to call the next one after that. It's also possible to
+'peek' the next iterator by doing iterator.next().
+
+This function is used internally by the async module but can be useful when
+you want to manually control the flow of functions in series.
+
+__Arguments__
+
+* tasks - An array of functions to run.
+
+__Example__
+
+```js
+var iterator = async.iterator([
+ function(){ sys.p('one'); },
+ function(){ sys.p('two'); },
+ function(){ sys.p('three'); }
+]);
+
+node> var iterator2 = iterator();
+'one'
+node> var iterator3 = iterator2();
+'two'
+node> iterator3();
+'three'
+node> var nextfn = iterator2.next();
+node> nextfn();
+'three'
+```
+
+---------------------------------------
+
+<a name="apply" />
+### apply(function, arguments..)
+
+Creates a continuation function with some arguments already applied, a useful
+shorthand when combined with other control flow functions. Any arguments
+passed to the returned function are added to the arguments originally passed
+to apply.
+
+__Arguments__
+
+* function - The function you want to eventually apply all arguments to.
+* arguments... - Any number of arguments to automatically apply when the
+ continuation is called.
+
+__Example__
+
+```js
+// using apply
+
+async.parallel([
+ async.apply(fs.writeFile, 'testfile1', 'test1'),
+ async.apply(fs.writeFile, 'testfile2', 'test2'),
+]);
+
+
+// the same process without using apply
+
+async.parallel([
+ function(callback){
+ fs.writeFile('testfile1', 'test1', callback);
+ },
+ function(callback){
+ fs.writeFile('testfile2', 'test2', callback);
+ }
+]);
+```
+
+It's possible to pass any number of additional arguments when calling the
+continuation:
+
+```js
+node> var fn = async.apply(sys.puts, 'one');
+node> fn('two', 'three');
+one
+two
+three
+```
+
+---------------------------------------
+
+<a name="nextTick" />
+### nextTick(callback)
+
+Calls the callback on a later loop around the event loop. In node.js this just
+calls process.nextTick, in the browser it falls back to setImmediate(callback)
+if available, otherwise setTimeout(callback, 0), which means other higher priority
+events may precede the execution of the callback.
+
+This is used internally for browser-compatibility purposes.
+
+__Arguments__
+
+* callback - The function to call on a later loop around the event loop.
+
+__Example__
+
+```js
+var call_order = [];
+async.nextTick(function(){
+ call_order.push('two');
+ // call_order now equals ['one','two']
+});
+call_order.push('one')
+```
+
+<a name="times" />
+### times(n, callback)
+
+Calls the callback n times and accumulates results in the same manner
+you would use with async.map.
+
+__Arguments__
+
+* n - The number of times to run the function.
+* callback - The function to call n times.
+
+__Example__
+
+```js
+// Pretend this is some complicated async factory
+var createUser = function(id, callback) {
+ callback(null, {
+ id: 'user' + id
+ })
+}
+// generate 5 users
+async.times(5, function(n, next){
+ createUser(n, function(err, user) {
+ next(err, user)
+ })
+}, function(err, users) {
+ // we should now have 5 users
+});
+```
+
+<a name="timesSeries" />
+### timesSeries(n, callback)
+
+The same as times only the iterator is applied to each item in the array in
+series. The next iterator is only called once the current one has completed
+processing. The results array will be in the same order as the original.
+
+
+## Utils
+
+<a name="memoize" />
+### memoize(fn, [hasher])
+
+Caches the results of an async function. When creating a hash to store function
+results against, the callback is omitted from the hash and an optional hash
+function can be used.
+
+The cache of results is exposed as the `memo` property of the function returned
+by `memoize`.
+
+__Arguments__
+
+* fn - the function you to proxy and cache results from.
+* hasher - an optional function for generating a custom hash for storing
+ results, it has all the arguments applied to it apart from the callback, and
+ must be synchronous.
+
+__Example__
+
+```js
+var slow_fn = function (name, callback) {
+ // do something
+ callback(null, result);
+};
+var fn = async.memoize(slow_fn);
+
+// fn can now be used as if it were slow_fn
+fn('some name', function () {
+ // callback
+});
+```
+
+<a name="unmemoize" />
+### unmemoize(fn)
+
+Undoes a memoized function, reverting it to the original, unmemoized
+form. Comes handy in tests.
+
+__Arguments__
+
+* fn - the memoized function
+
+<a name="log" />
+### log(function, arguments)
+
+Logs the result of an async function to the console. Only works in node.js or
+in browsers that support console.log and console.error (such as FF and Chrome).
+If multiple arguments are returned from the async function, console.log is
+called on each argument in order.
+
+__Arguments__
+
+* function - The function you want to eventually apply all arguments to.
+* arguments... - Any number of arguments to apply to the function.
+
+__Example__
+
+```js
+var hello = function(name, callback){
+ setTimeout(function(){
+ callback(null, 'hello ' + name);
+ }, 1000);
+};
+```
+```js
+node> async.log(hello, 'world');
+'hello world'
+```
+
+---------------------------------------
+
+<a name="dir" />
+### dir(function, arguments)
+
+Logs the result of an async function to the console using console.dir to
+display the properties of the resulting object. Only works in node.js or
+in browsers that support console.dir and console.error (such as FF and Chrome).
+If multiple arguments are returned from the async function, console.dir is
+called on each argument in order.
+
+__Arguments__
+
+* function - The function you want to eventually apply all arguments to.
+* arguments... - Any number of arguments to apply to the function.
+
+__Example__
+
+```js
+var hello = function(name, callback){
+ setTimeout(function(){
+ callback(null, {hello: name});
+ }, 1000);
+};
+```
+```js
+node> async.dir(hello, 'world');
+{hello: 'world'}
+```
+
+---------------------------------------
+
+<a name="noConflict" />
+### noConflict()
+
+Changes the value of async back to its original value, returning a reference to the
+async object.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/component.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/component.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/component.json
new file mode 100644
index 0000000..bbb0115
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/component.json
@@ -0,0 +1,11 @@
+{
+ "name": "async",
+ "repo": "caolan/async",
+ "description": "Higher-order functions and common patterns for asynchronous code",
+ "version": "0.1.23",
+ "keywords": [],
+ "dependencies": {},
+ "development": {},
+ "main": "lib/async.js",
+ "scripts": [ "lib/async.js" ]
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/lib/async.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/lib/async.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/lib/async.js
new file mode 100755
index 0000000..1eebb15
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/node_modules/async/lib/async.js
@@ -0,0 +1,958 @@
+/*global setImmediate: false, setTimeout: false, console: false */
+(function () {
+
+ var async = {};
+
+ // global on the server, window in the browser
+ var root, previous_async;
+
+ root = this;
+ if (root != null) {
+ previous_async = root.async;
+ }
+
+ async.noConflict = function () {
+ root.async = previous_async;
+ return async;
+ };
+
+ function only_once(fn) {
+ var called = false;
+ return function() {
+ if (called) throw new Error("Callback was already called.");
+ called = true;
+ fn.apply(root, arguments);
+ }
+ }
+
+ //// cross-browser compatiblity functions ////
+
+ var _each = function (arr, iterator) {
+ if (arr.forEach) {
+ return arr.forEach(iterator);
+ }
+ for (var i = 0; i < arr.length; i += 1) {
+ iterator(arr[i], i, arr);
+ }
+ };
+
+ var _map = function (arr, iterator) {
+ if (arr.map) {
+ return arr.map(iterator);
+ }
+ var results = [];
+ _each(arr, function (x, i, a) {
+ results.push(iterator(x, i, a));
+ });
+ return results;
+ };
+
+ var _reduce = function (arr, iterator, memo) {
+ if (arr.reduce) {
+ return arr.reduce(iterator, memo);
+ }
+ _each(arr, function (x, i, a) {
+ memo = iterator(memo, x, i, a);
+ });
+ return memo;
+ };
+
+ var _keys = function (obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ }
+ var keys = [];
+ for (var k in obj) {
+ if (obj.hasOwnProperty(k)) {
+ keys.push(k);
+ }
+ }
+ return keys;
+ };
+
+ //// exported async module functions ////
+
+ //// nextTick implementation with browser-compatible fallback ////
+ if (typeof process === 'undefined' || !(process.nextTick)) {
+ if (typeof setImmediate === 'function') {
+ async.nextTick = function (fn) {
+ // not a direct alias for IE10 compatibility
+ setImmediate(fn);
+ };
+ async.setImmediate = async.nextTick;
+ }
+ else {
+ async.nextTick = function (fn) {
+ setTimeout(fn, 0);
+ };
+ async.setImmediate = async.nextTick;
+ }
+ }
+ else {
+ async.nextTick = process.nextTick;
+ if (typeof setImmediate !== 'undefined') {
+ async.setImmediate = function (fn) {
+ // not a direct alias for IE10 compatibility
+ setImmediate(fn);
+ };
+ }
+ else {
+ async.setImmediate = async.nextTick;
+ }
+ }
+
+ async.each = function (arr, iterator, callback) {
+ callback = callback || function () {};
+ if (!arr.length) {
+ return callback();
+ }
+ var completed = 0;
+ _each(arr, function (x) {
+ iterator(x, only_once(function (err) {
+ if (err) {
+ callback(err);
+ callback = function () {};
+ }
+ else {
+ completed += 1;
+ if (completed >= arr.length) {
+ callback(null);
+ }
+ }
+ }));
+ });
+ };
+ async.forEach = async.each;
+
+ async.eachSeries = function (arr, iterator, callback) {
+ callback = callback || function () {};
+ if (!arr.length) {
+ return callback();
+ }
+ var completed = 0;
+ var iterate = function () {
+ iterator(arr[completed], function (err) {
+ if (err) {
+ callback(err);
+ callback = function () {};
+ }
+ else {
+ completed += 1;
+ if (completed >= arr.length) {
+ callback(null);
+ }
+ else {
+ iterate();
+ }
+ }
+ });
+ };
+ iterate();
+ };
+ async.forEachSeries = async.eachSeries;
+
+ async.eachLimit = function (arr, limit, iterator, callback) {
+ var fn = _eachLimit(limit);
+ fn.apply(null, [arr, iterator, callback]);
+ };
+ async.forEachLimit = async.eachLimit;
+
+ var _eachLimit = function (limit) {
+
+ return function (arr, iterator, callback) {
+ callback = callback || function () {};
+ if (!arr.length || limit <= 0) {
+ return callback();
+ }
+ var completed = 0;
+ var started = 0;
+ var running = 0;
+
+ (function replenish () {
+ if (completed >= arr.length) {
+ return callback();
+ }
+
+ while (running < limit && started < arr.length) {
+ started += 1;
+ running += 1;
+ iterator(arr[started - 1], function (err) {
+ if (err) {
+ callback(err);
+ callback = function () {};
+ }
+ else {
+ completed += 1;
+ running -= 1;
+ if (completed >= arr.length) {
+ callback();
+ }
+ else {
+ replenish();
+ }
+ }
+ });
+ }
+ })();
+ };
+ };
+
+
+ var doParallel = function (fn) {
+ return function () {
+ var args = Array.prototype.slice.call(arguments);
+ return fn.apply(null, [async.each].concat(args));
+ };
+ };
+ var doParallelLimit = function(limit, fn) {
+ return function () {
+ var args = Array.prototype.slice.call(arguments);
+ return fn.apply(null, [_eachLimit(limit)].concat(args));
+ };
+ };
+ var doSeries = function (fn) {
+ return function () {
+ var args = Array.prototype.slice.call(arguments);
+ return fn.apply(null, [async.eachSeries].concat(args));
+ };
+ };
+
+
+ var _asyncMap = function (eachfn, arr, iterator, callback) {
+ var results = [];
+ arr = _map(arr, function (x, i) {
+ return {index: i, value: x};
+ });
+ eachfn(arr, function (x, callback) {
+ iterator(x.value, function (err, v) {
+ results[x.index] = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+ };
+ async.map = doParallel(_asyncMap);
+ async.mapSeries = doSeries(_asyncMap);
+ async.mapLimit = function (arr, limit, iterator, callback) {
+ return _mapLimit(limit)(arr, iterator, callback);
+ };
+
+ var _mapLimit = function(limit) {
+ return doParallelLimit(limit, _asyncMap);
+ };
+
+ // reduce only has a series version, as doing reduce in parallel won't
+ // work in many situations.
+ async.reduce = function (arr, memo, iterator, callback) {
+ async.eachSeries(arr, function (x, callback) {
+ iterator(memo, x, function (err, v) {
+ memo = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, memo);
+ });
+ };
+ // inject alias
+ async.inject = async.reduce;
+ // foldl alias
+ async.foldl = async.reduce;
+
+ async.reduceRight = function (arr, memo, iterator, callback) {
+ var reversed = _map(arr, function (x) {
+ return x;
+ }).reverse();
+ async.reduce(reversed, memo, iterator, callback);
+ };
+ // foldr alias
+ async.foldr = async.reduceRight;
+
+ var _filter = function (eachfn, arr, iterator, callback) {
+ var results = [];
+ arr = _map(arr, function (x, i) {
+ return {index: i, value: x};
+ });
+ eachfn(arr, function (x, callback) {
+ iterator(x.value, function (v) {
+ if (v) {
+ results.push(x);
+ }
+ callback();
+ });
+ }, function (err) {
+ callback(_map(results.sort(function (a, b) {
+ return a.index - b.index;
+ }), function (x) {
+ return x.value;
+ }));
+ });
+ };
+ async.filter = doParallel(_filter);
+ async.filterSeries = doSeries(_filter);
+ // select alias
+ async.select = async.filter;
+ async.selectSeries = async.filterSeries;
+
+ var _reject = function (eachfn, arr, iterator, callback) {
+ var results = [];
+ arr = _map(arr, function (x, i) {
+ return {index: i, value: x};
+ });
+ eachfn(arr, function (x, callback) {
+ iterator(x.value, function (v) {
+ if (!v) {
+ results.push(x);
+ }
+ callback();
+ });
+ }, function (err) {
+ callback(_map(results.sort(function (a, b) {
+ return a.index - b.index;
+ }), function (x) {
+ return x.value;
+ }));
+ });
+ };
+ async.reject = doParallel(_reject);
+ async.rejectSeries = doSeries(_reject);
+
+ var _detect = function (eachfn, arr, iterator, main_callback) {
+ eachfn(arr, function (x, callback) {
+ iterator(x, function (result) {
+ if (result) {
+ main_callback(x);
+ main_callback = function () {};
+ }
+ else {
+ callback();
+ }
+ });
+ }, function (err) {
+ main_callback();
+ });
+ };
+ async.detect = doParallel(_detect);
+ async.detectSeries = doSeries(_detect);
+
+ async.some = function (arr, iterator, main_callback) {
+ async.each(arr, function (x, callback) {
+ iterator(x, function (v) {
+ if (v) {
+ main_callback(true);
+ main_callback = function () {};
+ }
+ callback();
+ });
+ }, function (err) {
+ main_callback(false);
+ });
+ };
+ // any alias
+ async.any = async.some;
+
+ async.every = function (arr, iterator, main_callback) {
+ async.each(arr, function (x, callback) {
+ iterator(x, function (v) {
+ if (!v) {
+ main_callback(false);
+ main_callback = function () {};
+ }
+ callback();
+ });
+ }, function (err) {
+ main_callback(true);
+ });
+ };
+ // all alias
+ async.all = async.every;
+
+ async.sortBy = function (arr, iterator, callback) {
+ async.map(arr, function (x, callback) {
+ iterator(x, function (err, criteria) {
+ if (err) {
+ callback(err);
+ }
+ else {
+ callback(null, {value: x, criteria: criteria});
+ }
+ });
+ }, function (err, results) {
+ if (err) {
+ return callback(err);
+ }
+ else {
+ var fn = function (left, right) {
+ var a = left.criteria, b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ };
+ callback(null, _map(results.sort(fn), function (x) {
+ return x.value;
+ }));
+ }
+ });
+ };
+
+ async.auto = function (tasks, callback) {
+ callback = callback || function () {};
+ var keys = _keys(tasks);
+ if (!keys.length) {
+ return callback(null);
+ }
+
+ var results = {};
+
+ var listeners = [];
+ var addListener = function (fn) {
+ listeners.unshift(fn);
+ };
+ var removeListener = function (fn) {
+ for (var i = 0; i < listeners.length; i += 1) {
+ if (listeners[i] === fn) {
+ listeners.splice(i, 1);
+ return;
+ }
+ }
+ };
+ var taskComplete = function () {
+ _each(listeners.slice(0), function (fn) {
+ fn();
+ });
+ };
+
+ addListener(function () {
+ if (_keys(results).length === keys.length) {
+ callback(null, results);
+ callback = function () {};
+ }
+ });
+
+ _each(keys, function (k) {
+ var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k];
+ var taskCallback = function (err) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ if (err) {
+ var safeResults = {};
+ _each(_keys(results), function(rkey) {
+ safeResults[rkey] = results[rkey];
+ });
+ safeResults[k] = args;
+ callback(err, safeResults);
+ // stop subsequent errors hitting callback multiple times
+ callback = function () {};
+ }
+ else {
+ results[k] = args;
+ async.setImmediate(taskComplete);
+ }
+ };
+ var requires = task.slice(0, Math.abs(task.length - 1)) || [];
+ var ready = function () {
+ return _reduce(requires, function (a, x) {
+ return (a && results.hasOwnProperty(x));
+ }, true) && !results.hasOwnProperty(k);
+ };
+ if (ready()) {
+ task[task.length - 1](taskCallback, results);
+ }
+ else {
+ var listener = function () {
+ if (ready()) {
+ removeListener(listener);
+ task[task.length - 1](taskCallback, results);
+ }
+ };
+ addListener(listener);
+ }
+ });
+ };
+
+ async.waterfall = function (tasks, callback) {
+ callback = callback || function () {};
+ if (tasks.constructor !== Array) {
+ var err = new Error('First argument to waterfall must be an array of functions');
+ return callback(err);
+ }
+ if (!tasks.length) {
+ return callback();
+ }
+ var wrapIterator = function (iterator) {
+ return function (err) {
+ if (err) {
+ callback.apply(null, arguments);
+ callback = function () {};
+ }
+ else {
+ var args = Array.prototype.slice.call(arguments, 1);
+ var next = iterator.next();
+ if (next) {
+ args.push(wrapIterator(next));
+ }
+ else {
+ args.push(callback);
+ }
+ async.setImmediate(function () {
+ iterator.apply(null, args);
+ });
+ }
+ };
+ };
+ wrapIterator(async.iterator(tasks))();
+ };
+
+ var _parallel = function(eachfn, tasks, callback) {
+ callback = callback || function () {};
+ if (tasks.constructor === Array) {
+ eachfn.map(tasks, function (fn, callback) {
+ if (fn) {
+ fn(function (err) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ callback.call(null, err, args);
+ });
+ }
+ }, callback);
+ }
+ else {
+ var results = {};
+ eachfn.each(_keys(tasks), function (k, callback) {
+ tasks[k](function (err) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ results[k] = args;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+ }
+ };
+
+ async.parallel = function (tasks, callback) {
+ _parallel({ map: async.map, each: async.each }, tasks, callback);
+ };
+
+ async.parallelLimit = function(tasks, limit, callback) {
+ _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback);
+ };
+
+ async.series = function (tasks, callback) {
+ callback = callback || function () {};
+ if (tasks.constructor === Array) {
+ async.mapSeries(tasks, function (fn, callback) {
+ if (fn) {
+ fn(function (err) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ callback.call(null, err, args);
+ });
+ }
+ }, callback);
+ }
+ else {
+ var results = {};
+ async.eachSeries(_keys(tasks), function (k, callback) {
+ tasks[k](function (err) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ results[k] = args;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+ }
+ };
+
+ async.iterator = function (tasks) {
+ var makeCallback = function (index) {
+ var fn = function () {
+ if (tasks.length) {
+ tasks[index].apply(null, arguments);
+ }
+ return fn.next();
+ };
+ fn.next = function () {
+ return (index < tasks.length - 1) ? makeCallback(index + 1): null;
+ };
+ return fn;
+ };
+ return makeCallback(0);
+ };
+
+ async.apply = function (fn) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ return function () {
+ return fn.apply(
+ null, args.concat(Array.prototype.slice.call(arguments))
+ );
+ };
+ };
+
+ var _concat = function (eachfn, arr, fn, callback) {
+ var r = [];
+ eachfn(arr, function (x, cb) {
+ fn(x, function (err, y) {
+ r = r.concat(y || []);
+ cb(err);
+ });
+ }, function (err) {
+ callback(err, r);
+ });
+ };
+ async.concat = doParallel(_concat);
+ async.concatSeries = doSeries(_concat);
+
+ async.whilst = function (test, iterator, callback) {
+ if (test()) {
+ iterator(function (err) {
+ if (err) {
+ return callback(err);
+ }
+ async.whilst(test, iterator, callback);
+ });
+ }
+ else {
+ callback();
+ }
+ };
+
+ async.doWhilst = function (iterator, test, callback) {
+ iterator(function (err) {
+ if (err) {
+ return callback(err);
+ }
+ if (test()) {
+ async.doWhilst(iterator, test, callback);
+ }
+ else {
+ callback();
+ }
+ });
+ };
+
+ async.until = function (test, iterator, callback) {
+ if (!test()) {
+ iterator(function (err) {
+ if (err) {
+ return callback(err);
+ }
+ async.until(test, iterator, callback);
+ });
+ }
+ else {
+ callback();
+ }
+ };
+
+ async.doUntil = function (iterator, test, callback) {
+ iterator(function (err) {
+ if (err) {
+ return callback(err);
+ }
+ if (!test()) {
+ async.doUntil(iterator, test, callback);
+ }
+ else {
+ callback();
+ }
+ });
+ };
+
+ async.queue = function (worker, concurrency) {
+ if (concurrency === undefined) {
+ concurrency = 1;
+ }
+ function _insert(q, data, pos, callback) {
+ if(data.constructor !== Array) {
+ data = [data];
+ }
+ _each(data, function(task) {
+ var item = {
+ data: task,
+ callback: typeof callback === 'function' ? callback : null
+ };
+
+ if (pos) {
+ q.tasks.unshift(item);
+ } else {
+ q.tasks.push(item);
+ }
+
+ if (q.saturated && q.tasks.length === concurrency) {
+ q.saturated();
+ }
+ async.setImmediate(q.process);
+ });
+ }
+
+ var workers = 0;
+ var q = {
+ tasks: [],
+ concurrency: concurrency,
+ saturated: null,
+ empty: null,
+ drain: null,
+ push: function (data, callback) {
+ _insert(q, data, false, callback);
+ },
+ unshift: function (data, callback) {
+ _insert(q, data, true, callback);
+ },
+ process: function () {
+ if (workers < q.concurrency && q.tasks.length) {
+ var task = q.tasks.shift();
+ if (q.empty && q.tasks.length === 0) {
+ q.empty();
+ }
+ workers += 1;
+ var next = function () {
+ workers -= 1;
+ if (task.callback) {
+ task.callback.apply(task, arguments);
+ }
+ if (q.drain && q.tasks.length + workers === 0) {
+ q.drain();
+ }
+ q.process();
+ };
+ var cb = only_once(next);
+ worker(task.data, cb);
+ }
+ },
+ length: function () {
+ return q.tasks.length;
+ },
+ running: function () {
+ return workers;
+ }
+ };
+ return q;
+ };
+
+ async.cargo = function (worker, payload) {
+ var working = false,
+ tasks = [];
+
+ var cargo = {
+ tasks: tasks,
+ payload: payload,
+ saturated: null,
+ empty: null,
+ drain: null,
+ push: function (data, callback) {
+ if(data.constructor !== Array) {
+ data = [data];
+ }
+ _each(data, function(task) {
+ tasks.push({
+ data: task,
+ callback: typeof callback === 'function' ? callback : null
+ });
+ if (cargo.saturated && tasks.length === payload) {
+ cargo.saturated();
+ }
+ });
+ async.setImmediate(cargo.process);
+ },
+ process: function process() {
+ if (working) return;
+ if (tasks.length === 0) {
+ if(cargo.drain) cargo.drain();
+ return;
+ }
+
+ var ts = typeof payload === 'number'
+ ? tasks.splice(0, payload)
+ : tasks.splice(0);
+
+ var ds = _map(ts, function (task) {
+ return task.data;
+ });
+
+ if(cargo.empty) cargo.empty();
+ working = true;
+ worker(ds, function () {
+ working = false;
+
+ var args = arguments;
+ _each(ts, function (data) {
+ if (data.callback) {
+ data.callback.apply(null, args);
+ }
+ });
+
+ process();
+ });
+ },
+ length: function () {
+ return tasks.length;
+ },
+ running: function () {
+ return working;
+ }
+ };
+ return cargo;
+ };
+
+ var _console_fn = function (name) {
+ return function (fn) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ fn.apply(null, args.concat([function (err) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ if (typeof console !== 'undefined') {
+ if (err) {
+ if (console.error) {
+ console.error(err);
+ }
+ }
+ else if (console[name]) {
+ _each(args, function (x) {
+ console[name](x);
+ });
+ }
+ }
+ }]));
+ };
+ };
+ async.log = _console_fn('log');
+ async.dir = _console_fn('dir');
+ /*async.info = _console_fn('info');
+ async.warn = _console_fn('warn');
+ async.error = _console_fn('error');*/
+
+ async.memoize = function (fn, hasher) {
+ var memo = {};
+ var queues = {};
+ hasher = hasher || function (x) {
+ return x;
+ };
+ var memoized = function () {
+ var args = Array.prototype.slice.call(arguments);
+ var callback = args.pop();
+ var key = hasher.apply(null, args);
+ if (key in memo) {
+ callback.apply(null, memo[key]);
+ }
+ else if (key in queues) {
+ queues[key].push(callback);
+ }
+ else {
+ queues[key] = [callback];
+ fn.apply(null, args.concat([function () {
+ memo[key] = arguments;
+ var q = queues[key];
+ delete queues[key];
+ for (var i = 0, l = q.length; i < l; i++) {
+ q[i].apply(null, arguments);
+ }
+ }]));
+ }
+ };
+ memoized.memo = memo;
+ memoized.unmemoized = fn;
+ return memoized;
+ };
+
+ async.unmemoize = function (fn) {
+ return function () {
+ return (fn.unmemoized || fn).apply(null, arguments);
+ };
+ };
+
+ async.times = function (count, iterator, callback) {
+ var counter = [];
+ for (var i = 0; i < count; i++) {
+ counter.push(i);
+ }
+ return async.map(counter, iterator, callback);
+ };
+
+ async.timesSeries = function (count, iterator, callback) {
+ var counter = [];
+ for (var i = 0; i < count; i++) {
+ counter.push(i);
+ }
+ return async.mapSeries(counter, iterator, callback);
+ };
+
+ async.compose = function (/* functions... */) {
+ var fns = Array.prototype.reverse.call(arguments);
+ return function () {
+ var that = this;
+ var args = Array.prototype.slice.call(arguments);
+ var callback = args.pop();
+ async.reduce(fns, args, function (newargs, fn, cb) {
+ fn.apply(that, newargs.concat([function () {
+ var err = arguments[0];
+ var nextargs = Array.prototype.slice.call(arguments, 1);
+ cb(err, nextargs);
+ }]))
+ },
+ function (err, results) {
+ callback.apply(that, [err].concat(results));
+ });
+ };
+ };
+
+ var _applyEach = function (eachfn, fns /*args...*/) {
+ var go = function () {
+ var that = this;
+ var args = Array.prototype.slice.call(arguments);
+ var callback = args.pop();
+ return eachfn(fns, function (fn, cb) {
+ fn.apply(that, args.concat([cb]));
+ },
+ callback);
+ };
+ if (arguments.length > 2) {
+ var args = Array.prototype.slice.call(arguments, 2);
+ return go.apply(this, args);
+ }
+ else {
+ return go;
+ }
+ };
+ async.applyEach = doParallel(_applyEach);
+ async.applyEachSeries = doSeries(_applyEach);
+
+ async.forever = function (fn, callback) {
+ function next(err) {
+ if (err) {
+ if (callback) {
+ return callback(err);
+ }
+ throw err;
+ }
+ fn(next);
+ }
+ next();
+ };
+
+ // AMD / RequireJS
+ if (typeof define !== 'undefined' && define.amd) {
+ define([], function () {
+ return async;
+ });
+ }
+ // Node.js
+ else if (typeof module !== 'undefined' && module.exports) {
+ module.exports = async;
+ }
+ // included directly via <script> tag
+ else {
+ root.async = async;
+ }
+
+}());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[43/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jslint.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jslint.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jslint.js
new file mode 100644
index 0000000..f563292
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/lib/jslint.js
@@ -0,0 +1,5504 @@
+// jslint.js
+// 2010-02-20
+
+/*
+Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+/*
+ JSLINT is a global function. It takes two parameters.
+
+ var myResult = JSLINT(source, option);
+
+ The first parameter is either a string or an array of strings. If it is a
+ string, it will be split on '\n' or '\r'. If it is an array of strings, it
+ is assumed that each string represents one line. The source can be a
+ JavaScript text, or HTML text, or a Konfabulator text.
+
+ The second parameter is an optional object of options which control the
+ operation of JSLINT. Most of the options are booleans: They are all are
+ optional and have a default value of false.
+
+ If it checks out, JSLINT returns true. Otherwise, it returns false.
+
+ If false, you can inspect JSLINT.errors to find out the problems.
+ JSLINT.errors is an array of objects containing these members:
+
+ {
+ line : The line (relative to 0) at which the lint was found
+ character : The character (relative to 0) at which the lint was found
+ reason : The problem
+ evidence : The text line in which the problem occurred
+ raw : The raw message before the details were inserted
+ a : The first detail
+ b : The second detail
+ c : The third detail
+ d : The fourth detail
+ }
+
+ If a fatal error was found, a null will be the last element of the
+ JSLINT.errors array.
+
+ You can request a Function Report, which shows all of the functions
+ and the parameters and vars that they use. This can be used to find
+ implied global variables and other problems. The report is in HTML and
+ can be inserted in an HTML <body>.
+
+ var myReport = JSLINT.report(limited);
+
+ If limited is true, then the report will be limited to only errors.
+
+ You can request a data structure which contains JSLint's results.
+
+ var myData = JSLINT.data();
+
+ It returns a structure with this form:
+
+ {
+ errors: [
+ {
+ line: NUMBER,
+ character: NUMBER,
+ reason: STRING,
+ evidence: STRING
+ }
+ ],
+ functions: [
+ name: STRING,
+ line: NUMBER,
+ last: NUMBER,
+ param: [
+ STRING
+ ],
+ closure: [
+ STRING
+ ],
+ var: [
+ STRING
+ ],
+ exception: [
+ STRING
+ ],
+ outer: [
+ STRING
+ ],
+ unused: [
+ STRING
+ ],
+ global: [
+ STRING
+ ],
+ label: [
+ STRING
+ ]
+ ],
+ globals: [
+ STRING
+ ],
+ member: {
+ STRING: NUMBER
+ },
+ unuseds: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ implieds: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ urls: [
+ STRING
+ ],
+ json: BOOLEAN
+ }
+
+ Empty arrays will not be included.
+
+*/
+
+/*jslint
+ evil: true, nomen: false, onevar: false, regexp: false, strict: true
+*/
+
+/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
+ "(begin)", "(breakage)", "(context)", "(error)", "(global)",
+ "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
+ "(params)", "(scope)", "(verb)", "*", "+", "++", "-", "--", "\/",
+ "<", "<=", "==", "===", ">", ">=", ADSAFE, Array, Boolean,
+ COM, Canvas, CustomAnimation, Date, Debug, E, Error, EvalError,
+ FadeAnimation, Flash, FormField, Frame, Function, HotKey, Image, JSON,
+ LN10, LN2, LOG10E, LOG2E, MAX_VALUE, MIN_VALUE, Math, MenuItem,
+ MoveAnimation, NEGATIVE_INFINITY, Number, Object, Option, PI,
+ POSITIVE_INFINITY, Point, RangeError, Rectangle, ReferenceError, RegExp,
+ ResizeAnimation, RotateAnimation, SQRT1_2, SQRT2, ScrollBar, String,
+ Style, SyntaxError, System, Text, TextArea, Timer, TypeError, URIError,
+ URL, Web, Window, XMLDOM, XMLHttpRequest, "\\", a, abbr, acronym,
+ addEventListener, address, adsafe, alert, aliceblue, animator,
+ antiquewhite, appleScript, applet, apply, approved, aqua, aquamarine,
+ area, arguments, arity, autocomplete, azure, b, background,
+ "background-attachment", "background-color", "background-image",
+ "background-position", "background-repeat", base, bdo, beep, beige, big,
+ bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
+ blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
+ "border-bottom-style", "border-bottom-width", "border-collapse",
+ "border-color", "border-left", "border-left-color", "border-left-style",
+ "border-left-width", "border-right", "border-right-color",
+ "border-right-style", "border-right-width", "border-spacing",
+ "border-style", "border-top", "border-top-color", "border-top-style",
+ "border-top-width", "border-width", bottom, br, brown, browser,
+ burlywood, button, bytesToUIString, c, cadetblue, call, callee, caller,
+ canvas, cap, caption, "caption-side", cases, center, charAt, charCodeAt,
+ character, chartreuse, chocolate, chooseColor, chooseFile, chooseFolder,
+ cite, clear, clearInterval, clearTimeout, clip, close, closeWidget,
+ closed, closure, cm, code, col, colgroup, color, comment, condition,
+ confirm, console, constructor, content, convertPathToHFS,
+ convertPathToPlatform, coral, cornflowerblue, cornsilk,
+ "counter-increment", "counter-reset", create, crimson, css, cursor,
+ cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
+ darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
+ darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
+ darkviolet, data, dd, debug, decodeURI, decodeURIComponent, deeppink,
+ deepskyblue, defaultStatus, defineClass, del, deserialize, devel, dfn,
+ dimension, dimgray, dir, direction, display, div, dl, document,
+ dodgerblue, dt, edition, else, em, embed, empty, "empty-cells",
+ encodeURI, encodeURIComponent, entityify, eqeqeq, errors, escape, eval,
+ event, evidence, evil, ex, exception, exec, exps, fieldset, filesystem,
+ firebrick, first, float, floor, floralwhite, focus, focusWidget, font,
+ "font-face", "font-family", "font-size", "font-size-adjust",
+ "font-stretch", "font-style", "font-variant", "font-weight",
+ forestgreen, forin, form, fragment, frame, frames, frameset, from,
+ fromCharCode, fuchsia, fud, funct, function, functions, g, gainsboro,
+ gc, getComputedStyle, ghostwhite, global, globals, gold, goldenrod,
+ gray, green, greenyellow, h1, h2, h3, h4, h5, h6, hasOwnProperty, head,
+ height, help, history, honeydew, hotpink, hr, html, i, iTunes, id,
+ identifier, iframe, img, immed, implieds, in, include, indent, indexOf,
+ indianred, indigo, init, input, ins, isAlpha, isApplicationRunning,
+ isDigit, isFinite, isNaN, ivory, join, jslint, json, kbd, khaki,
+ konfabulatorVersion, label, labelled, lang, last, lavender,
+ lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
+ lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
+ lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
+ lightseagreen, lightskyblue, lightslategray, lightsteelblue,
+ lightyellow, lime, limegreen, line, "line-height", linen, link,
+ "list-style", "list-style-image", "list-style-position",
+ "list-style-type", load, loadClass, location, log, m, magenta, map,
+ margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
+ "marker-offset", maroon, match, "max-height", "max-width", maxerr, maxlen,
+ md5, media, mediumaquamarine, mediumblue, mediumorchid, mediumpurple,
+ mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise,
+ mediumvioletred, member, menu, message, meta, midnightblue,
+ "min-height", "min-width", mintcream, mistyrose, mm, moccasin, moveBy,
+ moveTo, name, navajowhite, navigator, navy, new, newcap, noframes,
+ nomen, noscript, nud, object, ol, oldlace, olive, olivedrab, on,
+ onbeforeunload, onblur, onerror, onevar, onfocus, onload, onresize,
+ onunload, opacity, open, openURL, opener, opera, optgroup, option,
+ orange, orangered, orchid, outer, outline, "outline-color",
+ "outline-style", "outline-width", overflow, "overflow-x", "overflow-y",
+ p, padding, "padding-bottom", "padding-left", "padding-right",
+ "padding-top", page, "page-break-after", "page-break-before",
+ palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip,
+ param, parent, parseFloat, parseInt, passfail, pc, peachpuff, peru,
+ pink, play, plum, plusplus, pop, popupMenu, position, powderblue, pre,
+ predef, preferenceGroups, preferences, print, prompt, prototype, pt,
+ purple, push, px, q, quit, quotes, random, range, raw, reach, readFile,
+ readUrl, reason, red, regexp, reloadWidget, removeEventListener,
+ replace, report, reserved, resizeBy, resizeTo, resolvePath,
+ resumeUpdates, rhino, right, rosybrown, royalblue, runCommand,
+ runCommandInBg, saddlebrown, safe, salmon, samp, sandybrown, saveAs,
+ savePreferences, screen, script, scroll, scrollBy, scrollTo, seagreen,
+ seal, search, seashell, select, serialize, setInterval, setTimeout,
+ shift, showWidgetPreferences, sidebar, sienna, silver, skyblue,
+ slateblue, slategray, sleep, slice, small, snow, sort, span, spawn,
+ speak, split, springgreen, src, status, steelblue, strict, strong,
+ style, styleproperty, sub, substr, sup, supplant, suppressUpdates, sync,
+ system, table, "table-layout", tan, tbody, td, teal, tellWidget, test,
+ "text-align", "text-decoration", "text-indent", "text-shadow",
+ "text-transform", textarea, tfoot, th, thead, thistle, title,
+ toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
+ turquoise, type, u, ul, undef, unescape, "unicode-bidi", unused,
+ unwatch, updateNow, urls, value, valueOf, var, version,
+ "vertical-align", violet, visibility, watch, wheat, white,
+ "white-space", whitesmoke, widget, width, "word-spacing", "word-wrap",
+ yahooCheckLogin, yahooLogin, yahooLogout, yellow, yellowgreen,
+ "z-index"
+*/
+
+
+// We build the application inside a function so that we produce only a single
+// global variable. The function will be invoked, its return value is the JSLINT
+// application itself.
+
+"use strict";
+
+var JSLINT = (function () {
+ var adsafe_id, // The widget's ADsafe id.
+ adsafe_may, // The widget may load approved scripts.
+ adsafe_went, // ADSAFE.go has been called.
+ anonname, // The guessed name for anonymous functions.
+ approved, // ADsafe approved urls.
+
+ atrule = {
+ media : true,
+ 'font-face': true,
+ page : true
+ },
+
+// These are operators that should not be used with the ! operator.
+
+ bang = {
+ '<': true,
+ '<=': true,
+ '==': true,
+ '===': true,
+ '!==': true,
+ '!=': true,
+ '>': true,
+ '>=': true,
+ '+': true,
+ '-': true,
+ '*': true,
+ '/': true,
+ '%': true
+ },
+
+// These are members that should not be permitted in the safe subset.
+
+ banned = { // the member names that ADsafe prohibits.
+ 'arguments' : true,
+ callee : true,
+ caller : true,
+ constructor : true,
+ 'eval' : true,
+ prototype : true,
+ unwatch : true,
+ valueOf : true,
+ watch : true
+ },
+
+
+// These are the JSLint boolean options.
+
+ boolOptions = {
+ adsafe : true, // if ADsafe should be enforced
+ bitwise : true, // if bitwise operators should not be allowed
+ browser : true, // if the standard browser globals should be predefined
+ cap : true, // if upper case HTML should be allowed
+ css : true, // if CSS workarounds should be tolerated
+ debug : true, // if debugger statements should be allowed
+ devel : true, // if logging should be allowed (console, alert, etc.)
+ eqeqeq : true, // if === should be required
+ evil : true, // if eval should be allowed
+ forin : true, // if for in statements must filter
+ fragment : true, // if HTML fragments should be allowed
+ immed : true, // if immediate invocations must be wrapped in parens
+ laxbreak : true, // if line breaks should not be checked
+ newcap : true, // if constructor names must be capitalized
+ nomen : true, // if names should be checked
+ on : true, // if HTML event handlers should be allowed
+ onevar : true, // if only one var statement per function should be allowed
+ passfail : true, // if the scan should stop on first error
+ plusplus : true, // if increment/decrement should not be allowed
+ regexp : true, // if the . should not be allowed in regexp literals
+ rhino : true, // if the Rhino environment globals should be predefined
+ undef : true, // if variables should be declared before used
+ safe : true, // if use of some browser features should be restricted
+ sidebar : true, // if the System object should be predefined
+ strict : true, // require the "use strict"; pragma
+ sub : true, // if all forms of subscript notation are tolerated
+ white : true, // if strict whitespace rules apply
+ widget : true // if the Yahoo Widgets globals should be predefined
+ },
+
+// browser contains a set of global names which are commonly provided by a
+// web browser environment.
+
+ browser = {
+ addEventListener: false,
+ blur : false,
+ clearInterval : false,
+ clearTimeout : false,
+ close : false,
+ closed : false,
+ defaultStatus : false,
+ document : false,
+ event : false,
+ focus : false,
+ frames : false,
+ getComputedStyle: false,
+ history : false,
+ Image : false,
+ length : false,
+ location : false,
+ moveBy : false,
+ moveTo : false,
+ name : false,
+ navigator : false,
+ onbeforeunload : true,
+ onblur : true,
+ onerror : true,
+ onfocus : true,
+ onload : true,
+ onresize : true,
+ onunload : true,
+ open : false,
+ opener : false,
+ Option : false,
+ parent : false,
+ print : false,
+ removeEventListener: false,
+ resizeBy : false,
+ resizeTo : false,
+ screen : false,
+ scroll : false,
+ scrollBy : false,
+ scrollTo : false,
+ setInterval : false,
+ setTimeout : false,
+ status : false,
+ top : false,
+ XMLHttpRequest : false
+ },
+
+ cssAttributeData,
+ cssAny,
+
+ cssColorData = {
+ "aliceblue" : true,
+ "antiquewhite" : true,
+ "aqua" : true,
+ "aquamarine" : true,
+ "azure" : true,
+ "beige" : true,
+ "bisque" : true,
+ "black" : true,
+ "blanchedalmond" : true,
+ "blue" : true,
+ "blueviolet" : true,
+ "brown" : true,
+ "burlywood" : true,
+ "cadetblue" : true,
+ "chartreuse" : true,
+ "chocolate" : true,
+ "coral" : true,
+ "cornflowerblue" : true,
+ "cornsilk" : true,
+ "crimson" : true,
+ "cyan" : true,
+ "darkblue" : true,
+ "darkcyan" : true,
+ "darkgoldenrod" : true,
+ "darkgray" : true,
+ "darkgreen" : true,
+ "darkkhaki" : true,
+ "darkmagenta" : true,
+ "darkolivegreen" : true,
+ "darkorange" : true,
+ "darkorchid" : true,
+ "darkred" : true,
+ "darksalmon" : true,
+ "darkseagreen" : true,
+ "darkslateblue" : true,
+ "darkslategray" : true,
+ "darkturquoise" : true,
+ "darkviolet" : true,
+ "deeppink" : true,
+ "deepskyblue" : true,
+ "dimgray" : true,
+ "dodgerblue" : true,
+ "firebrick" : true,
+ "floralwhite" : true,
+ "forestgreen" : true,
+ "fuchsia" : true,
+ "gainsboro" : true,
+ "ghostwhite" : true,
+ "gold" : true,
+ "goldenrod" : true,
+ "gray" : true,
+ "green" : true,
+ "greenyellow" : true,
+ "honeydew" : true,
+ "hotpink" : true,
+ "indianred" : true,
+ "indigo" : true,
+ "ivory" : true,
+ "khaki" : true,
+ "lavender" : true,
+ "lavenderblush" : true,
+ "lawngreen" : true,
+ "lemonchiffon" : true,
+ "lightblue" : true,
+ "lightcoral" : true,
+ "lightcyan" : true,
+ "lightgoldenrodyellow" : true,
+ "lightgreen" : true,
+ "lightpink" : true,
+ "lightsalmon" : true,
+ "lightseagreen" : true,
+ "lightskyblue" : true,
+ "lightslategray" : true,
+ "lightsteelblue" : true,
+ "lightyellow" : true,
+ "lime" : true,
+ "limegreen" : true,
+ "linen" : true,
+ "magenta" : true,
+ "maroon" : true,
+ "mediumaquamarine" : true,
+ "mediumblue" : true,
+ "mediumorchid" : true,
+ "mediumpurple" : true,
+ "mediumseagreen" : true,
+ "mediumslateblue" : true,
+ "mediumspringgreen" : true,
+ "mediumturquoise" : true,
+ "mediumvioletred" : true,
+ "midnightblue" : true,
+ "mintcream" : true,
+ "mistyrose" : true,
+ "moccasin" : true,
+ "navajowhite" : true,
+ "navy" : true,
+ "oldlace" : true,
+ "olive" : true,
+ "olivedrab" : true,
+ "orange" : true,
+ "orangered" : true,
+ "orchid" : true,
+ "palegoldenrod" : true,
+ "palegreen" : true,
+ "paleturquoise" : true,
+ "palevioletred" : true,
+ "papayawhip" : true,
+ "peachpuff" : true,
+ "peru" : true,
+ "pink" : true,
+ "plum" : true,
+ "powderblue" : true,
+ "purple" : true,
+ "red" : true,
+ "rosybrown" : true,
+ "royalblue" : true,
+ "saddlebrown" : true,
+ "salmon" : true,
+ "sandybrown" : true,
+ "seagreen" : true,
+ "seashell" : true,
+ "sienna" : true,
+ "silver" : true,
+ "skyblue" : true,
+ "slateblue" : true,
+ "slategray" : true,
+ "snow" : true,
+ "springgreen" : true,
+ "steelblue" : true,
+ "tan" : true,
+ "teal" : true,
+ "thistle" : true,
+ "tomato" : true,
+ "turquoise" : true,
+ "violet" : true,
+ "wheat" : true,
+ "white" : true,
+ "whitesmoke" : true,
+ "yellow" : true,
+ "yellowgreen" : true
+ },
+
+ cssBorderStyle,
+ cssBreak,
+
+ cssLengthData = {
+ '%': true,
+ 'cm': true,
+ 'em': true,
+ 'ex': true,
+ 'in': true,
+ 'mm': true,
+ 'pc': true,
+ 'pt': true,
+ 'px': true
+ },
+
+ cssOverflow,
+
+ devel = {
+ alert : false,
+ confirm : false,
+ console : false,
+ Debug : false,
+ opera : false,
+ prompt : false
+ },
+
+ escapes = {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '/' : '\\/',
+ '\\': '\\\\'
+ },
+
+ funct, // The current function
+
+ functionicity = [
+ 'closure', 'exception', 'global', 'label',
+ 'outer', 'unused', 'var'
+ ],
+
+ functions, // All of the functions
+
+ global, // The global scope
+ htmltag = {
+ a: {},
+ abbr: {},
+ acronym: {},
+ address: {},
+ applet: {},
+ area: {empty: true, parent: ' map '},
+ b: {},
+ base: {empty: true, parent: ' head '},
+ bdo: {},
+ big: {},
+ blockquote: {},
+ body: {parent: ' html noframes '},
+ br: {empty: true},
+ button: {},
+ canvas: {parent: ' body p div th td '},
+ caption: {parent: ' table '},
+ center: {},
+ cite: {},
+ code: {},
+ col: {empty: true, parent: ' table colgroup '},
+ colgroup: {parent: ' table '},
+ dd: {parent: ' dl '},
+ del: {},
+ dfn: {},
+ dir: {},
+ div: {},
+ dl: {},
+ dt: {parent: ' dl '},
+ em: {},
+ embed: {},
+ fieldset: {},
+ font: {},
+ form: {},
+ frame: {empty: true, parent: ' frameset '},
+ frameset: {parent: ' html frameset '},
+ h1: {},
+ h2: {},
+ h3: {},
+ h4: {},
+ h5: {},
+ h6: {},
+ head: {parent: ' html '},
+ html: {parent: '*'},
+ hr: {empty: true},
+ i: {},
+ iframe: {},
+ img: {empty: true},
+ input: {empty: true},
+ ins: {},
+ kbd: {},
+ label: {},
+ legend: {parent: ' fieldset '},
+ li: {parent: ' dir menu ol ul '},
+ link: {empty: true, parent: ' head '},
+ map: {},
+ menu: {},
+ meta: {empty: true, parent: ' head noframes noscript '},
+ noframes: {parent: ' html body '},
+ noscript: {parent: ' body head noframes '},
+ object: {},
+ ol: {},
+ optgroup: {parent: ' select '},
+ option: {parent: ' optgroup select '},
+ p: {},
+ param: {empty: true, parent: ' applet object '},
+ pre: {},
+ q: {},
+ samp: {},
+ script: {empty: true, parent: ' body div frame head iframe p pre span '},
+ select: {},
+ small: {},
+ span: {},
+ strong: {},
+ style: {parent: ' head ', empty: true},
+ sub: {},
+ sup: {},
+ table: {},
+ tbody: {parent: ' table '},
+ td: {parent: ' tr '},
+ textarea: {},
+ tfoot: {parent: ' table '},
+ th: {parent: ' tr '},
+ thead: {parent: ' table '},
+ title: {parent: ' head '},
+ tr: {parent: ' table tbody thead tfoot '},
+ tt: {},
+ u: {},
+ ul: {},
+ 'var': {}
+ },
+
+ ids, // HTML ids
+ implied, // Implied globals
+ inblock,
+ indent,
+ jsonmode,
+ lines,
+ lookahead,
+ member,
+ membersOnly,
+ nexttoken,
+ noreach,
+ option,
+ predefined, // Global variables defined by option
+ prereg,
+ prevtoken,
+
+ rhino = {
+ defineClass : false,
+ deserialize : false,
+ gc : false,
+ help : false,
+ load : false,
+ loadClass : false,
+ print : false,
+ quit : false,
+ readFile : false,
+ readUrl : false,
+ runCommand : false,
+ seal : false,
+ serialize : false,
+ spawn : false,
+ sync : false,
+ toint32 : false,
+ version : false
+ },
+
+ scope, // The current scope
+
+ sidebar = {
+ System : false
+ },
+
+ src,
+ stack,
+
+// standard contains the global names that are provided by the
+// ECMAScript standard.
+
+ standard = {
+ Array : false,
+ Boolean : false,
+ Date : false,
+ decodeURI : false,
+ decodeURIComponent : false,
+ encodeURI : false,
+ encodeURIComponent : false,
+ Error : false,
+ 'eval' : false,
+ EvalError : false,
+ Function : false,
+ hasOwnProperty : false,
+ isFinite : false,
+ isNaN : false,
+ JSON : false,
+ Math : false,
+ Number : false,
+ Object : false,
+ parseInt : false,
+ parseFloat : false,
+ RangeError : false,
+ ReferenceError : false,
+ RegExp : false,
+ String : false,
+ SyntaxError : false,
+ TypeError : false,
+ URIError : false
+ },
+
+ standard_member = {
+ E : true,
+ LN2 : true,
+ LN10 : true,
+ LOG2E : true,
+ LOG10E : true,
+ PI : true,
+ SQRT1_2 : true,
+ SQRT2 : true,
+ MAX_VALUE : true,
+ MIN_VALUE : true,
+ NEGATIVE_INFINITY : true,
+ POSITIVE_INFINITY : true
+ },
+
+ strict_mode,
+ syntax = {},
+ tab,
+ token,
+ urls,
+ warnings,
+
+// widget contains the global names which are provided to a Yahoo
+// (fna Konfabulator) widget.
+
+ widget = {
+ alert : true,
+ animator : true,
+ appleScript : true,
+ beep : true,
+ bytesToUIString : true,
+ Canvas : true,
+ chooseColor : true,
+ chooseFile : true,
+ chooseFolder : true,
+ closeWidget : true,
+ COM : true,
+ convertPathToHFS : true,
+ convertPathToPlatform : true,
+ CustomAnimation : true,
+ escape : true,
+ FadeAnimation : true,
+ filesystem : true,
+ Flash : true,
+ focusWidget : true,
+ form : true,
+ FormField : true,
+ Frame : true,
+ HotKey : true,
+ Image : true,
+ include : true,
+ isApplicationRunning : true,
+ iTunes : true,
+ konfabulatorVersion : true,
+ log : true,
+ md5 : true,
+ MenuItem : true,
+ MoveAnimation : true,
+ openURL : true,
+ play : true,
+ Point : true,
+ popupMenu : true,
+ preferenceGroups : true,
+ preferences : true,
+ print : true,
+ prompt : true,
+ random : true,
+ Rectangle : true,
+ reloadWidget : true,
+ ResizeAnimation : true,
+ resolvePath : true,
+ resumeUpdates : true,
+ RotateAnimation : true,
+ runCommand : true,
+ runCommandInBg : true,
+ saveAs : true,
+ savePreferences : true,
+ screen : true,
+ ScrollBar : true,
+ showWidgetPreferences : true,
+ sleep : true,
+ speak : true,
+ Style : true,
+ suppressUpdates : true,
+ system : true,
+ tellWidget : true,
+ Text : true,
+ TextArea : true,
+ Timer : true,
+ unescape : true,
+ updateNow : true,
+ URL : true,
+ Web : true,
+ widget : true,
+ Window : true,
+ XMLDOM : true,
+ XMLHttpRequest : true,
+ yahooCheckLogin : true,
+ yahooLogin : true,
+ yahooLogout : true
+ },
+
+// xmode is used to adapt to the exceptions in html parsing.
+// It can have these states:
+// false .js script file
+// html
+// outer
+// script
+// style
+// scriptstring
+// styleproperty
+
+ xmode,
+ xquote,
+
+// unsafe comment or string
+ ax = /@cc|<\/?|script|\]*s\]|<\s*!|</i,
+// unsafe characters that are silently deleted by one or more browsers
+ cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
+// token
+ tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+[+=]?|-[\-=]?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
+// html token
+//////// hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-]*|[0-9]+|--|.)/,
+ hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-]*|[0-9]+|--)/,
+// characters in strings that need escapement
+ nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
+ nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+// outer html token
+ ox = /[>&]|<[\/!]?|--/,
+// star slash
+ lx = /\*\/|\/\*/,
+// identifier
+ ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
+// javascript url
+ jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
+// url badness
+ ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i,
+// style
+ sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
+ ssx = /^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/,
+// attributes characters
+ qx = /[^a-zA-Z0-9-_\/ ]/,
+// query characters for ids
+ dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
+
+ rx = {
+ outer: hx,
+ html: hx,
+ style: sx,
+ styleproperty: ssx
+ };
+
+ function F() {}
+
+ if (typeof Object.create !== 'function') {
+ Object.create = function (o) {
+ F.prototype = o;
+ return new F();
+ };
+ }
+
+
+ function is_own(object, name) {
+ return Object.prototype.hasOwnProperty.call(object, name);
+ }
+
+
+ function combine(t, o) {
+ var n;
+ for (n in o) {
+ if (is_own(o, n)) {
+ t[n] = o[n];
+ }
+ }
+ }
+
+ String.prototype.entityify = function () {
+ return this.
+ replace(/&/g, '&').
+ replace(/</g, '<').
+ replace(/>/g, '>');
+ };
+
+ String.prototype.isAlpha = function () {
+ return (this >= 'a' && this <= 'z\uffff') ||
+ (this >= 'A' && this <= 'Z\uffff');
+ };
+
+
+ String.prototype.isDigit = function () {
+ return (this >= '0' && this <= '9');
+ };
+
+
+ String.prototype.supplant = function (o) {
+ return this.replace(/\{([^{}]*)\}/g, function (a, b) {
+ var r = o[b];
+ return typeof r === 'string' || typeof r === 'number' ? r : a;
+ });
+ };
+
+ String.prototype.name = function () {
+
+// If the string looks like an identifier, then we can return it as is.
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can simply slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe
+// sequences.
+
+ if (ix.test(this)) {
+ return this;
+ }
+ if (nx.test(this)) {
+ return '"' + this.replace(nxg, function (a) {
+ var c = escapes[a];
+ if (c) {
+ return c;
+ }
+ return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
+ }) + '"';
+ }
+ return '"' + this + '"';
+ };
+
+
+ function assume() {
+ if (!option.safe) {
+ if (option.rhino) {
+ combine(predefined, rhino);
+ }
+ if (option.devel) {
+ combine(predefined, devel);
+ }
+ if (option.browser || option.sidebar) {
+ combine(predefined, browser);
+ }
+ if (option.sidebar) {
+ combine(predefined, sidebar);
+ }
+ if (option.widget) {
+ combine(predefined, widget);
+ }
+ }
+ }
+
+
+// Produce an error warning.
+
+ function quit(m, l, ch) {
+ throw {
+ name: 'JSLintError',
+ line: l,
+ character: ch,
+ message: m + " (" + Math.floor((l / lines.length) * 100) +
+ "% scanned)."
+ };
+ }
+
+ function warning(m, t, a, b, c, d) {
+ var ch, l, w;
+ t = t || nexttoken;
+ if (t.id === '(end)') { // `~
+ t = token;
+ }
+ l = t.line || 0;
+ ch = t.from || 0;
+ w = {
+ id: '(error)',
+ raw: m,
+ evidence: lines[l - 1] || '',
+ line: l,
+ character: ch,
+ a: a,
+ b: b,
+ c: c,
+ d: d
+ };
+ w.reason = m.supplant(w);
+ JSLINT.errors.push(w);
+ if (option.passfail) {
+ quit('Stopping. ', l, ch);
+ }
+ warnings += 1;
+ if (warnings >= option.maxerr) {
+ quit("Too many errors.", l, ch);
+ }
+ return w;
+ }
+
+ function warningAt(m, l, ch, a, b, c, d) {
+ return warning(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+ function error(m, t, a, b, c, d) {
+ var w = warning(m, t, a, b, c, d);
+ quit("Stopping, unable to continue.", w.line, w.character);
+ }
+
+ function errorAt(m, l, ch, a, b, c, d) {
+ return error(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+
+
+// lexical analysis
+
+ var lex = (function lex() {
+ var character, from, line, s;
+
+// Private lex methods
+
+ function nextLine() {
+ var at;
+ if (line >= lines.length) {
+ return false;
+ }
+ character = 1;
+ s = lines[line];
+ line += 1;
+ at = s.search(/ \t/);
+ if (at >= 0) {
+ warningAt("Mixed spaces and tabs.", line, at + 1);
+ }
+ s = s.replace(/\t/g, tab);
+ at = s.search(cx);
+ if (at >= 0) {
+ warningAt("Unsafe character.", line, at);
+ }
+ if (option.maxlen && option.maxlen < s.length) {
+ warningAt("Line too long.", line, s.length);
+ }
+ return true;
+ }
+
+// Produce a token object. The token inherits from a syntax symbol.
+
+ function it(type, value) {
+ var i, t;
+ if (type === '(color)') {
+ t = {type: type};
+ } else if (type === '(punctuator)' ||
+ (type === '(identifier)' && is_own(syntax, value))) {
+ t = syntax[value] || syntax['(error)'];
+ } else {
+ t = syntax[type];
+ }
+ t = Object.create(t);
+ if (type === '(string)' || type === '(range)') {
+ if (jx.test(value)) {
+ warningAt("Script URL.", line, from);
+ }
+ }
+ if (type === '(identifier)') {
+ t.identifier = true;
+ if (value === '__iterator__' || value === '__proto__') {
+ errorAt("Reserved name '{a}'.",
+ line, from, value);
+ } else if (option.nomen &&
+ (value.charAt(0) === '_' ||
+ value.charAt(value.length - 1) === '_')) {
+ warningAt("Unexpected {a} in '{b}'.", line, from,
+ "dangling '_'", value);
+ }
+ }
+ t.value = value;
+ t.line = line;
+ t.character = character;
+ t.from = from;
+ i = t.id;
+ if (i !== '(endline)') {
+ prereg = i &&
+ (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
+ i === 'return');
+ }
+ return t;
+ }
+
+// Public lex methods
+
+ return {
+ init: function (source) {
+ if (typeof source === 'string') {
+ lines = source.
+ replace(/\r\n/g, '\n').
+ replace(/\r/g, '\n').
+ split('\n');
+ } else {
+ lines = source;
+ }
+ line = 0;
+ nextLine();
+ from = 1;
+ },
+
+ range: function (begin, end) {
+ var c, value = '';
+ from = character;
+ if (s.charAt(0) !== begin) {
+ errorAt("Expected '{a}' and instead saw '{b}'.",
+ line, character, begin, s.charAt(0));
+ }
+ for (;;) {
+ s = s.slice(1);
+ character += 1;
+ c = s.charAt(0);
+ switch (c) {
+ case '':
+ errorAt("Missing '{a}'.", line, character, c);
+ break;
+ case end:
+ s = s.slice(1);
+ character += 1;
+ return it('(range)', value);
+ case xquote:
+ case '\\':
+ warningAt("Unexpected '{a}'.", line, character, c);
+ }
+ value += c;
+ }
+
+ },
+
+// token -- this is called by advance to get the next token.
+
+ token: function () {
+ var b, c, captures, d, depth, high, i, l, low, q, t;
+
+ function match(x) {
+ var r = x.exec(s), r1;
+ if (r) {
+ l = r[0].length;
+ r1 = r[1];
+ c = r1.charAt(0);
+ s = s.substr(l);
+ from = character + l - r1.length;
+ character += l;
+ return r1;
+ }
+ }
+
+ function string(x) {
+ var c, j, r = '';
+
+ if (jsonmode && x !== '"') {
+ warningAt("Strings must use doublequote.",
+ line, character);
+ }
+
+ if (xquote === x || (xmode === 'scriptstring' && !xquote)) {
+ return it('(punctuator)', x);
+ }
+
+ function esc(n) {
+ var i = parseInt(s.substr(j + 1, n), 16);
+ j += n;
+ if (i >= 32 && i <= 126 &&
+ i !== 34 && i !== 92 && i !== 39) {
+ warningAt("Unnecessary escapement.", line, character);
+ }
+ character += n;
+ c = String.fromCharCode(i);
+ }
+ j = 0;
+ for (;;) {
+ while (j >= s.length) {
+ j = 0;
+ if (xmode !== 'html' || !nextLine()) {
+ errorAt("Unclosed string.", line, from);
+ }
+ }
+ c = s.charAt(j);
+ if (c === x) {
+ character += 1;
+ s = s.substr(j + 1);
+ return it('(string)', r, x);
+ }
+ if (c < ' ') {
+ if (c === '\n' || c === '\r') {
+ break;
+ }
+ warningAt("Control character in string: {a}.",
+ line, character + j, s.slice(0, j));
+ } else if (c === xquote) {
+ warningAt("Bad HTML string", line, character + j);
+ } else if (c === '<') {
+ if (option.safe && xmode === 'html') {
+ warningAt("ADsafe string violation.",
+ line, character + j);
+ } else if (s.charAt(j + 1) === '/' && (xmode || option.safe)) {
+ warningAt("Expected '<\\/' and instead saw '</'.", line, character);
+ } else if (s.charAt(j + 1) === '!' && (xmode || option.safe)) {
+ warningAt("Unexpected '<!' in a string.", line, character);
+ }
+ } else if (c === '\\') {
+ if (xmode === 'html') {
+ if (option.safe) {
+ warningAt("ADsafe string violation.",
+ line, character + j);
+ }
+ } else if (xmode === 'styleproperty') {
+ j += 1;
+ character += 1;
+ c = s.charAt(j);
+ if (c !== x) {
+ warningAt("Escapement in style string.",
+ line, character + j);
+ }
+ } else {
+ j += 1;
+ character += 1;
+ c = s.charAt(j);
+ switch (c) {
+ case xquote:
+ warningAt("Bad HTML string", line,
+ character + j);
+ break;
+ case '\\':
+ case '\'':
+ case '"':
+ case '/':
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'u':
+ esc(4);
+ break;
+ case 'v':
+ c = '\v';
+ break;
+ case 'x':
+ if (jsonmode) {
+ warningAt("Avoid \\x-.", line, character);
+ }
+ esc(2);
+ break;
+ default:
+ warningAt("Bad escapement.", line, character);
+ }
+ }
+ }
+ r += c;
+ character += 1;
+ j += 1;
+ }
+ }
+
+ for (;;) {
+ if (!s) {
+ return it(nextLine() ? '(endline)' : '(end)', '');
+ }
+ while (xmode === 'outer') {
+ i = s.search(ox);
+ if (i === 0) {
+ break;
+ } else if (i > 0) {
+ character += 1;
+ s = s.slice(i);
+ break;
+ } else {
+ if (!nextLine()) {
+ return it('(end)', '');
+ }
+ }
+ }
+// t = match(rx[xmode] || tx);
+// if (!t) {
+// if (xmode === 'html') {
+// return it('(error)', s.charAt(0));
+// } else {
+// t = '';
+// c = '';
+// while (s && s < '!') {
+// s = s.substr(1);
+// }
+// if (s) {
+// errorAt("Unexpected '{a}'.",
+// line, character, s.substr(0, 1));
+// }
+// }
+ t = match(rx[xmode] || tx);
+ if (!t) {
+ t = '';
+ c = '';
+ while (s && s < '!') {
+ s = s.substr(1);
+ }
+ if (s) {
+ if (xmode === 'html') {
+ return it('(error)', s.charAt(0));
+ } else {
+ errorAt("Unexpected '{a}'.",
+ line, character, s.substr(0, 1));
+ }
+ }
+ } else {
+
+ // identifier
+
+ if (c.isAlpha() || c === '_' || c === '$') {
+ return it('(identifier)', t);
+ }
+
+ // number
+
+ if (c.isDigit()) {
+ if (xmode !== 'style' && !isFinite(Number(t))) {
+ warningAt("Bad number '{a}'.",
+ line, character, t);
+ }
+ if (xmode !== 'style' &&
+ xmode !== 'styleproperty' &&
+ s.substr(0, 1).isAlpha()) {
+ warningAt("Missing space after '{a}'.",
+ line, character, t);
+ }
+ if (c === '0') {
+ d = t.substr(1, 1);
+ if (d.isDigit()) {
+ if (token.id !== '.' && xmode !== 'styleproperty') {
+ warningAt("Don't use extra leading zeros '{a}'.",
+ line, character, t);
+ }
+ } else if (jsonmode && (d === 'x' || d === 'X')) {
+ warningAt("Avoid 0x-. '{a}'.",
+ line, character, t);
+ }
+ }
+ if (t.substr(t.length - 1) === '.') {
+ warningAt(
+ "A trailing decimal point can be confused with a dot '{a}'.",
+ line, character, t);
+ }
+ return it('(number)', t);
+ }
+ switch (t) {
+
+ // string
+
+ case '"':
+ case "'":
+ return string(t);
+
+ // // comment
+
+ case '//':
+ if (src || (xmode && xmode !== 'script')) {
+ warningAt("Unexpected comment.", line, character);
+ } else if (xmode === 'script' && /<\s*\//i.test(s)) {
+ warningAt("Unexpected <\/ in comment.", line, character);
+ } else if ((option.safe || xmode === 'script') && ax.test(s)) {
+ warningAt("Dangerous comment.", line, character);
+ }
+ s = '';
+ token.comment = true;
+ break;
+
+ // /* comment
+
+ case '/*':
+ if (src || (xmode && xmode !== 'script' && xmode !== 'style' && xmode !== 'styleproperty')) {
+ warningAt("Unexpected comment.", line, character);
+ }
+ if (option.safe && ax.test(s)) {
+ warningAt("ADsafe comment violation.", line, character);
+ }
+ for (;;) {
+ i = s.search(lx);
+ if (i >= 0) {
+ break;
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed comment.", line, character);
+ } else {
+ if (option.safe && ax.test(s)) {
+ warningAt("ADsafe comment violation.", line, character);
+ }
+ }
+ }
+ character += i + 2;
+ if (s.substr(i, 1) === '/') {
+ errorAt("Nested comment.", line, character);
+ }
+ s = s.substr(i + 2);
+ token.comment = true;
+ break;
+
+ // /*members /*jslint /*global
+
+ case '/*members':
+ case '/*member':
+ case '/*jslint':
+ case '/*global':
+ case '*/':
+ return {
+ value: t,
+ type: 'special',
+ line: line,
+ character: character,
+ from: from
+ };
+
+ case '':
+ break;
+ // /
+ case '/':
+ if (token.id === '/=') {
+ errorAt(
+"A regular expression literal can be confused with '/='.", line, from);
+ }
+ if (prereg) {
+ depth = 0;
+ captures = 0;
+ l = 0;
+ for (;;) {
+ b = true;
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '':
+ errorAt("Unclosed regular expression.", line, from);
+ return;
+ case '/':
+ if (depth > 0) {
+ warningAt("Unescaped '{a}'.", line, from + l, '/');
+ }
+ c = s.substr(0, l - 1);
+ q = {
+ g: true,
+ i: true,
+ m: true
+ };
+ while (q[s.charAt(l)] === true) {
+ q[s.charAt(l)] = false;
+ l += 1;
+ }
+ character += l;
+ s = s.substr(l);
+ q = s.charAt(0);
+ if (q === '/' || q === '*') {
+ errorAt("Confusing regular expression.", line, from);
+ }
+ return it('(regexp)', c);
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt("Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt("Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+ break;
+ case '(':
+ depth += 1;
+ b = false;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ switch (s.charAt(l)) {
+ case ':':
+ case '=':
+ case '!':
+ l += 1;
+ break;
+ default:
+ warningAt("Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
+ }
+ } else {
+ captures += 1;
+ }
+ break;
+ case '|':
+ b = false;
+ break;
+ case ')':
+ if (depth === 0) {
+ warningAt("Unescaped '{a}'.", line, from + l, ')');
+ } else {
+ depth -= 1;
+ }
+ break;
+ case ' ':
+ q = 1;
+ while (s.charAt(l) === ' ') {
+ l += 1;
+ q += 1;
+ }
+ if (q > 1) {
+ warningAt("Spaces are hard to count. Use {{a}}.", line, from + l, q);
+ }
+ break;
+ case '[':
+ c = s.charAt(l);
+ if (c === '^') {
+ l += 1;
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.", line, from + l, c);
+ }
+ }
+ q = false;
+ if (c === ']') {
+ warningAt("Empty class.", line, from + l - 1);
+ q = true;
+ }
+ klass: do {
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '[':
+ case '^':
+ warningAt("Unescaped '{a}'.", line, from + l, c);
+ q = true;
+ break;
+ case '-':
+ if (q) {
+ q = false;
+ } else {
+ warningAt("Unescaped '{a}'.", line, from + l, '-');
+ q = true;
+ }
+ break;
+ case ']':
+ if (!q) {
+ warningAt("Unescaped '{a}'.", line, from + l - 1, '-');
+ }
+ break klass;
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt("Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt("Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+ q = true;
+ break;
+ case '/':
+ warningAt("Unescaped '{a}'.", line, from + l - 1, '/');
+ q = true;
+ break;
+ case '<':
+ if (xmode === 'script') {
+ c = s.charAt(l);
+ if (c === '!' || c === '/') {
+ warningAt("HTML confusion in regular expression '<{a}'.", line, from + l, c);
+ }
+ }
+ q = true;
+ break;
+ default:
+ q = true;
+ }
+ } while (c);
+ break;
+ case '.':
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.", line, from + l, c);
+ }
+ break;
+ case ']':
+ case '?':
+ case '{':
+ case '}':
+ case '+':
+ case '*':
+ warningAt("Unescaped '{a}'.", line, from + l, c);
+ break;
+ case '<':
+ if (xmode === 'script') {
+ c = s.charAt(l);
+ if (c === '!' || c === '/') {
+ warningAt("HTML confusion in regular expression '<{a}'.", line, from + l, c);
+ }
+ }
+ }
+ if (b) {
+ switch (s.charAt(l)) {
+ case '?':
+ case '+':
+ case '*':
+ l += 1;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ break;
+ case '{':
+ l += 1;
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ warningAt("Expected a number and instead saw '{a}'.", line, from + l, c);
+ }
+ l += 1;
+ low = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ low = +c + (low * 10);
+ }
+ high = low;
+ if (c === ',') {
+ l += 1;
+ high = Infinity;
+ c = s.charAt(l);
+ if (c >= '0' && c <= '9') {
+ l += 1;
+ high = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ high = +c + (high * 10);
+ }
+ }
+ }
+ if (s.charAt(l) !== '}') {
+ warningAt("Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
+ } else {
+ l += 1;
+ }
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ if (low > high) {
+ warningAt("'{a}' should not be greater than '{b}'.", line, from + l, low, high);
+ }
+ }
+ }
+ }
+ c = s.substr(0, l - 1);
+ character += l;
+ s = s.substr(l);
+ return it('(regexp)', c);
+ }
+ return it('(punctuator)', t);
+
+ // punctuator
+
+ case '<!--':
+ l = line;
+ c = character;
+ for (;;) {
+ i = s.indexOf('--');
+ if (i >= 0) {
+ break;
+ }
+ i = s.indexOf('<!');
+ if (i >= 0) {
+ errorAt("Nested HTML comment.",
+ line, character + i);
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed HTML comment.", l, c);
+ }
+ }
+ l = s.indexOf('<!');
+ if (l >= 0 && l < i) {
+ errorAt("Nested HTML comment.",
+ line, character + l);
+ }
+ character += i;
+ if (s[i + 2] !== '>') {
+ errorAt("Expected -->.", line, character);
+ }
+ character += 3;
+ s = s.slice(i + 3);
+ break;
+ case '#':
+ if (xmode === 'html' || xmode === 'styleproperty') {
+ for (;;) {
+ c = s.charAt(0);
+ if ((c < '0' || c > '9') &&
+ (c < 'a' || c > 'f') &&
+ (c < 'A' || c > 'F')) {
+ break;
+ }
+ character += 1;
+ s = s.substr(1);
+ t += c;
+ }
+ if (t.length !== 4 && t.length !== 7) {
+ warningAt("Bad hex color '{a}'.", line,
+ from + l, t);
+ }
+ return it('(color)', t);
+ }
+ return it('(punctuator)', t);
+ default:
+ if (xmode === 'outer' && c === '&') {
+ character += 1;
+ s = s.substr(1);
+ for (;;) {
+ c = s.charAt(0);
+ character += 1;
+ s = s.substr(1);
+ if (c === ';') {
+ break;
+ }
+ if (!((c >= '0' && c <= '9') ||
+ (c >= 'a' && c <= 'z') ||
+ c === '#')) {
+ errorAt("Bad entity", line, from + l,
+ character);
+ }
+ }
+ break;
+ }
+ return it('(punctuator)', t);
+ }
+ }
+ }
+ }
+ };
+ }());
+
+
+ function addlabel(t, type) {
+
+ if (option.safe && funct['(global)'] && typeof predefined[t] !== 'boolean') {
+ warning('ADsafe global: ' + t + '.', token);
+ } else if (t === 'hasOwnProperty') {
+ warning("'hasOwnProperty' is a really bad name.");
+ }
+
+// Define t in the current function in the current scope.
+
+ if (is_own(funct, t) && !funct['(global)']) {
+ warning(funct[t] === true ?
+ "'{a}' was used before it was defined." :
+ "'{a}' is already defined.",
+ nexttoken, t);
+ }
+ funct[t] = type;
+ if (funct['(global)']) {
+ global[t] = funct;
+ if (is_own(implied, t)) {
+ warning("'{a}' was used before it was defined.", nexttoken, t);
+ delete implied[t];
+ }
+ } else {
+ scope[t] = funct;
+ }
+ }
+
+
+ function doOption() {
+ var b, obj, filter, o = nexttoken.value, t, v;
+ switch (o) {
+ case '*/':
+ error("Unbegun comment.");
+ break;
+ case '/*members':
+ case '/*member':
+ o = '/*members';
+ if (!membersOnly) {
+ membersOnly = {};
+ }
+ obj = membersOnly;
+ break;
+ case '/*jslint':
+ if (option.safe) {
+ warning("ADsafe restriction.");
+ }
+ obj = option;
+ filter = boolOptions;
+ break;
+ case '/*global':
+ if (option.safe) {
+ warning("ADsafe restriction.");
+ }
+ obj = predefined;
+ break;
+ default:
+ }
+ t = lex.token();
+loop: for (;;) {
+ for (;;) {
+ if (t.type === 'special' && t.value === '*/') {
+ break loop;
+ }
+ if (t.id !== '(endline)' && t.id !== ',') {
+ break;
+ }
+ t = lex.token();
+ }
+ if (t.type !== '(string)' && t.type !== '(identifier)' &&
+ o !== '/*members') {
+ error("Bad option.", t);
+ }
+ v = lex.token();
+ if (v.id === ':') {
+ v = lex.token();
+ if (obj === membersOnly) {
+ error("Expected '{a}' and instead saw '{b}'.",
+ t, '*/', ':');
+ }
+ if (t.value === 'indent' && o === '/*jslint') {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.white = true;
+ obj.indent = b;
+ } else if (t.value === 'maxerr' && o === '/*jslint') {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxerr = b;
+ } else if (t.value === 'maxlen' && o === '/*jslint') {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxlen = b;
+ } else if (v.value === 'true') {
+ obj[t.value] = true;
+ } else if (v.value === 'false') {
+ obj[t.value] = false;
+ } else {
+ error("Bad option value.", v);
+ }
+ t = lex.token();
+ } else {
+ if (o === '/*jslint') {
+ error("Missing option value.", t);
+ }
+ obj[t.value] = false;
+ t = v;
+ }
+ }
+ if (filter) {
+ assume();
+ }
+ }
+
+
+// We need a peek function. If it has an argument, it peeks that much farther
+// ahead. It is used to distinguish
+// for ( var i in ...
+// from
+// for ( var i = ...
+
+ function peek(p) {
+ var i = p || 0, j = 0, t;
+
+ while (j <= i) {
+ t = lookahead[j];
+ if (!t) {
+ t = lookahead[j] = lex.token();
+ }
+ j += 1;
+ }
+ return t;
+ }
+
+
+
+// Produce the next token. It looks for programming errors.
+
+ function advance(id, t) {
+ switch (token.id) {
+ case '(number)':
+ if (nexttoken.id === '.') {
+ warning(
+"A dot following a number can be confused with a decimal point.", token);
+ }
+ break;
+ case '-':
+ if (nexttoken.id === '-' || nexttoken.id === '--') {
+ warning("Confusing minusses.");
+ }
+ break;
+ case '+':
+ if (nexttoken.id === '+' || nexttoken.id === '++') {
+ warning("Confusing plusses.");
+ }
+ break;
+ }
+ if (token.type === '(string)' || token.identifier) {
+ anonname = token.value;
+ }
+
+ if (id && nexttoken.id !== id) {
+ if (t) {
+ if (nexttoken.id === '(end)') {
+ warning("Unmatched '{a}'.", t, t.id);
+ } else {
+ warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
+ nexttoken, id, t.id, t.line, nexttoken.value);
+ }
+ } else if (nexttoken.type !== '(identifier)' ||
+ nexttoken.value !== id) {
+ warning("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, id, nexttoken.value);
+ }
+ }
+ prevtoken = token;
+ token = nexttoken;
+ for (;;) {
+ nexttoken = lookahead.shift() || lex.token();
+ if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
+ return;
+ }
+ if (nexttoken.type === 'special') {
+ doOption();
+ } else {
+ if (nexttoken.id !== '(endline)') {
+ break;
+ }
+ }
+ }
+ }
+
+
+// This is the heart of JSLINT, the Pratt parser. In addition to parsing, it
+// is looking for ad hoc lint patterns. We add to Pratt's model .fud, which is
+// like nud except that it is only used on the first token of a statement.
+// Having .fud makes it much easier to define JavaScript. I retained Pratt's
+// nomenclature.
+
+// .nud Null denotation
+// .fud First null denotation
+// .led Left denotation
+// lbp Left binding power
+// rbp Right binding power
+
+// They are key to the parsing method called Top Down Operator Precedence.
+
+ function parse(rbp, initial) {
+ var left;
+ if (nexttoken.id === '(end)') {
+ error("Unexpected early end of program.", token);
+ }
+ advance();
+ if (option.safe && typeof predefined[token.value] === 'boolean' &&
+ (nexttoken.id !== '(' && nexttoken.id !== '.')) {
+ warning('ADsafe violation.', token);
+ }
+ if (initial) {
+ anonname = 'anonymous';
+ funct['(verb)'] = token.value;
+ }
+ if (initial === true && token.fud) {
+ left = token.fud();
+ } else {
+ if (token.nud) {
+ left = token.nud();
+ } else {
+ if (nexttoken.type === '(number)' && token.id === '.') {
+ warning(
+"A leading decimal point can be confused with a dot: '.{a}'.",
+ token, nexttoken.value);
+ advance();
+ return token;
+ } else {
+ error("Expected an identifier and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ while (rbp < nexttoken.lbp) {
+ advance();
+ if (token.led) {
+ left = token.led(left);
+ } else {
+ error("Expected an operator and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ }
+ return left;
+ }
+
+
+// Functions for conformance of style.
+
+ function adjacent(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white || xmode === 'styleproperty' || xmode === 'style') {
+ if (left.character !== right.from && left.line === right.line) {
+ warning("Unexpected space after '{a}'.", right, left.value);
+ }
+ }
+ }
+
+ function nospace(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white && !left.comment) {
+ if (left.line === right.line) {
+ adjacent(left, right);
+ }
+ }
+ }
+
+
+ function nonadjacent(left, right) {
+ if (option.white) {
+ left = left || token;
+ right = right || nexttoken;
+ if (left.line === right.line && left.character === right.from) {
+ warning("Missing space after '{a}'.",
+ nexttoken, left.value);
+ }
+ }
+ }
+
+ function nobreaknonadjacent(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (!option.laxbreak && left.line !== right.line) {
+ warning("Bad line breaking before '{a}'.", right, right.id);
+ } else if (option.white) {
+ left = left || token;
+ right = right || nexttoken;
+ if (left.character === right.from) {
+ warning("Missing space after '{a}'.",
+ nexttoken, left.value);
+ }
+ }
+ }
+
+ function indentation(bias) {
+ var i;
+ if (option.white && nexttoken.id !== '(end)') {
+ i = indent + (bias || 0);
+ if (nexttoken.from !== i) {
+ warning("Expected '{a}' to have an indentation at {b} instead at {c}.",
+ nexttoken, nexttoken.value, i, nexttoken.from);
+ }
+ }
+ }
+
+ function nolinebreak(t) {
+ t = t || token;
+ if (t.line !== nexttoken.line) {
+ warning("Line breaking error '{a}'.", t, t.value);
+ }
+ }
+
+
+ function comma() {
+ if (token.line !== nexttoken.line) {
+ if (!option.laxbreak) {
+ warning("Bad line breaking before '{a}'.", token, nexttoken.id);
+ }
+ } else if (token.character !== nexttoken.from && option.white) {
+ warning("Unexpected space after '{a}'.", nexttoken, token.value);
+ }
+ advance(',');
+ nonadjacent(token, nexttoken);
+ }
+
+
+// Functional constructors for making the symbols that will be inherited by
+// tokens.
+
+ function symbol(s, p) {
+ var x = syntax[s];
+ if (!x || typeof x !== 'object') {
+ syntax[s] = x = {
+ id: s,
+ lbp: p,
+ value: s
+ };
+ }
+ return x;
+ }
+
+
+ function delim(s) {
+ return symbol(s, 0);
+ }
+
+
+ function stmt(s, f) {
+ var x = delim(s);
+ x.identifier = x.reserved = true;
+ x.fud = f;
+ return x;
+ }
+
+
+ function blockstmt(s, f) {
+ var x = stmt(s, f);
+ x.block = true;
+ return x;
+ }
+
+
+ function reserveName(x) {
+ var c = x.id.charAt(0);
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
+ x.identifier = x.reserved = true;
+ }
+ return x;
+ }
+
+
+ function prefix(s, f) {
+ var x = symbol(s, 150);
+ reserveName(x);
+ x.nud = (typeof f === 'function') ? f : function () {
+ this.right = parse(150);
+ this.arity = 'u
<TRUNCATED>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[02/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pkcs1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pkcs1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pkcs1.js
new file mode 100644
index 0000000..889eb6d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/pkcs1.js
@@ -0,0 +1,1105 @@
+(function() {
+
+function Tests(ASSERT, PKI, PKCS1, MD, JSBN, UTIL) {
+ var BigInteger = JSBN.BigInteger;
+
+ // RSA's test vectors for Forge's RSA-OAEP implementation:
+ // http://www.rsa.com/rsalabs/node.asp?id=2125
+ describe('pkcs1', function() {
+ it('should detect invalid RSAES-OAEP padding', function() {
+ var keys = makeKey();
+
+ // provide the seed to test the same input each time
+ var seed = UTIL.decode64('JRTfRpV1WmeyiOr0kFw27sZv0v0=');
+
+ // test decrypting corrupted data: flip every bit (skip first byte to
+ // avoid triggering other invalid encryption error) in the message this
+ // tests the padding error handling
+ var encoded = PKCS1.encode_rsa_oaep(
+ keys.publicKey, 'datadatadatadata', {seed: seed});
+ var encrypted = keys.publicKey.encrypt(encoded, null);
+ var bitLength = encrypted.length * 8;
+ // FIXME: test it too slow to run all the time -- temporary
+ // change only does partial checks, need a longer term fix
+ bitLength /= 8;
+ for(var bit = 8; bit < bitLength; ++bit) {
+ var byteIndex = bit / 8;
+ var bitInByte = bit % 8;
+
+ var out = encrypted.substring(0, byteIndex);
+ var mask = 0x1 << bitInByte;
+ out += String.fromCharCode(encrypted.charCodeAt(byteIndex) ^ mask);
+ out += encrypted.substring(byteIndex + 1);
+
+ try {
+ var decrypted = keys.privateKey.decrypt(out, null);
+ PKCS1.decode_rsa_oaep(keys.privateKey, decrypted);
+ throw {
+ message: 'Expected an exception.'
+ };
+ } catch(e) {
+ ASSERT.equal(e.message, 'Invalid RSAES-OAEP padding.');
+ }
+ }
+ });
+
+ it('should detect leading zero bytes', function() {
+ var keys = makeKey();
+ var message = UTIL.fillString('\x00', 80);
+ var encoded = PKCS1.encode_rsa_oaep(keys.publicKey, message);
+ var ciphertext = keys.publicKey.encrypt(encoded, null);
+ var decrypted = keys.privateKey.decrypt(ciphertext, null);
+ var decoded = PKCS1.decode_rsa_oaep(keys.privateKey, decrypted);
+ ASSERT.equal(message, decoded);
+ });
+
+ testOAEP();
+ testOAEPSHA256();
+
+ function testOAEP() {
+ var modulus, exponent, d, p, q, dP, dQ, qInv, pubkey, privateKey;
+ var examples;
+
+ // Example 1: A 1024-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'qLOyhK+OtQs4cDSoYPFGxJGfMYdjzWxVmMiuSBGh4KvEx+CwgtaTpef87Wdc9GaFEncsDLxkp0LGxjD1M8jMcvYq6DPEC/JYQumEu3i9v5fAEH1VvbZi9cTg+rmEXLUUjvc5LdOq/5OuHmtme7PUJHYW1PW6ENTP0ibeiNOfFvs=';
+ exponent = 'AQAB';
+ d = 'UzOc/befyEZqZVxzFqyoXFX9j23YmP2vEZUX709S6P2OJY35P+4YD6DkqylpPNg7FSpVPUrE0YEri5+lrw5/Vf5zBN9BVwkm8zEfFcTWWnMsSDEW7j09LQrzVJrZv3y/t4rYhPhNW+sEck3HNpsx3vN9DPU56c/N095lNynq1dE=';
+ p = '0yc35yZ//hNBstXA0VCoG1hvsxMr7S+NUmKGSpy58wrzi+RIWY1BOhcu+4AsIazxwRxSDC8mpHHcrSEurHyjnQ==';
+ q = 'zIhT0dVNpjD6wAT0cfKBx7iYLYIkpJDtvrM9Pj1cyTxHZXA9HdeRZC8fEWoN2FK+JBmyr3K/6aAw6GCwKItddw==';
+ dP = 'DhK/FxjpzvVZm6HDiC/oBGqQh07vzo8szCDk8nQfsKM6OEiuyckwX77L0tdoGZZ9RnGsxkMeQDeWjbN4eOaVwQ==';
+ dQ = 'lSl7D5Wi+mfQBwfWCd/U/AXIna/C721upVvsdx6jM3NNklHnkILs2oZu/vE8RZ4aYxOGt+NUyJn18RLKhdcVgw==';
+ qInv = 'T0VsUCSTvcDtKrdWo6btTWc1Kml9QhbpMhKxJ6Y9VBHOb6mNXb79cyY+NygUJ0OBgWbtfdY2h90qjKHS9PvY4Q==';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 1.1',
+ message: 'ZigZThIHPbA7qUzanvlTI5fVDbp5uYcASv7+NA==',
+ seed: 'GLd26iEGnWl3ajPpa61I4d2gpe8=',
+ encrypted: 'NU/me0oSbV01/jbHd3kaP3uhPe9ITi05CK/3IvrUaPshaW3pXQvpEcLTF0+K/MIBA197bY5pQC3lRRYYwhpTX6nXv8W43Z/CQ/jPkn2zEyLW6IHqqRqZYXDmV6BaJmQm2YyIAD+Ed8EicJSg2foejEAkMJzh7My1IQA11HrHLoo='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.2',
+ message: 'dQxAR/VH6OQUEYVlIymKybriRe+vE5f75W+d1Q==',
+ seed: 'DMdCzkqbfzL5UbyyUe/ZJf5P418=',
+ encrypted: 'ZA2xrMWOBWj+VAfl+bcB3/jDyR5xbFNvx/zsbLW3HBFlmI1KJ54Vd9cw/Hopky4/AMgVFSNtjY4xAXp6Cd9DUtkEzet5qlg63MMeppikwFKD2rqQib5UkfZ8Gk7kjcdLu+ZkOu+EZnm0yzlaNS1e0RWRLfaW/+BwKTKUbXFJK0Q='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.3',
+ message: '2Urggy5kRc5CMxywbVMagrHbS6rTD3RtyRbfJNTjwkUf/1mmQj6w4dAtT+ZGz2md/YGMbpewUQ==',
+ seed: 'JRTfRpV1WmeyiOr0kFw27sZv0v0=',
+ encrypted: 'Qjc27QNfYCavJ2w1wLN0GzZeX3bKCRtOjCni8L7+5gNZWqgyLWAtLmJeleuBsvHJck6CLsp224YYzwnFNDUDpDYINbWQO8Y344efsF4O8yaF1a7FBnzXzJb+SyZwturDBmsfz1aGtoWJqvt9YpsC2PhiXKODNiTUgA+wgbHPlOs='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.4',
+ message: 'UuZQ2Y5/KgSLT4aFIVO5fgHdMW80ahn2eoU=',
+ seed: 'xENaPhoYpotoIENikKN877hds/s=',
+ encrypted: 'RerUylUeZiyYAPGsqCg7BSXmq64wvktKunYvpA/T044iq+/Gl5T267vAXduxEhYkfS9BL9D7qHxuOs2IiBNkb9DkjnhSBPnD9z1tgjlWJyLd3Ydx/sSLg6Me5vWSxM/UvIgXTzsToRKq47n3uA4PxvclW6iA3H2AIeIq1qhfB1U='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.5',
+ message: 'jaif2eX5dKKf7/tGK0kYD2z56AI=',
+ seed: 'sxjELfO+D4P+qCP1p7R+1eQlo7U=',
+ encrypted: 'NvbjTZSo002qy6M6ITnQCthak0WoYFHnMHFiAFa5IOIZAFhVohOg8jiXzc1zG0UlfHd/6QggK+/dC1g4axJE6gz1OaBdXRAynaROEwMP12Dc1kTP7yCU0ZENP0M+HHxt0YvB8t9/ZD1mL7ndN+rZBZGQ9PpmyjnoacTrRJy9xDk='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.6',
+ message: 'JlIQUIRCcQ==',
+ seed: '5OwJgsIzbzpnf2o1YXTrDOiHq8I=',
+ encrypted: 'Qs7iYXsezqTbP0gpOG+9Ydr78DjhgNg3yWNm3yTAl7SrD6xr31kNghyfEGQuaBrQW414s3jA9Gzi+tY/dOCtPfBrB11+tfVjb41AO5BZynYbXGK7UqpFAC6nC6rOCN7SQ7nYy9YqaK3iZYMrVlZOQ6b6Qu0ZmgmXaXQt8VOeglU='
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+
+ // Example 2: A 1025-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'AZR8f86QQl9HJ55whR8l1eYjFv6KHfGTcePmKOJgVD5JAe9ggfaMC4FBGQ0q6Nq6fRJQ7G22NulE7Dcih3x8HQpn8UsWlMXwN5RRpD5Joy3eg2cLc9qRocmbwjtDamAFXGEPC6+ZwaB5VluVo/FSZjLR1Npg8g7aJeZTxPACdm9F';
+ exponent = 'AQAB';
+ d = 'CCPyD6212okIip0AiT4h+kobEfvJPGSjvguq6pf7O5PD/3E3BMGcljwdEHqumQVHOfeeAuGG3ob4em3e/qbYzNHTyBpHv6clW+IGAaSksvCKFnteJ51xWxtFW91+qyRZQdl2i5rO+zzNpZUto87nJSW0UBZjqO4VyemS2SRi/jk=';
+ p = 'AVnb3gSjPvBvtgi4CxkPTT4ivME6yOSggQM6v6QW7bCzOKoItXMJ6lpSQOfcblQ3jGlBTDHZfdsfQG2zdpzEGkM=';
+ q = 'AStlLzBAOzi0CZX9b/QaGsyK2nA3Mja3IC05su4wz7RtsJUR9vMHzGHMIWBsGKdbimL4It8DG6DfDa/VUG9Wi9c=';
+ dP = 'Q271CN5zZRnC2kxYDZjILLdFKj+1763Ducd4mhvGWE95Wt270yQ5x0aGVS7LbCwwek069/U57sFXJIx7MfGiVQ==';
+ dQ = 'ASsVqJ89+ys5Bz5z8CvdDBp7N53UNfBc3eLv+eRilIt87GLukFDV4IFuB4WoVrSRCNy3XzaDh00cpjKaGQEwZv8=';
+ qInv = 'AnDbF9WRSwGNdhGLJDiac1Dsg2sAY6IXISNv2O222JtR5+64e2EbcTLLfqc1bCMVHB53UVB8eG2e4XlBcKjI6A==';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 2.1',
+ message: 'j/AMqmBccCgwY02abD1CxlK1jPHZL+xXC+7n',
+ seed: 'jEB7XsKJnlCZxT6M55O/lOcbF4I=',
+ encrypted: 'AYGviSK5/LTXnZLr4ZgVmS/AwUOdi81JE5ig9K06Mppb2ThVYNtTJoPIt9oE5LEq7Wqs30ccNMnNqJGt3MLfNFZlOqY4Lprlm1RFUlfrCZ1WK74QRT8rbRPFnALhDx+Ku12g0FcJMtrPLQkB23KdD+/MBU5wlo6lQMgbBLyu/nIO'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.2',
+ message: 'LQ==',
+ seed: 'tgDPPC5QbX8Wd4yRDTqLAD7uYdU=',
+ encrypted: 'AYdZ/x32OyeSQQViMUQWqK6vKsY0tG+UCrgtZNvxZe7jMBHadJ1Lq24vzRgSnJ5JJ32EUxErQpoiKoRxsHCZOZjnWIYcTT9tdJ2RxCkNMyx6SrP36jX/OgfUl8lV/w/8lQBrYsbSloENm/qwJBlseTQBLC35eO8pmrojmUDLoQJF'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.3',
+ message: 'dPyIxRvJD3evnV6aSnATPUtOCzTaPDfH744=',
+ seed: 'pzdoruqpH52MHtb50rY0Z/B8yuM=',
+ encrypted: 'AYgCurBMYDJegcSWIxHyvnwq3OkwQaAHGciPlXV18sefG3vIztEVxwazEcCKLZhso7apM2sUfCnG8ilAnd7GUb0f3VoLf2EMmTf9tKOnYjZLizIGtOpIX9CY0I9j1KqLsml9Ant1DDLX906vUYDS6bZrF8svpVUjvCgNoQ0UviBT'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.4',
+ message: 'p+sqUDaTHSfU6JEybZlpL/rdqb9+/T405iLErcCF9yHf6IUHLHiiA7FRc5vlQPqMFToQ8Ao=',
+ seed: 'mns7DnCL2W+BkOyrT7mys4BagVY=',
+ encrypted: 'AKRXjLwXYximOPun0B3xV0avRNT2zZbX58SVy/QlsJxknTK/iG2kj7r5iaIRcYfK+x+1gDF2kOPM1EaSC3r4KzHbWATYfQFRSsv6kVbngvhn9r7ZRJ4OmiwJvOzGqgh2NpZeNLPsdm8v4uQwGKL93rFAYWoOnYLlMxAk7gZS/HZB'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.5',
+ message: 'LvKwZvhUwz873LtZlKQ15z1sbA==',
+ seed: '6zzrvErcFrtI6IyK7A40r39Cf9M=',
+ encrypted: 'AOvF9f2nfP2tPINkGpAl531y2Kb7M6gQ9ZUPjXTHPo2THoY02GqxJGJWrge2AFtxt/L7mDUSGDMc5puP+9ydoIu8nHBPh23rnfn8LsBlyth/kJCweswXqn+ZeyespIgG6Jf3cdlRQf5FJtilMBtnhifvq3B/1A++vW55KiVhPnrs'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.6',
+ message: 'in+zRMi2yyzy7x9kP5oyGPbhm7qJwA==',
+ seed: 'TEXPTVfJjj1tIJWtxRxInrUN/4Q=',
+ encrypted: 'AQg57CDCe5BS5Vvvubd+b8JukHXXpUN4xkar31HkRb1XFd6BeJ9W8YA9kXB2Sp6Ty3h5hpQCPuc5POBLxdj4xaUsFx1Dg346ymL2CesKpf+wlg7wQZjddU9X9/vmq/dlzxGLTKRDsjtaqyZvlSMmrEWBEAZEMl+LchrNXQT/FO86'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+
+ // Example 3: A 1026-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'ArWP7AOahgcApNe2Ri+T5s3UkRYd3XT06BC0DjwWUgBqXCd7J3TBEwWky6taeO+lfheobfej+jb8Sx0iSfIux8LdakYyMqzOqQbWbr6AtXBLEHKdpvgzI0q7Xv3UopLL+tM7TTP6ehS4w5e1bjrNISA0KLd836M6bacGs9iw/EPp';
+ exponent = 'AQAB';
+ d = 'FbSKW1aDqUZw4jtXGPgU+g4T+FA49QcRGCy6YVEFgfPSLH4jLvk34i5VHWi4bi+MsarYvi5Ij13379J54/Vo1Orzb4DPcUGs5g/MkRP7bEqEH9ULvHxRL/y+/yFIeqgR6zyoxiAFNGqG3oa/odipSP0/NIwi6q3zM8PObOEyCP0=';
+ p = 'Ab8B0hbXNZXPAnDCvreNQKDYRH0x2pGamD9+6ngbd9hf43Gz6Tc+e2khfTFQoC2JWN5/rZ1VUWCVi0RUEn4Ofq8=';
+ q = 'AY0zmWWBZts4KYFteylUFnWenJGYf1stiuzWOwS0i9ey/PIpu3+KbciLoT3S45rVW20aBhYHCPlwC+gLj9N0TOc=';
+ dP = 'BsCiSdIKby7nXIi0lNU/aq6ZqkJ8iMKLFjp2lEXl85DPQMJ0/W6mMppc58fOA6IVg5buKnhFeG4J4ohalyjk5Q==';
+ dQ = '0dJ8Kf7dkthsNI7dDMv6wU90bgUc4dGBHfNdYfLuHJfUvygEgC9kJxh7qOkKivRCQ7QHmwNEXmAuKfpRk+ZP6Q==';
+ qInv = 'jLL3Vr2JQbHTt3DlrTHuNzsorNpp/5tvQP5Xi58a+4WDb5Yn03rP9zwneeY0uyYBHCyPfzNhriqepl7WieNjmg==';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 3.1',
+ message: 'CHggtWno+o0=',
+ seed: 'jO1rGWKQgFeQ6QkHQBXmogsMSJQ=',
+ encrypted: 'AmoEhdlq69lrQ4IIUJm5Yuaivew9kMjbYl4UNy3oXi1be6q2XI+vkbtVBPtJWvzlyYiz9qUuIOHWy9NWbFzR8rgxi7VCzA6iXEqrmTKvogdg6t3seEOWoH6g7yTU5vTTflBSp6MeFGqkgKERu+kmQBMH4A9BADOEK22C/lzk366A'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.2',
+ message: 'RlOsrxcZYLAfUqe+Y6OrIdw2jsQ7UNguw3geBA==',
+ seed: 'tCkdZWdVCEjMFWlnyAm6q2ylB/A=',
+ encrypted: 'Ak24nHgCmJvgeDhHhjCElBvyCddhmH44+Xy19vG8iNpypQtz668RyHnE+V3ze4ULj2XXYi4lsbiJ6A/oC6yiBp1uDh2CmVP8RZBp3pjql5i0UeVX6Zq/j+PZzPkJbrvz5SVdO04cbS7K3wZ6NZ7qhkBazUfV4WVRfMr9R9bb7kv1'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.3',
+ message: '2UzQ4I+kBO2J',
+ seed: 'zoko9gWVWCVACLrdl5T63NL9H2U=',
+ encrypted: 'Ajm85oEDJEFSiHfW0ci7KKo7yX8d9YRWNhiZV5doOETKhmZHMvS+16CqsIOqq/tyOPWC4wlYwgJOROVwQ7l5UP1UPal3yQzd5TN9YYRC+Z5g13g6tZzm3Z1pxHrR6WK+wi0FiVz/jT9k7VJh2SsmeFEDk0hJkLo/fwaBiub/zoo6'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.4',
+ message: 'bMZBtrYeb5Y5dNrSOpATKE7x',
+ seed: 'bil59S1oFKV9g7CQBUiI8RmluaM=',
+ encrypted: 'AplMYq/Xb0mLof0s9kKFf8qB9Dc8sI8cuu5vAlw7UStCw+h3kRNHZkgDnb4Ek/kkYpL6wolQYA58DzLt+cgbnexFw73gzI2IR1kBaZB7fcWZHOspuwcU1hPZbfDxLsXY01B8jueueN2D8hb6Yd4QA2OspIp+kUrp9C3fvpQ7Cdmg'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.5',
+ message: '31FRgyth9PJYkftBcvMo0u3fg3H/z9vpl5OSlfMOymkYAXz9oRU796avh1kyIw==',
+ seed: 'LXYL/jjFneNM3IuMeKOOZihKLSc=',
+ encrypted: 'AWIEL/aWlZKmFnAxgRojmDTOY4q/VP7IuZR4Eir+LuZ/jFsYsDOYBb/bxaTmcgs3xZz7qUJGTFl/9TKhGYIVRf0uWbEU5h2vcYIFKfUCnPUklUMnw07F5vW6fvzE3pQ6uK1O14exRUMp9w23mKOo9NkvgnTispSK3mJ86O4z5Dxg'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.6',
+ message: 'PDutiTxUSm1SCrAiMZGIyNUEt6eIuFCQO4WXLqoYVS4RNKetYJiCYlT/erZys9jrMVj6xtTLrvE=',
+ seed: '8XR3nF/Tz+AHuty3o2ybVb/Pvw4=',
+ encrypted: 'ABEgUeddBklDvER4B15DSC/VnO4Ged5ok+7DqUPapJC5aRyT38BGS2YjufPb0+cAgyZPA0s3T3QWThoAdjcl5XR0S6C524NDTzHflvbiom9tjro0i9RobCI4rAfDeqw3hdHH7qL4Gf2RSReY7Y6c715Dt4Gw4CduN8Q/+UktAFcw'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+
+ // Example 4: A 1027-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'BRJAtswABPpI0BNGccB4x8jew7Pi8lvCVkRnM52ziFPQa4XupbLeNTv/QqwuRryX+uaslhjalTelyPVTweNXYlmR1hCNzXiF+zolQT9T78rZSMs1zZua6cHGdibRE9V93kxb6na7W7felsANBzculoWm11z50jn6FI1wkxtfP7A5';
+ exponent = 'AQAB';
+ d = 'BBH/yjt8penpvn/jioUQXjU4ltsFxXlq7NKnJRYes2UchimpuGK5BNewx7N/jLWhwrVAAQGKAKHrLK/k7k6UksNIvCvtq0ueu/Bk6O/zIrkAn47sZTkF9A34ijzcSdRWf3VifUGspiQSm0agt8aY5eZfK3uhAsdJoQE1tlQNBAE=';
+ p = 'AnRYwZ7BY2kZ5zbJryXWCaUbj1YdGca/aUPdHuGriko/IyEAvUC4jezGuiNVSLbveSoRyd6CPQp5IscJW266VwE=';
+ q = 'AhDumzOrYXFuJ9JRvUZfSzWhojLi2gCQHClL8iNQzkkNCZ9kK1N1YS22O6HyA4ZJK/BNNLPCK865CdE0QbU7UTk=';
+ dP = 'OfoCi4JuiMESG3UKiyQvqaNcW2a9/R+mN9PMSKhKT0V6GU53J+Sfe8xuWlpBJlf8RwxzIuvDdBbvRYwweowJAQ==';
+ dQ = 'AV2ZqEGVlDl5+p4b4sPBtp9DL0b9A+R9W++7v9ax0Tcdg++zMKPgIJQrL+0RXl0CviT9kskBnRzs1t1M8eVMyJk=';
+ qInv = 'AfC3AVFws/XkIiO6MDAcQabYfLtw4wy308Z9JUc9sfbL8D4/kSbj6XloJ5qGWywrQmUkz8UqaD0x7TDrmEvkEro=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 4.1',
+ message: 'SoZglTTuQ0psvKP36WLnbUVeMmTBn2Bfbl/2E3xlxW1/s0TNUryTN089FmyfDG+cUGutGTMJctI=',
+ seed: 'HKwZzpk971X5ggP2hSiWyVzMofM=',
+ encrypted: 'BMzhlhSEXglBUqP+GOVOMzDETl77xkrhaIbLGGkBTMV4Gx+PngRThNARKhNcoNEunIio5AY0Ft6q44RPYNbpb+FVFF9FJbmjRDHKN2YYD3DhWl5djosaUW/4cGCfE/iWk1ztGIJ5pY7RPQcRQnfXXGVoYH4KsJL9gDoiPkqO4LGo'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.2',
+ message: 'sK3E8/4R2lnOmSdz2QWZQ8AwRkl+6dn5oG3xFm20bZj1jSfsB0wC7ubL4kSci5/FCAxcP0QzCSUS7EaqeTdDyA==',
+ seed: '9UXViXWF49txqgy42nbFHQMq6WM=',
+ encrypted: 'AJe2mMYWVkWzA0hvv1oqRHnA7oWIm1QabwuFjWtll7E7hU60+DmvAzmagNeb2mV4yEH5DWRXFbKA03FDmS3RhsgLlJt3XK6XNw5OyXRDE2xtpITpcP/bEyOiCEeCHTsYOB3hO7SarqZlMMSkuCcfPq4XLNNm4H5mNvEBnSoortFe'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.3',
+ message: 'v21C5wFwex0CBrDItFoccmQf8SiJIZqCveqWW155qWsNAWPtnVeOya2iDy+88eo8QInYNBm6gbDGDzYG2pk=',
+ seed: 'rZl/7vcw1up75g0NxS5y6sv90nU=',
+ encrypted: 'AwH5NenEery0isu+CYldn1lxrxSDnaT/lUF+5FPR/XcxkHK7cpfhtV11Yc2dG7JMGpo3xhmGQwgkKASHnYbr0AHc5Rg5deFQaYm3DlqDQ0FU1cv9aiR4fmDrDGWNKsGTMC0RksbmItShKtS1OSO8okbfMcY5XjdwLGp4rggfudBl'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.4',
+ message: '+y7xEvXnZuuUAZKXk0eU974vb8HFjg==',
+ seed: 'E2RU31cw9zyAen5A2MGjEqxbndM=',
+ encrypted: 'AtEQrTCvtye+tpHdDPF9CvGh5/oMwEDsGkuiakLFnQp5ai4iyPNXzMmLZRms62gulF5iy3NGFKUpQHzUUr7j5E/s6EI8wZ5VVIuLmUuEnH7N5JM+dgN+HQzkQnWwhxDGjkMBMLkpcw7XfgmwFWQsVZPwTk/7lBB5gQKo6W/9/hHk'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.5',
+ message: 'KMzUR7uehRZtq7nlt9GtrcS5058gTpbV5EDOmtkovBwihA==',
+ seed: 'vKgFf4JLLqJX8oYUB+72PTMghoE=',
+ encrypted: 'ANu4p0OdkO/ZGaN3xU+uj+EexYw7hYNi4jrRuKRDEHmQZrmTR6pSVpHSrcWNmwbjTyiMFwOQxfDhHAqjZFlZ8Y7nno8r6NesXCPQYfGN10uMXypY/LXrDFT5nwGoMkdWgpJTZYM0CUjXqMl8Ss0emNHincMg6XomBTKoqnp1ih7C'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.6',
+ message: '8iJCdR7GsQ==',
+ seed: 'Ln4eF/ZHtd3QM+FUcvkPaBLzrE4=',
+ encrypted: 'AKX/pHaMi77K7i23fo8u7JlZWTNUVSCDXlun25ST0+F83e/mpfVnYkRxkI204tg6D77mBgj8hASVA7IjSgfcg7J7IoR62JIP9C9nTvebdigLACM9K1G4yycDqdQr+8glDJbsMsBR5X8bS6Uo24nDfkxU4n5uZKxpY1roh9lUFhmp'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+
+ // Example 5: A 1028-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'Cq3z+cEl5diR8xrESOmT3v5YD4ArRfnX8iulAh6cR1drWh5oAxup205tq+TZah1vPSZyaM/0CABfEY78rbmYiNHCNEZxZrKiuEmgWoicBgrA2gxfrotV8wm6YucDdC+gMm8tELARAhSJ/0l3cBkNiV/Tn1IpPDnv1zppi9q58Q7Z';
+ exponent = 'AQAB';
+ d = 'AlbrTLpwZ/LSvlQNzf9FgqNrfTHRyQmbshS3mEhGaiaPgPWKSawEwONkiTSgIGwEU3wZsjZkOmCCcyFE33X6IXWI95RoK+iRaCdtxybFwMvbhNMbvybQpDr0lXF/fVKKz+40FWH2/zyuBcV4+EcNloL5wNBy+fYGi1bViA9oK+LF';
+ p = 'A7DTli9tF1Scv8oRKUNI3PDn45+MK8aCTyFktgbWh4YNrh5jI5PP7fUTIoIpBp4vYOSs1+YzpDYGP4I4X0iZNwc=';
+ q = 'AuTDLi9Rcmm3ByMJ8AwOMTZffOKLI2uCkS3yOavzlXLPDtYEsCmC5TVkxS1qBTl95cBSov3cFB73GJg2NGrrMx8=';
+ dP = 'AehLEZ0lFh+mewAlalvZtkXSsjLssFsBUYACmohiKtw/CbOurN5hYat83iLCrSbneX31TgcsvTsmc4ALPkM429U=';
+ dQ = '65CqGkATW0zqBxl87ciBm+Hny/8lR2YhFvRlpKn0h6sS87pP7xOCImWmUpfZi3ve2TcuP/6Bo4s+lgD+0FV1Tw==';
+ qInv = 'AS9/gTj5QEBi64WkKSRSCzj1u4hqAZb0i7jc6mD9kswCfxjngVijSlxdX4YKD2wEBxp9ATEsBlBi8etIt50cg8s=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 5.1',
+ message: 'r3GpAeOmHTEy8Pwf20dPnqZXklf/wk0WQXAUWz296A==',
+ seed: 'RMkuKD93uUmcYD2WNmDIfS+TlGE=',
+ encrypted: 'A2BGpKR9ntO6mokTnBBQOOt0krBaXWi/1TrM/0WX96aGUbR7SkYn2Sfkhe7XtFZkIOi0CYeeXWBuriUdIqXfeZ95IL/BF7mSVypTsSYxRrzqAzhcxehTyaEByMPhvaMaUZgHSWxsteXvtAiCOjUrj6BmH7Zk763Vk965n/9e0ADl'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.2',
+ message: 'o7hEoII5qKxBYFrxemz9pNNQE2WFkDpBenkmh2BRmktKwzA+xz8Ph8+zI5k=',
+ seed: 'yyj1hgZZ/O7knD7q/OYlpwgDvTI=',
+ encrypted: 'A9brZU7c5hW8WfRVJl7U5aGCI8u5vk5AabRzgE1d6W9U3KqmA9BJxdlKoUcN/NIlQGa3x7Yf8fb2dw4yFcUTmf1ONOxQgrxI8ImECtBDVK5m3A8b0Y5GGjPMEli0Q6KDem3yZ1mqIwIzSYb4c4DJzJ1Tvp+ZYF0smpfaewkVpKet'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.3',
+ message: 'MIsOy9LHbLd/xvcMXt0jP9LyCSnWKfAmlTu2Ko9KOjFL3hld6FtfgW2iqrB00my2rN3zI647nGeKw88S+93n',
+ seed: 'IoX0DXcEgvmp76LHLLOsVXFtwMo=',
+ encrypted: 'B3CVIYFkn5+fB/9ib/OiLDXEYkQ9kF1Fap/Qv/Q8rCynqfVU6UeLmsw6yDiwIED/0+GEfeLkJTkp+d2e5ARDJamwXKu4CLLuhA004V0QWj8feydpWhoHotc/4I7KqjycnU1aif+JDVRyfXrkDA7BqN2GFl2O4sY2gUEBaki1W2ln'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.4',
+ message: 'FcW57hGF',
+ seed: 'SfpF06eN0Q39V3OZ0esAr37tVRM=',
+ encrypted: 'CBK3Z2jry2QtBAJY5fREGgGFIb2WaH5sXomfzWwXWI/1moLMiuA6S0WzEpmvF4jDKffc0oX4z0ztgmBrl2EmcaRb7coTNEIUTRYX0RT4AoV/D51zl1HFej+e5ACRLGHi5pkr4DGkPdSPproU7vfEIrXtxOevoE/dOPQC0ci7cZq/'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.5',
+ message: 'IQJuaADH+nKPyqug0ZauKNeirE/9irznlPCYX2DIpnNydzZdP+oR24kjogKa',
+ seed: '8Ch0EyNMxQNHJKCUxFhrh6/xM/w=',
+ encrypted: 'B7YOFOyVS/0p5g0AR+eJ9R1XGGxjWJkDMGeTztP2gkHHQ1KaumpjdPkuGeAWPvozaX4Zb3Zh36qkeqxr3l5R3rUHxyxYmiyhaT2WsUYDgSSbLNuerER2nySJxdPS+Z8O48fuW/ZKWsecQr1DPxSb6MtZVINhZAWVUTyXr3vCUJcj'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.6',
+ message: 'VB43totsiHK4TAI=',
+ seed: '2fukXJbyHm4m0p6yzctlhb6cs0E=',
+ encrypted: 'CMNtTdozQjsu1oMNhfZBG6Hc9HCh+uDr7+58CJ8lbO90y5bqacOPYPOavuRBKby0yS3n95diOyAHTj2cKJlwHtkHHh76C92E1MPlEwMC2PAkC6ukuEpxzAMvIjWl/w+uJ3w+j5ESvvRMmuINF1/JpAWL/JMLoxsC4uT0REg3EPJK'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+
+ // Example 6: A 1029-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'ErF/ba0uzRn/RtwT94YPCeDgz7Z3s4pSWSMFzq8CLBZtuQ0ErCnjP33RLZ+vZuCBa7Y+rSZ8x9RsF8N74hS8oqItcjpk5EQHQ2tvyWVymu/CVU83bNXc6mgpN4CmK/OdAClIWhYLu55dwJctIaUE9S5e4CiqQWMy9RCy6c/19yKv';
+ exponent = 'AQAB';
+ d = 'ApXso1YGGDaVWc7NMDqpz9r8HZ8GlZ33X/75KaqJaWG80ZDcaZftp/WWPnJNB7TcEfMGXlrpfZaDURIoC5CEuxTyoh69ToidQbnEEy7BlW/KuLsv7QV1iEk2Uixf99MyYZBIJOfK3uTguzctJFfPeOK9EoYij/g/EHMc5jyQz/P5';
+ p = 'BKbOi3NY36ab3PdCYXAFr7U4X186WKJO90oiqMBct8w469TMnZqdeJpizQ9g8MuUHTQjyWku+k/jrf8pDEdJo4s=';
+ q = 'BATJqAM3H+20xb4588ALAJ5eCKY74eQANc2spQEcxwHPfuvLmfD/4Xz9Ckv3vv0t1TaslG23l/28Sr6PKTSbke0=';
+ dP = 'A5Ycj3YKor1RVMeq/XciWzus0BOa57WUjqMxH8zYb7lcda+nZyhLmy3lWVcvFdjQRMfrg6G+X63yzDd8DYR1KUs=';
+ dQ = 'AiGX4GZ0IZaqvAP6L+605wsVy3h9YXrNMbt1x7wjStcG98SNIYLR8P+cIo3PQZZ7bAum0sCtEQobhXgx7CReLLE=';
+ qInv = 'BAHEwMU9RdvbXp2W0P7PQnXfCXS8Sgc2tKdMMmkFPvtoas4kBuIsngWN20rlQGJ64v2wgmHo5+S8vJlNqvowXEU=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 6.1',
+ message: 'QEbKi6ozR8on9J4NgfnMHXG+m6UX1A==',
+ seed: '3Q9s/kFeiOWkaaUfu6bf1ArbQ4Q=',
+ encrypted: 'BjDuvNKFbCT3mIBuQfnmc0Xtqc7aOGrMn6yuoe7tBqzlg3CXGNnRafrfQU1cdvkploM+8wW3Wx5LlfZiog+u3DuuDEgnqL+KiO29V+wgOieoQfAuQ6YVurGoysBwHeNN6972KgiAibVew26nUi/T7I0GtqBz5t+DMVO8Cu/ZO9Gj'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.2',
+ message: 'XMcsYCMd8Ds9QPm1eTG8MRCflyUn8osZ50gMcojLPJKyJRIhTkvmyRR5Ldq99X+qiqc=',
+ seed: 'jRS9lGoTURSPXK4u2aDGU+hevYU=',
+ encrypted: 'Drw3N2FzpP0vicxVwspismsR1Rw8fOSeiEX3TnYHMXxDa8jSO5Zn3+udCHI0tHvGg3F1rlwFWfa4HX0iQW0+UPSsUz2PCBLy2555H+nHdayLatD1Na2c6yOkoCAUxYqz+NMWFJmiYPOTSOcUriodNEMgj9i3Isz9+zk+mAEfmeY/'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.3',
+ message: 'sg5lEwMJL0vMtDBwwPhtIwSTYu2WZC/FYywn20pS49gx8qsGiyOxSYecAC9r8/7ul1kRElYs',
+ seed: 'bAdbxFUg8WXAv16kxd8ZG8nvDkQ=',
+ encrypted: 'Cpi/EJNhk5RDbPaNjzji8Vj96OpU80NfI5uNBrgyGEQgJHau7ZYAlJJIDOOo1wVJjEyMaPAVAdyB22CPYAhzUMjDsL0unvaoFFi3yAG4ny5P6Z1JALpqS15althl3Gdsd1WSh5QTDWKAqBYKGQ8t8+p8+aoCcdiOnmkF7PHFFS1l'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.4',
+ message: 'aE4wOMXAQfc=',
+ seed: 'O7w71mN9/hKEaQECm/WwwHEDQ5w=',
+ encrypted: 'AI56Z8rPtcTiS+x97hSRF/GVmM6MRYCP74jGCP+c1uaVJjuaPArUuLpMlSOOlqhCK4U1YpyNU4I3RHmtE/o5l0skL5p1nur5yDrVqMoYlAoBYrp1WHbfJj9L1QxlJcVgkCZ8Hw4JzgiZoM81nogSCr2b+JNEWzyud9Ngc1mumlL4'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.5',
+ message: 'MkiMsmLQQdbk3TX5h788ppbbHwasKaRGkw==',
+ seed: 'tGtBiT6L7zJvZ1k4OoMHHa5/yrw=',
+ encrypted: 'AAA0dEFse2i9+WHDhXN5RNfx9AyzlTQ8aTzAtP5jsx/t8erurJzMBnizHcMuCXdIlRTE8JCF9imKllPwGupARf9YLuiHviauV1tz7vfzd0kh43Wj0ZrdoMoxqhhJiHwfQsrJZ396L06SP25ahos4wITvGHWU3J9/BI/qLgKVU4Sr'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.6',
+ message: 'ULoUvoRicgJ5wwa6',
+ seed: 'CiQDMSpB49UvBg+8E6Z95c92Cac=',
+ encrypted: 'CgJt2l/IeF972b91Mntj6F4sD97l2ttl69ysmuHelcksZyq0M6p6jmnOam2Il/rErEpU3oQa5eW7znaHh515Y0zqejBoQGXHFNUkCbkoJWu/U+q81SMetyWVBFNzmb0pFktybTOkbacBNgpBaKCRzKty1Epi/tJGwP/qWxNIq1Rw'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+
+ // Example 7: A 1030-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'MRF58Lz8m508oxXQDvMNe906LPrpkRv+3LlIs6R4LQcytqtEqkvwN0GmRNwBvsPmmwGgM+Z12KzXxJJcaxrsMRkFHf2Jdi0hXUVHX/y1n5CBSGI/NxdxVvauht16fF9D3B4fkIJUBYooSl8GwAIXk6h/GsX+/33K7mnF5Ro3ieNz';
+ exponent = 'AQAB';
+ d = 'Bwz8/y/rgnbidDLEXf7kj0m3kX1lMOHwyjRg8y4CdhdEh8VuIqRdJQDXd1SVIZ19Flqc872Swyr5qY2NycwpaACtyUoKVPtA80KRv4TujqErbxCTWcbTVCpQ+cdn9c//BaaBwuZW+3fKqttL6UaNirzU35j1jobSBT+hNJ90jiGx';
+ p = 'B0kmLBEc1HDsJWbms3MvwJMpRpqhkHHTucAZBlFMbx0muqFL6rCXHIt+YRpPeQCdb+p3aSjKJShbDeNkPRo/jHE=';
+ q = 'BrweUOlsAr9jbp7qi4mbvr92Ud533UdMPpvCO62BgrYZBMfZffvr+x4AEIh4tuZ+QVOR1nlCwrK/m0Q1+IsMsCM=';
+ dP = 'A7x+p/CqsUOrxs6LlxGGNqMBcuTP4CyPoN2jt7qvkPgJKYKYVSX0iL38tL1ybiJjmsZKMJKrf/y/HVM0z6ULW/E=';
+ dQ = 'AmKmqinCo8Z9xTRsBjga/Zh6o8yTz7/s9U/dn514fX9ZpSPTmJedoTei9jgf6UgB98lNohUY3DTLQIcMRpeZStk=';
+ qInv = 'ZJ1MF7buFyHnctA4mlWcPTzflVDUV8RrA3t0ZBsdUhZq+KITyDliBs37pEIvGNb2Hby10hTJcb9IKuuXanNwwg==';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 7.1',
+ message: 'R6rpCQ==',
+ seed: 'Q90JoH/0ysccqkYy7l4cHa7kzY8=',
+ encrypted: 'FojkzneUu6bLcBQWns1VnO3iowtWpSto2f4Yzxlz75eyoDFTlRx1X2KUqkmtvbVYRatodfs5hsk+z5J5YoQNKC+eVM6LaQ98DLi71zRA2VcdGxbNkmD56rR4PMSC5SI9xglzhxeD7Cewrg/UdzLLwoahc/ySsA+0umgkZHzZPIXB'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.2',
+ message: 'HZsuIiPZvBO/ufFiznNdtIunxo9oIqChp7auFlg05w==',
+ seed: 'Opw87HuE+b063svGc+yZ1UsivJs=',
+ encrypted: 'EFLtOXsuAeHQ7hxQvyQ2P5XlBPSgNDSgj9giV07WuXNu27XzkNsQMhR5qKE5NQ4r1Jd8N3jvMx8+eK4RiyaEUfIKLwHUcfXVPFZpNxcbLbwtS95FmleZ8DctZXQjmyMj0kXQu4HChrY8iaNhAXM35JAviKRn9MfyRL/Vq0ZDf/O2'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.3',
+ message: '2Xb8',
+ seed: 'dqdeW2FXpVbPiIS7LkXCk91UXPU=',
+ encrypted: 'IVXNhD/ySk7outt2lCYAKKSQgTuos2mky/EG7BSOUphwf1llvn0QHBBJ6oWEwkzWNFWtnBBNaGKC0/uAOkwRwcLpuRxxeIAdG2ZA8AP1co3wB7ikzMkrzgXkGicnjXyFAYxSQUMTpQd3iQAdTwGRC3Kq0F0iCqFKWHM6dIm8VFVr'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.4',
+ message: '1HOGI98iOqQ4Q9+EZ1NMQdAT4MgDxiTiY2ZrI5veQKXymuuN5549qmHdA3D0m9SwE4NLmCEq72scXuNzs8s=',
+ seed: 'eGYxSmrW8rJQo1lB2yj1hktYWFk=',
+ encrypted: 'CrFMNzrrfUMo0KqtjAlNiLnrCYuV8hBUopCCUivnwnoxKHi2N5F+PYGebDxWjbXYQ4ArBtUdnpiivgv0DAMUI7AO37/4Mg77kXG9IERlOky5xRIvbGXoPNouw8EmAnqcGla6h00P6iPzgLgs8kC4z1QABHWMTHfZNBV6dPP8Er+s'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.5',
+ message: 'u0cjHKXqHTrUbJk0XZqKYQ==',
+ seed: 'shZu1HLVjbEMqyxrAAzM8Qp9xQk=',
+ encrypted: 'AoOHoxgndDR5i02X9GAGjfUpj6ulBBuhF2Ghy3MWskGEEU7FACV+JYntO2B6HrvpemzC4CvxtoH0IxKjO3p32OeFXEpt4D48BGQ/eGuRomSg1oBeLOqR5oF363pk2SVeTyfnE7fM7ADcIA69IcLqK7iQ/q5JQt+UHcP5eJDtNHR4'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.6',
+ message: 'IYSCcJXTXD+G9gDo5ZdUATKW',
+ seed: 'Umc73iyhZsKqRhMawdyAjWfX07E=',
+ encrypted: 'FMZ4qUrWBSXvOelZsvO6XAl6lP+RK2fbrOgFNcGHq9R9B1QgsYchUrugj3/DHzE7v5JzyRL8TAFJqbDPt5gH40brMyBpYRvsD/m80Wjx98M+dzE86kVLlOJUnuzwAuKs9/by0oRdT+CqsuWpLd9oxICuESR5NdH2JXSEIhauZ0EV'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+
+ // Example 8: A 1031-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'W98OMNMh3aUUf4gkCPppGVSA34+A0/bov1gYUE82QnypsfVUC5xlqPaXTPhEeiRNkoAgG7Sfy75jeNGUTNIn4jD5bj0Q+Bnc7ydsZKALKktnAefQHeX6veOx6aDfgvRjE1nNImaWR/uxcXJGE07XtJfP/73EK1nHOpbtkBZiEt/3';
+ exponent = 'AQAB';
+ d = 'D30enlqqJf0T5KBmOuFE4NFfXNGLzbCd8sx+ZOPF6RWtYmRTBBYdCYxxW7eri9AdB+rz/tfH7QivKopi70SrFrMg4Ur3Kkj5av4mKgrkz2XmNekQeQzU7lzqdopLJjn35vZ3s/C7a+MrdXR9iQkDbwJk9Y1AHNuhMXFhV6dez2Mx';
+ p = 'CgLvhEjZ+ti70NAEyMKql1HvlyHBsNAyNqVLDflHy67VolXuno4g1JHqFyP+CUcEqXYuiK/RbrtZlEEsqWbcT58=';
+ q = 'CS02Ln7ToL/Z6f0ObAMBtt8pFZz1DMg7mwz01u6nGmHgArRuCuny3mLSW110UtSYuByaxvxYWT1MP7T11y37sKk=';
+ dP = 'B8cUEK8QOWLbNnQE43roULqk6cKd2SFFgVKUpnx9HG3tJjqgMKm2M65QMD4UA10a8BQSPrpoeCAwjY68hbaVfX0=';
+ dQ = 'rix1OAwCwBatBYkbMwHeiB8orhFxGCtrLIO+p8UV7KnKKYx7HKtYF6WXBo/IUGDeTaigFjeKrkPH+We8w3kEuQ==';
+ qInv = 'BZjRBZ462k9jIHUsCdgF/30fGuDQF67u6c76DX3X/3deRLV4Mi9kBdYhHaGVGWZqqH/cTNjIj2tuPWfpYdy7o9A=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 8.1',
+ message: 'BQt1Xl5ogPe56daSp0w3quRJsxv+pt7/g3R6iX9sLIJbsa2/hQo8lplLXeWzPLx9SheROnln',
+ seed: 'dwb/yh7PsevuKlXlxuJM0nl6QSU=',
+ encrypted: 'CbNoPYousPspW2LtH7kpC3FEV7eCUxn0ZHhyr4ibMECUcgIK0SkSvxmxHUgZ9JYUgk/9hNCcChfn0XMJ0SkZeQQQqimVaZ9qhtvjJCtazCOvRWkQgNaxroEPs+MFcIfwlwCSzgC+lWL/QFO2Jizgyqk+E3I9LjpboHXUXw1htUth'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.2',
+ message: 'TraNzZPKmxnfERvUNgj1VwJv5KodXPrCJ6PrWrlUjBigbd7SP4GCWYay/NcRCezvfv+Ihz8HXCqgxGn2nJK8',
+ seed: 'o3F9oUO03P+8dCZlqPqVBYVUg0M=',
+ encrypted: 'Ls8VyXxaFbFHaumGs3G1eiQoT0oWKo0MgYLnkF55IlbxgSul+D8fehMOQtzAIjKETtwUoxpo7peuVko4OjQRZWQkxfYt22Rgk8Nnvh/NpCbPAKBtist+V3dvu9hVrD31BvwWsdfD8hEPPYBo6R4YY2ODHIQJaA2NqezYzx+iDuOd'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.3',
+ message: 'hgSsVjKMGrWtkXhh',
+ seed: '7gYgkHPMoCa7Jk5Rhb+MaLdzn4Y=',
+ encrypted: 'S8iRMKWy2rt8L8+Q610Or55oG3FGo48xc6PZz+xS6p4KQZMuZIqdaTRMUNp2P1GgPJV2ITHoBSJU3NIkjLpA/TFmd4bOBaK3tTGsnaye1YSlm2d8GortjF0V1owFVp4r54C/fbY4/Sv9KoWrJ2hg83dzOPypif/XQ9E+4I4MqYk/'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.4',
+ message: '/dpfv27DYanZpKxoryFqBob0OLHg5cNrlV904QfznA3dzA==',
+ seed: 'mQrVc9xIqXMjW22CVDYY8ulVEF0=',
+ encrypted: 'LkVoR9j8Nv8BR9aZNZS5OXIn1Xd1LHnQ+QT8sDnU2BL+pgWntXTdgsp4b5N1I0hDjun1tUVJhdXw4WmePnrRdaMuFfA96wQquf4d2dsbuG+MCJzLRefvDF7nyptykMprFb7UcDl4ioqT/4Pg6NYkTHEAY2Le72m29Bb7PGhDg/vQ'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.5',
+ message: 'Sl9JFL7iXePGk0HeBw==',
+ seed: '7MY7KPB1byL1Ksjm7BJRpuwwRxg=',
+ encrypted: 'H7k1b9XEsXltsuv30NOTzIEK32FF3vwvznFPedk4ANXirCEeqLvsyktlS5TDsYsw3Vds403JVDbvV6CUFWRZIzWaXXtBce8iwkZw8bIp02A+kfdmcbffl+cxfJdzRHbV89F9Ic+Ctbqfg98uWI02mE/RtYRGi9I7LodfMvaJU/ey'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.6',
+ message: 'jgfWb3uICnJWOrzT81CSvDNAn7f4jyRyvg==',
+ seed: 'OSXHGzYtQKCm3kIUVXm6Hn3UWfw=',
+ encrypted: 'Ov2cZgAUeyF5jYGMZVoPTJIS2ybQsN/cKnWUzLPSL1vx18PhEs1z/H1QnHqLr908J00TmQCflgnsS+ZHfkU/B1qjPbOChwwcNAmu85LXOGrjppa5mpS02gWJRH6VXRbJixdgKlm9c2J5/Nj7KAxEYtWQv6m/E/7VcOr96XMwosIQ'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+
+ // Example 9: A 1536-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'zyzUHjTKOnKOpcuK/2TDbSe971Nk4zb9aNMSPFoZaowocBPoU9UVbVjRUZVFIPtPbXsXq7aBd2WQnFdhGWWdkCsZBu2KKxDBVcJNEkUo2rnurjeb6sZuSkEXhty4/QBi68Aw3hIZoEwqjBt90xMeTWtsruLjGl7UGsFQmy7x7iqxg2S+VoypQcJezIT/nWQ7XsGqrhAqINc/R5t4D9bakQdSEtnqwDoGdNiZ66LkMfTES2Fba6IjK9SzO67XPWJd';
+ exponent = 'AQAB';
+ d = 'GYwUHiNxWpK8z2oRmlvBE4lGjSgR9UjXJ+F7SrDrmG1vIR77U7cffMvqh+5px17mFQCMUzLetSvzkKvfv+N9cgU2gVmyY4wd4ybiHSIlHw+1hIs78VAF0qdDMPCv6RbuYszBNE0dg6cJ5gZ2JzhA9/N3QkpeCk2nXwGzH/doGc+cv90hUkPDkXwD7zgZkxLlZ7O/eu06tFfzce+KFCP0W2jG4oLsERu6KDO5h/1p+tg7wbjGE8Xh6hbBHtEl6n7B';
+ p = '/I1sBL7E65qBksp5AMvlNuLotRnezzOyRZeYxpCd9PF2230jGQ/HK4hlpxiviV8bzZFFKYAnQjtgXnCkfPWDkKjD6I/IxI6LMuPaIQ374+iB6lZ0tqNIwh6T+eVepl79';
+ q = '0gDUXniKrOpgakAdBGD4fdXBAn4S3BoNdYbok52c94m0D1GsBEKWHefSHMIeBcgxVcHyqpGTOHz9+VbLSNFTuicEBvm7ulN9SYfZ4vmULXoUy//+p0/s3ako0j4ln17h';
+ dP = '2xaAL3mi8NRfNY1p/TPkS4H66ChiLpOlQlPpl9AbB0N1naDoErSqTmyL6rIyjVQxlVpBimf/JqjFyAel2jVOBe8xzIz3WPRjcylQsD4mVyb7lOOdalcqJiRKsI23V1Kt';
+ dQ = 'oKMXz+ffFCP4em3uhFH04rSmflSX8ptPHk6DC5+t2UARZwJvVZblo5yXgX4PXxbifhnsmQLgHX6m+5qjx2Cv7h44G2neasnAdYWgatnEugC/dcitL6iYpHnoCuKU/tKh';
+ qInv = 'CyHzNcNTNC60TDqiREV4DC1lW5QBdMrjjHyKTmSTwLqf0wN0gmewg7mnpsth5C2zYrjJiW23Bk4CrVrmFYfaFbRknJBZSQn+s328tlS+tyaOyAHlqLSqORG+vYhULwW+';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 9.1',
+ message: '9zX9VbqSWSw7Urj5xPaaqhy++P6IrdCVWVQSRn+c9OwLiWxZ7aFiEOdUnIq7EM28IaEuyba1uP0vEDmetg==',
+ seed: 'jsll8TSj7Jkx6SocoNyBadXqcFw=',
+ encrypted: 'JnvNEYrKsfyLqByF1zADy4YQ+lXB2X2o1Ip8fwaJak23UaooQlW502rWXzdlPYKfGzf5e4ABlCVFsvwsVac3bKehvksXYMjgWjPlqiUmuNmOMXCI54NMdVsqWbEmMaGCwF1dQ6sXeSZPhFb1Fc5X399RLVST2re3M43Et9eNucCRrDuvU3pp/H9UnZefDv+alP2kFpvU0dGaacmeM8O1VJDVAbObHtrhGP9nk6FTJhWE06Xzn25oLj0XyM0SYfpy'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.2',
+ message: 'gbkGYFAVpjqr5C3fEeGXiRL1QEx0dLJtzj7Ugr+WHsyBi/QgxUZZ',
+ seed: '7LG4sl+lDNqwjlYEKGf0r1gm0Ww=',
+ encrypted: 'k6yfBnHsKay7RE7/waV0E1HWD9sOOT+/dUrPDeSXYaFIQd93cum8gnc5ZqFYTE1yuuoAEY+D81zKblN8vU2BH1WDspeD2KbZTNMb5w1vUmwQ/wnG+nzgaXlaP80FEf1fy1ZLzIDqnHjzi4ABJTnYpN32/oHpzdt/UNu7vMfl2GCXzPTsSRifuL8xi+bVoHFdUWtJrxkSWM0y3IM85utGc8A6Gbus6IzFSJX2NswMHsiQltEc4jWiZcoXZCMqaJro'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.3',
+ message: '/TJkKd+biQ4JtUsYuPNPHiQ=',
+ seed: '6JuwMsbOYiy9tTvJRmAU6nf3d8A=',
+ encrypted: 'gevdlQVLDIIu+a12k/Woet+0tMTOcN8t+E7UnATaWLpfwgoZ4abot6OQCyJ5bcToae5rQnktFajs61bAnGmRToE86o9pMeS47W9CGvKY1ZXJf0eJx8qmEsfvNgmEwhuT7cVAEGi1r0x4qHcbmE1TuOqK3y9qfUoLp2x14d2fZY8g3tSkYHHUbXeRtWgD2P6n8LD45Brj8JODpvlYX+d1Pqr/0r+UVjEIvuzCB7u1NfX8xwXw3en3CMYvSanJA3HT'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.4',
+ message: '8UWbXwyS8BoPcjouVmJITY+MCiD8KdrWrNQ7tfPv/fThtj4H/f5mKNDXTKGb8taeSgq/htKTklp5Z3L4CI4=',
+ seed: 'YG87mcC5zNdx6qKeoOTIhPMYnMw=',
+ encrypted: 'vMNflM3mbLETZiXWJblEMqNbIvPS+hGmE/8PylvVf4e5AszcHNCuvLBxXuhp0dH+OV9nkwA/XspGUFnIhmDURv9fCBhVICJVfjjAimfq2ZEmIlTxBoKXXsVjl3aFN/SXevbV9qrOt/sl3sWTcjAjH9iXivSRGaKfKeQkq4JytHVieS1clPd0uIKdCw2fGoye3fN1dNX6JI7vqcUnH8XsJXnIG91htBD6Yf425CQiHBE63bJ1ZkyAHTTKjGNR5KhY'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.5',
+ message: 'U+boxynW+cMZ3TF+dLDbjkzMol88gwV0bhN6xjpj7zc557WVq7lujVXlT3vUGrQzN4/7kR0=',
+ seed: '/LxCFALp7KvGCCr6QLpfJlIshA4=',
+ encrypted: 'Iyr7ySf6CML2onuH1KXLCcB9wm+uc9c6kFWIOfT9ZtKBuH7HNLziN7oWZpjtgpEGp95pQs1s3OeP7Y0uTYFCjmZJDQNiZM75KvlB0+NQVf45geFNKcu5pPZ0cwY7rseaEXn1oXycGDLyg4/X1eWbuWWdVtzooBnt7xuzrMxpfMbMenePYKBkx/b11SnGIQJi4APeWD6B4xZ7iZcfuMDhXUT//vibU9jWTdeX0Vm1bSsI6lMH6hLCQb1Y1O4nih8u'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.6',
+ message: 'trKOohmNDBAIvGQ=',
+ seed: 'I6reDh4Iu5uaeNIwKlL5whsuG6I=',
+ encrypted: 'Q4zH3AimjaJJ5CUF+Fc7pg4sJ3PVspD0z53/cY6EIIHDg+ZwJKDylZTqmHudJeS3OPKFlw0ZWrs6jIBU49eda5yagye6WW8SWeJxJmdHZpB9jVgv86hHYVSSmtsebRI1ssy07I9mO6nMZwqSvr2FPI2/acZDbQFvYa3YNulHMkUENCB/n9TEPewqEqlY76Ae/iZpiZteYEwlXFX7cWbeVYnjaVl7sJFowG3V2xd+BqF0DrLVyC+uym2S/O6ZMbqf'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+
+ // Example 10: A 2048-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'rkXtVgHOxrjMBfgDk1xnTdvg11xMCf15UfxrDK7DE6jfOZcMUYv/ul7Wjz8NfyKkAp1BPxrgfk6+nkF3ziPn9UBLVp5O4b3PPB+wPvETgC1PhV65tRNLWnyAha3K5vovoUF+w3Y74XGwxit2Dt4jwSrZK5gIhMZB9aj6wmva1KAzgaIv4bdUiFCUyCUG1AGaU1ooav6ycbubpZLeGNz2AMKu6uVuAvfPefwUzzvcfNhP67v5UMqQMEsiGaeqBjrvosPBmA5WDNZK/neVhbYQdle5V4V+/eYBCYirfeQX/IjY84TE5ucsP5Q+DDHAxKXMNvh52KOsnX1Zhg6q2muDuw==';
+ exponent = 'AQAB';
+ d = 'BWsEIW/l81SsdyUKS2sMhSWoXFmwvYDFZFCiLV9DjllqMzqodeKR3UP0jLiLnV/A1Jn5/NHDl/mvwHDNnjmMjRnmHbfHQQprJnXfv100W4BNIBrdUC1c4t/LCRzpmXu+vlcwbzg+TViBA/A29+hdGTTRUqMj5KjbRR1vSlsbDxAswVDgL+7iuI3qStTBusyyTYQHLRTh0kpncfdAjuMFZPuG1Dk6NLzwt4hQHRkzA/E6IoSwAfD2Ser3kyjUrFxDCrRBSSCpRg7Rt7xA7GU+h20Jq8UJrkW1JRkBFqDCYQGEgphQnBw786SD5ydAVOFelwdQNumJ9gkygHtSV3UeeQ==';
+ p = '7PWuzR5VFf/6y9daKBbG6/SQGM37RjjhhdZqc5a2+AkPgBjH/ZXMNLhX3BfwzGUWuxNGq01YLK2te0EDNSOHtwM40IQEfJ2VObZJYgSz3W6kQkmSB77AH5ZCh/9jNsOYRlgzaEb1bkaGGIHBAjPSF2vxWl6W3ceAvIaKp30852k=';
+ q = 'vEbEZPxqxMp4Ow6wijyEG3cvfpsvKLq9WIroheGgxh5IWKD7JawpmZDzW+hRZMJZuhF1zdcZJwcTUYSZK2wpt0bdDSyr4UKDX30UjMFhUktKCZRtSLgoRz8c52tstohsNFwD4F9B1RtcOpCj8kBzx9dKT+JdnPIcdZYPP8OGMYM=';
+ dP = 'xzVkVx0A+xXQij3plXpQkV1xJulELaz0K8guhi5Wc/9qAI7U0uN0YX34nxehYLQ7f9qctra3QhhgmBX31FyiY8FZqjLSctEn+vS8jKLXc3jorrGbCtfaPLPeCucxSYD2K21LCoddHfA8G645zNgz72zX4tlSi/CE0flp55Tp9sE=';
+ dQ = 'Jlizf235wQML4dtoEX+p2H456itpO35tOi9wlHQT7sYULhj7jfy2rFRdfIagrUj4RXFw8O+ya8SBJsU+/R0WkgGY3CoRB9woLbaoDNMGI2C6P6E/cOQxL/GmzWuPxM2cXD2xfG1qVyEvc64p9hkye61ZsVOFhYW6Tii2CmKkXkk=';
+ qInv = 'bzhSazklCFU07z5BWoNu3ouGFYosfL/sywvYNDBP7Gg7qNT0ecQz1DQW5jJpYjzqEAd22Fr/QB0//2EO5lQRzjsTY9Y6lwnu3kJkfOpWFJPVRXCoecGGgs2XcQuWIF7DERfXO182Ij+t1ui6kN18DuYdROFjJR4gx/ZuswURfLg=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 10.1',
+ message: 'i7pr+CpsD4bV8XVul5VocLCJU7BrTrIFvBaU7g==',
+ seed: 'R+GrcRn+5WyV7l6q2G9A0KpjvTM=',
+ encrypted: 'U+pdwIzSYPs7hYVnKH+pFVLDCy/r+6IT8K6HcC0GjRm6sH/ldFI9+0ITnWjDxa/u4L/ky3lpy/OCuATW5hOWFE4tDmB0H4mTwwFLWLmxlXqLq80jr4VPTDVvsWYqpyv8x+WGVZ3EKA0WDBJnhacj6+6+/3HxFZRECq74fRB5Ood0ojnUoEyH/hRnudr4UgjsbHJVeUqWzCkUL5qL1Bjjwf1nNEsM0IKd87K+xgJTGWKTxrNNP3XTLyE91Fxic9UFrfTM7RBXy3WPwmru+kQSVe1OZMGZ7gdefxZkYYL9tGRzm2irXa/w5j6VUgFoJPBUv008jJCpe7a2VTKE60KfzA=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.2',
+ message: '5q0YHwU7WKkE8kV1EDc+Vw==',
+ seed: 'bRf1tMH/rDUdGVv3sJ0J8JpAec8=',
+ encrypted: 'orGkMKnWV+L6HCu17UP/slwFowj+kJPAEDF5X1h0QAEQgorlj7m1gc6d3dPlSa4EoJhUWb3mxiZZTnsF3EJ4sqFGXBNoQIgjyF6W3GbDowmDxjlmT8RWmjf+IeWhlbV3bu0t+NjTYa9obnUCKbvWY/FhhopQYV4MM3vsDKNf7AuxnDbrLgu8wFgvodk6rNsGEGP1nyzh7kNgXl2J7KGD0qzf6fgQEQIq07Q6PdQX2slLThHqgbGSlm6WaxgggucZZGB7T4AC82KZhEoR8q4PrqwurnD49PmAiKzc0KxVbp/MxRFSGQj60m8ExkIBRQMFd4dYsFOL+LW7FEqCjmKXlQ=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.3',
+ message: 'UQos9g6Gb6I0BVPJTqOfvCVjEeg+lEVLQSQ=',
+ seed: 'OFOHUU3szHx0DdjN+druSaHL/VQ=',
+ encrypted: 'mIbD5nZKi5qE6EFI69jDsaqAUDgaePZocUwW2c/Spu3FaXnFNdne47RLhcGL6JKJkjcXEUciFtld2pjS7oNHybFN/9/4SqSNJawG99fmU5islnsc6Qkl9n3OBJt/gS2wdCmXp01E/oHb4Oej/q8uXECviI1VDdu+O8IGV6KVQ/j8KRO5vRphsqsiVuxAm719wNF3F+olxD9C7Sffhzi/SvxnZv96/whZVV7ig5IPTIpjxKc0DLr93DOezbSwUVAC+WyTK1t5Fnr2mcCtP8z98PROhacCYr8uGP40uFBYmXXoZ/+WnUjqvyEicVRs3AWmnstSblKHDINvMHvXmHgO3g=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.4',
+ message: 'vN0ZDaO30wDfmgbiLKrip18QyR/2Z7fBa96LUwZKJkmpQEXJ',
+ seed: 'XKymoPdkFhqWhPhdkrbg7zfKi2U=',
+ encrypted: 'Yxjp+1wNBeUwfhaDQ26QMpOsRkI1iqoiPXFjATq6h+Lf2o5gxoYOKaHpJoYWPqC5F18ynKOxMaHt06d3Wai5e61qT49DlvKM9vOcpYES5IFg1uID2qWFbzrKX/7Vd69JlAjj39Iz4+YE2+NKnEyQgt5lUnysYzHSncgOBQig+nEi5/Mp9sylz6NNTR2kF4BUV+AIvsVJ5Hj/nhKnY8R30Vu7ePW2m9V4MPwsTtaG15vHKpXYX4gTTGsK/laozPvIVYKLszm9F5Cc8dcN4zNa4HA5CT5gbWVTZd5lULhyzW3h1EDuAxthlF9imtijU7DUCTnpajxFDSqNXu6fZ4CTyA=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.5',
+ message: 'p91sfcJLRvndXx6RraTDs9+UfodyMqk=',
+ seed: 'lbyp44WYlLPdhp+n7NW7xkAb8+Q=',
+ encrypted: 'dSkIcsz9SkUFZg1lH1babaoJyhMB2JBjL2qZLz1WXO5GSv3tQO07W+k1ZxTqWqdlX0oTZsLxfHKPbyxaXR+OKEKbxOb48s/42o3A4KmAjkX9CeovpAyyts5v//XA4VnRG2jZCoX3uE4QOwnmgmZkgMZXUFwJKSWUaKMUeG106rExVzzyNL9X232eZsxnSBkuAC3A3uqTBYXwgx/c2bwz1R957S/8Frz01ZgS/OvKo/kGmw5EVobWRMJcz2O0Vu5fpv/pbxnN91H+2erzWVd1Tb9L/qUhaqGETcUHyy0IDnIuuhUDCMK1/xGTYg8XZuz0SBuvuUO9KSh38hNspJSroA=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.6',
+ message: '6vGnOhsMRglTfeac2SKLvPuajKjGw++vBW/kp/RjTtALfDnsaSLXuOosBOus',
+ seed: 'n0fd9C6X7qhWqb28cU6zrCL26zI=',
+ encrypted: 'LSB6c0Mqj7TAMFGz9zsophdkCY36NMR6IJlfgRWqaBZnm1V+gtvuWEkIxuaXgtfes029Za8GPVf8p2pf0GlJL9YGjZmE0gk1BWWmLlx38jA4wSyxDGY0cJtUfEb2tKcJvYXKEi10Rl75d2LCl2Pgbbx6nnOMeL/KAQLcXnnWW5c/KCQMqrLhYaeLV9JiRX7YGV1T48eunaAhiDxtt8JK/dIyLqyXKtPDVMX87x4UbDoCkPtnrfAHBm4AQo0s7BjOWPkyhpje/vSy617HaRj94cGYy7OLevxnYmqa7+xDIr/ZDSVjSByaIh94yCcsgtG2KrkU4cafavbvMMpSYNtKRg=='
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha1', examples);
+ }
+
+ function testOAEPSHA256() {
+ var modulus, exponent, d, p, q, dP, dQ, qInv, pubkey, privateKey;
+ var examples;
+
+ // Example 1: A 1024-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'qLOyhK+OtQs4cDSoYPFGxJGfMYdjzWxVmMiuSBGh4KvEx+CwgtaTpef87Wdc9GaFEncsDLxkp0LGxjD1M8jMcvYq6DPEC/JYQumEu3i9v5fAEH1VvbZi9cTg+rmEXLUUjvc5LdOq/5OuHmtme7PUJHYW1PW6ENTP0ibeiNOfFvs=';
+ exponent = 'AQAB';
+ d = 'UzOc/befyEZqZVxzFqyoXFX9j23YmP2vEZUX709S6P2OJY35P+4YD6DkqylpPNg7FSpVPUrE0YEri5+lrw5/Vf5zBN9BVwkm8zEfFcTWWnMsSDEW7j09LQrzVJrZv3y/t4rYhPhNW+sEck3HNpsx3vN9DPU56c/N095lNynq1dE=';
+ p = '0yc35yZ//hNBstXA0VCoG1hvsxMr7S+NUmKGSpy58wrzi+RIWY1BOhcu+4AsIazxwRxSDC8mpHHcrSEurHyjnQ==';
+ q = 'zIhT0dVNpjD6wAT0cfKBx7iYLYIkpJDtvrM9Pj1cyTxHZXA9HdeRZC8fEWoN2FK+JBmyr3K/6aAw6GCwKItddw==';
+ dP = 'DhK/FxjpzvVZm6HDiC/oBGqQh07vzo8szCDk8nQfsKM6OEiuyckwX77L0tdoGZZ9RnGsxkMeQDeWjbN4eOaVwQ==';
+ dQ = 'lSl7D5Wi+mfQBwfWCd/U/AXIna/C721upVvsdx6jM3NNklHnkILs2oZu/vE8RZ4aYxOGt+NUyJn18RLKhdcVgw==';
+ qInv = 'T0VsUCSTvcDtKrdWo6btTWc1Kml9QhbpMhKxJ6Y9VBHOb6mNXb79cyY+NygUJ0OBgWbtfdY2h90qjKHS9PvY4Q==';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 1.1',
+ message: 'ZigZThIHPbA7qUzanvlTI5fVDbp5uYcASv7+NA==',
+ seed: 'GLd26iEGnWl3ajPpa61I4d2gpe8Yt3bqIQadaXdqM+k=',
+ encrypted: 'W1QN+A1CKWotV6aZW7NYnUy7SmZd34SiX0jiPiLj9+8sZW6O/L7793+IFFSO3VKbPWhrjJPyR3ZmZ+yHDCzTDkRth+s5FN3nuFtlD3XQmmh0+x60PvAUiXJnAMcwxV96wHKjsUNPSnE1fsrCPBpIO5ZRaJ1pIF6R25IeuMwDujo='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.2',
+ message: 'dQxAR/VH6OQUEYVlIymKybriRe+vE5f75W+d1Q==',
+ seed: 'DMdCzkqbfzL5UbyyUe/ZJf5P418Mx0LOSpt/MvlRvLI=',
+ encrypted: 'jsKSyOW1BkucnZpnt9fS72P/lamWQqexXEDPVs8uzGlFj24Rj+cqGYVlt7i9nTmOGj2YrvM8swUTJQCYIF+QBiKbkcA7WBTBXfiUlkHvpWQD0bLwOkp1CmwfpF4sq2gTsCuSaGzZAc50ZAIOvpldizU7uOCwNNGOlERcFkvhfEE='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.3',
+ message: '2Urggy5kRc5CMxywbVMagrHbS6rTD3RtyRbfJNTjwkUf/1mmQj6w4dAtT+ZGz2md/YGMbpewUQ==',
+ seed: 'JRTfRpV1WmeyiOr0kFw27sZv0v0lFN9GlXVaZ7KI6vQ=',
+ encrypted: 'LcQ1BhOH4Vs0XX8/QJ6q/L0vSs9BUXfA20lQ6mwAt/gvUaUOvKJWBujoxt1QgpRnU6WuH7cSCFWXuKNnrhofpFF3CBTLIUbHZFoou0A4Roi4vFGFvYYu96Boy+oWivwB9/BKs1QMQeHADgNwUgqVD15+q27yHdfIH7kGp+DiGas='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.4',
+ message: 'UuZQ2Y5/KgSLT4aFIVO5fgHdMW80ahn2eoU=',
+ seed: 'xENaPhoYpotoIENikKN877hds/vEQ1o+Ghimi2ggQ2I=',
+ encrypted: 'ZMkqw9CM3SuY2zPBr8/9QbgXaVon4O4AKIufl3i7RVPD07fiTOnXF0aSWKUcdXNhE6ZcXc0Ha97/S5aw6mQKYfbmjaSq/H45s2nfZYTNIa74OgsV1DTDDLSF6/3J2UKhsG0LGIFaV9cNjfucDA5KbfQbzTq8u/+WN06J6nbInrI='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.5',
+ message: 'jaif2eX5dKKf7/tGK0kYD2z56AI=',
+ seed: 'sxjELfO+D4P+qCP1p7R+1eQlo7WzGMQt874Pg/6oI/U=',
+ encrypted: 'NzKEr8KhWRbX/VHniUE8ap0HzdDEWOyfl7dfNHXjL4h/320dmK633rGUvlA7sE4z9yuMj/xF++9ZeBzN6oSPLhVJV/aivUfcC8J99lwwp49W7phnvkUA4WUSmUeX+XRhwj8cR27mf5lu/6kKKbgasdt4BHqXcc5jOZICnld6vdE='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 1.6',
+ message: 'JlIQUIRCcQ==',
+ seed: '5OwJgsIzbzpnf2o1YXTrDOiHq8Lk7AmCwjNvOmd/ajU=',
+ encrypted: 'nfQEzsDY2gS9UYXF85t+u0Tm7HrOmmf+LqxCD+6N4XD36NoQ96PE9Squ83PvxKy8Bj8Q0N2L8E5Z5/9AWxLPCBqOkqkqIqO7ZDQMmpHml3H1yz82rpAzAQi6acZDSFQAW8NKhg4nEEwfwKdaGQcI0JZm6FrTQUuXskOqFUT0NJc='
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+
+ // Example 2: A 1025-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'AZR8f86QQl9HJ55whR8l1eYjFv6KHfGTcePmKOJgVD5JAe9ggfaMC4FBGQ0q6Nq6fRJQ7G22NulE7Dcih3x8HQpn8UsWlMXwN5RRpD5Joy3eg2cLc9qRocmbwjtDamAFXGEPC6+ZwaB5VluVo/FSZjLR1Npg8g7aJeZTxPACdm9F';
+ exponent = 'AQAB';
+ d = 'CCPyD6212okIip0AiT4h+kobEfvJPGSjvguq6pf7O5PD/3E3BMGcljwdEHqumQVHOfeeAuGG3ob4em3e/qbYzNHTyBpHv6clW+IGAaSksvCKFnteJ51xWxtFW91+qyRZQdl2i5rO+zzNpZUto87nJSW0UBZjqO4VyemS2SRi/jk=';
+ p = 'AVnb3gSjPvBvtgi4CxkPTT4ivME6yOSggQM6v6QW7bCzOKoItXMJ6lpSQOfcblQ3jGlBTDHZfdsfQG2zdpzEGkM=';
+ q = 'AStlLzBAOzi0CZX9b/QaGsyK2nA3Mja3IC05su4wz7RtsJUR9vMHzGHMIWBsGKdbimL4It8DG6DfDa/VUG9Wi9c=';
+ dP = 'Q271CN5zZRnC2kxYDZjILLdFKj+1763Ducd4mhvGWE95Wt270yQ5x0aGVS7LbCwwek069/U57sFXJIx7MfGiVQ==';
+ dQ = 'ASsVqJ89+ys5Bz5z8CvdDBp7N53UNfBc3eLv+eRilIt87GLukFDV4IFuB4WoVrSRCNy3XzaDh00cpjKaGQEwZv8=';
+ qInv = 'AnDbF9WRSwGNdhGLJDiac1Dsg2sAY6IXISNv2O222JtR5+64e2EbcTLLfqc1bCMVHB53UVB8eG2e4XlBcKjI6A==';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 2.1',
+ message: 'j/AMqmBccCgwY02abD1CxlK1jPHZL+xXC+7n',
+ seed: 'jEB7XsKJnlCZxT6M55O/lOcbF4KMQHtewomeUJnFPow=',
+ encrypted: 'AR3o2JwhHLKUfOLZ26KXD9INUK1/fWJzdZix7E545qladDYdpHRaE5zBP9nf6IPmZvBUPq75n1E4suxm+Bom7crf9be1HXCFZnmR/wo92CKg4D1zRlBwr/3Gitr3h9rU6N+tid2x9yOYj955rf3Bq4j6wmjYQpWphbhBIBMoliyJ'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.2',
+ message: 'LQ==',
+ seed: 'tgDPPC5QbX8Wd4yRDTqLAD7uYdW2AM88LlBtfxZ3jJE=',
+ encrypted: 'AIeYuAD2aYZYnEu1YK+INur95FfP2pTz8/k4r3xwL4bVMufgvzWFLdVK24fP96jTteLkrX6HjmebBVeUhSWG3ahebh3LH5yVS9yx+xHzM1Jxc8X1rS+kYgdCGWFbszMF/vP0ogisy5XthHqcoHNEM4Rzln7ugrXuS+dNuuPEjIAf'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.3',
+ message: 'dPyIxRvJD3evnV6aSnATPUtOCzTaPDfH744=',
+ seed: 'pzdoruqpH52MHtb50rY0Z/B8yuOnN2iu6qkfnYwe1vk=',
+ encrypted: 'AMkW9IJHAFs0JbfwRZhrRITtj1bQVDLcjFCwYxHMDBlSHIqpDzSAL8aMxiUq41Feo9S2O/1ZTXIiK8baJpWs9y+BPqgi1lABB6JJIvU2QZYMzWK0XgjkWk12g6HSPFhuK4yf+LQ1UYpbKVquUdZ9POOCR8S7yS+tdful6qP8Wpkm'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.4',
+ message: 'p+sqUDaTHSfU6JEybZlpL/rdqb9+/T405iLErcCF9yHf6IUHLHiiA7FRc5vlQPqMFToQ8Ao=',
+ seed: 'mns7DnCL2W+BkOyrT7mys4BagVaaezsOcIvZb4GQ7Ks=',
+ encrypted: 'AJ6YQ3DNjd7YXZzjHASKxPmwFbHKwoEpof+P+Li3+o6Xa95C21XyWZF0iCXc5USp5jwLt66T6G3aYQkEpoyFGvSPA3NV6tOUabopdmslYCkOwuOIsFLiuzkJc4Hu6nWXeJtTVtHn7FmzQgzQOMjuty1YConfe78YuQvyE3IAKkr2'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.5',
+ message: 'LvKwZvhUwz873LtZlKQ15z1sbA==',
+ seed: '6zzrvErcFrtI6IyK7A40r39Cf9PrPOu8StwWu0jojIo=',
+ encrypted: 'AMv457W0EOt8RH+LAEoMQ7dKjZamzOdwTHJepDkaGGoQHi2z8coCiVemL5XYZ+ctjPBdw3y3nlMn1sif9i3WCzY26ram8PL5eVYk7Bm3XBjv9wuhw1RZmLFzKfJS+3vi+RTFhwjyyeaJrc07f5E7Cu7CVWNh3Oe3lvSF3TB2HUI8'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 2.6',
+ message: 'in+zRMi2yyzy7x9kP5oyGPbhm7qJwA==',
+ seed: 'TEXPTVfJjj1tIJWtxRxInrUN/4RMRc9NV8mOPW0gla0=',
+ encrypted: 'AJ5iMVr3Q6ZZlqLj/x8wWewQBcUMnRoaS2lrejzqRk12Bw120fXolT6pgo20OtM6/ZpZSN7vCpmPOYgCf93MOqKpN1pqumUH33+iP1a+tos5351SidwwNb2hLy3JfhkapvjB+c9JvbIolIgr+xeWhWPmMDam/Du/y+EsBOdZrbYc'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+
+ // Example 3: A 1026-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'ArWP7AOahgcApNe2Ri+T5s3UkRYd3XT06BC0DjwWUgBqXCd7J3TBEwWky6taeO+lfheobfej+jb8Sx0iSfIux8LdakYyMqzOqQbWbr6AtXBLEHKdpvgzI0q7Xv3UopLL+tM7TTP6ehS4w5e1bjrNISA0KLd836M6bacGs9iw/EPp';
+ exponent = 'AQAB';
+ d = 'FbSKW1aDqUZw4jtXGPgU+g4T+FA49QcRGCy6YVEFgfPSLH4jLvk34i5VHWi4bi+MsarYvi5Ij13379J54/Vo1Orzb4DPcUGs5g/MkRP7bEqEH9ULvHxRL/y+/yFIeqgR6zyoxiAFNGqG3oa/odipSP0/NIwi6q3zM8PObOEyCP0=';
+ p = 'Ab8B0hbXNZXPAnDCvreNQKDYRH0x2pGamD9+6ngbd9hf43Gz6Tc+e2khfTFQoC2JWN5/rZ1VUWCVi0RUEn4Ofq8=';
+ q = 'AY0zmWWBZts4KYFteylUFnWenJGYf1stiuzWOwS0i9ey/PIpu3+KbciLoT3S45rVW20aBhYHCPlwC+gLj9N0TOc=';
+ dP = 'BsCiSdIKby7nXIi0lNU/aq6ZqkJ8iMKLFjp2lEXl85DPQMJ0/W6mMppc58fOA6IVg5buKnhFeG4J4ohalyjk5Q==';
+ dQ = '0dJ8Kf7dkthsNI7dDMv6wU90bgUc4dGBHfNdYfLuHJfUvygEgC9kJxh7qOkKivRCQ7QHmwNEXmAuKfpRk+ZP6Q==';
+ qInv = 'jLL3Vr2JQbHTt3DlrTHuNzsorNpp/5tvQP5Xi58a+4WDb5Yn03rP9zwneeY0uyYBHCyPfzNhriqepl7WieNjmg==';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 3.1',
+ message: 'CHggtWno+o0=',
+ seed: 'jO1rGWKQgFeQ6QkHQBXmogsMSJSM7WsZYpCAV5DpCQc=',
+ encrypted: 'AJqBCgTJGSHjv2OR0lObiDY2gZmWdutHfVeadCdFr2W4mS3ZHwet283wbtY/bsM8w0rVxNAPh3NZNrcRt56NhoT0NzD2IK3WNy39Im/CfbicvC6Vq2PyXUh1iza+90PUM3jECPP5NsOx658MzEnYyFZFb9izZIna6YLsXwkWoHVO'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.2',
+ message: 'RlOsrxcZYLAfUqe+Y6OrIdw2jsQ7UNguw3geBA==',
+ seed: 'tCkdZWdVCEjMFWlnyAm6q2ylB/C0KR1lZ1UISMwVaWc=',
+ encrypted: 'ARCj8j/hSsscyXtuINlyU0HuC+d7wZc7bSekF60BJFWKeKa1p28d4KsJXmdqI22sxha7PgkI9bgpfgdBd8KHp12g5y68uXiwRyPOvv8s6YDKmJFhbW13LHbE3iZHch2YG1eHi/20M/IrsAqCuk/W5Q/dP5eSVM1hLT9LBVsX3rIH'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.3',
+ message: '2UzQ4I+kBO2J',
+ seed: 'zoko9gWVWCVACLrdl5T63NL9H2XOiSj2BZVYJUAIut0=',
+ encrypted: 'Anfa/o/QML7UxLCHcSUWFPUWhcp955u97b5wLqXuLnWqoeQ3POhwasFh3/ow2lkzjjIdU47jkYJEk6A0dNgYiBuDg57/KN5yS2Px/QOSV+2nYEzPgSUHGyZacrHVkj/ZVyZ+ni7Iyf/QkNTfvPGxqmZtX6cq095jgdG1ELgYsTdr'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.4',
+ message: 'bMZBtrYeb5Y5dNrSOpATKE7x',
+ seed: 'bil59S1oFKV9g7CQBUiI8RmluaNuKXn1LWgUpX2DsJA=',
+ encrypted: 'AalUnNYX91mP0FrqphpfhU22832WgnjDNRU1pkpSrd5eD7t7Q1YhYE+pKds6glA8i1AE/li216hJs2IbCJMddyaXrDzT8V9/UfIUaSkLfcRYBrTn9DEDOTjY1Xnn38poLOFykpZbAz5hdbOh0qG39qFgl5QZG0+aTBd1tmlMZBfO'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.5',
+ message: '31FRgyth9PJYkftBcvMo0u3fg3H/z9vpl5OSlfMOymkYAXz9oRU796avh1kyIw==',
+ seed: 'LXYL/jjFneNM3IuMeKOOZihKLSctdgv+OMWd40zci4w=',
+ encrypted: 'AGgQQYTuy9dW6e3SwV5UFYbEtqQD7TDtxcrMYOmYlTPgTwIFpo4GbQbtgD9BMFAW7a1lIzLxKEld49jH6m95Xgtq/BAVFl/gXin5MMbiZfRTOl38miBTg5a6IS9w6tcrWIBeY5Z5n4iCuUqF9r/m9TqvxWF0aMP2VGVKZn+LHMVj'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 3.6',
+ message: 'PDutiTxUSm1SCrAiMZGIyNUEt6eIuFCQO4WXLqoYVS4RNKetYJiCYlT/erZys9jrMVj6xtTLrvE=',
+ seed: '8XR3nF/Tz+AHuty3o2ybVb/Pvw7xdHecX9PP4Ae63Lc=',
+ encrypted: 'Aps8BQrRkPPwpNIjHw3NBznsDvp1hIHmlbG5wRERr9+Ar4ervO2GA/MMUVNijdZEtFnCGjbLwpM6RKzCk96jJX1bIgzq7hnmIzwKmq2Ue4qqO29rQL39jpCS87BBo/YKMbkYsPc2yYSDMBMOe9VDG63pvDgFGrlk/3Yfz1km3+/Y'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+
+ // Example 4: A 1027-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'BRJAtswABPpI0BNGccB4x8jew7Pi8lvCVkRnM52ziFPQa4XupbLeNTv/QqwuRryX+uaslhjalTelyPVTweNXYlmR1hCNzXiF+zolQT9T78rZSMs1zZua6cHGdibRE9V93kxb6na7W7felsANBzculoWm11z50jn6FI1wkxtfP7A5';
+ exponent = 'AQAB';
+ d = 'BBH/yjt8penpvn/jioUQXjU4ltsFxXlq7NKnJRYes2UchimpuGK5BNewx7N/jLWhwrVAAQGKAKHrLK/k7k6UksNIvCvtq0ueu/Bk6O/zIrkAn47sZTkF9A34ijzcSdRWf3VifUGspiQSm0agt8aY5eZfK3uhAsdJoQE1tlQNBAE=';
+ p = 'AnRYwZ7BY2kZ5zbJryXWCaUbj1YdGca/aUPdHuGriko/IyEAvUC4jezGuiNVSLbveSoRyd6CPQp5IscJW266VwE=';
+ q = 'AhDumzOrYXFuJ9JRvUZfSzWhojLi2gCQHClL8iNQzkkNCZ9kK1N1YS22O6HyA4ZJK/BNNLPCK865CdE0QbU7UTk=';
+ dP = 'OfoCi4JuiMESG3UKiyQvqaNcW2a9/R+mN9PMSKhKT0V6GU53J+Sfe8xuWlpBJlf8RwxzIuvDdBbvRYwweowJAQ==';
+ dQ = 'AV2ZqEGVlDl5+p4b4sPBtp9DL0b9A+R9W++7v9ax0Tcdg++zMKPgIJQrL+0RXl0CviT9kskBnRzs1t1M8eVMyJk=';
+ qInv = 'AfC3AVFws/XkIiO6MDAcQabYfLtw4wy308Z9JUc9sfbL8D4/kSbj6XloJ5qGWywrQmUkz8UqaD0x7TDrmEvkEro=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 4.1',
+ message: 'SoZglTTuQ0psvKP36WLnbUVeMmTBn2Bfbl/2E3xlxW1/s0TNUryTN089FmyfDG+cUGutGTMJctI=',
+ seed: 'HKwZzpk971X5ggP2hSiWyVzMofMcrBnOmT3vVfmCA/Y=',
+ encrypted: 'AooWJVOiXRikAgxb8XW7nkDMKIcrCgZNTV0sY352+QatjTq4go6/DtieHvIgUgb/QYBYlOPOZkdiMWXtOFdapIMRFraGeq4mKhEVmSM8G5mpVgc62nVR0jX49AXeuw7kMGxnKTV4whJanPYYQRoOb0L4Mf+8uJ5QdqBE03Ohupsp'
+ /* FIXME: could not convert 4.2', to SHA-256, message too long
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.2',
+ message: 'sK3E8/4R2lnOmSdz2QWZQ8AwRkl+6dn5oG3xFm20bZj1jSfsB0wC7ubL4kSci5/FCAxcP0QzCSUS7EaqeTdDyA==',
+ seed: '9UXViXWF49txqgy42nbFHQMq6WM=',
+ encrypted: 'AJe2mMYWVkWzA0hvv1oqRHnA7oWIm1QabwuFjWtll7E7hU60+DmvAzmagNeb2mV4yEH5DWRXFbKA03FDmS3RhsgLlJt3XK6XNw5OyXRDE2xtpITpcP/bEyOiCEeCHTsYOB3hO7SarqZlMMSkuCcfPq4XLNNm4H5mNvEBnSoortFe'
+ */
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.3',
+ message: 'v21C5wFwex0CBrDItFoccmQf8SiJIZqCveqWW155qWsNAWPtnVeOya2iDy+88eo8QInYNBm6gbDGDzYG2pk=',
+ seed: 'rZl/7vcw1up75g0NxS5y6sv90nWtmX/u9zDW6nvmDQ0=',
+ encrypted: 'AtYYko32Vmzn3ZtrsDQH9Mw/cSQk9pePdwQZJ6my7gYXWYpBdhbEN/fH7LMmvjtHnKLLTDazfF1HT0tTG6E+TY002cy+fMUvdRn0rfmFkNeHeqVOABP2EmI4eXFCBbbIlpshLxbA3vDTzPPZZqwMN+KPG4O11wmS9DcyHYtpsIOU'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.4',
+ message: '+y7xEvXnZuuUAZKXk0eU974vb8HFjg==',
+ seed: 'E2RU31cw9zyAen5A2MGjEqxbndMTZFTfVzD3PIB6fkA=',
+ encrypted: 'AZX8z/njjTP/ApNNF+BNGUjlczSK/7iKULnZhiAKo4LJ0XaTzTtvL9jacr+OkRxSPUCpQeK36wXdi9qjsl3SO9D7APyzN1nNE5Nu5YstiAfEMVNpdRYGdgpUasEZ4jshBRGXYW28uTMcFWRtzrlol9Lc7IhIkldTXZsR9zg11KFn'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.5',
+ message: 'KMzUR7uehRZtq7nlt9GtrcS5058gTpbV5EDOmtkovBwihA==',
+ seed: 'vKgFf4JLLqJX8oYUB+72PTMghoG8qAV/gksuolfyhhQ=',
+ encrypted: 'A8GIo5X2qOS6MdKjYJg+h3hi2endxxeb3F5A8v+MbC7/8WbBJnzOvKLb6YMukOfAqutJiGGzdPQM9fopdhbRwS/Ovw4ksvmNBVM+Q26CFPqvdhV8P0WxmeYTxGFGrLgma+fwxpe7L6mj300Jq6Y/5kfTEJSXNdKuLRn0JsIg8LSD'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 4.6',
+ message: '8iJCdR7GsQ==',
+ seed: 'Ln4eF/ZHtd3QM+FUcvkPaBLzrE4ufh4X9ke13dAz4VQ=',
+ encrypted: 'AM9cnO14EVBadGQYTnkkbm/vYwqmnYvnAutrc4bZR3XC0DNhhuUlzFosUSmaC1LrjKcFfcqZOwzlev5uZycR7tUlLihC6lf4o0khAjUb03Dj+ubNsDKNCOA6vP63N3p6jSVIak7EPu0KtBLuNpIyW5mdkMuwssV7CNLOQ6qG7zxZ'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+
+ // Example 5: A 1028-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'Cq3z+cEl5diR8xrESOmT3v5YD4ArRfnX8iulAh6cR1drWh5oAxup205tq+TZah1vPSZyaM/0CABfEY78rbmYiNHCNEZxZrKiuEmgWoicBgrA2gxfrotV8wm6YucDdC+gMm8tELARAhSJ/0l3cBkNiV/Tn1IpPDnv1zppi9q58Q7Z';
+ exponent = 'AQAB';
+ d = 'AlbrTLpwZ/LSvlQNzf9FgqNrfTHRyQmbshS3mEhGaiaPgPWKSawEwONkiTSgIGwEU3wZsjZkOmCCcyFE33X6IXWI95RoK+iRaCdtxybFwMvbhNMbvybQpDr0lXF/fVKKz+40FWH2/zyuBcV4+EcNloL5wNBy+fYGi1bViA9oK+LF';
+ p = 'A7DTli9tF1Scv8oRKUNI3PDn45+MK8aCTyFktgbWh4YNrh5jI5PP7fUTIoIpBp4vYOSs1+YzpDYGP4I4X0iZNwc=';
+ q = 'AuTDLi9Rcmm3ByMJ8AwOMTZffOKLI2uCkS3yOavzlXLPDtYEsCmC5TVkxS1qBTl95cBSov3cFB73GJg2NGrrMx8=';
+ dP = 'AehLEZ0lFh+mewAlalvZtkXSsjLssFsBUYACmohiKtw/CbOurN5hYat83iLCrSbneX31TgcsvTsmc4ALPkM429U=';
+ dQ = '65CqGkATW0zqBxl87ciBm+Hny/8lR2YhFvRlpKn0h6sS87pP7xOCImWmUpfZi3ve2TcuP/6Bo4s+lgD+0FV1Tw==';
+ qInv = 'AS9/gTj5QEBi64WkKSRSCzj1u4hqAZb0i7jc6mD9kswCfxjngVijSlxdX4YKD2wEBxp9ATEsBlBi8etIt50cg8s=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 5.1',
+ message: 'r3GpAeOmHTEy8Pwf20dPnqZXklf/wk0WQXAUWz296A==',
+ seed: 'RMkuKD93uUmcYD2WNmDIfS+TlGFEyS4oP3e5SZxgPZY=',
+ encrypted: 'BOGyBDRo+2G7OC79yDEzJwwLMPuhIduDVaaBdb5svHj/ZAkVlyGVnH0j+ECliT42Nhvp4kZts+9cJ0W+ui7Q9KXbjmX033MpxrvSV1Ik//kHhX6xTn51UGpaOTiqofjM3QTTi9DVzRtAarWd/c8oAldrGok1vs+tJEDbcA5KvZz7'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.2',
+ message: 'o7hEoII5qKxBYFrxemz9pNNQE2WFkDpBenkmh2BRmktKwzA+xz8Ph8+zI5k=',
+ seed: 'yyj1hgZZ/O7knD7q/OYlpwgDvTLLKPWGBln87uScPuo=',
+ encrypted: 'AeleoSbRCOqBTpyWGLCrZ2G3mfjCYzMvupBy+q+sOKAfBzaLCjCehEUmIZFhe+CvtmVvyKGFqOwHUWgvks9vFU7Gfi580aZm7d4FtaGGVHBO6Q32/6IS7a+KSk7L6rPWwBTI+kyxb5SW12HTEowheKkFTda06tU0l4Ji45xP2tyh'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.3',
+ message: 'MIsOy9LHbLd/xvcMXt0jP9LyCSnWKfAmlTu2Ko9KOjFL3hld6FtfgW2iqrB00my2rN3zI647nGeKw88S+93n',
+ seed: 'IoX0DXcEgvmp76LHLLOsVXFtwMoihfQNdwSC+anvosc=',
+ encrypted: 'Ci3TBMV4P0o59ap6Wztb9LQHfJzYSOAaYaiXjk85Q9FYhAREaeS5YXhegKbbphMIS5i1SYJShmwpYu/t8SGHiX/72v6NnRgafDKzttROuF/HJoFkTBKH6C9NKke+mxoDy/YVZ9qYzFY6PwzB4pTDwku9s5Ha4DmRBlFdA/z713a4'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.4',
+ message: 'FcW57hGF',
+ seed: 'SfpF06eN0Q39V3OZ0esAr37tVRNJ+kXTp43RDf1Xc5k=',
+ encrypted: 'AcMQiclY0MMdT9K4kPqZ7JYHTaSolc8B3huHcQ4U5mG11/9XjzWjTLha8Liy0w909aaPbaB7+ZQTebg7x3F4yeWFRmnAJMaIFGBW/oA952mEaJ+FR2HO0xfRPzCRCaaU7cyOxy0gnR8d9FMunt9fhbffM9TvOfR6YDE5Duz6Jg0W'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.5',
+ message: 'IQJuaADH+nKPyqug0ZauKNeirE/9irznlPCYX2DIpnNydzZdP+oR24kjogKa',
+ seed: '8Ch0EyNMxQNHJKCUxFhrh6/xM/zwKHQTI0zFA0ckoJQ=',
+ encrypted: 'A/gvyZ/MNHUG3JGcisvAw/h1bhviZsqIsEM5+gBpLfj7d8iq28yZa6z5cnS4cJWywHxyQMgt9BAd37im/f5WcIcB+TZS9uegFSdgaetpYf4ft/1wMlcdc1ReCrTrCKPFHLLczeifyrnJSVvQD84kQY21b4fW9uLbSiGO0Ly94il1'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 5.6',
+ message: 'VB43totsiHK4TAI=',
+ seed: '2fukXJbyHm4m0p6yzctlhb6cs0HZ+6RclvIebibSnrI=',
+ encrypted: 'AWmTYpBHOqRBGy1h5mF88hMmBVNLN++kXAqQr4PKszqorigNQZbvwbOdWYNLsXydyvKi55ds8tTvXf4rRBswyuNmbtT0t2FVCTnTjNzA1cMSahInbdKfL/1wib3CjyQmC0TbbIa3kkAdXkiYytSafDxwNyan1OWtJcMLkJ6l8WRm'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+
+ // Example 6: A 1029-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'ErF/ba0uzRn/RtwT94YPCeDgz7Z3s4pSWSMFzq8CLBZtuQ0ErCnjP33RLZ+vZuCBa7Y+rSZ8x9RsF8N74hS8oqItcjpk5EQHQ2tvyWVymu/CVU83bNXc6mgpN4CmK/OdAClIWhYLu55dwJctIaUE9S5e4CiqQWMy9RCy6c/19yKv';
+ exponent = 'AQAB';
+ d = 'ApXso1YGGDaVWc7NMDqpz9r8HZ8GlZ33X/75KaqJaWG80ZDcaZftp/WWPnJNB7TcEfMGXlrpfZaDURIoC5CEuxTyoh69ToidQbnEEy7BlW/KuLsv7QV1iEk2Uixf99MyYZBIJOfK3uTguzctJFfPeOK9EoYij/g/EHMc5jyQz/P5';
+ p = 'BKbOi3NY36ab3PdCYXAFr7U4X186WKJO90oiqMBct8w469TMnZqdeJpizQ9g8MuUHTQjyWku+k/jrf8pDEdJo4s=';
+ q = 'BATJqAM3H+20xb4588ALAJ5eCKY74eQANc2spQEcxwHPfuvLmfD/4Xz9Ckv3vv0t1TaslG23l/28Sr6PKTSbke0=';
+ dP = 'A5Ycj3YKor1RVMeq/XciWzus0BOa57WUjqMxH8zYb7lcda+nZyhLmy3lWVcvFdjQRMfrg6G+X63yzDd8DYR1KUs=';
+ dQ = 'AiGX4GZ0IZaqvAP6L+605wsVy3h9YXrNMbt1x7wjStcG98SNIYLR8P+cIo3PQZZ7bAum0sCtEQobhXgx7CReLLE=';
+ qInv = 'BAHEwMU9RdvbXp2W0P7PQnXfCXS8Sgc2tKdMMmkFPvtoas4kBuIsngWN20rlQGJ64v2wgmHo5+S8vJlNqvowXEU=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 6.1',
+ message: 'QEbKi6ozR8on9J4NgfnMHXG+m6UX1A==',
+ seed: '3Q9s/kFeiOWkaaUfu6bf1ArbQ4TdD2z+QV6I5aRppR8=',
+ encrypted: 'C3d3hdR81ybq+Wuf6QUfy2KHVuQjrsvVH2HuE2LbJT2o2ZPdrDHIoGphdGj+GWNTrcV/d8iPLJlZ0CR3O2e2b7wLUVPMorv1HidYA8B8eJxkg5FIsPuK836LchnGqQlE7ObiWOjSuIw4lZ/ULCfOYejelr6PJXSxWgQUlV78sbvP'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.2',
+ message: 'XMcsYCMd8Ds9QPm1eTG8MRCflyUn8osZ50gMcojLPJKyJRIhTkvmyRR5Ldq99X+qiqc=',
+ seed: 'jRS9lGoTURSPXK4u2aDGU+hevYWNFL2UahNRFI9cri4=',
+ encrypted: 'DXAHBh/uWFjxl/kIwrzm0MXeHNH5MSmoPc0mjn00UcCUFmOwTQipPmLmephH+rNOOfCQVvwP5wysU3/w2hjmk/rl6Jb4qNc+KqDiij7fKSKhPGTvY3aiXZ2LflnJ3yv4LdT9KvvWsZrHEWfsEG+fQZW4c1OMEpOMC4N44nc88yRm'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.3',
+ message: 'sg5lEwMJL0vMtDBwwPhtIwSTYu2WZC/FYywn20pS49gx8qsGiyOxSYecAC9r8/7ul1kRElYs',
+ seed: 'bAdbxFUg8WXAv16kxd8ZG8nvDkRsB1vEVSDxZcC/XqQ=',
+ encrypted: 'AMe1ZPYbk4lABLKDLhwJMM4AfK46Jyilp/vQ9M921AamJzanoNGdlj6ZEFkbIO68hc/Wp4Qr43iWtjcasgpLw2NS0vroRi91VI5k9BZgXtgNG7Z9FBOtPjM61Um2PWSFpAyfaZS7zoJlfRKciEa+XUKa4VGly4fYSXXAbUJV2YHc'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.4',
+ message: 'aE4wOMXAQfc=',
+ seed: 'O7w71mN9/hKEaQECm/WwwHEDQ5w7vDvWY33+EoRpAQI=',
+ encrypted: 'AJS/vpVJKJuLwnnzENVQChT5MCBa0mLxw/a9nt+6Zj4FL8nucIl7scjXSOkwBDPcyCWr7gqdtjjZ9z6RCQv0HfjmVKI2M6AxI2MYuzwftIQldbhCRqo8AlyK3XKjfcK+Rzvii53W8Xw4Obbsv9OCLnCrrbK8aO3XKgrHPmDthH7x'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.5',
+ message: 'MkiMsmLQQdbk3TX5h788ppbbHwasKaRGkw==',
+ seed: 'tGtBiT6L7zJvZ1k4OoMHHa5/yry0a0GJPovvMm9nWTg=',
+ encrypted: 'CmNUKnNQco5hWHxCISdwN5M7LbL7YJ0u7bfH82LulE32VdATd3vcJmRiFtcczNNudMlHVhl6/ZsDVY1zymLrK2kLIYWeG9Iag3rQ5xhjLAdpMYBBuwjrJ8Oqc4+2qH57bBveynuE5xRpd9p+CkkiRP7x7g4B/iAwrmFxPtrxV/q/'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 6.6',
+ message: 'ULoUvoRicgJ5wwa6',
+ seed: 'CiQDMSpB49UvBg+8E6Z95c92CacKJAMxKkHj1S8GD7w=',
+ encrypted: 'DpQAu4uQ4zbkpP/f698+a5f3MhAXCi3QTcP7vXmQVlkH0CFlCnDESNG36Jk2ybe3VmzE2deBHBKI9a5cHUzM9Lsa/AoxnbD5qd2fJt9k19dSRtDWZUR/Bn/AdVHwstzsX/vRLe6qOk9Kf01OZcvKrmlWh2IBLs8/6sEJhBWXNAKj'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+
+ // Example 7: A 1030-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'MRF58Lz8m508oxXQDvMNe906LPrpkRv+3LlIs6R4LQcytqtEqkvwN0GmRNwBvsPmmwGgM+Z12KzXxJJcaxrsMRkFHf2Jdi0hXUVHX/y1n5CBSGI/NxdxVvauht16fF9D3B4fkIJUBYooSl8GwAIXk6h/GsX+/33K7mnF5Ro3ieNz';
+ exponent = 'AQAB';
+ d = 'Bwz8/y/rgnbidDLEXf7kj0m3kX1lMOHwyjRg8y4CdhdEh8VuIqRdJQDXd1SVIZ19Flqc872Swyr5qY2NycwpaACtyUoKVPtA80KRv4TujqErbxCTWcbTVCpQ+cdn9c//BaaBwuZW+3fKqttL6UaNirzU35j1jobSBT+hNJ90jiGx';
+ p = 'B0kmLBEc1HDsJWbms3MvwJMpRpqhkHHTucAZBlFMbx0muqFL6rCXHIt+YRpPeQCdb+p3aSjKJShbDeNkPRo/jHE=';
+ q = 'BrweUOlsAr9jbp7qi4mbvr92Ud533UdMPpvCO62BgrYZBMfZffvr+x4AEIh4tuZ+QVOR1nlCwrK/m0Q1+IsMsCM=';
+ dP = 'A7x+p/CqsUOrxs6LlxGGNqMBcuTP4CyPoN2jt7qvkPgJKYKYVSX0iL38tL1ybiJjmsZKMJKrf/y/HVM0z6ULW/E=';
+ dQ = 'AmKmqinCo8Z9xTRsBjga/Zh6o8yTz7/s9U/dn514fX9ZpSPTmJedoTei9jgf6UgB98lNohUY3DTLQIcMRpeZStk=';
+ qInv = 'ZJ1MF7buFyHnctA4mlWcPTzflVDUV8RrA3t0ZBsdUhZq+KITyDliBs37pEIvGNb2Hby10hTJcb9IKuuXanNwwg==';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 7.1',
+ message: 'R6rpCQ==',
+ seed: 'Q90JoH/0ysccqkYy7l4cHa7kzY9D3Qmgf/TKxxyqRjI=',
+ encrypted: 'CdXefX8LEW8SqnT1ly7/dvScQdke1rrSIBF4NcFO/G+jg0u7yjsqLLfTa8voI44Ue3W6lVuj5SkVYaP9i7VPmCWA4nFfeleuy23gbHylm4gokcCmzcAm2RLfPQYPnxIb3hoQ2C3wXo/aWoLIMFPYzI19g5uY90XMEchAci3FVC/a'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.2',
+ message: 'HZsuIiPZvBO/ufFiznNdtIunxo9oIqChp7auFlg05w==',
+ seed: 'Opw87HuE+b063svGc+yZ1UsivJs6nDzse4T5vTrey8Y=',
+ encrypted: 'DDar5/aikhAVropPgT3SVzSMRtdS9sEmVBEqg9my/3na0Okz51EcAy436TOZVsM0exezvKYsVbDQhtOM0Mn9r6oyBsqzUR4lx6Gt2rYDYC4X1aMsJSVcQs9pDqeAWfIAmDIIQH/3IN2uJ6u4Xl2+gFCpp8RP0F//Rj2llnEsnRsl'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.3',
+ message: '2Xb8',
+ seed: 'dqdeW2FXpVbPiIS7LkXCk91UXPV2p15bYVelVs+IhLs=',
+ encrypted: 'GpTkYrRFNyD9Jw1Pc1TSPSfc9Yb8k4Fw1l4kCwqPodlAboKMJe+yuXoGgVeB7Jb7JTQklGpQc1keZUzUUVZO0Q4qYUelFFe5lWM2uhq21VCbvcchrMTP6Wjts05hVgJHklLKF5cOtBGpQC0FlkwCYoXUAk//wejNycM/ZXw+ozkB'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.4',
+ message: '1HOGI98iOqQ4Q9+EZ1NMQdAT4MgDxiTiY2ZrI5veQKXymuuN5549qmHdA3D0m9SwE4NLmCEq72scXuNzs8s=',
+ seed: 'eGYxSmrW8rJQo1lB2yj1hktYWFl4ZjFKatbyslCjWUE=',
+ encrypted: 'G5GJEPP4ifUCg+3OHEq41DFvaucXwgdSGyuDX6/yQ1+e30d0OIjIFv4JTUXv6Oi8/uADg+EN5Ug+lEyf0RNSS4wfKgRfAaXK6x1U8dh48g/bED27ZCZ+MjhAkUcjMO0h4m3nNfLxAju7nxO2cJzNI9n1TBCMngJBco0zzhOvMZaN'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.5',
+ message: 'u0cjHKXqHTrUbJk0XZqKYQ==',
+ seed: 'shZu1HLVjbEMqyxrAAzM8Qp9xQmyFm7UctWNsQyrLGs=',
+ encrypted: 'HebBc/6i18c2FbG7ibWuxyQgtiN1uhtxyNsXw1Kuz8zo7RkBkt5JZEwucKyXFSwI6drZlK6QaqCRZwPQsdc2wnZlQzbkilVf1TiACqzDdpKX5i+SbCTUsOyGETV3vtxFe7/SatEKseFSLEWkIfZxAFcisIs5hWmLJdqfWQeYuMrK'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 7.6',
+ message: 'IYSCcJXTXD+G9gDo5ZdUATKW',
+ seed: 'Umc73iyhZsKqRhMawdyAjWfX07FSZzveLKFmwqpGExo=',
+ encrypted: 'DX+W3vsdnJfe63BVUFYgCAG1VmTqG/DbQ4nZgWTUGHhuijUshLtz07dHar21GJ9Ory8QQPX67PgKGnBMp0fJBnqKO3boMOEcc52HEnQxOWIW2h2rgmDtnaYtvK85pddXzhbuXkXg4DDnoMy+4XzgbLfArK12deGB0wruBbQyv3Ar'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+
+ // Example 8: A 1031-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'W98OMNMh3aUUf4gkCPppGVSA34+A0/bov1gYUE82QnypsfVUC5xlqPaXTPhEeiRNkoAgG7Sfy75jeNGUTNIn4jD5bj0Q+Bnc7ydsZKALKktnAefQHeX6veOx6aDfgvRjE1nNImaWR/uxcXJGE07XtJfP/73EK1nHOpbtkBZiEt/3';
+ exponent = 'AQAB';
+ d = 'D30enlqqJf0T5KBmOuFE4NFfXNGLzbCd8sx+ZOPF6RWtYmRTBBYdCYxxW7eri9AdB+rz/tfH7QivKopi70SrFrMg4Ur3Kkj5av4mKgrkz2XmNekQeQzU7lzqdopLJjn35vZ3s/C7a+MrdXR9iQkDbwJk9Y1AHNuhMXFhV6dez2Mx';
+ p = 'CgLvhEjZ+ti70NAEyMKql1HvlyHBsNAyNqVLDflHy67VolXuno4g1JHqFyP+CUcEqXYuiK/RbrtZlEEsqWbcT58=';
+ q = 'CS02Ln7ToL/Z6f0ObAMBtt8pFZz1DMg7mwz01u6nGmHgArRuCuny3mLSW110UtSYuByaxvxYWT1MP7T11y37sKk=';
+ dP = 'B8cUEK8QOWLbNnQE43roULqk6cKd2SFFgVKUpnx9HG3tJjqgMKm2M65QMD4UA10a8BQSPrpoeCAwjY68hbaVfX0=';
+ dQ = 'rix1OAwCwBatBYkbMwHeiB8orhFxGCtrLIO+p8UV7KnKKYx7HKtYF6WXBo/IUGDeTaigFjeKrkPH+We8w3kEuQ==';
+ qInv = 'BZjRBZ462k9jIHUsCdgF/30fGuDQF67u6c76DX3X/3deRLV4Mi9kBdYhHaGVGWZqqH/cTNjIj2tuPWfpYdy7o9A=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 8.1',
+ message: 'BQt1Xl5ogPe56daSp0w3quRJsxv+pt7/g3R6iX9sLIJbsa2/hQo8lplLXeWzPLx9SheROnln',
+ seed: 'dwb/yh7PsevuKlXlxuJM0nl6QSV3Bv/KHs+x6+4qVeU=',
+ encrypted: 'DZZvGJ61GU6OOkaPl2t8iLNAB1VwLjl3RKd/tcu19Vz9j68fjCFBQvASq9FK6Sul/N6sXIVsi4ypx/1m77bErYJqiGwkE8sQz/g4ViwQmeCvpfbCoq00B5LxklezvhnM5OeSxFtO/8AtYimLrJ3sUmDYk7xkDI20/Lb8/pyOFsjH'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.2',
+ message: 'TraNzZPKmxnfERvUNgj1VwJv5KodXPrCJ6PrWrlUjBigbd7SP4GCWYay/NcRCezvfv+Ihz8HXCqgxGn2nJK8',
+ seed: 'o3F9oUO03P+8dCZlqPqVBYVUg0OjcX2hQ7Tc/7x0JmU=',
+ encrypted: 'DwsnkHG2jNLgSU4LEvbkOuSaQ9+br9t3dwen8KDGmLkKVJgWGu+TNxyyo2gsBCw7S4eqEFrl49ENEhMehdjrHCBLrEBrhbHxgncKrwIXmcjX1DOCrQXEfbT4keig8TaXkasow5qby9Ded6MWcLu1dZnXPfiuiXaOYajMGJ1D3/y7'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.3',
+ message: 'hgSsVjKMGrWtkXhh',
+ seed: '7gYgkHPMoCa7Jk5Rhb+MaLdzn4buBiCQc8ygJrsmTlE=',
+ encrypted: 'PAKF3K/lSKcZKWQDr56LmmVqSltcaKEfS7G6+rwG239qszt8eKG6fMYJsP4h7ZfXyV1zuIZXTVhXgiRQbA9os0AhkWiMJJouhsAn60R20BOLQOtQxlXxVOvUMPGuG5EP2O+nTI0VCXky5kHNJdfJolSW+pJLVdSu4mX9Ooga1CSx'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.4',
+ message: '/dpfv27DYanZpKxoryFqBob0OLHg5cNrlV904QfznA3dzA==',
+ seed: 'mQrVc9xIqXMjW22CVDYY8ulVEF2ZCtVz3EipcyNbbYI=',
+ encrypted: 'LcCLDDj2S5ZOKwpvobOk6rfBWMBbxs3eWR+Edk3lKaoEAFFD5sQv0AaIs3r7yI8sOir9HvS6GKf+jc9t31zIDCIJc3sKVyrNZfEeUFSvihjbPZDo6IaZ8Jau8woE2p1z7n9rG+cbMwKuILRPSEN4hE0QSA/qz0wcye6bjb6NbK20'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.5',
+ message: 'Sl9JFL7iXePGk0HeBw==',
+ seed: '7MY7KPB1byL1Ksjm7BJRpuwwRxjsxjso8HVvIvUqyOY=',
+ encrypted: 'U+PBTMw6peNHnFQ3pwix/KvVeWu1nSKQGcr9QPpYNgHhuFZK6ARR7XhKxFtDoUMP+iVTXprcow4lr1Uaw4PnEx+cPe0Khl15R8GLiuh5Vm9p3lTPW1u58iP2Oa81pQZTB5AuFiD0fnFZsl+BYfjDVah3cMIu83KOBRPOdLY0j8iq'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 8.6',
+ message: 'jgfWb3uICnJWOrzT81CSvDNAn7f4jyRyvg==',
+ seed: 'OSXHGzYtQKCm3kIUVXm6Hn3UWfw5JccbNi1AoKbeQhQ=',
+ encrypted: 'WK9hbyje7E0PLeXtWaJxqD4cFkdL5x4vawlKJSOO1OKyZ6uaY8vMYBhBO47xRIqtab5Ul5UGCwdvwPR69PpARsiiSfJHVavkihXixHGgZViGTMU/7J7ftSiNT9hAwrj4JL4f1+8RhTp6WKRzsXAEKpvLK0TrzQL3ioF3QtTsiu/a'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+
+ // Example 9: A 1536-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'zyzUHjTKOnKOpcuK/2TDbSe971Nk4zb9aNMSPFoZaowocBPoU9UVbVjRUZVFIPtPbXsXq7aBd2WQnFdhGWWdkCsZBu2KKxDBVcJNEkUo2rnurjeb6sZuSkEXhty4/QBi68Aw3hIZoEwqjBt90xMeTWtsruLjGl7UGsFQmy7x7iqxg2S+VoypQcJezIT/nWQ7XsGqrhAqINc/R5t4D9bakQdSEtnqwDoGdNiZ66LkMfTES2Fba6IjK9SzO67XPWJd';
+ exponent = 'AQAB';
+ d = 'GYwUHiNxWpK8z2oRmlvBE4lGjSgR9UjXJ+F7SrDrmG1vIR77U7cffMvqh+5px17mFQCMUzLetSvzkKvfv+N9cgU2gVmyY4wd4ybiHSIlHw+1hIs78VAF0qdDMPCv6RbuYszBNE0dg6cJ5gZ2JzhA9/N3QkpeCk2nXwGzH/doGc+cv90hUkPDkXwD7zgZkxLlZ7O/eu06tFfzce+KFCP0W2jG4oLsERu6KDO5h/1p+tg7wbjGE8Xh6hbBHtEl6n7B';
+ p = '/I1sBL7E65qBksp5AMvlNuLotRnezzOyRZeYxpCd9PF2230jGQ/HK4hlpxiviV8bzZFFKYAnQjtgXnCkfPWDkKjD6I/IxI6LMuPaIQ374+iB6lZ0tqNIwh6T+eVepl79';
+ q = '0gDUXniKrOpgakAdBGD4fdXBAn4S3BoNdYbok52c94m0D1GsBEKWHefSHMIeBcgxVcHyqpGTOHz9+VbLSNFTuicEBvm7ulN9SYfZ4vmULXoUy//+p0/s3ako0j4ln17h';
+ dP = '2xaAL3mi8NRfNY1p/TPkS4H66ChiLpOlQlPpl9AbB0N1naDoErSqTmyL6rIyjVQxlVpBimf/JqjFyAel2jVOBe8xzIz3WPRjcylQsD4mVyb7lOOdalcqJiRKsI23V1Kt';
+ dQ = 'oKMXz+ffFCP4em3uhFH04rSmflSX8ptPHk6DC5+t2UARZwJvVZblo5yXgX4PXxbifhnsmQLgHX6m+5qjx2Cv7h44G2neasnAdYWgatnEugC/dcitL6iYpHnoCuKU/tKh';
+ qInv = 'CyHzNcNTNC60TDqiREV4DC1lW5QBdMrjjHyKTmSTwLqf0wN0gmewg7mnpsth5C2zYrjJiW23Bk4CrVrmFYfaFbRknJBZSQn+s328tlS+tyaOyAHlqLSqORG+vYhULwW+';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 9.1',
+ message: '9zX9VbqSWSw7Urj5xPaaqhy++P6IrdCVWVQSRn+c9OwLiWxZ7aFiEOdUnIq7EM28IaEuyba1uP0vEDmetg==',
+ seed: 'jsll8TSj7Jkx6SocoNyBadXqcFyOyWXxNKPsmTHpKhw=',
+ encrypted: 'kuBqApUSIPP0yfNvL0I57K2hReD8CcPhiYZFlPPmdM0cVFQHvdPMjQ2GcEekoBMk2+JR2H3IY6QF0JcANECuoepAuEvks/XolStfJNyUVUO3vLbWGlA1JOOSPiWElIdM0hmLN5In0DizqQit7R0mzH3Y1vUGPBhzOnNgNVQgrWVvqJugjG1SPY7LaZxIjhnz3O/8EkCpxLWcyWkFLX+ujnxIKxAqjmvEztiwLLlcWbJKILOy7KE1lctyh58wYP6e'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.2',
+ message: 'gbkGYFAVpjqr5C3fEeGXiRL1QEx0dLJtzj7Ugr+WHsyBi/QgxUZZ',
+ seed: '7LG4sl+lDNqwjlYEKGf0r1gm0WzssbiyX6UM2rCOVgQ=',
+ encrypted: 'iNEGT/cssEWuXX1C+SWyMK1hhUjRdNz9l8FeCBhftw8I5JUY1EDXPi2hUpESGxbJOjbyricua+QVvfP/UeoPfOxCcpRSoA3DlviB0ExCJTpCb2NSv9qXtw6Z7qEqk2YyQD7mAsGb2/Y3ug3KkKrF68MAxsWFV3tmL2NV2h+yfW6qz1dVAbAIUZeRuLIbaLdY9F7O4yPC68zkaX9NcTg0tOtnAJth9fMAOFX8sVbvKBgeOuVHV1A8HcAbmqkLMIyp'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.3',
+ message: '/TJkKd+biQ4JtUsYuPNPHiQ=',
+ seed: '6JuwMsbOYiy9tTvJRmAU6nf3d8Dom7Ayxs5iLL21O8k=',
+ encrypted: 'JiwfWprF58xVjVRR9B9r0mhomwU5IzkxXCZDgYJwYUcacmrz+KRLKMmtCMN7DLA2lOsfK+72mU+RLmhwfAAhBYmLGR8dLLstazb5xzU9wIM9u3jAl5iyyMLSo6wk/3SH0f7vC2bnFtMkhoHsd3VSTpzl5Q+SqX/4Q1JAMGWMMiHdyjCH+WaXNdTrboPEnPVtTcBGthkkYu8r/G0IkBR6OMPCZFgl/J4uiRTGCRbZx7UC02g6+qNMQY+ksygV6R8w'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.4',
+ message: '8UWbXwyS8BoPcjouVmJITY+MCiD8KdrWrNQ7tfPv/fThtj4H/f5mKNDXTKGb8taeSgq/htKTklp5Z3L4CI4=',
+ seed: 'YG87mcC5zNdx6qKeoOTIhPMYnMxgbzuZwLnM13Hqop4=',
+ encrypted: 'YXo+2y1QMWzjHkLtCW6DjdJ6fS5qdm+VHALYLFhG/dI1GmOwGOiOrFqesc5KPtWE73N5nJ680e6iYQYdFIsny6a4VH9mq/2Lr6qasMgM27znPzK8l6uQ1pTcDu1fJ4gCJABshzVEXzeTWx6OyKZsOFL8eXiNCwQpyfP9eH0tRjc+F75H3dnzX6AEVff4t0yKjDqp7aRMxFZGidcMJ6KetiNXUg1dhs/lHzItdQ7oMSUAgMnHYAvJDGqy5L4F8XXM'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.5',
+ message: 'U+boxynW+cMZ3TF+dLDbjkzMol88gwV0bhN6xjpj7zc557WVq7lujVXlT3vUGrQzN4/7kR0=',
+ seed: '/LxCFALp7KvGCCr6QLpfJlIshA78vEIUAunsq8YIKvo=',
+ encrypted: 'fwY+yhF2kyhotPKPlHEXcTOqVRG8Kg9bDJE/cSPUOoyVoiV0j57o9xpEYtZBuM5RanPUsTDcYNvorKqP5mbN81JV3SmEkIRTL7JoHGpJAMDHFjXBfpAwgUCPhfJ2+CUCIyOoPZqlt4w+K9l+WeFZYDatr0HC1NO+stbvWq358HRdX27TexTocG5OEB4l9gqhnUYD2JHNlGidsm0vzFQJoIMaH26x9Kgosg6tZQ0t3jdoeLbTCSxOMM9dDQjjK447'
+ }, {
+ title: 'RSAES-OAEP Encryption Example 9.6',
+ message: 'trKOohmNDBAIvGQ=',
+ seed: 'I6reDh4Iu5uaeNIwKlL5whsuG6Ijqt4OHgi7m5p40jA=',
+ encrypted: 'PISd/61VECapJ7gfG4J2OroSl69kvIZD2uuqmiro3E4pmXfpdOW/q+1WCr574Pjsj/xrIUdgmNMAl8QjciO/nArYi0IFco1tCRLNZqMDGjzZifHIcDNCsvnKg/VRmkPrjXbndebLqMtw7taeVztYq1HKVAoGsdIvLkuhmsK0Iaesp+/8xka40c9hWwcXHsG+I7pevwFarxQQbuUjXSkZ2ObWgzgGSiGCw9QNUGpO0usATLSd0AFkeE+IM/KAwJCy'
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+
+ // Example 10: A 2048-bit RSA Key Pair
+ // Components of the RSA Key Pair
+ modulus = 'rkXtVgHOxrjMBfgDk1xnTdvg11xMCf15UfxrDK7DE6jfOZcMUYv/ul7Wjz8NfyKkAp1BPxrgfk6+nkF3ziPn9UBLVp5O4b3PPB+wPvETgC1PhV65tRNLWnyAha3K5vovoUF+w3Y74XGwxit2Dt4jwSrZK5gIhMZB9aj6wmva1KAzgaIv4bdUiFCUyCUG1AGaU1ooav6ycbubpZLeGNz2AMKu6uVuAvfPefwUzzvcfNhP67v5UMqQMEsiGaeqBjrvosPBmA5WDNZK/neVhbYQdle5V4V+/eYBCYirfeQX/IjY84TE5ucsP5Q+DDHAxKXMNvh52KOsnX1Zhg6q2muDuw==';
+ exponent = 'AQAB';
+ d = 'BWsEIW/l81SsdyUKS2sMhSWoXFmwvYDFZFCiLV9DjllqMzqodeKR3UP0jLiLnV/A1Jn5/NHDl/mvwHDNnjmMjRnmHbfHQQprJnXfv100W4BNIBrdUC1c4t/LCRzpmXu+vlcwbzg+TViBA/A29+hdGTTRUqMj5KjbRR1vSlsbDxAswVDgL+7iuI3qStTBusyyTYQHLRTh0kpncfdAjuMFZPuG1Dk6NLzwt4hQHRkzA/E6IoSwAfD2Ser3kyjUrFxDCrRBSSCpRg7Rt7xA7GU+h20Jq8UJrkW1JRkBFqDCYQGEgphQnBw786SD5ydAVOFelwdQNumJ9gkygHtSV3UeeQ==';
+ p = '7PWuzR5VFf/6y9daKBbG6/SQGM37RjjhhdZqc5a2+AkPgBjH/ZXMNLhX3BfwzGUWuxNGq01YLK2te0EDNSOHtwM40IQEfJ2VObZJYgSz3W6kQkmSB77AH5ZCh/9jNsOYRlgzaEb1bkaGGIHBAjPSF2vxWl6W3ceAvIaKp30852k=';
+ q = 'vEbEZPxqxMp4Ow6wijyEG3cvfpsvKLq9WIroheGgxh5IWKD7JawpmZDzW+hRZMJZuhF1zdcZJwcTUYSZK2wpt0bdDSyr4UKDX30UjMFhUktKCZRtSLgoRz8c52tstohsNFwD4F9B1RtcOpCj8kBzx9dKT+JdnPIcdZYPP8OGMYM=';
+ dP = 'xzVkVx0A+xXQij3plXpQkV1xJulELaz0K8guhi5Wc/9qAI7U0uN0YX34nxehYLQ7f9qctra3QhhgmBX31FyiY8FZqjLSctEn+vS8jKLXc3jorrGbCtfaPLPeCucxSYD2K21LCoddHfA8G645zNgz72zX4tlSi/CE0flp55Tp9sE=';
+ dQ = 'Jlizf235wQML4dtoEX+p2H456itpO35tOi9wlHQT7sYULhj7jfy2rFRdfIagrUj4RXFw8O+ya8SBJsU+/R0WkgGY3CoRB9woLbaoDNMGI2C6P6E/cOQxL/GmzWuPxM2cXD2xfG1qVyEvc64p9hkye61ZsVOFhYW6Tii2CmKkXkk=';
+ qInv = 'bzhSazklCFU07z5BWoNu3ouGFYosfL/sywvYNDBP7Gg7qNT0ecQz1DQW5jJpYjzqEAd22Fr/QB0//2EO5lQRzjsTY9Y6lwnu3kJkfOpWFJPVRXCoecGGgs2XcQuWIF7DERfXO182Ij+t1ui6kN18DuYdROFjJR4gx/ZuswURfLg=';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ examples = [{
+ title: 'RSAES-OAEP Encryption Example 10.1',
+ message: 'i7pr+CpsD4bV8XVul5VocLCJU7BrTrIFvBaU7g==',
+ seed: 'R+GrcRn+5WyV7l6q2G9A0KpjvTNH4atxGf7lbJXuXqo=',
+ encrypted: 'iXCnHvFRO1zd7U4HnjDMCLRvnKZj6OVRMZv8VZCAyxdA1T4AUORzxWzAtAAA541iVjEs1n5MIrDkymBDk3cM1oha9XCGsXeazZpW2z2+4aeaM3mv/oz3QYfEGiet415sHNnikAQ9ZmYg2uzBNUOS90h0qRAWFdUV5Tyxo1HZ0slg37Ikvyu2d6tgWRAAjgiAGK7IzlU4muAfQ4GiLpvElfm+0vch7lhlrk7t5TErhEF7RWQe16lVBva7azIxlGyyrqOhYrmQ+6JQpmPnsmEKYpSxTUP2tLzoSH5e+Y0CSaD7ZB20PWILB+7PKRueJ23hlMYmnAgQBePWSUdsljXAgA=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.2',
+ message: '5q0YHwU7WKkE8kV1EDc+Vw==',
+ seed: 'bRf1tMH/rDUdGVv3sJ0J8JpAec9tF/W0wf+sNR0ZW/c=',
+ encrypted: 'I3uBbIiYuvEYFA5OtRycm8zxMuuEoZMNRsPspeKZIGhcnQkqH8XEM8iJMeL6ZKA0hJm3jj4z1Xz7ra3tqMyTiw3vGKocjsYdXchK+ar3Atj/jXkdJLeIiqfTBA+orCKoPbrBXLllt4dqkhc3lbq0Z5lTBeh6caklDnmJGIMnxkiG3vON/uVpIR6LMBg+IudMCMOv2f++RpBhhrI8iJOsPbnebdMIrxviVaVxT22GUNehadT8WrHI/qKv+p1rCpD3AAyXAhJy7KKp1l+nPCy1IY1prey+YgBxCAnlHuHv2V7q1FZTRXMJe3iKubLeiX6SfAKU1sivpoqk5ntMSMgAfw=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.3',
+ message: 'UQos9g6Gb6I0BVPJTqOfvCVjEeg+lEVLQSQ=',
+ seed: 'OFOHUU3szHx0DdjN+druSaHL/VQ4U4dRTezMfHQN2M0=',
+ encrypted: 'n3scq/IYyBWbaN4Xd+mKJ0bZQR10yiSYzdjV1D1K3xiH11Tvhbj59PdRQXflSxE1QMhxN0jp9/tsErIlXqSnBH2XsTX6glPwJmdgXj7gZ1Aj+wsl15PctCcZv0I/4imvBBOSEd5TRmag3oU7gmbpKQCSHi6Hp2z5H/xEHekrRZemX7Dwl6A8tzVhCBpPweKNpe34OLMrHcdyb0k/uyabEHtzoZLpiOgHRjqi7SHr2ene9PPOswH7hc87xkiKtiFOpCeCScF6asFeiUTn5sf5tuPHVGqjKskwxcm/ToW3hm7ChnQdYcPRlnHrMeLBJt6o6xdrg6+SvsnNzctLxes0gA=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.4',
+ message: 'vN0ZDaO30wDfmgbiLKrip18QyR/2Z7fBa96LUwZKJkmpQEXJ',
+ seed: 'XKymoPdkFhqWhPhdkrbg7zfKi2VcrKag92QWGpaE+F0=',
+ encrypted: 'KWbozLkoxbGfY0Dixr8GE/JD+MDAXIUFzm7K5AYscTvyAh9EDkLfDc/i8Y9Cjz/GXWsrRAlzO9PmLj4rECjbaNdkyzgYUiXSVV0SWmEF62nhZcScf+5QWHgsv6syu2VXdkz9nW4O3LWir2M/HqJ6kmpKVm5o7TqeYZ7GrY25FUnFDM8DpXOZqOImHVAoh8Tim9d2V9lk2D2Av6Tdsa4SIyBDj5VcX3OVoTbqdkKj5It9ANHjXaqGwqEyj7j1cQrRzrbGVbib3qzvoFvGWoo5yzr3D8J8z/UXJ4sBkumcjrphFTDe9qQcJ5FI82ZZsChJssRcZl4ApFosoljixk0WkA=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.5',
+ message: 'p91sfcJLRvndXx6RraTDs9+UfodyMqk=',
+ seed: 'lbyp44WYlLPdhp+n7NW7xkAb8+SVvKnjhZiUs92Gn6c=',
+ encrypted: 'D7UPhV1nPwixcgg47HSlk/8yDLEDSXxoyo6H7MMopUTYwCmAjtnpWp4oWGg0sACoUlzKpR3PN21a4xru1txalcOkceylsQI9AIFvLhZyS20HbvQeExT9zQGyJaDhygC/6gPifgELk7x5QUqsd+TL/MQdgBZqbLO0skLOqNG3KrTMmN0oeWgxgjMmWnyBH0qkUpV5SlRN2P3nIHd/DZrkDn/qJG0MpXh6AeNHhvSgv8gyDG2Vzdf04OgvZLJTJaTdqHuXz93t7+PQ+QfKOG0wCEf5gOaYpkFarorv9XPLhzuOauN+Dd2IPzgKH5+wjbTZlZzEn+xRyDXK7s6GL/XOZw=='
+ }, {
+ title: 'RSAES-OAEP Encryption Example 10.6',
+ message: '6vGnOhsMRglTfeac2SKLvPuajKjGw++vBW/kp/RjTtALfDnsaSLXuOosBOus',
+ seed: 'n0fd9C6X7qhWqb28cU6zrCL26zKfR930LpfuqFapvbw=',
+ encrypted: 'FO6Mv81w3SW/oVGIgdfAbIOW1eK8/UFdwryWg3ek0URFK09jNQtAaxT+66Yn5EJrTWh8fgRn1spnAOUsY5eq7iGpRsPGE86MLNonOvrBIht4Z+IDum55EgmwCrlfyiGe2fX4Xv1ifCQMSHd3OJTujAosVI3vPJaSsbTW6FqOFkM5m9uPqrdd+yhQ942wN4m4d4TG/YPx5gf62fbCRHOfvA5qSpO0XGQ45u+sWBAtOfzxmaYtf7WRAlu+JvIjTp8I2lAfVEuuW9+TJattx9RXN8jaWOBsceLIOfE6bkgad50UX5PyEtapnJOG1j0bh5PZ//oKtIASarB3PwdWM1EQTQ=='
+ }];
+ checkOAEPEncryptExamples(pubkey, privateKey, 'sha256', examples);
+ }
+
+ function _bytesToBigInteger(bytes) {
+ var buffer = UTIL.createBuffer(bytes);
+ var hex = buffer.toHex();
+ return new BigInteger(hex, 16);
+ }
+
+ function _base64ToBn(s) {
+ var decoded = UTIL.decode64(s);
+ return _bytesToBigInteger(decoded);
+ }
+
+ function checkOAEPEncryptExamples(publicKey, privateKey, md, examples) {
+ if(md === 'sha1') {
+ md = MD.sha1.create();
+ } else if(md === 'sha256') {
+ md = MD.sha256.create();
+ }
+
+ for(var i = 0; i < examples.length; ++i) {
+ var ex = examples[i];
+ it('should test ' + ex.title, function() {
+ checkOAEPEncrypt(
+ publicKey, privateKey, md, ex.message, ex.seed, ex.encrypted);
+ });
+ }
+ }
+
+ function checkOAEPEncrypt(
+ publicKey, privateKey, md, message, seed, expected) {
+ var message = UTIL.decode64(message);
+ var seed = UTIL.decode64(seed);
+ var encoded = PKCS1.encode_rsa_oaep(
+ publicKey, message, {seed: seed, md: md});
+ var ciphertext = publicKey.encrypt(encoded, null);
+ ASSERT.equal(expected, UTIL.encode64(ciphertext));
+
+ var decrypted = privateKey.decrypt(ciphertext, null);
+ var decoded = PKCS1.decode_rsa_oaep(privateKey, decrypted, {md: md});
+ ASSERT.equal(message, decoded);
+
+ // test with higher-level API, default label, and generating a seed
+ ciphertext = publicKey.encrypt(message, 'RSA-OAEP', {md: md});
+ decoded = privateKey.decrypt(ciphertext, 'RSA-OAEP', {md: md});
+ ASSERT.equal(message, decoded);
+ }
+
+ function decodeBase64PublicKey(modulus, exponent) {
+ modulus = _base64ToBn(modulus);
+ exponent = _base64ToBn(exponent);
+ return PKI.setRsaPublicKey(modulus, exponent);
+ }
+
+ function decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv) {
+ modulus = _base64ToBn(modulus);
+ exponent = _base64ToBn(exponent);
+ d = _base64ToBn(d);
+ p = _base64ToBn(p);
+ q = _base64ToBn(q);
+ dP = _base64ToBn(dP);
+ dQ = _base64ToBn(dQ);
+ qInv = _base64ToBn(qInv);
+ return PKI.setRsaPrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+ }
+
+ function makeKey() {
+ var modulus, exponent, d, p, q, dP, dQ, qInv, pubkey, privateKey;
+
+ // Example 1: A 1024-bit RSA Key Pair
+ modulus = 'qLOyhK+OtQs4cDSoYPFGxJGfMYdjzWxVmMiuSBGh4KvEx+CwgtaTpef87Wdc9GaFEncsDLxkp0LGxjD1M8jMcvYq6DPEC/JYQumEu3i9v5fAEH1VvbZi9cTg+rmEXLUUjvc5LdOq/5OuHmtme7PUJHYW1PW6ENTP0ibeiNOfFvs=';
+ exponent = 'AQAB';
+ d = 'UzOc/befyEZqZVxzFqyoXFX9j23YmP2vEZUX709S6P2OJY35P+4YD6DkqylpPNg7FSpVPUrE0YEri5+lrw5/Vf5zBN9BVwkm8zEfFcTWWnMsSDEW7j09LQrzVJrZv3y/t4rYhPhNW+sEck3HNpsx3vN9DPU56c/N095lNynq1dE=';
+ p = '0yc35yZ//hNBstXA0VCoG1hvsxMr7S+NUmKGSpy58wrzi+RIWY1BOhcu+4AsIazxwRxSDC8mpHHcrSEurHyjnQ==';
+ q = 'zIhT0dVNpjD6wAT0cfKBx7iYLYIkpJDtvrM9Pj1cyTxHZXA9HdeRZC8fEWoN2FK+JBmyr3K/6aAw6GCwKItddw==';
+ dP = 'DhK/FxjpzvVZm6HDiC/oBGqQh07vzo8szCDk8nQfsKM6OEiuyckwX77L0tdoGZZ9RnGsxkMeQDeWjbN4eOaVwQ==';
+ dQ = 'lSl7D5Wi+mfQBwfWCd/U/AXIna/C721upVvsdx6jM3NNklHnkILs2oZu/vE8RZ4aYxOGt+NUyJn18RLKhdcVgw==';
+ qInv = 'T0VsUCSTvcDtKrdWo6btTWc1Kml9QhbpMhKxJ6Y9VBHOb6mNXb79cyY+NygUJ0OBgWbtfdY2h90qjKHS9PvY4Q==';
+ pubkey = decodeBase64PublicKey(modulus, exponent);
+ privateKey = decodeBase64PrivateKey(modulus, exponent, d, p, q, dP, dQ, qInv);
+
+ return {publicKey: pubkey, privateKey: privateKey};
+ }
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/pki',
+ 'forge/pkcs1',
+ 'forge/md',
+ 'forge/jsbn',
+ 'forge/util'
+ ], function(PKI, PKCS1, MD, JSBN, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ PKI(),
+ PKCS1(),
+ MD(),
+ JSBN(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/pki')(),
+ require('../../js/pkcs1')(),
+ require('../../js/md')(),
+ require('../../js/jsbn')(),
+ require('../../js/util')());
+}
+
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[45/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/jquery.ba-hashchange.min.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/jquery.ba-hashchange.min.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/jquery.ba-hashchange.min.js
new file mode 100644
index 0000000..3c607ba
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/jquery.ba-hashchange.min.js
@@ -0,0 +1,9 @@
+/*
+ * jQuery hashchange event - v1.3 - 7/21/2010
+ * http://benalman.com/projects/jquery-hashchange-plugin/
+ *
+ * Copyright (c) 2010 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.docu
ment.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
new file mode 100644
index 0000000..11e1f0a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/json2.js
@@ -0,0 +1,480 @@
+/*
+ http://www.JSON.org/json2.js
+ 2011-02-23
+
+ Public Domain.
+
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+ See http://www.JSON.org/js.html
+
+
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
+
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
+
+
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
+
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
+
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
+
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or ' '),
+ it contains the characters used to indent at each level.
+
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
+
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
+
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
+
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
+
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
+
+ Example:
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
+
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
+
+
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
+
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+*/
+
+/*jslint evil: true, strict: false, regexp: false */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+var JSON;
+if (!JSON) {
+ JSON = {};
+}
+
+(function () {
+ "use strict";
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ if (typeof Date.prototype.toJSON !== 'function') {
+
+ Date.prototype.toJSON = function (key) {
+
+ return isFinite(this.valueOf()) ?
+ this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z' : null;
+ };
+
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+// Produce a string from holder[key].
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+// What happens next depends on the value's type.
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+ return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+ case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+ if (!value) {
+ return 'null';
+ }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+ gap += indent;
+ partial = [];
+
+// Is the value an array?
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+ v = partial.length === 0 ? '[]' : gap ?
+ '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+ v = partial.length === 0 ? '{}' : gap ?
+ '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
+ '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+ if (typeof JSON.stringify !== 'function') {
+ JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+ var i;
+ gap = '';
+ indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+ return str('', {'': value});
+ };
+ }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+ if (typeof JSON.parse !== 'function') {
+ JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+ var j;
+
+ function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+ text = String(text);
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' +
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ });
+ }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+ if (/^[\],:{}\s]*$/
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+ j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+ return typeof reviver === 'function' ?
+ walk({'': j}, '') : j;
+ }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+ throw new SyntaxError('JSON.parse');
+ };
+ }
+}());
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/main.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/main.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/main.js
new file mode 100644
index 0000000..4a9025a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/main.js
@@ -0,0 +1,3 @@
+$(document).ready(function() {
+
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/nav.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/nav.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/nav.js
new file mode 100644
index 0000000..7736b4a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/nav.js
@@ -0,0 +1,64 @@
+$(document).ready(function() {
+ var docsLoaded = false;
+
+ $(window).hashchange(function(e){
+ e.preventDefault();
+ e.stopPropagation();
+
+ if (location.hash === "#tryit") {
+ $("#main > .content").hide();
+ $("#tryit input").val("").keyup();
+ $("#tryit").fadeIn(400, function() {
+ $("#tryit input").val(".languagesSpoken .lang").keyup();
+ });
+ } else if (location.hash === "#cred") {
+ $("#main > .content").hide();
+ $("#cred").fadeIn(400);
+ } else if (location.hash === '#overview' || location.hash === '') {
+ $("#main > .content").hide();
+ $("#splash").fadeIn(400);
+ } else if (location.hash === '#code' || location.hash === '') {
+ $("#main > .content").hide();
+ $("#code").fadeIn(400);
+ } else if (location.hash.substr(0,5) === "#docs") {
+ function showIt() {
+ var where = window.location.hash.substr(6);
+ if (!where) {
+ $("#doc").fadeIn(400);
+ } else {
+ $("#doc").show();
+ var dst = $("a[name='" + where + "']");
+ if (dst.length) {
+ $('html, body').animate({scrollTop:dst.offset().top - 100}, 500);
+ }
+ }
+ }
+ $("#main > .content").hide();
+ if (!docsLoaded) {
+ $.get("JSONSelect.md").success(function(data) {
+ var converter = new Showdown.converter();
+ $("#doc").html(converter.makeHtml(data));
+ $("#doc a").each(function() {
+ var n = $(this).attr('href');
+ if (typeof n === 'string' && n.substr(0,1) === '#') {
+ $(this).attr('href', "#docs/" + n.substr(1));
+ }
+ });
+ docsLoaded = true;
+ showIt();
+ }).error(function() {
+ $("#doc").text("Darnit, error fetching docs...").fadeIn(400);
+ });
+ } else {
+ showIt();
+ }
+ } else {
+ }
+ return false;
+ });
+
+ // Trigger the event (useful on page load).
+ if (window.location.hash === "")
+ window.location.hash = "#overview";
+ $(window).hashchange();
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
new file mode 100644
index 0000000..43920d9
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/showdown.js
@@ -0,0 +1,1302 @@
+//
+// showdown.js -- A javascript port of Markdown.
+//
+// Copyright (c) 2007 John Fraser.
+//
+// Original Markdown Copyright (c) 2004-2005 John Gruber
+// <http://daringfireball.net/projects/markdown/>
+//
+// Redistributable under a BSD-style open source license.
+// See license.txt for more information.
+//
+// The full source distribution is at:
+//
+// A A L
+// T C A
+// T K B
+//
+// <http://www.attacklab.net/>
+//
+
+//
+// Wherever possible, Showdown is a straight, line-by-line port
+// of the Perl version of Markdown.
+//
+// This is not a normal parser design; it's basically just a
+// series of string substitutions. It's hard to read and
+// maintain this way, but keeping Showdown close to the original
+// design makes it easier to port new features.
+//
+// More importantly, Showdown behaves like markdown.pl in most
+// edge cases. So web applications can do client-side preview
+// in Javascript, and then build identical HTML on the server.
+//
+// This port needs the new RegExp functionality of ECMA 262,
+// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
+// should do fine. Even with the new regular expression features,
+// We do a lot of work to emulate Perl's regex functionality.
+// The tricky changes in this file mostly have the "attacklab:"
+// label. Major or self-explanatory changes don't.
+//
+// Smart diff tools like Araxis Merge will be able to match up
+// this file with markdown.pl in a useful way. A little tweaking
+// helps: in a copy of markdown.pl, replace "#" with "//" and
+// replace "$text" with "text". Be sure to ignore whitespace
+// and line endings.
+//
+
+
+//
+// Showdown usage:
+//
+// var text = "Markdown *rocks*.";
+//
+// var converter = new Showdown.converter();
+// var html = converter.makeHtml(text);
+//
+// alert(html);
+//
+// Note: move the sample code to the bottom of this
+// file before uncommenting it.
+//
+
+
+//
+// Showdown namespace
+//
+var Showdown = {};
+
+//
+// converter
+//
+// Wraps all "globals" so that the only thing
+// exposed is makeHtml().
+//
+Showdown.converter = function() {
+
+//
+// Globals:
+//
+
+// Global hashes, used by various utility routines
+var g_urls;
+var g_titles;
+var g_html_blocks;
+
+// Used to track when we're inside an ordered or unordered list
+// (see _ProcessListItems() for details):
+var g_list_level = 0;
+
+
+this.makeHtml = function(text) {
+//
+// Main function. The order in which other subs are called here is
+// essential. Link and image substitutions need to happen before
+// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a>
+// and <img> tags get encoded.
+//
+
+ // Clear the global hashes. If we don't clear these, you get conflicts
+ // from other articles when generating a page which contains more than
+ // one article (e.g. an index page that shows the N most recent
+ // articles):
+ g_urls = new Array();
+ g_titles = new Array();
+ g_html_blocks = new Array();
+
+ // attacklab: Replace ~ with ~T
+ // This lets us use tilde as an escape char to avoid md5 hashes
+ // The choice of character is arbitray; anything that isn't
+ // magic in Markdown will work.
+ text = text.replace(/~/g,"~T");
+
+ // attacklab: Replace $ with ~D
+ // RegExp interprets $ as a special character
+ // when it's in a replacement string
+ text = text.replace(/\$/g,"~D");
+
+ // Standardize line endings
+ text = text.replace(/\r\n/g,"\n"); // DOS to Unix
+ text = text.replace(/\r/g,"\n"); // Mac to Unix
+
+ // Make sure text begins and ends with a couple of newlines:
+ text = "\n\n" + text + "\n\n";
+
+ // Convert all tabs to spaces.
+ text = _Detab(text);
+
+ // Strip any lines consisting only of spaces and tabs.
+ // This makes subsequent regexen easier to write, because we can
+ // match consecutive blank lines with /\n+/ instead of something
+ // contorted like /[ \t]*\n+/ .
+ text = text.replace(/^[ \t]+$/mg,"");
+
+ // Turn block-level HTML blocks into hash entries
+ text = _HashHTMLBlocks(text);
+
+ // Strip link definitions, store in hashes.
+ text = _StripLinkDefinitions(text);
+
+ text = _RunBlockGamut(text);
+
+ text = _UnescapeSpecialChars(text);
+
+ // attacklab: Restore dollar signs
+ text = text.replace(/~D/g,"$$");
+
+ // attacklab: Restore tildes
+ text = text.replace(/~T/g,"~");
+
+ return text;
+}
+
+
+var _StripLinkDefinitions = function(text) {
+//
+// Strips link definitions from text, stores the URLs and titles in
+// hash references.
+//
+
+ // Link defs are in the form: ^[id]: url "optional title"
+
+ /*
+ var text = text.replace(/
+ ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
+ [ \t]*
+ \n? // maybe *one* newline
+ [ \t]*
+ <?(\S+?)>? // url = $2
+ [ \t]*
+ \n? // maybe one newline
+ [ \t]*
+ (?:
+ (\n*) // any lines skipped = $3 attacklab: lookbehind removed
+ ["(]
+ (.+?) // title = $4
+ [")]
+ [ \t]*
+ )? // title is optional
+ (?:\n+|$)
+ /gm,
+ function(){...});
+ */
+ var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,
+ function (wholeMatch,m1,m2,m3,m4) {
+ m1 = m1.toLowerCase();
+ g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive
+ if (m3) {
+ // Oops, found blank lines, so it's not a title.
+ // Put back the parenthetical statement we stole.
+ return m3+m4;
+ } else if (m4) {
+ g_titles[m1] = m4.replace(/"/g,""");
+ }
+
+ // Completely remove the definition from the text
+ return "";
+ }
+ );
+
+ return text;
+}
+
+
+var _HashHTMLBlocks = function(text) {
+ // attacklab: Double up blank lines to reduce lookaround
+ text = text.replace(/\n/g,"\n\n");
+
+ // Hashify HTML blocks:
+ // We only want to do this for block-level HTML tags, such as headers,
+ // lists, and tables. That's because we still want to wrap <p>s around
+ // "paragraphs" that are wrapped in non-block-level tags, such as anchors,
+ // phrase emphasis, and spans. The list of tags we're looking for is
+ // hard-coded:
+ var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"
+ var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"
+
+ // First, look for nested blocks, e.g.:
+ // <div>
+ // <div>
+ // tags for inner block must be indented.
+ // </div>
+ // </div>
+ //
+ // The outermost tags must start at the left margin for this to match, and
+ // the inner nested divs must be indented.
+ // We need to do this before the next, more liberal match, because the next
+ // match will start at the first `<div>` and stop at the first `</div>`.
+
+ // attacklab: This regex can be expensive when it fails.
+ /*
+ var text = text.replace(/
+ ( // save in $1
+ ^ // start of line (with /m)
+ <($block_tags_a) // start tag = $2
+ \b // word break
+ // attacklab: hack around khtml/pcre bug...
+ [^\r]*?\n // any number of lines, minimally matching
+ </\2> // the matching end tag
+ [ \t]* // trailing spaces/tabs
+ (?=\n+) // followed by a newline
+ ) // attacklab: there are sentinel newlines at end of document
+ /gm,function(){...}};
+ */
+ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement);
+
+ //
+ // Now match more liberally, simply from `\n<tag>` to `</tag>\n`
+ //
+
+ /*
+ var text = text.replace(/
+ ( // save in $1
+ ^ // start of line (with /m)
+ <($block_tags_b) // start tag = $2
+ \b // word break
+ // attacklab: hack around khtml/pcre bug...
+ [^\r]*? // any number of lines, minimally matching
+ .*</\2> // the matching end tag
+ [ \t]* // trailing spaces/tabs
+ (?=\n+) // followed by a newline
+ ) // attacklab: there are sentinel newlines at end of document
+ /gm,function(){...}};
+ */
+ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
+
+ // Special case just for <hr />. It was easier to make a special case than
+ // to make the other regex more complicated.
+
+ /*
+ text = text.replace(/
+ ( // save in $1
+ \n\n // Starting after a blank line
+ [ ]{0,3}
+ (<(hr) // start tag = $2
+ \b // word break
+ ([^<>])*? //
+ \/?>) // the matching end tag
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // Special case for standalone HTML comments:
+
+ /*
+ text = text.replace(/
+ ( // save in $1
+ \n\n // Starting after a blank line
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ <!
+ (--[^\r]*?--\s*)+
+ >
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // PHP and ASP-style processor instructions (<?...?> and <%...%>)
+
+ /*
+ text = text.replace(/
+ (?:
+ \n\n // Starting after a blank line
+ )
+ ( // save in $1
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ (?:
+ <([?%]) // $2
+ [^\r]*?
+ \2>
+ )
+ [ \t]*
+ (?=\n{2,}) // followed by a blank line
+ )
+ /g,hashElement);
+ */
+ text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement);
+
+ // attacklab: Undo double lines (see comment at top of this function)
+ text = text.replace(/\n\n/g,"\n");
+ return text;
+}
+
+var hashElement = function(wholeMatch,m1) {
+ var blockText = m1;
+
+ // Undo double lines
+ blockText = blockText.replace(/\n\n/g,"\n");
+ blockText = blockText.replace(/^\n/,"");
+
+ // strip trailing blank lines
+ blockText = blockText.replace(/\n+$/g,"");
+
+ // Replace the element text with a marker ("~KxK" where x is its key)
+ blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n";
+
+ return blockText;
+};
+
+var _RunBlockGamut = function(text) {
+//
+// These are all the transformations that form block-level
+// tags like paragraphs, headers, and list items.
+//
+ text = _DoHeaders(text);
+
+ // Do Horizontal Rules:
+ var key = hashBlock("<hr />");
+ text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);
+ text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);
+ text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
+
+ text = _DoLists(text);
+ text = _DoCodeBlocks(text);
+ text = _DoBlockQuotes(text);
+
+ // We already ran _HashHTMLBlocks() before, in Markdown(), but that
+ // was to escape raw HTML in the original Markdown source. This time,
+ // we're escaping the markup we've just created, so that we don't wrap
+ // <p> tags around block-level tags.
+ text = _HashHTMLBlocks(text);
+ text = _FormParagraphs(text);
+
+ return text;
+}
+
+
+var _RunSpanGamut = function(text) {
+//
+// These are all the transformations that occur *within* block-level
+// tags like paragraphs, headers, and list items.
+//
+
+ text = _DoCodeSpans(text);
+ text = _EscapeSpecialCharsWithinTagAttributes(text);
+ text = _EncodeBackslashEscapes(text);
+
+ // Process anchor and image tags. Images must come first,
+ // because ![foo][f] looks like an anchor.
+ text = _DoImages(text);
+ text = _DoAnchors(text);
+
+ // Make links out of things like `<http://example.com/>`
+ // Must come after _DoAnchors(), because you can use < and >
+ // delimiters in inline links like [this](<url>).
+ text = _DoAutoLinks(text);
+ text = _EncodeAmpsAndAngles(text);
+ text = _DoItalicsAndBold(text);
+
+ // Do hard breaks:
+ text = text.replace(/ +\n/g," <br />\n");
+
+ return text;
+}
+
+var _EscapeSpecialCharsWithinTagAttributes = function(text) {
+//
+// Within tags -- meaning between < and > -- encode [\ ` * _] so they
+// don't conflict with their use in Markdown for code, italics and strong.
+//
+
+ // Build a regex to find HTML tags and comments. See Friedl's
+ // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
+ var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
+
+ text = text.replace(regex, function(wholeMatch) {
+ var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");
+ tag = escapeCharacters(tag,"\\`*_");
+ return tag;
+ });
+
+ return text;
+}
+
+var _DoAnchors = function(text) {
+//
+// Turn Markdown link shortcuts into XHTML <a> tags.
+//
+ //
+ // First, handle reference-style links: [link text] [id]
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ (
+ (?:
+ \[[^\]]*\] // allow brackets nested one level
+ |
+ [^\[] // or anything else
+ )*
+ )
+ \]
+
+ [ ]? // one optional space
+ (?:\n[ ]*)? // one optional newline followed by spaces
+
+ \[
+ (.*?) // id = $3
+ \]
+ )()()()() // pad remaining backreferences
+ /g,_DoAnchors_callback);
+ */
+ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);
+
+ //
+ // Next, inline-style links: [link text](url "optional title")
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ (
+ (?:
+ \[[^\]]*\] // allow brackets nested one level
+ |
+ [^\[\]] // or anything else
+ )
+ )
+ \]
+ \( // literal paren
+ [ \t]*
+ () // no id, so leave $3 empty
+ <?(.*?)>? // href = $4
+ [ \t]*
+ ( // $5
+ (['"]) // quote char = $6
+ (.*?) // Title = $7
+ \6 // matching quote
+ [ \t]* // ignore any spaces/tabs between closing quote and )
+ )? // title is optional
+ \)
+ )
+ /g,writeAnchorTag);
+ */
+ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);
+
+ //
+ // Last, handle reference-style shortcuts: [link text]
+ // These must come last in case you've also got [link test][1]
+ // or [link test](/foo)
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ \[
+ ([^\[\]]+) // link text = $2; can't contain '[' or ']'
+ \]
+ )()()()()() // pad rest of backreferences
+ /g, writeAnchorTag);
+ */
+ text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
+
+ return text;
+}
+
+var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
+ if (m7 == undefined) m7 = "";
+ var whole_match = m1;
+ var link_text = m2;
+ var link_id = m3.toLowerCase();
+ var url = m4;
+ var title = m7;
+
+ if (url == "") {
+ if (link_id == "") {
+ // lower-case and turn embedded newlines into spaces
+ link_id = link_text.toLowerCase().replace(/ ?\n/g," ");
+ }
+ url = "#"+link_id;
+
+ if (g_urls[link_id] != undefined) {
+ url = g_urls[link_id];
+ if (g_titles[link_id] != undefined) {
+ title = g_titles[link_id];
+ }
+ }
+ else {
+ if (whole_match.search(/\(\s*\)$/m)>-1) {
+ // Special case for explicit empty url
+ url = "";
+ } else {
+ return whole_match;
+ }
+ }
+ }
+
+ url = escapeCharacters(url,"*_");
+ var result = "<a href=\"" + url + "\"";
+
+ if (title != "") {
+ title = title.replace(/"/g,""");
+ title = escapeCharacters(title,"*_");
+ result += " title=\"" + title + "\"";
+ }
+
+ result += ">" + link_text + "</a>";
+
+ return result;
+}
+
+
+var _DoImages = function(text) {
+//
+// Turn Markdown image shortcuts into <img> tags.
+//
+
+ //
+ // First, handle reference-style labeled images: ![alt text][id]
+ //
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ !\[
+ (.*?) // alt text = $2
+ \]
+
+ [ ]? // one optional space
+ (?:\n[ ]*)? // one optional newline followed by spaces
+
+ \[
+ (.*?) // id = $3
+ \]
+ )()()()() // pad rest of backreferences
+ /g,writeImageTag);
+ */
+ text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);
+
+ //
+ // Next, handle inline images: 
+ // Don't forget: encode * and _
+
+ /*
+ text = text.replace(/
+ ( // wrap whole match in $1
+ !\[
+ (.*?) // alt text = $2
+ \]
+ \s? // One optional whitespace character
+ \( // literal paren
+ [ \t]*
+ () // no id, so leave $3 empty
+ <?(\S+?)>? // src url = $4
+ [ \t]*
+ ( // $5
+ (['"]) // quote char = $6
+ (.*?) // title = $7
+ \6 // matching quote
+ [ \t]*
+ )? // title is optional
+ \)
+ )
+ /g,writeImageTag);
+ */
+ text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);
+
+ return text;
+}
+
+var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
+ var whole_match = m1;
+ var alt_text = m2;
+ var link_id = m3.toLowerCase();
+ var url = m4;
+ var title = m7;
+
+ if (!title) title = "";
+
+ if (url == "") {
+ if (link_id == "") {
+ // lower-case and turn embedded newlines into spaces
+ link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
+ }
+ url = "#"+link_id;
+
+ if (g_urls[link_id] != undefined) {
+ url = g_urls[link_id];
+ if (g_titles[link_id] != undefined) {
+ title = g_titles[link_id];
+ }
+ }
+ else {
+ return whole_match;
+ }
+ }
+
+ alt_text = alt_text.replace(/"/g,""");
+ url = escapeCharacters(url,"*_");
+ var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
+
+ // attacklab: Markdown.pl adds empty title attributes to images.
+ // Replicate this bug.
+
+ //if (title != "") {
+ title = title.replace(/"/g,""");
+ title = escapeCharacters(title,"*_");
+ result += " title=\"" + title + "\"";
+ //}
+
+ result += " />";
+
+ return result;
+}
+
+
+var _DoHeaders = function(text) {
+
+ // Setext-style headers:
+ // Header 1
+ // ========
+ //
+ // Header 2
+ // --------
+ //
+ text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
+ function(wholeMatch,m1){return hashBlock('<h1 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h1>");});
+
+ text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
+ function(matchFound,m1){return hashBlock('<h2 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h2>");});
+
+ // atx-style headers:
+ // # Header 1
+ // ## Header 2
+ // ## Header 2 with closing hashes ##
+ // ...
+ // ###### Header 6
+ //
+
+ /*
+ text = text.replace(/
+ ^(\#{1,6}) // $1 = string of #'s
+ [ \t]*
+ (.+?) // $2 = Header text
+ [ \t]*
+ \#* // optional closing #'s (not counted)
+ \n+
+ /gm, function() {...});
+ */
+
+ text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
+ function(wholeMatch,m1,m2) {
+ var h_level = m1.length;
+ return hashBlock("<h" + h_level + ' id="' + headerId(m2) + '">' + _RunSpanGamut(m2) + "</h" + h_level + ">");
+ });
+
+ function headerId(m) {
+ return m.replace(/[^\w]/g, '').toLowerCase();
+ }
+ return text;
+}
+
+// This declaration keeps Dojo compressor from outputting garbage:
+var _ProcessListItems;
+
+var _DoLists = function(text) {
+//
+// Form HTML ordered (numbered) and unordered (bulleted) lists.
+//
+
+ // attacklab: add sentinel to hack around khtml/safari bug:
+ // http://bugs.webkit.org/show_bug.cgi?id=11231
+ text += "~0";
+
+ // Re-usable pattern to match any entirel ul or ol list:
+
+ /*
+ var whole_list = /
+ ( // $1 = whole list
+ ( // $2
+ [ ]{0,3} // attacklab: g_tab_width - 1
+ ([*+-]|\d+[.]) // $3 = first list item marker
+ [ \t]+
+ )
+ [^\r]+?
+ ( // $4
+ ~0 // sentinel for workaround; should be $
+ |
+ \n{2,}
+ (?=\S)
+ (?! // Negative lookahead for another list item marker
+ [ \t]*
+ (?:[*+-]|\d+[.])[ \t]+
+ )
+ )
+ )/g
+ */
+ var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+
+ if (g_list_level) {
+ text = text.replace(whole_list,function(wholeMatch,m1,m2) {
+ var list = m1;
+ var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol";
+
+ // Turn double returns into triple returns, so that we can make a
+ // paragraph for the last item in a list, if necessary:
+ list = list.replace(/\n{2,}/g,"\n\n\n");;
+ var result = _ProcessListItems(list);
+
+ // Trim any trailing whitespace, to put the closing `</$list_type>`
+ // up on the preceding line, to get it past the current stupid
+ // HTML block parser. This is a hack to work around the terrible
+ // hack that is the HTML block parser.
+ result = result.replace(/\s+$/,"");
+ result = "<"+list_type+">" + result + "</"+list_type+">\n";
+ return result;
+ });
+ } else {
+ whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
+ text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) {
+ var runup = m1;
+ var list = m2;
+
+ var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol";
+ // Turn double returns into triple returns, so that we can make a
+ // paragraph for the last item in a list, if necessary:
+ var list = list.replace(/\n{2,}/g,"\n\n\n");;
+ var result = _ProcessListItems(list);
+ result = runup + "<"+list_type+">\n" + result + "</"+list_type+">\n";
+ return result;
+ });
+ }
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/,"");
+
+ return text;
+}
+
+_ProcessListItems = function(list_str) {
+//
+// Process the contents of a single ordered or unordered list, splitting it
+// into individual list items.
+//
+ // The $g_list_level global keeps track of when we're inside a list.
+ // Each time we enter a list, we increment it; when we leave a list,
+ // we decrement. If it's zero, we're not in a list anymore.
+ //
+ // We do this because when we're not inside a list, we want to treat
+ // something like this:
+ //
+ // I recommend upgrading to version
+ // 8. Oops, now this line is treated
+ // as a sub-list.
+ //
+ // As a single paragraph, despite the fact that the second line starts
+ // with a digit-period-space sequence.
+ //
+ // Whereas when we're inside a list (or sub-list), that line will be
+ // treated as the start of a sub-list. What a kludge, huh? This is
+ // an aspect of Markdown's syntax that's hard to parse perfectly
+ // without resorting to mind-reading. Perhaps the solution is to
+ // change the syntax rules such that sub-lists must start with a
+ // starting cardinal number; e.g. "1." or "a.".
+
+ g_list_level++;
+
+ // trim trailing blank lines:
+ list_str = list_str.replace(/\n{2,}$/,"\n");
+
+ // attacklab: add sentinel to emulate \z
+ list_str += "~0";
+
+ /*
+ list_str = list_str.replace(/
+ (\n)? // leading line = $1
+ (^[ \t]*) // leading whitespace = $2
+ ([*+-]|\d+[.]) [ \t]+ // list marker = $3
+ ([^\r]+? // list item text = $4
+ (\n{1,2}))
+ (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
+ /gm, function(){...});
+ */
+ list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
+ function(wholeMatch,m1,m2,m3,m4){
+ var item = m4;
+ var leading_line = m1;
+ var leading_space = m2;
+
+ if (leading_line || (item.search(/\n{2,}/)>-1)) {
+ item = _RunBlockGamut(_Outdent(item));
+ }
+ else {
+ // Recursion for sub-lists:
+ item = _DoLists(_Outdent(item));
+ item = item.replace(/\n$/,""); // chomp(item)
+ item = _RunSpanGamut(item);
+ }
+
+ return "<li>" + item + "</li>\n";
+ }
+ );
+
+ // attacklab: strip sentinel
+ list_str = list_str.replace(/~0/g,"");
+
+ g_list_level--;
+ return list_str;
+}
+
+
+var _DoCodeBlocks = function(text) {
+//
+// Process Markdown `<pre><code>` blocks.
+//
+
+ /*
+ text = text.replace(text,
+ /(?:\n\n|^)
+ ( // $1 = the code block -- one or more lines, starting with a space/tab
+ (?:
+ (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
+ .*\n+
+ )+
+ )
+ (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
+ /g,function(){...});
+ */
+
+ // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
+ text += "~0";
+
+ text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
+ function(wholeMatch,m1,m2) {
+ var codeblock = m1;
+ var nextChar = m2;
+
+ codeblock = _EncodeCode( _Outdent(codeblock));
+ codeblock = _Detab(codeblock);
+ codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
+ codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
+
+ codeblock = "<pre><code>" + codeblock + "\n</code></pre>";
+
+ return hashBlock(codeblock) + nextChar;
+ }
+ );
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/,"");
+
+ return text;
+}
+
+var hashBlock = function(text) {
+ text = text.replace(/(^\n+|\n+$)/g,"");
+ return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
+}
+
+
+var _DoCodeSpans = function(text) {
+//
+// * Backtick quotes are used for <code></code> spans.
+//
+// * You can use multiple backticks as the delimiters if you want to
+// include literal backticks in the code span. So, this input:
+//
+// Just type ``foo `bar` baz`` at the prompt.
+//
+// Will translate to:
+//
+// <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
+//
+// There's no arbitrary limit to the number of backticks you
+// can use as delimters. If you need three consecutive backticks
+// in your code, use four for delimiters, etc.
+//
+// * You can use spaces to get literal backticks at the edges:
+//
+// ... type `` `bar` `` ...
+//
+// Turns to:
+//
+// ... type <code>`bar`</code> ...
+//
+
+ /*
+ text = text.replace(/
+ (^|[^\\]) // Character before opening ` can't be a backslash
+ (`+) // $2 = Opening run of `
+ ( // $3 = The code block
+ [^\r]*?
+ [^`] // attacklab: work around lack of lookbehind
+ )
+ \2 // Matching closer
+ (?!`)
+ /gm, function(){...});
+ */
+
+ text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
+ function(wholeMatch,m1,m2,m3,m4) {
+ var c = m3;
+ c = c.replace(/^([ \t]*)/g,""); // leading whitespace
+ c = c.replace(/[ \t]*$/g,""); // trailing whitespace
+ c = _EncodeCode(c);
+ return m1+"<code>"+c+"</code>";
+ });
+
+ return text;
+}
+
+
+var _EncodeCode = function(text) {
+//
+// Encode/escape certain characters inside Markdown code runs.
+// The point is that in code, these characters are literals,
+// and lose their special Markdown meanings.
+//
+ // Encode all ampersands; HTML entities are not
+ // entities within a Markdown code span.
+ text = text.replace(/&/g,"&");
+
+ // Do the angle bracket song and dance:
+ text = text.replace(/</g,"<");
+ text = text.replace(/>/g,">");
+
+ // Now, escape characters that are magic in Markdown:
+ text = escapeCharacters(text,"\*_{}[]\\",false);
+
+// jj the line above breaks this:
+//---
+
+//* Item
+
+// 1. Subitem
+
+// special char: *
+//---
+
+ return text;
+}
+
+
+var _DoItalicsAndBold = function(text) {
+
+ // <strong> must go first:
+ text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
+ "<strong>$2</strong>");
+
+ text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
+ "<em>$2</em>");
+
+ return text;
+}
+
+
+var _DoBlockQuotes = function(text) {
+
+ /*
+ text = text.replace(/
+ ( // Wrap whole match in $1
+ (
+ ^[ \t]*>[ \t]? // '>' at the start of a line
+ .+\n // rest of the first line
+ (.+\n)* // subsequent consecutive lines
+ \n* // blanks
+ )+
+ )
+ /gm, function(){...});
+ */
+
+ text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
+ function(wholeMatch,m1) {
+ var bq = m1;
+
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ // "----------bug".replace(/^-/g,"") == "bug"
+
+ bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
+
+ // attacklab: clean up hack
+ bq = bq.replace(/~0/g,"");
+
+ bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
+ bq = _RunBlockGamut(bq); // recurse
+
+ bq = bq.replace(/(^|\n)/g,"$1 ");
+ // These leading spaces screw with <pre> content, so we need to fix that:
+ bq = bq.replace(
+ /(\s*<pre>[^\r]+?<\/pre>)/gm,
+ function(wholeMatch,m1) {
+ var pre = m1;
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ pre = pre.replace(/^ /mg,"~0");
+ pre = pre.replace(/~0/g,"");
+ return pre;
+ });
+
+ return hashBlock("<blockquote>\n" + bq + "\n</blockquote>");
+ });
+ return text;
+}
+
+
+var _FormParagraphs = function(text) {
+//
+// Params:
+// $text - string to process with html <p> tags
+//
+
+ // Strip leading and trailing lines:
+ text = text.replace(/^\n+/g,"");
+ text = text.replace(/\n+$/g,"");
+
+ var grafs = text.split(/\n{2,}/g);
+ var grafsOut = new Array();
+
+ //
+ // Wrap <p> tags.
+ //
+ var end = grafs.length;
+ for (var i=0; i<end; i++) {
+ var str = grafs[i];
+
+ // if this is an HTML marker, copy it
+ if (str.search(/~K(\d+)K/g) >= 0) {
+ grafsOut.push(str);
+ }
+ else if (str.search(/\S/) >= 0) {
+ str = _RunSpanGamut(str);
+ str = str.replace(/^([ \t]*)/g,"<p>");
+ str += "</p>"
+ grafsOut.push(str);
+ }
+
+ }
+
+ //
+ // Unhashify HTML blocks
+ //
+ end = grafsOut.length;
+ for (var i=0; i<end; i++) {
+ // if this is a marker for an html block...
+ while (grafsOut[i].search(/~K(\d+)K/) >= 0) {
+ var blockText = g_html_blocks[RegExp.$1];
+ blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs
+ grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText);
+ }
+ }
+
+ return grafsOut.join("\n\n");
+}
+
+
+var _EncodeAmpsAndAngles = function(text) {
+// Smart processing for ampersands and angle brackets that need to be encoded.
+
+ // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
+ // http://bumppo.net/projects/amputator/
+ text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&");
+
+ // Encode naked <'s
+ text = text.replace(/<(?![a-z\/?\$!])/gi,"<");
+
+ return text;
+}
+
+
+var _EncodeBackslashEscapes = function(text) {
+//
+// Parameter: String.
+// Returns: The string, with after processing the following backslash
+// escape sequences.
+//
+
+ // attacklab: The polite way to do this is with the new
+ // escapeCharacters() function:
+ //
+ // text = escapeCharacters(text,"\\",true);
+ // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
+ //
+ // ...but we're sidestepping its use of the (slow) RegExp constructor
+ // as an optimization for Firefox. This function gets called a LOT.
+
+ text = text.replace(/\\(\\)/g,escapeCharacters_callback);
+ text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback);
+ return text;
+}
+
+
+var _DoAutoLinks = function(text) {
+
+ text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");
+
+ // Email addresses: <ad...@domain.foo>
+
+ /*
+ text = text.replace(/
+ <
+ (?:mailto:)?
+ (
+ [-.\w]+
+ \@
+ [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
+ )
+ >
+ /gi, _DoAutoLinks_callback());
+ */
+ text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
+ function(wholeMatch,m1) {
+ return _EncodeEmailAddress( _UnescapeSpecialChars(m1) );
+ }
+ );
+
+ return text;
+}
+
+
+var _EncodeEmailAddress = function(addr) {
+//
+// Input: an email address, e.g. "foo@example.com"
+//
+// Output: the email address as a mailto link, with each character
+// of the address encoded as either a decimal or hex entity, in
+// the hopes of foiling most address harvesting spam bots. E.g.:
+//
+// <a href="mailto:foo@e
+// xample.com">foo
+// @example.com</a>
+//
+// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
+// mailing list: <http://tinyurl.com/yu7ue>
+//
+
+ // attacklab: why can't javascript speak hex?
+ function char2hex(ch) {
+ var hexDigits = '0123456789ABCDEF';
+ var dec = ch.charCodeAt(0);
+ return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15));
+ }
+
+ var encode = [
+ function(ch){return "&#"+ch.charCodeAt(0)+";";},
+ function(ch){return "&#x"+char2hex(ch)+";";},
+ function(ch){return ch;}
+ ];
+
+ addr = "mailto:" + addr;
+
+ addr = addr.replace(/./g, function(ch) {
+ if (ch == "@") {
+ // this *must* be encoded. I insist.
+ ch = encode[Math.floor(Math.random()*2)](ch);
+ } else if (ch !=":") {
+ // leave ':' alone (to spot mailto: later)
+ var r = Math.random();
+ // roughly 10% raw, 45% hex, 45% dec
+ ch = (
+ r > .9 ? encode[2](ch) :
+ r > .45 ? encode[1](ch) :
+ encode[0](ch)
+ );
+ }
+ return ch;
+ });
+
+ addr = "<a href=\"" + addr + "\">" + addr + "</a>";
+ addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part
+
+ return addr;
+}
+
+
+var _UnescapeSpecialChars = function(text) {
+//
+// Swap back in all the special characters we've hidden.
+//
+ text = text.replace(/~E(\d+)E/g,
+ function(wholeMatch,m1) {
+ var charCodeToReplace = parseInt(m1);
+ return String.fromCharCode(charCodeToReplace);
+ }
+ );
+ return text;
+}
+
+
+var _Outdent = function(text) {
+//
+// Remove one level of line-leading tabs or spaces
+//
+
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ // "----------bug".replace(/^-/g,"") == "bug"
+
+ text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width
+
+ // attacklab: clean up hack
+ text = text.replace(/~0/g,"")
+
+ return text;
+}
+
+var _Detab = function(text) {
+// attacklab: Detab's completely rewritten for speed.
+// In perl we could fix it by anchoring the regexp with \G.
+// In javascript we're less fortunate.
+
+ // expand first n-1 tabs
+ text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width
+
+ // replace the nth with two sentinels
+ text = text.replace(/\t/g,"~A~B");
+
+ // use the sentinel to anchor our regex so it doesn't explode
+ text = text.replace(/~B(.+?)~A/g,
+ function(wholeMatch,m1,m2) {
+ var leadingText = m1;
+ var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width
+
+ // there *must* be a better way to do this:
+ for (var i=0; i<numSpaces; i++) leadingText+=" ";
+
+ return leadingText;
+ }
+ );
+
+ // clean up sentinels
+ text = text.replace(/~A/g," "); // attacklab: g_tab_width
+ text = text.replace(/~B/g,"");
+
+ return text;
+}
+
+
+//
+// attacklab: Utility functions
+//
+
+
+var escapeCharacters = function(text, charsToEscape, afterBackslash) {
+ // First we have to escape the escape characters so that
+ // we can build a character class out of them
+ var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g,"\\$1") + "])";
+
+ if (afterBackslash) {
+ regexString = "\\\\" + regexString;
+ }
+
+ var regex = new RegExp(regexString,"g");
+ text = text.replace(regex,escapeCharacters_callback);
+
+ return text;
+}
+
+
+var escapeCharacters_callback = function(wholeMatch,m1) {
+ var charCodeToEscape = m1.charCodeAt(0);
+ return "~E"+charCodeToEscape+"E";
+}
+
+} // end of Showdown.converter
+
+// export
+if (typeof exports != 'undefined') exports.Showdown = Showdown;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/Makefile
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/Makefile b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/Makefile
new file mode 100644
index 0000000..ed07610
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/Makefile
@@ -0,0 +1,73 @@
+BUILD_DIR = build
+
+PREFIX = .
+SRC_DIR = ${PREFIX}
+DIST_DIR = ${PREFIX}/dist
+
+
+JS_ENGINE ?= `which node nodejs 2> /dev/null`
+COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
+POST_COMPILER = ${JS_ENGINE} ${BUILD_DIR}/post-compile.js
+
+SRC = ${SRC_DIR}/jsonselect.js
+DIST = ${DIST_DIR}/jsonselect.js
+DIST_MIN = ${DIST_DIR}/jsonselect.min.js
+
+all: hint project min tests
+ @@echo "Project build complete."
+
+${DIST_DIR}:
+ @@mkdir -p ${DIST_DIR}
+
+project: ${DIST}
+
+${DIST}: ${SRC} | ${DIST_DIR}
+ @@echo "Building" ${DIST}
+ @@echo ${SRC}
+ @@cat ${SRC} > ${DIST};
+
+
+min: project ${DIST_MIN}
+
+${DIST_MIN}: ${DIST}
+ @@if test ! -z ${JS_ENGINE}; then \
+ echo "Minifying Project" ${DIST_MIN}; \
+ ${COMPILER} ${DIST} > ${DIST_MIN}.tmp; \
+ ${POST_COMPILER} ${DIST_MIN}.tmp > ${DIST_MIN}; \
+ rm -f ${DIST_MIN}.tmp; \
+ else \
+ echo "You must have NodeJS installed in order to minify Project."; \
+ fi
+
+
+hint:
+ @@if test ! -z ${JS_ENGINE}; then \
+ echo "Hinting Project"; \
+ ${JS_ENGINE} build/jshint-check.js; \
+ else \
+ echo "Nodejs is missing"; \
+ fi
+
+
+test/tests/README.md:
+ @@cd .. && git submodule init
+ @@cd .. && git submodule update
+
+
+tests: test/tests/README.md
+ @@if test ! -z ${JS_ENGINE}; then \
+ echo "Testing Project"; \
+ ${JS_ENGINE} test/run.js; \
+ else \
+ echo "nodejs is missing"; \
+ fi
+
+
+clean:
+ @@echo "Removing Distribution directory:" ${DIST_DIR}
+ @@rm -rf ${DIST_DIR}
+
+
+
+
+.PHONY: all project hint min tests
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/jshint-check.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/jshint-check.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/jshint-check.js
new file mode 100644
index 0000000..312c643
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/build/jshint-check.js
@@ -0,0 +1,41 @@
+var JSHINT = require("./lib/jshint").JSHINT,
+ print = require("sys").print,
+ src = require("fs").readFileSync("jsonselect.js", "utf8");
+
+JSHINT(src, { evil: true, forin: true, maxerr: 100 });
+
+var ok = {
+
+ // w.reason
+ "Expected an identifier and instead saw 'undefined' (a reserved word).": true,
+ "Use '===' to compare with 'null'.": true,
+ "Use '!==' to compare with 'null'.": true,
+ "Expected an assignment or function call and instead saw an expression.": true,
+ "Expected a 'break' statement before 'case'.": true,
+ "'e' is already defined.": true,
+ // w.raw
+ "Expected an identifier and instead saw \'{a}\' (a reserved word).": true
+};
+
+var e = JSHINT.errors,
+ found = 0,
+ w;
+
+for ( var i = 0; i < e.length; i++ ) {
+ w = e[i];
+
+ //console.log( w );
+ if ( !ok[ w.reason ] && !ok[ w.raw ] ) {
+ found++;
+
+ print( "\n " + found + ". Problem at line " + w.line + " character " + w.character + ": " + w.reason );
+ print( "\n" + w.evidence );
+ }
+}
+
+if ( found > 0 ) {
+ print( "\n\n" + found + " Error(s) found.\n" );
+
+} else {
+ print( "JSHint check passed.\n" );
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[21/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/reduce.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/reduce.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/reduce.js
new file mode 100644
index 0000000..e9ef95b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/reduce.js
@@ -0,0 +1,173 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(
+ Promise, Promise$_CreatePromiseArray,
+ PromiseArray, apiRejection, INTERNAL) {
+
+ function Reduction(callback, index, accum, items, receiver) {
+ this.promise = new Promise(INTERNAL);
+ this.index = index;
+ this.length = items.length;
+ this.items = items;
+ this.callback = callback;
+ this.receiver = receiver;
+ this.accum = accum;
+ }
+
+ Reduction.prototype.reject = function Reduction$reject(e) {
+ this.promise._reject(e);
+ };
+
+ Reduction.prototype.fulfill = function Reduction$fulfill(value, index) {
+ this.accum = value;
+ this.index = index + 1;
+ this.iterate();
+ };
+
+ Reduction.prototype.iterate = function Reduction$iterate() {
+ var i = this.index;
+ var len = this.length;
+ var items = this.items;
+ var result = this.accum;
+ var receiver = this.receiver;
+ var callback = this.callback;
+ var iterate = this.iterate;
+
+ for(; i < len; ++i) {
+ result = Promise._cast(
+ callback.call(
+ receiver,
+ result,
+ items[i],
+ i,
+ len
+ ),
+ iterate,
+ void 0
+ );
+
+ if (result instanceof Promise) {
+ result._then(
+ this.fulfill, this.reject, void 0, this, i, iterate);
+ return;
+ }
+ }
+ this.promise._fulfill(result);
+ };
+
+ function Promise$_reducer(fulfilleds, initialValue) {
+ var fn = this;
+ var receiver = void 0;
+ if (typeof fn !== "function") {
+ receiver = fn.receiver;
+ fn = fn.fn;
+ }
+ var len = fulfilleds.length;
+ var accum = void 0;
+ var startIndex = 0;
+
+ if (initialValue !== void 0) {
+ accum = initialValue;
+ startIndex = 0;
+ }
+ else {
+ startIndex = 1;
+ if (len > 0) accum = fulfilleds[0];
+ }
+ var i = startIndex;
+
+ if (i >= len) {
+ return accum;
+ }
+
+ var reduction = new Reduction(fn, i, accum, fulfilleds, receiver);
+ reduction.iterate();
+ return reduction.promise;
+ }
+
+ function Promise$_unpackReducer(fulfilleds) {
+ var fn = this.fn;
+ var initialValue = this.initialValue;
+ return Promise$_reducer.call(fn, fulfilleds, initialValue);
+ }
+
+ function Promise$_slowReduce(
+ promises, fn, initialValue, useBound, caller) {
+ return initialValue._then(function callee(initialValue) {
+ return Promise$_Reduce(
+ promises, fn, initialValue, useBound, callee);
+ }, void 0, void 0, void 0, void 0, caller);
+ }
+
+ function Promise$_Reduce(promises, fn, initialValue, useBound, caller) {
+ if (typeof fn !== "function") {
+ return apiRejection("fn must be a function");
+ }
+
+ if (useBound === true && promises._isBound()) {
+ fn = {
+ fn: fn,
+ receiver: promises._boundTo
+ };
+ }
+
+ if (initialValue !== void 0) {
+ if (Promise.is(initialValue)) {
+ if (initialValue.isFulfilled()) {
+ initialValue = initialValue._settledValue;
+ }
+ else {
+ return Promise$_slowReduce(promises,
+ fn, initialValue, useBound, caller);
+ }
+ }
+
+ return Promise$_CreatePromiseArray(promises, PromiseArray, caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0)
+ .promise()
+ ._then(Promise$_unpackReducer, void 0, void 0, {
+ fn: fn,
+ initialValue: initialValue
+ }, void 0, Promise.reduce);
+ }
+ return Promise$_CreatePromiseArray(promises, PromiseArray, caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0).promise()
+ ._then(Promise$_reducer, void 0, void 0, fn, void 0, caller);
+ }
+
+
+ Promise.reduce = function Promise$Reduce(promises, fn, initialValue) {
+ return Promise$_Reduce(promises, fn,
+ initialValue, false, Promise.reduce);
+ };
+
+ Promise.prototype.reduce = function Promise$reduce(fn, initialValue) {
+ return Promise$_Reduce(this, fn, initialValue,
+ true, this.reduce);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/schedule.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/schedule.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/schedule.js
new file mode 100644
index 0000000..ae2271e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/schedule.js
@@ -0,0 +1,121 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var global = require("./global.js");
+var schedule;
+if (typeof process !== "undefined" && process !== null &&
+ typeof process.cwd === "function" &&
+ typeof process.nextTick === "function" &&
+ typeof process.version === "string") {
+ schedule = function Promise$_Scheduler(fn) {
+ process.nextTick(fn);
+ };
+}
+else if ((typeof global.MutationObserver === "function" ||
+ typeof global.WebkitMutationObserver === "function" ||
+ typeof global.WebKitMutationObserver === "function") &&
+ typeof document !== "undefined" &&
+ typeof document.createElement === "function") {
+
+
+ schedule = (function(){
+ var MutationObserver = global.MutationObserver ||
+ global.WebkitMutationObserver ||
+ global.WebKitMutationObserver;
+ var div = document.createElement("div");
+ var queuedFn = void 0;
+ var observer = new MutationObserver(
+ function Promise$_Scheduler() {
+ var fn = queuedFn;
+ queuedFn = void 0;
+ fn();
+ }
+ );
+ observer.observe(div, {
+ attributes: true
+ });
+ return function Promise$_Scheduler(fn) {
+ queuedFn = fn;
+ div.setAttribute("class", "foo");
+ };
+
+ })();
+}
+else if (typeof global.postMessage === "function" &&
+ typeof global.importScripts !== "function" &&
+ typeof global.addEventListener === "function" &&
+ typeof global.removeEventListener === "function") {
+
+ var MESSAGE_KEY = "bluebird_message_key_" + Math.random();
+ schedule = (function(){
+ var queuedFn = void 0;
+
+ function Promise$_Scheduler(e) {
+ if (e.source === global &&
+ e.data === MESSAGE_KEY) {
+ var fn = queuedFn;
+ queuedFn = void 0;
+ fn();
+ }
+ }
+
+ global.addEventListener("message", Promise$_Scheduler, false);
+
+ return function Promise$_Scheduler(fn) {
+ queuedFn = fn;
+ global.postMessage(
+ MESSAGE_KEY, "*"
+ );
+ };
+
+ })();
+}
+else if (typeof global.MessageChannel === "function") {
+ schedule = (function(){
+ var queuedFn = void 0;
+
+ var channel = new global.MessageChannel();
+ channel.port1.onmessage = function Promise$_Scheduler() {
+ var fn = queuedFn;
+ queuedFn = void 0;
+ fn();
+ };
+
+ return function Promise$_Scheduler(fn) {
+ queuedFn = fn;
+ channel.port2.postMessage(null);
+ };
+ })();
+}
+else if (global.setTimeout) {
+ schedule = function Promise$_Scheduler(fn) {
+ setTimeout(fn, 4);
+ };
+}
+else {
+ schedule = function Promise$_Scheduler(fn) {
+ fn();
+ };
+}
+
+module.exports = schedule;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/settle.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/settle.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/settle.js
new file mode 100644
index 0000000..863882f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/settle.js
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports =
+ function(Promise, Promise$_CreatePromiseArray, PromiseArray) {
+
+ var SettledPromiseArray = require("./settled_promise_array.js")(
+ Promise, PromiseArray);
+
+ function Promise$_Settle(promises, useBound, caller) {
+ return Promise$_CreatePromiseArray(
+ promises,
+ SettledPromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ ).promise();
+ }
+
+ Promise.settle = function Promise$Settle(promises) {
+ return Promise$_Settle(promises, false, Promise.settle);
+ };
+
+ Promise.prototype.settle = function Promise$settle() {
+ return Promise$_Settle(this, true, this.settle);
+ };
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/settled_promise_array.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/settled_promise_array.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/settled_promise_array.js
new file mode 100644
index 0000000..fd25d4d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/settled_promise_array.js
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, PromiseArray) {
+var PromiseInspection = require("./promise_inspection.js");
+var util = require("./util.js");
+var inherits = util.inherits;
+function SettledPromiseArray(values, caller, boundTo) {
+ this.constructor$(values, caller, boundTo);
+}
+inherits(SettledPromiseArray, PromiseArray);
+
+SettledPromiseArray.prototype._promiseResolved =
+function SettledPromiseArray$_promiseResolved(index, inspection) {
+ this._values[index] = inspection;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ this._resolve(this._values);
+ }
+};
+
+SettledPromiseArray.prototype._promiseFulfilled =
+function SettledPromiseArray$_promiseFulfilled(value, index) {
+ if (this._isResolved()) return;
+ var ret = new PromiseInspection();
+ ret._bitField = 268435456;
+ ret._settledValue = value;
+ this._promiseResolved(index, ret);
+};
+SettledPromiseArray.prototype._promiseRejected =
+function SettledPromiseArray$_promiseRejected(reason, index) {
+ if (this._isResolved()) return;
+ var ret = new PromiseInspection();
+ ret._bitField = 134217728;
+ ret._settledValue = reason;
+ this._promiseResolved(index, ret);
+};
+
+return SettledPromiseArray;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/some.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/some.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/some.js
new file mode 100644
index 0000000..21c4ecd
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/some.js
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports =
+function(Promise, Promise$_CreatePromiseArray, PromiseArray, apiRejection) {
+
+ var SomePromiseArray = require("./some_promise_array.js")(PromiseArray);
+ function Promise$_Some(promises, howMany, useBound, caller) {
+ if ((howMany | 0) !== howMany || howMany < 0) {
+ return apiRejection("expecting a positive integer");
+ }
+ var ret = Promise$_CreatePromiseArray(
+ promises,
+ SomePromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ );
+ var promise = ret.promise();
+ if (promise.isRejected()) {
+ return promise;
+ }
+ ret.setHowMany(howMany);
+ ret.init();
+ return promise;
+ }
+
+ Promise.some = function Promise$Some(promises, howMany) {
+ return Promise$_Some(promises, howMany, false, Promise.some);
+ };
+
+ Promise.prototype.some = function Promise$some(count) {
+ return Promise$_Some(this, count, true, this.some);
+ };
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/some_promise_array.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/some_promise_array.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/some_promise_array.js
new file mode 100644
index 0000000..d3b89d4
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/some_promise_array.js
@@ -0,0 +1,131 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function (PromiseArray) {
+var util = require("./util.js");
+var RangeError = require("./errors.js").RangeError;
+var inherits = util.inherits;
+var isArray = util.isArray;
+
+function SomePromiseArray(values, caller, boundTo) {
+ this.constructor$(values, caller, boundTo);
+ this._howMany = 0;
+ this._unwrap = false;
+ this._initialized = false;
+}
+inherits(SomePromiseArray, PromiseArray);
+
+SomePromiseArray.prototype._init = function SomePromiseArray$_init() {
+ if (!this._initialized) {
+ return;
+ }
+ if (this._howMany === 0) {
+ this._resolve([]);
+ return;
+ }
+ this._init$(void 0, -2);
+ var isArrayResolved = isArray(this._values);
+ this._holes = isArrayResolved ? this._values.length - this.length() : 0;
+
+ if (!this._isResolved() &&
+ isArrayResolved &&
+ this._howMany > this._canPossiblyFulfill()) {
+ var message = "(Promise.some) input array contains less than " +
+ this._howMany + " promises";
+ this._reject(new RangeError(message));
+ }
+};
+
+SomePromiseArray.prototype.init = function SomePromiseArray$init() {
+ this._initialized = true;
+ this._init();
+};
+
+SomePromiseArray.prototype.setUnwrap = function SomePromiseArray$setUnwrap() {
+ this._unwrap = true;
+};
+
+SomePromiseArray.prototype.howMany = function SomePromiseArray$howMany() {
+ return this._howMany;
+};
+
+SomePromiseArray.prototype.setHowMany =
+function SomePromiseArray$setHowMany(count) {
+ if (this._isResolved()) return;
+ this._howMany = count;
+};
+
+SomePromiseArray.prototype._promiseFulfilled =
+function SomePromiseArray$_promiseFulfilled(value) {
+ if (this._isResolved()) return;
+ this._addFulfilled(value);
+ if (this._fulfilled() === this.howMany()) {
+ this._values.length = this.howMany();
+ if (this.howMany() === 1 && this._unwrap) {
+ this._resolve(this._values[0]);
+ }
+ else {
+ this._resolve(this._values);
+ }
+ }
+
+};
+SomePromiseArray.prototype._promiseRejected =
+function SomePromiseArray$_promiseRejected(reason) {
+ if (this._isResolved()) return;
+ this._addRejected(reason);
+ if (this.howMany() > this._canPossiblyFulfill()) {
+ if (this._values.length === this.length()) {
+ this._reject([]);
+ }
+ else {
+ this._reject(this._values.slice(this.length() + this._holes));
+ }
+ }
+};
+
+SomePromiseArray.prototype._fulfilled = function SomePromiseArray$_fulfilled() {
+ return this._totalResolved;
+};
+
+SomePromiseArray.prototype._rejected = function SomePromiseArray$_rejected() {
+ return this._values.length - this.length() - this._holes;
+};
+
+SomePromiseArray.prototype._addRejected =
+function SomePromiseArray$_addRejected(reason) {
+ this._values.push(reason);
+};
+
+SomePromiseArray.prototype._addFulfilled =
+function SomePromiseArray$_addFulfilled(value) {
+ this._values[this._totalResolved++] = value;
+};
+
+SomePromiseArray.prototype._canPossiblyFulfill =
+function SomePromiseArray$_canPossiblyFulfill() {
+ return this.length() - this._rejected();
+};
+
+return SomePromiseArray;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/synchronous_inspection.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/synchronous_inspection.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/synchronous_inspection.js
new file mode 100644
index 0000000..dcbdc90
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/synchronous_inspection.js
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+ var PromiseInspection = require("./promise_inspection.js");
+
+ Promise.prototype.inspect = function Promise$inspect() {
+ return new PromiseInspection(this);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/thenables.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/thenables.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/thenables.js
new file mode 100644
index 0000000..510da18
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/thenables.js
@@ -0,0 +1,138 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+ var util = require("./util.js");
+ var canAttach = require("./errors.js").canAttach;
+ var errorObj = util.errorObj;
+ var isObject = util.isObject;
+
+ function getThen(obj) {
+ try {
+ return obj.then;
+ }
+ catch(e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+ }
+
+ function Promise$_Cast(obj, caller, originalPromise) {
+ if (isObject(obj)) {
+ if (obj instanceof Promise) {
+ return obj;
+ }
+ else if (isAnyBluebirdPromise(obj)) {
+ var ret = new Promise(INTERNAL);
+ ret._setTrace(caller, void 0);
+ obj._then(
+ ret._fulfillUnchecked,
+ ret._rejectUncheckedCheckError,
+ ret._progressUnchecked,
+ ret,
+ null,
+ void 0
+ );
+ ret._setFollowing();
+ return ret;
+ }
+ var then = getThen(obj);
+ if (then === errorObj) {
+ caller = typeof caller === "function" ? caller : Promise$_Cast;
+ if (originalPromise !== void 0 && canAttach(then.e)) {
+ originalPromise._attachExtraTrace(then.e);
+ }
+ return Promise.reject(then.e, caller);
+ }
+ else if (typeof then === "function") {
+ caller = typeof caller === "function" ? caller : Promise$_Cast;
+ return Promise$_doThenable(obj, then, caller, originalPromise);
+ }
+ }
+ return obj;
+ }
+
+ var hasProp = {}.hasOwnProperty;
+ function isAnyBluebirdPromise(obj) {
+ return hasProp.call(obj, "_promise0");
+ }
+
+ function Promise$_doThenable(x, then, caller, originalPromise) {
+ var resolver = Promise.defer(caller);
+ var called = false;
+ try {
+ then.call(
+ x,
+ Promise$_resolveFromThenable,
+ Promise$_rejectFromThenable,
+ Promise$_progressFromThenable
+ );
+ }
+ catch(e) {
+ if (!called) {
+ called = true;
+ var trace = canAttach(e) ? e : new Error(e + "");
+ if (originalPromise !== void 0) {
+ originalPromise._attachExtraTrace(trace);
+ }
+ resolver.promise._reject(e, trace);
+ }
+ }
+ return resolver.promise;
+
+ function Promise$_resolveFromThenable(y) {
+ if (called) return;
+ called = true;
+
+ if (x === y) {
+ var e = Promise._makeSelfResolutionError();
+ if (originalPromise !== void 0) {
+ originalPromise._attachExtraTrace(e);
+ }
+ resolver.promise._reject(e, void 0);
+ return;
+ }
+ resolver.resolve(y);
+ }
+
+ function Promise$_rejectFromThenable(r) {
+ if (called) return;
+ called = true;
+ var trace = canAttach(r) ? r : new Error(r + "");
+ if (originalPromise !== void 0) {
+ originalPromise._attachExtraTrace(trace);
+ }
+ resolver.promise._reject(r, trace);
+ }
+
+ function Promise$_progressFromThenable(v) {
+ if (called) return;
+ var promise = resolver.promise;
+ if (typeof promise._progress === "function") {
+ promise._progress(v);
+ }
+ }
+ }
+
+ Promise._cast = Promise$_Cast;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/timers.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/timers.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/timers.js
new file mode 100644
index 0000000..8edcac2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/timers.js
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+
+var global = require("./global.js");
+var setTimeout = function(fn, time) {
+ var $_len = arguments.length;var args = new Array($_len - 2); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];}
+ global.setTimeout(function() {
+ fn.apply(void 0, args);
+ }, time);
+};
+
+var pass = {};
+global.setTimeout( function(_) {
+ if(_ === pass) {
+ setTimeout = global.setTimeout;
+ }
+}, 1, pass);
+
+module.exports = function(Promise, INTERNAL) {
+ var util = require("./util.js");
+ var errors = require("./errors.js");
+ var apiRejection = require("./errors_api_rejection")(Promise);
+ var TimeoutError = Promise.TimeoutError;
+
+ var afterTimeout = function Promise$_afterTimeout(promise, message, ms) {
+ if (!promise.isPending()) return;
+ if (typeof message !== "string") {
+ message = "operation timed out after" + " " + ms + " ms"
+ }
+ var err = new TimeoutError(message);
+ errors.markAsOriginatingFromRejection(err);
+ promise._attachExtraTrace(err);
+ promise._rejectUnchecked(err);
+ };
+
+ var afterDelay = function Promise$_afterDelay(value, promise) {
+ promise._fulfill(value);
+ };
+
+ Promise.delay = function Promise$Delay(value, ms, caller) {
+ if (ms === void 0) {
+ ms = value;
+ value = void 0;
+ }
+ ms = +ms;
+ if (typeof caller !== "function") {
+ caller = Promise.delay;
+ }
+ var maybePromise = Promise._cast(value, caller, void 0);
+ var promise = new Promise(INTERNAL);
+
+ if (Promise.is(maybePromise)) {
+ if (maybePromise._isBound()) {
+ promise._setBoundTo(maybePromise._boundTo);
+ }
+ if (maybePromise._cancellable()) {
+ promise._setCancellable();
+ promise._cancellationParent = maybePromise;
+ }
+ promise._setTrace(caller, maybePromise);
+ promise._follow(maybePromise);
+ return promise.then(function(value) {
+ return Promise.delay(value, ms);
+ });
+ }
+ else {
+ promise._setTrace(caller, void 0);
+ setTimeout(afterDelay, ms, value, promise);
+ }
+ return promise;
+ };
+
+ Promise.prototype.delay = function Promise$delay(ms) {
+ return Promise.delay(this, ms, this.delay);
+ };
+
+ Promise.prototype.timeout = function Promise$timeout(ms, message) {
+ ms = +ms;
+
+ var ret = new Promise(INTERNAL);
+ ret._setTrace(this.timeout, this);
+
+ if (this._isBound()) ret._setBoundTo(this._boundTo);
+ if (this._cancellable()) {
+ ret._setCancellable();
+ ret._cancellationParent = this;
+ }
+ ret._follow(this);
+ setTimeout(afterTimeout, ms, ret, message, ms);
+ return ret;
+ };
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/util.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/util.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/util.js
new file mode 100644
index 0000000..fbd34e9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/util.js
@@ -0,0 +1,193 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var global = require("./global.js");
+var es5 = require("./es5.js");
+var haveGetters = (function(){
+ try {
+ var o = {};
+ es5.defineProperty(o, "f", {
+ get: function () {
+ return 3;
+ }
+ });
+ return o.f === 3;
+ }
+ catch (e) {
+ return false;
+ }
+
+})();
+
+var canEvaluate = (function() {
+ if (typeof window !== "undefined" && window !== null &&
+ typeof window.document !== "undefined" &&
+ typeof navigator !== "undefined" && navigator !== null &&
+ typeof navigator.appName === "string" &&
+ window === global) {
+ return false;
+ }
+ return true;
+})();
+
+function deprecated(msg) {
+ if (typeof console !== "undefined" && console !== null &&
+ typeof console.warn === "function") {
+ console.warn("Bluebird: " + msg);
+ }
+}
+
+var errorObj = {e: {}};
+function tryCatch1(fn, receiver, arg) {
+ try {
+ return fn.call(receiver, arg);
+ }
+ catch (e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+}
+
+function tryCatch2(fn, receiver, arg, arg2) {
+ try {
+ return fn.call(receiver, arg, arg2);
+ }
+ catch (e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+}
+
+function tryCatchApply(fn, args, receiver) {
+ try {
+ return fn.apply(receiver, args);
+ }
+ catch (e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+}
+
+var inherits = function(Child, Parent) {
+ var hasProp = {}.hasOwnProperty;
+
+ function T() {
+ this.constructor = Child;
+ this.constructor$ = Parent;
+ for (var propertyName in Parent.prototype) {
+ if (hasProp.call(Parent.prototype, propertyName) &&
+ propertyName.charAt(propertyName.length-1) !== "$"
+ ) {
+ this[propertyName + "$"] = Parent.prototype[propertyName];
+ }
+ }
+ }
+ T.prototype = Parent.prototype;
+ Child.prototype = new T();
+ return Child.prototype;
+};
+
+function asString(val) {
+ return typeof val === "string" ? val : ("" + val);
+}
+
+function isPrimitive(val) {
+ return val == null || val === true || val === false ||
+ typeof val === "string" || typeof val === "number";
+
+}
+
+function isObject(value) {
+ return !isPrimitive(value);
+}
+
+function maybeWrapAsError(maybeError) {
+ if (!isPrimitive(maybeError)) return maybeError;
+
+ return new Error(asString(maybeError));
+}
+
+function withAppended(target, appendee) {
+ var len = target.length;
+ var ret = new Array(len + 1);
+ var i;
+ for (i = 0; i < len; ++i) {
+ ret[i] = target[i];
+ }
+ ret[i] = appendee;
+ return ret;
+}
+
+
+function notEnumerableProp(obj, name, value) {
+ if (isPrimitive(obj)) return obj;
+ var descriptor = {
+ value: value,
+ configurable: true,
+ enumerable: false,
+ writable: true
+ };
+ es5.defineProperty(obj, name, descriptor);
+ return obj;
+}
+
+
+var wrapsPrimitiveReceiver = (function() {
+ return this !== "string";
+}).call("string");
+
+function thrower(r) {
+ throw r;
+}
+
+
+function toFastProperties(obj) {
+ /*jshint -W027*/
+ function f() {}
+ f.prototype = obj;
+ return f;
+ eval(obj);
+}
+
+var ret = {
+ thrower: thrower,
+ isArray: es5.isArray,
+ haveGetters: haveGetters,
+ notEnumerableProp: notEnumerableProp,
+ isPrimitive: isPrimitive,
+ isObject: isObject,
+ canEvaluate: canEvaluate,
+ deprecated: deprecated,
+ errorObj: errorObj,
+ tryCatch1: tryCatch1,
+ tryCatch2: tryCatch2,
+ tryCatchApply: tryCatchApply,
+ inherits: inherits,
+ withAppended: withAppended,
+ asString: asString,
+ maybeWrapAsError: maybeWrapAsError,
+ wrapsPrimitiveReceiver: wrapsPrimitiveReceiver,
+ toFastProperties: toFastProperties
+};
+
+module.exports = ret;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/any.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/any.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/any.js
new file mode 100644
index 0000000..8d174cf
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/any.js
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, Promise$_CreatePromiseArray, PromiseArray) {
+
+ var SomePromiseArray = require("./some_promise_array.js")(PromiseArray);
+ function Promise$_Any(promises, useBound, caller) {
+ var ret = Promise$_CreatePromiseArray(
+ promises,
+ SomePromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ );
+ var promise = ret.promise();
+ if (promise.isRejected()) {
+ return promise;
+ }
+ ret.setHowMany(1);
+ ret.setUnwrap();
+ ret.init();
+ return promise;
+ }
+
+ Promise.any = function Promise$Any(promises) {
+ return Promise$_Any(promises, false, Promise.any);
+ };
+
+ Promise.prototype.any = function Promise$any() {
+ return Promise$_Any(this, true, this.any);
+ };
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/assert.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/assert.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/assert.js
new file mode 100644
index 0000000..4adb8c2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/assert.js
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = (function(){
+ var AssertionError = (function() {
+ function AssertionError(a) {
+ this.constructor$(a);
+ this.message = a;
+ this.name = "AssertionError";
+ }
+ AssertionError.prototype = new Error();
+ AssertionError.prototype.constructor = AssertionError;
+ AssertionError.prototype.constructor$ = Error;
+ return AssertionError;
+ })();
+
+ function getParams(args) {
+ var params = [];
+ for (var i = 0; i < args.length; ++i) params.push("arg" + i);
+ return params;
+ }
+
+ function nativeAssert(callName, args, expect) {
+ try {
+ var params = getParams(args);
+ var constructorArgs = params;
+ constructorArgs.push("return " +
+ callName + "("+ params.join(",") + ");");
+ var fn = Function.apply(null, constructorArgs);
+ return fn.apply(null, args);
+ }
+ catch (e) {
+ if (!(e instanceof SyntaxError)) {
+ throw e;
+ }
+ else {
+ return expect;
+ }
+ }
+ }
+
+ return function assert(boolExpr, message) {
+ if (boolExpr === true) return;
+
+ if (typeof boolExpr === "string" &&
+ boolExpr.charAt(0) === "%") {
+ var nativeCallName = boolExpr;
+ var $_len = arguments.length;var args = new Array($_len - 2); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];}
+ if (nativeAssert(nativeCallName, args, message) === message) return;
+ message = (nativeCallName + " !== " + message);
+ }
+
+ var ret = new AssertionError(message);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(ret, assert);
+ }
+ if (console && console.error) {
+ console.error(ret.stack + "");
+ }
+ throw ret;
+
+ };
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/async.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/async.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/async.js
new file mode 100644
index 0000000..6f32b10
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/async.js
@@ -0,0 +1,111 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var schedule = require("./schedule.js");
+var Queue = require("./queue.js");
+var errorObj = require("./util.js").errorObj;
+var tryCatch1 = require("./util.js").tryCatch1;
+var process = require("./global.js").process;
+
+function Async() {
+ this._isTickUsed = false;
+ this._length = 0;
+ this._lateBuffer = new Queue();
+ this._functionBuffer = new Queue(25000 * 3);
+ var self = this;
+ this.consumeFunctionBuffer = function Async$consumeFunctionBuffer() {
+ self._consumeFunctionBuffer();
+ };
+}
+
+Async.prototype.haveItemsQueued = function Async$haveItemsQueued() {
+ return this._length > 0;
+};
+
+Async.prototype.invokeLater = function Async$invokeLater(fn, receiver, arg) {
+ if (process !== void 0 &&
+ process.domain != null &&
+ !fn.domain) {
+ fn = process.domain.bind(fn);
+ }
+ this._lateBuffer.push(fn, receiver, arg);
+ this._queueTick();
+};
+
+Async.prototype.invoke = function Async$invoke(fn, receiver, arg) {
+ if (process !== void 0 &&
+ process.domain != null &&
+ !fn.domain) {
+ fn = process.domain.bind(fn);
+ }
+ var functionBuffer = this._functionBuffer;
+ functionBuffer.push(fn, receiver, arg);
+ this._length = functionBuffer.length();
+ this._queueTick();
+};
+
+Async.prototype._consumeFunctionBuffer =
+function Async$_consumeFunctionBuffer() {
+ var functionBuffer = this._functionBuffer;
+ while(functionBuffer.length() > 0) {
+ var fn = functionBuffer.shift();
+ var receiver = functionBuffer.shift();
+ var arg = functionBuffer.shift();
+ fn.call(receiver, arg);
+ }
+ this._reset();
+ this._consumeLateBuffer();
+};
+
+Async.prototype._consumeLateBuffer = function Async$_consumeLateBuffer() {
+ var buffer = this._lateBuffer;
+ while(buffer.length() > 0) {
+ var fn = buffer.shift();
+ var receiver = buffer.shift();
+ var arg = buffer.shift();
+ var res = tryCatch1(fn, receiver, arg);
+ if (res === errorObj) {
+ this._queueTick();
+ if (fn.domain != null) {
+ fn.domain.emit("error", res.e);
+ }
+ else {
+ throw res.e;
+ }
+ }
+ }
+};
+
+Async.prototype._queueTick = function Async$_queue() {
+ if (!this._isTickUsed) {
+ schedule(this.consumeFunctionBuffer);
+ this._isTickUsed = true;
+ }
+};
+
+Async.prototype._reset = function Async$_reset() {
+ this._isTickUsed = false;
+ this._length = 0;
+};
+
+module.exports = new Async();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/bluebird.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/bluebird.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/bluebird.js
new file mode 100644
index 0000000..6fd85f1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/bluebird.js
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var Promise = require("./promise.js")();
+module.exports = Promise;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/call_get.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/call_get.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/call_get.js
new file mode 100644
index 0000000..2a3c1f5
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/call_get.js
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+ Promise.prototype.call = function Promise$call(propertyName) {
+ var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
+
+ return this._then(function(obj) {
+ return obj[propertyName].apply(obj, args);
+ },
+ void 0,
+ void 0,
+ void 0,
+ void 0,
+ this.call
+ );
+ };
+
+ function Promise$getter(obj) {
+ var prop = typeof this === "string"
+ ? this
+ : ("" + this);
+ return obj[prop];
+ }
+ Promise.prototype.get = function Promise$get(propertyName) {
+ return this._then(
+ Promise$getter,
+ void 0,
+ void 0,
+ propertyName,
+ void 0,
+ this.get
+ );
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/cancel.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/cancel.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/cancel.js
new file mode 100644
index 0000000..542b488
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/cancel.js
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+ var errors = require("./errors.js");
+ var async = require("./async.js");
+ var CancellationError = errors.CancellationError;
+ var SYNC_TOKEN = {};
+
+ Promise.prototype._cancel = function Promise$_cancel() {
+ if (!this.isCancellable()) return this;
+ var parent;
+ if ((parent = this._cancellationParent) !== void 0) {
+ parent.cancel(SYNC_TOKEN);
+ return;
+ }
+ var err = new CancellationError();
+ this._attachExtraTrace(err);
+ this._rejectUnchecked(err);
+ };
+
+ Promise.prototype.cancel = function Promise$cancel(token) {
+ if (!this.isCancellable()) return this;
+ if (token === SYNC_TOKEN) {
+ this._cancel();
+ return this;
+ }
+ async.invokeLater(this._cancel, this, void 0);
+ return this;
+ };
+
+ Promise.prototype.cancellable = function Promise$cancellable() {
+ if (this._cancellable()) return this;
+ this._setCancellable();
+ this._cancellationParent = void 0;
+ return this;
+ };
+
+ Promise.prototype.uncancellable = function Promise$uncancellable() {
+ var ret = new Promise(INTERNAL);
+ ret._setTrace(this.uncancellable, this);
+ ret._follow(this);
+ ret._unsetCancellable();
+ if (this._isBound()) ret._setBoundTo(this._boundTo);
+ return ret;
+ };
+
+ Promise.prototype.fork =
+ function Promise$fork(didFulfill, didReject, didProgress) {
+ var ret = this._then(didFulfill, didReject, didProgress,
+ void 0, void 0, this.fork);
+
+ ret._setCancellable();
+ ret._cancellationParent = void 0;
+ return ret;
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/captured_trace.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/captured_trace.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/captured_trace.js
new file mode 100644
index 0000000..af34f11
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/captured_trace.js
@@ -0,0 +1,237 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function() {
+var inherits = require("./util.js").inherits;
+var defineProperty = require("./es5.js").defineProperty;
+
+var rignore = new RegExp(
+ "\\b(?:[\\w.]*Promise(?:Array|Spawn)?\\$_\\w+|" +
+ "tryCatch(?:1|2|Apply)|new \\w*PromiseArray|" +
+ "\\w*PromiseArray\\.\\w*PromiseArray|" +
+ "setTimeout|CatchFilter\\$_\\w+|makeNodePromisified|processImmediate|" +
+ "process._tickCallback|nextTick|Async\\$\\w+)\\b"
+);
+
+var rtraceline = null;
+var formatStack = null;
+var areNamesMangled = false;
+
+function formatNonError(obj) {
+ var str;
+ if (typeof obj === "function") {
+ str = "[function " +
+ (obj.name || "anonymous") +
+ "]";
+ }
+ else {
+ str = obj.toString();
+ var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
+ if (ruselessToString.test(str)) {
+ try {
+ var newStr = JSON.stringify(obj);
+ str = newStr;
+ }
+ catch(e) {
+
+ }
+ }
+ if (str.length === 0) {
+ str = "(empty array)";
+ }
+ }
+ return ("(<" + snip(str) + ">, no stack trace)");
+}
+
+function snip(str) {
+ var maxChars = 41;
+ if (str.length < maxChars) {
+ return str;
+ }
+ return str.substr(0, maxChars - 3) + "...";
+}
+
+function CapturedTrace(ignoreUntil, isTopLevel) {
+ if (!areNamesMangled) {
+ }
+ this.captureStackTrace(ignoreUntil, isTopLevel);
+
+}
+inherits(CapturedTrace, Error);
+
+CapturedTrace.prototype.captureStackTrace =
+function CapturedTrace$captureStackTrace(ignoreUntil, isTopLevel) {
+ captureStackTrace(this, ignoreUntil, isTopLevel);
+};
+
+CapturedTrace.possiblyUnhandledRejection =
+function CapturedTrace$PossiblyUnhandledRejection(reason) {
+ if (typeof console === "object") {
+ var message;
+ if (typeof reason === "object" || typeof reason === "function") {
+ var stack = reason.stack;
+ message = "Possibly unhandled " + formatStack(stack, reason);
+ }
+ else {
+ message = "Possibly unhandled " + String(reason);
+ }
+ if (typeof console.error === "function" ||
+ typeof console.error === "object") {
+ console.error(message);
+ }
+ else if (typeof console.log === "function" ||
+ typeof console.error === "object") {
+ console.log(message);
+ }
+ }
+};
+
+areNamesMangled = CapturedTrace.prototype.captureStackTrace.name !==
+ "CapturedTrace$captureStackTrace";
+
+CapturedTrace.combine = function CapturedTrace$Combine(current, prev) {
+ var curLast = current.length - 1;
+ for (var i = prev.length - 1; i >= 0; --i) {
+ var line = prev[i];
+ if (current[curLast] === line) {
+ current.pop();
+ curLast--;
+ }
+ else {
+ break;
+ }
+ }
+
+ current.push("From previous event:");
+ var lines = current.concat(prev);
+
+ var ret = [];
+
+
+ for (var i = 0, len = lines.length; i < len; ++i) {
+
+ if ((rignore.test(lines[i]) ||
+ (i > 0 && !rtraceline.test(lines[i])) &&
+ lines[i] !== "From previous event:")
+ ) {
+ continue;
+ }
+ ret.push(lines[i]);
+ }
+ return ret;
+};
+
+CapturedTrace.isSupported = function CapturedTrace$IsSupported() {
+ return typeof captureStackTrace === "function";
+};
+
+var captureStackTrace = (function stackDetection() {
+ if (typeof Error.stackTraceLimit === "number" &&
+ typeof Error.captureStackTrace === "function") {
+ rtraceline = /^\s*at\s*/;
+ formatStack = function(stack, error) {
+ if (typeof stack === "string") return stack;
+
+ if (error.name !== void 0 &&
+ error.message !== void 0) {
+ return error.name + ". " + error.message;
+ }
+ return formatNonError(error);
+
+
+ };
+ var captureStackTrace = Error.captureStackTrace;
+ return function CapturedTrace$_captureStackTrace(
+ receiver, ignoreUntil) {
+ captureStackTrace(receiver, ignoreUntil);
+ };
+ }
+ var err = new Error();
+
+ if (!areNamesMangled && typeof err.stack === "string" &&
+ typeof "".startsWith === "function" &&
+ (err.stack.startsWith("stackDetection@")) &&
+ stackDetection.name === "stackDetection") {
+
+ defineProperty(Error, "stackTraceLimit", {
+ writable: true,
+ enumerable: false,
+ configurable: false,
+ value: 25
+ });
+ rtraceline = /@/;
+ var rline = /[@\n]/;
+
+ formatStack = function(stack, error) {
+ if (typeof stack === "string") {
+ return (error.name + ". " + error.message + "\n" + stack);
+ }
+
+ if (error.name !== void 0 &&
+ error.message !== void 0) {
+ return error.name + ". " + error.message;
+ }
+ return formatNonError(error);
+ };
+
+ return function captureStackTrace(o, fn) {
+ var name = fn.name;
+ var stack = new Error().stack;
+ var split = stack.split(rline);
+ var i, len = split.length;
+ for (i = 0; i < len; i += 2) {
+ if (split[i] === name) {
+ break;
+ }
+ }
+ split = split.slice(i + 2);
+ len = split.length - 2;
+ var ret = "";
+ for (i = 0; i < len; i += 2) {
+ ret += split[i];
+ ret += "@";
+ ret += split[i + 1];
+ ret += "\n";
+ }
+ o.stack = ret;
+ };
+ }
+ else {
+ formatStack = function(stack, error) {
+ if (typeof stack === "string") return stack;
+
+ if ((typeof error === "object" ||
+ typeof error === "function") &&
+ error.name !== void 0 &&
+ error.message !== void 0) {
+ return error.name + ". " + error.message;
+ }
+ return formatNonError(error);
+ };
+
+ return null;
+ }
+})();
+
+return CapturedTrace;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/catch_filter.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/catch_filter.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/catch_filter.js
new file mode 100644
index 0000000..8b42af1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/catch_filter.js
@@ -0,0 +1,93 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(NEXT_FILTER) {
+var util = require("./util.js");
+var errors = require("./errors.js");
+var tryCatch1 = util.tryCatch1;
+var errorObj = util.errorObj;
+var keys = require("./es5.js").keys;
+
+function CatchFilter(instances, callback, promise) {
+ this._instances = instances;
+ this._callback = callback;
+ this._promise = promise;
+}
+
+function CatchFilter$_safePredicate(predicate, e) {
+ var safeObject = {};
+ var retfilter = tryCatch1(predicate, safeObject, e);
+
+ if (retfilter === errorObj) return retfilter;
+
+ var safeKeys = keys(safeObject);
+ if (safeKeys.length) {
+ errorObj.e = new TypeError(
+ "Catch filter must inherit from Error "
+ + "or be a simple predicate function");
+ return errorObj;
+ }
+ return retfilter;
+}
+
+CatchFilter.prototype.doFilter = function CatchFilter$_doFilter(e) {
+ var cb = this._callback;
+ var promise = this._promise;
+ var boundTo = promise._isBound() ? promise._boundTo : void 0;
+ for (var i = 0, len = this._instances.length; i < len; ++i) {
+ var item = this._instances[i];
+ var itemIsErrorType = item === Error ||
+ (item != null && item.prototype instanceof Error);
+
+ if (itemIsErrorType && e instanceof item) {
+ var ret = tryCatch1(cb, boundTo, e);
+ if (ret === errorObj) {
+ NEXT_FILTER.e = ret.e;
+ return NEXT_FILTER;
+ }
+ return ret;
+ } else if (typeof item === "function" && !itemIsErrorType) {
+ var shouldHandle = CatchFilter$_safePredicate(item, e);
+ if (shouldHandle === errorObj) {
+ var trace = errors.canAttach(errorObj.e)
+ ? errorObj.e
+ : new Error(errorObj.e + "");
+ this._promise._attachExtraTrace(trace);
+ e = errorObj.e;
+ break;
+ } else if (shouldHandle) {
+ var ret = tryCatch1(cb, boundTo, e);
+ if (ret === errorObj) {
+ NEXT_FILTER.e = ret.e;
+ return NEXT_FILTER;
+ }
+ return ret;
+ }
+ }
+ }
+ NEXT_FILTER.e = e;
+ return NEXT_FILTER;
+};
+
+return CatchFilter;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/direct_resolve.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/direct_resolve.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/direct_resolve.js
new file mode 100644
index 0000000..f4d5384
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/direct_resolve.js
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var util = require("./util.js");
+var isPrimitive = util.isPrimitive;
+var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;
+
+module.exports = function(Promise) {
+var returner = function Promise$_returner() {
+ return this;
+};
+var thrower = function Promise$_thrower() {
+ throw this;
+};
+
+var wrapper = function Promise$_wrapper(value, action) {
+ if (action === 1) {
+ return function Promise$_thrower() {
+ throw value;
+ };
+ }
+ else if (action === 2) {
+ return function Promise$_returner() {
+ return value;
+ };
+ }
+};
+
+
+Promise.prototype["return"] =
+Promise.prototype.thenReturn =
+function Promise$thenReturn(value) {
+ if (wrapsPrimitiveReceiver && isPrimitive(value)) {
+ return this._then(
+ wrapper(value, 2),
+ void 0,
+ void 0,
+ void 0,
+ void 0,
+ this.thenReturn
+ );
+ }
+ return this._then(returner, void 0, void 0,
+ value, void 0, this.thenReturn);
+};
+
+Promise.prototype["throw"] =
+Promise.prototype.thenThrow =
+function Promise$thenThrow(reason) {
+ if (wrapsPrimitiveReceiver && isPrimitive(reason)) {
+ return this._then(
+ wrapper(reason, 1),
+ void 0,
+ void 0,
+ void 0,
+ void 0,
+ this.thenThrow
+ );
+ }
+ return this._then(thrower, void 0, void 0,
+ reason, void 0, this.thenThrow);
+};
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/errors.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/errors.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/errors.js
new file mode 100644
index 0000000..35fb66e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/errors.js
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var global = require("./global.js");
+var Objectfreeze = require("./es5.js").freeze;
+var util = require("./util.js");
+var inherits = util.inherits;
+var notEnumerableProp = util.notEnumerableProp;
+var Error = global.Error;
+
+function markAsOriginatingFromRejection(e) {
+ try {
+ notEnumerableProp(e, "isAsync", true);
+ }
+ catch(ignore) {}
+}
+
+function originatesFromRejection(e) {
+ if (e == null) return false;
+ return ((e instanceof RejectionError) ||
+ e["isAsync"] === true);
+}
+
+function isError(obj) {
+ return obj instanceof Error;
+}
+
+function canAttach(obj) {
+ return isError(obj);
+}
+
+function subError(nameProperty, defaultMessage) {
+ function SubError(message) {
+ if (!(this instanceof SubError)) return new SubError(message);
+ this.message = typeof message === "string" ? message : defaultMessage;
+ this.name = nameProperty;
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+ }
+ inherits(SubError, Error);
+ return SubError;
+}
+
+var TypeError = global.TypeError;
+if (typeof TypeError !== "function") {
+ TypeError = subError("TypeError", "type error");
+}
+var RangeError = global.RangeError;
+if (typeof RangeError !== "function") {
+ RangeError = subError("RangeError", "range error");
+}
+var CancellationError = subError("CancellationError", "cancellation error");
+var TimeoutError = subError("TimeoutError", "timeout error");
+
+function RejectionError(message) {
+ this.name = "RejectionError";
+ this.message = message;
+ this.cause = message;
+ this.isAsync = true;
+
+ if (message instanceof Error) {
+ this.message = message.message;
+ this.stack = message.stack;
+ }
+ else if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
+}
+inherits(RejectionError, Error);
+
+var key = "__BluebirdErrorTypes__";
+var errorTypes = global[key];
+if (!errorTypes) {
+ errorTypes = Objectfreeze({
+ CancellationError: CancellationError,
+ TimeoutError: TimeoutError,
+ RejectionError: RejectionError
+ });
+ notEnumerableProp(global, key, errorTypes);
+}
+
+module.exports = {
+ Error: Error,
+ TypeError: TypeError,
+ RangeError: RangeError,
+ CancellationError: errorTypes.CancellationError,
+ RejectionError: errorTypes.RejectionError,
+ TimeoutError: errorTypes.TimeoutError,
+ originatesFromRejection: originatesFromRejection,
+ markAsOriginatingFromRejection: markAsOriginatingFromRejection,
+ canAttach: canAttach
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/errors_api_rejection.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/errors_api_rejection.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/errors_api_rejection.js
new file mode 100644
index 0000000..e953e3b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/errors_api_rejection.js
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+var TypeError = require('./errors.js').TypeError;
+
+function apiRejection(msg) {
+ var error = new TypeError(msg);
+ var ret = Promise.rejected(error);
+ var parent = ret._peekContext();
+ if (parent != null) {
+ parent._attachExtraTrace(error);
+ }
+ return ret;
+}
+
+return apiRejection;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/es5.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/es5.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/es5.js
new file mode 100644
index 0000000..e22a0a9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/es5.js
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+var isES5 = (function(){
+ "use strict";
+ return this === void 0;
+})();
+
+if (isES5) {
+ module.exports = {
+ freeze: Object.freeze,
+ defineProperty: Object.defineProperty,
+ keys: Object.keys,
+ getPrototypeOf: Object.getPrototypeOf,
+ isArray: Array.isArray,
+ isES5: isES5
+ };
+}
+
+else {
+ var has = {}.hasOwnProperty;
+ var str = {}.toString;
+ var proto = {}.constructor.prototype;
+
+ function ObjectKeys(o) {
+ var ret = [];
+ for (var key in o) {
+ if (has.call(o, key)) {
+ ret.push(key);
+ }
+ }
+ return ret;
+ }
+
+ function ObjectDefineProperty(o, key, desc) {
+ o[key] = desc.value;
+ return o;
+ }
+
+ function ObjectFreeze(obj) {
+ return obj;
+ }
+
+ function ObjectGetPrototypeOf(obj) {
+ try {
+ return Object(obj).constructor.prototype;
+ }
+ catch (e) {
+ return proto;
+ }
+ }
+
+ function ArrayIsArray(obj) {
+ try {
+ return str.call(obj) === "[object Array]";
+ }
+ catch(e) {
+ return false;
+ }
+ }
+
+ module.exports = {
+ isArray: ArrayIsArray,
+ keys: ObjectKeys,
+ defineProperty: ObjectDefineProperty,
+ freeze: ObjectFreeze,
+ getPrototypeOf: ObjectGetPrototypeOf,
+ isES5: isES5
+ };
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[28/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/socket.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/socket.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/socket.js
new file mode 100644
index 0000000..67fa54f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tcpusb/socket.js
@@ -0,0 +1,391 @@
+(function() {
+ var Auth, EventEmitter, Forge, Parser, Promise, Protocol, RollingCounter, ServiceMap, Socket, crypto, debug,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ crypto = require('crypto');
+
+ EventEmitter = require('events').EventEmitter;
+
+ Promise = require('bluebird');
+
+ Forge = require('node-forge');
+
+ debug = require('debug')('adb:tcpusb:socket');
+
+ Parser = require('../parser');
+
+ Protocol = require('../protocol');
+
+ Auth = require('../auth');
+
+ ServiceMap = require('./servicemap');
+
+ RollingCounter = require('./rollingcounter');
+
+ Socket = (function(_super) {
+ var AUTH_RSAPUBLICKEY, AUTH_SIGNATURE, AUTH_TOKEN, A_AUTH, A_CLSE, A_CNXN, A_OKAY, A_OPEN, A_SYNC, A_WRTE, TOKEN_LENGTH, UINT32_MAX;
+
+ __extends(Socket, _super);
+
+ A_SYNC = 0x434e5953;
+
+ A_CNXN = 0x4e584e43;
+
+ A_OPEN = 0x4e45504f;
+
+ A_OKAY = 0x59414b4f;
+
+ A_CLSE = 0x45534c43;
+
+ A_WRTE = 0x45545257;
+
+ A_AUTH = 0x48545541;
+
+ UINT32_MAX = 0xFFFFFFFF;
+
+ AUTH_TOKEN = 1;
+
+ AUTH_SIGNATURE = 2;
+
+ AUTH_RSAPUBLICKEY = 3;
+
+ TOKEN_LENGTH = 20;
+
+ function Socket(client, serial, socket, options) {
+ var _base;
+ this.client = client;
+ this.serial = serial;
+ this.socket = socket;
+ this.options = options != null ? options : {};
+ (_base = this.options).auth || (_base.auth = Promise.resolve(true));
+ this.ended = false;
+ this.parser = new Parser(this.socket);
+ this.version = 1;
+ this.maxPayload = 4096;
+ this.authorized = false;
+ this.syncToken = new RollingCounter(UINT32_MAX);
+ this.remoteId = new RollingCounter(UINT32_MAX);
+ this.services = new ServiceMap;
+ this.remoteAddress = this.socket.remoteAddress;
+ this.token = null;
+ this.signature = null;
+ this._inputLoop();
+ }
+
+ Socket.prototype.end = function() {
+ if (!this.ended) {
+ this.socket.end();
+ this.services.end();
+ this.emit('end');
+ this.ended = true;
+ }
+ return this;
+ };
+
+ Socket.prototype._inputLoop = function() {
+ return this._readMessage().then((function(_this) {
+ return function(message) {
+ return _this._route(message);
+ };
+ })(this)).then((function(_this) {
+ return function() {
+ return setImmediate(_this._inputLoop.bind(_this));
+ };
+ })(this))["catch"](Parser.PrematureEOFError, (function(_this) {
+ return function() {
+ return _this.end();
+ };
+ })(this))["catch"]((function(_this) {
+ return function(err) {
+ debug("Error: " + err.message);
+ _this.emit('error', err);
+ return _this.end();
+ };
+ })(this));
+ };
+
+ Socket.prototype._readMessage = function() {
+ return this.parser.readBytes(24).then(function(header) {
+ return {
+ command: header.readUInt32LE(0),
+ arg0: header.readUInt32LE(4),
+ arg1: header.readUInt32LE(8),
+ length: header.readUInt32LE(12),
+ check: header.readUInt32LE(16),
+ magic: header.readUInt32LE(20)
+ };
+ }).then((function(_this) {
+ return function(message) {
+ return _this.parser.readBytes(message.length).then(function(data) {
+ message.data = data;
+ return message;
+ });
+ };
+ })(this)).then((function(_this) {
+ return function(message) {
+ return _this._validateMessage(message);
+ };
+ })(this));
+ };
+
+ Socket.prototype._route = function(message) {
+ if (this.ended) {
+ return;
+ }
+ this.emit('userActivity', message);
+ switch (message.command) {
+ case A_SYNC:
+ return this._handleSyncMessage(message);
+ case A_CNXN:
+ return this._handleConnectionMessage(message);
+ case A_OPEN:
+ return this._handleOpenMessage(message);
+ case A_OKAY:
+ return this._handleOkayMessage(message);
+ case A_CLSE:
+ return this._handleCloseMessage(message);
+ case A_WRTE:
+ return this._handleWriteMessage(message);
+ case A_AUTH:
+ return this._handleAuthMessage(message);
+ default:
+ return this.emit('error', new Error("Unknown command " + message.command));
+ }
+ };
+
+ Socket.prototype._handleSyncMessage = function(message) {
+ return this._writeHeader(A_SYNC, 1, this.syncToken.next(), 0);
+ };
+
+ Socket.prototype._handleConnectionMessage = function(message) {
+ debug('A_CNXN', message);
+ return this._createToken().then((function(_this) {
+ return function(token) {
+ _this.token = token;
+ return _this._writeMessage(A_AUTH, AUTH_TOKEN, 0, _this.token);
+ };
+ })(this));
+ };
+
+ Socket.prototype._handleAuthMessage = function(message) {
+ debug('A_AUTH', message);
+ switch (message.arg0) {
+ case AUTH_SIGNATURE:
+ if (!this.signature) {
+ this.signature = message.data;
+ }
+ return this._writeMessage(A_AUTH, AUTH_TOKEN, 0, this.token);
+ case AUTH_RSAPUBLICKEY:
+ return Auth.parsePublicKey(message.data.slice(0, -1)).then((function(_this) {
+ return function(key) {
+ var digest, sig;
+ digest = _this.token.toString('binary');
+ sig = _this.signature.toString('binary');
+ if (key.verify(digest, sig)) {
+ return _this.options.auth(key).then(function() {
+ return _this._deviceId().then(function(id) {
+ _this.authorized = true;
+ return _this._writeMessage(A_CNXN, _this.version, _this.maxPayload, "device::" + id);
+ });
+ })["catch"](function(err) {
+ return _this.end();
+ });
+ } else {
+ return _this.end();
+ }
+ };
+ })(this));
+ default:
+ return this.end();
+ }
+ };
+
+ Socket.prototype._handleOpenMessage = function(message) {
+ var command, localId, remoteId, service;
+ if (!this.authorized) {
+ return;
+ }
+ debug('A_OPEN', message);
+ localId = message.arg0;
+ remoteId = this.remoteId.next();
+ service = message.data.slice(0, -1);
+ command = service.toString().split(':', 1)[0];
+ return this.client.transport(this.serial).then((function(_this) {
+ return function(transport) {
+ var parser, pump;
+ if (_this.ended) {
+ return;
+ }
+ debug("Calling " + service);
+ _this.services.put(remoteId, transport);
+ transport.write(Protocol.encodeData(service));
+ parser = transport.parser;
+ pump = function() {
+ return new Promise(function(resolve, reject) {
+ var maybeRead, out;
+ out = parser.raw();
+ maybeRead = function() {
+ var chunk, _results;
+ _results = [];
+ while (chunk = _this._readChunk(out)) {
+ _results.push(_this._writeMessage(A_WRTE, remoteId, localId, chunk));
+ }
+ return _results;
+ };
+ out.on('readable', maybeRead);
+ return out.on('end', resolve);
+ });
+ };
+ parser.readAscii(4).then(function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ _this._writeHeader(A_OKAY, remoteId, localId);
+ return pump();
+ case Protocol.FAIL:
+ return parser.readError();
+ default:
+ return parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ })["catch"](Parser.PrematureEOFError, function() {
+ return true;
+ })["finally"](function() {
+ return _this._close(remoteId, localId);
+ })["catch"](Parser.FailError, function(err) {
+ debug("Unable to open transport: " + err);
+ return _this.end();
+ });
+ };
+ })(this));
+ };
+
+ Socket.prototype._handleOkayMessage = function(message) {
+ var localId, remoteId;
+ if (!this.authorized) {
+ return;
+ }
+ debug('A_OKAY', message);
+ localId = message.arg0;
+ return remoteId = message.arg1;
+ };
+
+ Socket.prototype._handleCloseMessage = function(message) {
+ var localId, remoteId;
+ if (!this.authorized) {
+ return;
+ }
+ debug('A_CLSE', message);
+ localId = message.arg0;
+ remoteId = message.arg1;
+ return this._close(remoteId, localId);
+ };
+
+ Socket.prototype._handleWriteMessage = function(message) {
+ var localId, remote, remoteId;
+ if (!this.authorized) {
+ return;
+ }
+ debug('A_WRTE', message);
+ localId = message.arg0;
+ remoteId = message.arg1;
+ if (remote = this.services.get(remoteId)) {
+ remote.write(message.data);
+ this._writeHeader(A_OKAY, remoteId, localId);
+ } else {
+ debug("A_WRTE to unknown socket pair " + localId + "/" + remoteId);
+ }
+ return true;
+ };
+
+ Socket.prototype._close = function(remoteId, localId) {
+ var remote;
+ if (remote = this.services.remove(remoteId)) {
+ remote.end();
+ return this._writeHeader(A_CLSE, remoteId, localId);
+ }
+ };
+
+ Socket.prototype._writeHeader = function(command, arg0, arg1, length, checksum) {
+ var header;
+ if (this.ended) {
+ return;
+ }
+ header = new Buffer(24);
+ header.writeUInt32LE(command, 0);
+ header.writeUInt32LE(arg0 || 0, 4);
+ header.writeUInt32LE(arg1 || 0, 8);
+ header.writeUInt32LE(length || 0, 12);
+ header.writeUInt32LE(checksum || 0, 16);
+ header.writeUInt32LE(this._magic(command), 20);
+ return this.socket.write(header);
+ };
+
+ Socket.prototype._writeMessage = function(command, arg0, arg1, data) {
+ if (this.ended) {
+ return;
+ }
+ if (!Buffer.isBuffer(data)) {
+ data = new Buffer(data);
+ }
+ this._writeHeader(command, arg0, arg1, data.length, this._checksum(data));
+ return this.socket.write(data);
+ };
+
+ Socket.prototype._validateMessage = function(message) {
+ if (message.magic !== this._magic(message.command)) {
+ throw new Error("Command failed magic check");
+ }
+ if (message.check !== this._checksum(message.data)) {
+ throw new Error("Message checksum doesn't match received message");
+ }
+ return message;
+ };
+
+ Socket.prototype._readChunk = function(stream) {
+ return stream.read(this.maxPayload) || stream.read();
+ };
+
+ Socket.prototype._checksum = function(data) {
+ var char, sum, _i, _len;
+ if (!Buffer.isBuffer(data)) {
+ throw new Error("Unable to calculate checksum of non-Buffer");
+ }
+ sum = 0;
+ for (_i = 0, _len = data.length; _i < _len; _i++) {
+ char = data[_i];
+ sum += char;
+ }
+ return sum;
+ };
+
+ Socket.prototype._magic = function(command) {
+ return (command ^ 0xffffffff) >>> 0;
+ };
+
+ Socket.prototype._createToken = function() {
+ return Promise.promisify(crypto.randomBytes)(TOKEN_LENGTH);
+ };
+
+ Socket.prototype._deviceId = function() {
+ return this.client.getProperties(this.serial).then(function(properties) {
+ var prop;
+ return ((function() {
+ var _i, _len, _ref, _results;
+ _ref = ['ro.product.name', 'ro.product.model', 'ro.product.device'];
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ prop = _ref[_i];
+ _results.push("" + prop + "=" + properties[prop] + ";");
+ }
+ return _results;
+ })()).join('');
+ });
+ };
+
+ return Socket;
+
+ })(EventEmitter);
+
+ module.exports = Socket;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tracker.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tracker.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tracker.js
new file mode 100644
index 0000000..ca96230
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/tracker.js
@@ -0,0 +1,92 @@
+(function() {
+ var EventEmitter, Parser, Promise, Tracker,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ EventEmitter = require('events').EventEmitter;
+
+ Promise = require('bluebird');
+
+ Parser = require('./parser');
+
+ Tracker = (function(_super) {
+ __extends(Tracker, _super);
+
+ function Tracker(command) {
+ this.command = command;
+ this.deviceList = [];
+ this.deviceMap = {};
+ this.reader = this.read()["catch"](Parser.PrematureEOFError, (function(_this) {
+ return function(err) {
+ return _this.emit('end');
+ };
+ })(this))["catch"](Promise.CancellationError, (function(_this) {
+ return function(err) {
+ _this.command.connection.end();
+ return _this.emit('end');
+ };
+ })(this))["catch"]((function(_this) {
+ return function(err) {
+ _this.emit('error', err);
+ return _this.emit('end');
+ };
+ })(this));
+ }
+
+ Tracker.prototype.read = function() {
+ return this.command._readDevices().cancellable().then((function(_this) {
+ return function(list) {
+ _this.update(list);
+ return _this.read();
+ };
+ })(this));
+ };
+
+ Tracker.prototype.update = function(newList) {
+ var changeSet, device, newMap, oldDevice, _i, _j, _len, _len1, _ref;
+ changeSet = {
+ removed: [],
+ changed: [],
+ added: []
+ };
+ newMap = {};
+ for (_i = 0, _len = newList.length; _i < _len; _i++) {
+ device = newList[_i];
+ oldDevice = this.deviceMap[device.id];
+ if (oldDevice) {
+ if (oldDevice.type !== device.type) {
+ changeSet.changed.push(device);
+ this.emit('change', device, oldDevice);
+ }
+ } else {
+ changeSet.added.push(device);
+ this.emit('add', device);
+ }
+ newMap[device.id] = device;
+ }
+ _ref = this.deviceList;
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
+ device = _ref[_j];
+ if (!newMap[device.id]) {
+ changeSet.removed.push(device);
+ this.emit('remove', device);
+ }
+ }
+ this.emit('changeSet', changeSet);
+ this.deviceList = newList;
+ this.deviceMap = newMap;
+ return this;
+ };
+
+ Tracker.prototype.end = function() {
+ this.reader.cancel();
+ return this;
+ };
+
+ return Tracker;
+
+ })(EventEmitter);
+
+ module.exports = Tracker;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/util.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/util.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/util.js
new file mode 100644
index 0000000..8207028
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/util.js
@@ -0,0 +1,16 @@
+(function() {
+ var Auth, Parser;
+
+ Parser = require('./parser');
+
+ Auth = require('./auth');
+
+ module.exports.readAll = function(stream, callback) {
+ return new Parser(stream).readAll(stream).nodeify(callback);
+ };
+
+ module.exports.parsePublicKey = function(keyString, callback) {
+ return Auth.parsePublicKey(keyString).nodeify(callback);
+ };
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/cli.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/cli.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/cli.js
new file mode 100644
index 0000000..11dc9cf
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/cli.js
@@ -0,0 +1,42 @@
+(function() {
+ var Auth, Promise, forge, fs, pkg, program;
+
+ fs = require('fs');
+
+ program = require('commander');
+
+ Promise = require('bluebird');
+
+ forge = require('node-forge');
+
+ pkg = require('../package');
+
+ Auth = require('./adb/auth');
+
+ Promise.longStackTraces();
+
+ program.version(pkg.version);
+
+ program.command('pubkey-convert <file>').option('-f, --format <format>', 'format (pem or openssh)', String, 'pem').description('Converts an ADB-generated public key into PEM format.').action(function(file, options) {
+ return Auth.parsePublicKey(fs.readFileSync(file)).then(function(key) {
+ switch (options.format.toLowerCase()) {
+ case 'pem':
+ return console.log(forge.pki.publicKeyToPem(key).trim());
+ case 'openssh':
+ return console.log(forge.ssh.publicKeyToOpenSSH(key, 'adbkey').trim());
+ default:
+ console.error("Unsupported format '" + options.format + "'");
+ return process.exit(1);
+ }
+ });
+ });
+
+ program.command('pubkey-fingerprint <file>').description('Outputs the fingerprint of an ADB-generated public key.').action(function(file) {
+ return Auth.parsePublicKey(fs.readFileSync(file)).then(function(key) {
+ return console.log('%s %s', key.fingerprint, key.comment);
+ });
+ });
+
+ program.parse(process.argv);
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/LICENSE b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/LICENSE
new file mode 100644
index 0000000..2ffff3d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/LICENSE
@@ -0,0 +1,13 @@
+Copyright © CyberAgent, Inc. All Rights Reserved.
+
+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.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/README.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/README.md
new file mode 100644
index 0000000..df54e35
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/README.md
@@ -0,0 +1,240 @@
+# adbkit-logcat
+
+**adbkit-logcat** provides a [Node.js][nodejs] interface for working with output produced by the Android [`logcat` tool][logcat-site]. It takes a log stream (that you must create separately), parses it, and emits log entries in real-time as they occur. Possible use cases include storing logs in a database, forwarding logs via [MessagePack][msgpack], or just advanced filtering.
+
+## Getting started
+
+Install via NPM:
+
+```bash
+npm install --save adbkit-logcat
+```
+
+Note that while adbkit-logcat is written in CoffeeScript, it is compiled to JavaScript before publishing to NPM, which means that you are not required to use CoffeeScript.
+
+### Examples
+
+#### Output all log messages
+
+##### JavaScript
+
+```javascript
+var logcat = require('adbkit-logcat');
+var spawn = require('child_process').spawn;
+
+// Retrieve a binary log stream
+var proc = spawn('adb', ['logcat', '-B']);
+
+// Connect logcat to the stream
+reader = logcat.readStream(proc.stdout);
+reader.on('entry', function(entry) {
+ console.log(entry.message);
+});
+
+// Make sure we don't leave anything hanging
+process.on('exit', function() {
+ proc.kill();
+});
+```
+
+##### CoffeeScript
+
+```coffeescript
+Logcat = require 'adbkit-logcat'
+{spawn} = require 'child_process'
+
+# Retrieve a binary log stream
+proc = spawn 'adb', ['logcat', '-B']
+
+# Connect logcat to the stream
+reader = Logcat.readStream proc.stdout
+reader.on 'entry', (entry) ->
+ console.log entry.message
+
+# Make sure we don't leave anything hanging
+process.on 'exit', ->
+ proc.kill()
+```
+
+## API
+
+### Logcat
+
+#### logcat.Priority
+
+Exposes `Priority`. See below for details.
+
+#### logcat.Reader
+
+Exposes `Reader`. See below for details.
+
+#### logcat.readStream(stream[, options])
+
+Creates a logcat reader instance from the provided logcat event [`Stream`][node-stream]. Note that you must create the stream separately.
+
+* **stream** The event stream to read.
+* **options** Optional. The following options are supported:
+ - **format** The format of the stream. Currently, the only supported value is `'binary'`, which (for example) `adb logcat -B` produces. Defaults to `'binary'`.
+ - **fixLineFeeds** All programs run via the ADB shell transform any `'\n'` in the output to `'\r\n'`, which breaks binary content. If set, this option reverses the transformation before parsing the stream. Defaults to `true`.
+* Returns: The `Reader` instance.
+
+### Priority
+
+#### Constants
+
+The following static properties are available:
+
+* **Priority.UNKNOWN** i.e. `0`.
+* **Priority.DEFAULT** i.e. `1`. Not available when reading a stream.
+* **Priority.VERBOSE** i.e. `2`.
+* **Priority.DEBUG** i.e. `3`.
+* **Priority.INFO** i.e. `4`.
+* **Priority.WARN** i.e. `5`.
+* **Priority.ERROR** i.e. `6`.
+* **Priority.FATAL** i.e. `7`.
+* **Priority.SILENT** i.e. `8`. Not available when reading a stream.
+
+#### Priority.fromLetter(letter)
+
+Static method to convert the given `letter` into a numeric priority. For example, `Priority.fromName('d')` would return `Priority.DEBUG`.
+
+* **letter** The priority as a `String`. Any single, case-insensitive character matching the first character of any `Priority` constant is accepted.
+* Returns: The priority as a `Number`, or `undefined`.
+
+#### Priority.fromName(name)
+
+Static method to convert the given `name` into a numeric priority. For example, `Priority.fromName('debug')` (or `Priority.fromName('d')`) would return `Priority.DEBUG`.
+
+* **name** The priority as a `String`. Any full, case-insensitive match of the `Priority` constants is accepted. If no match is found, falls back to `Priority.fromLetter()`.
+* Returns: The priority as a `Number`, or `undefined`.
+
+#### Priority.toLetter(priority)
+
+Static method to convert the numeric priority into its letter representation. For example, `Priority.toLetter(Priority.DEBUG)` would return `'D'`.
+
+* **priority** The priority as a `Number`. Any `Priority` constant value is accepted.
+* Returns: The priority as a `String` letter, or `undefined`.
+
+#### Priority.toName(priority)
+
+Static method to convert the numeric priority into its full string representation. For example, `Priority.toLetter(Priority.DEBUG)` would return `'DEBUG'`.
+
+* **priority** The priority as a `Number`. Any `Priority` constant value is accepted.
+* Returns: The priority as a `String`, or `undefined`.
+
+### Reader
+
+A reader instance, which is an [`EventEmitter`][node-events].
+
+#### Events
+
+The following events are available:
+
+* **error** **(err)** Emitted when an error occurs.
+ * **err** An `Error`.
+* **end** Emitted when the stream ends.
+* **finish** Emitted when the stream finishes.
+* **entry** **(entry)** Emitted when the stream finishes.
+ * **entry** A log `Entry`. See below for details.
+
+#### constructor([options])
+
+For advanced users. Manually constructs a `Reader` instance. Useful for testing and/or playing around. Normally you would use `logcat.readStream()` to create the instance.
+
+* **options** See `logcat.readStream()` for details.
+* Returns: N/A
+
+#### reader.connect(stream)
+
+For advanced users. When instantiated manually (not via `logcat.readStream()`), connects the `Reader` instance to the given stream.
+
+* **stream** See `logcat.readStream()` for details.
+* Returns: The `Reader` instance.
+
+#### reader.end()
+
+Convenience method for ending the stream.
+
+* Returns: The `Reader` instance.
+
+#### reader.exclude(tag)
+
+Skip entries with the provided tag. Alias for `reader.include(tag, Priority.SILENT)`. Note that even skipped events have to be parsed so that they can be ignored.
+
+* **tag** The tag string to exclude. If `'*'`, works the same as `reader.excludeAll()`.
+* Returns: The `Reader` instance.
+
+#### reader.excludeAll()
+
+Skip **ALL** entries. Alias for `reader.includeAll(Priority.SILENT)`. Any entries you wish to see must be included via `include()`/`includeAll()`.
+
+* Returns: The `Reader` instance.
+
+#### reader.include(tag[, priority])
+
+Include all entries with the given tag and a priority higher or equal to the given `priority`.
+
+* **tag** The tag string to include. If `'*'`, works the same as `reader.includeAll(priority)`.
+* **priority** Optional. A lower bound for the priority. Any numeric `Priority` constant or any `String` value accepted by `Priority.fromName()` is accepted. Defaults to `Priority.DEBUG`.
+* Returns: The `Reader` instance.
+
+#### reader.includeAll([priority])
+
+Include all entries with a priority higher or equal to the given `priority`.
+
+* **tag** The tag string to exclude.
+* **priority** Optional. See `reader.include()` for details.
+* Returns: The `Reader` instance.
+
+#### reader.resetFilters()
+
+Resets all inclusions/exclusions.
+
+* Returns: The `Reader` instance.
+
+### Entry
+
+A log entry.
+
+#### Properties
+
+The following properties are available:
+
+* **date** Event time as a `Date`.
+* **pid** Process ID as a `Number`.
+* **tid** Thread ID as a `Number`.
+* **priority** Event priority as a `Number`. You can use `logcat.Priority` to convert the value into a `String`.
+* **tag** Event tag as a `String`.
+* **message** Message as a `String`.
+
+#### entry.toBinary()
+
+Converts the entry back to the binary log format.
+
+* Returns: The binary event as a [`Buffer`][node-buffer].
+
+## More information
+
+* Liblog
+ - [logprint.c][logprint-source]
+* Logcat
+ - [logcat.cpp][logcat-source]
+
+## Contributing
+
+See [CONTRIBUTING.md](CONTRIBUTING.md).
+
+## License
+
+See [LICENSE](LICENSE).
+
+Copyright © CyberAgent, Inc. All Rights Reserved.
+
+[nodejs]: <http://nodejs.org/>
+[msgpack]: <http://msgpack.org/>
+[logcat-site]: <http://developer.android.com/tools/help/logcat.html>
+[logprint-source]: <https://github.com/android/platform_system_core/blob/master/liblog/logprint.c>
+[logcat-source]: <https://github.com/android/platform_system_core/blob/master/logcat/logcat.cpp>
+[node-stream]: <http://nodejs.org/api/stream.html>
+[node-events]: <http://nodejs.org/api/events.html>
+[node-buffer]: <http://nodejs.org/api/buffer.html>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/index.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/index.js
new file mode 100644
index 0000000..607433c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/index.js
@@ -0,0 +1,15 @@
+(function() {
+ var Path;
+
+ Path = require('path');
+
+ module.exports = (function() {
+ switch (Path.extname(__filename)) {
+ case '.coffee':
+ return require('./src/logcat');
+ default:
+ return require('./lib/logcat');
+ }
+ })();
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat.js
new file mode 100644
index 0000000..d224f07
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat.js
@@ -0,0 +1,25 @@
+(function() {
+ var Logcat, Priority, Reader;
+
+ Reader = require('./logcat/reader');
+
+ Priority = require('./logcat/priority');
+
+ Logcat = (function() {
+ function Logcat() {}
+
+ Logcat.readStream = function(stream, options) {
+ return new Reader(options).connect(stream);
+ };
+
+ return Logcat;
+
+ })();
+
+ Logcat.Reader = Reader;
+
+ Logcat.Priority = Priority;
+
+ module.exports = Logcat;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/entry.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/entry.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/entry.js
new file mode 100644
index 0000000..1a7f5d2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/entry.js
@@ -0,0 +1,76 @@
+(function() {
+ var Entry;
+
+ Entry = (function() {
+ function Entry() {
+ this.date = null;
+ this.pid = -1;
+ this.tid = -1;
+ this.priority = null;
+ this.tag = null;
+ this.message = null;
+ }
+
+ Entry.prototype.setDate = function(date) {
+ this.date = date;
+ };
+
+ Entry.prototype.setPid = function(pid) {
+ this.pid = pid;
+ };
+
+ Entry.prototype.setTid = function(tid) {
+ this.tid = tid;
+ };
+
+ Entry.prototype.setPriority = function(priority) {
+ this.priority = priority;
+ };
+
+ Entry.prototype.setTag = function(tag) {
+ this.tag = tag;
+ };
+
+ Entry.prototype.setMessage = function(message) {
+ this.message = message;
+ };
+
+ Entry.prototype.toBinary = function() {
+ var buffer, cursor, length;
+ length = 20;
+ length += 1;
+ length += this.tag.length;
+ length += 1;
+ length += this.message.length;
+ length += 1;
+ buffer = new Buffer(length);
+ cursor = 0;
+ buffer.writeUInt16LE(length - 20, cursor);
+ cursor += 4;
+ buffer.writeInt32LE(this.pid, cursor);
+ cursor += 4;
+ buffer.writeInt32LE(this.tid, cursor);
+ cursor += 4;
+ buffer.writeInt32LE(Math.floor(this.date.getTime() / 1000), cursor);
+ cursor += 4;
+ buffer.writeInt32LE((this.date.getTime() % 1000) * 1000000, cursor);
+ cursor += 4;
+ buffer[cursor] = this.priority;
+ cursor += 1;
+ buffer.write(this.tag, cursor, this.tag.length);
+ cursor += this.tag.length;
+ buffer[cursor] = 0x00;
+ cursor += 1;
+ buffer.write(this.message, cursor, this.message.length);
+ cursor += this.message.length;
+ buffer[cursor] = 0x00;
+ return buffer;
+ };
+
+ return Entry;
+
+ })();
+
+ module.exports = Entry;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/parser.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/parser.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/parser.js
new file mode 100644
index 0000000..e3c2939
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/parser.js
@@ -0,0 +1,32 @@
+(function() {
+ var EventEmitter, Parser, _ref,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ EventEmitter = require('events').EventEmitter;
+
+ Parser = (function(_super) {
+ __extends(Parser, _super);
+
+ function Parser() {
+ _ref = Parser.__super__.constructor.apply(this, arguments);
+ return _ref;
+ }
+
+ Parser.get = function(type) {
+ var parser;
+ parser = require("./parser/" + type);
+ return new parser();
+ };
+
+ Parser.prototype.parse = function() {
+ throw new Error("parse() is unimplemented");
+ };
+
+ return Parser;
+
+ })(EventEmitter);
+
+ module.exports = Parser;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/parser/binary.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/parser/binary.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/parser/binary.js
new file mode 100644
index 0000000..b861ace
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/parser/binary.js
@@ -0,0 +1,78 @@
+(function() {
+ var Binary, Entry, Parser, Priority,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Parser = require('../parser');
+
+ Entry = require('../entry');
+
+ Priority = require('../priority');
+
+ Binary = (function(_super) {
+ var HEADER_LENGTH;
+
+ __extends(Binary, _super);
+
+ HEADER_LENGTH = 20;
+
+ function Binary() {
+ this.buffer = new Buffer('');
+ }
+
+ Binary.prototype.parse = function(chunk) {
+ var cursor, data, entry, length, nsec, sec;
+ this.buffer = Buffer.concat([this.buffer, chunk]);
+ while (this.buffer.length > HEADER_LENGTH) {
+ cursor = 0;
+ length = this.buffer.readUInt16LE(cursor);
+ if (this.buffer.length < HEADER_LENGTH + length) {
+ break;
+ }
+ entry = new Entry;
+ cursor += 4;
+ entry.setPid(this.buffer.readInt32LE(cursor));
+ cursor += 4;
+ entry.setTid(this.buffer.readInt32LE(cursor));
+ cursor += 4;
+ sec = this.buffer.readInt32LE(cursor);
+ cursor += 4;
+ nsec = this.buffer.readInt32LE(cursor);
+ entry.setDate(new Date(sec * 1000 + nsec / 1000000));
+ cursor += 4;
+ data = this.buffer.slice(cursor, cursor + length);
+ cursor += length;
+ this.buffer = this.buffer.slice(cursor);
+ this._processEntry(entry, data);
+ }
+ if (this.buffer.length) {
+ this.emit('wait');
+ } else {
+ this.emit('drain');
+ }
+ };
+
+ Binary.prototype._processEntry = function(entry, data) {
+ var cursor, length;
+ entry.setPriority(data[0]);
+ cursor = 1;
+ length = data.length;
+ while (cursor < length) {
+ if (data[cursor] === 0) {
+ entry.setTag(data.slice(1, cursor).toString());
+ entry.setMessage(data.slice(cursor + 1, length - 1).toString());
+ this.emit('entry', entry);
+ return;
+ }
+ cursor += 1;
+ }
+ this.emit('error', new Error("Unprocessable entry data '" + data + "'"));
+ };
+
+ return Binary;
+
+ })(Parser);
+
+ module.exports = Binary;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/priority.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/priority.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/priority.js
new file mode 100644
index 0000000..532ea62
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/priority.js
@@ -0,0 +1,89 @@
+(function() {
+ var Priority;
+
+ Priority = (function() {
+ var letterNames, letters, names;
+
+ function Priority() {}
+
+ Priority.UNKNOWN = 0;
+
+ Priority.DEFAULT = 1;
+
+ Priority.VERBOSE = 2;
+
+ Priority.DEBUG = 3;
+
+ Priority.INFO = 4;
+
+ Priority.WARN = 5;
+
+ Priority.ERROR = 6;
+
+ Priority.FATAL = 7;
+
+ Priority.SILENT = 8;
+
+ names = {
+ 0: 'UNKNOWN',
+ 1: 'DEFAULT',
+ 2: 'VERBOSE',
+ 3: 'DEBUG',
+ 4: 'INFO',
+ 5: 'WARN',
+ 6: 'ERROR',
+ 7: 'FATAL',
+ 8: 'SILENT'
+ };
+
+ letters = {
+ '?': Priority.UNKNOWN,
+ 'V': Priority.VERBOSE,
+ 'D': Priority.DEBUG,
+ 'I': Priority.INFO,
+ 'W': Priority.WARN,
+ 'E': Priority.ERROR,
+ 'F': Priority.FATAL,
+ 'S': Priority.SILENT
+ };
+
+ letterNames = {
+ 0: '?',
+ 1: '?',
+ 2: 'V',
+ 3: 'D',
+ 4: 'I',
+ 5: 'W',
+ 6: 'E',
+ 7: 'F',
+ 8: 'S'
+ };
+
+ Priority.fromName = function(name) {
+ var value;
+ value = Priority[name.toUpperCase()];
+ if (value || value === 0) {
+ return value;
+ }
+ return Priority.fromLetter(name);
+ };
+
+ Priority.toName = function(value) {
+ return names[value];
+ };
+
+ Priority.fromLetter = function(letter) {
+ return letters[letter.toUpperCase()];
+ };
+
+ Priority.toLetter = function(value) {
+ return letterNames[value];
+ };
+
+ return Priority;
+
+ })();
+
+ module.exports = Priority;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/reader.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/reader.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/reader.js
new file mode 100644
index 0000000..7f07626
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/reader.js
@@ -0,0 +1,137 @@
+(function() {
+ var EventEmitter, Parser, Priority, Reader, Transform,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ EventEmitter = require('events').EventEmitter;
+
+ Parser = require('./parser');
+
+ Transform = require('./transform');
+
+ Priority = require('./priority');
+
+ Reader = (function(_super) {
+ __extends(Reader, _super);
+
+ Reader.ANY = '*';
+
+ function Reader(options) {
+ var _base;
+ this.options = options != null ? options : {};
+ (_base = this.options).format || (_base.format = 'binary');
+ if (this.options.fixLineFeeds == null) {
+ this.options.fixLineFeeds = true;
+ }
+ this.filters = {
+ all: -1,
+ tags: {}
+ };
+ this.parser = Parser.get(this.options.format);
+ this.stream = null;
+ }
+
+ Reader.prototype.exclude = function(tag) {
+ if (tag === Reader.ANY) {
+ return this.excludeAll();
+ }
+ this.filters.tags[tag] = Priority.SILENT;
+ return this;
+ };
+
+ Reader.prototype.excludeAll = function() {
+ this.filters.all = Priority.SILENT;
+ return this;
+ };
+
+ Reader.prototype.include = function(tag, priority) {
+ if (priority == null) {
+ priority = Priority.DEBUG;
+ }
+ if (tag === Reader.ANY) {
+ return this.includeAll(priority);
+ }
+ this.filters.tags[tag] = this._priority(priority);
+ return this;
+ };
+
+ Reader.prototype.includeAll = function(priority) {
+ if (priority == null) {
+ priority = Priority.DEBUG;
+ }
+ this.filters.all = this._priority(priority);
+ return this;
+ };
+
+ Reader.prototype.resetFilters = function() {
+ this.filters.all = -1;
+ this.filters.tags = {};
+ return this;
+ };
+
+ Reader.prototype._hook = function() {
+ var transform,
+ _this = this;
+ if (this.options.fixLineFeeds) {
+ transform = this.stream.pipe(new Transform);
+ transform.on('data', function(data) {
+ return _this.parser.parse(data);
+ });
+ } else {
+ this.stream.on('data', function(data) {
+ return _this.parser.parse(data);
+ });
+ }
+ this.stream.on('error', function(err) {
+ return _this.emit('error', err);
+ });
+ this.stream.on('end', function() {
+ return _this.emit('end');
+ });
+ this.stream.on('finish', function() {
+ return _this.emit('finish');
+ });
+ this.parser.on('entry', function(entry) {
+ if (_this._filter(entry)) {
+ return _this.emit('entry', entry);
+ }
+ });
+ this.parser.on('error', function(err) {
+ return _this.emit('error', err);
+ });
+ };
+
+ Reader.prototype._filter = function(entry) {
+ var priority;
+ priority = this.filters.tags[entry.tag];
+ if (!(priority >= 0)) {
+ priority = this.filters.all;
+ }
+ return entry.priority >= priority;
+ };
+
+ Reader.prototype._priority = function(priority) {
+ if (typeof priority === 'number') {
+ return priority;
+ }
+ return Priority.fromName(priority);
+ };
+
+ Reader.prototype.connect = function(stream) {
+ this.stream = stream;
+ this._hook();
+ return this;
+ };
+
+ Reader.prototype.end = function() {
+ this.stream.end();
+ return this;
+ };
+
+ return Reader;
+
+ })(EventEmitter);
+
+ module.exports = Reader;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/transform.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/transform.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/transform.js
new file mode 100644
index 0000000..b6fe7a2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/lib/logcat/transform.js
@@ -0,0 +1,51 @@
+(function() {
+ var Stream, Transform,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Stream = require('stream');
+
+ Transform = (function(_super) {
+ __extends(Transform, _super);
+
+ function Transform(options) {
+ this.savedR = null;
+ Transform.__super__.constructor.call(this, options);
+ }
+
+ Transform.prototype._transform = function(chunk, encoding, done) {
+ var hi, last, lo;
+ lo = 0;
+ hi = 0;
+ if (this.savedR) {
+ if (chunk[0] !== 0x0a) {
+ this.push(this.savedR);
+ }
+ this.savedR = null;
+ }
+ last = chunk.length - 1;
+ while (hi <= last) {
+ if (chunk[hi] === 0x0d) {
+ if (hi === last) {
+ this.savedR = chunk.slice(last);
+ break;
+ } else if (chunk[hi + 1] === 0x0a) {
+ this.push(chunk.slice(lo, hi));
+ lo = hi + 1;
+ }
+ }
+ hi += 1;
+ }
+ if (hi !== lo) {
+ this.push(chunk.slice(lo, hi));
+ }
+ done();
+ };
+
+ return Transform;
+
+ })(Stream.Transform);
+
+ module.exports = Transform;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/package.json
new file mode 100644
index 0000000..6fe20fd
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-logcat/package.json
@@ -0,0 +1,75 @@
+{
+ "name": "adbkit-logcat",
+ "version": "1.0.3",
+ "description": "A Node.js interface for working with Android's logcat output.",
+ "keywords": [
+ "adb",
+ "adbkit",
+ "logcat"
+ ],
+ "bugs": {
+ "url": "https://github.com/CyberAgent/adbkit-logcat/issues"
+ },
+ "license": "Apache-2.0",
+ "author": {
+ "name": "CyberAgent, Inc.",
+ "email": "npm@cyberagent.co.jp",
+ "url": "http://www.cyberagent.co.jp/"
+ },
+ "main": "./index",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/CyberAgent/adbkit-logcat.git"
+ },
+ "scripts": {
+ "postpublish": "grunt clean",
+ "prepublish": "grunt coffee",
+ "test": "grunt test"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "chai": "~1.8.1",
+ "coffee-script": "~1.6.3",
+ "grunt": "~0.4.1",
+ "grunt-cli": "~0.1.11",
+ "grunt-coffeelint": "~0.0.7",
+ "grunt-contrib-clean": "~0.5.0",
+ "grunt-contrib-coffee": "~0.7.0",
+ "grunt-contrib-watch": "~0.5.3",
+ "grunt-exec": "~0.4.2",
+ "grunt-jsonlint": "~1.0.2",
+ "grunt-notify": "~0.2.16",
+ "mocha": "~1.14.0",
+ "sinon": "~1.7.3",
+ "sinon-chai": "~2.4.0"
+ },
+ "engines": {
+ "node": ">= 0.10.4"
+ },
+ "homepage": "https://github.com/CyberAgent/adbkit-logcat",
+ "_id": "adbkit-logcat@1.0.3",
+ "dist": {
+ "shasum": "8b5fef57086c02c9e24004af5706ee508d83db07",
+ "tarball": "http://registry.npmjs.org/adbkit-logcat/-/adbkit-logcat-1.0.3.tgz"
+ },
+ "_from": "adbkit-logcat@~1.0.3",
+ "_npmVersion": "1.4.3",
+ "_npmUser": {
+ "name": "sorccu",
+ "email": "simo@shoqolate.com"
+ },
+ "maintainers": [
+ {
+ "name": "sorccu",
+ "email": "simo@shoqolate.com"
+ },
+ {
+ "name": "cyberagent",
+ "email": "npm@cyberagent.co.jp"
+ }
+ ],
+ "directories": {},
+ "_shasum": "8b5fef57086c02c9e24004af5706ee508d83db07",
+ "_resolved": "https://registry.npmjs.org/adbkit-logcat/-/adbkit-logcat-1.0.3.tgz",
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/LICENSE b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/LICENSE
new file mode 100644
index 0000000..2ffff3d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/LICENSE
@@ -0,0 +1,13 @@
+Copyright © CyberAgent, Inc. All Rights Reserved.
+
+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.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/README.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/README.md
new file mode 100644
index 0000000..97977bb
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/README.md
@@ -0,0 +1,469 @@
+# adbkit-monkey
+
+**adbkit-monkey** provides a [Node.js][nodejs] interface for working with the Android [`monkey` tool][monkey-site]. Albeit undocumented, they monkey program can be started in TCP mode with the `--port` argument. In this mode, it accepts a [range of commands][monkey-proto] that can be used to interact with the UI in a non-random manner. This mode is also used internally by the [`monkeyrunner` tool][monkeyrunner-site], although the documentation claims no relation to the monkey tool.
+
+## Getting started
+
+Install via NPM:
+
+```bash
+npm install --save adbkit-monkey
+```
+
+Note that while adbkit-monkey is written in CoffeeScript, it is compiled to JavaScript before publishing to NPM, which means that you are not required to use CoffeeScript.
+
+### Examples
+
+The following examples assume that monkey is already running (via `adb shell monkey --port 1080`) and a port forwarding (`adb forward tcp:1080 tcp:1080`) has been set up.
+
+#### Press the home button
+
+```javascript
+var assert = require('assert');
+var monkey = require('adbkit-monkey');
+
+var client = monkey.connect({ port: 1080 });
+
+client.press(3 /* KEYCODE_HOME */, function(err) {
+ assert.ifError(err);
+ console.log('Pressed home button');
+ client.end();
+});
+```
+
+#### Drag out the notification bar
+
+```javascript
+var assert = require('assert');
+var monkey = require('adbkit-monkey');
+
+var client = monkey.connect({ port: 1080 });
+
+client.multi()
+ .touchDown(100, 0)
+ .sleep(5)
+ .touchMove(100, 20)
+ .sleep(5)
+ .touchMove(100, 40)
+ .sleep(5)
+ .touchMove(100, 60)
+ .sleep(5)
+ .touchMove(100, 80)
+ .sleep(5)
+ .touchMove(100, 100)
+ .sleep(5)
+ .touchUp(100, 100)
+ .sleep(5)
+ .execute(function(err) {
+ assert.ifError(err);
+ console.log('Dragged out the notification bar');
+ client.end();
+ });
+```
+
+#### Get display size
+
+```javascript
+var assert = require('assert');
+var monkey = require('adbkit-monkey');
+
+var client = monkey.connect({ port: 1080 });
+
+client.getDisplayWidth(function(err, width) {
+ assert.ifError(err);
+ client.getDisplayHeight(function(err, height) {
+ assert.ifError(err);
+ console.log('Display size is %dx%d', width, height);
+ client.end();
+ });
+});
+```
+
+#### Type text
+
+Note that you should manually focus a text field first.
+
+```javascript
+var assert = require('assert');
+var monkey = require('adbkit-monkey');
+
+var client = monkey.connect({ port: 1080 });
+
+client.type('hello monkey!', function(err) {
+ assert.ifError(err);
+ console.log('Said hello to monkey');
+ client.end();
+});
+```
+
+## API
+
+### Monkey
+
+#### monkey.connect(options)
+
+Uses [Net.connect()][node-net] to open a new TCP connection to monkey. Useful when combined with `adb forward`.
+
+* **options** Any options [`Net.connect()`][node-net] accepts.
+* Returns: A new monkey `Client` instance.
+
+#### monkey.connectStream(stream)
+
+Attaches a monkey client to an existing monkey protocol stream.
+
+* **stream** The monkey protocol [`Stream`][node-stream].
+* Returns: A new monkey `Client` instance.
+
+### Client
+
+Implements `Api`. See below for details.
+
+#### Events
+
+The following events are available:
+
+* **error** **(err)** Emitted when an error occurs.
+ * **err** An `Error`.
+* **end** Emitted when the stream ends.
+* **finish** Emitted when the stream finishes.
+
+#### client.end()
+
+Ends the underlying stream/connection.
+
+* Returns: The `Client` instance.
+
+#### client.multi()
+
+Returns a new API wrapper that buffers commands for simultaneous delivery instead of sending them individually. When used with `api.sleep()`, allows simple gestures to be executed.
+
+* Returns: A new `Multi` instance. See `Multi` below.
+
+#### client.send(command, callback)
+
+Sends a raw protocol command to monkey.
+
+* **command** The command to send. When `String`, a single command is sent. When `Array`, a series of commands is sent at once.
+* **callback(err, value, command)** Called when monkey responds to the command. If multiple commands were sent, the callback will be called once for each command.
+ * **err** `null` when successful, `Error` otherwise.
+ * **value** The response value, if any.
+ * **command** The command the response is for.
+* Returns: The `Client` instance.
+
+### Api
+
+The monkey API implemented by `Client` and `Multi`.
+
+#### api.done(callback)
+
+Closes the current monkey session and allows a new session to connect.
+
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.flipClose(callback)
+
+Simulates closing the keyboard.
+
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.flipOpen(callback)
+
+Simulates opening the keyboard.
+
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.get(name, callback)
+
+Gets the value of a variable. Use `api.list()` to retrieve a list of supported variables.
+
+* **name** The name of the variable.
+* **callback(err, value)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+ * **value** The value of the variable.
+* Returns: The `Api` implementation instance.
+
+#### api.getAmCurrentAction(callback)
+
+Alias for `api.get('am.current.action', callback)`.
+
+#### api.getAmCurrentCategories(callback)
+
+Alias for `api.get('am.current.categories', callback)`.
+
+#### api.getAmCurrentCompClass(callback)
+
+Alias for `api.get('am.current.comp.class', callback)`.
+
+#### api.getAmCurrentCompPackage(callback)
+
+Alias for `api.get('am.current.comp.package', callback)`.
+
+#### api.getCurrentData(callback)
+
+Alias for `api.get('am.current.data', callback)`.
+
+#### api.getAmCurrentPackage(callback)
+
+Alias for `api.get('am.current.package', callback)`.
+
+#### api.getBuildBoard(callback)
+
+Alias for `api.get('build.board', callback)`.
+
+#### api.getBuildBrand(callback)
+
+Alias for `api.get('build.brand', callback)`.
+
+#### api.getBuildCpuAbi(callback)
+
+Alias for `api.get('build.cpu_abi', callback)`.
+
+#### api.getBuildDevice(callback)
+
+Alias for `api.get('build.device', callback)`.
+
+#### api.getBuildDisplay(callback)
+
+Alias for `api.get('build.display', callback)`.
+
+#### api.getBuildFingerprint(callback)
+
+Alias for `api.get('build.fingerprint', callback)`.
+
+#### api.getBuildHost(callback)
+
+Alias for `api.get('build.host', callback)`.
+
+#### api.getBuildId(callback)
+
+Alias for `api.get('build.id', callback)`.
+
+#### api.getBuildManufacturer(callback)
+
+Alias for `api.get('build.manufacturer', callback)`.
+
+#### api.getBuildModel(callback)
+
+Alias for `api.get('build.model', callback)`.
+
+#### api.getBuildProduct(callback)
+
+Alias for `api.get('build.product', callback)`.
+
+#### api.getBuildTags(callback)
+
+Alias for `api.get('build.tags', callback)`.
+
+#### api.getBuildType(callback)
+
+Alias for `api.get('build.type', callback)`.
+
+#### api.getBuildUser(callback)
+
+Alias for `api.get('build.user', callback)`.
+
+#### api.getBuildVersionCodename(callback)
+
+Alias for `api.get('build.version.codename', callback)`.
+
+#### api.getBuildVersionIncremental(callback)
+
+Alias for `api.get('build.version.incremental', callback)`.
+
+#### api.getBuildVersionRelease(callback)
+
+Alias for `api.get('build.version.release', callback)`.
+
+#### api.getBuildVersionSdk(callback)
+
+Alias for `api.get('build.version.sdk', callback)`.
+
+#### api.getClockMillis(callback)
+
+Alias for `api.get('clock.millis', callback)`.
+
+#### api.getClockRealtime(callback)
+
+Alias for `api.get('clock.realtime', callback)`.
+
+#### api.getClockUptime(callback)
+
+Alias for `api.get('clock.uptime', callback)`.
+
+#### api.getDisplayDensity(callback)
+
+Alias for `api.get('display.density', callback)`.
+
+#### api.getDisplayHeight(callback)
+
+Alias for `api.get('display.height', callback)`. Note that the height may exclude any virtual home button row.
+
+#### api.getDisplayWidth(callback)
+
+Alias for `api.get('display.width', callback)`.
+
+#### api.keyDown(keyCode, callback)
+
+Sends a key down event. Should be coupled with `api.keyUp()`. Note that `api.press()` performs the two events automatically.
+
+* **keyCode** The [key code][android-keycodes]. All monkeys support numeric keycodes, and some support automatic conversion from key names to key codes (e.g. `'home'` to `KEYCODE_HOME`). This will not work for number keys however. The most portable method is to simply use numeric key codes.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.keyUp(keyCode, callback)
+
+Sends a key up event. Should be coupled with `api.keyDown()`. Note that `api.press()` performs the two events automatically.
+
+* **keyCode** See `api.keyDown()`.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.list(callback)
+
+Lists supported variables.
+
+* **callback(err, vars)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+ * **vars** An array of supported variable names, to be used with `api.get()`.
+* Returns: The `Api` implementation instance.
+
+#### api.press(keyCode, callback)
+
+Sends a key press event.
+
+* **keyCode** See `api.keyDown()`.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.quit(callback)
+
+Closes the current monkey session and quits monkey.
+
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.sleep(ms, callback)
+
+Sleeps for the given duration. Can be useful for simulating gestures.
+
+* **ms** How many milliseconds to sleep for.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.tap(x, y, callback)
+
+Taps the given coordinates.
+
+* **x** The x coordinate.
+* **y** The y coordinate.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.touchDown(x, y, callback)
+
+Sends a touch down event on the given coordinates.
+
+* **x** The x coordinate.
+* **y** The y coordinate.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.touchMove(x, y, callback)
+
+Sends a touch move event on the given coordinates.
+
+* **x** The x coordinate.
+* **y** The y coordinate.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.touchUp(x, y, callback)
+
+Sends a touch up event on the given coordinates.
+
+* **x** The x coordinate.
+* **y** The y coordinate.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.trackball(x, y, callback)
+
+Sends a trackball event on the given coordinates.
+
+* **x** The x coordinate.
+* **y** The y coordinate.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.type(text, callback)
+
+Types the given text.
+
+* **text** A text `String`. Note that only characters for which [key codes][android-keycodes] exist can be entered. Also note that any IME in use may or may not transform the text.
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+#### api.wake(callback)
+
+Wakes the device from sleep and allows user input.
+
+* **callback(err)** Called when monkey responds.
+ * **err** `null` when successful, `Error` otherwise.
+* Returns: The `Api` implementation instance.
+
+### Multi
+
+Buffers `Api` commands and delivers them simultaneously for greater control over timing.
+
+Implements all `Api` methods, but without the last `callback` parameter.
+
+#### multi.execute(callback)
+
+Sends all buffered commands.
+
+* **callback(err, values)** Called when monkey has responded to all commands (i.e. just once at the end).
+ * **err** `null` when successful, `Error` otherwise.
+ * **values** An array of all response values, identical to individual `Api` responses.
+
+## More information
+
+* [Monkey][monkey-site]
+ - [Source code][monkey-source]
+ - [Protocol][monkey-proto]
+* [Monkeyrunner][monkeyrunner-site]
+
+## Contributing
+
+See [CONTRIBUTING.md](CONTRIBUTING.md).
+
+## License
+
+See [LICENSE](LICENSE).
+
+Copyright © CyberAgent, Inc. All Rights Reserved.
+
+[nodejs]: <http://nodejs.org/>
+[monkey-site]: <http://developer.android.com/tools/help/monkey.html>
+[monkey-source]: <https://github.com/android/platform_development/blob/master/cmds/monkey/>
+[monkey-proto]: <https://github.com/android/platform_development/blob/master/cmds/monkey/README.NETWORK.txt>
+[monkeyrunner-site]: <http://developer.android.com/tools/help/monkeyrunner_concepts.html>
+[node-net]: <http://nodejs.org/api/net.html>
+[node-stream]: <http://nodejs.org/api/stream.html>
+[android-keycodes]: <http://developer.android.com/reference/android/view/KeyEvent.html>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/index.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/index.js
new file mode 100644
index 0000000..a81226d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/index.js
@@ -0,0 +1,15 @@
+(function() {
+ var Path;
+
+ Path = require('path');
+
+ module.exports = (function() {
+ switch (Path.extname(__filename)) {
+ case '.coffee':
+ return require('./src/monkey');
+ default:
+ return require('./lib/monkey');
+ }
+ })();
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey.js
new file mode 100644
index 0000000..9e81c56
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey.js
@@ -0,0 +1,29 @@
+(function() {
+ var Client, Connection, Monkey;
+
+ Client = require('./monkey/client');
+
+ Connection = require('./monkey/connection');
+
+ Monkey = (function() {
+ function Monkey() {}
+
+ Monkey.connect = function(options) {
+ return new Connection().connect(options);
+ };
+
+ Monkey.connectStream = function(stream) {
+ return new Client().connect(stream);
+ };
+
+ return Monkey;
+
+ })();
+
+ Monkey.Connection = Connection;
+
+ Monkey.Client = Client;
+
+ module.exports = Monkey;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/api.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/api.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/api.js
new file mode 100644
index 0000000..34fce09
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/api.js
@@ -0,0 +1,276 @@
+(function() {
+ var Api, EventEmitter, _ref,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ EventEmitter = require('events').EventEmitter;
+
+ Api = (function(_super) {
+ __extends(Api, _super);
+
+ function Api() {
+ _ref = Api.__super__.constructor.apply(this, arguments);
+ return _ref;
+ }
+
+ Api.prototype.send = function() {
+ throw new Error("send is not implemented");
+ };
+
+ Api.prototype.keyDown = function(keyCode, callback) {
+ this.send("key down " + keyCode, callback);
+ return this;
+ };
+
+ Api.prototype.keyUp = function(keyCode, callback) {
+ this.send("key up " + keyCode, callback);
+ return this;
+ };
+
+ Api.prototype.touchDown = function(x, y, callback) {
+ this.send("touch down " + x + " " + y, callback);
+ return this;
+ };
+
+ Api.prototype.touchUp = function(x, y, callback) {
+ this.send("touch up " + x + " " + y, callback);
+ return this;
+ };
+
+ Api.prototype.touchMove = function(x, y, callback) {
+ this.send("touch move " + x + " " + y, callback);
+ return this;
+ };
+
+ Api.prototype.trackball = function(dx, dy, callback) {
+ this.send("trackball " + dx + " " + dy, callback);
+ return this;
+ };
+
+ Api.prototype.flipOpen = function(callback) {
+ this.send("flip open", callback);
+ return this;
+ };
+
+ Api.prototype.flipClose = function(callback) {
+ this.send("flip close", callback);
+ return this;
+ };
+
+ Api.prototype.wake = function(callback) {
+ this.send("wake", callback);
+ return this;
+ };
+
+ Api.prototype.tap = function(x, y, callback) {
+ this.send("tap " + x + " " + y, callback);
+ return this;
+ };
+
+ Api.prototype.press = function(keyCode, callback) {
+ this.send("press " + keyCode, callback);
+ return this;
+ };
+
+ Api.prototype.type = function(str, callback) {
+ str = str.replace(/"/g, '\\"');
+ if (str.indexOf(' ') === -1) {
+ this.send("type " + str, callback);
+ } else {
+ this.send("type \"" + str + "\"", callback);
+ }
+ return this;
+ };
+
+ Api.prototype.list = function(callback) {
+ var _this = this;
+ this.send("listvar", function(err, vars) {
+ if (err) {
+ return _this(callback(err));
+ }
+ if (err) {
+ return callback(err);
+ } else {
+ return callback(null, vars.split(/\s+/g));
+ }
+ });
+ return this;
+ };
+
+ Api.prototype.get = function(name, callback) {
+ this.send("getvar " + name, callback);
+ return this;
+ };
+
+ Api.prototype.quit = function(callback) {
+ this.send("quit", callback);
+ return this;
+ };
+
+ Api.prototype.done = function(callback) {
+ this.send("done", callback);
+ return this;
+ };
+
+ Api.prototype.sleep = function(ms, callback) {
+ this.send("sleep " + ms, callback);
+ return this;
+ };
+
+ Api.prototype.getAmCurrentAction = function(callback) {
+ this.get('am.current.action', callback);
+ return this;
+ };
+
+ Api.prototype.getAmCurrentCategories = function(callback) {
+ this.get('am.current.categories', callback);
+ return this;
+ };
+
+ Api.prototype.getAmCurrentCompClass = function(callback) {
+ this.get('am.current.comp.class', callback);
+ return this;
+ };
+
+ Api.prototype.getAmCurrentCompPackage = function(callback) {
+ this.get('am.current.comp.package', callback);
+ return this;
+ };
+
+ Api.prototype.getAmCurrentData = function(callback) {
+ this.get('am.current.data', callback);
+ return this;
+ };
+
+ Api.prototype.getAmCurrentPackage = function(callback) {
+ this.get('am.current.package', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildBoard = function(callback) {
+ this.get('build.board', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildBrand = function(callback) {
+ this.get('build.brand', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildCpuAbi = function(callback) {
+ this.get('build.cpu_abi', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildDevice = function(callback) {
+ this.get('build.device', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildDisplay = function(callback) {
+ this.get('build.display', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildFingerprint = function(callback) {
+ this.get('build.fingerprint', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildHost = function(callback) {
+ this.get('build.host', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildId = function(callback) {
+ this.get('build.id', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildManufacturer = function(callback) {
+ this.get('build.manufacturer', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildModel = function(callback) {
+ this.get('build.model', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildProduct = function(callback) {
+ this.get('build.product', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildTags = function(callback) {
+ this.get('build.tags', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildType = function(callback) {
+ this.get('build.type', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildUser = function(callback) {
+ this.get('build.user', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildVersionCodename = function(callback) {
+ this.get('build.version.codename', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildVersionIncremental = function(callback) {
+ this.get('build.version.incremental', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildVersionRelease = function(callback) {
+ this.get('build.version.release', callback);
+ return this;
+ };
+
+ Api.prototype.getBuildVersionSdk = function(callback) {
+ this.get('build.version.sdk', callback);
+ return this;
+ };
+
+ Api.prototype.getClockMillis = function(callback) {
+ this.get('clock.millis', callback);
+ return this;
+ };
+
+ Api.prototype.getClockRealtime = function(callback) {
+ this.get('clock.realtime', callback);
+ return this;
+ };
+
+ Api.prototype.getClockUptime = function(callback) {
+ this.get('clock.uptime', callback);
+ return this;
+ };
+
+ Api.prototype.getDisplayDensity = function(callback) {
+ this.get('display.density', callback);
+ return this;
+ };
+
+ Api.prototype.getDisplayHeight = function(callback) {
+ this.get('display.height', callback);
+ return this;
+ };
+
+ Api.prototype.getDisplayWidth = function(callback) {
+ this.get('display.width', callback);
+ return this;
+ };
+
+ return Api;
+
+ })(EventEmitter);
+
+ module.exports = Api;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/client.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/client.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/client.js
new file mode 100644
index 0000000..b6e1278
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/client.js
@@ -0,0 +1,98 @@
+(function() {
+ var Api, Client, Command, Multi, Parser, Queue, Reply,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Api = require('./api');
+
+ Command = require('./command');
+
+ Reply = require('./reply');
+
+ Queue = require('./queue');
+
+ Multi = require('./multi');
+
+ Parser = require('./parser');
+
+ Client = (function(_super) {
+ __extends(Client, _super);
+
+ function Client() {
+ this.commandQueue = new Queue;
+ this.parser = new Parser;
+ this.stream = null;
+ }
+
+ Client.prototype._hook = function() {
+ var _this = this;
+ this.stream.on('data', function(data) {
+ return _this.parser.parse(data);
+ });
+ this.stream.on('error', function(err) {
+ return _this.emit('error', err);
+ });
+ this.stream.on('end', function() {
+ return _this.emit('end');
+ });
+ this.stream.on('finish', function() {
+ return _this.emit('finish');
+ });
+ this.parser.on('reply', function(reply) {
+ return _this._consume(reply);
+ });
+ this.parser.on('error', function(err) {
+ return _this.emit('error', err);
+ });
+ };
+
+ Client.prototype._consume = function(reply) {
+ var command;
+ if (command = this.commandQueue.dequeue()) {
+ if (reply.isError()) {
+ command.callback(reply.toError(), null, command.command);
+ } else {
+ command.callback(null, reply.value, command.command);
+ }
+ } else {
+ throw new Error("Command queue depleted, but replies still coming in");
+ }
+ };
+
+ Client.prototype.connect = function(stream) {
+ this.stream = stream;
+ this._hook();
+ return this;
+ };
+
+ Client.prototype.end = function() {
+ this.stream.end();
+ return this;
+ };
+
+ Client.prototype.send = function(commands, callback) {
+ var command, _i, _len;
+ if (Array.isArray(commands)) {
+ for (_i = 0, _len = commands.length; _i < _len; _i++) {
+ command = commands[_i];
+ this.commandQueue.enqueue(new Command(command, callback));
+ }
+ this.stream.write("" + (commands.join('\n')) + "\n");
+ } else {
+ this.commandQueue.enqueue(new Command(commands, callback));
+ this.stream.write("" + commands + "\n");
+ }
+ return this;
+ };
+
+ Client.prototype.multi = function() {
+ return new Multi(this);
+ };
+
+ return Client;
+
+ })(Api);
+
+ module.exports = Client;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/command.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/command.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/command.js
new file mode 100644
index 0000000..41062e0
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/command.js
@@ -0,0 +1,17 @@
+(function() {
+ var Command;
+
+ Command = (function() {
+ function Command(command, callback) {
+ this.command = command;
+ this.callback = callback;
+ this.next = null;
+ }
+
+ return Command;
+
+ })();
+
+ module.exports = Command;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/connection.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/connection.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/connection.js
new file mode 100644
index 0000000..b52ee14
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/connection.js
@@ -0,0 +1,42 @@
+(function() {
+ var Client, Connection, Net, _ref,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Net = require('net');
+
+ Client = require('./client');
+
+ Connection = (function(_super) {
+ __extends(Connection, _super);
+
+ function Connection() {
+ _ref = Connection.__super__.constructor.apply(this, arguments);
+ return _ref;
+ }
+
+ Connection.prototype.connect = function(options) {
+ var stream;
+ stream = Net.connect(options);
+ stream.setNoDelay(true);
+ return Connection.__super__.connect.call(this, stream);
+ };
+
+ Connection.prototype._hook = function() {
+ var _this = this;
+ this.stream.on('connect', function() {
+ return _this.emit('connect');
+ });
+ this.stream.on('close', function(hadError) {
+ return _this.emit('close', hadError);
+ });
+ return Connection.__super__._hook.call(this);
+ };
+
+ return Connection;
+
+ })(Client);
+
+ module.exports = Connection;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/multi.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/multi.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/multi.js
new file mode 100644
index 0000000..80e8214
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/multi.js
@@ -0,0 +1,85 @@
+(function() {
+ var Api, Command, Multi,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Api = require('./api');
+
+ Command = require('./command');
+
+ Multi = (function(_super) {
+ __extends(Multi, _super);
+
+ function Multi(monkey) {
+ var _this = this;
+ this.monkey = monkey;
+ this.commands = [];
+ this.replies = [];
+ this.errors = [];
+ this.counter = 0;
+ this.sent = false;
+ this.callback = null;
+ this.collector = function(err, result, cmd) {
+ if (err) {
+ _this.errors.push("" + cmd + ": " + err.message);
+ }
+ _this.replies.push(result);
+ _this.counter -= 1;
+ return _this._maybeFinish();
+ };
+ }
+
+ Multi.prototype._maybeFinish = function() {
+ var _this = this;
+ if (this.counter === 0) {
+ if (this.errors.length) {
+ setImmediate(function() {
+ return _this.callback(new Error(_this.errors.join(', ')));
+ });
+ } else {
+ setImmediate(function() {
+ return _this.callback(null, _this.replies);
+ });
+ }
+ }
+ };
+
+ Multi.prototype._forbidReuse = function() {
+ if (this.sent) {
+ throw new Error("Reuse not supported");
+ }
+ };
+
+ Multi.prototype.send = function(command) {
+ this._forbidReuse();
+ this.commands.push(new Command(command, this.collector));
+ };
+
+ Multi.prototype.execute = function(callback) {
+ var command, parts, _i, _len, _ref;
+ this._forbidReuse();
+ this.counter = this.commands.length;
+ this.sent = true;
+ this.callback = callback;
+ if (this.counter === 0) {
+ return;
+ }
+ parts = [];
+ _ref = this.commands;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ command = _ref[_i];
+ this.monkey.commandQueue.enqueue(command);
+ parts.push(command.command);
+ }
+ parts.push('');
+ this.commands = [];
+ this.monkey.stream.write(parts.join('\n'));
+ };
+
+ return Multi;
+
+ })(Api);
+
+ module.exports = Multi;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/parser.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/parser.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/parser.js
new file mode 100644
index 0000000..75dcb9f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/parser.js
@@ -0,0 +1,66 @@
+(function() {
+ var EventEmitter, Parser, Reply,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ EventEmitter = require('events').EventEmitter;
+
+ Reply = require('./reply');
+
+ Parser = (function(_super) {
+ __extends(Parser, _super);
+
+ function Parser(options) {
+ this.column = 0;
+ this.buffer = new Buffer('');
+ }
+
+ Parser.prototype.parse = function(chunk) {
+ this.buffer = Buffer.concat([this.buffer, chunk]);
+ while (this.column < this.buffer.length) {
+ if (this.buffer[this.column] === 0x0a) {
+ this._parseLine(this.buffer.slice(0, this.column));
+ this.buffer = this.buffer.slice(this.column + 1);
+ this.column = 0;
+ }
+ this.column += 1;
+ }
+ if (this.buffer.length) {
+ this.emit('wait');
+ } else {
+ this.emit('drain');
+ }
+ };
+
+ Parser.prototype._parseLine = function(line) {
+ switch (line[0]) {
+ case 0x4f:
+ if (line.length === 2) {
+ this.emit('reply', new Reply(Reply.OK, null));
+ } else {
+ this.emit('reply', new Reply(Reply.OK, line.toString('ascii', 3)));
+ }
+ break;
+ case 0x45:
+ if (line.length === 5) {
+ this.emit('reply', new Reply(Reply.ERROR, null));
+ } else {
+ this.emit('reply', new Reply(Reply.ERROR, line.toString('ascii', 6)));
+ }
+ break;
+ default:
+ this._complain(line);
+ }
+ };
+
+ Parser.prototype._complain = function(line) {
+ this.emit('error', new SyntaxError("Unparseable line '" + line + "'"));
+ };
+
+ return Parser;
+
+ })(EventEmitter);
+
+ module.exports = Parser;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/queue.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/queue.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/queue.js
new file mode 100644
index 0000000..19d6615
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/adbkit-monkey/lib/monkey/queue.js
@@ -0,0 +1,38 @@
+(function() {
+ var Queue;
+
+ Queue = (function() {
+ function Queue() {
+ this.head = null;
+ this.tail = null;
+ }
+
+ Queue.prototype.enqueue = function(item) {
+ if (this.tail) {
+ this.tail.next = item;
+ } else {
+ this.head = item;
+ }
+ this.tail = item;
+ };
+
+ Queue.prototype.dequeue = function() {
+ var item;
+ item = this.head;
+ if (item) {
+ if (item === this.tail) {
+ this.tail = null;
+ }
+ this.head = item.next;
+ item.next = null;
+ }
+ return item;
+ };
+
+ return Queue;
+
+ })();
+
+ module.exports = Queue;
+
+}).call(this);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[08/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/tls.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/tls.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/tls.js
new file mode 100644
index 0000000..b3bb2e8
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/tls.js
@@ -0,0 +1,4316 @@
+/**
+ * A Javascript implementation of Transport Layer Security (TLS).
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2009-2014 Digital Bazaar, Inc.
+ *
+ * The TLS Handshake Protocol involves the following steps:
+ *
+ * - Exchange hello messages to agree on algorithms, exchange random values,
+ * and check for session resumption.
+ *
+ * - Exchange the necessary cryptographic parameters to allow the client and
+ * server to agree on a premaster secret.
+ *
+ * - Exchange certificates and cryptographic information to allow the client
+ * and server to authenticate themselves.
+ *
+ * - Generate a master secret from the premaster secret and exchanged random
+ * values.
+ *
+ * - Provide security parameters to the record layer.
+ *
+ * - Allow the client and server to verify that their peer has calculated the
+ * same security parameters and that the handshake occurred without tampering
+ * by an attacker.
+ *
+ * Up to 4 different messages may be sent during a key exchange. The server
+ * certificate, the server key exchange, the client certificate, and the
+ * client key exchange.
+ *
+ * A typical handshake (from the client's perspective).
+ *
+ * 1. Client sends ClientHello.
+ * 2. Client receives ServerHello.
+ * 3. Client receives optional Certificate.
+ * 4. Client receives optional ServerKeyExchange.
+ * 5. Client receives ServerHelloDone.
+ * 6. Client sends optional Certificate.
+ * 7. Client sends ClientKeyExchange.
+ * 8. Client sends optional CertificateVerify.
+ * 9. Client sends ChangeCipherSpec.
+ * 10. Client sends Finished.
+ * 11. Client receives ChangeCipherSpec.
+ * 12. Client receives Finished.
+ * 13. Client sends/receives application data.
+ *
+ * To reuse an existing session:
+ *
+ * 1. Client sends ClientHello with session ID for reuse.
+ * 2. Client receives ServerHello with same session ID if reusing.
+ * 3. Client receives ChangeCipherSpec message if reusing.
+ * 4. Client receives Finished.
+ * 5. Client sends ChangeCipherSpec.
+ * 6. Client sends Finished.
+ *
+ * Note: Client ignores HelloRequest if in the middle of a handshake.
+ *
+ * Record Layer:
+ *
+ * The record layer fragments information blocks into TLSPlaintext records
+ * carrying data in chunks of 2^14 bytes or less. Client message boundaries are
+ * not preserved in the record layer (i.e., multiple client messages of the
+ * same ContentType MAY be coalesced into a single TLSPlaintext record, or a
+ * single message MAY be fragmented across several records).
+ *
+ * struct {
+ * uint8 major;
+ * uint8 minor;
+ * } ProtocolVersion;
+ *
+ * struct {
+ * ContentType type;
+ * ProtocolVersion version;
+ * uint16 length;
+ * opaque fragment[TLSPlaintext.length];
+ * } TLSPlaintext;
+ *
+ * type:
+ * The higher-level protocol used to process the enclosed fragment.
+ *
+ * version:
+ * The version of the protocol being employed. TLS Version 1.2 uses version
+ * {3, 3}. TLS Version 1.0 uses version {3, 1}. Note that a client that
+ * supports multiple versions of TLS may not know what version will be
+ * employed before it receives the ServerHello.
+ *
+ * length:
+ * The length (in bytes) of the following TLSPlaintext.fragment. The length
+ * MUST NOT exceed 2^14 = 16384 bytes.
+ *
+ * fragment:
+ * The application data. This data is transparent and treated as an
+ * independent block to be dealt with by the higher-level protocol specified
+ * by the type field.
+ *
+ * Implementations MUST NOT send zero-length fragments of Handshake, Alert, or
+ * ChangeCipherSpec content types. Zero-length fragments of Application data
+ * MAY be sent as they are potentially useful as a traffic analysis
+ * countermeasure.
+ *
+ * Note: Data of different TLS record layer content types MAY be interleaved.
+ * Application data is generally of lower precedence for transmission than
+ * other content types. However, records MUST be delivered to the network in
+ * the same order as they are protected by the record layer. Recipients MUST
+ * receive and process interleaved application layer traffic during handshakes
+ * subsequent to the first one on a connection.
+ *
+ * struct {
+ * ContentType type; // same as TLSPlaintext.type
+ * ProtocolVersion version;// same as TLSPlaintext.version
+ * uint16 length;
+ * opaque fragment[TLSCompressed.length];
+ * } TLSCompressed;
+ *
+ * length:
+ * The length (in bytes) of the following TLSCompressed.fragment.
+ * The length MUST NOT exceed 2^14 + 1024.
+ *
+ * fragment:
+ * The compressed form of TLSPlaintext.fragment.
+ *
+ * Note: A CompressionMethod.null operation is an identity operation; no fields
+ * are altered. In this implementation, since no compression is supported,
+ * uncompressed records are always the same as compressed records.
+ *
+ * Encryption Information:
+ *
+ * The encryption and MAC functions translate a TLSCompressed structure into a
+ * TLSCiphertext. The decryption functions reverse the process. The MAC of the
+ * record also includes a sequence number so that missing, extra, or repeated
+ * messages are detectable.
+ *
+ * struct {
+ * ContentType type;
+ * ProtocolVersion version;
+ * uint16 length;
+ * select (SecurityParameters.cipher_type) {
+ * case stream: GenericStreamCipher;
+ * case block: GenericBlockCipher;
+ * case aead: GenericAEADCipher;
+ * } fragment;
+ * } TLSCiphertext;
+ *
+ * type:
+ * The type field is identical to TLSCompressed.type.
+ *
+ * version:
+ * The version field is identical to TLSCompressed.version.
+ *
+ * length:
+ * The length (in bytes) of the following TLSCiphertext.fragment.
+ * The length MUST NOT exceed 2^14 + 2048.
+ *
+ * fragment:
+ * The encrypted form of TLSCompressed.fragment, with the MAC.
+ *
+ * Note: Only CBC Block Ciphers are supported by this implementation.
+ *
+ * The TLSCompressed.fragment structures are converted to/from block
+ * TLSCiphertext.fragment structures.
+ *
+ * struct {
+ * opaque IV[SecurityParameters.record_iv_length];
+ * block-ciphered struct {
+ * opaque content[TLSCompressed.length];
+ * opaque MAC[SecurityParameters.mac_length];
+ * uint8 padding[GenericBlockCipher.padding_length];
+ * uint8 padding_length;
+ * };
+ * } GenericBlockCipher;
+ *
+ * The MAC is generated as described in Section 6.2.3.1.
+ *
+ * IV:
+ * The Initialization Vector (IV) SHOULD be chosen at random, and MUST be
+ * unpredictable. Note that in versions of TLS prior to 1.1, there was no
+ * IV field, and the last ciphertext block of the previous record (the "CBC
+ * residue") was used as the IV. This was changed to prevent the attacks
+ * described in [CBCATT]. For block ciphers, the IV length is of length
+ * SecurityParameters.record_iv_length, which is equal to the
+ * SecurityParameters.block_size.
+ *
+ * padding:
+ * Padding that is added to force the length of the plaintext to be an
+ * integral multiple of the block cipher's block length. The padding MAY be
+ * any length up to 255 bytes, as long as it results in the
+ * TLSCiphertext.length being an integral multiple of the block length.
+ * Lengths longer than necessary might be desirable to frustrate attacks on
+ * a protocol that are based on analysis of the lengths of exchanged
+ * messages. Each uint8 in the padding data vector MUST be filled with the
+ * padding length value. The receiver MUST check this padding and MUST use
+ * the bad_record_mac alert to indicate padding errors.
+ *
+ * padding_length:
+ * The padding length MUST be such that the total size of the
+ * GenericBlockCipher structure is a multiple of the cipher's block length.
+ * Legal values range from zero to 255, inclusive. This length specifies the
+ * length of the padding field exclusive of the padding_length field itself.
+ *
+ * The encrypted data length (TLSCiphertext.length) is one more than the sum of
+ * SecurityParameters.block_length, TLSCompressed.length,
+ * SecurityParameters.mac_length, and padding_length.
+ *
+ * Example: If the block length is 8 bytes, the content length
+ * (TLSCompressed.length) is 61 bytes, and the MAC length is 20 bytes, then the
+ * length before padding is 82 bytes (this does not include the IV. Thus, the
+ * padding length modulo 8 must be equal to 6 in order to make the total length
+ * an even multiple of 8 bytes (the block length). The padding length can be
+ * 6, 14, 22, and so on, through 254. If the padding length were the minimum
+ * necessary, 6, the padding would be 6 bytes, each containing the value 6.
+ * Thus, the last 8 octets of the GenericBlockCipher before block encryption
+ * would be xx 06 06 06 06 06 06 06, where xx is the last octet of the MAC.
+ *
+ * Note: With block ciphers in CBC mode (Cipher Block Chaining), it is critical
+ * that the entire plaintext of the record be known before any ciphertext is
+ * transmitted. Otherwise, it is possible for the attacker to mount the attack
+ * described in [CBCATT].
+ *
+ * Implementation note: Canvel et al. [CBCTIME] have demonstrated a timing
+ * attack on CBC padding based on the time required to compute the MAC. In
+ * order to defend against this attack, implementations MUST ensure that
+ * record processing time is essentially the same whether or not the padding
+ * is correct. In general, the best way to do this is to compute the MAC even
+ * if the padding is incorrect, and only then reject the packet. For instance,
+ * if the pad appears to be incorrect, the implementation might assume a
+ * zero-length pad and then compute the MAC. This leaves a small timing
+ * channel, since MAC performance depends, to some extent, on the size of the
+ * data fragment, but it is not believed to be large enough to be exploitable,
+ * due to the large block size of existing MACs and the small size of the
+ * timing signal.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+/**
+ * Generates pseudo random bytes by mixing the result of two hash functions,
+ * MD5 and SHA-1.
+ *
+ * prf_TLS1(secret, label, seed) =
+ * P_MD5(S1, label + seed) XOR P_SHA-1(S2, label + seed);
+ *
+ * Each P_hash function functions as follows:
+ *
+ * P_hash(secret, seed) = HMAC_hash(secret, A(1) + seed) +
+ * HMAC_hash(secret, A(2) + seed) +
+ * HMAC_hash(secret, A(3) + seed) + ...
+ * A() is defined as:
+ * A(0) = seed
+ * A(i) = HMAC_hash(secret, A(i-1))
+ *
+ * The '+' operator denotes concatenation.
+ *
+ * As many iterations A(N) as are needed are performed to generate enough
+ * pseudo random byte output. If an iteration creates more data than is
+ * necessary, then it is truncated.
+ *
+ * Therefore:
+ * A(1) = HMAC_hash(secret, A(0))
+ * = HMAC_hash(secret, seed)
+ * A(2) = HMAC_hash(secret, A(1))
+ * = HMAC_hash(secret, HMAC_hash(secret, seed))
+ *
+ * Therefore:
+ * P_hash(secret, seed) =
+ * HMAC_hash(secret, HMAC_hash(secret, A(0)) + seed) +
+ * HMAC_hash(secret, HMAC_hash(secret, A(1)) + seed) +
+ * ...
+ *
+ * Therefore:
+ * P_hash(secret, seed) =
+ * HMAC_hash(secret, HMAC_hash(secret, seed) + seed) +
+ * HMAC_hash(secret, HMAC_hash(secret, HMAC_hash(secret, seed)) + seed) +
+ * ...
+ *
+ * @param secret the secret to use.
+ * @param label the label to use.
+ * @param seed the seed value to use.
+ * @param length the number of bytes to generate.
+ *
+ * @return the pseudo random bytes in a byte buffer.
+ */
+var prf_TLS1 = function(secret, label, seed, length) {
+ var rval = forge.util.createBuffer();
+
+ /* For TLS 1.0, the secret is split in half, into two secrets of equal
+ length. If the secret has an odd length then the last byte of the first
+ half will be the same as the first byte of the second. The length of the
+ two secrets is half of the secret rounded up. */
+ var idx = (secret.length >> 1);
+ var slen = idx + (secret.length & 1);
+ var s1 = secret.substr(0, slen);
+ var s2 = secret.substr(idx, slen);
+ var ai = forge.util.createBuffer();
+ var hmac = forge.hmac.create();
+ seed = label + seed;
+
+ // determine the number of iterations that must be performed to generate
+ // enough output bytes, md5 creates 16 byte hashes, sha1 creates 20
+ var md5itr = Math.ceil(length / 16);
+ var sha1itr = Math.ceil(length / 20);
+
+ // do md5 iterations
+ hmac.start('MD5', s1);
+ var md5bytes = forge.util.createBuffer();
+ ai.putBytes(seed);
+ for(var i = 0; i < md5itr; ++i) {
+ // HMAC_hash(secret, A(i-1))
+ hmac.start(null, null);
+ hmac.update(ai.getBytes());
+ ai.putBuffer(hmac.digest());
+
+ // HMAC_hash(secret, A(i) + seed)
+ hmac.start(null, null);
+ hmac.update(ai.bytes() + seed);
+ md5bytes.putBuffer(hmac.digest());
+ }
+
+ // do sha1 iterations
+ hmac.start('SHA1', s2);
+ var sha1bytes = forge.util.createBuffer();
+ ai.clear();
+ ai.putBytes(seed);
+ for(var i = 0; i < sha1itr; ++i) {
+ // HMAC_hash(secret, A(i-1))
+ hmac.start(null, null);
+ hmac.update(ai.getBytes());
+ ai.putBuffer(hmac.digest());
+
+ // HMAC_hash(secret, A(i) + seed)
+ hmac.start(null, null);
+ hmac.update(ai.bytes() + seed);
+ sha1bytes.putBuffer(hmac.digest());
+ }
+
+ // XOR the md5 bytes with the sha1 bytes
+ rval.putBytes(forge.util.xorBytes(
+ md5bytes.getBytes(), sha1bytes.getBytes(), length));
+
+ return rval;
+};
+
+/**
+ * Generates pseudo random bytes using a SHA256 algorithm. For TLS 1.2.
+ *
+ * @param secret the secret to use.
+ * @param label the label to use.
+ * @param seed the seed value to use.
+ * @param length the number of bytes to generate.
+ *
+ * @return the pseudo random bytes in a byte buffer.
+ */
+var prf_sha256 = function(secret, label, seed, length) {
+ // FIXME: implement me for TLS 1.2
+};
+
+/**
+ * Gets a MAC for a record using the SHA-1 hash algorithm.
+ *
+ * @param key the mac key.
+ * @param state the sequence number (array of two 32-bit integers).
+ * @param record the record.
+ *
+ * @return the sha-1 hash (20 bytes) for the given record.
+ */
+var hmac_sha1 = function(key, seqNum, record) {
+ /* MAC is computed like so:
+ HMAC_hash(
+ key, seqNum +
+ TLSCompressed.type +
+ TLSCompressed.version +
+ TLSCompressed.length +
+ TLSCompressed.fragment)
+ */
+ var hmac = forge.hmac.create();
+ hmac.start('SHA1', key);
+ var b = forge.util.createBuffer();
+ b.putInt32(seqNum[0]);
+ b.putInt32(seqNum[1]);
+ b.putByte(record.type);
+ b.putByte(record.version.major);
+ b.putByte(record.version.minor);
+ b.putInt16(record.length);
+ b.putBytes(record.fragment.bytes());
+ hmac.update(b.getBytes());
+ return hmac.digest().getBytes();
+};
+
+/**
+ * Compresses the TLSPlaintext record into a TLSCompressed record using the
+ * deflate algorithm.
+ *
+ * @param c the TLS connection.
+ * @param record the TLSPlaintext record to compress.
+ * @param s the ConnectionState to use.
+ *
+ * @return true on success, false on failure.
+ */
+var deflate = function(c, record, s) {
+ var rval = false;
+
+ try {
+ var bytes = c.deflate(record.fragment.getBytes());
+ record.fragment = forge.util.createBuffer(bytes);
+ record.length = bytes.length;
+ rval = true;
+ } catch(ex) {
+ // deflate error, fail out
+ }
+
+ return rval;
+};
+
+/**
+ * Decompresses the TLSCompressed record into a TLSPlaintext record using the
+ * deflate algorithm.
+ *
+ * @param c the TLS connection.
+ * @param record the TLSCompressed record to decompress.
+ * @param s the ConnectionState to use.
+ *
+ * @return true on success, false on failure.
+ */
+var inflate = function(c, record, s) {
+ var rval = false;
+
+ try {
+ var bytes = c.inflate(record.fragment.getBytes());
+ record.fragment = forge.util.createBuffer(bytes);
+ record.length = bytes.length;
+ rval = true;
+ } catch(ex) {
+ // inflate error, fail out
+ }
+
+ return rval;
+};
+
+/**
+ * Reads a TLS variable-length vector from a byte buffer.
+ *
+ * Variable-length vectors are defined by specifying a subrange of legal
+ * lengths, inclusively, using the notation <floor..ceiling>. When these are
+ * encoded, the actual length precedes the vector's contents in the byte
+ * stream. The length will be in the form of a number consuming as many bytes
+ * as required to hold the vector's specified maximum (ceiling) length. A
+ * variable-length vector with an actual length field of zero is referred to
+ * as an empty vector.
+ *
+ * @param b the byte buffer.
+ * @param lenBytes the number of bytes required to store the length.
+ *
+ * @return the resulting byte buffer.
+ */
+var readVector = function(b, lenBytes) {
+ var len = 0;
+ switch(lenBytes) {
+ case 1:
+ len = b.getByte();
+ break;
+ case 2:
+ len = b.getInt16();
+ break;
+ case 3:
+ len = b.getInt24();
+ break;
+ case 4:
+ len = b.getInt32();
+ break;
+ }
+
+ // read vector bytes into a new buffer
+ return forge.util.createBuffer(b.getBytes(len));
+};
+
+/**
+ * Writes a TLS variable-length vector to a byte buffer.
+ *
+ * @param b the byte buffer.
+ * @param lenBytes the number of bytes required to store the length.
+ * @param v the byte buffer vector.
+ */
+var writeVector = function(b, lenBytes, v) {
+ // encode length at the start of the vector, where the number of bytes for
+ // the length is the maximum number of bytes it would take to encode the
+ // vector's ceiling
+ b.putInt(v.length(), lenBytes << 3);
+ b.putBuffer(v);
+};
+
+/**
+ * The tls implementation.
+ */
+var tls = {};
+
+/**
+ * Version: TLS 1.2 = 3.3, TLS 1.1 = 3.2, TLS 1.0 = 3.1. Both TLS 1.1 and
+ * TLS 1.2 were still too new (ie: openSSL didn't implement them) at the time
+ * of this implementation so TLS 1.0 was implemented instead.
+ */
+tls.Versions = {
+ TLS_1_0: {major: 3, minor: 1},
+ TLS_1_1: {major: 3, minor: 2},
+ TLS_1_2: {major: 3, minor: 3}
+};
+tls.SupportedVersions = [
+ tls.Versions.TLS_1_1,
+ tls.Versions.TLS_1_0
+];
+tls.Version = tls.SupportedVersions[0];
+
+/**
+ * Maximum fragment size. True maximum is 16384, but we fragment before that
+ * to allow for unusual small increases during compression.
+ */
+tls.MaxFragment = 16384 - 1024;
+
+/**
+ * Whether this entity is considered the "client" or "server".
+ * enum { server, client } ConnectionEnd;
+ */
+tls.ConnectionEnd = {
+ server: 0,
+ client: 1
+};
+
+/**
+ * Pseudo-random function algorithm used to generate keys from the master
+ * secret.
+ * enum { tls_prf_sha256 } PRFAlgorithm;
+ */
+tls.PRFAlgorithm = {
+ tls_prf_sha256: 0
+};
+
+/**
+ * Bulk encryption algorithms.
+ * enum { null, rc4, des3, aes } BulkCipherAlgorithm;
+ */
+tls.BulkCipherAlgorithm = {
+ none: null,
+ rc4: 0,
+ des3: 1,
+ aes: 2
+};
+
+/**
+ * Cipher types.
+ * enum { stream, block, aead } CipherType;
+ */
+tls.CipherType = {
+ stream: 0,
+ block: 1,
+ aead: 2
+};
+
+/**
+ * MAC (Message Authentication Code) algorithms.
+ * enum { null, hmac_md5, hmac_sha1, hmac_sha256,
+ * hmac_sha384, hmac_sha512} MACAlgorithm;
+ */
+tls.MACAlgorithm = {
+ none: null,
+ hmac_md5: 0,
+ hmac_sha1: 1,
+ hmac_sha256: 2,
+ hmac_sha384: 3,
+ hmac_sha512: 4
+};
+
+/**
+ * Compression algorithms.
+ * enum { null(0), deflate(1), (255) } CompressionMethod;
+ */
+tls.CompressionMethod = {
+ none: 0,
+ deflate: 1
+};
+
+/**
+ * TLS record content types.
+ * enum {
+ * change_cipher_spec(20), alert(21), handshake(22),
+ * application_data(23), (255)
+ * } ContentType;
+ */
+tls.ContentType = {
+ change_cipher_spec: 20,
+ alert: 21,
+ handshake: 22,
+ application_data: 23,
+ heartbeat: 24
+};
+
+/**
+ * TLS handshake types.
+ * enum {
+ * hello_request(0), client_hello(1), server_hello(2),
+ * certificate(11), server_key_exchange (12),
+ * certificate_request(13), server_hello_done(14),
+ * certificate_verify(15), client_key_exchange(16),
+ * finished(20), (255)
+ * } HandshakeType;
+ */
+tls.HandshakeType = {
+ hello_request: 0,
+ client_hello: 1,
+ server_hello: 2,
+ certificate: 11,
+ server_key_exchange: 12,
+ certificate_request: 13,
+ server_hello_done: 14,
+ certificate_verify: 15,
+ client_key_exchange: 16,
+ finished: 20
+};
+
+/**
+ * TLS Alert Protocol.
+ *
+ * enum { warning(1), fatal(2), (255) } AlertLevel;
+ *
+ * enum {
+ * close_notify(0),
+ * unexpected_message(10),
+ * bad_record_mac(20),
+ * decryption_failed(21),
+ * record_overflow(22),
+ * decompression_failure(30),
+ * handshake_failure(40),
+ * bad_certificate(42),
+ * unsupported_certificate(43),
+ * certificate_revoked(44),
+ * certificate_expired(45),
+ * certificate_unknown(46),
+ * illegal_parameter(47),
+ * unknown_ca(48),
+ * access_denied(49),
+ * decode_error(50),
+ * decrypt_error(51),
+ * export_restriction(60),
+ * protocol_version(70),
+ * insufficient_security(71),
+ * internal_error(80),
+ * user_canceled(90),
+ * no_renegotiation(100),
+ * (255)
+ * } AlertDescription;
+ *
+ * struct {
+ * AlertLevel level;
+ * AlertDescription description;
+ * } Alert;
+ */
+tls.Alert = {};
+tls.Alert.Level = {
+ warning: 1,
+ fatal: 2
+};
+tls.Alert.Description = {
+ close_notify: 0,
+ unexpected_message: 10,
+ bad_record_mac: 20,
+ decryption_failed: 21,
+ record_overflow: 22,
+ decompression_failure: 30,
+ handshake_failure: 40,
+ bad_certificate: 42,
+ unsupported_certificate: 43,
+ certificate_revoked: 44,
+ certificate_expired: 45,
+ certificate_unknown: 46,
+ illegal_parameter: 47,
+ unknown_ca: 48,
+ access_denied: 49,
+ decode_error: 50,
+ decrypt_error: 51,
+ export_restriction: 60,
+ protocol_version: 70,
+ insufficient_security: 71,
+ internal_error: 80,
+ user_canceled: 90,
+ no_renegotiation: 100
+};
+
+/**
+ * TLS Heartbeat Message types.
+ * enum {
+ * heartbeat_request(1),
+ * heartbeat_response(2),
+ * (255)
+ * } HeartbeatMessageType;
+ */
+tls.HeartbeatMessageType = {
+ heartbeat_request: 1,
+ heartbeat_response: 2
+};
+
+/**
+ * Supported cipher suites.
+ */
+tls.CipherSuites = {};
+
+/**
+ * Gets a supported cipher suite from its 2 byte ID.
+ *
+ * @param twoBytes two bytes in a string.
+ *
+ * @return the matching supported cipher suite or null.
+ */
+tls.getCipherSuite = function(twoBytes) {
+ var rval = null;
+ for(var key in tls.CipherSuites) {
+ var cs = tls.CipherSuites[key];
+ if(cs.id[0] === twoBytes.charCodeAt(0) &&
+ cs.id[1] === twoBytes.charCodeAt(1)) {
+ rval = cs;
+ break;
+ }
+ }
+ return rval;
+};
+
+/**
+ * Called when an unexpected record is encountered.
+ *
+ * @param c the connection.
+ * @param record the record.
+ */
+tls.handleUnexpected = function(c, record) {
+ // if connection is client and closed, ignore unexpected messages
+ var ignore = (!c.open && c.entity === tls.ConnectionEnd.client);
+ if(!ignore) {
+ c.error(c, {
+ message: 'Unexpected message. Received TLS record out of order.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.unexpected_message
+ }
+ });
+ }
+};
+
+/**
+ * Called when a client receives a HelloRequest record.
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleHelloRequest = function(c, record, length) {
+ // ignore renegotiation requests from the server during a handshake, but
+ // if handshaking, send a warning alert that renegotation is denied
+ if(!c.handshaking && c.handshakes > 0) {
+ // send alert warning
+ tls.queue(c, tls.createAlert(c, {
+ level: tls.Alert.Level.warning,
+ description: tls.Alert.Description.no_renegotiation
+ }));
+ tls.flush(c);
+ }
+
+ // continue
+ c.process();
+};
+
+/**
+ * Parses a hello message from a ClientHello or ServerHello record.
+ *
+ * @param record the record to parse.
+ *
+ * @return the parsed message.
+ */
+tls.parseHelloMessage = function(c, record, length) {
+ var msg = null;
+
+ var client = (c.entity === tls.ConnectionEnd.client);
+
+ // minimum of 38 bytes in message
+ if(length < 38) {
+ c.error(c, {
+ message: client ?
+ 'Invalid ServerHello message. Message too short.' :
+ 'Invalid ClientHello message. Message too short.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.illegal_parameter
+ }
+ });
+ } else {
+ // use 'remaining' to calculate # of remaining bytes in the message
+ var b = record.fragment;
+ var remaining = b.length();
+ msg = {
+ version: {
+ major: b.getByte(),
+ minor: b.getByte()
+ },
+ random: forge.util.createBuffer(b.getBytes(32)),
+ session_id: readVector(b, 1),
+ extensions: []
+ };
+ if(client) {
+ msg.cipher_suite = b.getBytes(2);
+ msg.compression_method = b.getByte();
+ } else {
+ msg.cipher_suites = readVector(b, 2);
+ msg.compression_methods = readVector(b, 1);
+ }
+
+ // read extensions if there are any bytes left in the message
+ remaining = length - (remaining - b.length());
+ if(remaining > 0) {
+ // parse extensions
+ var exts = readVector(b, 2);
+ while(exts.length() > 0) {
+ msg.extensions.push({
+ type: [exts.getByte(), exts.getByte()],
+ data: readVector(exts, 2)
+ });
+ }
+
+ // TODO: make extension support modular
+ if(!client) {
+ for(var i = 0; i < msg.extensions.length; ++i) {
+ var ext = msg.extensions[i];
+
+ // support SNI extension
+ if(ext.type[0] === 0x00 && ext.type[1] === 0x00) {
+ // get server name list
+ var snl = readVector(ext.data, 2);
+ while(snl.length() > 0) {
+ // read server name type
+ var snType = snl.getByte();
+
+ // only HostName type (0x00) is known, break out if
+ // another type is detected
+ if(snType !== 0x00) {
+ break;
+ }
+
+ // add host name to server name list
+ c.session.extensions.server_name.serverNameList.push(
+ readVector(snl, 2).getBytes());
+ }
+ }
+ }
+ }
+ }
+
+ // version already set, do not allow version change
+ if(c.session.version) {
+ if(msg.version.major !== c.session.version.major ||
+ msg.version.minor !== c.session.version.minor) {
+ return c.error(c, {
+ message: 'TLS version change is disallowed during renegotiation.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.protocol_version
+ }
+ });
+ }
+ }
+
+ // get the chosen (ServerHello) cipher suite
+ if(client) {
+ // FIXME: should be checking configured acceptable cipher suites
+ c.session.cipherSuite = tls.getCipherSuite(msg.cipher_suite);
+ } else {
+ // get a supported preferred (ClientHello) cipher suite
+ // choose the first supported cipher suite
+ var tmp = forge.util.createBuffer(msg.cipher_suites.bytes());
+ while(tmp.length() > 0) {
+ // FIXME: should be checking configured acceptable suites
+ // cipher suites take up 2 bytes
+ c.session.cipherSuite = tls.getCipherSuite(tmp.getBytes(2));
+ if(c.session.cipherSuite !== null) {
+ break;
+ }
+ }
+ }
+
+ // cipher suite not supported
+ if(c.session.cipherSuite === null) {
+ return c.error(c, {
+ message: 'No cipher suites in common.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.handshake_failure
+ },
+ cipherSuite: forge.util.bytesToHex(msg.cipher_suite)
+ });
+ }
+
+ // TODO: handle compression methods
+ if(client) {
+ c.session.compressionMethod = msg.compression_method;
+ } else {
+ // no compression
+ c.session.compressionMethod = tls.CompressionMethod.none;
+ }
+ }
+
+ return msg;
+};
+
+/**
+ * Creates security parameters for the given connection based on the given
+ * hello message.
+ *
+ * @param c the TLS connection.
+ * @param msg the hello message.
+ */
+tls.createSecurityParameters = function(c, msg) {
+ /* Note: security params are from TLS 1.2, some values like prf_algorithm
+ are ignored for TLS 1.0/1.1 and the builtin as specified in the spec is
+ used. */
+
+ // TODO: handle other options from server when more supported
+
+ // get client and server randoms
+ var client = (c.entity === tls.ConnectionEnd.client);
+ var msgRandom = msg.random.bytes();
+ var cRandom = client ? c.session.sp.client_random : msgRandom;
+ var sRandom = client ? msgRandom : tls.createRandom().getBytes();
+
+ // create new security parameters
+ c.session.sp = {
+ entity: c.entity,
+ prf_algorithm: tls.PRFAlgorithm.tls_prf_sha256,
+ bulk_cipher_algorithm: null,
+ cipher_type: null,
+ enc_key_length: null,
+ block_length: null,
+ fixed_iv_length: null,
+ record_iv_length: null,
+ mac_algorithm: null,
+ mac_length: null,
+ mac_key_length: null,
+ compression_algorithm: c.session.compressionMethod,
+ pre_master_secret: null,
+ master_secret: null,
+ client_random: cRandom,
+ server_random: sRandom
+ };
+};
+
+/**
+ * Called when a client receives a ServerHello record.
+ *
+ * When a ServerHello message will be sent:
+ * The server will send this message in response to a client hello message
+ * when it was able to find an acceptable set of algorithms. If it cannot
+ * find such a match, it will respond with a handshake failure alert.
+ *
+ * uint24 length;
+ * struct {
+ * ProtocolVersion server_version;
+ * Random random;
+ * SessionID session_id;
+ * CipherSuite cipher_suite;
+ * CompressionMethod compression_method;
+ * select(extensions_present) {
+ * case false:
+ * struct {};
+ * case true:
+ * Extension extensions<0..2^16-1>;
+ * };
+ * } ServerHello;
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleServerHello = function(c, record, length) {
+ var msg = tls.parseHelloMessage(c, record, length);
+ if(c.fail) {
+ return;
+ }
+
+ // ensure server version is compatible
+ if(msg.version.minor <= c.version.minor) {
+ c.version.minor = msg.version.minor;
+ } else {
+ return c.error(c, {
+ message: 'Incompatible TLS version.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.protocol_version
+ }
+ });
+ }
+
+ // indicate session version has been set
+ c.session.version = c.version;
+
+ // get the session ID from the message
+ var sessionId = msg.session_id.bytes();
+
+ // if the session ID is not blank and matches the cached one, resume
+ // the session
+ if(sessionId.length > 0 && sessionId === c.session.id) {
+ // resuming session, expect a ChangeCipherSpec next
+ c.expect = SCC;
+ c.session.resuming = true;
+
+ // get new server random
+ c.session.sp.server_random = msg.random.bytes();
+ } else {
+ // not resuming, expect a server Certificate message next
+ c.expect = SCE;
+ c.session.resuming = false;
+
+ // create new security parameters
+ tls.createSecurityParameters(c, msg);
+ }
+
+ // set new session ID
+ c.session.id = sessionId;
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a server receives a ClientHello record.
+ *
+ * When a ClientHello message will be sent:
+ * When a client first connects to a server it is required to send the
+ * client hello as its first message. The client can also send a client
+ * hello in response to a hello request or on its own initiative in order
+ * to renegotiate the security parameters in an existing connection.
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleClientHello = function(c, record, length) {
+ var msg = tls.parseHelloMessage(c, record, length);
+ if(c.fail) {
+ return;
+ }
+
+ // get the session ID from the message
+ var sessionId = msg.session_id.bytes();
+
+ // see if the given session ID is in the cache
+ var session = null;
+ if(c.sessionCache) {
+ session = c.sessionCache.getSession(sessionId);
+ if(session === null) {
+ // session ID not found
+ sessionId = '';
+ } else if(session.version.major !== msg.version.major ||
+ session.version.minor > msg.version.minor) {
+ // if session version is incompatible with client version, do not resume
+ session = null;
+ sessionId = '';
+ }
+ }
+
+ // no session found to resume, generate a new session ID
+ if(sessionId.length === 0) {
+ sessionId = forge.random.getBytes(32);
+ }
+
+ // update session
+ c.session.id = sessionId;
+ c.session.clientHelloVersion = msg.version;
+ c.session.sp = {};
+ if(session) {
+ // use version and security parameters from resumed session
+ c.version = c.session.version = session.version;
+ c.session.sp = session.sp;
+ } else {
+ // use highest compatible minor version
+ var version;
+ for(var i = 1; i < tls.SupportedVersions.length; ++i) {
+ version = tls.SupportedVersions[i];
+ if(version.minor <= msg.version.minor) {
+ break;
+ }
+ }
+ c.version = {major: version.major, minor: version.minor};
+ c.session.version = c.version;
+ }
+
+ // if a session is set, resume it
+ if(session !== null) {
+ // resuming session, expect a ChangeCipherSpec next
+ c.expect = CCC;
+ c.session.resuming = true;
+
+ // get new client random
+ c.session.sp.client_random = msg.random.bytes();
+ } else {
+ // not resuming, expect a Certificate or ClientKeyExchange
+ c.expect = (c.verifyClient !== false) ? CCE : CKE;
+ c.session.resuming = false;
+
+ // create new security parameters
+ tls.createSecurityParameters(c, msg);
+ }
+
+ // connection now open
+ c.open = true;
+
+ // queue server hello
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createServerHello(c)
+ }));
+
+ if(c.session.resuming) {
+ // queue change cipher spec message
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.change_cipher_spec,
+ data: tls.createChangeCipherSpec()
+ }));
+
+ // create pending state
+ c.state.pending = tls.createConnectionState(c);
+
+ // change current write state to pending write state
+ c.state.current.write = c.state.pending.write;
+
+ // queue finished
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createFinished(c)
+ }));
+ } else {
+ // queue server certificate
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createCertificate(c)
+ }));
+
+ if(!c.fail) {
+ // queue server key exchange
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createServerKeyExchange(c)
+ }));
+
+ // request client certificate if set
+ if(c.verifyClient !== false) {
+ // queue certificate request
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createCertificateRequest(c)
+ }));
+ }
+
+ // queue server hello done
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createServerHelloDone(c)
+ }));
+ }
+ }
+
+ // send records
+ tls.flush(c);
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a client receives a Certificate record.
+ *
+ * When this message will be sent:
+ * The server must send a certificate whenever the agreed-upon key exchange
+ * method is not an anonymous one. This message will always immediately
+ * follow the server hello message.
+ *
+ * Meaning of this message:
+ * The certificate type must be appropriate for the selected cipher suite's
+ * key exchange algorithm, and is generally an X.509v3 certificate. It must
+ * contain a key which matches the key exchange method, as follows. Unless
+ * otherwise specified, the signing algorithm for the certificate must be
+ * the same as the algorithm for the certificate key. Unless otherwise
+ * specified, the public key may be of any length.
+ *
+ * opaque ASN.1Cert<1..2^24-1>;
+ * struct {
+ * ASN.1Cert certificate_list<1..2^24-1>;
+ * } Certificate;
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleCertificate = function(c, record, length) {
+ // minimum of 3 bytes in message
+ if(length < 3) {
+ return c.error(c, {
+ message: 'Invalid Certificate message. Message too short.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.illegal_parameter
+ }
+ });
+ }
+
+ var b = record.fragment;
+ var msg = {
+ certificate_list: readVector(b, 3)
+ };
+
+ /* The sender's certificate will be first in the list (chain), each
+ subsequent one that follows will certify the previous one, but root
+ certificates (self-signed) that specify the certificate authority may
+ be omitted under the assumption that clients must already possess it. */
+ var cert, asn1;
+ var certs = [];
+ try {
+ while(msg.certificate_list.length() > 0) {
+ // each entry in msg.certificate_list is a vector with 3 len bytes
+ cert = readVector(msg.certificate_list, 3);
+ asn1 = forge.asn1.fromDer(cert);
+ cert = forge.pki.certificateFromAsn1(asn1, true);
+ certs.push(cert);
+ }
+ } catch(ex) {
+ return c.error(c, {
+ message: 'Could not parse certificate list.',
+ cause: ex,
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.bad_certificate
+ }
+ });
+ }
+
+ // ensure at least 1 certificate was provided if in client-mode
+ // or if verifyClient was set to true to require a certificate
+ // (as opposed to 'optional')
+ var client = (c.entity === tls.ConnectionEnd.client);
+ if((client || c.verifyClient === true) && certs.length === 0) {
+ // error, no certificate
+ c.error(c, {
+ message: client ?
+ 'No server certificate provided.' :
+ 'No client certificate provided.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.illegal_parameter
+ }
+ });
+ } else if(certs.length === 0) {
+ // no certs to verify
+ // expect a ServerKeyExchange or ClientKeyExchange message next
+ c.expect = client ? SKE : CKE;
+ } else {
+ // save certificate in session
+ if(client) {
+ c.session.serverCertificate = certs[0];
+ } else {
+ c.session.clientCertificate = certs[0];
+ }
+
+ if(tls.verifyCertificateChain(c, certs)) {
+ // expect a ServerKeyExchange or ClientKeyExchange message next
+ c.expect = client ? SKE : CKE;
+ }
+ }
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a client receives a ServerKeyExchange record.
+ *
+ * When this message will be sent:
+ * This message will be sent immediately after the server certificate
+ * message (or the server hello message, if this is an anonymous
+ * negotiation).
+ *
+ * The server key exchange message is sent by the server only when the
+ * server certificate message (if sent) does not contain enough data to
+ * allow the client to exchange a premaster secret.
+ *
+ * Meaning of this message:
+ * This message conveys cryptographic information to allow the client to
+ * communicate the premaster secret: either an RSA public key to encrypt
+ * the premaster secret with, or a Diffie-Hellman public key with which the
+ * client can complete a key exchange (with the result being the premaster
+ * secret.)
+ *
+ * enum {
+ * dhe_dss, dhe_rsa, dh_anon, rsa, dh_dss, dh_rsa
+ * } KeyExchangeAlgorithm;
+ *
+ * struct {
+ * opaque dh_p<1..2^16-1>;
+ * opaque dh_g<1..2^16-1>;
+ * opaque dh_Ys<1..2^16-1>;
+ * } ServerDHParams;
+ *
+ * struct {
+ * select(KeyExchangeAlgorithm) {
+ * case dh_anon:
+ * ServerDHParams params;
+ * case dhe_dss:
+ * case dhe_rsa:
+ * ServerDHParams params;
+ * digitally-signed struct {
+ * opaque client_random[32];
+ * opaque server_random[32];
+ * ServerDHParams params;
+ * } signed_params;
+ * case rsa:
+ * case dh_dss:
+ * case dh_rsa:
+ * struct {};
+ * };
+ * } ServerKeyExchange;
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleServerKeyExchange = function(c, record, length) {
+ // this implementation only supports RSA, no Diffie-Hellman support
+ // so any length > 0 is invalid
+ if(length > 0) {
+ return c.error(c, {
+ message: 'Invalid key parameters. Only RSA is supported.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.unsupported_certificate
+ }
+ });
+ }
+
+ // expect an optional CertificateRequest message next
+ c.expect = SCR;
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a client receives a ClientKeyExchange record.
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleClientKeyExchange = function(c, record, length) {
+ // this implementation only supports RSA, no Diffie-Hellman support
+ // so any length < 48 is invalid
+ if(length < 48) {
+ return c.error(c, {
+ message: 'Invalid key parameters. Only RSA is supported.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.unsupported_certificate
+ }
+ });
+ }
+
+ var b = record.fragment;
+ var msg = {
+ enc_pre_master_secret: readVector(b, 2).getBytes()
+ };
+
+ // do rsa decryption
+ var privateKey = null;
+ if(c.getPrivateKey) {
+ try {
+ privateKey = c.getPrivateKey(c, c.session.serverCertificate);
+ privateKey = forge.pki.privateKeyFromPem(privateKey);
+ } catch(ex) {
+ c.error(c, {
+ message: 'Could not get private key.',
+ cause: ex,
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.internal_error
+ }
+ });
+ }
+ }
+
+ if(privateKey === null) {
+ return c.error(c, {
+ message: 'No private key set.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.internal_error
+ }
+ });
+ }
+
+ try {
+ // decrypt 48-byte pre-master secret
+ var sp = c.session.sp;
+ sp.pre_master_secret = privateKey.decrypt(msg.enc_pre_master_secret);
+
+ // ensure client hello version matches first 2 bytes
+ var version = c.session.clientHelloVersion;
+ if(version.major !== sp.pre_master_secret.charCodeAt(0) ||
+ version.minor !== sp.pre_master_secret.charCodeAt(1)) {
+ // error, do not send alert (see BLEI attack below)
+ throw new Error('TLS version rollback attack detected.');
+ }
+ } catch(ex) {
+ /* Note: Daniel Bleichenbacher [BLEI] can be used to attack a
+ TLS server which is using PKCS#1 encoded RSA, so instead of
+ failing here, we generate 48 random bytes and use that as
+ the pre-master secret. */
+ sp.pre_master_secret = forge.random.getBytes(48);
+ }
+
+ // expect a CertificateVerify message if a Certificate was received that
+ // does not have fixed Diffie-Hellman params, otherwise expect
+ // ChangeCipherSpec
+ c.expect = CCC;
+ if(c.session.clientCertificate !== null) {
+ // only RSA support, so expect CertificateVerify
+ // TODO: support Diffie-Hellman
+ c.expect = CCV;
+ }
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a client receives a CertificateRequest record.
+ *
+ * When this message will be sent:
+ * A non-anonymous server can optionally request a certificate from the
+ * client, if appropriate for the selected cipher suite. This message, if
+ * sent, will immediately follow the Server Key Exchange message (if it is
+ * sent; otherwise, the Server Certificate message).
+ *
+ * enum {
+ * rsa_sign(1), dss_sign(2), rsa_fixed_dh(3), dss_fixed_dh(4),
+ * rsa_ephemeral_dh_RESERVED(5), dss_ephemeral_dh_RESERVED(6),
+ * fortezza_dms_RESERVED(20), (255)
+ * } ClientCertificateType;
+ *
+ * opaque DistinguishedName<1..2^16-1>;
+ *
+ * struct {
+ * ClientCertificateType certificate_types<1..2^8-1>;
+ * SignatureAndHashAlgorithm supported_signature_algorithms<2^16-1>;
+ * DistinguishedName certificate_authorities<0..2^16-1>;
+ * } CertificateRequest;
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleCertificateRequest = function(c, record, length) {
+ // minimum of 3 bytes in message
+ if(length < 3) {
+ return c.error(c, {
+ message: 'Invalid CertificateRequest. Message too short.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.illegal_parameter
+ }
+ });
+ }
+
+ // TODO: TLS 1.2+ has different format including
+ // SignatureAndHashAlgorithm after cert types
+ var b = record.fragment;
+ var msg = {
+ certificate_types: readVector(b, 1),
+ certificate_authorities: readVector(b, 2)
+ };
+
+ // save certificate request in session
+ c.session.certificateRequest = msg;
+
+ // expect a ServerHelloDone message next
+ c.expect = SHD;
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a server receives a CertificateVerify record.
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleCertificateVerify = function(c, record, length) {
+ if(length < 2) {
+ return c.error(c, {
+ message: 'Invalid CertificateVerify. Message too short.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.illegal_parameter
+ }
+ });
+ }
+
+ // rewind to get full bytes for message so it can be manually
+ // digested below (special case for CertificateVerify messages because
+ // they must be digested *after* handling as opposed to all others)
+ var b = record.fragment;
+ b.read -= 4;
+ var msgBytes = b.bytes();
+ b.read += 4;
+
+ var msg = {
+ signature: readVector(b, 2).getBytes()
+ };
+
+ // TODO: add support for DSA
+
+ // generate data to verify
+ var verify = forge.util.createBuffer();
+ verify.putBuffer(c.session.md5.digest());
+ verify.putBuffer(c.session.sha1.digest());
+ verify = verify.getBytes();
+
+ try {
+ var cert = c.session.clientCertificate;
+ /*b = forge.pki.rsa.decrypt(
+ msg.signature, cert.publicKey, true, verify.length);
+ if(b !== verify) {*/
+ if(!cert.publicKey.verify(verify, msg.signature, 'NONE')) {
+ throw new Error('CertificateVerify signature does not match.');
+ }
+
+ // digest message now that it has been handled
+ c.session.md5.update(msgBytes);
+ c.session.sha1.update(msgBytes);
+ } catch(ex) {
+ return c.error(c, {
+ message: 'Bad signature in CertificateVerify.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.handshake_failure
+ }
+ });
+ }
+
+ // expect ChangeCipherSpec
+ c.expect = CCC;
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a client receives a ServerHelloDone record.
+ *
+ * When this message will be sent:
+ * The server hello done message is sent by the server to indicate the end
+ * of the server hello and associated messages. After sending this message
+ * the server will wait for a client response.
+ *
+ * Meaning of this message:
+ * This message means that the server is done sending messages to support
+ * the key exchange, and the client can proceed with its phase of the key
+ * exchange.
+ *
+ * Upon receipt of the server hello done message the client should verify
+ * that the server provided a valid certificate if required and check that
+ * the server hello parameters are acceptable.
+ *
+ * struct {} ServerHelloDone;
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleServerHelloDone = function(c, record, length) {
+ // len must be 0 bytes
+ if(length > 0) {
+ return c.error(c, {
+ message: 'Invalid ServerHelloDone message. Invalid length.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.record_overflow
+ }
+ });
+ }
+
+ if(c.serverCertificate === null) {
+ // no server certificate was provided
+ var error = {
+ message: 'No server certificate provided. Not enough security.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.insufficient_security
+ }
+ };
+
+ // call application callback
+ var depth = 0;
+ var ret = c.verify(c, error.alert.description, depth, []);
+ if(ret !== true) {
+ // check for custom alert info
+ if(ret || ret === 0) {
+ // set custom message and alert description
+ if(typeof ret === 'object' && !forge.util.isArray(ret)) {
+ if(ret.message) {
+ error.message = ret.message;
+ }
+ if(ret.alert) {
+ error.alert.description = ret.alert;
+ }
+ } else if(typeof ret === 'number') {
+ // set custom alert description
+ error.alert.description = ret;
+ }
+ }
+
+ // send error
+ return c.error(c, error);
+ }
+ }
+
+ // create client certificate message if requested
+ if(c.session.certificateRequest !== null) {
+ record = tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createCertificate(c)
+ });
+ tls.queue(c, record);
+ }
+
+ // create client key exchange message
+ record = tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createClientKeyExchange(c)
+ });
+ tls.queue(c, record);
+
+ // expect no messages until the following callback has been called
+ c.expect = SER;
+
+ // create callback to handle client signature (for client-certs)
+ var callback = function(c, signature) {
+ if(c.session.certificateRequest !== null &&
+ c.session.clientCertificate !== null) {
+ // create certificate verify message
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createCertificateVerify(c, signature)
+ }));
+ }
+
+ // create change cipher spec message
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.change_cipher_spec,
+ data: tls.createChangeCipherSpec()
+ }));
+
+ // create pending state
+ c.state.pending = tls.createConnectionState(c);
+
+ // change current write state to pending write state
+ c.state.current.write = c.state.pending.write;
+
+ // create finished message
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createFinished(c)
+ }));
+
+ // expect a server ChangeCipherSpec message next
+ c.expect = SCC;
+
+ // send records
+ tls.flush(c);
+
+ // continue
+ c.process();
+ };
+
+ // if there is no certificate request or no client certificate, do
+ // callback immediately
+ if(c.session.certificateRequest === null ||
+ c.session.clientCertificate === null) {
+ return callback(c, null);
+ }
+
+ // otherwise get the client signature
+ tls.getClientSignature(c, callback);
+};
+
+/**
+ * Called when a ChangeCipherSpec record is received.
+ *
+ * @param c the connection.
+ * @param record the record.
+ */
+tls.handleChangeCipherSpec = function(c, record) {
+ if(record.fragment.getByte() !== 0x01) {
+ return c.error(c, {
+ message: 'Invalid ChangeCipherSpec message received.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.illegal_parameter
+ }
+ });
+ }
+
+ // create pending state if:
+ // 1. Resuming session in client mode OR
+ // 2. NOT resuming session in server mode
+ var client = (c.entity === tls.ConnectionEnd.client);
+ if((c.session.resuming && client) || (!c.session.resuming && !client)) {
+ c.state.pending = tls.createConnectionState(c);
+ }
+
+ // change current read state to pending read state
+ c.state.current.read = c.state.pending.read;
+
+ // clear pending state if:
+ // 1. NOT resuming session in client mode OR
+ // 2. resuming a session in server mode
+ if((!c.session.resuming && client) || (c.session.resuming && !client)) {
+ c.state.pending = null;
+ }
+
+ // expect a Finished record next
+ c.expect = client ? SFI : CFI;
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a Finished record is received.
+ *
+ * When this message will be sent:
+ * A finished message is always sent immediately after a change
+ * cipher spec message to verify that the key exchange and
+ * authentication processes were successful. It is essential that a
+ * change cipher spec message be received between the other
+ * handshake messages and the Finished message.
+ *
+ * Meaning of this message:
+ * The finished message is the first protected with the just-
+ * negotiated algorithms, keys, and secrets. Recipients of finished
+ * messages must verify that the contents are correct. Once a side
+ * has sent its Finished message and received and validated the
+ * Finished message from its peer, it may begin to send and receive
+ * application data over the connection.
+ *
+ * struct {
+ * opaque verify_data[verify_data_length];
+ * } Finished;
+ *
+ * verify_data
+ * PRF(master_secret, finished_label, Hash(handshake_messages))
+ * [0..verify_data_length-1];
+ *
+ * finished_label
+ * For Finished messages sent by the client, the string
+ * "client finished". For Finished messages sent by the server, the
+ * string "server finished".
+ *
+ * verify_data_length depends on the cipher suite. If it is not specified
+ * by the cipher suite, then it is 12. Versions of TLS < 1.2 always used
+ * 12 bytes.
+ *
+ * @param c the connection.
+ * @param record the record.
+ * @param length the length of the handshake message.
+ */
+tls.handleFinished = function(c, record, length) {
+ // rewind to get full bytes for message so it can be manually
+ // digested below (special case for Finished messages because they
+ // must be digested *after* handling as opposed to all others)
+ var b = record.fragment;
+ b.read -= 4;
+ var msgBytes = b.bytes();
+ b.read += 4;
+
+ // message contains only verify_data
+ var vd = record.fragment.getBytes();
+
+ // ensure verify data is correct
+ b = forge.util.createBuffer();
+ b.putBuffer(c.session.md5.digest());
+ b.putBuffer(c.session.sha1.digest());
+
+ // set label based on entity type
+ var client = (c.entity === tls.ConnectionEnd.client);
+ var label = client ? 'server finished' : 'client finished';
+
+ // TODO: determine prf function and verify length for TLS 1.2
+ var sp = c.session.sp;
+ var vdl = 12;
+ var prf = prf_TLS1;
+ b = prf(sp.master_secret, label, b.getBytes(), vdl);
+ if(b.getBytes() !== vd) {
+ return c.error(c, {
+ message: 'Invalid verify_data in Finished message.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.decrypt_error
+ }
+ });
+ }
+
+ // digest finished message now that it has been handled
+ c.session.md5.update(msgBytes);
+ c.session.sha1.update(msgBytes);
+
+ // resuming session as client or NOT resuming session as server
+ if((c.session.resuming && client) || (!c.session.resuming && !client)) {
+ // create change cipher spec message
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.change_cipher_spec,
+ data: tls.createChangeCipherSpec()
+ }));
+
+ // change current write state to pending write state, clear pending
+ c.state.current.write = c.state.pending.write;
+ c.state.pending = null;
+
+ // create finished message
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.handshake,
+ data: tls.createFinished(c)
+ }));
+ }
+
+ // expect application data next
+ c.expect = client ? SAD : CAD;
+
+ // handshake complete
+ c.handshaking = false;
+ ++c.handshakes;
+
+ // save access to peer certificate
+ c.peerCertificate = client ?
+ c.session.serverCertificate : c.session.clientCertificate;
+
+ // send records
+ tls.flush(c);
+
+ // now connected
+ c.isConnected = true;
+ c.connected(c);
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when an Alert record is received.
+ *
+ * @param c the connection.
+ * @param record the record.
+ */
+tls.handleAlert = function(c, record) {
+ // read alert
+ var b = record.fragment;
+ var alert = {
+ level: b.getByte(),
+ description: b.getByte()
+ };
+
+ // TODO: consider using a table?
+ // get appropriate message
+ var msg;
+ switch(alert.description) {
+ case tls.Alert.Description.close_notify:
+ msg = 'Connection closed.';
+ break;
+ case tls.Alert.Description.unexpected_message:
+ msg = 'Unexpected message.';
+ break;
+ case tls.Alert.Description.bad_record_mac:
+ msg = 'Bad record MAC.';
+ break;
+ case tls.Alert.Description.decryption_failed:
+ msg = 'Decryption failed.';
+ break;
+ case tls.Alert.Description.record_overflow:
+ msg = 'Record overflow.';
+ break;
+ case tls.Alert.Description.decompression_failure:
+ msg = 'Decompression failed.';
+ break;
+ case tls.Alert.Description.handshake_failure:
+ msg = 'Handshake failure.';
+ break;
+ case tls.Alert.Description.bad_certificate:
+ msg = 'Bad certificate.';
+ break;
+ case tls.Alert.Description.unsupported_certificate:
+ msg = 'Unsupported certificate.';
+ break;
+ case tls.Alert.Description.certificate_revoked:
+ msg = 'Certificate revoked.';
+ break;
+ case tls.Alert.Description.certificate_expired:
+ msg = 'Certificate expired.';
+ break;
+ case tls.Alert.Description.certificate_unknown:
+ msg = 'Certificate unknown.';
+ break;
+ case tls.Alert.Description.illegal_parameter:
+ msg = 'Illegal parameter.';
+ break;
+ case tls.Alert.Description.unknown_ca:
+ msg = 'Unknown certificate authority.';
+ break;
+ case tls.Alert.Description.access_denied:
+ msg = 'Access denied.';
+ break;
+ case tls.Alert.Description.decode_error:
+ msg = 'Decode error.';
+ break;
+ case tls.Alert.Description.decrypt_error:
+ msg = 'Decrypt error.';
+ break;
+ case tls.Alert.Description.export_restriction:
+ msg = 'Export restriction.';
+ break;
+ case tls.Alert.Description.protocol_version:
+ msg = 'Unsupported protocol version.';
+ break;
+ case tls.Alert.Description.insufficient_security:
+ msg = 'Insufficient security.';
+ break;
+ case tls.Alert.Description.internal_error:
+ msg = 'Internal error.';
+ break;
+ case tls.Alert.Description.user_canceled:
+ msg = 'User canceled.';
+ break;
+ case tls.Alert.Description.no_renegotiation:
+ msg = 'Renegotiation not supported.';
+ break;
+ default:
+ msg = 'Unknown error.';
+ break;
+ }
+
+ // close connection on close_notify, not an error
+ if(alert.description === tls.Alert.Description.close_notify) {
+ return c.close();
+ }
+
+ // call error handler
+ c.error(c, {
+ message: msg,
+ send: false,
+ // origin is the opposite end
+ origin: (c.entity === tls.ConnectionEnd.client) ? 'server' : 'client',
+ alert: alert
+ });
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a Handshake record is received.
+ *
+ * @param c the connection.
+ * @param record the record.
+ */
+tls.handleHandshake = function(c, record) {
+ // get the handshake type and message length
+ var b = record.fragment;
+ var type = b.getByte();
+ var length = b.getInt24();
+
+ // see if the record fragment doesn't yet contain the full message
+ if(length > b.length()) {
+ // cache the record, clear its fragment, and reset the buffer read
+ // pointer before the type and length were read
+ c.fragmented = record;
+ record.fragment = forge.util.createBuffer();
+ b.read -= 4;
+
+ // continue
+ return c.process();
+ }
+
+ // full message now available, clear cache, reset read pointer to
+ // before type and length
+ c.fragmented = null;
+ b.read -= 4;
+
+ // save the handshake bytes for digestion after handler is found
+ // (include type and length of handshake msg)
+ var bytes = b.bytes(length + 4);
+
+ // restore read pointer
+ b.read += 4;
+
+ // handle expected message
+ if(type in hsTable[c.entity][c.expect]) {
+ // initialize server session
+ if(c.entity === tls.ConnectionEnd.server && !c.open && !c.fail) {
+ c.handshaking = true;
+ c.session = {
+ version: null,
+ extensions: {
+ server_name: {
+ serverNameList: []
+ }
+ },
+ cipherSuite: null,
+ compressionMethod: null,
+ serverCertificate: null,
+ clientCertificate: null,
+ md5: forge.md.md5.create(),
+ sha1: forge.md.sha1.create()
+ };
+ }
+
+ /* Update handshake messages digest. Finished and CertificateVerify
+ messages are not digested here. They can't be digested as part of
+ the verify_data that they contain. These messages are manually
+ digested in their handlers. HelloRequest messages are simply never
+ included in the handshake message digest according to spec. */
+ if(type !== tls.HandshakeType.hello_request &&
+ type !== tls.HandshakeType.certificate_verify &&
+ type !== tls.HandshakeType.finished) {
+ c.session.md5.update(bytes);
+ c.session.sha1.update(bytes);
+ }
+
+ // handle specific handshake type record
+ hsTable[c.entity][c.expect][type](c, record, length);
+ } else {
+ // unexpected record
+ tls.handleUnexpected(c, record);
+ }
+};
+
+/**
+ * Called when an ApplicationData record is received.
+ *
+ * @param c the connection.
+ * @param record the record.
+ */
+tls.handleApplicationData = function(c, record) {
+ // buffer data, notify that its ready
+ c.data.putBuffer(record.fragment);
+ c.dataReady(c);
+
+ // continue
+ c.process();
+};
+
+/**
+ * Called when a Heartbeat record is received.
+ *
+ * @param c the connection.
+ * @param record the record.
+ */
+tls.handleHeartbeat = function(c, record) {
+ // get the heartbeat type and payload
+ var b = record.fragment;
+ var type = b.getByte();
+ var length = b.getInt16();
+ var payload = b.getBytes(length);
+
+ if(type === tls.HeartbeatMessageType.heartbeat_request) {
+ // discard request during handshake or if length is too large
+ if(c.handshaking || length > payload.length) {
+ // continue
+ return c.process();
+ }
+ // retransmit payload
+ tls.queue(c, tls.createRecord(c, {
+ type: tls.ContentType.heartbeat,
+ data: tls.createHeartbeat(
+ tls.HeartbeatMessageType.heartbeat_response, payload)
+ }));
+ tls.flush(c);
+ } else if(type === tls.HeartbeatMessageType.heartbeat_response) {
+ // check payload against expected payload, discard heartbeat if no match
+ if(payload !== c.expectedHeartbeatPayload) {
+ // continue
+ return c.process();
+ }
+
+ // notify that a valid heartbeat was received
+ if(c.heartbeatReceived) {
+ c.heartbeatReceived(c, forge.util.createBuffer(payload));
+ }
+ }
+
+ // continue
+ c.process();
+};
+
+/**
+ * The transistional state tables for receiving TLS records. It maps the
+ * current TLS engine state and a received record to a function to handle the
+ * record and update the state.
+ *
+ * For instance, if the current state is SHE, then the TLS engine is expecting
+ * a ServerHello record. Once a record is received, the handler function is
+ * looked up using the state SHE and the record's content type.
+ *
+ * The resulting function will either be an error handler or a record handler.
+ * The function will take whatever action is appropriate and update the state
+ * for the next record.
+ *
+ * The states are all based on possible server record types. Note that the
+ * client will never specifically expect to receive a HelloRequest or an alert
+ * from the server so there is no state that reflects this. These messages may
+ * occur at any time.
+ *
+ * There are two tables for mapping states because there is a second tier of
+ * types for handshake messages. Once a record with a content type of handshake
+ * is received, the handshake record handler will look up the handshake type in
+ * the secondary map to get its appropriate handler.
+ *
+ * Valid message orders are as follows:
+ *
+ * =======================FULL HANDSHAKE======================
+ * Client Server
+ *
+ * ClientHello -------->
+ * ServerHello
+ * Certificate*
+ * ServerKeyExchange*
+ * CertificateRequest*
+ * <-------- ServerHelloDone
+ * Certificate*
+ * ClientKeyExchange
+ * CertificateVerify*
+ * [ChangeCipherSpec]
+ * Finished -------->
+ * [ChangeCipherSpec]
+ * <-------- Finished
+ * Application Data <-------> Application Data
+ *
+ * =====================SESSION RESUMPTION=====================
+ * Client Server
+ *
+ * ClientHello -------->
+ * ServerHello
+ * [ChangeCipherSpec]
+ * <-------- Finished
+ * [ChangeCipherSpec]
+ * Finished -------->
+ * Application Data <-------> Application Data
+ */
+// client expect states (indicate which records are expected to be received)
+var SHE = 0; // rcv server hello
+var SCE = 1; // rcv server certificate
+var SKE = 2; // rcv server key exchange
+var SCR = 3; // rcv certificate request
+var SHD = 4; // rcv server hello done
+var SCC = 5; // rcv change cipher spec
+var SFI = 6; // rcv finished
+var SAD = 7; // rcv application data
+var SER = 8; // not expecting any messages at this point
+
+// server expect states
+var CHE = 0; // rcv client hello
+var CCE = 1; // rcv client certificate
+var CKE = 2; // rcv client key exchange
+var CCV = 3; // rcv certificate verify
+var CCC = 4; // rcv change cipher spec
+var CFI = 5; // rcv finished
+var CAD = 6; // rcv application data
+var CER = 7; // not expecting any messages at this point
+
+// map client current expect state and content type to function
+var __ = tls.handleUnexpected;
+var R0 = tls.handleChangeCipherSpec;
+var R1 = tls.handleAlert;
+var R2 = tls.handleHandshake;
+var R3 = tls.handleApplicationData;
+var R4 = tls.handleHeartbeat;
+var ctTable = [];
+ctTable[tls.ConnectionEnd.client] = [
+// CC,AL,HS,AD,HB
+/*SHE*/[__,R1,R2,__,R4],
+/*SCE*/[__,R1,R2,__,R4],
+/*SKE*/[__,R1,R2,__,R4],
+/*SCR*/[__,R1,R2,__,R4],
+/*SHD*/[__,R1,R2,__,R4],
+/*SCC*/[R0,R1,__,__,R4],
+/*SFI*/[__,R1,R2,__,R4],
+/*SAD*/[__,R1,R2,R3,R4],
+/*SER*/[__,R1,R2,__,R4]
+];
+
+// map server current expect state and content type to function
+ctTable[tls.ConnectionEnd.server] = [
+// CC,AL,HS,AD
+/*CHE*/[__,R1,R2,__,R4],
+/*CCE*/[__,R1,R2,__,R4],
+/*CKE*/[__,R1,R2,__,R4],
+/*CCV*/[__,R1,R2,__,R4],
+/*CCC*/[R0,R1,__,__,R4],
+/*CFI*/[__,R1,R2,__,R4],
+/*CAD*/[__,R1,R2,R3,R4],
+/*CER*/[__,R1,R2,__,R4]
+];
+
+// map client current expect state and handshake type to function
+var H0 = tls.handleHelloRequest;
+var H1 = tls.handleServerHello;
+var H2 = tls.handleCertificate;
+var H3 = tls.handleServerKeyExchange;
+var H4 = tls.handleCertificateRequest;
+var H5 = tls.handleServerHelloDone;
+var H6 = tls.handleFinished;
+var hsTable = [];
+hsTable[tls.ConnectionEnd.client] = [
+// HR,01,SH,03,04,05,06,07,08,09,10,SC,SK,CR,HD,15,CK,17,18,19,FI
+/*SHE*/[__,__,H1,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],
+/*SCE*/[H0,__,__,__,__,__,__,__,__,__,__,H2,H3,H4,H5,__,__,__,__,__,__],
+/*SKE*/[H0,__,__,__,__,__,__,__,__,__,__,__,H3,H4,H5,__,__,__,__,__,__],
+/*SCR*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,H4,H5,__,__,__,__,__,__],
+/*SHD*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,H5,__,__,__,__,__,__],
+/*SCC*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],
+/*SFI*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H6],
+/*SAD*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],
+/*SER*/[H0,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__]
+];
+
+// map server current expect state and handshake type to function
+// Note: CAD[CH] does not map to FB because renegotation is prohibited
+var H7 = tls.handleClientHello;
+var H8 = tls.handleClientKeyExchange;
+var H9 = tls.handleCertificateVerify;
+hsTable[tls.ConnectionEnd.server] = [
+// 01,CH,02,03,04,05,06,07,08,09,10,CC,12,13,14,CV,CK,17,18,19,FI
+/*CHE*/[__,H7,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],
+/*CCE*/[__,__,__,__,__,__,__,__,__,__,__,H2,__,__,__,__,__,__,__,__,__],
+/*CKE*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H8,__,__,__,__],
+/*CCV*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H9,__,__,__,__,__],
+/*CCC*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],
+/*CFI*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,H6],
+/*CAD*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__],
+/*CER*/[__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__]
+];
+
+/**
+ * Generates the master_secret and keys using the given security parameters.
+ *
+ * The security parameters for a TLS connection state are defined as such:
+ *
+ * struct {
+ * ConnectionEnd entity;
+ * PRFAlgorithm prf_algorithm;
+ * BulkCipherAlgorithm bulk_cipher_algorithm;
+ * CipherType cipher_type;
+ * uint8 enc_key_length;
+ * uint8 block_length;
+ * uint8 fixed_iv_length;
+ * uint8 record_iv_length;
+ * MACAlgorithm mac_algorithm;
+ * uint8 mac_length;
+ * uint8 mac_key_length;
+ * CompressionMethod compression_algorithm;
+ * opaque master_secret[48];
+ * opaque client_random[32];
+ * opaque server_random[32];
+ * } SecurityParameters;
+ *
+ * Note that this definition is from TLS 1.2. In TLS 1.0 some of these
+ * parameters are ignored because, for instance, the PRFAlgorithm is a
+ * builtin-fixed algorithm combining iterations of MD5 and SHA-1 in TLS 1.0.
+ *
+ * The Record Protocol requires an algorithm to generate keys required by the
+ * current connection state.
+ *
+ * The master secret is expanded into a sequence of secure bytes, which is then
+ * split to a client write MAC key, a server write MAC key, a client write
+ * encryption key, and a server write encryption key. In TLS 1.0 a client write
+ * IV and server write IV are also generated. Each of these is generated from
+ * the byte sequence in that order. Unused values are empty. In TLS 1.2, some
+ * AEAD ciphers may additionally require a client write IV and a server write
+ * IV (see Section 6.2.3.3).
+ *
+ * When keys, MAC keys, and IVs are generated, the master secret is used as an
+ * entropy source.
+ *
+ * To generate the key material, compute:
+ *
+ * master_secret = PRF(pre_master_secret, "master secret",
+ * ClientHello.random + ServerHello.random)
+ *
+ * key_block = PRF(SecurityParameters.master_secret,
+ * "key expansion",
+ * SecurityParameters.server_random +
+ * SecurityParameters.client_random);
+ *
+ * until enough output has been generated. Then, the key_block is
+ * partitioned as follows:
+ *
+ * client_write_MAC_key[SecurityParameters.mac_key_length]
+ * server_write_MAC_key[SecurityParameters.mac_key_length]
+ * client_write_key[SecurityParameters.enc_key_length]
+ * server_write_key[SecurityParameters.enc_key_length]
+ * client_write_IV[SecurityParameters.fixed_iv_length]
+ * server_write_IV[SecurityParameters.fixed_iv_length]
+ *
+ * In TLS 1.2, the client_write_IV and server_write_IV are only generated for
+ * implicit nonce techniques as described in Section 3.2.1 of [AEAD]. This
+ * implementation uses TLS 1.0 so IVs are generated.
+ *
+ * Implementation note: The currently defined cipher suite which requires the
+ * most material is AES_256_CBC_SHA256. It requires 2 x 32 byte keys and 2 x 32
+ * byte MAC keys, for a total 128 bytes of key material. In TLS 1.0 it also
+ * requires 2 x 16 byte IVs, so it actually takes 160 bytes of key material.
+ *
+ * @param c the connection.
+ * @param sp the security parameters to use.
+ *
+ * @return the security keys.
+ */
+tls.generateKeys = function(c, sp) {
+ // TLS_RSA_WITH_AES_128_CBC_SHA (required to be compliant with TLS 1.2) &
+ // TLS_RSA_WITH_AES_256_CBC_SHA are the only cipher suites implemented
+ // at present
+
+ // TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA is required to be compliant with
+ // TLS 1.0 but we don't care right now because AES is better and we have
+ // an implementation for it
+
+ // TODO: TLS 1.2 implementation
+ /*
+ // determine the PRF
+ var prf;
+ switch(sp.prf_algorithm) {
+ case tls.PRFAlgorithm.tls_prf_sha256:
+ prf = prf_sha256;
+ break;
+ default:
+ // should never happen
+ throw new Error('Invalid PRF');
+ }
+ */
+
+ // TLS 1.0/1.1 implementation
+ var prf = prf_TLS1;
+
+ // concatenate server and client random
+ var random = sp.client_random + sp.server_random;
+
+ // only create master secret if session is new
+ if(!c.session.resuming) {
+ // create master secret, clean up pre-master secret
+ sp.master_secret = prf(
+ sp.pre_master_secret, 'master secret', random, 48).bytes();
+ sp.pre_master_secret = null;
+ }
+
+ // generate the amount of key material needed
+ random = sp.server_random + sp.client_random;
+ var length = 2 * sp.mac_key_length + 2 * sp.enc_key_length;
+
+ // include IV for TLS/1.0
+ var tls10 = (c.version.major === tls.Versions.TLS_1_0.major &&
+ c.version.minor === tls.Versions.TLS_1_0.minor);
+ if(tls10) {
+ length += 2 * sp.fixed_iv_length;
+ }
+ var km = prf(sp.master_secret, 'key expansion', random, length);
+
+ // split the key material into the MAC and encryption keys
+ var rval = {
+ client_write_MAC_key: km.getBytes(sp.mac_key_length),
+ server_write_MAC_key: km.getBytes(sp.mac_key_length),
+ client_write_key: km.getBytes(sp.enc_key_length),
+ server_write_key: km.getBytes(sp.enc_key_length)
+ };
+
+ // include TLS 1.0 IVs
+ if(tls10) {
+ rval.client_write_IV = km.getBytes(sp.fixed_iv_length);
+ rval.server_write_IV = km.getBytes(sp.fixed_iv_length);
+ }
+
+ return rval;
+};
+
+/**
+ * Creates a new initialized TLS connection state. A connection state has
+ * a read mode and a write mode.
+ *
+ * compression state:
+ * The current state of the compression algorithm.
+ *
+ * cipher state:
+ * The current state of the encryption algorithm. This will consist of the
+ * scheduled key for that connection. For stream ciphers, this will also
+ * contain whatever state information is necessary to allow the stream to
+ * continue to encrypt or decrypt data.
+ *
+ * MAC key:
+ * The MAC key for the connection.
+ *
+ * sequence number:
+ * Each connection state contains a sequence number, which is maintained
+ * separately for read and write states. The sequence number MUST be set to
+ * zero whenever a connection state is made the active state. Sequence
+ * numbers are of type uint64 and may not exceed 2^64-1. Sequence numbers do
+ * not wrap. If a TLS implementation would need to wrap a sequence number,
+ * it must renegotiate instead. A sequence number is incremented after each
+ * record: specifically, the first record transmitted under a particular
+ * connection state MUST use sequence number 0.
+ *
+ * @param c the connection.
+ *
+ * @return the new initialized TLS connection state.
+ */
+tls.createConnectionState = function(c) {
+ var client = (c.entity === tls.ConnectionEnd.client);
+
+ var createMode = function() {
+ var mode = {
+ // two 32-bit numbers, first is most significant
+ sequenceNumber: [0, 0],
+ macKey: null,
+ macLength: 0,
+ macFunction: null,
+ cipherState: null,
+ cipherFunction: function(record) {return true;},
+ compressionState: null,
+ compressFunction: function(record) {return true;},
+ updateSequenceNumber: function() {
+ if(mode.sequenceNumber[1] === 0xFFFFFFFF) {
+ mode.sequenceNumber[1] = 0;
+ ++mode.sequenceNumber[0];
+ } else {
+ ++mode.sequenceNumber[1];
+ }
+ }
+ };
+ return mode;
+ };
+ var state = {
+ read: createMode(),
+ write: createMode()
+ };
+
+ // update function in read mode will decrypt then decompress a record
+ state.read.update = function(c, record) {
+ if(!state.read.cipherFunction(record, state.read)) {
+ c.error(c, {
+ message: 'Could not decrypt record or bad MAC.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ // doesn't matter if decryption failed or MAC was
+ // invalid, return the same error so as not to reveal
+ // which one occurred
+ description: tls.Alert.Description.bad_record_mac
+ }
+ });
+ } else if(!state.read.compressFunction(c, record, state.read)) {
+ c.error(c, {
+ message: 'Could not decompress record.',
+ send: true,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.decompression_failure
+ }
+ });
+ }
+ return !c.fail;
+ };
+
+ // update function in write mode will compress then encrypt a record
+ state.write.update = function(c, record) {
+ if(!state.write.compressFunction(c, record, state.write)) {
+ // error, but do not send alert since it would require
+ // compression as well
+ c.error(c, {
+ message: 'Could not compress record.',
+ send: false,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.internal_error
+ }
+ });
+ } else if(!state.write.cipherFunction(record, state.write)) {
+ // error, but do not send alert since it would require
+ // encryption as well
+ c.error(c, {
+ message: 'Could not encrypt record.',
+ send: false,
+ alert: {
+ level: tls.Alert.Level.fatal,
+ description: tls.Alert.Description.internal_error
+ }
+ });
+ }
+ return !c.fail;
+ };
+
+ // handle security parameters
+ if(c.session) {
+ var sp = c.session.sp;
+ c.session.cipherSuite.initSecurityParameters(sp);
+
+ // generate keys
+ sp.keys = tls.generateKeys(c, sp);
+ state.read.macKey = client ?
+ sp.keys.server_write_MAC_key : sp.keys.client_write_MAC_key;
+ state.write.macKey = client ?
+ sp.keys.client_write_MAC_key : sp.keys.server_write_MAC_key;
+
+ // cipher suite setup
+ c.session.cipherSuite.initConnectionState(state, c, sp);
+
+ // compression setup
+ switch(sp.compression_algorithm) {
+ case tls.CompressionMethod.none:
+ break;
+ case tls.CompressionMethod.deflate:
+ state.read.compressFunction = inflate;
+ state.write.compressFunction = deflate;
+ break;
+ default:
+ throw new Error('Unsupported compression algorithm.');
+ }
+ }
+
+ return state;
+};
+
+/**
+ * Creates a Random structure.
+ *
+ * struct {
+ * uint32 gmt_unix_time;
+ * opaque random_bytes[28];
+ * } Random;
+ *
+ * gmt_unix_time:
+ * The current time and date in standard UNIX 32-bit format (seconds since
+ * the midnight starting Jan 1, 1970, UTC, ignoring leap seconds) according
+ * to the sender's internal clock. Clocks are not required to be set
+ * correctly by the basic TLS protocol; higher-level or application
+ * protocols may define additional requirements. Note that, for historical
+ * reasons, the data element is named using GMT, the predecessor of the
+ * current worldwide time base, UTC.
+ * random_bytes:
+ * 28 bytes generated by a secure random number generator.
+ *
+ * @return the Random structure as a byte array.
+ */
+tls.createRandom = function() {
+ // get UTC milliseconds
+ var d = new Date();
+ var utc = +d + d.getTimezoneOffset() * 60000;
+ var rval = forge.util.createBuffer();
+ rval.putInt32(utc);
+ rval.putBytes(forge.random.getBytes(28));
+ return rval;
+};
+
+/**
+ * Creates a TLS record with the given type and data.
+ *
+ * @param c the connection.
+ * @param options:
+ * type: the record type.
+ * data: the plain text data in a byte buffer.
+ *
+ * @return the created record.
+ */
+tls.createRecord = function(c, options) {
+ if(!options.data) {
+ return null;
+ }
+ var record = {
+ type: options.type,
+ version: {
+ major: c.version.major,
+ minor: c.version.minor
+ },
+ length: options.data.length(),
+ fragment: options.data
+ };
+ return record;
+};
+
+/**
+ * Creates a TLS alert record.
+ *
+ * @param c the connection.
+ * @param alert:
+ * level: the TLS alert level.
+ * description: the TLS alert description.
+ *
+ * @return the created alert record.
+ */
+tls.createAlert = function(c, alert) {
+ var b = forge.util.createBuffer();
+ b.putByte(alert.level);
+ b.putByte(alert.description);
+ return tls.createRecord(c, {
+ type: tls.ContentType.alert,
+ data: b
+ });
+};
+
+/* The structure of a TLS handshake message.
+ *
+ * struct {
+ * HandshakeType msg_type; // handshake type
+ * uint24 length; // bytes in message
+ * select(HandshakeType) {
+ * case hello_request: HelloRequest;
+ * case client_hello: ClientHello;
+ * case server_hello: ServerHello;
+ * case certificate: Certificate;
+ * case server_key_exchange: ServerKeyExchange;
+ * case certificate_request: CertificateRequest;
+ * case server_hello_done: ServerHelloDone;
+ * case certificate_verify: CertificateVerify;
+ * case client_key_exchange: ClientKeyExchange;
+ * case finished: Finished;
+ * } body;
+ * } Handshake;
+ */
+
+/**
+ * Creates a ClientHello message.
+ *
+ * opaque SessionID<0..32>;
+ * enum { null(0), deflate(1), (255) } CompressionMethod;
+ * uint8 CipherSuite[2];
+ *
+ * struct {
+ * ProtocolVersion client_version;
+ * Random random;
+ * SessionID session_id;
+ * CipherSuite cipher_suites<2..2^16-2>;
+ * CompressionMethod compression_methods<1..2^8-1>;
+ * select(extensions_present) {
+ * case false:
+ * struct {};
+ * case true:
+ * Extension extensions<0..2^16-1>;
+ * };
+ * } ClientHello;
+ *
+ * The extension format for extended client hellos and server hellos is:
+ *
+ * struct {
+ * ExtensionType extension_type;
+ * opaque extension_data<0..2^16-1>;
+ * } Extension;
+ *
+ * Here:
+ *
+ * - "extension_type" identifies the particular extension type.
+ * - "extension_data" contains information specific to the particular
+ * extension type.
+ *
+ * The extension types defined in this document are:
+ *
+ * enum {
+ * server_name(0), max_fragment_length(1),
+ * client_certificate_url(2), trusted_ca_keys(3),
+ * truncated_hmac(4), status_request(5), (65535)
+ * } ExtensionType;
+ *
+ * @param c the connection.
+ *
+ * @return the ClientHello byte buffer.
+ */
+tls.createClientHello = function(c) {
+ // save hello version
+ c.session.clientHelloVersion = {
+ major: c.version.major,
+ minor: c.version.minor
+ };
+
+ // create supported cipher suites
+ var cipherSuites = forge.util.createBuffer();
+ for(var i = 0; i < c.cipherSuites.length; ++i) {
+ var cs = c.cipherSuites[i];
+ cipherSuites.putByte(cs.id[0]);
+ cipherSuites.putByte(cs.id[1]);
+ }
+ var cSuites = cipherSuites.length();
+
+ // create supported compression methods, null always supported, but
+ // also support deflate if connection has inflate and deflate methods
+ var compressionMethods = forge.util.createBuffer();
+ compressionMethods.putByte(tls.CompressionMethod.none);
+ // FIXME: deflate support disabled until issues with raw deflate data
+ // without zlib headers are resolved
+ /*
+ if(c.inflate !== null && c.deflate !== null) {
+ compressionMethods.putByte(tls.CompressionMethod.deflate);
+ }
+ */
+ var cMethods = compressionMethods.length();
+
+ // create TLS SNI (server name indication) extension if virtual host
+ // has been specified, see RFC 3546
+ var extensions = forge.util.createBuffer();
+ if(c.virtualHost) {
+ // create extension struct
+ var ext = forge.util.createBuffer();
+ ext.putByte(0x00); // type server_name (ExtensionType is 2 bytes)
+ ext.putByte(0x00);
+
+ /* In order to provide the server name, clients MAY include an
+ * extension of type "server_name" in the (extended) client hello.
+ * The "extension_data" field of this extension SHALL contain
+ * "ServerNameList" where:
+ *
+ * struct {
+ * NameType name_type;
+ * select(name_type) {
+ * case host_name: HostName;
+ * } name;
+ * } ServerName;
+ *
+ * enum {
+ * host_name(0), (255)
+ * } NameType;
+ *
+ * opaque HostName<1..2^16-1>;
+ *
+ * struct {
+ * ServerName server_name_list<1..2^16-1>
+ * } ServerNameList;
+ */
+ var serverName = forge.util.createBuffer();
+ serverName.putByte(0x00); // type host_name
+ writeVector(serverName, 2, forge.util.createBuffer(c.virtualHost));
+
+ // ServerNameList is in extension_data
+ var snList = forge.util.createBuffer();
+ writeVector(snList, 2, serverName);
+ writeVector(ext, 2, snList);
+ extensions.putBuffer(ext);
+ }
+ var extLength = extensions.length();
+ if(extLength > 0) {
+ // add extension vector length
+ extLength += 2;
+ }
+
+ // determine length of the handshake message
+ // cipher suites and compression methods size will need to be
+ // updated if more get added to the list
+ var sessionId = c.session.id;
+ var length =
+ sessionId.length + 1 + // session ID vector
+ 2 + // version (major + minor)
+ 4 + 28 + // random time and random bytes
+ 2 + cSuites + // cipher suites vector
+ 1 + cMethods + // compression methods vector
+ extLength; // extensions vector
+
+ // build record fragment
+ var rval = forge.util.createBuffer();
+ rval.putByte(tls.HandshakeType.client_hello);
+ rval.putInt24(length); // handshake length
+ rval.putByte(c.version.major); // major version
+ rval.putByte(c.version.minor); // minor version
+ rval.putBytes(c.session.sp.client_random); // random time + bytes
+ writeVector(rval, 1, forge.util.createBuffer(sessionId));
+ writeVector(rval, 2, cipherSuites);
+ writeVector(rval, 1, compressionMethods);
+ if(extLength > 0) {
+ writeVector(rval, 2, extensions);
+ }
+ return rval;
+};
+
+/**
+ * Creates a ServerHello message.
+ *
+ * @param c the connection.
+ *
+ * @return the ServerHello byte buffer.
+ */
+tls.createServerHello = function(c) {
+ // determine length of the handshake message
+ var sessionId = c.session.id;
+ var length =
+ sessi
<TRUNCATED>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[13/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/log.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/log.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/log.js
new file mode 100644
index 0000000..c7931f5
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/log.js
@@ -0,0 +1,372 @@
+/**
+ * Cross-browser support for logging in a web application.
+ *
+ * @author David I. Lehn <dl...@digitalbazaar.com>
+ *
+ * Copyright (c) 2008-2013 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+/* LOG API */
+forge.log = forge.log || {};
+
+/**
+ * Application logging system.
+ *
+ * Each logger level available as it's own function of the form:
+ * forge.log.level(category, args...)
+ * The category is an arbitrary string, and the args are the same as
+ * Firebug's console.log API. By default the call will be output as:
+ * 'LEVEL [category] <args[0]>, args[1], ...'
+ * This enables proper % formatting via the first argument.
+ * Each category is enabled by default but can be enabled or disabled with
+ * the setCategoryEnabled() function.
+ */
+// list of known levels
+forge.log.levels = [
+ 'none', 'error', 'warning', 'info', 'debug', 'verbose', 'max'];
+// info on the levels indexed by name:
+// index: level index
+// name: uppercased display name
+var sLevelInfo = {};
+// list of loggers
+var sLoggers = [];
+/**
+ * Standard console logger. If no console support is enabled this will
+ * remain null. Check before using.
+ */
+var sConsoleLogger = null;
+
+// logger flags
+/**
+ * Lock the level at the current value. Used in cases where user config may
+ * set the level such that only critical messages are seen but more verbose
+ * messages are needed for debugging or other purposes.
+ */
+forge.log.LEVEL_LOCKED = (1 << 1);
+/**
+ * Always call log function. By default, the logging system will check the
+ * message level against logger.level before calling the log function. This
+ * flag allows the function to do its own check.
+ */
+forge.log.NO_LEVEL_CHECK = (1 << 2);
+/**
+ * Perform message interpolation with the passed arguments. "%" style
+ * fields in log messages will be replaced by arguments as needed. Some
+ * loggers, such as Firebug, may do this automatically. The original log
+ * message will be available as 'message' and the interpolated version will
+ * be available as 'fullMessage'.
+ */
+forge.log.INTERPOLATE = (1 << 3);
+
+// setup each log level
+for(var i = 0; i < forge.log.levels.length; ++i) {
+ var level = forge.log.levels[i];
+ sLevelInfo[level] = {
+ index: i,
+ name: level.toUpperCase()
+ };
+}
+
+/**
+ * Message logger. Will dispatch a message to registered loggers as needed.
+ *
+ * @param message message object
+ */
+forge.log.logMessage = function(message) {
+ var messageLevelIndex = sLevelInfo[message.level].index;
+ for(var i = 0; i < sLoggers.length; ++i) {
+ var logger = sLoggers[i];
+ if(logger.flags & forge.log.NO_LEVEL_CHECK) {
+ logger.f(message);
+ } else {
+ // get logger level
+ var loggerLevelIndex = sLevelInfo[logger.level].index;
+ // check level
+ if(messageLevelIndex <= loggerLevelIndex) {
+ // message critical enough, call logger
+ logger.f(logger, message);
+ }
+ }
+ }
+};
+
+/**
+ * Sets the 'standard' key on a message object to:
+ * "LEVEL [category] " + message
+ *
+ * @param message a message log object
+ */
+forge.log.prepareStandard = function(message) {
+ if(!('standard' in message)) {
+ message.standard =
+ sLevelInfo[message.level].name +
+ //' ' + +message.timestamp +
+ ' [' + message.category + '] ' +
+ message.message;
+ }
+};
+
+/**
+ * Sets the 'full' key on a message object to the original message
+ * interpolated via % formatting with the message arguments.
+ *
+ * @param message a message log object.
+ */
+forge.log.prepareFull = function(message) {
+ if(!('full' in message)) {
+ // copy args and insert message at the front
+ var args = [message.message];
+ args = args.concat([] || message['arguments']);
+ // format the message
+ message.full = forge.util.format.apply(this, args);
+ }
+};
+
+/**
+ * Applies both preparseStandard() and prepareFull() to a message object and
+ * store result in 'standardFull'.
+ *
+ * @param message a message log object.
+ */
+forge.log.prepareStandardFull = function(message) {
+ if(!('standardFull' in message)) {
+ // FIXME implement 'standardFull' logging
+ forge.log.prepareStandard(message);
+ message.standardFull = message.standard;
+ }
+};
+
+// create log level functions
+if(true) {
+ // levels for which we want functions
+ var levels = ['error', 'warning', 'info', 'debug', 'verbose'];
+ for(var i = 0; i < levels.length; ++i) {
+ // wrap in a function to ensure proper level var is passed
+ (function(level) {
+ // create function for this level
+ forge.log[level] = function(category, message/*, args...*/) {
+ // convert arguments to real array, remove category and message
+ var args = Array.prototype.slice.call(arguments).slice(2);
+ // create message object
+ // Note: interpolation and standard formatting is done lazily
+ var msg = {
+ timestamp: new Date(),
+ level: level,
+ category: category,
+ message: message,
+ 'arguments': args
+ /*standard*/
+ /*full*/
+ /*fullMessage*/
+ };
+ // process this message
+ forge.log.logMessage(msg);
+ };
+ })(levels[i]);
+ }
+}
+
+/**
+ * Creates a new logger with specified custom logging function.
+ *
+ * The logging function has a signature of:
+ * function(logger, message)
+ * logger: current logger
+ * message: object:
+ * level: level id
+ * category: category
+ * message: string message
+ * arguments: Array of extra arguments
+ * fullMessage: interpolated message and arguments if INTERPOLATE flag set
+ *
+ * @param logFunction a logging function which takes a log message object
+ * as a parameter.
+ *
+ * @return a logger object.
+ */
+forge.log.makeLogger = function(logFunction) {
+ var logger = {
+ flags: 0,
+ f: logFunction
+ };
+ forge.log.setLevel(logger, 'none');
+ return logger;
+};
+
+/**
+ * Sets the current log level on a logger.
+ *
+ * @param logger the target logger.
+ * @param level the new maximum log level as a string.
+ *
+ * @return true if set, false if not.
+ */
+forge.log.setLevel = function(logger, level) {
+ var rval = false;
+ if(logger && !(logger.flags & forge.log.LEVEL_LOCKED)) {
+ for(var i = 0; i < forge.log.levels.length; ++i) {
+ var aValidLevel = forge.log.levels[i];
+ if(level == aValidLevel) {
+ // set level
+ logger.level = level;
+ rval = true;
+ break;
+ }
+ }
+ }
+
+ return rval;
+};
+
+/**
+ * Locks the log level at its current value.
+ *
+ * @param logger the target logger.
+ * @param lock boolean lock value, default to true.
+ */
+forge.log.lock = function(logger, lock) {
+ if(typeof lock === 'undefined' || lock) {
+ logger.flags |= forge.log.LEVEL_LOCKED;
+ } else {
+ logger.flags &= ~forge.log.LEVEL_LOCKED;
+ }
+};
+
+/**
+ * Adds a logger.
+ *
+ * @param logger the logger object.
+ */
+forge.log.addLogger = function(logger) {
+ sLoggers.push(logger);
+};
+
+// setup the console logger if possible, else create fake console.log
+if(typeof(console) !== 'undefined' && 'log' in console) {
+ var logger;
+ if(console.error && console.warn && console.info && console.debug) {
+ // looks like Firebug-style logging is available
+ // level handlers map
+ var levelHandlers = {
+ error: console.error,
+ warning: console.warn,
+ info: console.info,
+ debug: console.debug,
+ verbose: console.debug
+ };
+ var f = function(logger, message) {
+ forge.log.prepareStandard(message);
+ var handler = levelHandlers[message.level];
+ // prepend standard message and concat args
+ var args = [message.standard];
+ args = args.concat(message['arguments'].slice());
+ // apply to low-level console function
+ handler.apply(console, args);
+ };
+ logger = forge.log.makeLogger(f);
+ } else {
+ // only appear to have basic console.log
+ var f = function(logger, message) {
+ forge.log.prepareStandardFull(message);
+ console.log(message.standardFull);
+ };
+ logger = forge.log.makeLogger(f);
+ }
+ forge.log.setLevel(logger, 'debug');
+ forge.log.addLogger(logger);
+ sConsoleLogger = logger;
+} else {
+ // define fake console.log to avoid potential script errors on
+ // browsers that do not have console logging
+ console = {
+ log: function() {}
+ };
+}
+
+/*
+ * Check for logging control query vars.
+ *
+ * console.level=<level-name>
+ * Set's the console log level by name. Useful to override defaults and
+ * allow more verbose logging before a user config is loaded.
+ *
+ * console.lock=<true|false>
+ * Lock the console log level at whatever level it is set at. This is run
+ * after console.level is processed. Useful to force a level of verbosity
+ * that could otherwise be limited by a user config.
+ */
+if(sConsoleLogger !== null) {
+ var query = forge.util.getQueryVariables();
+ if('console.level' in query) {
+ // set with last value
+ forge.log.setLevel(
+ sConsoleLogger, query['console.level'].slice(-1)[0]);
+ }
+ if('console.lock' in query) {
+ // set with last value
+ var lock = query['console.lock'].slice(-1)[0];
+ if(lock == 'true') {
+ forge.log.lock(sConsoleLogger);
+ }
+ }
+}
+
+// provide public access to console logger
+forge.log.consoleLogger = sConsoleLogger;
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'log';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/md.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/md.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/md.js
new file mode 100644
index 0000000..e980cfd
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/md.js
@@ -0,0 +1,75 @@
+/**
+ * Node.js module for Forge message digests.
+ *
+ * @author Dave Longley
+ *
+ * Copyright 2011-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+forge.md = forge.md || {};
+forge.md.algorithms = {
+ md5: forge.md5,
+ sha1: forge.sha1,
+ sha256: forge.sha256
+};
+forge.md.md5 = forge.md5;
+forge.md.sha1 = forge.sha1;
+forge.md.sha256 = forge.sha256;
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'md';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(
+ ['require', 'module', './md5', './sha1', './sha256', './sha512'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/md5.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/md5.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/md5.js
new file mode 100644
index 0000000..acf7d11
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/md5.js
@@ -0,0 +1,322 @@
+/**
+ * Message Digest Algorithm 5 with 128-bit digest (MD5) implementation.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+var md5 = forge.md5 = forge.md5 || {};
+forge.md = forge.md || {};
+forge.md.algorithms = forge.md.algorithms || {};
+forge.md.md5 = forge.md.algorithms.md5 = md5;
+
+/**
+ * Creates an MD5 message digest object.
+ *
+ * @return a message digest object.
+ */
+md5.create = function() {
+ // do initialization as necessary
+ if(!_initialized) {
+ _init();
+ }
+
+ // MD5 state contains four 32-bit integers
+ var _state = null;
+
+ // input buffer
+ var _input = forge.util.createBuffer();
+
+ // used for word storage
+ var _w = new Array(16);
+
+ // message digest object
+ var md = {
+ algorithm: 'md5',
+ blockLength: 64,
+ digestLength: 16,
+ // 56-bit length of message so far (does not including padding)
+ messageLength: 0,
+ // true 64-bit message length as two 32-bit ints
+ messageLength64: [0, 0]
+ };
+
+ /**
+ * Starts the digest.
+ *
+ * @return this digest object.
+ */
+ md.start = function() {
+ md.messageLength = 0;
+ md.messageLength64 = [0, 0];
+ _input = forge.util.createBuffer();
+ _state = {
+ h0: 0x67452301,
+ h1: 0xEFCDAB89,
+ h2: 0x98BADCFE,
+ h3: 0x10325476
+ };
+ return md;
+ };
+ // start digest automatically for first time
+ md.start();
+
+ /**
+ * Updates the digest with the given message input. The given input can
+ * treated as raw input (no encoding will be applied) or an encoding of
+ * 'utf8' maybe given to encode the input using UTF-8.
+ *
+ * @param msg the message input to update with.
+ * @param encoding the encoding to use (default: 'raw', other: 'utf8').
+ *
+ * @return this digest object.
+ */
+ md.update = function(msg, encoding) {
+ if(encoding === 'utf8') {
+ msg = forge.util.encodeUtf8(msg);
+ }
+
+ // update message length
+ md.messageLength += msg.length;
+ md.messageLength64[0] += (msg.length / 0x100000000) >>> 0;
+ md.messageLength64[1] += msg.length >>> 0;
+
+ // add bytes to input buffer
+ _input.putBytes(msg);
+
+ // process bytes
+ _update(_state, _w, _input);
+
+ // compact input buffer every 2K or if empty
+ if(_input.read > 2048 || _input.length() === 0) {
+ _input.compact();
+ }
+
+ return md;
+ };
+
+ /**
+ * Produces the digest.
+ *
+ * @return a byte buffer containing the digest value.
+ */
+ md.digest = function() {
+ /* Note: Here we copy the remaining bytes in the input buffer and
+ add the appropriate MD5 padding. Then we do the final update
+ on a copy of the state so that if the user wants to get
+ intermediate digests they can do so. */
+
+ /* Determine the number of bytes that must be added to the message
+ to ensure its length is congruent to 448 mod 512. In other words,
+ the data to be digested must be a multiple of 512 bits (or 128 bytes).
+ This data includes the message, some padding, and the length of the
+ message. Since the length of the message will be encoded as 8 bytes (64
+ bits), that means that the last segment of the data must have 56 bytes
+ (448 bits) of message and padding. Therefore, the length of the message
+ plus the padding must be congruent to 448 mod 512 because
+ 512 - 128 = 448.
+
+ In order to fill up the message length it must be filled with
+ padding that begins with 1 bit followed by all 0 bits. Padding
+ must *always* be present, so if the message length is already
+ congruent to 448 mod 512, then 512 padding bits must be added. */
+
+ // 512 bits == 64 bytes, 448 bits == 56 bytes, 64 bits = 8 bytes
+ // _padding starts with 1 byte with first bit is set in it which
+ // is byte value 128, then there may be up to 63 other pad bytes
+ var padBytes = forge.util.createBuffer();
+ padBytes.putBytes(_input.bytes());
+ // 64 - (remaining msg + 8 bytes msg length) mod 64
+ padBytes.putBytes(
+ _padding.substr(0, 64 - ((md.messageLength64[1] + 8) & 0x3F)));
+
+ /* Now append length of the message. The length is appended in bits
+ as a 64-bit number in little-endian order. Since we store the length in
+ bytes, we must multiply the 64-bit length by 8 (or left shift by 3). */
+ padBytes.putInt32Le(md.messageLength64[1] << 3);
+ padBytes.putInt32Le(
+ (md.messageLength64[0] << 3) | (md.messageLength64[0] >>> 28));
+ var s2 = {
+ h0: _state.h0,
+ h1: _state.h1,
+ h2: _state.h2,
+ h3: _state.h3
+ };
+ _update(s2, _w, padBytes);
+ var rval = forge.util.createBuffer();
+ rval.putInt32Le(s2.h0);
+ rval.putInt32Le(s2.h1);
+ rval.putInt32Le(s2.h2);
+ rval.putInt32Le(s2.h3);
+ return rval;
+ };
+
+ return md;
+};
+
+// padding, constant tables for calculating md5
+var _padding = null;
+var _g = null;
+var _r = null;
+var _k = null;
+var _initialized = false;
+
+/**
+ * Initializes the constant tables.
+ */
+function _init() {
+ // create padding
+ _padding = String.fromCharCode(128);
+ _padding += forge.util.fillString(String.fromCharCode(0x00), 64);
+
+ // g values
+ _g = [
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12,
+ 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2,
+ 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9];
+
+ // rounds table
+ _r = [
+ 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
+ 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
+ 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
+ 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21];
+
+ // get the result of abs(sin(i + 1)) as a 32-bit integer
+ _k = new Array(64);
+ for(var i = 0; i < 64; ++i) {
+ _k[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 0x100000000);
+ }
+
+ // now initialized
+ _initialized = true;
+}
+
+/**
+ * Updates an MD5 state with the given byte buffer.
+ *
+ * @param s the MD5 state to update.
+ * @param w the array to use to store words.
+ * @param bytes the byte buffer to update with.
+ */
+function _update(s, w, bytes) {
+ // consume 512 bit (64 byte) chunks
+ var t, a, b, c, d, f, r, i;
+ var len = bytes.length();
+ while(len >= 64) {
+ // initialize hash value for this chunk
+ a = s.h0;
+ b = s.h1;
+ c = s.h2;
+ d = s.h3;
+
+ // round 1
+ for(i = 0; i < 16; ++i) {
+ w[i] = bytes.getInt32Le();
+ f = d ^ (b & (c ^ d));
+ t = (a + f + _k[i] + w[i]);
+ r = _r[i];
+ a = d;
+ d = c;
+ c = b;
+ b += (t << r) | (t >>> (32 - r));
+ }
+ // round 2
+ for(; i < 32; ++i) {
+ f = c ^ (d & (b ^ c));
+ t = (a + f + _k[i] + w[_g[i]]);
+ r = _r[i];
+ a = d;
+ d = c;
+ c = b;
+ b += (t << r) | (t >>> (32 - r));
+ }
+ // round 3
+ for(; i < 48; ++i) {
+ f = b ^ c ^ d;
+ t = (a + f + _k[i] + w[_g[i]]);
+ r = _r[i];
+ a = d;
+ d = c;
+ c = b;
+ b += (t << r) | (t >>> (32 - r));
+ }
+ // round 4
+ for(; i < 64; ++i) {
+ f = c ^ (b | ~d);
+ t = (a + f + _k[i] + w[_g[i]]);
+ r = _r[i];
+ a = d;
+ d = c;
+ c = b;
+ b += (t << r) | (t >>> (32 - r));
+ }
+
+ // update hash state
+ s.h0 = (s.h0 + a) | 0;
+ s.h1 = (s.h1 + b) | 0;
+ s.h2 = (s.h2 + c) | 0;
+ s.h3 = (s.h3 + d) | 0;
+
+ len -= 64;
+ }
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'md5';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/mgf.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/mgf.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/mgf.js
new file mode 100644
index 0000000..927082a
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/mgf.js
@@ -0,0 +1,67 @@
+/**
+ * Node.js module for Forge mask generation functions.
+ *
+ * @author Stefan Siegl
+ *
+ * Copyright 2012 Stefan Siegl <st...@brokenpipe.de>
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+forge.mgf = forge.mgf || {};
+forge.mgf.mgf1 = forge.mgf1;
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'mgf';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './mgf1'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/mgf1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/mgf1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/mgf1.js
new file mode 100644
index 0000000..82d62cd
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/mgf1.js
@@ -0,0 +1,112 @@
+/**
+ * Javascript implementation of mask generation function MGF1.
+ *
+ * @author Stefan Siegl
+ * @author Dave Longley
+ *
+ * Copyright (c) 2012 Stefan Siegl <st...@brokenpipe.de>
+ * Copyright (c) 2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+forge.mgf = forge.mgf || {};
+var mgf1 = forge.mgf.mgf1 = forge.mgf1 = forge.mgf1 || {};
+
+/**
+ * Creates a MGF1 mask generation function object.
+ *
+ * @param md the message digest API to use (eg: forge.md.sha1.create()).
+ *
+ * @return a mask generation function object.
+ */
+mgf1.create = function(md) {
+ var mgf = {
+ /**
+ * Generate mask of specified length.
+ *
+ * @param {String} seed The seed for mask generation.
+ * @param maskLen Number of bytes to generate.
+ * @return {String} The generated mask.
+ */
+ generate: function(seed, maskLen) {
+ /* 2. Let T be the empty octet string. */
+ var t = new forge.util.ByteBuffer();
+
+ /* 3. For counter from 0 to ceil(maskLen / hLen), do the following: */
+ var len = Math.ceil(maskLen / md.digestLength);
+ for(var i = 0; i < len; i++) {
+ /* a. Convert counter to an octet string C of length 4 octets */
+ var c = new forge.util.ByteBuffer();
+ c.putInt32(i);
+
+ /* b. Concatenate the hash of the seed mgfSeed and C to the octet
+ * string T: */
+ md.start();
+ md.update(seed + c.getBytes());
+ t.putBuffer(md.digest());
+ }
+
+ /* Output the leading maskLen octets of T as the octet string mask. */
+ t.truncate(t.length() - maskLen);
+ return t.getBytes();
+ }
+ };
+
+ return mgf;
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'mgf1';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/oids.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/oids.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/oids.js
new file mode 100644
index 0000000..ef3e67d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/oids.js
@@ -0,0 +1,269 @@
+/**
+ * Object IDs for ASN.1.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2013 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+forge.pki = forge.pki || {};
+var oids = forge.pki.oids = forge.oids = forge.oids || {};
+
+// algorithm OIDs
+oids['1.2.840.113549.1.1.1'] = 'rsaEncryption';
+oids['rsaEncryption'] = '1.2.840.113549.1.1.1';
+// Note: md2 & md4 not implemented
+//oids['1.2.840.113549.1.1.2'] = 'md2WithRSAEncryption';
+//oids['md2WithRSAEncryption'] = '1.2.840.113549.1.1.2';
+//oids['1.2.840.113549.1.1.3'] = 'md4WithRSAEncryption';
+//oids['md4WithRSAEncryption'] = '1.2.840.113549.1.1.3';
+oids['1.2.840.113549.1.1.4'] = 'md5WithRSAEncryption';
+oids['md5WithRSAEncryption'] = '1.2.840.113549.1.1.4';
+oids['1.2.840.113549.1.1.5'] = 'sha1WithRSAEncryption';
+oids['sha1WithRSAEncryption'] = '1.2.840.113549.1.1.5';
+oids['1.2.840.113549.1.1.7'] = 'RSAES-OAEP';
+oids['RSAES-OAEP'] = '1.2.840.113549.1.1.7';
+oids['1.2.840.113549.1.1.8'] = 'mgf1';
+oids['mgf1'] = '1.2.840.113549.1.1.8';
+oids['1.2.840.113549.1.1.9'] = 'pSpecified';
+oids['pSpecified'] = '1.2.840.113549.1.1.9';
+oids['1.2.840.113549.1.1.10'] = 'RSASSA-PSS';
+oids['RSASSA-PSS'] = '1.2.840.113549.1.1.10';
+oids['1.2.840.113549.1.1.11'] = 'sha256WithRSAEncryption';
+oids['sha256WithRSAEncryption'] = '1.2.840.113549.1.1.11';
+oids['1.2.840.113549.1.1.12'] = 'sha384WithRSAEncryption';
+oids['sha384WithRSAEncryption'] = '1.2.840.113549.1.1.12';
+oids['1.2.840.113549.1.1.13'] = 'sha512WithRSAEncryption';
+oids['sha512WithRSAEncryption'] = '1.2.840.113549.1.1.13';
+
+oids['1.3.14.3.2.7'] = 'desCBC';
+oids['desCBC'] = '1.3.14.3.2.7';
+
+oids['1.3.14.3.2.26'] = 'sha1';
+oids['sha1'] = '1.3.14.3.2.26';
+oids['2.16.840.1.101.3.4.2.1'] = 'sha256';
+oids['sha256'] = '2.16.840.1.101.3.4.2.1';
+oids['2.16.840.1.101.3.4.2.2'] = 'sha384';
+oids['sha384'] = '2.16.840.1.101.3.4.2.2';
+oids['2.16.840.1.101.3.4.2.3'] = 'sha512';
+oids['sha512'] = '2.16.840.1.101.3.4.2.3';
+oids['1.2.840.113549.2.5'] = 'md5';
+oids['md5'] = '1.2.840.113549.2.5';
+
+// pkcs#7 content types
+oids['1.2.840.113549.1.7.1'] = 'data';
+oids['data'] = '1.2.840.113549.1.7.1';
+oids['1.2.840.113549.1.7.2'] = 'signedData';
+oids['signedData'] = '1.2.840.113549.1.7.2';
+oids['1.2.840.113549.1.7.3'] = 'envelopedData';
+oids['envelopedData'] = '1.2.840.113549.1.7.3';
+oids['1.2.840.113549.1.7.4'] = 'signedAndEnvelopedData';
+oids['signedAndEnvelopedData'] = '1.2.840.113549.1.7.4';
+oids['1.2.840.113549.1.7.5'] = 'digestedData';
+oids['digestedData'] = '1.2.840.113549.1.7.5';
+oids['1.2.840.113549.1.7.6'] = 'encryptedData';
+oids['encryptedData'] = '1.2.840.113549.1.7.6';
+
+// pkcs#9 oids
+oids['1.2.840.113549.1.9.1'] = 'emailAddress';
+oids['emailAddress'] = '1.2.840.113549.1.9.1';
+oids['1.2.840.113549.1.9.2'] = 'unstructuredName';
+oids['unstructuredName'] = '1.2.840.113549.1.9.2';
+oids['1.2.840.113549.1.9.3'] = 'contentType';
+oids['contentType'] = '1.2.840.113549.1.9.3';
+oids['1.2.840.113549.1.9.4'] = 'messageDigest';
+oids['messageDigest'] = '1.2.840.113549.1.9.4';
+oids['1.2.840.113549.1.9.5'] = 'signingTime';
+oids['signingTime'] = '1.2.840.113549.1.9.5';
+oids['1.2.840.113549.1.9.6'] = 'counterSignature';
+oids['counterSignature'] = '1.2.840.113549.1.9.6';
+oids['1.2.840.113549.1.9.7'] = 'challengePassword';
+oids['challengePassword'] = '1.2.840.113549.1.9.7';
+oids['1.2.840.113549.1.9.8'] = 'unstructuredAddress';
+oids['unstructuredAddress'] = '1.2.840.113549.1.9.8';
+oids['1.2.840.113549.1.9.14'] = 'extensionRequest';
+oids['extensionRequest'] = '1.2.840.113549.1.9.14';
+
+oids['1.2.840.113549.1.9.20'] = 'friendlyName';
+oids['friendlyName'] = '1.2.840.113549.1.9.20';
+oids['1.2.840.113549.1.9.21'] = 'localKeyId';
+oids['localKeyId'] = '1.2.840.113549.1.9.21';
+oids['1.2.840.113549.1.9.22.1'] = 'x509Certificate';
+oids['x509Certificate'] = '1.2.840.113549.1.9.22.1';
+
+// pkcs#12 safe bags
+oids['1.2.840.113549.1.12.10.1.1'] = 'keyBag';
+oids['keyBag'] = '1.2.840.113549.1.12.10.1.1';
+oids['1.2.840.113549.1.12.10.1.2'] = 'pkcs8ShroudedKeyBag';
+oids['pkcs8ShroudedKeyBag'] = '1.2.840.113549.1.12.10.1.2';
+oids['1.2.840.113549.1.12.10.1.3'] = 'certBag';
+oids['certBag'] = '1.2.840.113549.1.12.10.1.3';
+oids['1.2.840.113549.1.12.10.1.4'] = 'crlBag';
+oids['crlBag'] = '1.2.840.113549.1.12.10.1.4';
+oids['1.2.840.113549.1.12.10.1.5'] = 'secretBag';
+oids['secretBag'] = '1.2.840.113549.1.12.10.1.5';
+oids['1.2.840.113549.1.12.10.1.6'] = 'safeContentsBag';
+oids['safeContentsBag'] = '1.2.840.113549.1.12.10.1.6';
+
+// password-based-encryption for pkcs#12
+oids['1.2.840.113549.1.5.13'] = 'pkcs5PBES2';
+oids['pkcs5PBES2'] = '1.2.840.113549.1.5.13';
+oids['1.2.840.113549.1.5.12'] = 'pkcs5PBKDF2';
+oids['pkcs5PBKDF2'] = '1.2.840.113549.1.5.12';
+
+oids['1.2.840.113549.1.12.1.1'] = 'pbeWithSHAAnd128BitRC4';
+oids['pbeWithSHAAnd128BitRC4'] = '1.2.840.113549.1.12.1.1';
+oids['1.2.840.113549.1.12.1.2'] = 'pbeWithSHAAnd40BitRC4';
+oids['pbeWithSHAAnd40BitRC4'] = '1.2.840.113549.1.12.1.2';
+oids['1.2.840.113549.1.12.1.3'] = 'pbeWithSHAAnd3-KeyTripleDES-CBC';
+oids['pbeWithSHAAnd3-KeyTripleDES-CBC'] = '1.2.840.113549.1.12.1.3';
+oids['1.2.840.113549.1.12.1.4'] = 'pbeWithSHAAnd2-KeyTripleDES-CBC';
+oids['pbeWithSHAAnd2-KeyTripleDES-CBC'] = '1.2.840.113549.1.12.1.4';
+oids['1.2.840.113549.1.12.1.5'] = 'pbeWithSHAAnd128BitRC2-CBC';
+oids['pbeWithSHAAnd128BitRC2-CBC'] = '1.2.840.113549.1.12.1.5';
+oids['1.2.840.113549.1.12.1.6'] = 'pbewithSHAAnd40BitRC2-CBC';
+oids['pbewithSHAAnd40BitRC2-CBC'] = '1.2.840.113549.1.12.1.6';
+
+// symmetric key algorithm oids
+oids['1.2.840.113549.3.7'] = 'des-EDE3-CBC';
+oids['des-EDE3-CBC'] = '1.2.840.113549.3.7';
+oids['2.16.840.1.101.3.4.1.2'] = 'aes128-CBC';
+oids['aes128-CBC'] = '2.16.840.1.101.3.4.1.2';
+oids['2.16.840.1.101.3.4.1.22'] = 'aes192-CBC';
+oids['aes192-CBC'] = '2.16.840.1.101.3.4.1.22';
+oids['2.16.840.1.101.3.4.1.42'] = 'aes256-CBC';
+oids['aes256-CBC'] = '2.16.840.1.101.3.4.1.42';
+
+// certificate issuer/subject OIDs
+oids['2.5.4.3'] = 'commonName';
+oids['commonName'] = '2.5.4.3';
+oids['2.5.4.5'] = 'serialName';
+oids['serialName'] = '2.5.4.5';
+oids['2.5.4.6'] = 'countryName';
+oids['countryName'] = '2.5.4.6';
+oids['2.5.4.7'] = 'localityName';
+oids['localityName'] = '2.5.4.7';
+oids['2.5.4.8'] = 'stateOrProvinceName';
+oids['stateOrProvinceName'] = '2.5.4.8';
+oids['2.5.4.10'] = 'organizationName';
+oids['organizationName'] = '2.5.4.10';
+oids['2.5.4.11'] = 'organizationalUnitName';
+oids['organizationalUnitName'] = '2.5.4.11';
+
+// X.509 extension OIDs
+oids['2.16.840.1.113730.1.1'] = 'nsCertType';
+oids['nsCertType'] = '2.16.840.1.113730.1.1';
+oids['2.5.29.1'] = 'authorityKeyIdentifier'; // deprecated, use .35
+oids['2.5.29.2'] = 'keyAttributes'; // obsolete use .37 or .15
+oids['2.5.29.3'] = 'certificatePolicies'; // deprecated, use .32
+oids['2.5.29.4'] = 'keyUsageRestriction'; // obsolete use .37 or .15
+oids['2.5.29.5'] = 'policyMapping'; // deprecated use .33
+oids['2.5.29.6'] = 'subtreesConstraint'; // obsolete use .30
+oids['2.5.29.7'] = 'subjectAltName'; // deprecated use .17
+oids['2.5.29.8'] = 'issuerAltName'; // deprecated use .18
+oids['2.5.29.9'] = 'subjectDirectoryAttributes';
+oids['2.5.29.10'] = 'basicConstraints'; // deprecated use .19
+oids['2.5.29.11'] = 'nameConstraints'; // deprecated use .30
+oids['2.5.29.12'] = 'policyConstraints'; // deprecated use .36
+oids['2.5.29.13'] = 'basicConstraints'; // deprecated use .19
+oids['2.5.29.14'] = 'subjectKeyIdentifier';
+oids['subjectKeyIdentifier'] = '2.5.29.14';
+oids['2.5.29.15'] = 'keyUsage';
+oids['keyUsage'] = '2.5.29.15';
+oids['2.5.29.16'] = 'privateKeyUsagePeriod';
+oids['2.5.29.17'] = 'subjectAltName';
+oids['subjectAltName'] = '2.5.29.17';
+oids['2.5.29.18'] = 'issuerAltName';
+oids['issuerAltName'] = '2.5.29.18';
+oids['2.5.29.19'] = 'basicConstraints';
+oids['basicConstraints'] = '2.5.29.19';
+oids['2.5.29.20'] = 'cRLNumber';
+oids['2.5.29.21'] = 'cRLReason';
+oids['2.5.29.22'] = 'expirationDate';
+oids['2.5.29.23'] = 'instructionCode';
+oids['2.5.29.24'] = 'invalidityDate';
+oids['2.5.29.25'] = 'cRLDistributionPoints'; // deprecated use .31
+oids['2.5.29.26'] = 'issuingDistributionPoint'; // deprecated use .28
+oids['2.5.29.27'] = 'deltaCRLIndicator';
+oids['2.5.29.28'] = 'issuingDistributionPoint';
+oids['2.5.29.29'] = 'certificateIssuer';
+oids['2.5.29.30'] = 'nameConstraints';
+oids['2.5.29.31'] = 'cRLDistributionPoints';
+oids['2.5.29.32'] = 'certificatePolicies';
+oids['2.5.29.33'] = 'policyMappings';
+oids['2.5.29.34'] = 'policyConstraints'; // deprecated use .36
+oids['2.5.29.35'] = 'authorityKeyIdentifier';
+oids['2.5.29.36'] = 'policyConstraints';
+oids['2.5.29.37'] = 'extKeyUsage';
+oids['extKeyUsage'] = '2.5.29.37';
+oids['2.5.29.46'] = 'freshestCRL';
+oids['2.5.29.54'] = 'inhibitAnyPolicy';
+
+// extKeyUsage purposes
+oids['1.3.6.1.5.5.7.3.1'] = 'serverAuth';
+oids['serverAuth'] = '1.3.6.1.5.5.7.3.1';
+oids['1.3.6.1.5.5.7.3.2'] = 'clientAuth';
+oids['clientAuth'] = '1.3.6.1.5.5.7.3.2';
+oids['1.3.6.1.5.5.7.3.3'] = 'codeSigning';
+oids['codeSigning'] = '1.3.6.1.5.5.7.3.3';
+oids['1.3.6.1.5.5.7.3.4'] = 'emailProtection';
+oids['emailProtection'] = '1.3.6.1.5.5.7.3.4';
+oids['1.3.6.1.5.5.7.3.8'] = 'timeStamping';
+oids['timeStamping'] = '1.3.6.1.5.5.7.3.8';
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'oids';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pbe.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pbe.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pbe.js
new file mode 100644
index 0000000..0b25758
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pbe.js
@@ -0,0 +1,975 @@
+/**
+ * Password-based encryption functions.
+ *
+ * @author Dave Longley
+ * @author Stefan Siegl <st...@brokenpipe.de>
+ *
+ * Copyright (c) 2010-2013 Digital Bazaar, Inc.
+ * Copyright (c) 2012 Stefan Siegl <st...@brokenpipe.de>
+ *
+ * An EncryptedPrivateKeyInfo:
+ *
+ * EncryptedPrivateKeyInfo ::= SEQUENCE {
+ * encryptionAlgorithm EncryptionAlgorithmIdentifier,
+ * encryptedData EncryptedData }
+ *
+ * EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * EncryptedData ::= OCTET STRING
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+if(typeof BigInteger === 'undefined') {
+ var BigInteger = forge.jsbn.BigInteger;
+}
+
+// shortcut for asn.1 API
+var asn1 = forge.asn1;
+
+/* Password-based encryption implementation. */
+var pki = forge.pki = forge.pki || {};
+pki.pbe = forge.pbe = forge.pbe || {};
+var oids = pki.oids;
+
+// validator for an EncryptedPrivateKeyInfo structure
+// Note: Currently only works w/algorithm params
+var encryptedPrivateKeyValidator = {
+ name: 'EncryptedPrivateKeyInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'EncryptedPrivateKeyInfo.encryptionAlgorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'AlgorithmIdentifier.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'encryptionOid'
+ }, {
+ name: 'AlgorithmIdentifier.parameters',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'encryptionParams'
+ }]
+ }, {
+ // encryptedData
+ name: 'EncryptedPrivateKeyInfo.encryptedData',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ constructed: false,
+ capture: 'encryptedData'
+ }]
+};
+
+// validator for a PBES2Algorithms structure
+// Note: Currently only works w/PBKDF2 + AES encryption schemes
+var PBES2AlgorithmsValidator = {
+ name: 'PBES2Algorithms',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'PBES2Algorithms.keyDerivationFunc',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'PBES2Algorithms.keyDerivationFunc.oid',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'kdfOid'
+ }, {
+ name: 'PBES2Algorithms.params',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'PBES2Algorithms.params.salt',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ constructed: false,
+ capture: 'kdfSalt'
+ }, {
+ name: 'PBES2Algorithms.params.iterationCount',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ onstructed: true,
+ capture: 'kdfIterationCount'
+ }]
+ }]
+ }, {
+ name: 'PBES2Algorithms.encryptionScheme',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'PBES2Algorithms.encryptionScheme.oid',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'encOid'
+ }, {
+ name: 'PBES2Algorithms.encryptionScheme.iv',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ constructed: false,
+ capture: 'encIv'
+ }]
+ }]
+};
+
+var pkcs12PbeParamsValidator = {
+ name: 'pkcs-12PbeParams',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'pkcs-12PbeParams.salt',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ constructed: false,
+ capture: 'salt'
+ }, {
+ name: 'pkcs-12PbeParams.iterations',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'iterations'
+ }]
+};
+
+/**
+ * Encrypts a ASN.1 PrivateKeyInfo object, producing an EncryptedPrivateKeyInfo.
+ *
+ * PBES2Algorithms ALGORITHM-IDENTIFIER ::=
+ * { {PBES2-params IDENTIFIED BY id-PBES2}, ...}
+ *
+ * id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13}
+ *
+ * PBES2-params ::= SEQUENCE {
+ * keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},
+ * encryptionScheme AlgorithmIdentifier {{PBES2-Encs}}
+ * }
+ *
+ * PBES2-KDFs ALGORITHM-IDENTIFIER ::=
+ * { {PBKDF2-params IDENTIFIED BY id-PBKDF2}, ... }
+ *
+ * PBES2-Encs ALGORITHM-IDENTIFIER ::= { ... }
+ *
+ * PBKDF2-params ::= SEQUENCE {
+ * salt CHOICE {
+ * specified OCTET STRING,
+ * otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}}
+ * },
+ * iterationCount INTEGER (1..MAX),
+ * keyLength INTEGER (1..MAX) OPTIONAL,
+ * prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1
+ * }
+ *
+ * @param obj the ASN.1 PrivateKeyInfo object.
+ * @param password the password to encrypt with.
+ * @param options:
+ * algorithm the encryption algorithm to use
+ * ('aes128', 'aes192', 'aes256', '3des'), defaults to 'aes128'.
+ * count the iteration count to use.
+ * saltSize the salt size to use.
+ *
+ * @return the ASN.1 EncryptedPrivateKeyInfo.
+ */
+pki.encryptPrivateKeyInfo = function(obj, password, options) {
+ // set default options
+ options = options || {};
+ options.saltSize = options.saltSize || 8;
+ options.count = options.count || 2048;
+ options.algorithm = options.algorithm || 'aes128';
+
+ // generate PBE params
+ var salt = forge.random.getBytesSync(options.saltSize);
+ var count = options.count;
+ var countBytes = asn1.integerToDer(count);
+ var dkLen;
+ var encryptionAlgorithm;
+ var encryptedData;
+ if(options.algorithm.indexOf('aes') === 0 || options.algorithm === 'des') {
+ // Do PBES2
+ var ivLen, encOid, cipherFn;
+ switch(options.algorithm) {
+ case 'aes128':
+ dkLen = 16;
+ ivLen = 16;
+ encOid = oids['aes128-CBC'];
+ cipherFn = forge.aes.createEncryptionCipher;
+ break;
+ case 'aes192':
+ dkLen = 24;
+ ivLen = 16;
+ encOid = oids['aes192-CBC'];
+ cipherFn = forge.aes.createEncryptionCipher;
+ break;
+ case 'aes256':
+ dkLen = 32;
+ ivLen = 16;
+ encOid = oids['aes256-CBC'];
+ cipherFn = forge.aes.createEncryptionCipher;
+ break;
+ case 'des':
+ dkLen = 8;
+ ivLen = 8;
+ encOid = oids['desCBC'];
+ cipherFn = forge.des.createEncryptionCipher;
+ break;
+ default:
+ var error = new Error('Cannot encrypt private key. Unknown encryption algorithm.');
+ error.algorithm = options.algorithm;
+ throw error;
+ }
+
+ // encrypt private key using pbe SHA-1 and AES/DES
+ var dk = forge.pkcs5.pbkdf2(password, salt, count, dkLen);
+ var iv = forge.random.getBytesSync(ivLen);
+ var cipher = cipherFn(dk);
+ cipher.start(iv);
+ cipher.update(asn1.toDer(obj));
+ cipher.finish();
+ encryptedData = cipher.output.getBytes();
+
+ encryptionAlgorithm = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(oids['pkcs5PBES2']).getBytes()),
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // keyDerivationFunc
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(oids['pkcs5PBKDF2']).getBytes()),
+ // PBKDF2-params
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // salt
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, salt),
+ // iteration count
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ countBytes.getBytes())
+ ])
+ ]),
+ // encryptionScheme
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(encOid).getBytes()),
+ // iv
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, iv)
+ ])
+ ])
+ ]);
+ } else if(options.algorithm === '3des') {
+ // Do PKCS12 PBE
+ dkLen = 24;
+
+ var saltBytes = new forge.util.ByteBuffer(salt);
+ var dk = pki.pbe.generatePkcs12Key(password, saltBytes, 1, count, dkLen);
+ var iv = pki.pbe.generatePkcs12Key(password, saltBytes, 2, count, dkLen);
+ var cipher = forge.des.createEncryptionCipher(dk);
+ cipher.start(iv);
+ cipher.update(asn1.toDer(obj));
+ cipher.finish();
+ encryptedData = cipher.output.getBytes();
+
+ encryptionAlgorithm = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(oids['pbeWithSHAAnd3-KeyTripleDES-CBC']).getBytes()),
+ // pkcs-12PbeParams
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // salt
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, salt),
+ // iteration count
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ countBytes.getBytes())
+ ])
+ ]);
+ } else {
+ var error = new Error('Cannot encrypt private key. Unknown encryption algorithm.');
+ error.algorithm = options.algorithm;
+ throw error;
+ }
+
+ // EncryptedPrivateKeyInfo
+ var rval = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // encryptionAlgorithm
+ encryptionAlgorithm,
+ // encryptedData
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, encryptedData)
+ ]);
+ return rval;
+};
+
+/**
+ * Decrypts a ASN.1 PrivateKeyInfo object.
+ *
+ * @param obj the ASN.1 EncryptedPrivateKeyInfo object.
+ * @param password the password to decrypt with.
+ *
+ * @return the ASN.1 PrivateKeyInfo on success, null on failure.
+ */
+pki.decryptPrivateKeyInfo = function(obj, password) {
+ var rval = null;
+
+ // get PBE params
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(obj, encryptedPrivateKeyValidator, capture, errors)) {
+ var error = new Error('Cannot read encrypted private key. ' +
+ 'ASN.1 object is not a supported EncryptedPrivateKeyInfo.');
+ error.errors = errors;
+ throw error;
+ }
+
+ // get cipher
+ var oid = asn1.derToOid(capture.encryptionOid);
+ var cipher = pki.pbe.getCipher(oid, capture.encryptionParams, password);
+
+ // get encrypted data
+ var encrypted = forge.util.createBuffer(capture.encryptedData);
+
+ cipher.update(encrypted);
+ if(cipher.finish()) {
+ rval = asn1.fromDer(cipher.output);
+ }
+
+ return rval;
+};
+
+/**
+ * Converts a EncryptedPrivateKeyInfo to PEM format.
+ *
+ * @param epki the EncryptedPrivateKeyInfo.
+ * @param maxline the maximum characters per line, defaults to 64.
+ *
+ * @return the PEM-formatted encrypted private key.
+ */
+pki.encryptedPrivateKeyToPem = function(epki, maxline) {
+ // convert to DER, then PEM-encode
+ var msg = {
+ type: 'ENCRYPTED PRIVATE KEY',
+ body: asn1.toDer(epki).getBytes()
+ };
+ return forge.pem.encode(msg, {maxline: maxline});
+};
+
+/**
+ * Converts a PEM-encoded EncryptedPrivateKeyInfo to ASN.1 format. Decryption
+ * is not performed.
+ *
+ * @param pem the EncryptedPrivateKeyInfo in PEM-format.
+ *
+ * @return the ASN.1 EncryptedPrivateKeyInfo.
+ */
+pki.encryptedPrivateKeyFromPem = function(pem) {
+ var msg = forge.pem.decode(pem)[0];
+
+ if(msg.type !== 'ENCRYPTED PRIVATE KEY') {
+ var error = new Error('Could not convert encrypted private key from PEM; ' +
+ 'PEM header type is "ENCRYPTED PRIVATE KEY".');
+ error.headerType = msg.type;
+ throw error;
+ }
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
+ throw new Error('Could not convert encrypted private key from PEM; ' +
+ 'PEM is encrypted.');
+ }
+
+ // convert DER to ASN.1 object
+ return asn1.fromDer(msg.body);
+};
+
+/**
+ * Encrypts an RSA private key. By default, the key will be wrapped in
+ * a PrivateKeyInfo and encrypted to produce a PKCS#8 EncryptedPrivateKeyInfo.
+ * This is the standard, preferred way to encrypt a private key.
+ *
+ * To produce a non-standard PEM-encrypted private key that uses encapsulated
+ * headers to indicate the encryption algorithm (old-style non-PKCS#8 OpenSSL
+ * private key encryption), set the 'legacy' option to true. Note: Using this
+ * option will cause the iteration count to be forced to 1.
+ *
+ * Note: The 'des' algorithm is supported, but it is not considered to be
+ * secure because it only uses a single 56-bit key. If possible, it is highly
+ * recommended that a different algorithm be used.
+ *
+ * @param rsaKey the RSA key to encrypt.
+ * @param password the password to use.
+ * @param options:
+ * algorithm: the encryption algorithm to use
+ * ('aes128', 'aes192', 'aes256', '3des', 'des').
+ * count: the iteration count to use.
+ * saltSize: the salt size to use.
+ * legacy: output an old non-PKCS#8 PEM-encrypted+encapsulated
+ * headers (DEK-Info) private key.
+ *
+ * @return the PEM-encoded ASN.1 EncryptedPrivateKeyInfo.
+ */
+pki.encryptRsaPrivateKey = function(rsaKey, password, options) {
+ // standard PKCS#8
+ options = options || {};
+ if(!options.legacy) {
+ // encrypt PrivateKeyInfo
+ var rval = pki.wrapRsaPrivateKey(pki.privateKeyToAsn1(rsaKey));
+ rval = pki.encryptPrivateKeyInfo(rval, password, options);
+ return pki.encryptedPrivateKeyToPem(rval);
+ }
+
+ // legacy non-PKCS#8
+ var algorithm;
+ var iv;
+ var dkLen;
+ var cipherFn;
+ switch(options.algorithm) {
+ case 'aes128':
+ algorithm = 'AES-128-CBC';
+ dkLen = 16;
+ iv = forge.random.getBytesSync(16);
+ cipherFn = forge.aes.createEncryptionCipher;
+ break;
+ case 'aes192':
+ algorithm = 'AES-192-CBC';
+ dkLen = 24;
+ iv = forge.random.getBytesSync(16);
+ cipherFn = forge.aes.createEncryptionCipher;
+ break;
+ case 'aes256':
+ algorithm = 'AES-256-CBC';
+ dkLen = 32;
+ iv = forge.random.getBytesSync(16);
+ cipherFn = forge.aes.createEncryptionCipher;
+ break;
+ case '3des':
+ algorithm = 'DES-EDE3-CBC';
+ dkLen = 24;
+ iv = forge.random.getBytesSync(8);
+ cipherFn = forge.des.createEncryptionCipher;
+ break;
+ case 'des':
+ algorithm = 'DES-CBC';
+ dkLen = 8;
+ iv = forge.random.getBytesSync(8);
+ cipherFn = forge.des.createEncryptionCipher;
+ break;
+ default:
+ var error = new Error('Could not encrypt RSA private key; unsupported ' +
+ 'encryption algorithm "' + options.algorithm + '".');
+ error.algorithm = options.algorithm;
+ throw error;
+ }
+
+ // encrypt private key using OpenSSL legacy key derivation
+ var dk = forge.pbe.opensslDeriveBytes(password, iv.substr(0, 8), dkLen);
+ var cipher = cipherFn(dk);
+ cipher.start(iv);
+ cipher.update(asn1.toDer(pki.privateKeyToAsn1(rsaKey)));
+ cipher.finish();
+
+ var msg = {
+ type: 'RSA PRIVATE KEY',
+ procType: {
+ version: '4',
+ type: 'ENCRYPTED'
+ },
+ dekInfo: {
+ algorithm: algorithm,
+ parameters: forge.util.bytesToHex(iv).toUpperCase()
+ },
+ body: cipher.output.getBytes()
+ };
+ return forge.pem.encode(msg);
+};
+
+/**
+ * Decrypts an RSA private key.
+ *
+ * @param pem the PEM-formatted EncryptedPrivateKeyInfo to decrypt.
+ * @param password the password to use.
+ *
+ * @return the RSA key on success, null on failure.
+ */
+pki.decryptRsaPrivateKey = function(pem, password) {
+ var rval = null;
+
+ var msg = forge.pem.decode(pem)[0];
+
+ if(msg.type !== 'ENCRYPTED PRIVATE KEY' &&
+ msg.type !== 'PRIVATE KEY' &&
+ msg.type !== 'RSA PRIVATE KEY') {
+ var error = new Error('Could not convert private key from PEM; PEM header type ' +
+ 'is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');
+ error.headerType = error;
+ throw error;
+ }
+
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
+ var dkLen;
+ var cipherFn;
+ switch(msg.dekInfo.algorithm) {
+ case 'DES-CBC':
+ dkLen = 8;
+ cipherFn = forge.des.createDecryptionCipher;
+ break;
+ case 'DES-EDE3-CBC':
+ dkLen = 24;
+ cipherFn = forge.des.createDecryptionCipher;
+ break;
+ case 'AES-128-CBC':
+ dkLen = 16;
+ cipherFn = forge.aes.createDecryptionCipher;
+ break;
+ case 'AES-192-CBC':
+ dkLen = 24;
+ cipherFn = forge.aes.createDecryptionCipher;
+ break;
+ case 'AES-256-CBC':
+ dkLen = 32;
+ cipherFn = forge.aes.createDecryptionCipher;
+ break;
+ case 'RC2-40-CBC':
+ dkLen = 5;
+ cipherFn = function(key) {
+ return forge.rc2.createDecryptionCipher(key, 40);
+ };
+ break;
+ case 'RC2-64-CBC':
+ dkLen = 8;
+ cipherFn = function(key) {
+ return forge.rc2.createDecryptionCipher(key, 64);
+ };
+ break;
+ case 'RC2-128-CBC':
+ dkLen = 16;
+ cipherFn = function(key) {
+ return forge.rc2.createDecryptionCipher(key, 128);
+ };
+ break;
+ default:
+ var error = new Error('Could not decrypt private key; unsupported ' +
+ 'encryption algorithm "' + msg.dekInfo.algorithm + '".');
+ error.algorithm = msg.dekInfo.algorithm;
+ throw error;
+ }
+
+ // use OpenSSL legacy key derivation
+ var iv = forge.util.hexToBytes(msg.dekInfo.parameters);
+ var dk = forge.pbe.opensslDeriveBytes(password, iv.substr(0, 8), dkLen);
+ var cipher = cipherFn(dk);
+ cipher.start(iv);
+ cipher.update(forge.util.createBuffer(msg.body));
+ if(cipher.finish()) {
+ rval = cipher.output.getBytes();
+ } else {
+ return rval;
+ }
+ } else {
+ rval = msg.body;
+ }
+
+ if(msg.type === 'ENCRYPTED PRIVATE KEY') {
+ rval = pki.decryptPrivateKeyInfo(asn1.fromDer(rval), password);
+ } else {
+ // decryption already performed above
+ rval = asn1.fromDer(rval);
+ }
+
+ if(rval !== null) {
+ rval = pki.privateKeyFromAsn1(rval);
+ }
+
+ return rval;
+};
+
+/**
+ * Derives a PKCS#12 key.
+ *
+ * @param password the password to derive the key material from, null or
+ * undefined for none.
+ * @param salt the salt, as a ByteBuffer, to use.
+ * @param id the PKCS#12 ID byte (1 = key material, 2 = IV, 3 = MAC).
+ * @param iter the iteration count.
+ * @param n the number of bytes to derive from the password.
+ * @param md the message digest to use, defaults to SHA-1.
+ *
+ * @return a ByteBuffer with the bytes derived from the password.
+ */
+pki.pbe.generatePkcs12Key = function(password, salt, id, iter, n, md) {
+ var j, l;
+
+ if(typeof md === 'undefined' || md === null) {
+ md = forge.md.sha1.create();
+ }
+
+ var u = md.digestLength;
+ var v = md.blockLength;
+ var result = new forge.util.ByteBuffer();
+
+ /* Convert password to Unicode byte buffer + trailing 0-byte. */
+ var passBuf = new forge.util.ByteBuffer();
+ if(password !== null && password !== undefined) {
+ for(l = 0; l < password.length; l++) {
+ passBuf.putInt16(password.charCodeAt(l));
+ }
+ passBuf.putInt16(0);
+ }
+
+ /* Length of salt and password in BYTES. */
+ var p = passBuf.length();
+ var s = salt.length();
+
+ /* 1. Construct a string, D (the "diversifier"), by concatenating
+ v copies of ID. */
+ var D = new forge.util.ByteBuffer();
+ D.fillWithByte(id, v);
+
+ /* 2. Concatenate copies of the salt together to create a string S of length
+ v * ceil(s / v) bytes (the final copy of the salt may be trunacted
+ to create S).
+ Note that if the salt is the empty string, then so is S. */
+ var Slen = v * Math.ceil(s / v);
+ var S = new forge.util.ByteBuffer();
+ for(l = 0; l < Slen; l ++) {
+ S.putByte(salt.at(l % s));
+ }
+
+ /* 3. Concatenate copies of the password together to create a string P of
+ length v * ceil(p / v) bytes (the final copy of the password may be
+ truncated to create P).
+ Note that if the password is the empty string, then so is P. */
+ var Plen = v * Math.ceil(p / v);
+ var P = new forge.util.ByteBuffer();
+ for(l = 0; l < Plen; l ++) {
+ P.putByte(passBuf.at(l % p));
+ }
+
+ /* 4. Set I=S||P to be the concatenation of S and P. */
+ var I = S;
+ I.putBuffer(P);
+
+ /* 5. Set c=ceil(n / u). */
+ var c = Math.ceil(n / u);
+
+ /* 6. For i=1, 2, ..., c, do the following: */
+ for(var i = 1; i <= c; i ++) {
+ /* a) Set Ai=H^r(D||I). (l.e. the rth hash of D||I, H(H(H(...H(D||I)))) */
+ var buf = new forge.util.ByteBuffer();
+ buf.putBytes(D.bytes());
+ buf.putBytes(I.bytes());
+ for(var round = 0; round < iter; round ++) {
+ md.start();
+ md.update(buf.getBytes());
+ buf = md.digest();
+ }
+
+ /* b) Concatenate copies of Ai to create a string B of length v bytes (the
+ final copy of Ai may be truncated to create B). */
+ var B = new forge.util.ByteBuffer();
+ for(l = 0; l < v; l ++) {
+ B.putByte(buf.at(l % u));
+ }
+
+ /* c) Treating I as a concatenation I0, I1, ..., Ik-1 of v-byte blocks,
+ where k=ceil(s / v) + ceil(p / v), modify I by setting
+ Ij=(Ij+B+1) mod 2v for each j. */
+ var k = Math.ceil(s / v) + Math.ceil(p / v);
+ var Inew = new forge.util.ByteBuffer();
+ for(j = 0; j < k; j ++) {
+ var chunk = new forge.util.ByteBuffer(I.getBytes(v));
+ var x = 0x1ff;
+ for(l = B.length() - 1; l >= 0; l --) {
+ x = x >> 8;
+ x += B.at(l) + chunk.at(l);
+ chunk.setAt(l, x & 0xff);
+ }
+ Inew.putBuffer(chunk);
+ }
+ I = Inew;
+
+ /* Add Ai to A. */
+ result.putBuffer(buf);
+ }
+
+ result.truncate(result.length() - n);
+ return result;
+};
+
+/**
+ * Get new Forge cipher object instance.
+ *
+ * @param oid the OID (in string notation).
+ * @param params the ASN.1 params object.
+ * @param password the password to decrypt with.
+ *
+ * @return new cipher object instance.
+ */
+pki.pbe.getCipher = function(oid, params, password) {
+ switch(oid) {
+ case pki.oids['pkcs5PBES2']:
+ return pki.pbe.getCipherForPBES2(oid, params, password);
+
+ case pki.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:
+ case pki.oids['pbewithSHAAnd40BitRC2-CBC']:
+ return pki.pbe.getCipherForPKCS12PBE(oid, params, password);
+
+ default:
+ var error = new Error('Cannot read encrypted PBE data block. Unsupported OID.');
+ error.oid = oid;
+ error.supportedOids = [
+ 'pkcs5PBES2',
+ 'pbeWithSHAAnd3-KeyTripleDES-CBC',
+ 'pbewithSHAAnd40BitRC2-CBC'
+ ];
+ throw error;
+ }
+};
+
+/**
+ * Get new Forge cipher object instance according to PBES2 params block.
+ *
+ * The returned cipher instance is already started using the IV
+ * from PBES2 parameter block.
+ *
+ * @param oid the PKCS#5 PBKDF2 OID (in string notation).
+ * @param params the ASN.1 PBES2-params object.
+ * @param password the password to decrypt with.
+ *
+ * @return new cipher object instance.
+ */
+pki.pbe.getCipherForPBES2 = function(oid, params, password) {
+ // get PBE params
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(params, PBES2AlgorithmsValidator, capture, errors)) {
+ var error = new Error('Cannot read password-based-encryption algorithm ' +
+ 'parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.');
+ error.errors = errors;
+ throw error;
+ }
+
+ // check oids
+ oid = asn1.derToOid(capture.kdfOid);
+ if(oid !== pki.oids['pkcs5PBKDF2']) {
+ var error = new Error('Cannot read encrypted private key. ' +
+ 'Unsupported key derivation function OID.');
+ error.oid = oid;
+ error.supportedOids = ['pkcs5PBKDF2'];
+ throw error;
+ }
+ oid = asn1.derToOid(capture.encOid);
+ if(oid !== pki.oids['aes128-CBC'] &&
+ oid !== pki.oids['aes192-CBC'] &&
+ oid !== pki.oids['aes256-CBC'] &&
+ oid !== pki.oids['des-EDE3-CBC'] &&
+ oid !== pki.oids['desCBC']) {
+ var error = new Error('Cannot read encrypted private key. ' +
+ 'Unsupported encryption scheme OID.');
+ error.oid = oid;
+ error.supportedOids = [
+ 'aes128-CBC', 'aes192-CBC', 'aes256-CBC', 'des-EDE3-CBC', 'desCBC'];
+ throw error;
+ }
+
+ // set PBE params
+ var salt = capture.kdfSalt;
+ var count = forge.util.createBuffer(capture.kdfIterationCount);
+ count = count.getInt(count.length() << 3);
+ var dkLen;
+ var cipherFn;
+ switch(pki.oids[oid]) {
+ case 'aes128-CBC':
+ dkLen = 16;
+ cipherFn = forge.aes.createDecryptionCipher;
+ break;
+ case 'aes192-CBC':
+ dkLen = 24;
+ cipherFn = forge.aes.createDecryptionCipher;
+ break;
+ case 'aes256-CBC':
+ dkLen = 32;
+ cipherFn = forge.aes.createDecryptionCipher;
+ break;
+ case 'des-EDE3-CBC':
+ dkLen = 24;
+ cipherFn = forge.des.createDecryptionCipher;
+ break;
+ case 'desCBC':
+ dkLen = 8;
+ cipherFn = forge.des.createDecryptionCipher;
+ break;
+ }
+
+ // decrypt private key using pbe SHA-1 and AES/DES
+ var dk = forge.pkcs5.pbkdf2(password, salt, count, dkLen);
+ var iv = capture.encIv;
+ var cipher = cipherFn(dk);
+ cipher.start(iv);
+
+ return cipher;
+};
+
+/**
+ * Get new Forge cipher object instance for PKCS#12 PBE.
+ *
+ * The returned cipher instance is already started using the key & IV
+ * derived from the provided password and PKCS#12 PBE salt.
+ *
+ * @param oid The PKCS#12 PBE OID (in string notation).
+ * @param params The ASN.1 PKCS#12 PBE-params object.
+ * @param password The password to decrypt with.
+ *
+ * @return the new cipher object instance.
+ */
+pki.pbe.getCipherForPKCS12PBE = function(oid, params, password) {
+ // get PBE params
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(params, pkcs12PbeParamsValidator, capture, errors)) {
+ var error = new Error('Cannot read password-based-encryption algorithm ' +
+ 'parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.');
+ error.errors = errors;
+ throw error;
+ }
+
+ var salt = forge.util.createBuffer(capture.salt);
+ var count = forge.util.createBuffer(capture.iterations);
+ count = count.getInt(count.length() << 3);
+
+ var dkLen, dIvLen, cipherFn;
+ switch(oid) {
+ case pki.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:
+ dkLen = 24;
+ dIvLen = 8;
+ cipherFn = forge.des.startDecrypting;
+ break;
+
+ case pki.oids['pbewithSHAAnd40BitRC2-CBC']:
+ dkLen = 5;
+ dIvLen = 8;
+ cipherFn = function(key, iv) {
+ var cipher = forge.rc2.createDecryptionCipher(key, 40);
+ cipher.start(iv, null);
+ return cipher;
+ };
+ break;
+
+ default:
+ var error = new Error('Cannot read PKCS #12 PBE data block. Unsupported OID.');
+ error.oid = oid;
+ throw error;
+ }
+
+ var key = pki.pbe.generatePkcs12Key(password, salt, 1, count, dkLen);
+ var iv = pki.pbe.generatePkcs12Key(password, salt, 2, count, dIvLen);
+
+ return cipherFn(key, iv);
+};
+
+/**
+ * OpenSSL's legacy key derivation function.
+ *
+ * See: http://www.openssl.org/docs/crypto/EVP_BytesToKey.html
+ *
+ * @param password the password to derive the key from.
+ * @param salt the salt to use, null for none.
+ * @param dkLen the number of bytes needed for the derived key.
+ * @param [options] the options to use:
+ * [md] an optional message digest object to use.
+ */
+pki.pbe.opensslDeriveBytes = function(password, salt, dkLen, md) {
+ if(typeof md === 'undefined' || md === null) {
+ md = forge.md.md5.create();
+ }
+ if(salt === null) {
+ salt = '';
+ }
+ var digests = [hash(md, password + salt)];
+ for(var length = 16, i = 1; length < dkLen; ++i, length += 16) {
+ digests.push(hash(md, digests[i - 1] + password + salt));
+ }
+ return digests.join('').substr(0, dkLen);
+};
+
+function hash(md, bytes) {
+ return md.start().update(bytes).digest().getBytes();
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'pbe';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define([
+ 'require',
+ 'module',
+ './aes',
+ './asn1',
+ './des',
+ './md',
+ './oids',
+ './pem',
+ './pbkdf2',
+ './random',
+ './rc2',
+ './rsa',
+ './util'
+], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pbkdf2.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pbkdf2.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pbkdf2.js
new file mode 100644
index 0000000..d983610
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pbkdf2.js
@@ -0,0 +1,214 @@
+/**
+ * Password-Based Key-Derivation Function #2 implementation.
+ *
+ * See RFC 2898 for details.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2013 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+var pkcs5 = forge.pkcs5 = forge.pkcs5 || {};
+
+/**
+ * Derives a key from a password.
+ *
+ * @param p the password as a string of bytes.
+ * @param s the salt as a string of bytes.
+ * @param c the iteration count, a positive integer.
+ * @param dkLen the intended length, in bytes, of the derived key,
+ * (max: 2^32 - 1) * hash length of the PRF.
+ * @param md the message digest to use in the PRF, defaults to SHA-1.
+ *
+ * @return the derived key, as a string of bytes.
+ */
+forge.pbkdf2 = pkcs5.pbkdf2 = function(p, s, c, dkLen, md, callback) {
+ if(typeof md === 'function') {
+ callback = md;
+ md = null;
+ }
+ // default prf to SHA-1
+ if(typeof md === 'undefined' || md === null) {
+ md = forge.md.sha1.create();
+ }
+
+ var hLen = md.digestLength;
+
+ /* 1. If dkLen > (2^32 - 1) * hLen, output "derived key too long" and
+ stop. */
+ if(dkLen > (0xFFFFFFFF * hLen)) {
+ var err = new Error('Derived key is too long.');
+ if(callback) {
+ return callback(err);
+ }
+ throw err;
+ }
+
+ /* 2. Let len be the number of hLen-octet blocks in the derived key,
+ rounding up, and let r be the number of octets in the last
+ block:
+
+ len = CEIL(dkLen / hLen),
+ r = dkLen - (len - 1) * hLen. */
+ var len = Math.ceil(dkLen / hLen);
+ var r = dkLen - (len - 1) * hLen;
+
+ /* 3. For each block of the derived key apply the function F defined
+ below to the password P, the salt S, the iteration count c, and
+ the block index to compute the block:
+
+ T_1 = F(P, S, c, 1),
+ T_2 = F(P, S, c, 2),
+ ...
+ T_len = F(P, S, c, len),
+
+ where the function F is defined as the exclusive-or sum of the
+ first c iterates of the underlying pseudorandom function PRF
+ applied to the password P and the concatenation of the salt S
+ and the block index i:
+
+ F(P, S, c, i) = u_1 XOR u_2 XOR ... XOR u_c
+
+ where
+
+ u_1 = PRF(P, S || INT(i)),
+ u_2 = PRF(P, u_1),
+ ...
+ u_c = PRF(P, u_{c-1}).
+
+ Here, INT(i) is a four-octet encoding of the integer i, most
+ significant octet first. */
+ var prf = forge.hmac.create();
+ prf.start(md, p);
+ var dk = '';
+ var xor, u_c, u_c1;
+
+ // sync version
+ if(!callback) {
+ for(var i = 1; i <= len; ++i) {
+ // PRF(P, S || INT(i)) (first iteration)
+ prf.start(null, null);
+ prf.update(s);
+ prf.update(forge.util.int32ToBytes(i));
+ xor = u_c1 = prf.digest().getBytes();
+
+ // PRF(P, u_{c-1}) (other iterations)
+ for(var j = 2; j <= c; ++j) {
+ prf.start(null, null);
+ prf.update(u_c1);
+ u_c = prf.digest().getBytes();
+ // F(p, s, c, i)
+ xor = forge.util.xorBytes(xor, u_c, hLen);
+ u_c1 = u_c;
+ }
+
+ /* 4. Concatenate the blocks and extract the first dkLen octets to
+ produce a derived key DK:
+
+ DK = T_1 || T_2 || ... || T_len<0..r-1> */
+ dk += (i < len) ? xor : xor.substr(0, r);
+ }
+ /* 5. Output the derived key DK. */
+ return dk;
+ }
+
+ // async version
+ var i = 1, j;
+ function outer() {
+ if(i > len) {
+ // done
+ return callback(null, dk);
+ }
+
+ // PRF(P, S || INT(i)) (first iteration)
+ prf.start(null, null);
+ prf.update(s);
+ prf.update(forge.util.int32ToBytes(i));
+ xor = u_c1 = prf.digest().getBytes();
+
+ // PRF(P, u_{c-1}) (other iterations)
+ j = 2;
+ inner();
+ }
+
+ function inner() {
+ if(j <= c) {
+ prf.start(null, null);
+ prf.update(u_c1);
+ u_c = prf.digest().getBytes();
+ // F(p, s, c, i)
+ xor = forge.util.xorBytes(xor, u_c, hLen);
+ u_c1 = u_c;
+ ++j;
+ return forge.util.setImmediate(inner);
+ }
+
+ /* 4. Concatenate the blocks and extract the first dkLen octets to
+ produce a derived key DK:
+
+ DK = T_1 || T_2 || ... || T_len<0..r-1> */
+ dk += (i < len) ? xor : xor.substr(0, r);
+
+ ++i;
+ outer();
+ }
+
+ outer();
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'pbkdf2';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './hmac', './md', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pem.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pem.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pem.js
new file mode 100644
index 0000000..e3085dc
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pem.js
@@ -0,0 +1,285 @@
+/**
+ * Javascript implementation of basic PEM (Privacy Enhanced Mail) algorithms.
+ *
+ * See: RFC 1421.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2013-2014 Digital Bazaar, Inc.
+ *
+ * A Forge PEM object has the following fields:
+ *
+ * type: identifies the type of message (eg: "RSA PRIVATE KEY").
+ *
+ * procType: identifies the type of processing performed on the message,
+ * it has two subfields: version and type, eg: 4,ENCRYPTED.
+ *
+ * contentDomain: identifies the type of content in the message, typically
+ * only uses the value: "RFC822".
+ *
+ * dekInfo: identifies the message encryption algorithm and mode and includes
+ * any parameters for the algorithm, it has two subfields: algorithm and
+ * parameters, eg: DES-CBC,F8143EDE5960C597.
+ *
+ * headers: contains all other PEM encapsulated headers -- where order is
+ * significant (for pairing data like recipient ID + key info).
+ *
+ * body: the binary-encoded body.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// shortcut for pem API
+var pem = forge.pem = forge.pem || {};
+
+/**
+ * Encodes (serializes) the given PEM object.
+ *
+ * @param msg the PEM message object to encode.
+ * @param options the options to use:
+ * maxline the maximum characters per line for the body, (default: 64).
+ *
+ * @return the PEM-formatted string.
+ */
+pem.encode = function(msg, options) {
+ options = options || {};
+ var rval = '-----BEGIN ' + msg.type + '-----\r\n';
+
+ // encode special headers
+ var header;
+ if(msg.procType) {
+ header = {
+ name: 'Proc-Type',
+ values: [String(msg.procType.version), msg.procType.type]
+ };
+ rval += foldHeader(header);
+ }
+ if(msg.contentDomain) {
+ header = {name: 'Content-Domain', values: [msg.contentDomain]};
+ rval += foldHeader(header);
+ }
+ if(msg.dekInfo) {
+ header = {name: 'DEK-Info', values: [msg.dekInfo.algorithm]};
+ if(msg.dekInfo.parameters) {
+ header.values.push(msg.dekInfo.parameters);
+ }
+ rval += foldHeader(header);
+ }
+
+ if(msg.headers) {
+ // encode all other headers
+ for(var i = 0; i < msg.headers.length; ++i) {
+ rval += foldHeader(msg.headers[i]);
+ }
+ }
+
+ // terminate header
+ if(msg.procType) {
+ rval += '\r\n';
+ }
+
+ // add body
+ rval += forge.util.encode64(msg.body, options.maxline || 64) + '\r\n';
+
+ rval += '-----END ' + msg.type + '-----\r\n';
+ return rval;
+};
+
+/**
+ * Decodes (deserializes) all PEM messages found in the given string.
+ *
+ * @param str the PEM-formatted string to decode.
+ *
+ * @return the PEM message objects in an array.
+ */
+pem.decode = function(str) {
+ var rval = [];
+
+ // split string into PEM messages (be lenient w/EOF on BEGIN line)
+ var rMessage = /\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g;
+ var rHeader = /([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/;
+ var rCRLF = /\r?\n/;
+ var match;
+ while(true) {
+ match = rMessage.exec(str);
+ if(!match) {
+ break;
+ }
+
+ var msg = {
+ type: match[1],
+ procType: null,
+ contentDomain: null,
+ dekInfo: null,
+ headers: [],
+ body: forge.util.decode64(match[3])
+ };
+ rval.push(msg);
+
+ // no headers
+ if(!match[2]) {
+ continue;
+ }
+
+ // parse headers
+ var lines = match[2].split(rCRLF);
+ var li = 0;
+ while(match && li < lines.length) {
+ // get line, trim any rhs whitespace
+ var line = lines[li].replace(/\s+$/, '');
+
+ // RFC2822 unfold any following folded lines
+ for(var nl = li + 1; nl < lines.length; ++nl) {
+ var next = lines[nl];
+ if(!/\s/.test(next[0])) {
+ break;
+ }
+ line += next;
+ li = nl;
+ }
+
+ // parse header
+ match = line.match(rHeader);
+ if(match) {
+ var header = {name: match[1], values: []};
+ var values = match[2].split(',');
+ for(var vi = 0; vi < values.length; ++vi) {
+ header.values.push(ltrim(values[vi]));
+ }
+
+ // Proc-Type must be the first header
+ if(!msg.procType) {
+ if(header.name !== 'Proc-Type') {
+ throw new Error('Invalid PEM formatted message. The first ' +
+ 'encapsulated header must be "Proc-Type".');
+ } else if(header.values.length !== 2) {
+ throw new Error('Invalid PEM formatted message. The "Proc-Type" ' +
+ 'header must have two subfields.');
+ }
+ msg.procType = {version: values[0], type: values[1]};
+ } else if(!msg.contentDomain && header.name === 'Content-Domain') {
+ // special-case Content-Domain
+ msg.contentDomain = values[0] || '';
+ } else if(!msg.dekInfo && header.name === 'DEK-Info') {
+ // special-case DEK-Info
+ if(header.values.length === 0) {
+ throw new Error('Invalid PEM formatted message. The "DEK-Info" ' +
+ 'header must have at least one subfield.');
+ }
+ msg.dekInfo = {algorithm: values[0], parameters: values[1] || null};
+ } else {
+ msg.headers.push(header);
+ }
+ }
+
+ ++li;
+ }
+
+ if(msg.procType === 'ENCRYPTED' && !msg.dekInfo) {
+ throw new Error('Invalid PEM formatted message. The "DEK-Info" ' +
+ 'header must be present if "Proc-Type" is "ENCRYPTED".');
+ }
+ }
+
+ if(rval.length === 0) {
+ throw new Error('Invalid PEM formatted message.');
+ }
+
+ return rval;
+};
+
+function foldHeader(header) {
+ var rval = header.name + ': ';
+
+ // ensure values with CRLF are folded
+ var values = [];
+ var insertSpace = function(match, $1) {
+ return ' ' + $1;
+ };
+ for(var i = 0; i < header.values.length; ++i) {
+ values.push(header.values[i].replace(/^(\S+\r\n)/, insertSpace));
+ }
+ rval += values.join(',') + '\r\n';
+
+ // do folding
+ var length = 0;
+ var candidate = -1;
+ for(var i = 0; i < rval.length; ++i, ++length) {
+ if(length > 65 && candidate !== -1) {
+ var insert = rval[candidate];
+ if(insert === ',') {
+ ++candidate;
+ rval = rval.substr(0, candidate) + '\r\n ' + rval.substr(candidate);
+ } else {
+ rval = rval.substr(0, candidate) +
+ '\r\n' + insert + rval.substr(candidate + 1);
+ }
+ length = (i - candidate - 1);
+ candidate = -1;
+ ++i;
+ } else if(rval[i] === ' ' || rval[i] === '\t' || rval[i] === ',') {
+ candidate = i;
+ }
+ }
+
+ return rval;
+}
+
+function ltrim(str) {
+ return str.replace(/^\s+/, '');
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'pem';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[23/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/async.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/async.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/async.js
new file mode 100644
index 0000000..6f32b10
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/async.js
@@ -0,0 +1,111 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var schedule = require("./schedule.js");
+var Queue = require("./queue.js");
+var errorObj = require("./util.js").errorObj;
+var tryCatch1 = require("./util.js").tryCatch1;
+var process = require("./global.js").process;
+
+function Async() {
+ this._isTickUsed = false;
+ this._length = 0;
+ this._lateBuffer = new Queue();
+ this._functionBuffer = new Queue(25000 * 3);
+ var self = this;
+ this.consumeFunctionBuffer = function Async$consumeFunctionBuffer() {
+ self._consumeFunctionBuffer();
+ };
+}
+
+Async.prototype.haveItemsQueued = function Async$haveItemsQueued() {
+ return this._length > 0;
+};
+
+Async.prototype.invokeLater = function Async$invokeLater(fn, receiver, arg) {
+ if (process !== void 0 &&
+ process.domain != null &&
+ !fn.domain) {
+ fn = process.domain.bind(fn);
+ }
+ this._lateBuffer.push(fn, receiver, arg);
+ this._queueTick();
+};
+
+Async.prototype.invoke = function Async$invoke(fn, receiver, arg) {
+ if (process !== void 0 &&
+ process.domain != null &&
+ !fn.domain) {
+ fn = process.domain.bind(fn);
+ }
+ var functionBuffer = this._functionBuffer;
+ functionBuffer.push(fn, receiver, arg);
+ this._length = functionBuffer.length();
+ this._queueTick();
+};
+
+Async.prototype._consumeFunctionBuffer =
+function Async$_consumeFunctionBuffer() {
+ var functionBuffer = this._functionBuffer;
+ while(functionBuffer.length() > 0) {
+ var fn = functionBuffer.shift();
+ var receiver = functionBuffer.shift();
+ var arg = functionBuffer.shift();
+ fn.call(receiver, arg);
+ }
+ this._reset();
+ this._consumeLateBuffer();
+};
+
+Async.prototype._consumeLateBuffer = function Async$_consumeLateBuffer() {
+ var buffer = this._lateBuffer;
+ while(buffer.length() > 0) {
+ var fn = buffer.shift();
+ var receiver = buffer.shift();
+ var arg = buffer.shift();
+ var res = tryCatch1(fn, receiver, arg);
+ if (res === errorObj) {
+ this._queueTick();
+ if (fn.domain != null) {
+ fn.domain.emit("error", res.e);
+ }
+ else {
+ throw res.e;
+ }
+ }
+ }
+};
+
+Async.prototype._queueTick = function Async$_queue() {
+ if (!this._isTickUsed) {
+ schedule(this.consumeFunctionBuffer);
+ this._isTickUsed = true;
+ }
+};
+
+Async.prototype._reset = function Async$_reset() {
+ this._isTickUsed = false;
+ this._length = 0;
+};
+
+module.exports = new Async();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/bluebird.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/bluebird.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/bluebird.js
new file mode 100644
index 0000000..6fd85f1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/bluebird.js
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var Promise = require("./promise.js")();
+module.exports = Promise;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/call_get.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/call_get.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/call_get.js
new file mode 100644
index 0000000..2a3c1f5
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/call_get.js
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+ Promise.prototype.call = function Promise$call(propertyName) {
+ var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
+
+ return this._then(function(obj) {
+ return obj[propertyName].apply(obj, args);
+ },
+ void 0,
+ void 0,
+ void 0,
+ void 0,
+ this.call
+ );
+ };
+
+ function Promise$getter(obj) {
+ var prop = typeof this === "string"
+ ? this
+ : ("" + this);
+ return obj[prop];
+ }
+ Promise.prototype.get = function Promise$get(propertyName) {
+ return this._then(
+ Promise$getter,
+ void 0,
+ void 0,
+ propertyName,
+ void 0,
+ this.get
+ );
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/cancel.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/cancel.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/cancel.js
new file mode 100644
index 0000000..542b488
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/cancel.js
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+ var errors = require("./errors.js");
+ var async = require("./async.js");
+ var CancellationError = errors.CancellationError;
+ var SYNC_TOKEN = {};
+
+ Promise.prototype._cancel = function Promise$_cancel() {
+ if (!this.isCancellable()) return this;
+ var parent;
+ if ((parent = this._cancellationParent) !== void 0) {
+ parent.cancel(SYNC_TOKEN);
+ return;
+ }
+ var err = new CancellationError();
+ this._attachExtraTrace(err);
+ this._rejectUnchecked(err);
+ };
+
+ Promise.prototype.cancel = function Promise$cancel(token) {
+ if (!this.isCancellable()) return this;
+ if (token === SYNC_TOKEN) {
+ this._cancel();
+ return this;
+ }
+ async.invokeLater(this._cancel, this, void 0);
+ return this;
+ };
+
+ Promise.prototype.cancellable = function Promise$cancellable() {
+ if (this._cancellable()) return this;
+ this._setCancellable();
+ this._cancellationParent = void 0;
+ return this;
+ };
+
+ Promise.prototype.uncancellable = function Promise$uncancellable() {
+ var ret = new Promise(INTERNAL);
+ ret._setTrace(this.uncancellable, this);
+ ret._follow(this);
+ ret._unsetCancellable();
+ if (this._isBound()) ret._setBoundTo(this._boundTo);
+ return ret;
+ };
+
+ Promise.prototype.fork =
+ function Promise$fork(didFulfill, didReject, didProgress) {
+ var ret = this._then(didFulfill, didReject, didProgress,
+ void 0, void 0, this.fork);
+
+ ret._setCancellable();
+ ret._cancellationParent = void 0;
+ return ret;
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/captured_trace.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/captured_trace.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/captured_trace.js
new file mode 100644
index 0000000..af34f11
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/captured_trace.js
@@ -0,0 +1,237 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function() {
+var inherits = require("./util.js").inherits;
+var defineProperty = require("./es5.js").defineProperty;
+
+var rignore = new RegExp(
+ "\\b(?:[\\w.]*Promise(?:Array|Spawn)?\\$_\\w+|" +
+ "tryCatch(?:1|2|Apply)|new \\w*PromiseArray|" +
+ "\\w*PromiseArray\\.\\w*PromiseArray|" +
+ "setTimeout|CatchFilter\\$_\\w+|makeNodePromisified|processImmediate|" +
+ "process._tickCallback|nextTick|Async\\$\\w+)\\b"
+);
+
+var rtraceline = null;
+var formatStack = null;
+var areNamesMangled = false;
+
+function formatNonError(obj) {
+ var str;
+ if (typeof obj === "function") {
+ str = "[function " +
+ (obj.name || "anonymous") +
+ "]";
+ }
+ else {
+ str = obj.toString();
+ var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
+ if (ruselessToString.test(str)) {
+ try {
+ var newStr = JSON.stringify(obj);
+ str = newStr;
+ }
+ catch(e) {
+
+ }
+ }
+ if (str.length === 0) {
+ str = "(empty array)";
+ }
+ }
+ return ("(<" + snip(str) + ">, no stack trace)");
+}
+
+function snip(str) {
+ var maxChars = 41;
+ if (str.length < maxChars) {
+ return str;
+ }
+ return str.substr(0, maxChars - 3) + "...";
+}
+
+function CapturedTrace(ignoreUntil, isTopLevel) {
+ if (!areNamesMangled) {
+ }
+ this.captureStackTrace(ignoreUntil, isTopLevel);
+
+}
+inherits(CapturedTrace, Error);
+
+CapturedTrace.prototype.captureStackTrace =
+function CapturedTrace$captureStackTrace(ignoreUntil, isTopLevel) {
+ captureStackTrace(this, ignoreUntil, isTopLevel);
+};
+
+CapturedTrace.possiblyUnhandledRejection =
+function CapturedTrace$PossiblyUnhandledRejection(reason) {
+ if (typeof console === "object") {
+ var message;
+ if (typeof reason === "object" || typeof reason === "function") {
+ var stack = reason.stack;
+ message = "Possibly unhandled " + formatStack(stack, reason);
+ }
+ else {
+ message = "Possibly unhandled " + String(reason);
+ }
+ if (typeof console.error === "function" ||
+ typeof console.error === "object") {
+ console.error(message);
+ }
+ else if (typeof console.log === "function" ||
+ typeof console.error === "object") {
+ console.log(message);
+ }
+ }
+};
+
+areNamesMangled = CapturedTrace.prototype.captureStackTrace.name !==
+ "CapturedTrace$captureStackTrace";
+
+CapturedTrace.combine = function CapturedTrace$Combine(current, prev) {
+ var curLast = current.length - 1;
+ for (var i = prev.length - 1; i >= 0; --i) {
+ var line = prev[i];
+ if (current[curLast] === line) {
+ current.pop();
+ curLast--;
+ }
+ else {
+ break;
+ }
+ }
+
+ current.push("From previous event:");
+ var lines = current.concat(prev);
+
+ var ret = [];
+
+
+ for (var i = 0, len = lines.length; i < len; ++i) {
+
+ if ((rignore.test(lines[i]) ||
+ (i > 0 && !rtraceline.test(lines[i])) &&
+ lines[i] !== "From previous event:")
+ ) {
+ continue;
+ }
+ ret.push(lines[i]);
+ }
+ return ret;
+};
+
+CapturedTrace.isSupported = function CapturedTrace$IsSupported() {
+ return typeof captureStackTrace === "function";
+};
+
+var captureStackTrace = (function stackDetection() {
+ if (typeof Error.stackTraceLimit === "number" &&
+ typeof Error.captureStackTrace === "function") {
+ rtraceline = /^\s*at\s*/;
+ formatStack = function(stack, error) {
+ if (typeof stack === "string") return stack;
+
+ if (error.name !== void 0 &&
+ error.message !== void 0) {
+ return error.name + ". " + error.message;
+ }
+ return formatNonError(error);
+
+
+ };
+ var captureStackTrace = Error.captureStackTrace;
+ return function CapturedTrace$_captureStackTrace(
+ receiver, ignoreUntil) {
+ captureStackTrace(receiver, ignoreUntil);
+ };
+ }
+ var err = new Error();
+
+ if (!areNamesMangled && typeof err.stack === "string" &&
+ typeof "".startsWith === "function" &&
+ (err.stack.startsWith("stackDetection@")) &&
+ stackDetection.name === "stackDetection") {
+
+ defineProperty(Error, "stackTraceLimit", {
+ writable: true,
+ enumerable: false,
+ configurable: false,
+ value: 25
+ });
+ rtraceline = /@/;
+ var rline = /[@\n]/;
+
+ formatStack = function(stack, error) {
+ if (typeof stack === "string") {
+ return (error.name + ". " + error.message + "\n" + stack);
+ }
+
+ if (error.name !== void 0 &&
+ error.message !== void 0) {
+ return error.name + ". " + error.message;
+ }
+ return formatNonError(error);
+ };
+
+ return function captureStackTrace(o, fn) {
+ var name = fn.name;
+ var stack = new Error().stack;
+ var split = stack.split(rline);
+ var i, len = split.length;
+ for (i = 0; i < len; i += 2) {
+ if (split[i] === name) {
+ break;
+ }
+ }
+ split = split.slice(i + 2);
+ len = split.length - 2;
+ var ret = "";
+ for (i = 0; i < len; i += 2) {
+ ret += split[i];
+ ret += "@";
+ ret += split[i + 1];
+ ret += "\n";
+ }
+ o.stack = ret;
+ };
+ }
+ else {
+ formatStack = function(stack, error) {
+ if (typeof stack === "string") return stack;
+
+ if ((typeof error === "object" ||
+ typeof error === "function") &&
+ error.name !== void 0 &&
+ error.message !== void 0) {
+ return error.name + ". " + error.message;
+ }
+ return formatNonError(error);
+ };
+
+ return null;
+ }
+})();
+
+return CapturedTrace;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/catch_filter.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/catch_filter.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/catch_filter.js
new file mode 100644
index 0000000..8b42af1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/catch_filter.js
@@ -0,0 +1,93 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(NEXT_FILTER) {
+var util = require("./util.js");
+var errors = require("./errors.js");
+var tryCatch1 = util.tryCatch1;
+var errorObj = util.errorObj;
+var keys = require("./es5.js").keys;
+
+function CatchFilter(instances, callback, promise) {
+ this._instances = instances;
+ this._callback = callback;
+ this._promise = promise;
+}
+
+function CatchFilter$_safePredicate(predicate, e) {
+ var safeObject = {};
+ var retfilter = tryCatch1(predicate, safeObject, e);
+
+ if (retfilter === errorObj) return retfilter;
+
+ var safeKeys = keys(safeObject);
+ if (safeKeys.length) {
+ errorObj.e = new TypeError(
+ "Catch filter must inherit from Error "
+ + "or be a simple predicate function");
+ return errorObj;
+ }
+ return retfilter;
+}
+
+CatchFilter.prototype.doFilter = function CatchFilter$_doFilter(e) {
+ var cb = this._callback;
+ var promise = this._promise;
+ var boundTo = promise._isBound() ? promise._boundTo : void 0;
+ for (var i = 0, len = this._instances.length; i < len; ++i) {
+ var item = this._instances[i];
+ var itemIsErrorType = item === Error ||
+ (item != null && item.prototype instanceof Error);
+
+ if (itemIsErrorType && e instanceof item) {
+ var ret = tryCatch1(cb, boundTo, e);
+ if (ret === errorObj) {
+ NEXT_FILTER.e = ret.e;
+ return NEXT_FILTER;
+ }
+ return ret;
+ } else if (typeof item === "function" && !itemIsErrorType) {
+ var shouldHandle = CatchFilter$_safePredicate(item, e);
+ if (shouldHandle === errorObj) {
+ var trace = errors.canAttach(errorObj.e)
+ ? errorObj.e
+ : new Error(errorObj.e + "");
+ this._promise._attachExtraTrace(trace);
+ e = errorObj.e;
+ break;
+ } else if (shouldHandle) {
+ var ret = tryCatch1(cb, boundTo, e);
+ if (ret === errorObj) {
+ NEXT_FILTER.e = ret.e;
+ return NEXT_FILTER;
+ }
+ return ret;
+ }
+ }
+ }
+ NEXT_FILTER.e = e;
+ return NEXT_FILTER;
+};
+
+return CatchFilter;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/direct_resolve.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/direct_resolve.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/direct_resolve.js
new file mode 100644
index 0000000..f4d5384
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/direct_resolve.js
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var util = require("./util.js");
+var isPrimitive = util.isPrimitive;
+var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;
+
+module.exports = function(Promise) {
+var returner = function Promise$_returner() {
+ return this;
+};
+var thrower = function Promise$_thrower() {
+ throw this;
+};
+
+var wrapper = function Promise$_wrapper(value, action) {
+ if (action === 1) {
+ return function Promise$_thrower() {
+ throw value;
+ };
+ }
+ else if (action === 2) {
+ return function Promise$_returner() {
+ return value;
+ };
+ }
+};
+
+
+Promise.prototype["return"] =
+Promise.prototype.thenReturn =
+function Promise$thenReturn(value) {
+ if (wrapsPrimitiveReceiver && isPrimitive(value)) {
+ return this._then(
+ wrapper(value, 2),
+ void 0,
+ void 0,
+ void 0,
+ void 0,
+ this.thenReturn
+ );
+ }
+ return this._then(returner, void 0, void 0,
+ value, void 0, this.thenReturn);
+};
+
+Promise.prototype["throw"] =
+Promise.prototype.thenThrow =
+function Promise$thenThrow(reason) {
+ if (wrapsPrimitiveReceiver && isPrimitive(reason)) {
+ return this._then(
+ wrapper(reason, 1),
+ void 0,
+ void 0,
+ void 0,
+ void 0,
+ this.thenThrow
+ );
+ }
+ return this._then(thrower, void 0, void 0,
+ reason, void 0, this.thenThrow);
+};
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/errors.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/errors.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/errors.js
new file mode 100644
index 0000000..35fb66e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/errors.js
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var global = require("./global.js");
+var Objectfreeze = require("./es5.js").freeze;
+var util = require("./util.js");
+var inherits = util.inherits;
+var notEnumerableProp = util.notEnumerableProp;
+var Error = global.Error;
+
+function markAsOriginatingFromRejection(e) {
+ try {
+ notEnumerableProp(e, "isAsync", true);
+ }
+ catch(ignore) {}
+}
+
+function originatesFromRejection(e) {
+ if (e == null) return false;
+ return ((e instanceof RejectionError) ||
+ e["isAsync"] === true);
+}
+
+function isError(obj) {
+ return obj instanceof Error;
+}
+
+function canAttach(obj) {
+ return isError(obj);
+}
+
+function subError(nameProperty, defaultMessage) {
+ function SubError(message) {
+ if (!(this instanceof SubError)) return new SubError(message);
+ this.message = typeof message === "string" ? message : defaultMessage;
+ this.name = nameProperty;
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+ }
+ inherits(SubError, Error);
+ return SubError;
+}
+
+var TypeError = global.TypeError;
+if (typeof TypeError !== "function") {
+ TypeError = subError("TypeError", "type error");
+}
+var RangeError = global.RangeError;
+if (typeof RangeError !== "function") {
+ RangeError = subError("RangeError", "range error");
+}
+var CancellationError = subError("CancellationError", "cancellation error");
+var TimeoutError = subError("TimeoutError", "timeout error");
+
+function RejectionError(message) {
+ this.name = "RejectionError";
+ this.message = message;
+ this.cause = message;
+ this.isAsync = true;
+
+ if (message instanceof Error) {
+ this.message = message.message;
+ this.stack = message.stack;
+ }
+ else if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
+}
+inherits(RejectionError, Error);
+
+var key = "__BluebirdErrorTypes__";
+var errorTypes = global[key];
+if (!errorTypes) {
+ errorTypes = Objectfreeze({
+ CancellationError: CancellationError,
+ TimeoutError: TimeoutError,
+ RejectionError: RejectionError
+ });
+ notEnumerableProp(global, key, errorTypes);
+}
+
+module.exports = {
+ Error: Error,
+ TypeError: TypeError,
+ RangeError: RangeError,
+ CancellationError: errorTypes.CancellationError,
+ RejectionError: errorTypes.RejectionError,
+ TimeoutError: errorTypes.TimeoutError,
+ originatesFromRejection: originatesFromRejection,
+ markAsOriginatingFromRejection: markAsOriginatingFromRejection,
+ canAttach: canAttach
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/errors_api_rejection.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/errors_api_rejection.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/errors_api_rejection.js
new file mode 100644
index 0000000..e953e3b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/errors_api_rejection.js
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+var TypeError = require('./errors.js').TypeError;
+
+function apiRejection(msg) {
+ var error = new TypeError(msg);
+ var ret = Promise.rejected(error);
+ var parent = ret._peekContext();
+ if (parent != null) {
+ parent._attachExtraTrace(error);
+ }
+ return ret;
+}
+
+return apiRejection;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/es5.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/es5.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/es5.js
new file mode 100644
index 0000000..e22a0a9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/es5.js
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+var isES5 = (function(){
+ "use strict";
+ return this === void 0;
+})();
+
+if (isES5) {
+ module.exports = {
+ freeze: Object.freeze,
+ defineProperty: Object.defineProperty,
+ keys: Object.keys,
+ getPrototypeOf: Object.getPrototypeOf,
+ isArray: Array.isArray,
+ isES5: isES5
+ };
+}
+
+else {
+ var has = {}.hasOwnProperty;
+ var str = {}.toString;
+ var proto = {}.constructor.prototype;
+
+ function ObjectKeys(o) {
+ var ret = [];
+ for (var key in o) {
+ if (has.call(o, key)) {
+ ret.push(key);
+ }
+ }
+ return ret;
+ }
+
+ function ObjectDefineProperty(o, key, desc) {
+ o[key] = desc.value;
+ return o;
+ }
+
+ function ObjectFreeze(obj) {
+ return obj;
+ }
+
+ function ObjectGetPrototypeOf(obj) {
+ try {
+ return Object(obj).constructor.prototype;
+ }
+ catch (e) {
+ return proto;
+ }
+ }
+
+ function ArrayIsArray(obj) {
+ try {
+ return str.call(obj) === "[object Array]";
+ }
+ catch(e) {
+ return false;
+ }
+ }
+
+ module.exports = {
+ isArray: ArrayIsArray,
+ keys: ObjectKeys,
+ defineProperty: ObjectDefineProperty,
+ freeze: ObjectFreeze,
+ getPrototypeOf: ObjectGetPrototypeOf,
+ isES5: isES5
+ };
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/filter.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/filter.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/filter.js
new file mode 100644
index 0000000..a4b8ae7
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/filter.js
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+ var isArray = require("./util.js").isArray;
+
+ function Promise$_filter(booleans) {
+ var values = this._settledValue;
+ var len = values.length;
+ var ret = new Array(len);
+ var j = 0;
+
+ for (var i = 0; i < len; ++i) {
+ if (booleans[i]) ret[j++] = values[i];
+
+ }
+ ret.length = j;
+ return ret;
+ }
+
+ var ref = {ref: null};
+ Promise.filter = function Promise$Filter(promises, fn) {
+ return Promise.map(promises, fn, ref)
+ ._then(Promise$_filter, void 0, void 0,
+ ref.ref, void 0, Promise.filter);
+ };
+
+ Promise.prototype.filter = function Promise$filter(fn) {
+ return this.map(fn, ref)
+ ._then(Promise$_filter, void 0, void 0,
+ ref.ref, void 0, this.filter);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/finally.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/finally.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/finally.js
new file mode 100644
index 0000000..ef1e0ef
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/finally.js
@@ -0,0 +1,132 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, NEXT_FILTER) {
+ var util = require("./util.js");
+ var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;
+ var isPrimitive = util.isPrimitive;
+ var thrower = util.thrower;
+
+
+ function returnThis() {
+ return this;
+ }
+ function throwThis() {
+ throw this;
+ }
+ function makeReturner(r) {
+ return function Promise$_returner() {
+ return r;
+ };
+ }
+ function makeThrower(r) {
+ return function Promise$_thrower() {
+ throw r;
+ };
+ }
+ function promisedFinally(ret, reasonOrValue, isFulfilled) {
+ var useConstantFunction =
+ wrapsPrimitiveReceiver && isPrimitive(reasonOrValue);
+
+ if (isFulfilled) {
+ return ret._then(
+ useConstantFunction
+ ? returnThis
+ : makeReturner(reasonOrValue),
+ thrower, void 0, reasonOrValue, void 0, promisedFinally);
+ }
+ else {
+ return ret._then(
+ useConstantFunction
+ ? throwThis
+ : makeThrower(reasonOrValue),
+ thrower, void 0, reasonOrValue, void 0, promisedFinally);
+ }
+ }
+
+ function finallyHandler(reasonOrValue) {
+ var promise = this.promise;
+ var handler = this.handler;
+
+ var ret = promise._isBound()
+ ? handler.call(promise._boundTo)
+ : handler();
+
+ if (ret !== void 0) {
+ var maybePromise = Promise._cast(ret, finallyHandler, void 0);
+ if (maybePromise instanceof Promise) {
+ return promisedFinally(maybePromise, reasonOrValue,
+ promise.isFulfilled());
+ }
+ }
+
+ if (promise.isRejected()) {
+ NEXT_FILTER.e = reasonOrValue;
+ return NEXT_FILTER;
+ }
+ else {
+ return reasonOrValue;
+ }
+ }
+
+ function tapHandler(value) {
+ var promise = this.promise;
+ var handler = this.handler;
+
+ var ret = promise._isBound()
+ ? handler.call(promise._boundTo, value)
+ : handler(value);
+
+ if (ret !== void 0) {
+ var maybePromise = Promise._cast(ret, tapHandler, void 0);
+ if (maybePromise instanceof Promise) {
+ return promisedFinally(maybePromise, value, true);
+ }
+ }
+ return value;
+ }
+
+ Promise.prototype._passThroughHandler =
+ function Promise$_passThroughHandler(handler, isFinally, caller) {
+ if (typeof handler !== "function") return this.then();
+
+ var promiseAndHandler = {
+ promise: this,
+ handler: handler
+ };
+
+ return this._then(
+ isFinally ? finallyHandler : tapHandler,
+ isFinally ? finallyHandler : void 0, void 0,
+ promiseAndHandler, void 0, caller);
+ };
+
+ Promise.prototype.lastly =
+ Promise.prototype["finally"] = function Promise$finally(handler) {
+ return this._passThroughHandler(handler, true, this.lastly);
+ };
+
+ Promise.prototype.tap = function Promise$tap(handler) {
+ return this._passThroughHandler(handler, false, this.tap);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/generators.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/generators.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/generators.js
new file mode 100644
index 0000000..9632ae7
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/generators.js
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, apiRejection, INTERNAL) {
+ var PromiseSpawn = require("./promise_spawn.js")(Promise, INTERNAL);
+ var errors = require("./errors.js");
+ var TypeError = errors.TypeError;
+ var deprecated = require("./util.js").deprecated;
+
+ Promise.coroutine = function Promise$Coroutine(generatorFunction) {
+ if (typeof generatorFunction !== "function") {
+ throw new TypeError("generatorFunction must be a function");
+ }
+ var PromiseSpawn$ = PromiseSpawn;
+ return function anonymous() {
+ var generator = generatorFunction.apply(this, arguments);
+ var spawn = new PromiseSpawn$(void 0, void 0, anonymous);
+ spawn._generator = generator;
+ spawn._next(void 0);
+ return spawn.promise();
+ };
+ };
+
+ Promise.coroutine.addYieldHandler = PromiseSpawn.addYieldHandler;
+
+ Promise.spawn = function Promise$Spawn(generatorFunction) {
+ deprecated("Promise.spawn is deprecated. Use Promise.coroutine instead.");
+ if (typeof generatorFunction !== "function") {
+ return apiRejection("generatorFunction must be a function");
+ }
+ var spawn = new PromiseSpawn(generatorFunction, this, Promise.spawn);
+ var ret = spawn.promise();
+ spawn._run(Promise.spawn);
+ return ret;
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/global.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/global.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/global.js
new file mode 100644
index 0000000..1ab1947
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/global.js
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = (function(){
+ if (typeof this !== "undefined") {
+ return this;
+ }
+ if (typeof process !== "undefined" &&
+ typeof global !== "undefined" &&
+ typeof process.execPath === "string") {
+ return global;
+ }
+ if (typeof window !== "undefined" &&
+ typeof document !== "undefined" &&
+ typeof navigator !== "undefined" && navigator !== null &&
+ typeof navigator.appName === "string") {
+ if(window.wrappedJSObject !== undefined){
+ return window.wrappedJSObject;
+ }
+ return window;
+ }
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/map.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/map.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/map.js
new file mode 100644
index 0000000..b2a36b0
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/map.js
@@ -0,0 +1,127 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(
+ Promise, Promise$_CreatePromiseArray, PromiseArray, apiRejection) {
+
+ function Promise$_mapper(values) {
+ var fn = this;
+ var receiver = void 0;
+
+ if (typeof fn !== "function") {
+ receiver = fn.receiver;
+ fn = fn.fn;
+ }
+ var shouldDefer = false;
+
+ var ret = new Array(values.length);
+
+ if (receiver === void 0) {
+ for (var i = 0, len = values.length; i < len; ++i) {
+ var value = fn(values[i], i, len);
+ if (!shouldDefer) {
+ var maybePromise = Promise._cast(value,
+ Promise$_mapper, void 0);
+ if (maybePromise instanceof Promise) {
+ if (maybePromise.isFulfilled()) {
+ ret[i] = maybePromise._settledValue;
+ continue;
+ }
+ else {
+ shouldDefer = true;
+ }
+ value = maybePromise;
+ }
+ }
+ ret[i] = value;
+ }
+ }
+ else {
+ for (var i = 0, len = values.length; i < len; ++i) {
+ var value = fn.call(receiver, values[i], i, len);
+ if (!shouldDefer) {
+ var maybePromise = Promise._cast(value,
+ Promise$_mapper, void 0);
+ if (maybePromise instanceof Promise) {
+ if (maybePromise.isFulfilled()) {
+ ret[i] = maybePromise._settledValue;
+ continue;
+ }
+ else {
+ shouldDefer = true;
+ }
+ value = maybePromise;
+ }
+ }
+ ret[i] = value;
+ }
+ }
+ return shouldDefer
+ ? Promise$_CreatePromiseArray(ret, PromiseArray,
+ Promise$_mapper, void 0).promise()
+ : ret;
+ }
+
+ function Promise$_Map(promises, fn, useBound, caller, ref) {
+ if (typeof fn !== "function") {
+ return apiRejection("fn must be a function");
+ }
+
+ if (useBound === true && promises._isBound()) {
+ fn = {
+ fn: fn,
+ receiver: promises._boundTo
+ };
+ }
+
+ var ret = Promise$_CreatePromiseArray(
+ promises,
+ PromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ ).promise();
+
+ if (ref !== void 0) {
+ ref.ref = ret;
+ }
+
+ return ret._then(
+ Promise$_mapper,
+ void 0,
+ void 0,
+ fn,
+ void 0,
+ caller
+ );
+ }
+
+ Promise.prototype.map = function Promise$map(fn, ref) {
+ return Promise$_Map(this, fn, true, this.map, ref);
+ };
+
+ Promise.map = function Promise$Map(promises, fn, ref) {
+ return Promise$_Map(promises, fn, false, Promise.map, ref);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/nodeify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/nodeify.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/nodeify.js
new file mode 100644
index 0000000..9fe25f9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/nodeify.js
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+ var util = require("./util.js");
+ var async = require("./async.js");
+ var tryCatch2 = util.tryCatch2;
+ var tryCatch1 = util.tryCatch1;
+ var errorObj = util.errorObj;
+
+ function thrower(r) {
+ throw r;
+ }
+
+ function Promise$_successAdapter(val, receiver) {
+ var nodeback = this;
+ var ret = tryCatch2(nodeback, receiver, null, val);
+ if (ret === errorObj) {
+ async.invokeLater(thrower, void 0, ret.e);
+ }
+ }
+ function Promise$_errorAdapter(reason, receiver) {
+ var nodeback = this;
+ var ret = tryCatch1(nodeback, receiver, reason);
+ if (ret === errorObj) {
+ async.invokeLater(thrower, void 0, ret.e);
+ }
+ }
+
+ Promise.prototype.nodeify = function Promise$nodeify(nodeback) {
+ if (typeof nodeback == "function") {
+ this._then(
+ Promise$_successAdapter,
+ Promise$_errorAdapter,
+ void 0,
+ nodeback,
+ this._isBound() ? this._boundTo : null,
+ this.nodeify
+ );
+ return;
+ }
+ return this;
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/progress.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/progress.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/progress.js
new file mode 100644
index 0000000..106bc58
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/main/progress.js
@@ -0,0 +1,113 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, isPromiseArrayProxy) {
+ var util = require("./util.js");
+ var async = require("./async.js");
+ var errors = require("./errors.js");
+ var tryCatch1 = util.tryCatch1;
+ var errorObj = util.errorObj;
+
+ Promise.prototype.progressed = function Promise$progressed(handler) {
+ return this._then(void 0, void 0, handler,
+ void 0, void 0, this.progressed);
+ };
+
+ Promise.prototype._progress = function Promise$_progress(progressValue) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._progressUnchecked(progressValue);
+
+ };
+
+ Promise.prototype._progressHandlerAt =
+ function Promise$_progressHandlerAt(index) {
+ if (index === 0) return this._progressHandler0;
+ return this[index + 2 - 5];
+ };
+
+ Promise.prototype._doProgressWith =
+ function Promise$_doProgressWith(progression) {
+ var progressValue = progression.value;
+ var handler = progression.handler;
+ var promise = progression.promise;
+ var receiver = progression.receiver;
+
+ this._pushContext();
+ var ret = tryCatch1(handler, receiver, progressValue);
+ this._popContext();
+
+ if (ret === errorObj) {
+ if (ret.e != null &&
+ ret.e.name !== "StopProgressPropagation") {
+ var trace = errors.canAttach(ret.e)
+ ? ret.e : new Error(ret.e + "");
+ promise._attachExtraTrace(trace);
+ promise._progress(ret.e);
+ }
+ }
+ else if (Promise.is(ret)) {
+ ret._then(promise._progress, null, null, promise, void 0,
+ this._progress);
+ }
+ else {
+ promise._progress(ret);
+ }
+ };
+
+
+ Promise.prototype._progressUnchecked =
+ function Promise$_progressUnchecked(progressValue) {
+ if (!this.isPending()) return;
+ var len = this._length();
+
+ for (var i = 0; i < len; i += 5) {
+ var handler = this._progressHandlerAt(i);
+ var promise = this._promiseAt(i);
+ if (!Promise.is(promise)) {
+ var receiver = this._receiverAt(i);
+ if (typeof handler === "function") {
+ handler.call(receiver, progressValue, promise);
+ }
+ else if (Promise.is(receiver) && receiver._isProxied()) {
+ receiver._progressUnchecked(progressValue);
+ }
+ else if (isPromiseArrayProxy(receiver, promise)) {
+ receiver._promiseProgressed(progressValue, promise);
+ }
+ continue;
+ }
+
+ if (typeof handler === "function") {
+ async.invoke(this._doProgressWith, this, {
+ handler: handler,
+ promise: promise,
+ receiver: this._receiverAt(i),
+ value: progressValue
+ });
+ }
+ else {
+ async.invoke(promise._progress, promise, progressValue);
+ }
+ }
+ };
+};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[49/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/README.md b/node_modules/node-firefox-connect/README.md
new file mode 100644
index 0000000..39d445d
--- /dev/null
+++ b/node_modules/node-firefox-connect/README.md
@@ -0,0 +1,62 @@
+# node-firefox-connect [](http://travis-ci.org/mozilla/node-firefox-connect)
+
+> Connects to a Firefox debuggable runtime.
+
+[](https://nodei.co/npm/node-firefox-connect/)
+
+This is part of the [node-firefox](https://github.com/mozilla/node-firefox) project.
+
+## Installation
+
+### From git
+
+```sh
+git clone https://github.com/mozilla/node-firefox-connect.git
+cd node-firefox-connect
+npm install
+```
+
+If you want to update later on:
+
+```sh
+cd node-firefox-connect
+git pull origin master
+npm install
+```
+
+### npm
+
+```bash
+npm install node-firefox-connect
+```
+
+## Usage
+
+Connects to a Firefox runtime, given a port number, and returns a [client](https://github.com/harthur/firefox-client) that can be used to interact with said client.
+
+```javascript
+// `connect` returns a Promise
+connect(portNumber).then(function(client) {
+
+});
+```
+
+## Example
+
+```javascript
+var connect = require('node-firefox-connect');
+
+connect(1234)
+ .then(function(client) {
+ // Let's show for example all the running apps
+ client.getWebapps(function(err, webapps) {
+ webapps.listRunningApps(function(err, apps) {
+ console.log("Running apps:", apps);
+ });
+ });
+ });
+```
+
+## History
+
+This is based on initial work on fxos-connect by Nicola Greco.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/examples/connect.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/examples/connect.js b/node_modules/node-firefox-connect/examples/connect.js
new file mode 100644
index 0000000..f6a3a12
--- /dev/null
+++ b/node_modules/node-firefox-connect/examples/connect.js
@@ -0,0 +1,15 @@
+'use strict';
+
+var connect = require('../');
+
+// Connect to a runtime listening to port 8000
+connect(8000).then(function(client) {
+
+ // Let's show for example all the running apps
+ client.getWebapps(function(err, webapps) {
+ webapps.listRunningApps(function(err, apps) {
+ console.log('Running apps:', apps);
+ });
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/examples/startAndConnect.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/examples/startAndConnect.js b/node_modules/node-firefox-connect/examples/startAndConnect.js
new file mode 100644
index 0000000..9ff5508
--- /dev/null
+++ b/node_modules/node-firefox-connect/examples/startAndConnect.js
@@ -0,0 +1,21 @@
+'use strict';
+
+var connect = require('../');
+var startSimulator = require('node-firefox-start-simulator');
+
+startSimulator({}).then(function(simulator) {
+
+ // Connect to the simulator we just launched
+ connect(simulator.port).then(function(client) {
+
+ // Let's show for example all the running apps
+ client.getWebapps(function(err, webapps) {
+ webapps.listRunningApps(function(err, apps) {
+ console.log('Running apps:', apps);
+ });
+ });
+
+ });
+
+});
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/gulpfile.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/gulpfile.js b/node_modules/node-firefox-connect/gulpfile.js
new file mode 100644
index 0000000..f5e5ab9
--- /dev/null
+++ b/node_modules/node-firefox-connect/gulpfile.js
@@ -0,0 +1,3 @@
+var gulp = require('gulp');
+
+require('node-firefox-build-tools').loadGulpTasks(gulp);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/index.js b/node_modules/node-firefox-connect/index.js
new file mode 100644
index 0000000..35c5dbd
--- /dev/null
+++ b/node_modules/node-firefox-connect/index.js
@@ -0,0 +1,23 @@
+'use strict';
+
+// See https://github.com/jshint/jshint/issues/1747 for context
+/* global -Promise */
+var Promise = require('es6-promise').Promise;
+var FirefoxClient = require('firefox-client');
+
+module.exports = connect;
+
+function connect(port) {
+ return new Promise(function(resolve, reject) {
+
+ var client = new FirefoxClient();
+ client.connect(port, function(err) {
+ if (err) {
+ reject(err);
+ }
+ resolve(client);
+ });
+
+ });
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/.release.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/.release.json b/node_modules/node-firefox-connect/node_modules/es6-promise/.release.json
new file mode 100644
index 0000000..dee8cbc
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/.release.json
@@ -0,0 +1,17 @@
+{
+ "non-interactive": true,
+ "dry-run": false,
+ "verbose": false,
+ "force": false,
+ "pkgFiles": ["package.json", "bower.json"],
+ "increment": "patch",
+ "commitMessage": "Release %s",
+ "tagName": "%s",
+ "tagAnnotation": "Release %s",
+ "buildCommand": "npm run-script build-all",
+ "distRepo": "git@github.com:components/rsvp.js.git",
+ "distStageDir": "tmp/stage",
+ "distBase": "dist",
+ "distFiles": ["**/*", "../package.json", "../bower.json"],
+ "publish": false
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/Brocfile.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/Brocfile.js b/node_modules/node-firefox-connect/node_modules/es6-promise/Brocfile.js
new file mode 100644
index 0000000..d34f458
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/Brocfile.js
@@ -0,0 +1,75 @@
+/* jshint node:true, undef:true, unused:true */
+var AMDFormatter = require('es6-module-transpiler-amd-formatter');
+var closureCompiler = require('broccoli-closure-compiler');
+var compileModules = require('broccoli-compile-modules');
+var mergeTrees = require('broccoli-merge-trees');
+var moveFile = require('broccoli-file-mover');
+var es3Recast = require('broccoli-es3-safe-recast');
+var concat = require('broccoli-concat');
+var replace = require('broccoli-string-replace');
+var calculateVersion = require('./lib/calculateVersion');
+var path = require('path');
+var trees = [];
+var env = process.env.EMBER_ENV || 'development';
+
+var bundle = compileModules('lib', {
+ inputFiles: ['es6-promise.umd.js'],
+ output: '/es6-promise.js',
+ formatter: 'bundle',
+});
+
+trees.push(bundle);
+trees.push(compileModules('lib', {
+ inputFiles: ['**/*.js'],
+ output: '/amd/',
+ formatter: new AMDFormatter()
+}));
+
+if (env === 'production') {
+ trees.push(closureCompiler(moveFile(bundle, {
+ srcFile: 'es6-promise.js',
+ destFile: 'es6-promise.min.js'
+ }), {
+ compilation_level: 'ADVANCED_OPTIMIZATIONS',
+ externs: ['node'],
+ }));
+}
+
+var distTree = mergeTrees(trees.concat('config'));
+var distTrees = [];
+
+distTrees.push(concat(distTree, {
+ inputFiles: [
+ 'versionTemplate.txt',
+ 'es6-promise.js'
+ ],
+ outputFile: '/es6-promise.js'
+}));
+
+if (env === 'production') {
+ distTrees.push(concat(distTree, {
+ inputFiles: [
+ 'versionTemplate.txt',
+ 'es6-promise.min.js'
+ ],
+ outputFile: '/es6-promise.min.js'
+ }));
+}
+
+if (env !== 'development') {
+ distTrees = distTrees.map(es3Recast);
+}
+
+distTree = mergeTrees(distTrees);
+var distTree = replace(distTree, {
+ files: [
+ 'es6-promise.js',
+ 'es6-promise.min.js'
+ ],
+ pattern: {
+ match: /VERSION_PLACEHOLDER_STRING/g,
+ replacement: calculateVersion()
+ }
+});
+
+module.exports = distTree;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/CHANGELOG.md b/node_modules/node-firefox-connect/node_modules/es6-promise/CHANGELOG.md
new file mode 100644
index 0000000..e06b496
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/CHANGELOG.md
@@ -0,0 +1,9 @@
+# Master
+
+# 2.0.0
+
+* re-sync with RSVP. Many large performance improvements and bugfixes.
+
+# 1.0.0
+
+* first subset of RSVP
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/LICENSE b/node_modules/node-firefox-connect/node_modules/es6-promise/LICENSE
new file mode 100644
index 0000000..954ec59
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/README.md b/node_modules/node-firefox-connect/node_modules/es6-promise/README.md
new file mode 100644
index 0000000..b974ce4
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/README.md
@@ -0,0 +1,58 @@
+# ES6-Promise (subset of [rsvp.js](https://github.com/tildeio/rsvp.js))
+
+This is a polyfill of the [ES6 Promise](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-constructor). The implementation is a subset of [rsvp.js](https://github.com/tildeio/rsvp.js), if you're wanting extra features and more debugging options, check out the [full library](https://github.com/tildeio/rsvp.js).
+
+For API details and how to use promises, see the <a href="http://www.html5rocks.com/en/tutorials/es6/promises/">JavaScript Promises HTML5Rocks article</a>.
+
+## Downloads
+
+* [es6-promise](https://es6-promises.s3.amazonaws.com/es6-promise-2.0.1.js)
+* [es6-promise-min](https://es6-promises.s3.amazonaws.com/es6-promise-2.0.1.min.js) (~2.2k gzipped)
+
+## Node.js
+
+To install:
+
+```sh
+npm install es6-promise
+```
+
+To use:
+
+```js
+var Promise = require('es6-promise').Promise;
+```
+
+## Usage in IE<9
+
+`catch` is a reserved word in IE<9, meaning `promise.catch(func)` throws a syntax error. To work around this, you can use a string to access the property as shown in the following example.
+
+However, please remember that such technique is already provided by most common minifiers, making the resulting code safe for old browsers and production:
+
+```js
+promise['catch'](function(err) {
+ // ...
+});
+```
+
+Or use `.then` instead:
+
+```js
+promise.then(undefined, function(err) {
+ // ...
+});
+```
+
+## Auto-polyfill
+
+To polyfill the global environment (either in Node or in the browser via CommonJS) use the following code snippet:
+
+```js
+require('es6-promise').polyfill();
+```
+
+Notice that we don't assign the result of `polyfill()` to any variable. The `polyfill()` method will patch the global environment (in this case to the `Promise` name) when called.
+
+## Building & Testing
+
+* `npm run build-all && npm test` - Run Mocha tests through Node and PhantomJS.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/bin/publish_to_s3.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/bin/publish_to_s3.js b/node_modules/node-firefox-connect/node_modules/es6-promise/bin/publish_to_s3.js
new file mode 100755
index 0000000..7daf49a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/bin/publish_to_s3.js
@@ -0,0 +1,28 @@
+#!/usr/bin/env node
+
+// To invoke this from the commandline you need the following to env vars to exist:
+//
+// S3_BUCKET_NAME
+// TRAVIS_BRANCH
+// TRAVIS_TAG
+// TRAVIS_COMMIT
+// S3_SECRET_ACCESS_KEY
+// S3_ACCESS_KEY_ID
+//
+// Once you have those you execute with the following:
+//
+// ```sh
+// ./bin/publish_to_s3.js
+// ```
+var S3Publisher = require('ember-publisher');
+var configPath = require('path').join(__dirname, '../config/s3ProjectConfig.js');
+publisher = new S3Publisher({ projectConfigPath: configPath });
+
+// Always use wildcard section of project config.
+// This is useful when the including library does not
+// require channels (like in ember.js / ember-data).
+publisher.currentBranch = function() {
+ return (process.env.TRAVIS_BRANCH === 'master') ? 'wildcard' : 'no-op';
+};
+publisher.publish();
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/bower.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/bower.json b/node_modules/node-firefox-connect/node_modules/es6-promise/bower.json
new file mode 100644
index 0000000..84ec5ad
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/bower.json
@@ -0,0 +1,29 @@
+{
+ "name": "es6-promise",
+ "namespace": "Promise",
+ "version": "2.0.1",
+ "description": "A polyfill for ES6-style Promises, tracking rsvp",
+ "authors": [
+ "Stefan Penner <st...@gmail.com>"
+ ],
+ "main": "dist/es6-promise.js",
+ "keywords": [
+ "promise"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jakearchibald/ES6-Promises.git"
+ },
+ "bugs": {
+ "url": "https://github.com/jakearchibald/ES6-Promises/issues"
+ },
+ "license": "MIT",
+ "ignore": [
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests",
+ "vendor",
+ "tasks"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/config/s3ProjectConfig.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/config/s3ProjectConfig.js b/node_modules/node-firefox-connect/node_modules/es6-promise/config/s3ProjectConfig.js
new file mode 100644
index 0000000..5f3349a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/config/s3ProjectConfig.js
@@ -0,0 +1,26 @@
+/*
+ * Using wildcard because es6-promise does not currently have a
+ * channel system in place.
+ */
+module.exports = function(revision,tag,date){
+ return {
+ 'es6-promise.js':
+ { contentType: 'text/javascript',
+ destinations: {
+ wildcard: [
+ 'es6-promise-latest.js',
+ 'es6-promise-' + revision + '.js'
+ ]
+ }
+ },
+ 'es6-promise.min.js':
+ { contentType: 'text/javascript',
+ destinations: {
+ wildcard: [
+ 'es6-promise-latest.min.js',
+ 'es6-promise-' + revision + '.min.js'
+ ]
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/config/versionTemplate.txt
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/config/versionTemplate.txt b/node_modules/node-firefox-connect/node_modules/es6-promise/config/versionTemplate.txt
new file mode 100644
index 0000000..999a5fc
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/config/versionTemplate.txt
@@ -0,0 +1,7 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version VERSION_PLACEHOLDER_STRING
+ */
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/dist/es6-promise.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/dist/es6-promise.js b/node_modules/node-firefox-connect/node_modules/es6-promise/dist/es6-promise.js
new file mode 100644
index 0000000..30a6d81
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/dist/es6-promise.js
@@ -0,0 +1,960 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version 2.0.1
+ */
+
+(function() {
+ "use strict";
+
+ function $$utils$$objectOrFunction(x) {
+ return typeof x === 'function' || (typeof x === 'object' && x !== null);
+ }
+
+ function $$utils$$isFunction(x) {
+ return typeof x === 'function';
+ }
+
+ function $$utils$$isMaybeThenable(x) {
+ return typeof x === 'object' && x !== null;
+ }
+
+ var $$utils$$_isArray;
+
+ if (!Array.isArray) {
+ $$utils$$_isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+ } else {
+ $$utils$$_isArray = Array.isArray;
+ }
+
+ var $$utils$$isArray = $$utils$$_isArray;
+ var $$utils$$now = Date.now || function() { return new Date().getTime(); };
+ function $$utils$$F() { }
+
+ var $$utils$$o_create = (Object.create || function (o) {
+ if (arguments.length > 1) {
+ throw new Error('Second argument not supported');
+ }
+ if (typeof o !== 'object') {
+ throw new TypeError('Argument must be an object');
+ }
+ $$utils$$F.prototype = o;
+ return new $$utils$$F();
+ });
+
+ var $$asap$$len = 0;
+
+ var $$asap$$default = function asap(callback, arg) {
+ $$asap$$queue[$$asap$$len] = callback;
+ $$asap$$queue[$$asap$$len + 1] = arg;
+ $$asap$$len += 2;
+ if ($$asap$$len === 2) {
+ // If len is 1, that means that we need to schedule an async flush.
+ // If additional callbacks are queued before the queue is flushed, they
+ // will be processed by this flush that we are scheduling.
+ $$asap$$scheduleFlush();
+ }
+ };
+
+ var $$asap$$browserGlobal = (typeof window !== 'undefined') ? window : {};
+ var $$asap$$BrowserMutationObserver = $$asap$$browserGlobal.MutationObserver || $$asap$$browserGlobal.WebKitMutationObserver;
+
+ // test for web worker but not in IE10
+ var $$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
+ typeof importScripts !== 'undefined' &&
+ typeof MessageChannel !== 'undefined';
+
+ // node
+ function $$asap$$useNextTick() {
+ return function() {
+ process.nextTick($$asap$$flush);
+ };
+ }
+
+ function $$asap$$useMutationObserver() {
+ var iterations = 0;
+ var observer = new $$asap$$BrowserMutationObserver($$asap$$flush);
+ var node = document.createTextNode('');
+ observer.observe(node, { characterData: true });
+
+ return function() {
+ node.data = (iterations = ++iterations % 2);
+ };
+ }
+
+ // web worker
+ function $$asap$$useMessageChannel() {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = $$asap$$flush;
+ return function () {
+ channel.port2.postMessage(0);
+ };
+ }
+
+ function $$asap$$useSetTimeout() {
+ return function() {
+ setTimeout($$asap$$flush, 1);
+ };
+ }
+
+ var $$asap$$queue = new Array(1000);
+
+ function $$asap$$flush() {
+ for (var i = 0; i < $$asap$$len; i+=2) {
+ var callback = $$asap$$queue[i];
+ var arg = $$asap$$queue[i+1];
+
+ callback(arg);
+
+ $$asap$$queue[i] = undefined;
+ $$asap$$queue[i+1] = undefined;
+ }
+
+ $$asap$$len = 0;
+ }
+
+ var $$asap$$scheduleFlush;
+
+ // Decide what async method to use to triggering processing of queued callbacks:
+ if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
+ $$asap$$scheduleFlush = $$asap$$useNextTick();
+ } else if ($$asap$$BrowserMutationObserver) {
+ $$asap$$scheduleFlush = $$asap$$useMutationObserver();
+ } else if ($$asap$$isWorker) {
+ $$asap$$scheduleFlush = $$asap$$useMessageChannel();
+ } else {
+ $$asap$$scheduleFlush = $$asap$$useSetTimeout();
+ }
+
+ function $$$internal$$noop() {}
+ var $$$internal$$PENDING = void 0;
+ var $$$internal$$FULFILLED = 1;
+ var $$$internal$$REJECTED = 2;
+ var $$$internal$$GET_THEN_ERROR = new $$$internal$$ErrorObject();
+
+ function $$$internal$$selfFullfillment() {
+ return new TypeError("You cannot resolve a promise with itself");
+ }
+
+ function $$$internal$$cannotReturnOwn() {
+ return new TypeError('A promises callback cannot return that same promise.')
+ }
+
+ function $$$internal$$getThen(promise) {
+ try {
+ return promise.then;
+ } catch(error) {
+ $$$internal$$GET_THEN_ERROR.error = error;
+ return $$$internal$$GET_THEN_ERROR;
+ }
+ }
+
+ function $$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
+ try {
+ then.call(value, fulfillmentHandler, rejectionHandler);
+ } catch(e) {
+ return e;
+ }
+ }
+
+ function $$$internal$$handleForeignThenable(promise, thenable, then) {
+ $$asap$$default(function(promise) {
+ var sealed = false;
+ var error = $$$internal$$tryThen(then, thenable, function(value) {
+ if (sealed) { return; }
+ sealed = true;
+ if (thenable !== value) {
+ $$$internal$$resolve(promise, value);
+ } else {
+ $$$internal$$fulfill(promise, value);
+ }
+ }, function(reason) {
+ if (sealed) { return; }
+ sealed = true;
+
+ $$$internal$$reject(promise, reason);
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
+
+ if (!sealed && error) {
+ sealed = true;
+ $$$internal$$reject(promise, error);
+ }
+ }, promise);
+ }
+
+ function $$$internal$$handleOwnThenable(promise, thenable) {
+ if (thenable._state === $$$internal$$FULFILLED) {
+ $$$internal$$fulfill(promise, thenable._result);
+ } else if (promise._state === $$$internal$$REJECTED) {
+ $$$internal$$reject(promise, thenable._result);
+ } else {
+ $$$internal$$subscribe(thenable, undefined, function(value) {
+ $$$internal$$resolve(promise, value);
+ }, function(reason) {
+ $$$internal$$reject(promise, reason);
+ });
+ }
+ }
+
+ function $$$internal$$handleMaybeThenable(promise, maybeThenable) {
+ if (maybeThenable.constructor === promise.constructor) {
+ $$$internal$$handleOwnThenable(promise, maybeThenable);
+ } else {
+ var then = $$$internal$$getThen(maybeThenable);
+
+ if (then === $$$internal$$GET_THEN_ERROR) {
+ $$$internal$$reject(promise, $$$internal$$GET_THEN_ERROR.error);
+ } else if (then === undefined) {
+ $$$internal$$fulfill(promise, maybeThenable);
+ } else if ($$utils$$isFunction(then)) {
+ $$$internal$$handleForeignThenable(promise, maybeThenable, then);
+ } else {
+ $$$internal$$fulfill(promise, maybeThenable);
+ }
+ }
+ }
+
+ function $$$internal$$resolve(promise, value) {
+ if (promise === value) {
+ $$$internal$$reject(promise, $$$internal$$selfFullfillment());
+ } else if ($$utils$$objectOrFunction(value)) {
+ $$$internal$$handleMaybeThenable(promise, value);
+ } else {
+ $$$internal$$fulfill(promise, value);
+ }
+ }
+
+ function $$$internal$$publishRejection(promise) {
+ if (promise._onerror) {
+ promise._onerror(promise._result);
+ }
+
+ $$$internal$$publish(promise);
+ }
+
+ function $$$internal$$fulfill(promise, value) {
+ if (promise._state !== $$$internal$$PENDING) { return; }
+
+ promise._result = value;
+ promise._state = $$$internal$$FULFILLED;
+
+ if (promise._subscribers.length === 0) {
+ } else {
+ $$asap$$default($$$internal$$publish, promise);
+ }
+ }
+
+ function $$$internal$$reject(promise, reason) {
+ if (promise._state !== $$$internal$$PENDING) { return; }
+ promise._state = $$$internal$$REJECTED;
+ promise._result = reason;
+
+ $$asap$$default($$$internal$$publishRejection, promise);
+ }
+
+ function $$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
+
+ parent._onerror = null;
+
+ subscribers[length] = child;
+ subscribers[length + $$$internal$$FULFILLED] = onFulfillment;
+ subscribers[length + $$$internal$$REJECTED] = onRejection;
+
+ if (length === 0 && parent._state) {
+ $$asap$$default($$$internal$$publish, parent);
+ }
+ }
+
+ function $$$internal$$publish(promise) {
+ var subscribers = promise._subscribers;
+ var settled = promise._state;
+
+ if (subscribers.length === 0) { return; }
+
+ var child, callback, detail = promise._result;
+
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
+
+ if (child) {
+ $$$internal$$invokeCallback(settled, child, callback, detail);
+ } else {
+ callback(detail);
+ }
+ }
+
+ promise._subscribers.length = 0;
+ }
+
+ function $$$internal$$ErrorObject() {
+ this.error = null;
+ }
+
+ var $$$internal$$TRY_CATCH_ERROR = new $$$internal$$ErrorObject();
+
+ function $$$internal$$tryCatch(callback, detail) {
+ try {
+ return callback(detail);
+ } catch(e) {
+ $$$internal$$TRY_CATCH_ERROR.error = e;
+ return $$$internal$$TRY_CATCH_ERROR;
+ }
+ }
+
+ function $$$internal$$invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = $$utils$$isFunction(callback),
+ value, error, succeeded, failed;
+
+ if (hasCallback) {
+ value = $$$internal$$tryCatch(callback, detail);
+
+ if (value === $$$internal$$TRY_CATCH_ERROR) {
+ failed = true;
+ error = value.error;
+ value = null;
+ } else {
+ succeeded = true;
+ }
+
+ if (promise === value) {
+ $$$internal$$reject(promise, $$$internal$$cannotReturnOwn());
+ return;
+ }
+
+ } else {
+ value = detail;
+ succeeded = true;
+ }
+
+ if (promise._state !== $$$internal$$PENDING) {
+ // noop
+ } else if (hasCallback && succeeded) {
+ $$$internal$$resolve(promise, value);
+ } else if (failed) {
+ $$$internal$$reject(promise, error);
+ } else if (settled === $$$internal$$FULFILLED) {
+ $$$internal$$fulfill(promise, value);
+ } else if (settled === $$$internal$$REJECTED) {
+ $$$internal$$reject(promise, value);
+ }
+ }
+
+ function $$$internal$$initializePromise(promise, resolver) {
+ try {
+ resolver(function resolvePromise(value){
+ $$$internal$$resolve(promise, value);
+ }, function rejectPromise(reason) {
+ $$$internal$$reject(promise, reason);
+ });
+ } catch(e) {
+ $$$internal$$reject(promise, e);
+ }
+ }
+
+ function $$$enumerator$$makeSettledResult(state, position, value) {
+ if (state === $$$internal$$FULFILLED) {
+ return {
+ state: 'fulfilled',
+ value: value
+ };
+ } else {
+ return {
+ state: 'rejected',
+ reason: value
+ };
+ }
+ }
+
+ function $$$enumerator$$Enumerator(Constructor, input, abortOnReject, label) {
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor($$$internal$$noop, label);
+ this._abortOnReject = abortOnReject;
+
+ if (this._validateInput(input)) {
+ this._input = input;
+ this.length = input.length;
+ this._remaining = input.length;
+
+ this._init();
+
+ if (this.length === 0) {
+ $$$internal$$fulfill(this.promise, this._result);
+ } else {
+ this.length = this.length || 0;
+ this._enumerate();
+ if (this._remaining === 0) {
+ $$$internal$$fulfill(this.promise, this._result);
+ }
+ }
+ } else {
+ $$$internal$$reject(this.promise, this._validationError());
+ }
+ }
+
+ $$$enumerator$$Enumerator.prototype._validateInput = function(input) {
+ return $$utils$$isArray(input);
+ };
+
+ $$$enumerator$$Enumerator.prototype._validationError = function() {
+ return new Error('Array Methods must be provided an Array');
+ };
+
+ $$$enumerator$$Enumerator.prototype._init = function() {
+ this._result = new Array(this.length);
+ };
+
+ var $$$enumerator$$default = $$$enumerator$$Enumerator;
+
+ $$$enumerator$$Enumerator.prototype._enumerate = function() {
+ var length = this.length;
+ var promise = this.promise;
+ var input = this._input;
+
+ for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) {
+ this._eachEntry(input[i], i);
+ }
+ };
+
+ $$$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
+ var c = this._instanceConstructor;
+ if ($$utils$$isMaybeThenable(entry)) {
+ if (entry.constructor === c && entry._state !== $$$internal$$PENDING) {
+ entry._onerror = null;
+ this._settledAt(entry._state, i, entry._result);
+ } else {
+ this._willSettleAt(c.resolve(entry), i);
+ }
+ } else {
+ this._remaining--;
+ this._result[i] = this._makeResult($$$internal$$FULFILLED, i, entry);
+ }
+ };
+
+ $$$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
+ var promise = this.promise;
+
+ if (promise._state === $$$internal$$PENDING) {
+ this._remaining--;
+
+ if (this._abortOnReject && state === $$$internal$$REJECTED) {
+ $$$internal$$reject(promise, value);
+ } else {
+ this._result[i] = this._makeResult(state, i, value);
+ }
+ }
+
+ if (this._remaining === 0) {
+ $$$internal$$fulfill(promise, this._result);
+ }
+ };
+
+ $$$enumerator$$Enumerator.prototype._makeResult = function(state, i, value) {
+ return value;
+ };
+
+ $$$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
+ var enumerator = this;
+
+ $$$internal$$subscribe(promise, undefined, function(value) {
+ enumerator._settledAt($$$internal$$FULFILLED, i, value);
+ }, function(reason) {
+ enumerator._settledAt($$$internal$$REJECTED, i, reason);
+ });
+ };
+
+ var $$promise$all$$default = function all(entries, label) {
+ return new $$$enumerator$$default(this, entries, true /* abort on reject */, label).promise;
+ };
+
+ var $$promise$race$$default = function race(entries, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ var promise = new Constructor($$$internal$$noop, label);
+
+ if (!$$utils$$isArray(entries)) {
+ $$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
+ return promise;
+ }
+
+ var length = entries.length;
+
+ function onFulfillment(value) {
+ $$$internal$$resolve(promise, value);
+ }
+
+ function onRejection(reason) {
+ $$$internal$$reject(promise, reason);
+ }
+
+ for (var i = 0; promise._state === $$$internal$$PENDING && i < length; i++) {
+ $$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
+ }
+
+ return promise;
+ };
+
+ var $$promise$resolve$$default = function resolve(object, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
+
+ var promise = new Constructor($$$internal$$noop, label);
+ $$$internal$$resolve(promise, object);
+ return promise;
+ };
+
+ var $$promise$reject$$default = function reject(reason, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor($$$internal$$noop, label);
+ $$$internal$$reject(promise, reason);
+ return promise;
+ };
+
+ var $$es6$promise$promise$$counter = 0;
+
+ function $$es6$promise$promise$$needsResolver() {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+ }
+
+ function $$es6$promise$promise$$needsNew() {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
+ }
+
+ var $$es6$promise$promise$$default = $$es6$promise$promise$$Promise;
+
+ /**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise’s eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable.
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ }
+ }
+ };
+ });
+ }
+
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class Promise
+ @param {function} resolver
+ Useful for tooling.
+ @constructor
+ */
+ function $$es6$promise$promise$$Promise(resolver) {
+ this._id = $$es6$promise$promise$$counter++;
+ this._state = undefined;
+ this._result = undefined;
+ this._subscribers = [];
+
+ if ($$$internal$$noop !== resolver) {
+ if (!$$utils$$isFunction(resolver)) {
+ $$es6$promise$promise$$needsResolver();
+ }
+
+ if (!(this instanceof $$es6$promise$promise$$Promise)) {
+ $$es6$promise$promise$$needsNew();
+ }
+
+ $$$internal$$initializePromise(this, resolver);
+ }
+ }
+
+ $$es6$promise$promise$$Promise.all = $$promise$all$$default;
+ $$es6$promise$promise$$Promise.race = $$promise$race$$default;
+ $$es6$promise$promise$$Promise.resolve = $$promise$resolve$$default;
+ $$es6$promise$promise$$Promise.reject = $$promise$reject$$default;
+
+ $$es6$promise$promise$$Promise.prototype = {
+ constructor: $$es6$promise$promise$$Promise,
+
+ /**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, 'downstream'
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return 'default name';
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `'default name'`
+ });
+
+ findUser().then(function (user) {
+ throw new Error('Found user, but still unhappy');
+ }, function (reason) {
+ throw new Error('`findUser` rejected and we're unhappy');
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException('Upstream error');
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var result;
+
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+ }
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfilled
+ @param {Function} onRejected
+ Useful for tooling.
+ @return {Promise}
+ */
+ then: function(onFulfillment, onRejection) {
+ var parent = this;
+ var state = parent._state;
+
+ if (state === $$$internal$$FULFILLED && !onFulfillment || state === $$$internal$$REJECTED && !onRejection) {
+ return this;
+ }
+
+ var child = new this.constructor($$$internal$$noop);
+ var result = parent._result;
+
+ if (state) {
+ var callback = arguments[state - 1];
+ $$asap$$default(function(){
+ $$$internal$$invokeCallback(state, child, callback, result);
+ });
+ } else {
+ $$$internal$$subscribe(parent, child, onFulfillment, onRejection);
+ }
+
+ return child;
+ },
+
+ /**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error('couldn't find that author');
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ Useful for tooling.
+ @return {Promise}
+ */
+ 'catch': function(onRejection) {
+ return this.then(null, onRejection);
+ }
+ };
+
+ var $$es6$promise$polyfill$$default = function polyfill() {
+ var local;
+
+ if (typeof global !== 'undefined') {
+ local = global;
+ } else if (typeof window !== 'undefined' && window.document) {
+ local = window;
+ } else {
+ local = self;
+ }
+
+ var es6PromiseSupport =
+ "Promise" in local &&
+ // Some of these methods are missing from
+ // Firefox/Chrome experimental implementations
+ "resolve" in local.Promise &&
+ "reject" in local.Promise &&
+ "all" in local.Promise &&
+ "race" in local.Promise &&
+ // Older version of the spec had a resolver object
+ // as the arg rather than a function
+ (function() {
+ var resolve;
+ new local.Promise(function(r) { resolve = r; });
+ return $$utils$$isFunction(resolve);
+ }());
+
+ if (!es6PromiseSupport) {
+ local.Promise = $$es6$promise$promise$$default;
+ }
+ };
+
+ var es6$promise$umd$$ES6Promise = {
+ 'Promise': $$es6$promise$promise$$default,
+ 'polyfill': $$es6$promise$polyfill$$default
+ };
+
+ /* global define:true module:true window: true */
+ if (typeof define === 'function' && define['amd']) {
+ define(function() { return es6$promise$umd$$ES6Promise; });
+ } else if (typeof module !== 'undefined' && module['exports']) {
+ module['exports'] = es6$promise$umd$$ES6Promise;
+ } else if (typeof this !== 'undefined') {
+ this['ES6Promise'] = es6$promise$umd$$ES6Promise;
+ }
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/dist/es6-promise.min.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/dist/es6-promise.min.js b/node_modules/node-firefox-connect/node_modules/es6-promise/dist/es6-promise.min.js
new file mode 100644
index 0000000..6e0c99f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/dist/es6-promise.min.js
@@ -0,0 +1,18 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version 2.0.1
+ */
+
+(function(){function r(a,b){n[l]=a;n[l+1]=b;l+=2;2===l&&A()}function s(a){return"function"===typeof a}function F(){return function(){process.nextTick(t)}}function G(){var a=0,b=new B(t),c=document.createTextNode("");b.observe(c,{characterData:!0});return function(){c.data=a=++a%2}}function H(){var a=new MessageChannel;a.port1.onmessage=t;return function(){a.port2.postMessage(0)}}function I(){return function(){setTimeout(t,1)}}function t(){for(var a=0;a<l;a+=2)(0,n[a])(n[a+1]),n[a]=void 0,n[a+1]=void 0;
+l=0}function p(){}function J(a,b,c,d){try{a.call(b,c,d)}catch(e){return e}}function K(a,b,c){r(function(a){var e=!1,f=J(c,b,function(c){e||(e=!0,b!==c?q(a,c):m(a,c))},function(b){e||(e=!0,g(a,b))});!e&&f&&(e=!0,g(a,f))},a)}function L(a,b){1===b.a?m(a,b.b):2===a.a?g(a,b.b):u(b,void 0,function(b){q(a,b)},function(b){g(a,b)})}function q(a,b){if(a===b)g(a,new TypeError("You cannot resolve a promise with itself"));else if("function"===typeof b||"object"===typeof b&&null!==b)if(b.constructor===a.constructor)L(a,
+b);else{var c;try{c=b.then}catch(d){v.error=d,c=v}c===v?g(a,v.error):void 0===c?m(a,b):s(c)?K(a,b,c):m(a,b)}else m(a,b)}function M(a){a.f&&a.f(a.b);x(a)}function m(a,b){void 0===a.a&&(a.b=b,a.a=1,0!==a.e.length&&r(x,a))}function g(a,b){void 0===a.a&&(a.a=2,a.b=b,r(M,a))}function u(a,b,c,d){var e=a.e,f=e.length;a.f=null;e[f]=b;e[f+1]=c;e[f+2]=d;0===f&&a.a&&r(x,a)}function x(a){var b=a.e,c=a.a;if(0!==b.length){for(var d,e,f=a.b,g=0;g<b.length;g+=3)d=b[g],e=b[g+c],d?C(c,d,e,f):e(f);a.e.length=0}}function D(){this.error=
+null}function C(a,b,c,d){var e=s(c),f,k,h,l;if(e){try{f=c(d)}catch(n){y.error=n,f=y}f===y?(l=!0,k=f.error,f=null):h=!0;if(b===f){g(b,new TypeError("A promises callback cannot return that same promise."));return}}else f=d,h=!0;void 0===b.a&&(e&&h?q(b,f):l?g(b,k):1===a?m(b,f):2===a&&g(b,f))}function N(a,b){try{b(function(b){q(a,b)},function(b){g(a,b)})}catch(c){g(a,c)}}function k(a,b,c,d){this.n=a;this.c=new a(p,d);this.i=c;this.o(b)?(this.m=b,this.d=this.length=b.length,this.l(),0===this.length?m(this.c,
+this.b):(this.length=this.length||0,this.k(),0===this.d&&m(this.c,this.b))):g(this.c,this.p())}function h(a){O++;this.b=this.a=void 0;this.e=[];if(p!==a){if(!s(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof h))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");N(this,a)}}var E=Array.isArray?Array.isArray:function(a){return"[object Array]"===
+Object.prototype.toString.call(a)},l=0,w="undefined"!==typeof window?window:{},B=w.MutationObserver||w.WebKitMutationObserver,w="undefined"!==typeof Uint8ClampedArray&&"undefined"!==typeof importScripts&&"undefined"!==typeof MessageChannel,n=Array(1E3),A;A="undefined"!==typeof process&&"[object process]"==={}.toString.call(process)?F():B?G():w?H():I();var v=new D,y=new D;k.prototype.o=function(a){return E(a)};k.prototype.p=function(){return Error("Array Methods must be provided an Array")};k.prototype.l=
+function(){this.b=Array(this.length)};k.prototype.k=function(){for(var a=this.length,b=this.c,c=this.m,d=0;void 0===b.a&&d<a;d++)this.j(c[d],d)};k.prototype.j=function(a,b){var c=this.n;"object"===typeof a&&null!==a?a.constructor===c&&void 0!==a.a?(a.f=null,this.g(a.a,b,a.b)):this.q(c.resolve(a),b):(this.d--,this.b[b]=this.h(a))};k.prototype.g=function(a,b,c){var d=this.c;void 0===d.a&&(this.d--,this.i&&2===a?g(d,c):this.b[b]=this.h(c));0===this.d&&m(d,this.b)};k.prototype.h=function(a){return a};
+k.prototype.q=function(a,b){var c=this;u(a,void 0,function(a){c.g(1,b,a)},function(a){c.g(2,b,a)})};var O=0;h.all=function(a,b){return(new k(this,a,!0,b)).c};h.race=function(a,b){function c(a){q(e,a)}function d(a){g(e,a)}var e=new this(p,b);if(!E(a))return (g(e,new TypeError("You must pass an array to race.")), e);for(var f=a.length,h=0;void 0===e.a&&h<f;h++)u(this.resolve(a[h]),void 0,c,d);return e};h.resolve=function(a,b){if(a&&"object"===typeof a&&a.constructor===this)return a;var c=new this(p,b);
+q(c,a);return c};h.reject=function(a,b){var c=new this(p,b);g(c,a);return c};h.prototype={constructor:h,then:function(a,b){var c=this.a;if(1===c&&!a||2===c&&!b)return this;var d=new this.constructor(p),e=this.b;if(c){var f=arguments[c-1];r(function(){C(c,d,f,e)})}else u(this,d,a,b);return d},"catch":function(a){return this.then(null,a)}};var z={Promise:h,polyfill:function(){var a;a="undefined"!==typeof global?global:"undefined"!==typeof window&&window.document?window:self;"Promise"in a&&"resolve"in
+a.Promise&&"reject"in a.Promise&&"all"in a.Promise&&"race"in a.Promise&&function(){var b;new a.Promise(function(a){b=a});return s(b)}()||(a.Promise=h)}};"function"===typeof define&&define.amd?define(function(){return z}):"undefined"!==typeof module&&module.exports?module.exports=z:"undefined"!==typeof this&&(this.ES6Promise=z)}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/calculateVersion.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/calculateVersion.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/calculateVersion.js
new file mode 100644
index 0000000..018e364
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/calculateVersion.js
@@ -0,0 +1,36 @@
+'use strict';
+
+var fs = require('fs');
+var path = require('path');
+
+module.exports = function () {
+ var packageVersion = require('../package.json').version;
+ var output = [packageVersion];
+ var gitPath = path.join(__dirname,'..','.git');
+ var headFilePath = path.join(gitPath, 'HEAD');
+
+ if (packageVersion.indexOf('+') > -1) {
+ try {
+ if (fs.existsSync(headFilePath)) {
+ var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'});
+ var branchName = headFile.split('/').slice(-1)[0].trim();
+ var refPath = headFile.split(' ')[1];
+ var branchSHA;
+
+ if (refPath) {
+ var branchPath = path.join(gitPath, refPath.trim());
+ branchSHA = fs.readFileSync(branchPath);
+ } else {
+ branchSHA = branchName;
+ }
+
+ output.push(branchSHA.slice(0,10));
+ }
+ } catch (err) {
+ console.error(err.stack);
+ }
+ return output.join('.');
+ } else {
+ return packageVersion;
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise.umd.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise.umd.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise.umd.js
new file mode 100644
index 0000000..cd01553
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise.umd.js
@@ -0,0 +1,16 @@
+import Promise from './es6-promise/promise';
+import polyfill from './es6-promise/polyfill';
+
+var ES6Promise = {
+ 'Promise': Promise,
+ 'polyfill': polyfill
+};
+
+/* global define:true module:true window: true */
+if (typeof define === 'function' && define['amd']) {
+ define(function() { return ES6Promise; });
+} else if (typeof module !== 'undefined' && module['exports']) {
+ module['exports'] = ES6Promise;
+} else if (typeof this !== 'undefined') {
+ this['ES6Promise'] = ES6Promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/-internal.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/-internal.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/-internal.js
new file mode 100644
index 0000000..afef22e
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/-internal.js
@@ -0,0 +1,251 @@
+import {
+ objectOrFunction,
+ isFunction
+} from './utils';
+
+import asap from './asap';
+
+function noop() {}
+
+var PENDING = void 0;
+var FULFILLED = 1;
+var REJECTED = 2;
+
+var GET_THEN_ERROR = new ErrorObject();
+
+function selfFullfillment() {
+ return new TypeError("You cannot resolve a promise with itself");
+}
+
+function cannotReturnOwn() {
+ return new TypeError('A promises callback cannot return that same promise.')
+}
+
+function getThen(promise) {
+ try {
+ return promise.then;
+ } catch(error) {
+ GET_THEN_ERROR.error = error;
+ return GET_THEN_ERROR;
+ }
+}
+
+function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
+ try {
+ then.call(value, fulfillmentHandler, rejectionHandler);
+ } catch(e) {
+ return e;
+ }
+}
+
+function handleForeignThenable(promise, thenable, then) {
+ asap(function(promise) {
+ var sealed = false;
+ var error = tryThen(then, thenable, function(value) {
+ if (sealed) { return; }
+ sealed = true;
+ if (thenable !== value) {
+ resolve(promise, value);
+ } else {
+ fulfill(promise, value);
+ }
+ }, function(reason) {
+ if (sealed) { return; }
+ sealed = true;
+
+ reject(promise, reason);
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
+
+ if (!sealed && error) {
+ sealed = true;
+ reject(promise, error);
+ }
+ }, promise);
+}
+
+function handleOwnThenable(promise, thenable) {
+ if (thenable._state === FULFILLED) {
+ fulfill(promise, thenable._result);
+ } else if (promise._state === REJECTED) {
+ reject(promise, thenable._result);
+ } else {
+ subscribe(thenable, undefined, function(value) {
+ resolve(promise, value);
+ }, function(reason) {
+ reject(promise, reason);
+ });
+ }
+}
+
+function handleMaybeThenable(promise, maybeThenable) {
+ if (maybeThenable.constructor === promise.constructor) {
+ handleOwnThenable(promise, maybeThenable);
+ } else {
+ var then = getThen(maybeThenable);
+
+ if (then === GET_THEN_ERROR) {
+ reject(promise, GET_THEN_ERROR.error);
+ } else if (then === undefined) {
+ fulfill(promise, maybeThenable);
+ } else if (isFunction(then)) {
+ handleForeignThenable(promise, maybeThenable, then);
+ } else {
+ fulfill(promise, maybeThenable);
+ }
+ }
+}
+
+function resolve(promise, value) {
+ if (promise === value) {
+ reject(promise, selfFullfillment());
+ } else if (objectOrFunction(value)) {
+ handleMaybeThenable(promise, value);
+ } else {
+ fulfill(promise, value);
+ }
+}
+
+function publishRejection(promise) {
+ if (promise._onerror) {
+ promise._onerror(promise._result);
+ }
+
+ publish(promise);
+}
+
+function fulfill(promise, value) {
+ if (promise._state !== PENDING) { return; }
+
+ promise._result = value;
+ promise._state = FULFILLED;
+
+ if (promise._subscribers.length === 0) {
+ } else {
+ asap(publish, promise);
+ }
+}
+
+function reject(promise, reason) {
+ if (promise._state !== PENDING) { return; }
+ promise._state = REJECTED;
+ promise._result = reason;
+
+ asap(publishRejection, promise);
+}
+
+function subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
+
+ parent._onerror = null;
+
+ subscribers[length] = child;
+ subscribers[length + FULFILLED] = onFulfillment;
+ subscribers[length + REJECTED] = onRejection;
+
+ if (length === 0 && parent._state) {
+ asap(publish, parent);
+ }
+}
+
+function publish(promise) {
+ var subscribers = promise._subscribers;
+ var settled = promise._state;
+
+ if (subscribers.length === 0) { return; }
+
+ var child, callback, detail = promise._result;
+
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
+
+ if (child) {
+ invokeCallback(settled, child, callback, detail);
+ } else {
+ callback(detail);
+ }
+ }
+
+ promise._subscribers.length = 0;
+}
+
+function ErrorObject() {
+ this.error = null;
+}
+
+var TRY_CATCH_ERROR = new ErrorObject();
+
+function tryCatch(callback, detail) {
+ try {
+ return callback(detail);
+ } catch(e) {
+ TRY_CATCH_ERROR.error = e;
+ return TRY_CATCH_ERROR;
+ }
+}
+
+function invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = isFunction(callback),
+ value, error, succeeded, failed;
+
+ if (hasCallback) {
+ value = tryCatch(callback, detail);
+
+ if (value === TRY_CATCH_ERROR) {
+ failed = true;
+ error = value.error;
+ value = null;
+ } else {
+ succeeded = true;
+ }
+
+ if (promise === value) {
+ reject(promise, cannotReturnOwn());
+ return;
+ }
+
+ } else {
+ value = detail;
+ succeeded = true;
+ }
+
+ if (promise._state !== PENDING) {
+ // noop
+ } else if (hasCallback && succeeded) {
+ resolve(promise, value);
+ } else if (failed) {
+ reject(promise, error);
+ } else if (settled === FULFILLED) {
+ fulfill(promise, value);
+ } else if (settled === REJECTED) {
+ reject(promise, value);
+ }
+}
+
+function initializePromise(promise, resolver) {
+ try {
+ resolver(function resolvePromise(value){
+ resolve(promise, value);
+ }, function rejectPromise(reason) {
+ reject(promise, reason);
+ });
+ } catch(e) {
+ reject(promise, e);
+ }
+}
+
+export {
+ noop,
+ resolve,
+ reject,
+ fulfill,
+ subscribe,
+ publish,
+ publishRejection,
+ initializePromise,
+ invokeCallback,
+ FULFILLED,
+ REJECTED,
+ PENDING
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/asap.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/asap.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/asap.js
new file mode 100644
index 0000000..4872589
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/asap.js
@@ -0,0 +1,82 @@
+var len = 0;
+
+export default function asap(callback, arg) {
+ queue[len] = callback;
+ queue[len + 1] = arg;
+ len += 2;
+ if (len === 2) {
+ // If len is 1, that means that we need to schedule an async flush.
+ // If additional callbacks are queued before the queue is flushed, they
+ // will be processed by this flush that we are scheduling.
+ scheduleFlush();
+ }
+}
+
+var browserGlobal = (typeof window !== 'undefined') ? window : {};
+var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
+
+// test for web worker but not in IE10
+var isWorker = typeof Uint8ClampedArray !== 'undefined' &&
+ typeof importScripts !== 'undefined' &&
+ typeof MessageChannel !== 'undefined';
+
+// node
+function useNextTick() {
+ return function() {
+ process.nextTick(flush);
+ };
+}
+
+function useMutationObserver() {
+ var iterations = 0;
+ var observer = new BrowserMutationObserver(flush);
+ var node = document.createTextNode('');
+ observer.observe(node, { characterData: true });
+
+ return function() {
+ node.data = (iterations = ++iterations % 2);
+ };
+}
+
+// web worker
+function useMessageChannel() {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = flush;
+ return function () {
+ channel.port2.postMessage(0);
+ };
+}
+
+function useSetTimeout() {
+ return function() {
+ setTimeout(flush, 1);
+ };
+}
+
+var queue = new Array(1000);
+function flush() {
+ for (var i = 0; i < len; i+=2) {
+ var callback = queue[i];
+ var arg = queue[i+1];
+
+ callback(arg);
+
+ queue[i] = undefined;
+ queue[i+1] = undefined;
+ }
+
+ len = 0;
+}
+
+var scheduleFlush;
+
+// Decide what async method to use to triggering processing of queued callbacks:
+if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
+ scheduleFlush = useNextTick();
+} else if (BrowserMutationObserver) {
+ scheduleFlush = useMutationObserver();
+} else if (isWorker) {
+ scheduleFlush = useMessageChannel();
+} else {
+ scheduleFlush = useSetTimeout();
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/enumerator.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/enumerator.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/enumerator.js
new file mode 100644
index 0000000..7d3f803
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/enumerator.js
@@ -0,0 +1,125 @@
+import {
+ isArray,
+ isMaybeThenable
+} from './utils';
+
+import {
+ noop,
+ reject,
+ fulfill,
+ subscribe,
+ FULFILLED,
+ REJECTED,
+ PENDING
+} from './-internal';
+
+export function makeSettledResult(state, position, value) {
+ if (state === FULFILLED) {
+ return {
+ state: 'fulfilled',
+ value: value
+ };
+ } else {
+ return {
+ state: 'rejected',
+ reason: value
+ };
+ }
+}
+
+function Enumerator(Constructor, input, abortOnReject, label) {
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor(noop, label);
+ this._abortOnReject = abortOnReject;
+
+ if (this._validateInput(input)) {
+ this._input = input;
+ this.length = input.length;
+ this._remaining = input.length;
+
+ this._init();
+
+ if (this.length === 0) {
+ fulfill(this.promise, this._result);
+ } else {
+ this.length = this.length || 0;
+ this._enumerate();
+ if (this._remaining === 0) {
+ fulfill(this.promise, this._result);
+ }
+ }
+ } else {
+ reject(this.promise, this._validationError());
+ }
+}
+
+Enumerator.prototype._validateInput = function(input) {
+ return isArray(input);
+};
+
+Enumerator.prototype._validationError = function() {
+ return new Error('Array Methods must be provided an Array');
+};
+
+Enumerator.prototype._init = function() {
+ this._result = new Array(this.length);
+};
+
+export default Enumerator;
+
+Enumerator.prototype._enumerate = function() {
+ var length = this.length;
+ var promise = this.promise;
+ var input = this._input;
+
+ for (var i = 0; promise._state === PENDING && i < length; i++) {
+ this._eachEntry(input[i], i);
+ }
+};
+
+Enumerator.prototype._eachEntry = function(entry, i) {
+ var c = this._instanceConstructor;
+ if (isMaybeThenable(entry)) {
+ if (entry.constructor === c && entry._state !== PENDING) {
+ entry._onerror = null;
+ this._settledAt(entry._state, i, entry._result);
+ } else {
+ this._willSettleAt(c.resolve(entry), i);
+ }
+ } else {
+ this._remaining--;
+ this._result[i] = this._makeResult(FULFILLED, i, entry);
+ }
+};
+
+Enumerator.prototype._settledAt = function(state, i, value) {
+ var promise = this.promise;
+
+ if (promise._state === PENDING) {
+ this._remaining--;
+
+ if (this._abortOnReject && state === REJECTED) {
+ reject(promise, value);
+ } else {
+ this._result[i] = this._makeResult(state, i, value);
+ }
+ }
+
+ if (this._remaining === 0) {
+ fulfill(promise, this._result);
+ }
+};
+
+Enumerator.prototype._makeResult = function(state, i, value) {
+ return value;
+};
+
+Enumerator.prototype._willSettleAt = function(promise, i) {
+ var enumerator = this;
+
+ subscribe(promise, undefined, function(value) {
+ enumerator._settledAt(FULFILLED, i, value);
+ }, function(reason) {
+ enumerator._settledAt(REJECTED, i, reason);
+ });
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/polyfill.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/polyfill.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/polyfill.js
new file mode 100644
index 0000000..e5b0165
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/polyfill.js
@@ -0,0 +1,35 @@
+/*global self*/
+import { default as RSVPPromise } from "./promise";
+import { isFunction } from "./utils";
+
+export default function polyfill() {
+ var local;
+
+ if (typeof global !== 'undefined') {
+ local = global;
+ } else if (typeof window !== 'undefined' && window.document) {
+ local = window;
+ } else {
+ local = self;
+ }
+
+ var es6PromiseSupport =
+ "Promise" in local &&
+ // Some of these methods are missing from
+ // Firefox/Chrome experimental implementations
+ "resolve" in local.Promise &&
+ "reject" in local.Promise &&
+ "all" in local.Promise &&
+ "race" in local.Promise &&
+ // Older version of the spec had a resolver object
+ // as the arg rather than a function
+ (function() {
+ var resolve;
+ new local.Promise(function(r) { resolve = r; });
+ return isFunction(resolve);
+ }());
+
+ if (!es6PromiseSupport) {
+ local.Promise = RSVPPromise;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise.js
new file mode 100644
index 0000000..5e865a7
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise.js
@@ -0,0 +1,409 @@
+import {
+ isFunction,
+ now
+} from './utils';
+
+import {
+ noop,
+ subscribe,
+ initializePromise,
+ invokeCallback,
+ FULFILLED,
+ REJECTED
+} from './-internal';
+
+import asap from './asap';
+
+import all from './promise/all';
+import race from './promise/race';
+import Resolve from './promise/resolve';
+import Reject from './promise/reject';
+
+var counter = 0;
+
+function needsResolver() {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+}
+
+function needsNew() {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
+}
+
+export default Promise;
+/**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise’s eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable.
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ }
+ }
+ };
+ });
+ }
+
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class Promise
+ @param {function} resolver
+ Useful for tooling.
+ @constructor
+*/
+function Promise(resolver) {
+ this._id = counter++;
+ this._state = undefined;
+ this._result = undefined;
+ this._subscribers = [];
+
+ if (noop !== resolver) {
+ if (!isFunction(resolver)) {
+ needsResolver();
+ }
+
+ if (!(this instanceof Promise)) {
+ needsNew();
+ }
+
+ initializePromise(this, resolver);
+ }
+}
+
+Promise.all = all;
+Promise.race = race;
+Promise.resolve = Resolve;
+Promise.reject = Reject;
+
+Promise.prototype = {
+ constructor: Promise,
+
+/**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, 'downstream'
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return 'default name';
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `'default name'`
+ });
+
+ findUser().then(function (user) {
+ throw new Error('Found user, but still unhappy');
+ }, function (reason) {
+ throw new Error('`findUser` rejected and we're unhappy');
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException('Upstream error');
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var result;
+
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+ }
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfilled
+ @param {Function} onRejected
+ Useful for tooling.
+ @return {Promise}
+*/
+ then: function(onFulfillment, onRejection) {
+ var parent = this;
+ var state = parent._state;
+
+ if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) {
+ return this;
+ }
+
+ var child = new this.constructor(noop);
+ var result = parent._result;
+
+ if (state) {
+ var callback = arguments[state - 1];
+ asap(function(){
+ invokeCallback(state, child, callback, result);
+ });
+ } else {
+ subscribe(parent, child, onFulfillment, onRejection);
+ }
+
+ return child;
+ },
+
+/**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error('couldn't find that author');
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ Useful for tooling.
+ @return {Promise}
+*/
+ 'catch': function(onRejection) {
+ return this.then(null, onRejection);
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/all.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/all.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/all.js
new file mode 100644
index 0000000..8db7e71
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/all.js
@@ -0,0 +1,52 @@
+import Enumerator from '../enumerator';
+
+/**
+ `Promise.all` accepts an array of promises, and returns a new promise which
+ is fulfilled with an array of fulfillment values for the passed promises, or
+ rejected with the reason of the first passed promise to be rejected. It casts all
+ elements of the passed iterable to promises as it runs this algorithm.
+
+ Example:
+
+ ```javascript
+ var promise1 = resolve(1);
+ var promise2 = resolve(2);
+ var promise3 = resolve(3);
+ var promises = [ promise1, promise2, promise3 ];
+
+ Promise.all(promises).then(function(array){
+ // The array here would be [ 1, 2, 3 ];
+ });
+ ```
+
+ If any of the `promises` given to `all` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promises's
+ rejection handler. For example:
+
+ Example:
+
+ ```javascript
+ var promise1 = resolve(1);
+ var promise2 = reject(new Error("2"));
+ var promise3 = reject(new Error("3"));
+ var promises = [ promise1, promise2, promise3 ];
+
+ Promise.all(promises).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(error) {
+ // error.message === "2"
+ });
+ ```
+
+ @method all
+ @static
+ @param {Array} entries array of promises
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled when all `promises` have been
+ fulfilled, or rejected if any of them become rejected.
+ @static
+*/
+export default function all(entries, label) {
+ return new Enumerator(this, entries, true /* abort on reject */, label).promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/race.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/race.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/race.js
new file mode 100644
index 0000000..7daa28a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/race.js
@@ -0,0 +1,105 @@
+import {
+ isArray
+} from "../utils";
+
+import {
+ noop,
+ resolve,
+ reject,
+ subscribe,
+ PENDING
+} from '../-internal';
+
+/**
+ `Promise.race` returns a new promise which is settled in the same way as the
+ first passed promise to settle.
+
+ Example:
+
+ ```javascript
+ var promise1 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 2');
+ }, 100);
+ });
+
+ Promise.race([promise1, promise2]).then(function(result){
+ // result === 'promise 2' because it was resolved before promise1
+ // was resolved.
+ });
+ ```
+
+ `Promise.race` is deterministic in that only the state of the first
+ settled promise matters. For example, even if other promises given to the
+ `promises` array argument are resolved, but the first settled promise has
+ become rejected before the other promises became fulfilled, the returned
+ promise will become rejected:
+
+ ```javascript
+ var promise1 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ reject(new Error('promise 2'));
+ }, 100);
+ });
+
+ Promise.race([promise1, promise2]).then(function(result){
+ // Code here never runs
+ }, function(reason){
+ // reason.message === 'promise 2' because promise 2 became rejected before
+ // promise 1 became fulfilled
+ });
+ ```
+
+ An example real-world use case is implementing timeouts:
+
+ ```javascript
+ Promise.race([ajax('foo.json'), timeout(5000)])
+ ```
+
+ @method race
+ @static
+ @param {Array} promises array of promises to observe
+ @param {String} label optional string for describing the promise returned.
+ Useful for tooling.
+ @return {Promise} a promise which settles in the same way as the first passed
+ promise to settle.
+*/
+export default function race(entries, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ var promise = new Constructor(noop, label);
+
+ if (!isArray(entries)) {
+ reject(promise, new TypeError('You must pass an array to race.'));
+ return promise;
+ }
+
+ var length = entries.length;
+
+ function onFulfillment(value) {
+ resolve(promise, value);
+ }
+
+ function onRejection(reason) {
+ reject(promise, reason);
+ }
+
+ for (var i = 0; promise._state === PENDING && i < length; i++) {
+ subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
+ }
+
+ return promise;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/reject.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/reject.js b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/reject.js
new file mode 100644
index 0000000..518eff7
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/es6-promise/lib/es6-promise/promise/reject.js
@@ -0,0 +1,47 @@
+import {
+ noop,
+ reject as _reject
+} from '../-internal';
+
+/**
+ `Promise.reject` returns a promise rejected with the passed `reason`.
+ It is shorthand for the following:
+
+ ```javascript
+ var promise = new Promise(function(resolve, reject){
+ reject(new Error('WHOOPS'));
+ });
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = Promise.reject(new Error('WHOOPS'));
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ @method reject
+ @static
+ @param {Any} reason value that the returned promise will be rejected with.
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise rejected with the given `reason`.
+*/
+export default function reject(reason, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor(noop, label);
+ _reject(promise, reason);
+ return promise;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[12/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs1.js
new file mode 100644
index 0000000..7bf734c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs1.js
@@ -0,0 +1,329 @@
+/**
+ * Partial implementation of PKCS#1 v2.2: RSA-OEAP
+ *
+ * Modified but based on the following MIT and BSD licensed code:
+ *
+ * https://github.com/kjur/jsjws/blob/master/rsa.js:
+ *
+ * The 'jsjws'(JSON Web Signature JavaScript Library) License
+ *
+ * Copyright (c) 2012 Kenji Urushima
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * http://webrsa.cvs.sourceforge.net/viewvc/webrsa/Client/RSAES-OAEP.js?content-type=text%2Fplain:
+ *
+ * RSAES-OAEP.js
+ * $Id: RSAES-OAEP.js,v 1.1.1.1 2003/03/19 15:37:20 ellispritchard Exp $
+ * JavaScript Implementation of PKCS #1 v2.1 RSA CRYPTOGRAPHY STANDARD (RSA Laboratories, June 14, 2002)
+ * Copyright (C) Ellis Pritchard, Guardian Unlimited 2003.
+ * Contact: ellis@nukinetics.com
+ * Distributed under the BSD License.
+ *
+ * Official documentation: http://www.rsa.com/rsalabs/node.asp?id=2125
+ *
+ * @author Evan Jones (http://evanjones.ca/)
+ * @author Dave Longley
+ *
+ * Copyright (c) 2013-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// shortcut for PKCS#1 API
+var pkcs1 = forge.pkcs1 = forge.pkcs1 || {};
+
+/**
+ * Encode the given RSAES-OAEP message (M) using key, with optional label (L)
+ * and seed.
+ *
+ * This method does not perform RSA encryption, it only encodes the message
+ * using RSAES-OAEP.
+ *
+ * @param key the RSA key to use.
+ * @param message the message to encode.
+ * @param options the options to use:
+ * label an optional label to use.
+ * seed the seed to use.
+ * md the message digest object to use, undefined for SHA-1.
+ * mgf1 optional mgf1 parameters:
+ * md the message digest object to use for MGF1.
+ *
+ * @return the encoded message bytes.
+ */
+pkcs1.encode_rsa_oaep = function(key, message, options) {
+ // parse arguments
+ var label;
+ var seed;
+ var md;
+ var mgf1Md;
+ // legacy args (label, seed, md)
+ if(typeof options === 'string') {
+ label = options;
+ seed = arguments[3] || undefined;
+ md = arguments[4] || undefined;
+ } else if(options) {
+ label = options.label || undefined;
+ seed = options.seed || undefined;
+ md = options.md || undefined;
+ if(options.mgf1 && options.mgf1.md) {
+ mgf1Md = options.mgf1.md;
+ }
+ }
+
+ // default OAEP to SHA-1 message digest
+ if(!md) {
+ md = forge.md.sha1.create();
+ } else {
+ md.start();
+ }
+
+ // default MGF-1 to same as OAEP
+ if(!mgf1Md) {
+ mgf1Md = md;
+ }
+
+ // compute length in bytes and check output
+ var keyLength = Math.ceil(key.n.bitLength() / 8);
+ var maxLength = keyLength - 2 * md.digestLength - 2;
+ if(message.length > maxLength) {
+ var error = new Error('RSAES-OAEP input message length is too long.');
+ error.length = message.length;
+ error.maxLength = maxLength;
+ throw error;
+ }
+
+ if(!label) {
+ label = '';
+ }
+ md.update(label, 'raw');
+ var lHash = md.digest();
+
+ var PS = '';
+ var PS_length = maxLength - message.length;
+ for (var i = 0; i < PS_length; i++) {
+ PS += '\x00';
+ }
+
+ var DB = lHash.getBytes() + PS + '\x01' + message;
+
+ if(!seed) {
+ seed = forge.random.getBytes(md.digestLength);
+ } else if(seed.length !== md.digestLength) {
+ var error = new Error('Invalid RSAES-OAEP seed. The seed length must ' +
+ 'match the digest length.')
+ error.seedLength = seed.length;
+ error.digestLength = md.digestLength;
+ throw error;
+ }
+
+ var dbMask = rsa_mgf1(seed, keyLength - md.digestLength - 1, mgf1Md);
+ var maskedDB = forge.util.xorBytes(DB, dbMask, DB.length);
+
+ var seedMask = rsa_mgf1(maskedDB, md.digestLength, mgf1Md);
+ var maskedSeed = forge.util.xorBytes(seed, seedMask, seed.length);
+
+ // return encoded message
+ return '\x00' + maskedSeed + maskedDB;
+};
+
+/**
+ * Decode the given RSAES-OAEP encoded message (EM) using key, with optional
+ * label (L).
+ *
+ * This method does not perform RSA decryption, it only decodes the message
+ * using RSAES-OAEP.
+ *
+ * @param key the RSA key to use.
+ * @param em the encoded message to decode.
+ * @param options the options to use:
+ * label an optional label to use.
+ * md the message digest object to use for OAEP, undefined for SHA-1.
+ * mgf1 optional mgf1 parameters:
+ * md the message digest object to use for MGF1.
+ *
+ * @return the decoded message bytes.
+ */
+pkcs1.decode_rsa_oaep = function(key, em, options) {
+ // parse args
+ var label;
+ var md;
+ var mgf1Md;
+ // legacy args
+ if(typeof options === 'string') {
+ label = options;
+ md = arguments[3] || undefined;
+ } else if(options) {
+ label = options.label || undefined;
+ md = options.md || undefined;
+ if(options.mgf1 && options.mgf1.md) {
+ mgf1Md = options.mgf1.md;
+ }
+ }
+
+ // compute length in bytes
+ var keyLength = Math.ceil(key.n.bitLength() / 8);
+
+ if(em.length !== keyLength) {
+ var error = new Error('RSAES-OAEP encoded message length is invalid.');
+ error.length = em.length;
+ error.expectedLength = keyLength;
+ throw error;
+ }
+
+ // default OAEP to SHA-1 message digest
+ if(md === undefined) {
+ md = forge.md.sha1.create();
+ } else {
+ md.start();
+ }
+
+ // default MGF-1 to same as OAEP
+ if(!mgf1Md) {
+ mgf1Md = md;
+ }
+
+ if(keyLength < 2 * md.digestLength + 2) {
+ throw new Error('RSAES-OAEP key is too short for the hash function.');
+ }
+
+ if(!label) {
+ label = '';
+ }
+ md.update(label, 'raw');
+ var lHash = md.digest().getBytes();
+
+ // split the message into its parts
+ var y = em.charAt(0);
+ var maskedSeed = em.substring(1, md.digestLength + 1);
+ var maskedDB = em.substring(1 + md.digestLength);
+
+ var seedMask = rsa_mgf1(maskedDB, md.digestLength, mgf1Md);
+ var seed = forge.util.xorBytes(maskedSeed, seedMask, maskedSeed.length);
+
+ var dbMask = rsa_mgf1(seed, keyLength - md.digestLength - 1, mgf1Md);
+ var db = forge.util.xorBytes(maskedDB, dbMask, maskedDB.length);
+
+ var lHashPrime = db.substring(0, md.digestLength);
+
+ // constant time check that all values match what is expected
+ var error = (y !== '\x00');
+
+ // constant time check lHash vs lHashPrime
+ for(var i = 0; i < md.digestLength; ++i) {
+ error |= (lHash.charAt(i) !== lHashPrime.charAt(i));
+ }
+
+ // "constant time" find the 0x1 byte separating the padding (zeros) from the
+ // message
+ // TODO: It must be possible to do this in a better/smarter way?
+ var in_ps = 1;
+ var index = md.digestLength;
+ for(var j = md.digestLength; j < db.length; j++) {
+ var code = db.charCodeAt(j);
+
+ var is_0 = (code & 0x1) ^ 0x1;
+
+ // non-zero if not 0 or 1 in the ps section
+ var error_mask = in_ps ? 0xfffe : 0x0000;
+ error |= (code & error_mask);
+
+ // latch in_ps to zero after we find 0x1
+ in_ps = in_ps & is_0;
+ index += in_ps;
+ }
+
+ if(error || db.charCodeAt(index) !== 0x1) {
+ throw new Error('Invalid RSAES-OAEP padding.');
+ }
+
+ return db.substring(index + 1);
+};
+
+function rsa_mgf1(seed, maskLength, hash) {
+ // default to SHA-1 message digest
+ if(!hash) {
+ hash = forge.md.sha1.create();
+ }
+ var t = '';
+ var count = Math.ceil(maskLength / hash.digestLength);
+ for(var i = 0; i < count; ++i) {
+ var c = String.fromCharCode(
+ (i >> 24) & 0xFF, (i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF);
+ hash.start();
+ hash.update(seed + c);
+ t += hash.digest().getBytes();
+ }
+ return t.substring(0, maskLength);
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'pkcs1';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util', './random', './sha1'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs12.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs12.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs12.js
new file mode 100644
index 0000000..19f1c55
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs12.js
@@ -0,0 +1,1121 @@
+/**
+ * Javascript implementation of PKCS#12.
+ *
+ * @author Dave Longley
+ * @author Stefan Siegl <st...@brokenpipe.de>
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ * Copyright (c) 2012 Stefan Siegl <st...@brokenpipe.de>
+ *
+ * The ASN.1 representation of PKCS#12 is as follows
+ * (see ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-12/pkcs-12-tc1.pdf for details)
+ *
+ * PFX ::= SEQUENCE {
+ * version INTEGER {v3(3)}(v3,...),
+ * authSafe ContentInfo,
+ * macData MacData OPTIONAL
+ * }
+ *
+ * MacData ::= SEQUENCE {
+ * mac DigestInfo,
+ * macSalt OCTET STRING,
+ * iterations INTEGER DEFAULT 1
+ * }
+ * Note: The iterations default is for historical reasons and its use is
+ * deprecated. A higher value, like 1024, is recommended.
+ *
+ * DigestInfo is defined in PKCS#7 as follows:
+ *
+ * DigestInfo ::= SEQUENCE {
+ * digestAlgorithm DigestAlgorithmIdentifier,
+ * digest Digest
+ * }
+ *
+ * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters
+ * for the algorithm, if any. In the case of SHA1 there is none.
+ *
+ * AlgorithmIdentifer ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL
+ * }
+ *
+ * Digest ::= OCTET STRING
+ *
+ *
+ * ContentInfo ::= SEQUENCE {
+ * contentType ContentType,
+ * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
+ * }
+ *
+ * ContentType ::= OBJECT IDENTIFIER
+ *
+ * AuthenticatedSafe ::= SEQUENCE OF ContentInfo
+ * -- Data if unencrypted
+ * -- EncryptedData if password-encrypted
+ * -- EnvelopedData if public key-encrypted
+ *
+ *
+ * SafeContents ::= SEQUENCE OF SafeBag
+ *
+ * SafeBag ::= SEQUENCE {
+ * bagId BAG-TYPE.&id ({PKCS12BagSet})
+ * bagValue [0] EXPLICIT BAG-TYPE.&Type({PKCS12BagSet}{@bagId}),
+ * bagAttributes SET OF PKCS12Attribute OPTIONAL
+ * }
+ *
+ * PKCS12Attribute ::= SEQUENCE {
+ * attrId ATTRIBUTE.&id ({PKCS12AttrSet}),
+ * attrValues SET OF ATTRIBUTE.&Type ({PKCS12AttrSet}{@attrId})
+ * } -- This type is compatible with the X.500 type ’Attribute’
+ *
+ * PKCS12AttrSet ATTRIBUTE ::= {
+ * friendlyName | -- from PKCS #9
+ * localKeyId, -- from PKCS #9
+ * ... -- Other attributes are allowed
+ * }
+ *
+ * CertBag ::= SEQUENCE {
+ * certId BAG-TYPE.&id ({CertTypes}),
+ * certValue [0] EXPLICIT BAG-TYPE.&Type ({CertTypes}{@certId})
+ * }
+ *
+ * x509Certificate BAG-TYPE ::= {OCTET STRING IDENTIFIED BY {certTypes 1}}
+ * -- DER-encoded X.509 certificate stored in OCTET STRING
+ *
+ * sdsiCertificate BAG-TYPE ::= {IA5String IDENTIFIED BY {certTypes 2}}
+ * -- Base64-encoded SDSI certificate stored in IA5String
+ *
+ * CertTypes BAG-TYPE ::= {
+ * x509Certificate |
+ * sdsiCertificate,
+ * ... -- For future extensions
+ * }
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// shortcut for asn.1 & PKI API
+var asn1 = forge.asn1;
+var pki = forge.pki;
+
+// shortcut for PKCS#12 API
+var p12 = forge.pkcs12 = forge.pkcs12 || {};
+
+var contentInfoValidator = {
+ name: 'ContentInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE, // a ContentInfo
+ constructed: true,
+ value: [{
+ name: 'ContentInfo.contentType',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'contentType'
+ }, {
+ name: 'ContentInfo.content',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ constructed: true,
+ captureAsn1: 'content'
+ }]
+};
+
+var pfxValidator = {
+ name: 'PFX',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'PFX.version',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'version'
+ },
+ contentInfoValidator, {
+ name: 'PFX.macData',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ optional: true,
+ captureAsn1: 'mac',
+ value: [{
+ name: 'PFX.macData.mac',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE, // DigestInfo
+ constructed: true,
+ value: [{
+ name: 'PFX.macData.mac.digestAlgorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE, // DigestAlgorithmIdentifier
+ constructed: true,
+ value: [{
+ name: 'PFX.macData.mac.digestAlgorithm.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'macAlgorithm'
+ }, {
+ name: 'PFX.macData.mac.digestAlgorithm.parameters',
+ tagClass: asn1.Class.UNIVERSAL,
+ captureAsn1: 'macAlgorithmParameters'
+ }]
+ }, {
+ name: 'PFX.macData.mac.digest',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ constructed: false,
+ capture: 'macDigest'
+ }]
+ }, {
+ name: 'PFX.macData.macSalt',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ constructed: false,
+ capture: 'macSalt'
+ }, {
+ name: 'PFX.macData.iterations',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ optional: true,
+ capture: 'macIterations'
+ }]
+ }]
+};
+
+var safeBagValidator = {
+ name: 'SafeBag',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'SafeBag.bagId',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'bagId'
+ }, {
+ name: 'SafeBag.bagValue',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ constructed: true,
+ captureAsn1: 'bagValue'
+ }, {
+ name: 'SafeBag.bagAttributes',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SET,
+ constructed: true,
+ optional: true,
+ capture: 'bagAttributes'
+ }]
+};
+
+var attributeValidator = {
+ name: 'Attribute',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'Attribute.attrId',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'oid'
+ }, {
+ name: 'Attribute.attrValues',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SET,
+ constructed: true,
+ capture: 'values'
+ }]
+};
+
+var certBagValidator = {
+ name: 'CertBag',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'CertBag.certId',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'certId'
+ }, {
+ name: 'CertBag.certValue',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ constructed: true,
+ /* So far we only support X.509 certificates (which are wrapped in
+ an OCTET STRING, hence hard code that here). */
+ value: [{
+ name: 'CertBag.certValue[0]',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Class.OCTETSTRING,
+ constructed: false,
+ capture: 'cert'
+ }]
+ }]
+};
+
+/**
+ * Search SafeContents structure for bags with matching attributes.
+ *
+ * The search can optionally be narrowed by a certain bag type.
+ *
+ * @param safeContents the SafeContents structure to search in.
+ * @param attrName the name of the attribute to compare against.
+ * @param attrValue the attribute value to search for.
+ * @param [bagType] bag type to narrow search by.
+ *
+ * @return an array of matching bags.
+ */
+function _getBagsByAttribute(safeContents, attrName, attrValue, bagType) {
+ var result = [];
+
+ for(var i = 0; i < safeContents.length; i ++) {
+ for(var j = 0; j < safeContents[i].safeBags.length; j ++) {
+ var bag = safeContents[i].safeBags[j];
+ if(bagType !== undefined && bag.type !== bagType) {
+ continue;
+ }
+ // only filter by bag type, no attribute specified
+ if(attrName === null) {
+ result.push(bag);
+ continue;
+ }
+ if(bag.attributes[attrName] !== undefined &&
+ bag.attributes[attrName].indexOf(attrValue) >= 0) {
+ result.push(bag);
+ }
+ }
+ }
+
+ return result;
+}
+
+/**
+ * Converts a PKCS#12 PFX in ASN.1 notation into a PFX object.
+ *
+ * @param obj The PKCS#12 PFX in ASN.1 notation.
+ * @param strict true to use strict DER decoding, false not to (default: true).
+ * @param {String} password Password to decrypt with (optional).
+ *
+ * @return PKCS#12 PFX object.
+ */
+p12.pkcs12FromAsn1 = function(obj, strict, password) {
+ // handle args
+ if(typeof strict === 'string') {
+ password = strict;
+ strict = true;
+ } else if(strict === undefined) {
+ strict = true;
+ }
+
+ // validate PFX and capture data
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(obj, pfxValidator, capture, errors)) {
+ var error = new Error('Cannot read PKCS#12 PFX. ' +
+ 'ASN.1 object is not an PKCS#12 PFX.');
+ error.errors = error;
+ throw error;
+ }
+
+ var pfx = {
+ version: capture.version.charCodeAt(0),
+ safeContents: [],
+
+ /**
+ * Gets bags with matching attributes.
+ *
+ * @param filter the attributes to filter by:
+ * [localKeyId] the localKeyId to search for.
+ * [localKeyIdHex] the localKeyId in hex to search for.
+ * [friendlyName] the friendly name to search for.
+ * [bagType] bag type to narrow each attribute search by.
+ *
+ * @return a map of attribute type to an array of matching bags or, if no
+ * attribute was given but a bag type, the map key will be the
+ * bag type.
+ */
+ getBags: function(filter) {
+ var rval = {};
+
+ var localKeyId;
+ if('localKeyId' in filter) {
+ localKeyId = filter.localKeyId;
+ } else if('localKeyIdHex' in filter) {
+ localKeyId = forge.util.hexToBytes(filter.localKeyIdHex);
+ }
+
+ // filter on bagType only
+ if(localKeyId === undefined && !('friendlyName' in filter) &&
+ 'bagType' in filter) {
+ rval[filter.bagType] = _getBagsByAttribute(
+ pfx.safeContents, null, null, filter.bagType);
+ }
+
+ if(localKeyId !== undefined) {
+ rval.localKeyId = _getBagsByAttribute(
+ pfx.safeContents, 'localKeyId',
+ localKeyId, filter.bagType);
+ }
+ if('friendlyName' in filter) {
+ rval.friendlyName = _getBagsByAttribute(
+ pfx.safeContents, 'friendlyName',
+ filter.friendlyName, filter.bagType);
+ }
+
+ return rval;
+ },
+
+ /**
+ * DEPRECATED: use getBags() instead.
+ *
+ * Get bags with matching friendlyName attribute.
+ *
+ * @param friendlyName the friendly name to search for.
+ * @param [bagType] bag type to narrow search by.
+ *
+ * @return an array of bags with matching friendlyName attribute.
+ */
+ getBagsByFriendlyName: function(friendlyName, bagType) {
+ return _getBagsByAttribute(
+ pfx.safeContents, 'friendlyName', friendlyName, bagType);
+ },
+
+ /**
+ * DEPRECATED: use getBags() instead.
+ *
+ * Get bags with matching localKeyId attribute.
+ *
+ * @param localKeyId the localKeyId to search for.
+ * @param [bagType] bag type to narrow search by.
+ *
+ * @return an array of bags with matching localKeyId attribute.
+ */
+ getBagsByLocalKeyId: function(localKeyId, bagType) {
+ return _getBagsByAttribute(
+ pfx.safeContents, 'localKeyId', localKeyId, bagType);
+ }
+ };
+
+ if(capture.version.charCodeAt(0) !== 3) {
+ var error = new Error('PKCS#12 PFX of version other than 3 not supported.');
+ error.version = capture.version.charCodeAt(0);
+ throw error;
+ }
+
+ if(asn1.derToOid(capture.contentType) !== pki.oids.data) {
+ var error = new Error('Only PKCS#12 PFX in password integrity mode supported.');
+ error.oid = asn1.derToOid(capture.contentType);
+ throw error;
+ }
+
+ var data = capture.content.value[0];
+ if(data.tagClass !== asn1.Class.UNIVERSAL ||
+ data.type !== asn1.Type.OCTETSTRING) {
+ throw new Error('PKCS#12 authSafe content data is not an OCTET STRING.');
+ }
+ data = _decodePkcs7Data(data);
+
+ // check for MAC
+ if(capture.mac) {
+ var md = null;
+ var macKeyBytes = 0;
+ var macAlgorithm = asn1.derToOid(capture.macAlgorithm);
+ switch(macAlgorithm) {
+ case pki.oids.sha1:
+ md = forge.md.sha1.create();
+ macKeyBytes = 20;
+ break;
+ case pki.oids.sha256:
+ md = forge.md.sha256.create();
+ macKeyBytes = 32;
+ break;
+ case pki.oids.sha384:
+ md = forge.md.sha384.create();
+ macKeyBytes = 48;
+ break;
+ case pki.oids.sha512:
+ md = forge.md.sha512.create();
+ macKeyBytes = 64;
+ break;
+ case pki.oids.md5:
+ md = forge.md.md5.create();
+ macKeyBytes = 16;
+ break;
+ }
+ if(md === null) {
+ throw new Error('PKCS#12 uses unsupported MAC algorithm: ' + macAlgorithm);
+ }
+
+ // verify MAC (iterations default to 1)
+ var macSalt = new forge.util.ByteBuffer(capture.macSalt);
+ var macIterations = (('macIterations' in capture) ?
+ parseInt(forge.util.bytesToHex(capture.macIterations), 16) : 1);
+ var macKey = p12.generateKey(
+ password, macSalt, 3, macIterations, macKeyBytes, md);
+ var mac = forge.hmac.create();
+ mac.start(md, macKey);
+ mac.update(data.value);
+ var macValue = mac.getMac();
+ if(macValue.getBytes() !== capture.macDigest) {
+ throw new Error('PKCS#12 MAC could not be verified. Invalid password?');
+ }
+ }
+
+ _decodeAuthenticatedSafe(pfx, data.value, strict, password);
+ return pfx;
+};
+
+/**
+ * Decodes PKCS#7 Data. PKCS#7 (RFC 2315) defines "Data" as an OCTET STRING,
+ * but it is sometimes an OCTET STRING that is composed/constructed of chunks,
+ * each its own OCTET STRING. This is BER-encoding vs. DER-encoding. This
+ * function transforms this corner-case into the usual simple,
+ * non-composed/constructed OCTET STRING.
+ *
+ * This function may be moved to ASN.1 at some point to better deal with
+ * more BER-encoding issues, should they arise.
+ *
+ * @param data the ASN.1 Data object to transform.
+ */
+function _decodePkcs7Data(data) {
+ // handle special case of "chunked" data content: an octet string composed
+ // of other octet strings
+ if(data.composed || data.constructed) {
+ var value = forge.util.createBuffer();
+ for(var i = 0; i < data.value.length; ++i) {
+ value.putBytes(data.value[i].value);
+ }
+ data.composed = data.constructed = false;
+ data.value = value.getBytes();
+ }
+ return data;
+}
+
+/**
+ * Decode PKCS#12 AuthenticatedSafe (BER encoded) into PFX object.
+ *
+ * The AuthenticatedSafe is a BER-encoded SEQUENCE OF ContentInfo.
+ *
+ * @param pfx The PKCS#12 PFX object to fill.
+ * @param {String} authSafe BER-encoded AuthenticatedSafe.
+ * @param strict true to use strict DER decoding, false not to.
+ * @param {String} password Password to decrypt with (optional).
+ */
+function _decodeAuthenticatedSafe(pfx, authSafe, strict, password) {
+ authSafe = asn1.fromDer(authSafe, strict); /* actually it's BER encoded */
+
+ if(authSafe.tagClass !== asn1.Class.UNIVERSAL ||
+ authSafe.type !== asn1.Type.SEQUENCE ||
+ authSafe.constructed !== true) {
+ throw new Error('PKCS#12 AuthenticatedSafe expected to be a ' +
+ 'SEQUENCE OF ContentInfo');
+ }
+
+ for(var i = 0; i < authSafe.value.length; i ++) {
+ var contentInfo = authSafe.value[i];
+
+ // validate contentInfo and capture data
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(contentInfo, contentInfoValidator, capture, errors)) {
+ var error = new Error('Cannot read ContentInfo.');
+ error.errors = errors;
+ throw error;
+ }
+
+ var obj = {
+ encrypted: false
+ };
+ var safeContents = null;
+ var data = capture.content.value[0];
+ switch(asn1.derToOid(capture.contentType)) {
+ case pki.oids.data:
+ if(data.tagClass !== asn1.Class.UNIVERSAL ||
+ data.type !== asn1.Type.OCTETSTRING) {
+ throw new Error('PKCS#12 SafeContents Data is not an OCTET STRING.');
+ }
+ safeContents = _decodePkcs7Data(data).value;
+ break;
+ case pki.oids.encryptedData:
+ safeContents = _decryptSafeContents(data, password);
+ obj.encrypted = true;
+ break;
+ default:
+ var error = new Error('Unsupported PKCS#12 contentType.');
+ error.contentType = asn1.derToOid(capture.contentType);
+ throw error;
+ }
+
+ obj.safeBags = _decodeSafeContents(safeContents, strict, password);
+ pfx.safeContents.push(obj);
+ }
+}
+
+/**
+ * Decrypt PKCS#7 EncryptedData structure.
+ *
+ * @param data ASN.1 encoded EncryptedContentInfo object.
+ * @param password The user-provided password.
+ *
+ * @return The decrypted SafeContents (ASN.1 object).
+ */
+function _decryptSafeContents(data, password) {
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(
+ data, forge.pkcs7.asn1.encryptedDataValidator, capture, errors)) {
+ var error = new Error('Cannot read EncryptedContentInfo.');
+ error.errors = errors;
+ throw error;
+ }
+
+ var oid = asn1.derToOid(capture.contentType);
+ if(oid !== pki.oids.data) {
+ var error = new Error(
+ 'PKCS#12 EncryptedContentInfo ContentType is not Data.');
+ error.oid = oid;
+ throw error;
+ }
+
+ // get cipher
+ oid = asn1.derToOid(capture.encAlgorithm);
+ var cipher = pki.pbe.getCipher(oid, capture.encParameter, password);
+
+ // get encrypted data
+ var encryptedContentAsn1 = _decodePkcs7Data(capture.encryptedContentAsn1);
+ var encrypted = forge.util.createBuffer(encryptedContentAsn1.value);
+
+ cipher.update(encrypted);
+ if(!cipher.finish()) {
+ throw new Error('Failed to decrypt PKCS#12 SafeContents.');
+ }
+
+ return cipher.output.getBytes();
+}
+
+/**
+ * Decode PKCS#12 SafeContents (BER-encoded) into array of Bag objects.
+ *
+ * The safeContents is a BER-encoded SEQUENCE OF SafeBag.
+ *
+ * @param {String} safeContents BER-encoded safeContents.
+ * @param strict true to use strict DER decoding, false not to.
+ * @param {String} password Password to decrypt with (optional).
+ *
+ * @return {Array} Array of Bag objects.
+ */
+function _decodeSafeContents(safeContents, strict, password) {
+ // if strict and no safe contents, return empty safes
+ if(!strict && safeContents.length === 0) {
+ return [];
+ }
+
+ // actually it's BER-encoded
+ safeContents = asn1.fromDer(safeContents, strict);
+
+ if(safeContents.tagClass !== asn1.Class.UNIVERSAL ||
+ safeContents.type !== asn1.Type.SEQUENCE ||
+ safeContents.constructed !== true) {
+ throw new Error(
+ 'PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.');
+ }
+
+ var res = [];
+ for(var i = 0; i < safeContents.value.length; i++) {
+ var safeBag = safeContents.value[i];
+
+ // validate SafeBag and capture data
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(safeBag, safeBagValidator, capture, errors)) {
+ var error = new Error('Cannot read SafeBag.');
+ error.errors = errors;
+ throw error;
+ }
+
+ /* Create bag object and push to result array. */
+ var bag = {
+ type: asn1.derToOid(capture.bagId),
+ attributes: _decodeBagAttributes(capture.bagAttributes)
+ };
+ res.push(bag);
+
+ var validator, decoder;
+ var bagAsn1 = capture.bagValue.value[0];
+ switch(bag.type) {
+ case pki.oids.pkcs8ShroudedKeyBag:
+ /* bagAsn1 has a EncryptedPrivateKeyInfo, which we need to decrypt.
+ Afterwards we can handle it like a keyBag,
+ which is a PrivateKeyInfo. */
+ bagAsn1 = pki.decryptPrivateKeyInfo(bagAsn1, password);
+ if(bagAsn1 === null) {
+ throw new Error(
+ 'Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?');
+ }
+
+ /* fall through */
+ case pki.oids.keyBag:
+ /* A PKCS#12 keyBag is a simple PrivateKeyInfo as understood by our
+ PKI module, hence we don't have to do validation/capturing here,
+ just pass what we already got. */
+ bag.key = pki.privateKeyFromAsn1(bagAsn1);
+ continue; /* Nothing more to do. */
+
+ case pki.oids.certBag:
+ /* A PKCS#12 certBag can wrap both X.509 and sdsi certificates.
+ Therefore put the SafeBag content through another validator to
+ capture the fields. Afterwards check & store the results. */
+ validator = certBagValidator;
+ decoder = function() {
+ if(asn1.derToOid(capture.certId) !== pki.oids.x509Certificate) {
+ var error = new Error(
+ 'Unsupported certificate type, only X.509 supported.');
+ error.oid = asn1.derToOid(capture.certId);
+ throw error;
+ }
+
+ // true=produce cert hash
+ bag.cert = pki.certificateFromAsn1(
+ asn1.fromDer(capture.cert, strict), true);
+ };
+ break;
+
+ default:
+ var error = new Error('Unsupported PKCS#12 SafeBag type.');
+ error.oid = bag.type;
+ throw error;
+ }
+
+ /* Validate SafeBag value (i.e. CertBag, etc.) and capture data if needed. */
+ if(validator !== undefined &&
+ !asn1.validate(bagAsn1, validator, capture, errors)) {
+ var error = new Error('Cannot read PKCS#12 ' + validator.name);
+ error.errors = errors;
+ throw error;
+ }
+
+ /* Call decoder function from above to store the results. */
+ decoder();
+ }
+
+ return res;
+}
+
+/**
+ * Decode PKCS#12 SET OF PKCS12Attribute into JavaScript object.
+ *
+ * @param attributes SET OF PKCS12Attribute (ASN.1 object).
+ *
+ * @return the decoded attributes.
+ */
+function _decodeBagAttributes(attributes) {
+ var decodedAttrs = {};
+
+ if(attributes !== undefined) {
+ for(var i = 0; i < attributes.length; ++i) {
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(attributes[i], attributeValidator, capture, errors)) {
+ var error = new Error('Cannot read PKCS#12 BagAttribute.');
+ error.errors = errors;
+ throw error;
+ }
+
+ var oid = asn1.derToOid(capture.oid);
+ if(pki.oids[oid] === undefined) {
+ // unsupported attribute type, ignore.
+ continue;
+ }
+
+ decodedAttrs[pki.oids[oid]] = [];
+ for(var j = 0; j < capture.values.length; ++j) {
+ decodedAttrs[pki.oids[oid]].push(capture.values[j].value);
+ }
+ }
+ }
+
+ return decodedAttrs;
+}
+
+/**
+ * Wraps a private key and certificate in a PKCS#12 PFX wrapper. If a
+ * password is provided then the private key will be encrypted.
+ *
+ * An entire certificate chain may also be included. To do this, pass
+ * an array for the "cert" parameter where the first certificate is
+ * the one that is paired with the private key and each subsequent one
+ * verifies the previous one. The certificates may be in PEM format or
+ * have been already parsed by Forge.
+ *
+ * @todo implement password-based-encryption for the whole package
+ *
+ * @param key the private key.
+ * @param cert the certificate (may be an array of certificates in order
+ * to specify a certificate chain).
+ * @param password the password to use, null for none.
+ * @param options:
+ * algorithm the encryption algorithm to use
+ * ('aes128', 'aes192', 'aes256', '3des'), defaults to 'aes128'.
+ * count the iteration count to use.
+ * saltSize the salt size to use.
+ * useMac true to include a MAC, false not to, defaults to true.
+ * localKeyId the local key ID to use, in hex.
+ * friendlyName the friendly name to use.
+ * generateLocalKeyId true to generate a random local key ID,
+ * false not to, defaults to true.
+ *
+ * @return the PKCS#12 PFX ASN.1 object.
+ */
+p12.toPkcs12Asn1 = function(key, cert, password, options) {
+ // set default options
+ options = options || {};
+ options.saltSize = options.saltSize || 8;
+ options.count = options.count || 2048;
+ options.algorithm = options.algorithm || options.encAlgorithm || 'aes128';
+ if(!('useMac' in options)) {
+ options.useMac = true;
+ }
+ if(!('localKeyId' in options)) {
+ options.localKeyId = null;
+ }
+ if(!('generateLocalKeyId' in options)) {
+ options.generateLocalKeyId = true;
+ }
+
+ var localKeyId = options.localKeyId;
+ var bagAttrs;
+ if(localKeyId !== null) {
+ localKeyId = forge.util.hexToBytes(localKeyId);
+ } else if(options.generateLocalKeyId) {
+ // use SHA-1 of paired cert, if available
+ if(cert) {
+ var pairedCert = forge.util.isArray(cert) ? cert[0] : cert;
+ if(typeof pairedCert === 'string') {
+ pairedCert = pki.certificateFromPem(pairedCert);
+ }
+ var sha1 = forge.md.sha1.create();
+ sha1.update(asn1.toDer(pki.certificateToAsn1(pairedCert)).getBytes());
+ localKeyId = sha1.digest().getBytes();
+ } else {
+ // FIXME: consider using SHA-1 of public key (which can be generated
+ // from private key components), see: cert.generateSubjectKeyIdentifier
+ // generate random bytes
+ localKeyId = forge.random.getBytes(20);
+ }
+ }
+
+ var attrs = [];
+ if(localKeyId !== null) {
+ attrs.push(
+ // localKeyID
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // attrId
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids.localKeyId).getBytes()),
+ // attrValues
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ localKeyId)
+ ])
+ ]));
+ }
+ if('friendlyName' in options) {
+ attrs.push(
+ // friendlyName
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // attrId
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids.friendlyName).getBytes()),
+ // attrValues
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BMPSTRING, false,
+ options.friendlyName)
+ ])
+ ]));
+ }
+
+ if(attrs.length > 0) {
+ bagAttrs = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, attrs);
+ }
+
+ // collect contents for AuthenticatedSafe
+ var contents = [];
+
+ // create safe bag(s) for certificate chain
+ var chain = [];
+ if(cert !== null) {
+ if(forge.util.isArray(cert)) {
+ chain = cert;
+ } else {
+ chain = [cert];
+ }
+ }
+
+ var certSafeBags = [];
+ for(var i = 0; i < chain.length; ++i) {
+ // convert cert from PEM as necessary
+ cert = chain[i];
+ if(typeof cert === 'string') {
+ cert = pki.certificateFromPem(cert);
+ }
+
+ // SafeBag
+ var certBagAttrs = (i === 0) ? bagAttrs : undefined;
+ var certAsn1 = pki.certificateToAsn1(cert);
+ var certSafeBag =
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // bagId
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids.certBag).getBytes()),
+ // bagValue
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ // CertBag
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // certId
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids.x509Certificate).getBytes()),
+ // certValue (x509Certificate)
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ asn1.toDer(certAsn1).getBytes())
+ ])])]),
+ // bagAttributes (OPTIONAL)
+ certBagAttrs
+ ]);
+ certSafeBags.push(certSafeBag);
+ }
+
+ if(certSafeBags.length > 0) {
+ // SafeContents
+ var certSafeContents = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, certSafeBags);
+
+ // ContentInfo
+ var certCI =
+ // PKCS#7 ContentInfo
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // contentType
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ // OID for the content type is 'data'
+ asn1.oidToDer(pki.oids.data).getBytes()),
+ // content
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ asn1.toDer(certSafeContents).getBytes())
+ ])
+ ]);
+ contents.push(certCI);
+ }
+
+ // create safe contents for private key
+ var keyBag = null;
+ if(key !== null) {
+ // SafeBag
+ var pkAsn1 = pki.wrapRsaPrivateKey(pki.privateKeyToAsn1(key));
+ if(password === null) {
+ // no encryption
+ keyBag = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // bagId
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids.keyBag).getBytes()),
+ // bagValue
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ // PrivateKeyInfo
+ pkAsn1
+ ]),
+ // bagAttributes (OPTIONAL)
+ bagAttrs
+ ]);
+ } else {
+ // encrypted PrivateKeyInfo
+ keyBag = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // bagId
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids.pkcs8ShroudedKeyBag).getBytes()),
+ // bagValue
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ // EncryptedPrivateKeyInfo
+ pki.encryptPrivateKeyInfo(pkAsn1, password, options)
+ ]),
+ // bagAttributes (OPTIONAL)
+ bagAttrs
+ ]);
+ }
+
+ // SafeContents
+ var keySafeContents =
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [keyBag]);
+
+ // ContentInfo
+ var keyCI =
+ // PKCS#7 ContentInfo
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // contentType
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ // OID for the content type is 'data'
+ asn1.oidToDer(pki.oids.data).getBytes()),
+ // content
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ asn1.toDer(keySafeContents).getBytes())
+ ])
+ ]);
+ contents.push(keyCI);
+ }
+
+ // create AuthenticatedSafe by stringing together the contents
+ var safe = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, contents);
+
+ var macData;
+ if(options.useMac) {
+ // MacData
+ var sha1 = forge.md.sha1.create();
+ var macSalt = new forge.util.ByteBuffer(
+ forge.random.getBytes(options.saltSize));
+ var count = options.count;
+ // 160-bit key
+ var key = p12.generateKey(password, macSalt, 3, count, 20);
+ var mac = forge.hmac.create();
+ mac.start(sha1, key);
+ mac.update(asn1.toDer(safe).getBytes());
+ var macValue = mac.getMac();
+ macData = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // mac DigestInfo
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // digestAlgorithm
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // algorithm = SHA-1
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids.sha1).getBytes()),
+ // parameters = Null
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
+ ]),
+ // digest
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,
+ false, macValue.getBytes())
+ ]),
+ // macSalt OCTET STRING
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, macSalt.getBytes()),
+ // iterations INTEGER (XXX: Only support count < 65536)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(count).getBytes()
+ )
+ ]);
+ }
+
+ // PFX
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // version (3)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(3).getBytes()),
+ // PKCS#7 ContentInfo
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // contentType
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ // OID for the content type is 'data'
+ asn1.oidToDer(pki.oids.data).getBytes()),
+ // content
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ asn1.toDer(safe).getBytes())
+ ])
+ ]),
+ macData
+ ]);
+};
+
+/**
+ * Derives a PKCS#12 key.
+ *
+ * @param password the password to derive the key material from, null or
+ * undefined for none.
+ * @param salt the salt, as a ByteBuffer, to use.
+ * @param id the PKCS#12 ID byte (1 = key material, 2 = IV, 3 = MAC).
+ * @param iter the iteration count.
+ * @param n the number of bytes to derive from the password.
+ * @param md the message digest to use, defaults to SHA-1.
+ *
+ * @return a ByteBuffer with the bytes derived from the password.
+ */
+p12.generateKey = forge.pbe.generatePkcs12Key;
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'pkcs12';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define([
+ 'require',
+ 'module',
+ './asn1',
+ './hmac',
+ './oids',
+ './pkcs7asn1',
+ './pbe',
+ './random',
+ './rsa',
+ './sha1',
+ './util',
+ './x509'
+], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs7.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs7.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs7.js
new file mode 100644
index 0000000..ffa7413
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs7.js
@@ -0,0 +1,842 @@
+/**
+ * Javascript implementation of PKCS#7 v1.5. Currently only certain parts of
+ * PKCS#7 are implemented, especially the enveloped-data content type.
+ *
+ * @author Stefan Siegl
+ *
+ * Copyright (c) 2012 Stefan Siegl <st...@brokenpipe.de>
+ *
+ * Currently this implementation only supports ContentType of either
+ * EnvelopedData or EncryptedData on root level. The top level elements may
+ * contain only a ContentInfo of ContentType Data, i.e. plain data. Further
+ * nesting is not (yet) supported.
+ *
+ * The Forge validators for PKCS #7's ASN.1 structures are available from
+ * a seperate file pkcs7asn1.js, since those are referenced from other
+ * PKCS standards like PKCS #12.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// shortcut for ASN.1 API
+var asn1 = forge.asn1;
+
+// shortcut for PKCS#7 API
+var p7 = forge.pkcs7 = forge.pkcs7 || {};
+
+/**
+ * Converts a PKCS#7 message from PEM format.
+ *
+ * @param pem the PEM-formatted PKCS#7 message.
+ *
+ * @return the PKCS#7 message.
+ */
+p7.messageFromPem = function(pem) {
+ var msg = forge.pem.decode(pem)[0];
+
+ if(msg.type !== 'PKCS7') {
+ var error = new Error('Could not convert PKCS#7 message from PEM; PEM ' +
+ 'header type is not "PKCS#7".');
+ error.headerType = msg.type;
+ throw error;
+ }
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
+ throw new Error('Could not convert PKCS#7 message from PEM; PEM is encrypted.');
+ }
+
+ // convert DER to ASN.1 object
+ var obj = asn1.fromDer(msg.body);
+
+ return p7.messageFromAsn1(obj);
+};
+
+/**
+ * Converts a PKCS#7 message to PEM format.
+ *
+ * @param msg The PKCS#7 message object
+ * @param maxline The maximum characters per line, defaults to 64.
+ *
+ * @return The PEM-formatted PKCS#7 message.
+ */
+p7.messageToPem = function(msg, maxline) {
+ // convert to ASN.1, then DER, then PEM-encode
+ var pemObj = {
+ type: 'PKCS7',
+ body: asn1.toDer(msg.toAsn1()).getBytes()
+ };
+ return forge.pem.encode(pemObj, {maxline: maxline});
+};
+
+/**
+ * Converts a PKCS#7 message from an ASN.1 object.
+ *
+ * @param obj the ASN.1 representation of a ContentInfo.
+ *
+ * @return the PKCS#7 message.
+ */
+p7.messageFromAsn1 = function(obj) {
+ // validate root level ContentInfo and capture data
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(obj, p7.asn1.contentInfoValidator, capture, errors))
+ {
+ var error = new Error('Cannot read PKCS#7 message. ' +
+ 'ASN.1 object is not an PKCS#7 ContentInfo.');
+ error.errors = errors;
+ throw error;
+ }
+
+ var contentType = asn1.derToOid(capture.contentType);
+ var msg;
+
+ switch(contentType) {
+ case forge.pki.oids.envelopedData:
+ msg = p7.createEnvelopedData();
+ break;
+
+ case forge.pki.oids.encryptedData:
+ msg = p7.createEncryptedData();
+ break;
+
+ case forge.pki.oids.signedData:
+ msg = p7.createSignedData();
+ break;
+
+ default:
+ throw new Error('Cannot read PKCS#7 message. ContentType with OID ' +
+ contentType + ' is not (yet) supported.');
+ }
+
+ msg.fromAsn1(capture.content.value[0]);
+ return msg;
+};
+
+/**
+ * Converts a single RecipientInfo from an ASN.1 object.
+ *
+ * @param obj The ASN.1 representation of a RecipientInfo.
+ *
+ * @return The recipientInfo object.
+ */
+var _recipientInfoFromAsn1 = function(obj) {
+ // Validate EnvelopedData content block and capture data.
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(obj, p7.asn1.recipientInfoValidator, capture, errors))
+ {
+ var error = new Error('Cannot read PKCS#7 message. ' +
+ 'ASN.1 object is not an PKCS#7 EnvelopedData.');
+ error.errors = errors;
+ throw error;
+ }
+
+ return {
+ version: capture.version.charCodeAt(0),
+ issuer: forge.pki.RDNAttributesAsArray(capture.issuer),
+ serialNumber: forge.util.createBuffer(capture.serial).toHex(),
+ encryptedContent: {
+ algorithm: asn1.derToOid(capture.encAlgorithm),
+ parameter: capture.encParameter.value,
+ content: capture.encKey
+ }
+ };
+};
+
+/**
+ * Converts a single recipientInfo object to an ASN.1 object.
+ *
+ * @param obj The recipientInfo object.
+ *
+ * @return The ASN.1 representation of a RecipientInfo.
+ */
+var _recipientInfoToAsn1 = function(obj) {
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // Version
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(obj.version).getBytes()),
+ // IssuerAndSerialNumber
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // Name
+ forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),
+ // Serial
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ forge.util.hexToBytes(obj.serialNumber))
+ ]),
+ // KeyEncryptionAlgorithmIdentifier
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // Algorithm
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(obj.encryptedContent.algorithm).getBytes()),
+ // Parameter, force NULL, only RSA supported for now.
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
+ ]),
+ // EncryptedKey
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ obj.encryptedContent.content)
+ ]);
+};
+
+/**
+ * Map a set of RecipientInfo ASN.1 objects to recipientInfo objects.
+ *
+ * @param objArr Array of ASN.1 representations RecipientInfo (i.e. SET OF).
+ *
+ * @return array of recipientInfo objects.
+ */
+var _recipientInfosFromAsn1 = function(objArr) {
+ var ret = [];
+ for(var i = 0; i < objArr.length; i ++) {
+ ret.push(_recipientInfoFromAsn1(objArr[i]));
+ }
+ return ret;
+};
+
+/**
+ * Map an array of recipientInfo objects to ASN.1 objects.
+ *
+ * @param recipientsArr Array of recipientInfo objects.
+ *
+ * @return Array of ASN.1 representations RecipientInfo.
+ */
+var _recipientInfosToAsn1 = function(recipientsArr) {
+ var ret = [];
+ for(var i = 0; i < recipientsArr.length; i ++) {
+ ret.push(_recipientInfoToAsn1(recipientsArr[i]));
+ }
+ return ret;
+};
+
+/**
+ * Map messages encrypted content to ASN.1 objects.
+ *
+ * @param ec The encryptedContent object of the message.
+ *
+ * @return ASN.1 representation of the encryptedContent object (SEQUENCE).
+ */
+var _encryptedContentToAsn1 = function(ec) {
+ return [
+ // ContentType, always Data for the moment
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(forge.pki.oids.data).getBytes()),
+ // ContentEncryptionAlgorithmIdentifier
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // Algorithm
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(ec.algorithm).getBytes()),
+ // Parameters (IV)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ ec.parameter.getBytes())
+ ]),
+ // [0] EncryptedContent
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ ec.content.getBytes())
+ ])
+ ];
+};
+
+/**
+ * Reads the "common part" of an PKCS#7 content block (in ASN.1 format)
+ *
+ * This function reads the "common part" of the PKCS#7 content blocks
+ * EncryptedData and EnvelopedData, i.e. version number and symmetrically
+ * encrypted content block.
+ *
+ * The result of the ASN.1 validate and capture process is returned
+ * to allow the caller to extract further data, e.g. the list of recipients
+ * in case of a EnvelopedData object.
+ *
+ * @param msg the PKCS#7 object to read the data to.
+ * @param obj the ASN.1 representation of the content block.
+ * @param validator the ASN.1 structure validator object to use.
+ *
+ * @return the value map captured by validator object.
+ */
+var _fromAsn1 = function(msg, obj, validator) {
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(obj, validator, capture, errors)) {
+ var error = new Error('Cannot read PKCS#7 message. ' +
+ 'ASN.1 object is not a supported PKCS#7 message.');
+ error.errors = error;
+ throw error;
+ }
+
+ // Check contentType, so far we only support (raw) Data.
+ var contentType = asn1.derToOid(capture.contentType);
+ if(contentType !== forge.pki.oids.data) {
+ throw new Error('Unsupported PKCS#7 message. ' +
+ 'Only wrapped ContentType Data supported.');
+ }
+
+ if(capture.encryptedContent) {
+ var content = '';
+ if(forge.util.isArray(capture.encryptedContent)) {
+ for(var i = 0; i < capture.encryptedContent.length; ++i) {
+ if(capture.encryptedContent[i].type !== asn1.Type.OCTETSTRING) {
+ throw new Error('Malformed PKCS#7 message, expecting encrypted ' +
+ 'content constructed of only OCTET STRING objects.');
+ }
+ content += capture.encryptedContent[i].value;
+ }
+ } else {
+ content = capture.encryptedContent;
+ }
+ msg.encryptedContent = {
+ algorithm: asn1.derToOid(capture.encAlgorithm),
+ parameter: forge.util.createBuffer(capture.encParameter.value),
+ content: forge.util.createBuffer(content)
+ };
+ }
+
+ if(capture.content) {
+ var content = '';
+ if(forge.util.isArray(capture.content)) {
+ for(var i = 0; i < capture.content.length; ++i) {
+ if(capture.content[i].type !== asn1.Type.OCTETSTRING) {
+ throw new Error('Malformed PKCS#7 message, expecting ' +
+ 'content constructed of only OCTET STRING objects.');
+ }
+ content += capture.content[i].value;
+ }
+ } else {
+ content = capture.content;
+ }
+ msg.content = forge.util.createBuffer(content);
+ }
+
+ msg.version = capture.version.charCodeAt(0);
+ msg.rawCapture = capture;
+
+ return capture;
+};
+
+/**
+ * Decrypt the symmetrically encrypted content block of the PKCS#7 message.
+ *
+ * Decryption is skipped in case the PKCS#7 message object already has a
+ * (decrypted) content attribute. The algorithm, key and cipher parameters
+ * (probably the iv) are taken from the encryptedContent attribute of the
+ * message object.
+ *
+ * @param The PKCS#7 message object.
+ */
+var _decryptContent = function (msg) {
+ if(msg.encryptedContent.key === undefined) {
+ throw new Error('Symmetric key not available.');
+ }
+
+ if(msg.content === undefined) {
+ var ciph;
+
+ switch(msg.encryptedContent.algorithm) {
+ case forge.pki.oids['aes128-CBC']:
+ case forge.pki.oids['aes192-CBC']:
+ case forge.pki.oids['aes256-CBC']:
+ ciph = forge.aes.createDecryptionCipher(msg.encryptedContent.key);
+ break;
+
+ case forge.pki.oids['desCBC']:
+ case forge.pki.oids['des-EDE3-CBC']:
+ ciph = forge.des.createDecryptionCipher(msg.encryptedContent.key);
+ break;
+
+ default:
+ throw new Error('Unsupported symmetric cipher, OID ' +
+ msg.encryptedContent.algorithm);
+ }
+ ciph.start(msg.encryptedContent.parameter);
+ ciph.update(msg.encryptedContent.content);
+
+ if(!ciph.finish()) {
+ throw new Error('Symmetric decryption failed.');
+ }
+
+ msg.content = ciph.output;
+ }
+};
+
+p7.createSignedData = function() {
+ var msg = null;
+ msg = {
+ type: forge.pki.oids.signedData,
+ version: 1,
+ certificates: [],
+ crls: [],
+ // populated during sign()
+ digestAlgorithmIdentifiers: [],
+ contentInfo: null,
+ signerInfos: [],
+
+ fromAsn1: function(obj) {
+ // validate SignedData content block and capture data.
+ _fromAsn1(msg, obj, p7.asn1.signedDataValidator);
+ msg.certificates = [];
+ msg.crls = [];
+ msg.digestAlgorithmIdentifiers = [];
+ msg.contentInfo = null;
+ msg.signerInfos = [];
+
+ var certs = msg.rawCapture.certificates.value;
+ for(var i = 0; i < certs.length; ++i) {
+ msg.certificates.push(forge.pki.certificateFromAsn1(certs[i]));
+ }
+
+ // TODO: parse crls
+ },
+
+ toAsn1: function() {
+ // TODO: add support for more data types here
+ if('content' in msg) {
+ throw new Error('Signing PKCS#7 content not yet implemented.');
+ }
+
+ // degenerate case with no content
+ if(!msg.contentInfo) {
+ msg.sign();
+ }
+
+ var certs = [];
+ for(var i = 0; i < msg.certificates.length; ++i) {
+ certs.push(forge.pki.certificateToAsn1(msg.certificates[0]));
+ }
+
+ var crls = [];
+ // TODO: implement CRLs
+
+ // ContentInfo
+ return asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // ContentType
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(msg.type).getBytes()),
+ // [0] SignedData
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // Version
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(msg.version).getBytes()),
+ // DigestAlgorithmIdentifiers
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SET, true,
+ msg.digestAlgorithmIdentifiers),
+ // ContentInfo
+ msg.contentInfo,
+ // [0] IMPLICIT ExtendedCertificatesAndCertificates
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, certs),
+ // [1] IMPLICIT CertificateRevocationLists
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, crls),
+ // SignerInfos
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true,
+ msg.signerInfos)
+ ])
+ ])
+ ]);
+ },
+
+ /**
+ * Signs the content.
+ *
+ * @param signer the signer (or array of signers) to sign as, for each:
+ * key the private key to sign with.
+ * [md] the message digest to use, defaults to sha-1.
+ */
+ sign: function(signer) {
+ if('content' in msg) {
+ throw new Error('PKCS#7 signing not yet implemented.');
+ }
+
+ if(typeof msg.content !== 'object') {
+ // use Data ContentInfo
+ msg.contentInfo = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // ContentType
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(forge.pki.oids.data).getBytes())
+ ]);
+
+ // add actual content, if present
+ if('content' in msg) {
+ msg.contentInfo.value.push(
+ // [0] EXPLICIT content
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ msg.content)
+ ]));
+ }
+ }
+
+ // TODO: generate digest algorithm identifiers
+
+ // TODO: generate signerInfos
+ },
+
+ verify: function() {
+ throw new Error('PKCS#7 signature verification not yet implemented.');
+ },
+
+ /**
+ * Add a certificate.
+ *
+ * @param cert the certificate to add.
+ */
+ addCertificate: function(cert) {
+ // convert from PEM
+ if(typeof cert === 'string') {
+ cert = forge.pki.certificateFromPem(cert);
+ }
+ msg.certificates.push(cert);
+ },
+
+ /**
+ * Add a certificate revokation list.
+ *
+ * @param crl the certificate revokation list to add.
+ */
+ addCertificateRevokationList: function(crl) {
+ throw new Error('PKCS#7 CRL support not yet implemented.');
+ }
+ };
+ return msg;
+};
+
+/**
+ * Creates an empty PKCS#7 message of type EncryptedData.
+ *
+ * @return the message.
+ */
+p7.createEncryptedData = function() {
+ var msg = null;
+ msg = {
+ type: forge.pki.oids.encryptedData,
+ version: 0,
+ encryptedContent: {
+ algorithm: forge.pki.oids['aes256-CBC']
+ },
+
+ /**
+ * Reads an EncryptedData content block (in ASN.1 format)
+ *
+ * @param obj The ASN.1 representation of the EncryptedData content block
+ */
+ fromAsn1: function(obj) {
+ // Validate EncryptedData content block and capture data.
+ _fromAsn1(msg, obj, p7.asn1.encryptedDataValidator);
+ },
+
+ /**
+ * Decrypt encrypted content
+ *
+ * @param key The (symmetric) key as a byte buffer
+ */
+ decrypt: function(key) {
+ if(key !== undefined) {
+ msg.encryptedContent.key = key;
+ }
+ _decryptContent(msg);
+ }
+ };
+ return msg;
+};
+
+/**
+ * Creates an empty PKCS#7 message of type EnvelopedData.
+ *
+ * @return the message.
+ */
+p7.createEnvelopedData = function() {
+ var msg = null;
+ msg = {
+ type: forge.pki.oids.envelopedData,
+ version: 0,
+ recipients: [],
+ encryptedContent: {
+ algorithm: forge.pki.oids['aes256-CBC']
+ },
+
+ /**
+ * Reads an EnvelopedData content block (in ASN.1 format)
+ *
+ * @param obj the ASN.1 representation of the EnvelopedData content block.
+ */
+ fromAsn1: function(obj) {
+ // validate EnvelopedData content block and capture data
+ var capture = _fromAsn1(msg, obj, p7.asn1.envelopedDataValidator);
+ msg.recipients = _recipientInfosFromAsn1(capture.recipientInfos.value);
+ },
+
+ toAsn1: function() {
+ // ContentInfo
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // ContentType
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(msg.type).getBytes()),
+ // [0] EnvelopedData
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // Version
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(msg.version).getBytes()),
+ // RecipientInfos
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true,
+ _recipientInfosToAsn1(msg.recipients)),
+ // EncryptedContentInfo
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true,
+ _encryptedContentToAsn1(msg.encryptedContent))
+ ])
+ ])
+ ]);
+ },
+
+ /**
+ * Find recipient by X.509 certificate's issuer.
+ *
+ * @param cert the certificate with the issuer to look for.
+ *
+ * @return the recipient object.
+ */
+ findRecipient: function(cert) {
+ var sAttr = cert.issuer.attributes;
+
+ for(var i = 0; i < msg.recipients.length; ++i) {
+ var r = msg.recipients[i];
+ var rAttr = r.issuer;
+
+ if(r.serialNumber !== cert.serialNumber) {
+ continue;
+ }
+
+ if(rAttr.length !== sAttr.length) {
+ continue;
+ }
+
+ var match = true;
+ for(var j = 0; j < sAttr.length; ++j) {
+ if(rAttr[j].type !== sAttr[j].type ||
+ rAttr[j].value !== sAttr[j].value) {
+ match = false;
+ break;
+ }
+ }
+
+ if(match) {
+ return r;
+ }
+ }
+
+ return null;
+ },
+
+ /**
+ * Decrypt enveloped content
+ *
+ * @param recipient The recipient object related to the private key
+ * @param privKey The (RSA) private key object
+ */
+ decrypt: function(recipient, privKey) {
+ if(msg.encryptedContent.key === undefined && recipient !== undefined &&
+ privKey !== undefined) {
+ switch(recipient.encryptedContent.algorithm) {
+ case forge.pki.oids.rsaEncryption:
+ case forge.pki.oids.desCBC:
+ var key = privKey.decrypt(recipient.encryptedContent.content);
+ msg.encryptedContent.key = forge.util.createBuffer(key);
+ break;
+
+ default:
+ throw new Error('Unsupported asymmetric cipher, ' +
+ 'OID ' + recipient.encryptedContent.algorithm);
+ }
+ }
+
+ _decryptContent(msg);
+ },
+
+ /**
+ * Add (another) entity to list of recipients.
+ *
+ * @param cert The certificate of the entity to add.
+ */
+ addRecipient: function(cert) {
+ msg.recipients.push({
+ version: 0,
+ issuer: cert.issuer.attributes,
+ serialNumber: cert.serialNumber,
+ encryptedContent: {
+ // We simply assume rsaEncryption here, since forge.pki only
+ // supports RSA so far. If the PKI module supports other
+ // ciphers one day, we need to modify this one as well.
+ algorithm: forge.pki.oids.rsaEncryption,
+ key: cert.publicKey
+ }
+ });
+ },
+
+ /**
+ * Encrypt enveloped content.
+ *
+ * This function supports two optional arguments, cipher and key, which
+ * can be used to influence symmetric encryption. Unless cipher is
+ * provided, the cipher specified in encryptedContent.algorithm is used
+ * (defaults to AES-256-CBC). If no key is provided, encryptedContent.key
+ * is (re-)used. If that one's not set, a random key will be generated
+ * automatically.
+ *
+ * @param [key] The key to be used for symmetric encryption.
+ * @param [cipher] The OID of the symmetric cipher to use.
+ */
+ encrypt: function(key, cipher) {
+ // Part 1: Symmetric encryption
+ if(msg.encryptedContent.content === undefined) {
+ cipher = cipher || msg.encryptedContent.algorithm;
+ key = key || msg.encryptedContent.key;
+
+ var keyLen, ivLen, ciphFn;
+ switch(cipher) {
+ case forge.pki.oids['aes128-CBC']:
+ keyLen = 16;
+ ivLen = 16;
+ ciphFn = forge.aes.createEncryptionCipher;
+ break;
+
+ case forge.pki.oids['aes192-CBC']:
+ keyLen = 24;
+ ivLen = 16;
+ ciphFn = forge.aes.createEncryptionCipher;
+ break;
+
+ case forge.pki.oids['aes256-CBC']:
+ keyLen = 32;
+ ivLen = 16;
+ ciphFn = forge.aes.createEncryptionCipher;
+ break;
+
+ case forge.pki.oids['des-EDE3-CBC']:
+ keyLen = 24;
+ ivLen = 8;
+ ciphFn = forge.des.createEncryptionCipher;
+ break;
+
+ default:
+ throw new Error('Unsupported symmetric cipher, OID ' + cipher);
+ }
+
+ if(key === undefined) {
+ key = forge.util.createBuffer(forge.random.getBytes(keyLen));
+ } else if(key.length() != keyLen) {
+ throw new Error('Symmetric key has wrong length; ' +
+ 'got ' + key.length() + ' bytes, expected ' + keyLen + '.');
+ }
+
+ // Keep a copy of the key & IV in the object, so the caller can
+ // use it for whatever reason.
+ msg.encryptedContent.algorithm = cipher;
+ msg.encryptedContent.key = key;
+ msg.encryptedContent.parameter = forge.util.createBuffer(
+ forge.random.getBytes(ivLen));
+
+ var ciph = ciphFn(key);
+ ciph.start(msg.encryptedContent.parameter.copy());
+ ciph.update(msg.content);
+
+ // The finish function does PKCS#7 padding by default, therefore
+ // no action required by us.
+ if(!ciph.finish()) {
+ throw new Error('Symmetric encryption failed.');
+ }
+
+ msg.encryptedContent.content = ciph.output;
+ }
+
+ // Part 2: asymmetric encryption for each recipient
+ for(var i = 0; i < msg.recipients.length; i ++) {
+ var recipient = msg.recipients[i];
+
+ // Nothing to do, encryption already done.
+ if(recipient.encryptedContent.content !== undefined) {
+ continue;
+ }
+
+ switch(recipient.encryptedContent.algorithm) {
+ case forge.pki.oids.rsaEncryption:
+ recipient.encryptedContent.content =
+ recipient.encryptedContent.key.encrypt(
+ msg.encryptedContent.key.data);
+ break;
+
+ default:
+ throw new Error('Unsupported asymmetric cipher, OID ' +
+ recipient.encryptedContent.algorithm);
+ }
+ }
+ }
+ };
+ return msg;
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'pkcs7';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define([
+ 'require',
+ 'module',
+ './aes',
+ './asn1',
+ './des',
+ './oids',
+ './pem',
+ './pkcs7asn1',
+ './random',
+ './util',
+ './x509'
+], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs7asn1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs7asn1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs7asn1.js
new file mode 100644
index 0000000..f7c4df6
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/pkcs7asn1.js
@@ -0,0 +1,399 @@
+/**
+ * Javascript implementation of PKCS#7 v1.5. Currently only certain parts of
+ * PKCS#7 are implemented, especially the enveloped-data content type.
+ *
+ * @author Stefan Siegl
+ *
+ * Copyright (c) 2012 Stefan Siegl <st...@brokenpipe.de>
+ *
+ * The ASN.1 representation of PKCS#7 is as follows
+ * (see RFC #2315 for details, http://www.ietf.org/rfc/rfc2315.txt):
+ *
+ * A PKCS#7 message consists of a ContentInfo on root level, which may
+ * contain any number of further ContentInfo nested into it.
+ *
+ * ContentInfo ::= SEQUENCE {
+ * contentType ContentType,
+ * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
+ * }
+ *
+ * ContentType ::= OBJECT IDENTIFIER
+ *
+ * EnvelopedData ::= SEQUENCE {
+ * version Version,
+ * recipientInfos RecipientInfos,
+ * encryptedContentInfo EncryptedContentInfo
+ * }
+ *
+ * EncryptedData ::= SEQUENCE {
+ * version Version,
+ * encryptedContentInfo EncryptedContentInfo
+ * }
+ *
+ * Version ::= INTEGER
+ *
+ * RecipientInfos ::= SET OF RecipientInfo
+ *
+ * EncryptedContentInfo ::= SEQUENCE {
+ * contentType ContentType,
+ * contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
+ * encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL
+ * }
+ *
+ * ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters
+ * for the algorithm, if any. In the case of AES and DES3, there is only one,
+ * the IV.
+ *
+ * AlgorithmIdentifer ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL
+ * }
+ *
+ * EncryptedContent ::= OCTET STRING
+ *
+ * RecipientInfo ::= SEQUENCE {
+ * version Version,
+ * issuerAndSerialNumber IssuerAndSerialNumber,
+ * keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,
+ * encryptedKey EncryptedKey
+ * }
+ *
+ * IssuerAndSerialNumber ::= SEQUENCE {
+ * issuer Name,
+ * serialNumber CertificateSerialNumber
+ * }
+ *
+ * CertificateSerialNumber ::= INTEGER
+ *
+ * KeyEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * EncryptedKey ::= OCTET STRING
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// shortcut for ASN.1 API
+var asn1 = forge.asn1;
+
+// shortcut for PKCS#7 API
+var p7v = forge.pkcs7asn1 = forge.pkcs7asn1 || {};
+forge.pkcs7 = forge.pkcs7 || {};
+forge.pkcs7.asn1 = p7v;
+
+var contentInfoValidator = {
+ name: 'ContentInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'ContentInfo.ContentType',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'contentType'
+ }, {
+ name: 'ContentInfo.content',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 0,
+ constructed: true,
+ optional: true,
+ captureAsn1: 'content'
+ }]
+};
+p7v.contentInfoValidator = contentInfoValidator;
+
+var encryptedContentInfoValidator = {
+ name: 'EncryptedContentInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'EncryptedContentInfo.contentType',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'contentType'
+ }, {
+ name: 'EncryptedContentInfo.contentEncryptionAlgorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'EncryptedContentInfo.contentEncryptionAlgorithm.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'encAlgorithm'
+ }, {
+ name: 'EncryptedContentInfo.contentEncryptionAlgorithm.parameter',
+ tagClass: asn1.Class.UNIVERSAL,
+ captureAsn1: 'encParameter'
+ }]
+ }, {
+ name: 'EncryptedContentInfo.encryptedContent',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 0,
+ /* The PKCS#7 structure output by OpenSSL somewhat differs from what
+ * other implementations do generate.
+ *
+ * OpenSSL generates a structure like this:
+ * SEQUENCE {
+ * ...
+ * [0]
+ * 26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38
+ * C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45
+ * ...
+ * }
+ *
+ * Whereas other implementations (and this PKCS#7 module) generate:
+ * SEQUENCE {
+ * ...
+ * [0] {
+ * OCTET STRING
+ * 26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38
+ * C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45
+ * ...
+ * }
+ * }
+ *
+ * In order to support both, we just capture the context specific
+ * field here. The OCTET STRING bit is removed below.
+ */
+ capture: 'encryptedContent',
+ captureAsn1: 'encryptedContentAsn1'
+ }]
+};
+
+p7v.envelopedDataValidator = {
+ name: 'EnvelopedData',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'EnvelopedData.Version',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'version'
+ }, {
+ name: 'EnvelopedData.RecipientInfos',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SET,
+ constructed: true,
+ captureAsn1: 'recipientInfos'
+ }].concat(encryptedContentInfoValidator)
+};
+
+p7v.encryptedDataValidator = {
+ name: 'EncryptedData',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'EncryptedData.Version',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'version'
+ }].concat(encryptedContentInfoValidator)
+};
+
+var signerValidator = {
+ name: 'SignerInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'SignerInfo.Version',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false
+ }, {
+ name: 'SignerInfo.IssuerAndSerialNumber',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true
+ }, {
+ name: 'SignerInfo.DigestAlgorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true
+ }, {
+ name: 'SignerInfo.AuthenticatedAttributes',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 0,
+ constructed: true,
+ optional: true,
+ capture: 'authenticatedAttributes'
+ }, {
+ name: 'SignerInfo.DigestEncryptionAlgorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true
+ }, {
+ name: 'SignerInfo.EncryptedDigest',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ constructed: false,
+ capture: 'signature'
+ }, {
+ name: 'SignerInfo.UnauthenticatedAttributes',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 1,
+ constructed: true,
+ optional: true
+ }]
+};
+
+p7v.signedDataValidator = {
+ name: 'SignedData',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'SignedData.Version',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'version'
+ }, {
+ name: 'SignedData.DigestAlgorithms',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SET,
+ constructed: true,
+ captureAsn1: 'digestAlgorithms'
+ },
+ contentInfoValidator,
+ {
+ name: 'SignedData.Certificates',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 0,
+ optional: true,
+ captureAsn1: 'certificates'
+ }, {
+ name: 'SignedData.CertificateRevocationLists',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 1,
+ optional: true,
+ captureAsn1: 'crls'
+ }, {
+ name: 'SignedData.SignerInfos',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SET,
+ capture: 'signerInfos',
+ optional: true,
+ value: [signerValidator]
+ }]
+};
+
+p7v.recipientInfoValidator = {
+ name: 'RecipientInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'RecipientInfo.version',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'version'
+ }, {
+ name: 'RecipientInfo.issuerAndSerial',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'RecipientInfo.issuerAndSerial.issuer',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'issuer'
+ }, {
+ name: 'RecipientInfo.issuerAndSerial.serialNumber',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'serial'
+ }]
+ }, {
+ name: 'RecipientInfo.keyEncryptionAlgorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'RecipientInfo.keyEncryptionAlgorithm.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'encAlgorithm'
+ }, {
+ name: 'RecipientInfo.keyEncryptionAlgorithm.parameter',
+ tagClass: asn1.Class.UNIVERSAL,
+ constructed: false,
+ captureAsn1: 'encParameter'
+ }]
+ }, {
+ name: 'RecipientInfo.encryptedKey',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ constructed: false,
+ capture: 'encKey'
+ }]
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'pkcs7asn1';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './asn1', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[39/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/doctest.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/doctest.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/doctest.js
new file mode 100644
index 0000000..0cfb7eb
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/js/doctest.js
@@ -0,0 +1,1397 @@
+/*
+
+Javascript doctest runner
+Copyright 2006-2010 Ian Bicking
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the MIT License.
+
+*/
+
+
+function doctest(verbosity/*default=0*/, elements/*optional*/,
+ outputId/*optional*/) {
+ var output = document.getElementById(outputId || 'doctestOutput');
+ var reporter = new doctest.Reporter(output, verbosity || 0);
+ if (elements) {
+ if (typeof elements == 'string') {
+ // Treat it as an id
+ elements = [document.getElementById(elementId)];
+ }
+ if (! elements.length) {
+ throw('No elements');
+ }
+ var suite = new doctest.TestSuite(elements, reporter);
+ } else {
+ var els = doctest.getElementsByTagAndClassName('pre', 'doctest');
+ var suite = new doctest.TestSuite(els, reporter);
+ }
+ suite.run();
+}
+
+doctest.runDoctest = function (el, reporter) {
+ logDebug('Testing element', el);
+ reporter.startElement(el);
+ if (el === null) {
+ throw('runDoctest() with a null element');
+ }
+ var parsed = new doctest.Parser(el);
+ var runner = new doctest.JSRunner(reporter);
+ runner.runParsed(parsed);
+};
+
+doctest.TestSuite = function (els, reporter) {
+ if (this === window) {
+ throw('you forgot new!');
+ }
+ this.els = els;
+ this.parsers = [];
+ for (var i=0; i<els.length; i++) {
+ this.parsers.push(new doctest.Parser(els[i]));
+ }
+ this.reporter = reporter;
+};
+
+doctest.TestSuite.prototype.run = function (ctx) {
+ if (! ctx) {
+ ctx = new doctest.Context(this);
+ }
+ if (! ctx.runner ) {
+ ctx.runner = new doctest.JSRunner(this.reporter);
+ }
+ return ctx.run();
+};
+
+// FIXME: should this just be part of TestSuite?
+doctest.Context = function (testSuite) {
+ if (this === window) {
+ throw('You forgot new!');
+ }
+ this.testSuite = testSuite;
+ this.runner = null;
+};
+
+doctest.Context.prototype.run = function (parserIndex) {
+ var self = this;
+ parserIndex = parserIndex || 0;
+ if (parserIndex >= this.testSuite.parsers.length) {
+ logInfo('All examples from all sections tested');
+ this.runner.reporter.finish();
+ return;
+ }
+ logInfo('Testing example ' + (parserIndex+1) + ' of '
+ + this.testSuite.parsers.length);
+ var runNext = function () {
+ self.run(parserIndex+1);
+ };
+ this.runner.runParsed(this.testSuite.parsers[parserIndex], 0, runNext);
+};
+
+doctest.Parser = function (el) {
+ if (this === window) {
+ throw('you forgot new!');
+ }
+ if (! el) {
+ throw('Bad call to doctest.Parser');
+ }
+ if (el.getAttribute('parsed-id')) {
+ var examplesID = el.getAttribute('parsed-id');
+ if (doctest._allExamples[examplesID]) {
+ this.examples = doctest._allExamples[examplesID];
+ return;
+ }
+ }
+ var newHTML = document.createElement('span');
+ newHTML.className = 'doctest-example-set';
+ var examplesID = doctest.genID('example-set');
+ newHTML.setAttribute('id', examplesID);
+ el.setAttribute('parsed-id', examplesID);
+ var text = doctest.getText(el);
+ var lines = text.split(/(?:\r\n|\r|\n)/);
+ this.examples = [];
+ var example_lines = [];
+ var output_lines = [];
+ for (var i=0; i<lines.length; i++) {
+ var line = lines[i];
+ if (/^[$]/.test(line)) {
+ if (example_lines.length) {
+ var ex = new doctest.Example(example_lines, output_lines);
+ this.examples.push(ex);
+ newHTML.appendChild(ex.createSpan());
+ }
+ example_lines = [];
+ output_lines = [];
+ line = line.substr(1).replace(/ *$/, '').replace(/^ /, '');
+ example_lines.push(line);
+ } else if (/^>/.test(line)) {
+ if (! example_lines.length) {
+ throw('Bad example: '+doctest.repr(line)+'\n'
+ +'> line not preceded by $');
+ }
+ line = line.substr(1).replace(/ *$/, '').replace(/^ /, '');
+ example_lines.push(line);
+ } else {
+ output_lines.push(line);
+ }
+ }
+ if (example_lines.length) {
+ var ex = new doctest.Example(example_lines, output_lines);
+ this.examples.push(ex);
+ newHTML.appendChild(ex.createSpan());
+ }
+ el.innerHTML = '';
+ el.appendChild(newHTML);
+ doctest._allExamples[examplesID] = this.examples;
+};
+
+doctest._allExamples = {};
+
+doctest.Example = function (example, output) {
+ if (this === window) {
+ throw('you forgot new!');
+ }
+ this.example = example.join('\n');
+ this.output = output.join('\n');
+ this.htmlID = null;
+ this.detailID = null;
+};
+
+doctest.Example.prototype.createSpan = function () {
+ var id = doctest.genID('example');
+ var span = document.createElement('span');
+ span.className = 'doctest-example';
+ span.setAttribute('id', id);
+ this.htmlID = id;
+ var exampleSpan = document.createElement('span');
+ exampleSpan.className = 'doctest-example-code';
+ var exampleLines = this.example.split(/\n/);
+ for (var i=0; i<exampleLines.length; i++) {
+ var promptSpan = document.createElement('span');
+ promptSpan.className = 'doctest-example-prompt';
+ promptSpan.innerHTML = i == 0 ? '$ ' : '> ';
+ exampleSpan.appendChild(promptSpan);
+ var lineSpan = document.createElement('span');
+ lineSpan.className = 'doctest-example-code-line';
+ lineSpan.appendChild(document.createTextNode(doctest.rstrip(exampleLines[i])));
+ exampleSpan.appendChild(lineSpan);
+ exampleSpan.appendChild(document.createTextNode('\n'));
+ }
+ span.appendChild(exampleSpan);
+ var outputSpan = document.createElement('span');
+ outputSpan.className = 'doctest-example-output';
+ outputSpan.appendChild(document.createTextNode(this.output));
+ span.appendChild(outputSpan);
+ span.appendChild(document.createTextNode('\n'));
+ return span;
+};
+
+doctest.Example.prototype.markExample = function (name, detail) {
+ if (! this.htmlID) {
+ return;
+ }
+ if (this.detailID) {
+ var el = document.getElementById(this.detailID);
+ el.parentNode.removeChild(el);
+ this.detailID = null;
+ }
+ var span = document.getElementById(this.htmlID);
+ span.className = span.className.replace(/ doctest-failure/, '')
+ .replace(/ doctest-success/, '')
+ + ' ' + name;
+ if (detail) {
+ this.detailID = doctest.genID('doctest-example-detail');
+ var detailSpan = document.createElement('span');
+ detailSpan.className = 'doctest-example-detail';
+ detailSpan.setAttribute('id', this.detailID);
+ detailSpan.appendChild(document.createTextNode(detail));
+ span.appendChild(detailSpan);
+ }
+};
+
+doctest.Reporter = function (container, verbosity) {
+ if (this === window) {
+ throw('you forgot new!');
+ }
+ if (! container) {
+ throw('No container passed to doctest.Reporter');
+ }
+ this.container = container;
+ this.verbosity = verbosity;
+ this.success = 0;
+ this.failure = 0;
+ this.elements = 0;
+};
+
+doctest.Reporter.prototype.startElement = function (el) {
+ this.elements += 1;
+ logDebug('Adding element', el);
+};
+
+doctest.Reporter.prototype.reportSuccess = function (example, output) {
+ if (this.verbosity > 0) {
+ if (this.verbosity > 1) {
+ this.write('Trying:\n');
+ this.write(this.formatOutput(example.example));
+ this.write('Expecting:\n');
+ this.write(this.formatOutput(example.output));
+ this.write('ok\n');
+ } else {
+ this.writeln(example.example + ' ... passed!');
+ }
+ }
+ this.success += 1;
+ if ((example.output.indexOf('...') >= 0
+ || example.output.indexOf('?') >= 0)
+ && output) {
+ example.markExample('doctest-success', 'Output:\n' + output);
+ } else {
+ example.markExample('doctest-success');
+ }
+};
+
+doctest.Reporter.prototype.reportFailure = function (example, output) {
+ this.write('Failed example:\n');
+ this.write('<span style="color: #00f"><a href="#'
+ + example.htmlID
+ + '" class="doctest-failure-link" title="Go to example">'
+ + this.formatOutput(example.example)
+ +'</a></span>');
+ this.write('Expected:\n');
+ this.write(this.formatOutput(example.output));
+ this.write('Got:\n');
+ this.write(this.formatOutput(output));
+ this.failure += 1;
+ example.markExample('doctest-failure', 'Actual output:\n' + output);
+};
+
+doctest.Reporter.prototype.finish = function () {
+ this.writeln((this.success+this.failure)
+ + ' tests in ' + this.elements + ' items.');
+ if (this.failure) {
+ var color = '#f00';
+ } else {
+ var color = '#0f0';
+ }
+ this.writeln('<span class="passed">' + this.success + '</span> tests of '
+ + '<span class="total">' + (this.success+this.failure) + '</span> passed, '
+ + '<span class="failed" style="color: '+color+'">'
+ + this.failure + '</span> failed.');
+};
+
+doctest.Reporter.prototype.writeln = function (text) {
+ this.write(text + '\n');
+};
+
+doctest.Reporter.prototype.write = function (text) {
+ var leading = /^[ ]*/.exec(text)[0];
+ text = text.substr(leading.length);
+ for (var i=0; i<leading.length; i++) {
+ text = String.fromCharCode(160)+text;
+ }
+ text = text.replace(/\n/g, '<br>');
+ this.container.innerHTML += text;
+};
+
+doctest.Reporter.prototype.formatOutput = function (text) {
+ if (! text) {
+ return ' <span style="color: #999">(nothing)</span>\n';
+ }
+ var lines = text.split(/\n/);
+ var output = '';
+ for (var i=0; i<lines.length; i++) {
+ output += ' '+doctest.escapeSpaces(doctest.escapeHTML(lines[i]))+'\n';
+ }
+ return output;
+};
+
+doctest.JSRunner = function (reporter) {
+ if (this === window) {
+ throw('you forgot new!');
+ }
+ this.reporter = reporter;
+};
+
+doctest.JSRunner.prototype.runParsed = function (parsed, index, finishedCallback) {
+ var self = this;
+ index = index || 0;
+ if (index >= parsed.examples.length) {
+ if (finishedCallback) {
+ finishedCallback();
+ }
+ return;
+ }
+ var example = parsed.examples[index];
+ if (typeof example == 'undefined') {
+ throw('Undefined example (' + (index+1) + ' of ' + parsed.examples.length + ')');
+ }
+ doctest._waitCond = null;
+ this.run(example);
+ var finishThisRun = function () {
+ self.finishRun(example);
+ if (doctest._AbortCalled) {
+ // FIXME: I need to find a way to make this more visible:
+ logWarn('Abort() called');
+ return;
+ }
+ self.runParsed(parsed, index+1, finishedCallback);
+ };
+ if (doctest._waitCond !== null) {
+ if (typeof doctest._waitCond == 'number') {
+ var condition = null;
+ var time = doctest._waitCond;
+ var maxTime = null;
+ } else {
+ var condition = doctest._waitCond;
+ // FIXME: shouldn't be hard-coded
+ var time = 100;
+ var maxTime = doctest._waitTimeout || doctest.defaultTimeout;
+ }
+ var start = (new Date()).getTime();
+ var timeoutFunc = function () {
+ if (condition === null
+ || condition()) {
+ finishThisRun();
+ } else {
+ // Condition not met, try again soon...
+ if ((new Date()).getTime() - start > maxTime) {
+ // Time has run out
+ var msg = 'Error: wait(' + repr(condition) + ') has timed out';
+ writeln(msg);
+ logDebug(msg);
+ logDebug('Timeout after ' + ((new Date()).getTime() - start)
+ + ' milliseconds');
+ finishThisRun();
+ return;
+ }
+ setTimeout(timeoutFunc, time);
+ }
+ };
+ setTimeout(timeoutFunc, time);
+ } else {
+ finishThisRun();
+ }
+};
+
+doctest.formatTraceback = function (e, skipFrames) {
+ skipFrames = skipFrames || 0;
+ var lines = [];
+ if (typeof e == 'undefined' || !e) {
+ var caughtErr = null;
+ try {
+ (null).foo;
+ } catch (caughtErr) {
+ e = caughtErr;
+ }
+ skipFrames++;
+ }
+ if (e.stack) {
+ var stack = e.stack.split('\n');
+ for (var i=skipFrames; i<stack.length; i++) {
+ if (stack[i] == '@:0' || ! stack[i]) {
+ continue;
+ }
+ if (stack[i].indexOf('@') == -1) {
+ lines.push(stack[i]);
+ continue;
+ }
+ var parts = stack[i].split('@');
+ var context = parts[0];
+ parts = parts[1].split(':');
+ var filename = parts[parts.length-2].split('/');
+ filename = filename[filename.length-1];
+ var lineno = parts[parts.length-1];
+ context = context.replace('\\n', '\n');
+ if (context != '' && filename != 'doctest.js') {
+ lines.push(' ' + context + ' -> ' + filename + ':' + lineno);
+ }
+ }
+ }
+ if (lines.length) {
+ return lines;
+ } else {
+ return null;
+ }
+};
+
+doctest.logTraceback = function (e, skipFrames) {
+ var tracebackLines = doctest.formatTraceback(e, skipFrames);
+ if (! tracebackLines) {
+ return;
+ }
+ for (var i=0; i<tracebackLines.length; i++) {
+ logDebug(tracebackLines[i]);
+ }
+};
+
+doctest.JSRunner.prototype.run = function (example) {
+ this.capturer = new doctest.OutputCapturer();
+ this.capturer.capture();
+ try {
+ var result = doctest.eval(example.example);
+ } catch (e) {
+ var tracebackLines = doctest.formatTraceback(e);
+ writeln('Error: ' + (e.message || e));
+ var result = null;
+ logWarn('Error in expression: ' + example.example);
+ logDebug('Traceback for error', e);
+ if (tracebackLines) {
+ for (var i=0; i<tracebackLines.length; i++) {
+ logDebug(tracebackLines[i]);
+ }
+ }
+ if (e instanceof Abort) {
+ throw e;
+ }
+ }
+ if (typeof result != 'undefined'
+ && result !== null
+ && example.output) {
+ writeln(doctest.repr(result));
+ }
+};
+
+doctest._AbortCalled = false;
+
+doctest.Abort = function (message) {
+ if (this === window) {
+ return new Abort(message);
+ }
+ this.message = message;
+ // We register this so Abort can be raised in an async call:
+ doctest._AbortCalled = true;
+};
+
+doctest.Abort.prototype.toString = function () {
+ return this.message;
+};
+
+if (typeof Abort == 'undefined') {
+ Abort = doctest.Abort;
+}
+
+doctest.JSRunner.prototype.finishRun = function(example) {
+ this.capturer.stopCapture();
+ var success = this.checkResult(this.capturer.output, example.output);
+ if (success) {
+ this.reporter.reportSuccess(example, this.capturer.output);
+ } else {
+ this.reporter.reportFailure(example, this.capturer.output);
+ logDebug('Failure: '+doctest.repr(example.output)
+ +' != '+doctest.repr(this.capturer.output));
+ if (location.href.search(/abort/) != -1) {
+ doctest.Abort('abort on first failure');
+ }
+ }
+};
+
+doctest.JSRunner.prototype.checkResult = function (got, expected) {
+ // Make sure trailing whitespace doesn't matter:
+ got = got.replace(/ +\n/, '\n');
+ expected = expected.replace(/ +\n/, '\n');
+ got = got.replace(/[ \n\r]*$/, '') + '\n';
+ expected = expected.replace(/[ \n\r]*$/, '') + '\n';
+ if (expected == '...\n') {
+ return true;
+ }
+ expected = RegExp.escape(expected);
+ // Note: .* doesn't match newlines, [^] doesn't work on IE
+ expected = '^' + expected.replace(/\\\.\\\.\\\./g, "[\\S\\s\\r\\n]*") + '$';
+ expected = expected.replace(/\\\?/g, "[a-zA-Z0-9_.]+");
+ expected = expected.replace(/[ \t]+/g, " +");
+ expected = expected.replace(/\n/g, '\\n');
+ var re = new RegExp(expected);
+ var result = got.search(re) != -1;
+ if (! result) {
+ if (doctest.strip(got).split('\n').length > 1) {
+ // If it's only one line it's not worth showing this
+ var check = this.showCheckDifference(got, expected);
+ logWarn('Mismatch of output (line-by-line comparison follows)');
+ for (var i=0; i<check.length; i++) {
+ logDebug(check[i]);
+ }
+ }
+ }
+ return result;
+};
+
+doctest.JSRunner.prototype.showCheckDifference = function (got, expectedRegex) {
+ if (expectedRegex.charAt(0) != '^') {
+ throw 'Unexpected regex, no leading ^';
+ }
+ if (expectedRegex.charAt(expectedRegex.length-1) != '$') {
+ throw 'Unexpected regex, no trailing $';
+ }
+ expectedRegex = expectedRegex.substr(1, expectedRegex.length-2);
+ // Technically this might not be right, but this is all a heuristic:
+ var expectedRegex = expectedRegex.replace(/\(\?:\.\|\[\\r\\n\]\)\*/g, '...');
+ var expectedLines = expectedRegex.split('\\n');
+ for (var i=0; i<expectedLines.length; i++) {
+ expectedLines[i] = expectedLines[i].replace(/\.\.\./g, '(?:.|[\r\n])*');
+ }
+ var gotLines = got.split('\n');
+ var result = [];
+ var totalLines = expectedLines.length > gotLines.length ?
+ expectedLines.length : gotLines.length;
+ function displayExpectedLine(line) {
+ return line;
+ line = line.replace(/\[a-zA-Z0-9_.\]\+/g, '?');
+ line = line.replace(/ \+/g, ' ');
+ line = line.replace(/\(\?:\.\|\[\\r\\n\]\)\*/g, '...');
+ // FIXME: also unescape values? e.g., * became \*
+ return line;
+ }
+ for (var i=0; i<totalLines; i++) {
+ if (i >= expectedLines.length) {
+ result.push('got extra line: ' + repr(gotLines[i]));
+ continue;
+ } else if (i >= gotLines.length) {
+ result.push('expected extra line: ' + displayExpectedLine(expectedLines[i]));
+ continue;
+ }
+ var gotLine = gotLines[i];
+ try {
+ var expectRE = new RegExp('^' + expectedLines[i] + '$');
+ } catch (e) {
+ result.push('regex match failed: ' + repr(gotLine) + ' ('
+ + expectedLines[i] + ')');
+ continue;
+ }
+ if (gotLine.search(expectRE) != -1) {
+ result.push('match: ' + repr(gotLine));
+ } else {
+ result.push('no match: ' + repr(gotLine) + ' ('
+ + displayExpectedLine(expectedLines[i]) + ')');
+ }
+ }
+ return result;
+};
+
+// Should I really be setting this on RegExp?
+RegExp.escape = function (text) {
+ if (!arguments.callee.sRE) {
+ var specials = [
+ '/', '.', '*', '+', '?', '|',
+ '(', ')', '[', ']', '{', '}', '\\'
+ ];
+ arguments.callee.sRE = new RegExp(
+ '(\\' + specials.join('|\\') + ')', 'g'
+ );
+ }
+ return text.replace(arguments.callee.sRE, '\\$1');
+};
+
+doctest.OutputCapturer = function () {
+ if (this === window) {
+ throw('you forgot new!');
+ }
+ this.output = '';
+};
+
+doctest._output = null;
+
+doctest.OutputCapturer.prototype.capture = function () {
+ doctest._output = this;
+};
+
+doctest.OutputCapturer.prototype.stopCapture = function () {
+ doctest._output = null;
+};
+
+doctest.OutputCapturer.prototype.write = function (text) {
+ if (typeof text == 'string') {
+ this.output += text;
+ } else {
+ this.output += repr(text);
+ }
+};
+
+// Used to create unique IDs:
+doctest._idGen = 0;
+
+doctest.genID = function (prefix) {
+ prefix = prefix || 'generic-doctest';
+ var id = doctest._idGen++;
+ return prefix + '-' + doctest._idGen;
+};
+
+doctest.writeln = function () {
+ for (var i=0; i<arguments.length; i++) {
+ write(arguments[i]);
+ if (i) {
+ write(' ');
+ }
+ }
+ write('\n');
+};
+
+if (typeof writeln == 'undefined') {
+ writeln = doctest.writeln;
+}
+
+doctest.write = function (text) {
+ if (doctest._output !== null) {
+ doctest._output.write(text);
+ } else {
+ log(text);
+ }
+};
+
+if (typeof write == 'undefined') {
+ write = doctest.write;
+}
+
+doctest._waitCond = null;
+
+function wait(conditionOrTime, hardTimeout) {
+ // FIXME: should support a timeout even with a condition
+ if (typeof conditionOrTime == 'undefined'
+ || conditionOrTime === null) {
+ // same as wait-some-small-amount-of-time
+ conditionOrTime = 0;
+ }
+ doctest._waitCond = conditionOrTime;
+ doctest._waitTimeout = hardTimeout;
+};
+
+doctest.wait = wait;
+
+doctest.assert = function (expr, statement) {
+ if (typeof expr == 'string') {
+ if (! statement) {
+ statement = expr;
+ }
+ expr = doctest.eval(expr);
+ }
+ if (! expr) {
+ throw('AssertionError: '+statement);
+ }
+};
+
+if (typeof assert == 'undefined') {
+ assert = doctest.assert;
+}
+
+doctest.getText = function (el) {
+ if (! el) {
+ throw('You must pass in an element');
+ }
+ var text = '';
+ for (var i=0; i<el.childNodes.length; i++) {
+ var sub = el.childNodes[i];
+ if (sub.nodeType == 3) {
+ // TEXT_NODE
+ text += sub.nodeValue;
+ } else if (sub.childNodes) {
+ text += doctest.getText(sub);
+ }
+ }
+ return text;
+};
+
+doctest.reload = function (button/*optional*/) {
+ if (button) {
+ button.innerHTML = 'reloading...';
+ button.disabled = true;
+ }
+ location.reload();
+};
+
+/* Taken from MochiKit, with an addition to print objects */
+doctest.repr = function (o, indentString, maxLen) {
+ indentString = indentString || '';
+ if (doctest._reprTracker === null) {
+ var iAmTheTop = true;
+ doctest._reprTracker = [];
+ } else {
+ var iAmTheTop = false;
+ }
+ try {
+ if (doctest._reprTrackObj(o)) {
+ return '..recursive..';
+ }
+ if (maxLen === undefined) {
+ maxLen = 120;
+ }
+ if (typeof o == 'undefined') {
+ return 'undefined';
+ } else if (o === null) {
+ return "null";
+ }
+ try {
+ if (typeof(o.__repr__) == 'function') {
+ return o.__repr__(indentString, maxLen);
+ } else if (typeof(o.repr) == 'function' && o.repr != arguments.callee) {
+ return o.repr(indentString, maxLen);
+ }
+ for (var i=0; i<doctest.repr.registry.length; i++) {
+ var item = doctest.repr.registry[i];
+ if (item[0](o)) {
+ return item[1](o, indentString, maxLen);
+ }
+ }
+ } catch (e) {
+ if (typeof(o.NAME) == 'string' && (
+ o.toString == Function.prototype.toString ||
+ o.toString == Object.prototype.toString)) {
+ return o.NAME;
+ }
+ }
+ try {
+ var ostring = (o + "");
+ if (ostring == '[object Object]' || ostring == '[object]') {
+ ostring = doctest.objRepr(o, indentString, maxLen);
+ }
+ } catch (e) {
+ return "[" + typeof(o) + "]";
+ }
+ if (typeof(o) == "function") {
+ var ostring = ostring.replace(/^\s+/, "").replace(/\s+/g, " ");
+ var idx = ostring.indexOf("{");
+ if (idx != -1) {
+ ostring = ostring.substr(o, idx) + "{...}";
+ }
+ }
+ return ostring;
+ } finally {
+ if (iAmTheTop) {
+ doctest._reprTracker = null;
+ }
+ }
+};
+
+doctest._reprTracker = null;
+
+doctest._reprTrackObj = function (obj) {
+ if (typeof obj != 'object') {
+ return false;
+ }
+ for (var i=0; i<doctest._reprTracker.length; i++) {
+ if (doctest._reprTracker[i] === obj) {
+ return true;
+ }
+ }
+ doctest._reprTracker.push(obj);
+ return false;
+};
+
+doctest._reprTrackSave = function () {
+ return doctest._reprTracker.length-1;
+};
+
+doctest._reprTrackRestore = function (point) {
+ doctest._reprTracker.splice(point, doctest._reprTracker.length - point);
+};
+
+doctest._sortedKeys = function (obj) {
+ var keys = [];
+ for (var i in obj) {
+ // FIXME: should I use hasOwnProperty?
+ if (typeof obj.prototype == 'undefined'
+ || obj[i] !== obj.prototype[i]) {
+ keys.push(i);
+ }
+ }
+ keys.sort();
+ return keys;
+};
+
+doctest.objRepr = function (obj, indentString, maxLen) {
+ var restorer = doctest._reprTrackSave();
+ var ostring = '{';
+ var keys = doctest._sortedKeys(obj);
+ for (var i=0; i<keys.length; i++) {
+ if (ostring != '{') {
+ ostring += ', ';
+ }
+ ostring += keys[i] + ': ' + doctest.repr(obj[keys[i]], indentString, maxLen);
+ }
+ ostring += '}';
+ if (ostring.length > (maxLen - indentString.length)) {
+ doctest._reprTrackRestore(restorer);
+ return doctest.multilineObjRepr(obj, indentString, maxLen);
+ }
+ return ostring;
+};
+
+doctest.multilineObjRepr = function (obj, indentString, maxLen) {
+ var keys = doctest._sortedKeys(obj);
+ var ostring = '{\n';
+ for (var i=0; i<keys.length; i++) {
+ ostring += indentString + ' ' + keys[i] + ': ';
+ ostring += doctest.repr(obj[keys[i]], indentString+' ', maxLen);
+ if (i != keys.length - 1) {
+ ostring += ',';
+ }
+ ostring += '\n';
+ }
+ ostring += indentString + '}';
+ return ostring;
+};
+
+doctest.arrayRepr = function (obj, indentString, maxLen) {
+ var restorer = doctest._reprTrackSave();
+ var s = "[";
+ for (var i=0; i<obj.length; i++) {
+ s += doctest.repr(obj[i], indentString, maxLen);
+ if (i != obj.length-1) {
+ s += ", ";
+ }
+ }
+ s += "]";
+ if (s.length > (maxLen + indentString.length)) {
+ doctest._reprTrackRestore(restorer);
+ return doctest.multilineArrayRepr(obj, indentString, maxLen);
+ }
+ return s;
+};
+
+doctest.multilineArrayRepr = function (obj, indentString, maxLen) {
+ var s = "[\n";
+ for (var i=0; i<obj.length; i++) {
+ s += indentString + ' ' + doctest.repr(obj[i], indentString+' ', maxLen);
+ if (i != obj.length - 1) {
+ s += ',';
+ }
+ s += '\n';
+ }
+ s += indentString + ']';
+ return s;
+};
+
+doctest.xmlRepr = function (doc, indentString) {
+ var i;
+ if (doc.nodeType == doc.DOCUMENT_NODE) {
+ return doctest.xmlRepr(doc.childNodes[0], indentString);
+ }
+ indentString = indentString || '';
+ var s = indentString + '<' + doc.tagName;
+ var attrs = [];
+ if (doc.attributes && doc.attributes.length) {
+ for (i=0; i<doc.attributes.length; i++) {
+ attrs.push(doc.attributes[i].nodeName);
+ }
+ attrs.sort();
+ for (i=0; i<attrs.length; i++) {
+ s += ' ' + attrs[i] + '="';
+ var value = doc.getAttribute(attrs[i]);
+ value = value.replace('&', '&');
+ value = value.replace('"', '"');
+ s += value;
+ s += '"';
+ }
+ }
+ if (! doc.childNodes.length) {
+ s += ' />';
+ return s;
+ } else {
+ s += '>';
+ }
+ var hasNewline = false;
+ for (i=0; i<doc.childNodes.length; i++) {
+ var el = doc.childNodes[i];
+ if (el.nodeType == doc.TEXT_NODE) {
+ s += doctest.strip(el.textContent);
+ } else {
+ if (! hasNewline) {
+ s += '\n';
+ hasNewline = true;
+ }
+ s += doctest.xmlRepr(el, indentString + ' ');
+ s += '\n';
+ }
+ }
+ if (hasNewline) {
+ s += indentString;
+ }
+ s += '</' + doc.tagName + '>';
+ return s;
+};
+
+doctest.repr.registry = [
+ [function (o) {
+ return typeof o == 'string';},
+ function (o) {
+ o = '"' + o.replace(/([\"\\])/g, '\\$1') + '"';
+ o = o.replace(/[\f]/g, "\\f")
+ .replace(/[\b]/g, "\\b")
+ .replace(/[\n]/g, "\\n")
+ .replace(/[\t]/g, "\\t")
+ .replace(/[\r]/g, "\\r");
+ return o;
+ }],
+ [function (o) {
+ return typeof o == 'number';},
+ function (o) {
+ return o + "";
+ }],
+ [function (o) {
+ return (typeof o == 'object' && o.xmlVersion);
+ },
+ doctest.xmlRepr],
+ [function (o) {
+ var typ = typeof o;
+ if ((typ != 'object' && ! (type == 'function' && typeof o.item == 'function')) ||
+ o === null ||
+ typeof o.length != 'number' ||
+ o.nodeType === 3) {
+ return false;
+ }
+ return true;
+ },
+ doctest.arrayRepr
+ ]];
+
+doctest.objDiff = function (orig, current) {
+ var result = {
+ added: {},
+ removed: {},
+ changed: {},
+ same: {}
+ };
+ for (var i in orig) {
+ if (! (i in current)) {
+ result.removed[i] = orig[i];
+ } else if (orig[i] !== current[i]) {
+ result.changed[i] = [orig[i], current[i]];
+ } else {
+ result.same[i] = orig[i];
+ }
+ }
+ for (i in current) {
+ if (! (i in orig)) {
+ result.added[i] = current[i];
+ }
+ }
+ return result;
+};
+
+doctest.writeDiff = function (orig, current, indentString) {
+ if (typeof orig != 'object' || typeof current != 'object') {
+ writeln(indentString + repr(orig, indentString) + ' -> ' + repr(current, indentString));
+ return;
+ }
+ indentString = indentString || '';
+ var diff = doctest.objDiff(orig, current);
+ var i, keys;
+ var any = false;
+ keys = doctest._sortedKeys(diff.added);
+ for (i=0; i<keys.length; i++) {
+ any = true;
+ writeln(indentString + '+' + keys[i] + ': '
+ + repr(diff.added[keys[i]], indentString));
+ }
+ keys = doctest._sortedKeys(diff.removed);
+ for (i=0; i<keys.length; i++) {
+ any = true;
+ writeln(indentString + '-' + keys[i] + ': '
+ + repr(diff.removed[keys[i]], indentString));
+ }
+ keys = doctest._sortedKeys(diff.changed);
+ for (i=0; i<keys.length; i++) {
+ any = true;
+ writeln(indentString + keys[i] + ': '
+ + repr(diff.changed[keys[i]][0], indentString)
+ + ' -> '
+ + repr(diff.changed[keys[i]][1], indentString));
+ }
+ if (! any) {
+ writeln(indentString + '(no changes)');
+ }
+};
+
+doctest.objectsEqual = function (ob1, ob2) {
+ var i;
+ if (typeof ob1 != 'object' || typeof ob2 != 'object') {
+ return ob1 === ob2;
+ }
+ for (i in ob1) {
+ if (ob1[i] !== ob2[i]) {
+ return false;
+ }
+ }
+ for (i in ob2) {
+ if (! (i in ob1)) {
+ return false;
+ }
+ }
+ return true;
+};
+
+doctest.getElementsByTagAndClassName = function (tagName, className, parent/*optional*/) {
+ parent = parent || document;
+ var els = parent.getElementsByTagName(tagName);
+ var result = [];
+ var regexes = [];
+ if (typeof className == 'string') {
+ className = [className];
+ }
+ for (var i=0; i<className.length; i++) {
+ regexes.push(new RegExp("\\b" + className[i] + "\\b"));
+ }
+ for (i=0; i<els.length; i++) {
+ var el = els[i];
+ if (el.className) {
+ var passed = true;
+ for (var j=0; j<regexes.length; j++) {
+ if (el.className.search(regexes[j]) == -1) {
+ passed = false;
+ break;
+ }
+ }
+ if (passed) {
+ result.push(el);
+ }
+ }
+ }
+ return result;
+};
+
+doctest.strip = function (str) {
+ str = str + "";
+ return str.replace(/\s+$/, "").replace(/^\s+/, "");
+};
+
+doctest.rstrip = function (str) {
+ str = str + "";
+ return str.replace(/\s+$/, "");
+};
+
+doctest.escapeHTML = function (s) {
+ return s.replace(/&/g, '&')
+ .replace(/\"/g, """)
+ .replace(/</g, '<')
+ .replace(/>/g, '>');
+};
+
+doctest.escapeSpaces = function (s) {
+ return s.replace(/ /g, ' ');
+};
+
+doctest.extend = function (obj, extendWith) {
+ for (i in extendWith) {
+ obj[i] = extendWith[i];
+ }
+ return obj;
+};
+
+doctest.extendDefault = function (obj, extendWith) {
+ for (i in extendWith) {
+ if (typeof obj[i] == 'undefined') {
+ obj[i] = extendWith[i];
+ }
+ }
+ return obj;
+};
+
+if (typeof repr == 'undefined') {
+ repr = doctest.repr;
+}
+
+doctest._consoleFunc = function (attr) {
+ if (typeof window.console != 'undefined'
+ && typeof window.console[attr] != 'undefined') {
+ if (typeof console[attr].apply === 'function') {
+ result = function() {
+ console[attr].apply(console, arguments);
+ };
+ } else {
+ result = console[attr];
+ }
+ } else {
+ result = function () {
+ // FIXME: do something
+ };
+ }
+ return result;
+};
+
+if (typeof log == 'undefined') {
+ log = doctest._consoleFunc('log');
+}
+
+if (typeof logDebug == 'undefined') {
+ logDebug = doctest._consoleFunc('log');
+}
+
+if (typeof logInfo == 'undefined') {
+ logInfo = doctest._consoleFunc('info');
+}
+
+if (typeof logWarn == 'undefined') {
+ logWarn = doctest._consoleFunc('warn');
+}
+
+doctest.eval = function () {
+ return window.eval.apply(window, arguments);
+};
+
+doctest.useCoffeeScript = function (options) {
+ options = options || {};
+ options.bare = true;
+ options.globals = true;
+ if (! options.fileName) {
+ options.fileName = 'repl';
+ }
+ if (typeof CoffeeScript == 'undefined') {
+ doctest.logWarn('coffee-script.js is not included');
+ throw 'coffee-script.js is not included';
+ }
+ doctest.eval = function (code) {
+ var src = CoffeeScript.compile(code, options);
+ logDebug('Compiled code to:', src);
+ return window.eval(src);
+ };
+};
+
+doctest.autoSetup = function (parent) {
+ var tags = doctest.getElementsByTagAndClassName('div', 'test', parent);
+ // First we'll make sure everything has an ID
+ var tagsById = {};
+ for (var i=0; i<tags.length; i++) {
+ var tagId = tags[i].getAttribute('id');
+ if (! tagId) {
+ tagId = 'test-' + (++doctest.autoSetup._idCount);
+ tags[i].setAttribute('id', tagId);
+ }
+ // FIXME: test uniqueness here, warn
+ tagsById[tagId] = tags[i];
+ }
+ // Then fill in the labels
+ for (i=0; i<tags.length; i++) {
+ var el = document.createElement('span');
+ el.className = 'test-id';
+ var anchor = document.createElement('a');
+ anchor.setAttribute('href', '#' + tags[i].getAttribute('id'));
+ anchor.appendChild(document.createTextNode(tags[i].getAttribute('id')));
+ var button = document.createElement('button');
+ button.innerHTML = 'test';
+ button.setAttribute('type', 'button');
+ button.setAttribute('test-id', tags[i].getAttribute('id'));
+ button.onclick = function () {
+ location.hash = '#' + this.getAttribute('test-id');
+ location.reload();
+ };
+ el.appendChild(anchor);
+ el.appendChild(button);
+ tags[i].insertBefore(el, tags[i].childNodes[0]);
+ }
+ // Lastly, create output areas in each section
+ for (i=0; i<tags.length; i++) {
+ var outEl = doctest.getElementsByTagAndClassName('pre', 'output', tags[i]);
+ if (! outEl.length) {
+ outEl = document.createElement('pre');
+ outEl.className = 'output';
+ outEl.setAttribute('id', tags[i].getAttribute('id') + '-output');
+ }
+ }
+ if (location.hash.length > 1) {
+ // This makes the :target CSS work, since if the hash points to an
+ // element whose id has just been added, it won't be noticed
+ location.hash = location.hash;
+ }
+ var output = document.getElementById('doctestOutput');
+ if (! tags.length) {
+ tags = document.getElementsByTagName('body');
+ }
+ if (! output) {
+ output = document.createElement('pre');
+ output.setAttribute('id', 'doctestOutput');
+ output.className = 'output';
+ tags[0].parentNode.insertBefore(output, tags[0]);
+ }
+ var reloader = document.getElementById('doctestReload');
+ if (! reloader) {
+ reloader = document.createElement('button');
+ reloader.setAttribute('type', 'button');
+ reloader.setAttribute('id', 'doctest-testall');
+ reloader.innerHTML = 'test all';
+ reloader.onclick = function () {
+ location.hash = '#doctest-testall';
+ location.reload();
+ };
+ output.parentNode.insertBefore(reloader, output);
+ }
+};
+
+doctest.autoSetup._idCount = 0;
+
+doctest.Spy = function (name, options, extraOptions) {
+ var self;
+ if (doctest.spies[name]) {
+ self = doctest.spies[name];
+ if (! options && ! extraOptions) {
+ return self;
+ }
+ } else {
+ self = function () {
+ return self.func.apply(this, arguments);
+ };
+ }
+ name = name || 'spy';
+ options = options || {};
+ if (typeof options == 'function') {
+ options = {applies: options};
+ }
+ if (extraOptions) {
+ doctest.extendDefault(options, extraOptions);
+ }
+ doctest.extendDefault(options, doctest.defaultSpyOptions);
+ self._name = name;
+ self.options = options;
+ self.called = false;
+ self.calledWait = false;
+ self.args = null;
+ self.self = null;
+ self.argList = [];
+ self.selfList = [];
+ self.writes = options.writes || false;
+ self.returns = options.returns || null;
+ self.applies = options.applies || null;
+ self.binds = options.binds || null;
+ self.throwError = options.throwError || null;
+ self.ignoreThis = options.ignoreThis || false;
+ self.wrapArgs = options.wrapArgs || false;
+ self.func = function () {
+ self.called = true;
+ self.calledWait = true;
+ self.args = doctest._argsToArray(arguments);
+ self.self = this;
+ self.argList.push(self.args);
+ self.selfList.push(this);
+ // It might be possible to get the caller?
+ if (self.writes) {
+ writeln(self.formatCall());
+ }
+ if (self.throwError) {
+ throw self.throwError;
+ }
+ if (self.applies) {
+ return self.applies.apply(this, arguments);
+ }
+ return self.returns;
+ };
+ self.func.toString = function () {
+ return "Spy('" + self._name + "').func";
+ };
+
+ // Method definitions:
+ self.formatCall = function () {
+ var s = '';
+ if ((! self.ignoreThis) && self.self !== window && self.self !== self) {
+ s += doctest.repr(self.self) + '.';
+ }
+ s += self._name;
+ if (self.args === null) {
+ return s + ':never called';
+ }
+ s += '(';
+ for (var i=0; i<self.args.length; i++) {
+ if (i) {
+ s += ', ';
+ }
+ if (self.wrapArgs) {
+ var maxLen = 10;
+ } else {
+ var maxLen = undefined;
+ }
+ s += doctest.repr(self.args[i], '', maxLen);
+ }
+ s += ')';
+ return s;
+ };
+
+ self.method = function (name, options, extraOptions) {
+ var desc = self._name + '.' + name;
+ var newSpy = Spy(desc, options, extraOptions);
+ self[name] = self.func[name] = newSpy.func;
+ return newSpy;
+ };
+
+ self.methods = function (props) {
+ for (var i in props) {
+ if (props[i] === props.prototype[i]) {
+ continue;
+ }
+ self.method(i, props[i]);
+ }
+ return self;
+ };
+
+ self.wait = function (timeout) {
+ var func = function () {
+ var value = self.calledWait;
+ if (value) {
+ self.calledWait = false;
+ }
+ return value;
+ };
+ func.repr = function () {
+ return 'called:'+repr(self);
+ };
+ doctest.wait(func, timeout);
+ };
+
+ self.repr = function () {
+ return "Spy('" + self._name + "')";
+ };
+
+ if (options.methods) {
+ self.methods(options.methods);
+ }
+ doctest.spies[name] = self;
+ if (options.wait) {
+ self.wait();
+ }
+ return self;
+};
+
+doctest._argsToArray = function (args) {
+ var array = [];
+ for (var i=0; i<args.length; i++) {
+ array.push(args[i]);
+ }
+ return array;
+};
+
+Spy = doctest.Spy;
+
+doctest.spies = {};
+
+doctest.defaultTimeout = 2000;
+
+doctest.defaultSpyOptions = {writes: true};
+
+var docTestOnLoad = function () {
+ var auto = false;
+ if (/\bautodoctest\b/.exec(document.body.className)) {
+ doctest.autoSetup();
+ auto = true;
+ } else {
+ logDebug('No autodoctest class on <body>');
+ }
+ var loc = window.location.search.substring(1);
+ if (auto || (/doctestRun/).exec(loc)) {
+ var elements = null;
+ // FIXME: we need to put the output near the specific test being tested:
+ if (location.hash) {
+ var el = document.getElementById(location.hash.substr(1));
+ if (el) {
+ if (/\btest\b/.exec(el.className)) {
+ var testEls = doctest.getElementsByTagAndClassName('pre', 'doctest', el);
+ elements = doctest.getElementsByTagAndClassName('pre', ['doctest', 'setup']);
+ for (var i=0; i<testEls.length; i++) {
+ elements.push(testEls[i]);
+ }
+ }
+ }
+ }
+ doctest(0, elements);
+ }
+};
+
+if (window.addEventListener) {
+ window.addEventListener('load', docTestOnLoad, false);
+} else if(window.attachEvent) {
+ window.attachEvent('onload', docTestOnLoad);
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[52/52] [abbrv] cordova-firefoxos git commit: CB-4548 Implement the
`run` command using node-firefox-* modules
Posted by za...@apache.org.
CB-4548 Implement the `run` command using node-firefox-* modules
Project: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/commit/d46b4430
Tree: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/tree/d46b4430
Diff: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/diff/d46b4430
Branch: refs/heads/master
Commit: d46b4430bc92d72f9e4866af4022bea98c090e11
Parents: b2b4320
Author: Les Orchard <me...@lmorchard.com>
Authored: Wed Mar 11 16:08:46 2015 -0400
Committer: Les Orchard <me...@lmorchard.com>
Committed: Fri Mar 27 16:13:59 2015 -0400
----------------------------------------------------------------------
bin/lib/update.js | 1 +
bin/templates/project/cordova/lib/common.js | 105 ++++++++++++++
.../project/cordova/lib/install-device | 69 +++++++++
.../project/cordova/lib/install-device.bat | 26 ++++
.../project/cordova/lib/install-emulator | 58 ++++++++
.../project/cordova/lib/install-emulator.bat | 26 ++++
bin/templates/project/cordova/lib/list-devices | 32 +++++
.../project/cordova/lib/list-devices.bat | 26 ++++
.../project/cordova/lib/list-emulator-images | 31 ++++
.../cordova/lib/list-emulator-images.bat | 26 ++++
.../project/cordova/lib/list-started-emulators | 32 +++++
.../cordova/lib/list-started-emulators.bat | 26 ++++
bin/templates/project/cordova/lib/run.js | 140 +++++++++++++++++++
.../project/cordova/lib/start-emulator | 43 ++++++
.../project/cordova/lib/start-emulator.bat | 26 ++++
bin/templates/project/cordova/run | 49 ++++---
bin/templates/project/cordova/run.bat | 26 ++++
17 files changed, 723 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/lib/update.js
----------------------------------------------------------------------
diff --git a/bin/lib/update.js b/bin/lib/update.js
index 8f674a1..3e0100d 100755
--- a/bin/lib/update.js
+++ b/bin/lib/update.js
@@ -42,6 +42,7 @@ function copyScripts(projectPath) {
shell.rm('-rf', destScriptsDir);
// Copy in the new ones.
shell.cp('-r', srcScriptsDir, projectPath);
+ shell.cp('-r', path.join(ROOT, 'node_modules'), destScriptsDir);
// Make sure they are executable.
shell.find(destScriptsDir).forEach(function(entry) {
shell.chmod(755, entry);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/common.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/common.js b/bin/templates/project/cordova/lib/common.js
new file mode 100644
index 0000000..3f8eb1a
--- /dev/null
+++ b/bin/templates/project/cordova/lib/common.js
@@ -0,0 +1,105 @@
+var path = require('path');
+var fs = require('fs');
+
+var Promise = require('es6-promise').Promise;
+
+var findSimulators = require('node-firefox-find-simulators');
+var findPorts = require('node-firefox-find-ports');
+var connect = require('node-firefox-connect');
+var installApp = require('node-firefox-install-app');
+var findApp = require('node-firefox-find-app');
+var launchApp = require('node-firefox-launch-app');
+var uninstallApp = require('node-firefox-uninstall-app');
+var startSimulator = require('node-firefox-start-simulator');
+
+var common = exports;
+
+common.collectSimulatorVersions = function() {
+ // There can be multiple Firefox installations, each with their own set of
+ // FxOS simulator addons. But, they're only unique by version. So, this
+ // just collects versions.
+ return findSimulators().then(function (simulators) {
+ var versions = {};
+ simulators.forEach(function (simulator) {
+ versions[simulator.version] = true;
+ });
+ return Object.keys(versions).sort();
+ });
+};
+
+common.collectRunningSimulatorsByVersion = function () {
+ return findPorts({
+ firefoxOSSimulator: true,
+ detailed: true
+ }).then(function(results) {
+ var ports_by_version = {};
+ results.forEach(function (result) {
+ var release_parts = result.release.split(/\./g);
+ result.version = release_parts[0] + '.' + release_parts[1];
+ ports_by_version[result.version] = result;
+ });
+ return ports_by_version;
+ });
+};
+
+common.findOrStartSimulatorTarget = function (install_target) {
+ return common.collectRunningSimulatorsByVersion().then(function (running) {
+ if (!install_target) {
+ install_target = Object.keys(running)[0];
+ }
+ if (!install_target) {
+ throw new Error('no emulator target found');
+ }
+ if (install_target in running) {
+ return running[install_target];
+ }
+ return common.collectSimulatorVersions().then(function (versions) {
+ if (install_target && versions.indexOf(install_target) === -1) {
+ throw new Error('emulator \'' + install_target + '\' does not exist.');
+ }
+ return startSimulator({
+ version: install_target,
+ detached: true
+ }).then(function (simulator) {
+ return common.collectRunningSimulatorsByVersion();
+ }).then(function (running) {
+ return running[install_target];
+ });
+ });
+ });
+};
+
+common.pushApp = function (client) {
+
+ var appPath = path.join(path.dirname(path.dirname(__dirname)), 'www');
+ var manifest = JSON.parse(fs.readFileSync(appPath + '/manifest.webapp'));
+
+ // TODO: replace most of this with node-firefox-push-app when it exists
+ // https://github.com/mozilla/node-firefox/issues/37
+ return findApp({
+ client: client,
+ manifest: manifest
+ }).then(function(apps) {
+ return Promise.all(apps.map(function (app) {
+ return uninstallApp({
+ client: client,
+ manifestURL: app.manifestURL
+ });
+ }));
+ }).then(function(uninstalled) {
+ return installApp({
+ client: client,
+ appPath: appPath
+ });
+ }).then(function(result) {
+ return findApp({
+ client: client,
+ manifest: manifest
+ });
+ }).then(function(apps) {
+ return launchApp({
+ client: client,
+ manifestURL: apps[0].manifestURL
+ });
+ });
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/install-device
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/install-device b/bin/templates/project/cordova/lib/install-device
new file mode 100755
index 0000000..115aadf
--- /dev/null
+++ b/bin/templates/project/cordova/lib/install-device
@@ -0,0 +1,69 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+var fs = require('fs');
+var path = require('path');
+
+var Promise = require('es6-promise').Promise;
+
+var common = require('./common');
+
+var findPorts = require('node-firefox-find-ports');
+var findDevices = require('node-firefox-find-devices');
+var forwardPorts = require('node-firefox-forward-ports');
+var connect = require('node-firefox-connect');
+
+var args = process.argv;
+var install_target;
+if(args.length > 2) {
+ if (args[2].substring(0, 9) == '--target=') {
+ install_target = args[2].substring(9, args[2].length);
+ } else {
+ console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
+ process.exit(2);
+ }
+}
+
+
+return forwardPorts([
+ { id: install_target }
+]).then(function() {
+ return findPorts({ firefoxOSDevice: true });
+}).then(function(ports) {
+
+ var targetPorts = ports.filter(function (port) {
+ return port.deviceId === install_target;
+ });
+ if (targetPorts.length === 0) {
+ throw new Error('Could not find device \'' + install_target + '\'.');
+ }
+ return connect(targetPorts[0].port);
+
+}).then(common.pushApp).then(function(result) {
+
+ process.exit(0);
+
+}).catch(function(err) {
+
+ console.error('ERROR: ' + err);
+ process.exit(2);
+
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/install-device.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/install-device.bat b/bin/templates/project/cordova/lib/install-device.bat
new file mode 100644
index 0000000..ac7214a
--- /dev/null
+++ b/bin/templates/project/cordova/lib/install-device.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0install-device"
+IF EXIST %script_path% (
+ node "%script_path%" %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'install-device' script in 'cordova\lib' folder, aborting...>&2
+ EXIT /B 1
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/install-emulator
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/install-emulator b/bin/templates/project/cordova/lib/install-emulator
new file mode 100755
index 0000000..c70720f
--- /dev/null
+++ b/bin/templates/project/cordova/lib/install-emulator
@@ -0,0 +1,58 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+var fs = require('fs');
+var path = require('path');
+
+var Promise = require('es6-promise').Promise;
+
+var common = require('./common');
+
+var findPorts = require('node-firefox-find-ports');
+var connect = require('node-firefox-connect');
+
+var args = process.argv;
+var install_target;
+if(args.length > 2) {
+ if (args[2].substring(0, 9) == '--target=') {
+ install_target = args[2].substring(9, args[2].length);
+ } else {
+ console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
+ process.exit(2);
+ }
+}
+
+common.findOrStartSimulatorTarget(install_target).then(function (simulator) {
+
+ var port = simulator.port;
+ console.log('Connecting to simulator on ' + port);
+ return connect(port);
+
+}).then(common.pushApp).then(function(result) {
+
+ process.exit(0);
+
+}).catch(function(err) {
+
+ console.error('ERROR: ' + err);
+ process.exit(2);
+
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/install-emulator.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/install-emulator.bat b/bin/templates/project/cordova/lib/install-emulator.bat
new file mode 100644
index 0000000..1ec6779
--- /dev/null
+++ b/bin/templates/project/cordova/lib/install-emulator.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0install-emulator"
+IF EXIST %script_path% (
+ node "%script_path%" %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'install-emulator' script in 'cordova\lib' folder, aborting...>&2
+ EXIT /B 1
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/list-devices
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/list-devices b/bin/templates/project/cordova/lib/list-devices
new file mode 100755
index 0000000..902dca7
--- /dev/null
+++ b/bin/templates/project/cordova/lib/list-devices
@@ -0,0 +1,32 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+var common = require('./common');
+var findDevices = require('node-firefox-find-devices');
+
+findDevices().then(function (devices) {
+ devices.forEach(function (device) {
+ console.log(device.id);
+ });
+}).catch(function(err) {
+ console.error('ERROR: ' + err);
+ process.exit(2);
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/list-devices.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/list-devices.bat b/bin/templates/project/cordova/lib/list-devices.bat
new file mode 100644
index 0000000..c0bcdd9
--- /dev/null
+++ b/bin/templates/project/cordova/lib/list-devices.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0list-devices"
+IF EXIST %script_path% (
+ node "%script_path%" %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'list-devices' script in 'cordova\lib' folder, aborting...>&2
+ EXIT /B 1
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/list-emulator-images
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/list-emulator-images b/bin/templates/project/cordova/lib/list-emulator-images
new file mode 100755
index 0000000..7b91fd4
--- /dev/null
+++ b/bin/templates/project/cordova/lib/list-emulator-images
@@ -0,0 +1,31 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+var common = require('./common');
+
+common.collectSimulatorVersions().then(function (versions) {
+ versions.forEach(function (version) {
+ console.log(version);
+ });
+}).catch(function(err) {
+ console.error('ERROR: ' + err);
+ process.exit(2);
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/list-emulator-images.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/list-emulator-images.bat b/bin/templates/project/cordova/lib/list-emulator-images.bat
new file mode 100644
index 0000000..661cbf9
--- /dev/null
+++ b/bin/templates/project/cordova/lib/list-emulator-images.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0list-emulator-images"
+IF EXIST %script_path% (
+ node "%script_path%" %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'list-emulator-images' script in 'cordova\lib' folder, aborting...>&2
+ EXIT /B 1
+)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/list-started-emulators
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/list-started-emulators b/bin/templates/project/cordova/lib/list-started-emulators
new file mode 100755
index 0000000..53c6513
--- /dev/null
+++ b/bin/templates/project/cordova/lib/list-started-emulators
@@ -0,0 +1,32 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+var common = require('./common');
+
+common.collectRunningSimulatorsByVersion().then(function(running) {
+ for (var version in running) {
+ var simulator = running[version];
+ console.log([version, simulator.port, simulator.type, simulator.pid].join(' '));
+ }
+}).catch(function(err) {
+ console.error('ERROR: ' + err);
+ process.exit(2);
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/list-started-emulators.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/list-started-emulators.bat b/bin/templates/project/cordova/lib/list-started-emulators.bat
new file mode 100644
index 0000000..a4e88f7
--- /dev/null
+++ b/bin/templates/project/cordova/lib/list-started-emulators.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0list-started-emulators"
+IF EXIST %script_path% (
+ node "%script_path%" %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'list-started-emulators' script in 'cordova\lib' folder, aborting...>&2
+ EXIT /B 1
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/run.js b/bin/templates/project/cordova/lib/run.js
new file mode 100644
index 0000000..127023e
--- /dev/null
+++ b/bin/templates/project/cordova/lib/run.js
@@ -0,0 +1,140 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+var path = require('path');
+var shell = require('shelljs');
+
+exports.help = function(args) {
+ console.log('Usage: ' + path.relative(process.cwd(), args[1]) + ' [options]');
+ console.log('Deploy options :');
+ console.log(' --device : Will deploy the built project to a device');
+ console.log(' --emulator : Will deploy the built project to an emulator if one exists');
+ console.log(' --list : List available device and emulator target ids');
+ console.log(' --target=<target_id> : Installs to the target with the specified id.');
+ process.exit(0);
+}
+
+exports.run = function(args) {
+
+ var install_target = null;
+ var use_emulator = null;
+ var list = false;
+
+ for (var i=2; i<args.length; i++) {
+ if (args[i] == '--device') {
+ use_emulator = false;
+ } else if (args[i] == '--emulator') {
+ use_emulator = true;
+ } else if (/^--target=/.exec(args[i])) {
+ install_target = args[i].substring(9, args[i].length);
+ } else if (args[i] == '--list') {
+ list = true;
+ } else {
+ console.warn('Option \'' + args[i] + '\' not recognized (ignoring).');
+ }
+ }
+
+ try {
+
+ var devices = runHelperScript('list-devices');
+ var emulators = runHelperScript('list-emulator-images');
+
+ if (list) {
+ if (!install_target || install_target == '--emulator') {
+ console.log('Available Firefox OS Simulators:');
+ console.log(emulators.map(function(item) { return "\t" + item }).join("\n"));
+ }
+ if (!install_target || install_target == '--device') {
+ console.log('Available Firefox OS Devices:');
+ console.log(devices.map(function(item) { return "\t" + item }).join("\n"));
+ }
+ return;
+ }
+
+ if (install_target) {
+
+ // We have an install target, so figure out if it's device or emulator.
+ if (emulators.indexOf(install_target) !== -1) {
+ use_emulator = true;
+ } else if (devices.indexOf(install_target) !== -1) {
+ use_emulator = false;
+ } else {
+ throw new Error('target \'' + install_target + '\' is neither a device nor an emulator');
+ }
+
+ } else {
+
+ // No explicit install target. If neither device nor emulator was
+ // called for specifically, we'll look for a device first and then
+ // fall back to an emulator. Otherwise, we'll limit looking for
+ // whichever was explictly called for.
+
+ if ((use_emulator === null || use_emulator === false)) {
+ if (devices.length) {
+ // Found a device, so use it as default target
+ install_target = devices[devices.length - 1];
+ use_emulator = false;
+ console.log('WARNING : No target specified, deploying to device \'' + install_target + '\'.');
+ }
+ }
+
+ if ((use_emulator === null || use_emulator === true)) {
+ var running_emulators = runHelperScript('list-started-emulators');
+ if (running_emulators.length) {
+ // Found a running emulator, so use it as default target.
+ install_target = emulators[emulators.length - 1];
+ use_emulator = true;
+ console.log('WARNING : No target specified, deploying to running emulator \'' + install_target + '\'.');
+ } else if (emulators.length) {
+ // Found an emulator, so use it as default target.
+ install_target = emulators[emulators.length - 1];
+ use_emulator = true;
+ console.log('WARNING : No target specified, starting and deploying to emulator \'' + install_target + '\'.');
+ }
+ }
+
+ }
+
+ if (!install_target || use_emulator === null) {
+ // Something went wrong in the selection process above, and we have
+ // no installation target.
+ throw new Error('no installation target could be found');
+ }
+
+ var install_script = use_emulator ? 'install-emulator' : 'install-device';
+ console.log(runHelperScript(install_script + ' --target=' + install_target, true));
+
+ } catch (err) {
+ console.error('' + err);
+ }
+
+}
+
+function runHelperScript(script, skipParse) {
+ var result = shell.exec(path.join(__dirname, script), {silent:true});
+ if (result.code !== 0) {
+ throw new Error(script + ' failed with exit code ' + result.code + ' - ' + result.output);
+ }
+ if (skipParse) {
+ return result.output;
+ }
+ return result.output.split(/\n/)
+ .filter(function(line) { return line != ''; })
+ .map(function(line) { return line.split(/\s/)[0]; });
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/start-emulator
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/start-emulator b/bin/templates/project/cordova/lib/start-emulator
new file mode 100755
index 0000000..f40bd25
--- /dev/null
+++ b/bin/templates/project/cordova/lib/start-emulator
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+var common = require('./common');
+
+var args = process.argv;
+
+var install_target;
+if(args.length > 2) {
+ if (args[2].substring(0, 9) == '--target=') {
+ install_target = args[2].substring(9, args[2].length);
+ } else {
+ console.error('ERROR : argument \'' + args[2] + '\' not recognized.');
+ process.exit(2);
+ }
+}
+
+common.findOrStartSimulatorTarget(install_target).then(function(simulator) {
+ console.log(simulator.port +
+ " FirefoxOS simulator running, PID " + simulator.pid);
+ process.exit(0);
+}).catch(function(err) {
+ console.error('ERROR: ' + err);
+ process.exit(2);
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/lib/start-emulator.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/start-emulator.bat b/bin/templates/project/cordova/lib/start-emulator.bat
new file mode 100644
index 0000000..9329d95
--- /dev/null
+++ b/bin/templates/project/cordova/lib/start-emulator.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0start-emulator"
+IF EXIST %script_path% (
+ node "%script_path%" %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'start-emulator' script in 'cordova\lib' folder, aborting...>&2
+ EXIT /B 1
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/run
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/run b/bin/templates/project/cordova/run
index 7b8e621..8ea228c 100755
--- a/bin/templates/project/cordova/run
+++ b/bin/templates/project/cordova/run
@@ -1,20 +1,31 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-#
+#!/usr/bin/env node
-echo "run not implemented, please use firefoxos simulator to launch app"
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+var run = require('./lib/run'),
+ args = process.argv;
+
+// Support basic help commands
+if (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
+ args[2] == 'help' || args[2] == '-help' || args[2] == '/help') {
+ run.help(args);
+} else {
+ run.run(args);
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/d46b4430/bin/templates/project/cordova/run.bat
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/run.bat b/bin/templates/project/cordova/run.bat
new file mode 100644
index 0000000..56c5296
--- /dev/null
+++ b/bin/templates/project/cordova/run.bat
@@ -0,0 +1,26 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements. See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership. The ASF licenses this file
+:: to you 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.
+
+@ECHO OFF
+SET script_path="%~dp0run"
+IF EXIST %script_path% (
+ node %script_path% %*
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'run' script in 'cordova' folder, aborting...>&2
+ EXIT /B 1
+)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[10/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/rsa.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/rsa.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/rsa.js
new file mode 100644
index 0000000..90f8c0a
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/rsa.js
@@ -0,0 +1,1712 @@
+/**
+ * Javascript implementation of basic RSA algorithms.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ *
+ * The only algorithm currently supported for PKI is RSA.
+ *
+ * An RSA key is often stored in ASN.1 DER format. The SubjectPublicKeyInfo
+ * ASN.1 structure is composed of an algorithm of type AlgorithmIdentifier
+ * and a subjectPublicKey of type bit string.
+ *
+ * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters
+ * for the algorithm, if any. In the case of RSA, there aren't any.
+ *
+ * SubjectPublicKeyInfo ::= SEQUENCE {
+ * algorithm AlgorithmIdentifier,
+ * subjectPublicKey BIT STRING
+ * }
+ *
+ * AlgorithmIdentifer ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL
+ * }
+ *
+ * For an RSA public key, the subjectPublicKey is:
+ *
+ * RSAPublicKey ::= SEQUENCE {
+ * modulus INTEGER, -- n
+ * publicExponent INTEGER -- e
+ * }
+ *
+ * PrivateKeyInfo ::= SEQUENCE {
+ * version Version,
+ * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
+ * privateKey PrivateKey,
+ * attributes [0] IMPLICIT Attributes OPTIONAL
+ * }
+ *
+ * Version ::= INTEGER
+ * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
+ * PrivateKey ::= OCTET STRING
+ * Attributes ::= SET OF Attribute
+ *
+ * An RSA private key as the following structure:
+ *
+ * RSAPrivateKey ::= SEQUENCE {
+ * version Version,
+ * modulus INTEGER, -- n
+ * publicExponent INTEGER, -- e
+ * privateExponent INTEGER, -- d
+ * prime1 INTEGER, -- p
+ * prime2 INTEGER, -- q
+ * exponent1 INTEGER, -- d mod (p-1)
+ * exponent2 INTEGER, -- d mod (q-1)
+ * coefficient INTEGER -- (inverse of q) mod p
+ * }
+ *
+ * Version ::= INTEGER
+ *
+ * The OID for the RSA key algorithm is: 1.2.840.113549.1.1.1
+ */
+(function() {
+function initModule(forge) {
+/* ########## Begin module implementation ########## */
+
+if(typeof BigInteger === 'undefined') {
+ var BigInteger = forge.jsbn.BigInteger;
+}
+
+// shortcut for asn.1 API
+var asn1 = forge.asn1;
+
+/*
+ * RSA encryption and decryption, see RFC 2313.
+ */
+forge.pki = forge.pki || {};
+forge.pki.rsa = forge.rsa = forge.rsa || {};
+var pki = forge.pki;
+
+// for finding primes, which are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29
+var GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];
+
+// validator for a PrivateKeyInfo structure
+var privateKeyValidator = {
+ // PrivateKeyInfo
+ name: 'PrivateKeyInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ // Version (INTEGER)
+ name: 'PrivateKeyInfo.version',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyVersion'
+ }, {
+ // privateKeyAlgorithm
+ name: 'PrivateKeyInfo.privateKeyAlgorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'AlgorithmIdentifier.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'privateKeyOid'
+ }]
+ }, {
+ // PrivateKey
+ name: 'PrivateKeyInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ constructed: false,
+ capture: 'privateKey'
+ }]
+};
+
+// validator for an RSA private key
+var rsaPrivateKeyValidator = {
+ // RSAPrivateKey
+ name: 'RSAPrivateKey',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ // Version (INTEGER)
+ name: 'RSAPrivateKey.version',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyVersion'
+ }, {
+ // modulus (n)
+ name: 'RSAPrivateKey.modulus',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyModulus'
+ }, {
+ // publicExponent (e)
+ name: 'RSAPrivateKey.publicExponent',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyPublicExponent'
+ }, {
+ // privateExponent (d)
+ name: 'RSAPrivateKey.privateExponent',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyPrivateExponent'
+ }, {
+ // prime1 (p)
+ name: 'RSAPrivateKey.prime1',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyPrime1'
+ }, {
+ // prime2 (q)
+ name: 'RSAPrivateKey.prime2',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyPrime2'
+ }, {
+ // exponent1 (d mod (p-1))
+ name: 'RSAPrivateKey.exponent1',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyExponent1'
+ }, {
+ // exponent2 (d mod (q-1))
+ name: 'RSAPrivateKey.exponent2',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyExponent2'
+ }, {
+ // coefficient ((inverse of q) mod p)
+ name: 'RSAPrivateKey.coefficient',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'privateKeyCoefficient'
+ }]
+};
+
+// validator for an RSA public key
+var rsaPublicKeyValidator = {
+ // RSAPublicKey
+ name: 'RSAPublicKey',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ // modulus (n)
+ name: 'RSAPublicKey.modulus',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'publicKeyModulus'
+ }, {
+ // publicExponent (e)
+ name: 'RSAPublicKey.exponent',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'publicKeyExponent'
+ }]
+};
+
+// validator for an SubjectPublicKeyInfo structure
+// Note: Currently only works with an RSA public key
+var publicKeyValidator = forge.pki.rsa.publicKeyValidator = {
+ name: 'SubjectPublicKeyInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'subjectPublicKeyInfo',
+ value: [{
+ name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'AlgorithmIdentifier.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'publicKeyOid'
+ }]
+ }, {
+ // subjectPublicKey
+ name: 'SubjectPublicKeyInfo.subjectPublicKey',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.BITSTRING,
+ constructed: false,
+ value: [{
+ // RSAPublicKey
+ name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ optional: true,
+ captureAsn1: 'rsaPublicKey'
+ }]
+ }]
+};
+
+/**
+ * Wrap digest in DigestInfo object.
+ *
+ * This function implements EMSA-PKCS1-v1_5-ENCODE as per RFC 3447.
+ *
+ * DigestInfo ::= SEQUENCE {
+ * digestAlgorithm DigestAlgorithmIdentifier,
+ * digest Digest
+ * }
+ *
+ * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
+ * Digest ::= OCTET STRING
+ *
+ * @param md the message digest object with the hash to sign.
+ *
+ * @return the encoded message (ready for RSA encrytion)
+ */
+var emsaPkcs1v15encode = function(md) {
+ // get the oid for the algorithm
+ var oid;
+ if(md.algorithm in pki.oids) {
+ oid = pki.oids[md.algorithm];
+ } else {
+ var error = new Error('Unknown message digest algorithm.');
+ error.algorithm = md.algorithm;
+ throw error;
+ }
+ var oidBytes = asn1.oidToDer(oid).getBytes();
+
+ // create the digest info
+ var digestInfo = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
+ var digestAlgorithm = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
+ digestAlgorithm.value.push(asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OID, false, oidBytes));
+ digestAlgorithm.value.push(asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.NULL, false, ''));
+ var digest = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,
+ false, md.digest().getBytes());
+ digestInfo.value.push(digestAlgorithm);
+ digestInfo.value.push(digest);
+
+ // encode digest info
+ return asn1.toDer(digestInfo).getBytes();
+};
+
+/**
+ * Performs x^c mod n (RSA encryption or decryption operation).
+ *
+ * @param x the number to raise and mod.
+ * @param key the key to use.
+ * @param pub true if the key is public, false if private.
+ *
+ * @return the result of x^c mod n.
+ */
+var _modPow = function(x, key, pub) {
+ if(pub) {
+ return x.modPow(key.e, key.n);
+ }
+
+ if(!key.p || !key.q) {
+ // allow calculation without CRT params (slow)
+ return x.modPow(key.d, key.n);
+ }
+
+ // pre-compute dP, dQ, and qInv if necessary
+ if(!key.dP) {
+ key.dP = key.d.mod(key.p.subtract(BigInteger.ONE));
+ }
+ if(!key.dQ) {
+ key.dQ = key.d.mod(key.q.subtract(BigInteger.ONE));
+ }
+ if(!key.qInv) {
+ key.qInv = key.q.modInverse(key.p);
+ }
+
+ /* Chinese remainder theorem (CRT) states:
+
+ Suppose n1, n2, ..., nk are positive integers which are pairwise
+ coprime (n1 and n2 have no common factors other than 1). For any
+ integers x1, x2, ..., xk there exists an integer x solving the
+ system of simultaneous congruences (where ~= means modularly
+ congruent so a ~= b mod n means a mod n = b mod n):
+
+ x ~= x1 mod n1
+ x ~= x2 mod n2
+ ...
+ x ~= xk mod nk
+
+ This system of congruences has a single simultaneous solution x
+ between 0 and n - 1. Furthermore, each xk solution and x itself
+ is congruent modulo the product n = n1*n2*...*nk.
+ So x1 mod n = x2 mod n = xk mod n = x mod n.
+
+ The single simultaneous solution x can be solved with the following
+ equation:
+
+ x = sum(xi*ri*si) mod n where ri = n/ni and si = ri^-1 mod ni.
+
+ Where x is less than n, xi = x mod ni.
+
+ For RSA we are only concerned with k = 2. The modulus n = pq, where
+ p and q are coprime. The RSA decryption algorithm is:
+
+ y = x^d mod n
+
+ Given the above:
+
+ x1 = x^d mod p
+ r1 = n/p = q
+ s1 = q^-1 mod p
+ x2 = x^d mod q
+ r2 = n/q = p
+ s2 = p^-1 mod q
+
+ So y = (x1r1s1 + x2r2s2) mod n
+ = ((x^d mod p)q(q^-1 mod p) + (x^d mod q)p(p^-1 mod q)) mod n
+
+ According to Fermat's Little Theorem, if the modulus P is prime,
+ for any integer A not evenly divisible by P, A^(P-1) ~= 1 mod P.
+ Since A is not divisible by P it follows that if:
+ N ~= M mod (P - 1), then A^N mod P = A^M mod P. Therefore:
+
+ A^N mod P = A^(M mod (P - 1)) mod P. (The latter takes less effort
+ to calculate). In order to calculate x^d mod p more quickly the
+ exponent d mod (p - 1) is stored in the RSA private key (the same
+ is done for x^d mod q). These values are referred to as dP and dQ
+ respectively. Therefore we now have:
+
+ y = ((x^dP mod p)q(q^-1 mod p) + (x^dQ mod q)p(p^-1 mod q)) mod n
+
+ Since we'll be reducing x^dP by modulo p (same for q) we can also
+ reduce x by p (and q respectively) before hand. Therefore, let
+
+ xp = ((x mod p)^dP mod p), and
+ xq = ((x mod q)^dQ mod q), yielding:
+
+ y = (xp*q*(q^-1 mod p) + xq*p*(p^-1 mod q)) mod n
+
+ This can be further reduced to a simple algorithm that only
+ requires 1 inverse (the q inverse is used) to be used and stored.
+ The algorithm is called Garner's algorithm. If qInv is the
+ inverse of q, we simply calculate:
+
+ y = (qInv*(xp - xq) mod p) * q + xq
+
+ However, there are two further complications. First, we need to
+ ensure that xp > xq to prevent signed BigIntegers from being used
+ so we add p until this is true (since we will be mod'ing with
+ p anyway). Then, there is a known timing attack on algorithms
+ using the CRT. To mitigate this risk, "cryptographic blinding"
+ should be used. This requires simply generating a random number r between
+ 0 and n-1 and its inverse and multiplying x by r^e before calculating y
+ and then multiplying y by r^-1 afterwards.
+ */
+
+ // cryptographic blinding
+ var r;
+ do {
+ r = new BigInteger(
+ forge.util.bytesToHex(forge.random.getBytes(key.n.bitLength() / 8)),
+ 16).mod(key.n);
+ } while(r.equals(BigInteger.ZERO));
+ x = x.multiply(r.modPow(key.e, key.n)).mod(key.n);
+
+ // calculate xp and xq
+ var xp = x.mod(key.p).modPow(key.dP, key.p);
+ var xq = x.mod(key.q).modPow(key.dQ, key.q);
+
+ // xp must be larger than xq to avoid signed bit usage
+ while(xp.compareTo(xq) < 0) {
+ xp = xp.add(key.p);
+ }
+
+ // do last step
+ var y = xp.subtract(xq)
+ .multiply(key.qInv).mod(key.p)
+ .multiply(key.q).add(xq);
+
+ // remove effect of random for cryptographic blinding
+ y = y.multiply(r.modInverse(key.n)).mod(key.n);
+
+ return y;
+};
+
+/**
+ * NOTE: THIS METHOD IS DEPRECATED, use 'sign' on a private key object or
+ * 'encrypt' on a public key object instead.
+ *
+ * Performs RSA encryption.
+ *
+ * The parameter bt controls whether to put padding bytes before the
+ * message passed in. Set bt to either true or false to disable padding
+ * completely (in order to handle e.g. EMSA-PSS encoding seperately before),
+ * signaling whether the encryption operation is a public key operation
+ * (i.e. encrypting data) or not, i.e. private key operation (data signing).
+ *
+ * For PKCS#1 v1.5 padding pass in the block type to use, i.e. either 0x01
+ * (for signing) or 0x02 (for encryption). The key operation mode (private
+ * or public) is derived from this flag in that case).
+ *
+ * @param m the message to encrypt as a byte string.
+ * @param key the RSA key to use.
+ * @param bt for PKCS#1 v1.5 padding, the block type to use
+ * (0x01 for private key, 0x02 for public),
+ * to disable padding: true = public key, false = private key.
+ *
+ * @return the encrypted bytes as a string.
+ */
+pki.rsa.encrypt = function(m, key, bt) {
+ var pub = bt;
+ var eb;
+
+ // get the length of the modulus in bytes
+ var k = Math.ceil(key.n.bitLength() / 8);
+
+ if(bt !== false && bt !== true) {
+ // legacy, default to PKCS#1 v1.5 padding
+ pub = (bt === 0x02);
+ eb = _encodePkcs1_v1_5(m, key, bt);
+ } else {
+ eb = forge.util.createBuffer();
+ eb.putBytes(m);
+ }
+
+ // load encryption block as big integer 'x'
+ // FIXME: hex conversion inefficient, get BigInteger w/byte strings
+ var x = new BigInteger(eb.toHex(), 16);
+
+ // do RSA encryption
+ var y = _modPow(x, key, pub);
+
+ // convert y into the encrypted data byte string, if y is shorter in
+ // bytes than k, then prepend zero bytes to fill up ed
+ // FIXME: hex conversion inefficient, get BigInteger w/byte strings
+ var yhex = y.toString(16);
+ var ed = forge.util.createBuffer();
+ var zeros = k - Math.ceil(yhex.length / 2);
+ while(zeros > 0) {
+ ed.putByte(0x00);
+ --zeros;
+ }
+ ed.putBytes(forge.util.hexToBytes(yhex));
+ return ed.getBytes();
+};
+
+/**
+ * NOTE: THIS METHOD IS DEPRECATED, use 'decrypt' on a private key object or
+ * 'verify' on a public key object instead.
+ *
+ * Performs RSA decryption.
+ *
+ * The parameter ml controls whether to apply PKCS#1 v1.5 padding
+ * or not. Set ml = false to disable padding removal completely
+ * (in order to handle e.g. EMSA-PSS later on) and simply pass back
+ * the RSA encryption block.
+ *
+ * @param ed the encrypted data to decrypt in as a byte string.
+ * @param key the RSA key to use.
+ * @param pub true for a public key operation, false for private.
+ * @param ml the message length, if known, false to disable padding.
+ *
+ * @return the decrypted message as a byte string.
+ */
+pki.rsa.decrypt = function(ed, key, pub, ml) {
+ // get the length of the modulus in bytes
+ var k = Math.ceil(key.n.bitLength() / 8);
+
+ // error if the length of the encrypted data ED is not k
+ if(ed.length !== k) {
+ var error = new Error('Encrypted message length is invalid.');
+ error.length = ed.length;
+ error.expected = k;
+ throw error;
+ }
+
+ // convert encrypted data into a big integer
+ // FIXME: hex conversion inefficient, get BigInteger w/byte strings
+ var y = new BigInteger(forge.util.createBuffer(ed).toHex(), 16);
+
+ // y must be less than the modulus or it wasn't the result of
+ // a previous mod operation (encryption) using that modulus
+ if(y.compareTo(key.n) >= 0) {
+ throw new Error('Encrypted message is invalid.');
+ }
+
+ // do RSA decryption
+ var x = _modPow(y, key, pub);
+
+ // create the encryption block, if x is shorter in bytes than k, then
+ // prepend zero bytes to fill up eb
+ // FIXME: hex conversion inefficient, get BigInteger w/byte strings
+ var xhex = x.toString(16);
+ var eb = forge.util.createBuffer();
+ var zeros = k - Math.ceil(xhex.length / 2);
+ while(zeros > 0) {
+ eb.putByte(0x00);
+ --zeros;
+ }
+ eb.putBytes(forge.util.hexToBytes(xhex));
+
+ if(ml !== false) {
+ // legacy, default to PKCS#1 v1.5 padding
+ return _decodePkcs1_v1_5(eb.getBytes(), key, pub);
+ }
+
+ // return message
+ return eb.getBytes();
+};
+
+/**
+ * Creates an RSA key-pair generation state object. It is used to allow
+ * key-generation to be performed in steps. It also allows for a UI to
+ * display progress updates.
+ *
+ * @param bits the size for the private key in bits, defaults to 2048.
+ * @param e the public exponent to use, defaults to 65537 (0x10001).
+ * @param [options] the options to use.
+ * prng a custom crypto-secure pseudo-random number generator to use,
+ * that must define "getBytesSync".
+ * algorithm the algorithm to use (default: 'PRIMEINC').
+ *
+ * @return the state object to use to generate the key-pair.
+ */
+pki.rsa.createKeyPairGenerationState = function(bits, e, options) {
+ // TODO: migrate step-based prime generation code to forge.prime
+
+ // set default bits
+ if(typeof(bits) === 'string') {
+ bits = parseInt(bits, 10);
+ }
+ bits = bits || 2048;
+
+ // create prng with api that matches BigInteger secure random
+ options = options || {};
+ var prng = options.prng || forge.random;
+ var rng = {
+ // x is an array to fill with bytes
+ nextBytes: function(x) {
+ var b = prng.getBytesSync(x.length);
+ for(var i = 0; i < x.length; ++i) {
+ x[i] = b.charCodeAt(i);
+ }
+ }
+ };
+
+ var algorithm = options.algorithm || 'PRIMEINC';
+
+ // create PRIMEINC algorithm state
+ var rval;
+ if(algorithm === 'PRIMEINC') {
+ rval = {
+ algorithm: algorithm,
+ state: 0,
+ bits: bits,
+ rng: rng,
+ eInt: e || 65537,
+ e: new BigInteger(null),
+ p: null,
+ q: null,
+ qBits: bits >> 1,
+ pBits: bits - (bits >> 1),
+ pqState: 0,
+ num: null,
+ keys: null
+ };
+ rval.e.fromInt(rval.eInt);
+ } else {
+ throw new Error('Invalid key generation algorithm: ' + algorithm);
+ }
+
+ return rval;
+};
+
+/**
+ * Attempts to runs the key-generation algorithm for at most n seconds
+ * (approximately) using the given state. When key-generation has completed,
+ * the keys will be stored in state.keys.
+ *
+ * To use this function to update a UI while generating a key or to prevent
+ * causing browser lockups/warnings, set "n" to a value other than 0. A
+ * simple pattern for generating a key and showing a progress indicator is:
+ *
+ * var state = pki.rsa.createKeyPairGenerationState(2048);
+ * var step = function() {
+ * // step key-generation, run algorithm for 100 ms, repeat
+ * if(!forge.pki.rsa.stepKeyPairGenerationState(state, 100)) {
+ * setTimeout(step, 1);
+ * } else {
+ * // key-generation complete
+ * // TODO: turn off progress indicator here
+ * // TODO: use the generated key-pair in "state.keys"
+ * }
+ * };
+ * // TODO: turn on progress indicator here
+ * setTimeout(step, 0);
+ *
+ * @param state the state to use.
+ * @param n the maximum number of milliseconds to run the algorithm for, 0
+ * to run the algorithm to completion.
+ *
+ * @return true if the key-generation completed, false if not.
+ */
+pki.rsa.stepKeyPairGenerationState = function(state, n) {
+ // set default algorithm if not set
+ if(!('algorithm' in state)) {
+ state.algorithm = 'PRIMEINC';
+ }
+
+ // TODO: migrate step-based prime generation code to forge.prime
+ // TODO: abstract as PRIMEINC algorithm
+
+ // do key generation (based on Tom Wu's rsa.js, see jsbn.js license)
+ // with some minor optimizations and designed to run in steps
+
+ // local state vars
+ var THIRTY = new BigInteger(null);
+ THIRTY.fromInt(30);
+ var deltaIdx = 0;
+ var op_or = function(x,y) { return x|y; };
+
+ // keep stepping until time limit is reached or done
+ var t1 = +new Date();
+ var t2;
+ var total = 0;
+ while(state.keys === null && (n <= 0 || total < n)) {
+ // generate p or q
+ if(state.state === 0) {
+ /* Note: All primes are of the form:
+
+ 30k+i, for i < 30 and gcd(30, i)=1, where there are 8 values for i
+
+ When we generate a random number, we always align it at 30k + 1. Each
+ time the number is determined not to be prime we add to get to the
+ next 'i', eg: if the number was at 30k + 1 we add 6. */
+ var bits = (state.p === null) ? state.pBits : state.qBits;
+ var bits1 = bits - 1;
+
+ // get a random number
+ if(state.pqState === 0) {
+ state.num = new BigInteger(bits, state.rng);
+ // force MSB set
+ if(!state.num.testBit(bits1)) {
+ state.num.bitwiseTo(
+ BigInteger.ONE.shiftLeft(bits1), op_or, state.num);
+ }
+ // align number on 30k+1 boundary
+ state.num.dAddOffset(31 - state.num.mod(THIRTY).byteValue(), 0);
+ deltaIdx = 0;
+
+ ++state.pqState;
+ } else if(state.pqState === 1) {
+ // try to make the number a prime
+ if(state.num.bitLength() > bits) {
+ // overflow, try again
+ state.pqState = 0;
+ // do primality test
+ } else if(state.num.isProbablePrime(
+ _getMillerRabinTests(state.num.bitLength()))) {
+ ++state.pqState;
+ } else {
+ // get next potential prime
+ state.num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);
+ }
+ } else if(state.pqState === 2) {
+ // ensure number is coprime with e
+ state.pqState =
+ (state.num.subtract(BigInteger.ONE).gcd(state.e)
+ .compareTo(BigInteger.ONE) === 0) ? 3 : 0;
+ } else if(state.pqState === 3) {
+ // store p or q
+ state.pqState = 0;
+ if(state.p === null) {
+ state.p = state.num;
+ } else {
+ state.q = state.num;
+ }
+
+ // advance state if both p and q are ready
+ if(state.p !== null && state.q !== null) {
+ ++state.state;
+ }
+ state.num = null;
+ }
+ } else if(state.state === 1) {
+ // ensure p is larger than q (swap them if not)
+ if(state.p.compareTo(state.q) < 0) {
+ state.num = state.p;
+ state.p = state.q;
+ state.q = state.num;
+ }
+ ++state.state;
+ } else if(state.state === 2) {
+ // compute phi: (p - 1)(q - 1) (Euler's totient function)
+ state.p1 = state.p.subtract(BigInteger.ONE);
+ state.q1 = state.q.subtract(BigInteger.ONE);
+ state.phi = state.p1.multiply(state.q1);
+ ++state.state;
+ } else if(state.state === 3) {
+ // ensure e and phi are coprime
+ if(state.phi.gcd(state.e).compareTo(BigInteger.ONE) === 0) {
+ // phi and e are coprime, advance
+ ++state.state;
+ } else {
+ // phi and e aren't coprime, so generate a new p and q
+ state.p = null;
+ state.q = null;
+ state.state = 0;
+ }
+ } else if(state.state === 4) {
+ // create n, ensure n is has the right number of bits
+ state.n = state.p.multiply(state.q);
+
+ // ensure n is right number of bits
+ if(state.n.bitLength() === state.bits) {
+ // success, advance
+ ++state.state;
+ } else {
+ // failed, get new q
+ state.q = null;
+ state.state = 0;
+ }
+ } else if(state.state === 5) {
+ // set keys
+ var d = state.e.modInverse(state.phi);
+ state.keys = {
+ privateKey: pki.rsa.setPrivateKey(
+ state.n, state.e, d, state.p, state.q,
+ d.mod(state.p1), d.mod(state.q1),
+ state.q.modInverse(state.p)),
+ publicKey: pki.rsa.setPublicKey(state.n, state.e)
+ };
+ }
+
+ // update timing
+ t2 = +new Date();
+ total += t2 - t1;
+ t1 = t2;
+ }
+
+ return state.keys !== null;
+};
+
+/**
+ * Generates an RSA public-private key pair in a single call.
+ *
+ * To generate a key-pair in steps (to allow for progress updates and to
+ * prevent blocking or warnings in slow browsers) then use the key-pair
+ * generation state functions.
+ *
+ * To generate a key-pair asynchronously (either through web-workers, if
+ * available, or by breaking up the work on the main thread), pass a
+ * callback function.
+ *
+ * @param [bits] the size for the private key in bits, defaults to 2048.
+ * @param [e] the public exponent to use, defaults to 65537.
+ * @param [options] options for key-pair generation, if given then 'bits'
+ * and 'e' must *not* be given:
+ * bits the size for the private key in bits, (default: 2048).
+ * e the public exponent to use, (default: 65537 (0x10001)).
+ * workerScript the worker script URL.
+ * workers the number of web workers (if supported) to use,
+ * (default: 2).
+ * workLoad the size of the work load, ie: number of possible prime
+ * numbers for each web worker to check per work assignment,
+ * (default: 100).
+ * e the public exponent to use, defaults to 65537.
+ * prng a custom crypto-secure pseudo-random number generator to use,
+ * that must define "getBytesSync".
+ * algorithm the algorithm to use (default: 'PRIMEINC').
+ * @param [callback(err, keypair)] called once the operation completes.
+ *
+ * @return an object with privateKey and publicKey properties.
+ */
+pki.rsa.generateKeyPair = function(bits, e, options, callback) {
+ // (bits), (options), (callback)
+ if(arguments.length === 1) {
+ if(typeof bits === 'object') {
+ options = bits;
+ bits = undefined;
+ } else if(typeof bits === 'function') {
+ callback = bits;
+ bits = undefined;
+ }
+ } else if(arguments.length === 2) {
+ // (bits, e), (bits, options), (bits, callback), (options, callback)
+ if(typeof bits === 'number') {
+ if(typeof e === 'function') {
+ callback = e;
+ e = undefined;
+ } else if(typeof e !== 'number') {
+ options = e;
+ e = undefined;
+ }
+ } else {
+ options = bits;
+ callback = e;
+ bits = undefined;
+ e = undefined;
+ }
+ } else if(arguments.length === 3) {
+ // (bits, e, options), (bits, e, callback), (bits, options, callback)
+ if(typeof e === 'number') {
+ if(typeof options === 'function') {
+ callback = options;
+ options = undefined;
+ }
+ } else {
+ callback = options;
+ options = e;
+ e = undefined;
+ }
+ }
+ options = options || {};
+ if(bits === undefined) {
+ bits = options.bits || 2048;
+ }
+ if(e === undefined) {
+ e = options.e || 0x10001;
+ }
+ var state = pki.rsa.createKeyPairGenerationState(bits, e, options);
+ if(!callback) {
+ pki.rsa.stepKeyPairGenerationState(state, 0);
+ return state.keys;
+ }
+ _generateKeyPair(state, options, callback);
+};
+
+/**
+ * Sets an RSA public key from BigIntegers modulus and exponent.
+ *
+ * @param n the modulus.
+ * @param e the exponent.
+ *
+ * @return the public key.
+ */
+pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
+ var key = {
+ n: n,
+ e: e
+ };
+
+ /**
+ * Encrypts the given data with this public key. Newer applications
+ * should use the 'RSA-OAEP' decryption scheme, 'RSAES-PKCS1-V1_5' is for
+ * legacy applications.
+ *
+ * @param data the byte string to encrypt.
+ * @param scheme the encryption scheme to use:
+ * 'RSAES-PKCS1-V1_5' (default),
+ * 'RSA-OAEP',
+ * 'RAW', 'NONE', or null to perform raw RSA encryption,
+ * an object with an 'encode' property set to a function
+ * with the signature 'function(data, key)' that returns
+ * a binary-encoded string representing the encoded data.
+ * @param schemeOptions any scheme-specific options.
+ *
+ * @return the encrypted byte string.
+ */
+ key.encrypt = function(data, scheme, schemeOptions) {
+ if(typeof scheme === 'string') {
+ scheme = scheme.toUpperCase();
+ } else if(scheme === undefined) {
+ scheme = 'RSAES-PKCS1-V1_5';
+ }
+
+ if(scheme === 'RSAES-PKCS1-V1_5') {
+ scheme = {
+ encode: function(m, key, pub) {
+ return _encodePkcs1_v1_5(m, key, 0x02).getBytes();
+ }
+ };
+ } else if(scheme === 'RSA-OAEP' || scheme === 'RSAES-OAEP') {
+ scheme = {
+ encode: function(m, key) {
+ return forge.pkcs1.encode_rsa_oaep(key, m, schemeOptions);
+ }
+ };
+ } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {
+ scheme = { encode: function(e) { return e; } };
+ } else if(typeof scheme === 'string') {
+ throw new Error('Unsupported encryption scheme: "' + scheme + '".');
+ }
+
+ // do scheme-based encoding then rsa encryption
+ var e = scheme.encode(data, key, true);
+ return pki.rsa.encrypt(e, key, true);
+ };
+
+ /**
+ * Verifies the given signature against the given digest.
+ *
+ * PKCS#1 supports multiple (currently two) signature schemes:
+ * RSASSA-PKCS1-V1_5 and RSASSA-PSS.
+ *
+ * By default this implementation uses the "old scheme", i.e.
+ * RSASSA-PKCS1-V1_5, in which case once RSA-decrypted, the
+ * signature is an OCTET STRING that holds a DigestInfo.
+ *
+ * DigestInfo ::= SEQUENCE {
+ * digestAlgorithm DigestAlgorithmIdentifier,
+ * digest Digest
+ * }
+ * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
+ * Digest ::= OCTET STRING
+ *
+ * To perform PSS signature verification, provide an instance
+ * of Forge PSS object as the scheme parameter.
+ *
+ * @param digest the message digest hash to compare against the signature,
+ * as a binary-encoded string.
+ * @param signature the signature to verify, as a binary-encoded string.
+ * @param scheme signature verification scheme to use:
+ * 'RSASSA-PKCS1-V1_5' or undefined for RSASSA PKCS#1 v1.5,
+ * a Forge PSS object for RSASSA-PSS,
+ * 'NONE' or null for none, DigestInfo will not be expected, but
+ * PKCS#1 v1.5 padding will still be used.
+ *
+ * @return true if the signature was verified, false if not.
+ */
+ key.verify = function(digest, signature, scheme) {
+ if(typeof scheme === 'string') {
+ scheme = scheme.toUpperCase();
+ } else if(scheme === undefined) {
+ scheme = 'RSASSA-PKCS1-V1_5';
+ }
+
+ if(scheme === 'RSASSA-PKCS1-V1_5') {
+ scheme = {
+ verify: function(digest, d) {
+ // remove padding
+ d = _decodePkcs1_v1_5(d, key, true);
+ // d is ASN.1 BER-encoded DigestInfo
+ var obj = asn1.fromDer(d);
+ // compare the given digest to the decrypted one
+ return digest === obj.value[1].value;
+ }
+ };
+ } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {
+ scheme = {
+ verify: function(digest, d) {
+ // remove padding
+ d = _decodePkcs1_v1_5(d, key, true);
+ return digest === d;
+ }
+ };
+ }
+
+ // do rsa decryption w/o any decoding, then verify -- which does decoding
+ var d = pki.rsa.decrypt(signature, key, true, false);
+ return scheme.verify(digest, d, key.n.bitLength());
+ };
+
+ return key;
+};
+
+/**
+ * Sets an RSA private key from BigIntegers modulus, exponent, primes,
+ * prime exponents, and modular multiplicative inverse.
+ *
+ * @param n the modulus.
+ * @param e the public exponent.
+ * @param d the private exponent ((inverse of e) mod n).
+ * @param p the first prime.
+ * @param q the second prime.
+ * @param dP exponent1 (d mod (p-1)).
+ * @param dQ exponent2 (d mod (q-1)).
+ * @param qInv ((inverse of q) mod p)
+ *
+ * @return the private key.
+ */
+pki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(
+ n, e, d, p, q, dP, dQ, qInv) {
+ var key = {
+ n: n,
+ e: e,
+ d: d,
+ p: p,
+ q: q,
+ dP: dP,
+ dQ: dQ,
+ qInv: qInv
+ };
+
+ /**
+ * Decrypts the given data with this private key. The decryption scheme
+ * must match the one used to encrypt the data.
+ *
+ * @param data the byte string to decrypt.
+ * @param scheme the decryption scheme to use:
+ * 'RSAES-PKCS1-V1_5' (default),
+ * 'RSA-OAEP',
+ * 'RAW', 'NONE', or null to perform raw RSA decryption.
+ * @param schemeOptions any scheme-specific options.
+ *
+ * @return the decrypted byte string.
+ */
+ key.decrypt = function(data, scheme, schemeOptions) {
+ if(typeof scheme === 'string') {
+ scheme = scheme.toUpperCase();
+ } else if(scheme === undefined) {
+ scheme = 'RSAES-PKCS1-V1_5';
+ }
+
+ // do rsa decryption w/o any decoding
+ var d = pki.rsa.decrypt(data, key, false, false);
+
+ if(scheme === 'RSAES-PKCS1-V1_5') {
+ scheme = { decode: _decodePkcs1_v1_5 };
+ } else if(scheme === 'RSA-OAEP' || scheme === 'RSAES-OAEP') {
+ scheme = {
+ decode: function(d, key) {
+ return forge.pkcs1.decode_rsa_oaep(key, d, schemeOptions);
+ }
+ };
+ } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {
+ scheme = { decode: function(d) { return d; } };
+ } else {
+ throw new Error('Unsupported encryption scheme: "' + scheme + '".');
+ }
+
+ // decode according to scheme
+ return scheme.decode(d, key, false);
+ };
+
+ /**
+ * Signs the given digest, producing a signature.
+ *
+ * PKCS#1 supports multiple (currently two) signature schemes:
+ * RSASSA-PKCS1-V1_5 and RSASSA-PSS.
+ *
+ * By default this implementation uses the "old scheme", i.e.
+ * RSASSA-PKCS1-V1_5. In order to generate a PSS signature, provide
+ * an instance of Forge PSS object as the scheme parameter.
+ *
+ * @param md the message digest object with the hash to sign.
+ * @param scheme the signature scheme to use:
+ * 'RSASSA-PKCS1-V1_5' or undefined for RSASSA PKCS#1 v1.5,
+ * a Forge PSS object for RSASSA-PSS,
+ * 'NONE' or null for none, DigestInfo will not be used but
+ * PKCS#1 v1.5 padding will still be used.
+ *
+ * @return the signature as a byte string.
+ */
+ key.sign = function(md, scheme) {
+ /* Note: The internal implementation of RSA operations is being
+ transitioned away from a PKCS#1 v1.5 hard-coded scheme. Some legacy
+ code like the use of an encoding block identifier 'bt' will eventually
+ be removed. */
+
+ // private key operation
+ var bt = false;
+
+ if(typeof scheme === 'string') {
+ scheme = scheme.toUpperCase();
+ }
+
+ if(scheme === undefined || scheme === 'RSASSA-PKCS1-V1_5') {
+ scheme = { encode: emsaPkcs1v15encode };
+ bt = 0x01;
+ } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {
+ scheme = { encode: function() { return md; } };
+ bt = 0x01;
+ }
+
+ // encode and then encrypt
+ var d = scheme.encode(md, key.n.bitLength());
+ return pki.rsa.encrypt(d, key, bt);
+ };
+
+ return key;
+};
+
+/**
+ * Wraps an RSAPrivateKey ASN.1 object in an ASN.1 PrivateKeyInfo object.
+ *
+ * @param rsaKey the ASN.1 RSAPrivateKey.
+ *
+ * @return the ASN.1 PrivateKeyInfo.
+ */
+pki.wrapRsaPrivateKey = function(rsaKey) {
+ // PrivateKeyInfo
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // version (0)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(0).getBytes()),
+ // privateKeyAlgorithm
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
+ ]),
+ // PrivateKey
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ asn1.toDer(rsaKey).getBytes())
+ ]);
+};
+
+/**
+ * Converts a private key from an ASN.1 object.
+ *
+ * @param obj the ASN.1 representation of a PrivateKeyInfo containing an
+ * RSAPrivateKey or an RSAPrivateKey.
+ *
+ * @return the private key.
+ */
+pki.privateKeyFromAsn1 = function(obj) {
+ // get PrivateKeyInfo
+ var capture = {};
+ var errors = [];
+ if(asn1.validate(obj, privateKeyValidator, capture, errors)) {
+ obj = asn1.fromDer(forge.util.createBuffer(capture.privateKey));
+ }
+
+ // get RSAPrivateKey
+ capture = {};
+ errors = [];
+ if(!asn1.validate(obj, rsaPrivateKeyValidator, capture, errors)) {
+ var error = new Error('Cannot read private key. ' +
+ 'ASN.1 object does not contain an RSAPrivateKey.');
+ error.errors = errors;
+ throw error;
+ }
+
+ // Note: Version is currently ignored.
+ // capture.privateKeyVersion
+ // FIXME: inefficient, get a BigInteger that uses byte strings
+ var n, e, d, p, q, dP, dQ, qInv;
+ n = forge.util.createBuffer(capture.privateKeyModulus).toHex();
+ e = forge.util.createBuffer(capture.privateKeyPublicExponent).toHex();
+ d = forge.util.createBuffer(capture.privateKeyPrivateExponent).toHex();
+ p = forge.util.createBuffer(capture.privateKeyPrime1).toHex();
+ q = forge.util.createBuffer(capture.privateKeyPrime2).toHex();
+ dP = forge.util.createBuffer(capture.privateKeyExponent1).toHex();
+ dQ = forge.util.createBuffer(capture.privateKeyExponent2).toHex();
+ qInv = forge.util.createBuffer(capture.privateKeyCoefficient).toHex();
+
+ // set private key
+ return pki.setRsaPrivateKey(
+ new BigInteger(n, 16),
+ new BigInteger(e, 16),
+ new BigInteger(d, 16),
+ new BigInteger(p, 16),
+ new BigInteger(q, 16),
+ new BigInteger(dP, 16),
+ new BigInteger(dQ, 16),
+ new BigInteger(qInv, 16));
+};
+
+/**
+ * Converts a private key to an ASN.1 RSAPrivateKey.
+ *
+ * @param key the private key.
+ *
+ * @return the ASN.1 representation of an RSAPrivateKey.
+ */
+pki.privateKeyToAsn1 = pki.privateKeyToRSAPrivateKey = function(key) {
+ // RSAPrivateKey
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // version (0 = only 2 primes, 1 multiple primes)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(0).getBytes()),
+ // modulus (n)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.n)),
+ // publicExponent (e)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.e)),
+ // privateExponent (d)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.d)),
+ // privateKeyPrime1 (p)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.p)),
+ // privateKeyPrime2 (q)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.q)),
+ // privateKeyExponent1 (dP)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.dP)),
+ // privateKeyExponent2 (dQ)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.dQ)),
+ // coefficient (qInv)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.qInv))
+ ]);
+};
+
+/**
+ * Converts a public key from an ASN.1 SubjectPublicKeyInfo or RSAPublicKey.
+ *
+ * @param obj the asn1 representation of a SubjectPublicKeyInfo or RSAPublicKey.
+ *
+ * @return the public key.
+ */
+pki.publicKeyFromAsn1 = function(obj) {
+ // get SubjectPublicKeyInfo
+ var capture = {};
+ var errors = [];
+ if(asn1.validate(obj, publicKeyValidator, capture, errors)) {
+ // get oid
+ var oid = asn1.derToOid(capture.publicKeyOid);
+ if(oid !== pki.oids.rsaEncryption) {
+ var error = new Error('Cannot read public key. Unknown OID.');
+ error.oid = oid;
+ throw error;
+ }
+ obj = capture.rsaPublicKey;
+ }
+
+ // get RSA params
+ errors = [];
+ if(!asn1.validate(obj, rsaPublicKeyValidator, capture, errors)) {
+ var error = new Error('Cannot read public key. ' +
+ 'ASN.1 object does not contain an RSAPublicKey.');
+ error.errors = errors;
+ throw error;
+ }
+
+ // FIXME: inefficient, get a BigInteger that uses byte strings
+ var n = forge.util.createBuffer(capture.publicKeyModulus).toHex();
+ var e = forge.util.createBuffer(capture.publicKeyExponent).toHex();
+
+ // set public key
+ return pki.setRsaPublicKey(
+ new BigInteger(n, 16),
+ new BigInteger(e, 16));
+};
+
+/**
+ * Converts a public key to an ASN.1 SubjectPublicKeyInfo.
+ *
+ * @param key the public key.
+ *
+ * @return the asn1 representation of a SubjectPublicKeyInfo.
+ */
+pki.publicKeyToAsn1 = pki.publicKeyToSubjectPublicKeyInfo = function(key) {
+ // SubjectPublicKeyInfo
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // AlgorithmIdentifier
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // algorithm
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),
+ // parameters (null)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
+ ]),
+ // subjectPublicKey
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, [
+ pki.publicKeyToRSAPublicKey(key)
+ ])
+ ]);
+};
+
+/**
+ * Converts a public key to an ASN.1 RSAPublicKey.
+ *
+ * @param key the public key.
+ *
+ * @return the asn1 representation of a RSAPublicKey.
+ */
+pki.publicKeyToRSAPublicKey = function(key) {
+ // RSAPublicKey
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // modulus (n)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.n)),
+ // publicExponent (e)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ _bnToBytes(key.e))
+ ]);
+};
+
+/**
+ * Encodes a message using PKCS#1 v1.5 padding.
+ *
+ * @param m the message to encode.
+ * @param key the RSA key to use.
+ * @param bt the block type to use, i.e. either 0x01 (for signing) or 0x02
+ * (for encryption).
+ *
+ * @return the padded byte buffer.
+ */
+function _encodePkcs1_v1_5(m, key, bt) {
+ var eb = forge.util.createBuffer();
+
+ // get the length of the modulus in bytes
+ var k = Math.ceil(key.n.bitLength() / 8);
+
+ /* use PKCS#1 v1.5 padding */
+ if(m.length > (k - 11)) {
+ var error = new Error('Message is too long for PKCS#1 v1.5 padding.');
+ error.length = m.length;
+ error.max = k - 11;
+ throw error;
+ }
+
+ /* A block type BT, a padding string PS, and the data D shall be
+ formatted into an octet string EB, the encryption block:
+
+ EB = 00 || BT || PS || 00 || D
+
+ The block type BT shall be a single octet indicating the structure of
+ the encryption block. For this version of the document it shall have
+ value 00, 01, or 02. For a private-key operation, the block type
+ shall be 00 or 01. For a public-key operation, it shall be 02.
+
+ The padding string PS shall consist of k-3-||D|| octets. For block
+ type 00, the octets shall have value 00; for block type 01, they
+ shall have value FF; and for block type 02, they shall be
+ pseudorandomly generated and nonzero. This makes the length of the
+ encryption block EB equal to k. */
+
+ // build the encryption block
+ eb.putByte(0x00);
+ eb.putByte(bt);
+
+ // create the padding
+ var padNum = k - 3 - m.length;
+ var padByte;
+ // private key op
+ if(bt === 0x00 || bt === 0x01) {
+ padByte = (bt === 0x00) ? 0x00 : 0xFF;
+ for(var i = 0; i < padNum; ++i) {
+ eb.putByte(padByte);
+ }
+ } else {
+ // public key op
+ // pad with random non-zero values
+ while(padNum > 0) {
+ var numZeros = 0;
+ var padBytes = forge.random.getBytes(padNum);
+ for(var i = 0; i < padNum; ++i) {
+ padByte = padBytes.charCodeAt(i);
+ if(padByte === 0) {
+ ++numZeros;
+ } else {
+ eb.putByte(padByte);
+ }
+ }
+ padNum = numZeros;
+ }
+ }
+
+ // zero followed by message
+ eb.putByte(0x00);
+ eb.putBytes(m);
+
+ return eb;
+}
+
+/**
+ * Decodes a message using PKCS#1 v1.5 padding.
+ *
+ * @param em the message to decode.
+ * @param key the RSA key to use.
+ * @param pub true if the key is a public key, false if it is private.
+ * @param ml the message length, if specified.
+ *
+ * @return the decoded bytes.
+ */
+function _decodePkcs1_v1_5(em, key, pub, ml) {
+ // get the length of the modulus in bytes
+ var k = Math.ceil(key.n.bitLength() / 8);
+
+ /* It is an error if any of the following conditions occurs:
+
+ 1. The encryption block EB cannot be parsed unambiguously.
+ 2. The padding string PS consists of fewer than eight octets
+ or is inconsisent with the block type BT.
+ 3. The decryption process is a public-key operation and the block
+ type BT is not 00 or 01, or the decryption process is a
+ private-key operation and the block type is not 02.
+ */
+
+ // parse the encryption block
+ var eb = forge.util.createBuffer(em);
+ var first = eb.getByte();
+ var bt = eb.getByte();
+ if(first !== 0x00 ||
+ (pub && bt !== 0x00 && bt !== 0x01) ||
+ (!pub && bt != 0x02) ||
+ (pub && bt === 0x00 && typeof(ml) === 'undefined')) {
+ throw new Error('Encryption block is invalid.');
+ }
+
+ var padNum = 0;
+ if(bt === 0x00) {
+ // check all padding bytes for 0x00
+ padNum = k - 3 - ml;
+ for(var i = 0; i < padNum; ++i) {
+ if(eb.getByte() !== 0x00) {
+ throw new Error('Encryption block is invalid.');
+ }
+ }
+ } else if(bt === 0x01) {
+ // find the first byte that isn't 0xFF, should be after all padding
+ padNum = 0;
+ while(eb.length() > 1) {
+ if(eb.getByte() !== 0xFF) {
+ --eb.read;
+ break;
+ }
+ ++padNum;
+ }
+ } else if(bt === 0x02) {
+ // look for 0x00 byte
+ padNum = 0;
+ while(eb.length() > 1) {
+ if(eb.getByte() === 0x00) {
+ --eb.read;
+ break;
+ }
+ ++padNum;
+ }
+ }
+
+ // zero must be 0x00 and padNum must be (k - 3 - message length)
+ var zero = eb.getByte();
+ if(zero !== 0x00 || padNum !== (k - 3 - eb.length())) {
+ throw new Error('Encryption block is invalid.');
+ }
+
+ return eb.getBytes();
+}
+
+/**
+ * Runs the key-generation algorithm asynchronously, either in the background
+ * via Web Workers, or using the main thread and setImmediate.
+ *
+ * @param state the key-pair generation state.
+ * @param [options] options for key-pair generation:
+ * workerScript the worker script URL.
+ * workers the number of web workers (if supported) to use,
+ * (default: 2, -1 to use estimated cores minus one).
+ * workLoad the size of the work load, ie: number of possible prime
+ * numbers for each web worker to check per work assignment,
+ * (default: 100).
+ * @param callback(err, keypair) called once the operation completes.
+ */
+function _generateKeyPair(state, options, callback) {
+ if(typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+ options = options || {};
+
+ var opts = {
+ algorithm: {
+ name: options.algorithm || 'PRIMEINC',
+ options: {
+ workers: options.workers || 2,
+ workLoad: options.workLoad || 100,
+ workerScript: options.workerScript
+ }
+ }
+ };
+ if('prng' in options) {
+ opts.prng = options.prng;
+ }
+
+ generate();
+
+ function generate() {
+ // find p and then q (done in series to simplify)
+ getPrime(state.pBits, function(err, num) {
+ if(err) {
+ return callback(err);
+ }
+ state.p = num;
+ if(state.q !== null) {
+ return finish(err, state.q);
+ }
+ getPrime(state.qBits, finish);
+ });
+ }
+
+ function getPrime(bits, callback) {
+ forge.prime.generateProbablePrime(bits, opts, callback);
+ }
+
+ function finish(err, num) {
+ if(err) {
+ return callback(err);
+ }
+
+ // set q
+ state.q = num;
+
+ // ensure p is larger than q (swap them if not)
+ if(state.p.compareTo(state.q) < 0) {
+ var tmp = state.p;
+ state.p = state.q;
+ state.q = tmp;
+ }
+
+ // ensure p is coprime with e
+ if(state.p.subtract(BigInteger.ONE).gcd(state.e)
+ .compareTo(BigInteger.ONE) !== 0) {
+ state.p = null;
+ generate();
+ return;
+ }
+
+ // ensure q is coprime with e
+ if(state.q.subtract(BigInteger.ONE).gcd(state.e)
+ .compareTo(BigInteger.ONE) !== 0) {
+ state.q = null;
+ getPrime(state.qBits, finish);
+ return;
+ }
+
+ // compute phi: (p - 1)(q - 1) (Euler's totient function)
+ state.p1 = state.p.subtract(BigInteger.ONE);
+ state.q1 = state.q.subtract(BigInteger.ONE);
+ state.phi = state.p1.multiply(state.q1);
+
+ // ensure e and phi are coprime
+ if(state.phi.gcd(state.e).compareTo(BigInteger.ONE) !== 0) {
+ // phi and e aren't coprime, so generate a new p and q
+ state.p = state.q = null;
+ generate();
+ return;
+ }
+
+ // create n, ensure n is has the right number of bits
+ state.n = state.p.multiply(state.q);
+ if(state.n.bitLength() !== state.bits) {
+ // failed, get new q
+ state.q = null;
+ getPrime(state.qBits, finish);
+ return;
+ }
+
+ // set keys
+ var d = state.e.modInverse(state.phi);
+ state.keys = {
+ privateKey: pki.rsa.setPrivateKey(
+ state.n, state.e, d, state.p, state.q,
+ d.mod(state.p1), d.mod(state.q1),
+ state.q.modInverse(state.p)),
+ publicKey: pki.rsa.setPublicKey(state.n, state.e)
+ };
+
+ callback(null, state.keys);
+ }
+}
+
+/**
+ * Converts a positive BigInteger into 2's-complement big-endian bytes.
+ *
+ * @param b the big integer to convert.
+ *
+ * @return the bytes.
+ */
+function _bnToBytes(b) {
+ // prepend 0x00 if first byte >= 0x80
+ var hex = b.toString(16);
+ if(hex[0] >= '8') {
+ hex = '00' + hex;
+ }
+ return forge.util.hexToBytes(hex);
+}
+
+/**
+ * Returns the required number of Miller-Rabin tests to generate a
+ * prime with an error probability of (1/2)^80.
+ *
+ * See Handbook of Applied Cryptography Chapter 4, Table 4.4.
+ *
+ * @param bits the bit size.
+ *
+ * @return the required number of iterations.
+ */
+function _getMillerRabinTests(bits) {
+ if(bits <= 100) return 27;
+ if(bits <= 150) return 18;
+ if(bits <= 200) return 15;
+ if(bits <= 250) return 12;
+ if(bits <= 300) return 9;
+ if(bits <= 350) return 8;
+ if(bits <= 400) return 7;
+ if(bits <= 500) return 6;
+ if(bits <= 600) return 5;
+ if(bits <= 800) return 4;
+ if(bits <= 1250) return 3;
+ return 2;
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'rsa';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define([
+ 'require',
+ 'module',
+ './asn1',
+ './jsbn',
+ './oids',
+ './pkcs1',
+ './prime',
+ './random',
+ './util'
+], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha1.js
new file mode 100644
index 0000000..53f65d2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha1.js
@@ -0,0 +1,342 @@
+/**
+ * Secure Hash Algorithm with 160-bit digest (SHA-1) implementation.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+var sha1 = forge.sha1 = forge.sha1 || {};
+forge.md = forge.md || {};
+forge.md.algorithms = forge.md.algorithms || {};
+forge.md.sha1 = forge.md.algorithms.sha1 = sha1;
+
+/**
+ * Creates a SHA-1 message digest object.
+ *
+ * @return a message digest object.
+ */
+sha1.create = function() {
+ // do initialization as necessary
+ if(!_initialized) {
+ _init();
+ }
+
+ // SHA-1 state contains five 32-bit integers
+ var _state = null;
+
+ // input buffer
+ var _input = forge.util.createBuffer();
+
+ // used for word storage
+ var _w = new Array(80);
+
+ // message digest object
+ var md = {
+ algorithm: 'sha1',
+ blockLength: 64,
+ digestLength: 20,
+ // 56-bit length of message so far (does not including padding)
+ messageLength: 0,
+ // true 64-bit message length as two 32-bit ints
+ messageLength64: [0, 0]
+ };
+
+ /**
+ * Starts the digest.
+ *
+ * @return this digest object.
+ */
+ md.start = function() {
+ md.messageLength = 0;
+ md.messageLength64 = [0, 0];
+ _input = forge.util.createBuffer();
+ _state = {
+ h0: 0x67452301,
+ h1: 0xEFCDAB89,
+ h2: 0x98BADCFE,
+ h3: 0x10325476,
+ h4: 0xC3D2E1F0
+ };
+ return md;
+ };
+ // start digest automatically for first time
+ md.start();
+
+ /**
+ * Updates the digest with the given message input. The given input can
+ * treated as raw input (no encoding will be applied) or an encoding of
+ * 'utf8' maybe given to encode the input using UTF-8.
+ *
+ * @param msg the message input to update with.
+ * @param encoding the encoding to use (default: 'raw', other: 'utf8').
+ *
+ * @return this digest object.
+ */
+ md.update = function(msg, encoding) {
+ if(encoding === 'utf8') {
+ msg = forge.util.encodeUtf8(msg);
+ }
+
+ // update message length
+ md.messageLength += msg.length;
+ md.messageLength64[0] += (msg.length / 0x100000000) >>> 0;
+ md.messageLength64[1] += msg.length >>> 0;
+
+ // add bytes to input buffer
+ _input.putBytes(msg);
+
+ // process bytes
+ _update(_state, _w, _input);
+
+ // compact input buffer every 2K or if empty
+ if(_input.read > 2048 || _input.length() === 0) {
+ _input.compact();
+ }
+
+ return md;
+ };
+
+ /**
+ * Produces the digest.
+ *
+ * @return a byte buffer containing the digest value.
+ */
+ md.digest = function() {
+ /* Note: Here we copy the remaining bytes in the input buffer and
+ add the appropriate SHA-1 padding. Then we do the final update
+ on a copy of the state so that if the user wants to get
+ intermediate digests they can do so. */
+
+ /* Determine the number of bytes that must be added to the message
+ to ensure its length is congruent to 448 mod 512. In other words,
+ the data to be digested must be a multiple of 512 bits (or 128 bytes).
+ This data includes the message, some padding, and the length of the
+ message. Since the length of the message will be encoded as 8 bytes (64
+ bits), that means that the last segment of the data must have 56 bytes
+ (448 bits) of message and padding. Therefore, the length of the message
+ plus the padding must be congruent to 448 mod 512 because
+ 512 - 128 = 448.
+
+ In order to fill up the message length it must be filled with
+ padding that begins with 1 bit followed by all 0 bits. Padding
+ must *always* be present, so if the message length is already
+ congruent to 448 mod 512, then 512 padding bits must be added. */
+
+ // 512 bits == 64 bytes, 448 bits == 56 bytes, 64 bits = 8 bytes
+ // _padding starts with 1 byte with first bit is set in it which
+ // is byte value 128, then there may be up to 63 other pad bytes
+ var padBytes = forge.util.createBuffer();
+ padBytes.putBytes(_input.bytes());
+ // 64 - (remaining msg + 8 bytes msg length) mod 64
+ padBytes.putBytes(
+ _padding.substr(0, 64 - ((md.messageLength64[1] + 8) & 0x3F)));
+
+ /* Now append length of the message. The length is appended in bits
+ as a 64-bit number in big-endian order. Since we store the length in
+ bytes, we must multiply the 64-bit length by 8 (or left shift by 3). */
+ padBytes.putInt32(
+ (md.messageLength64[0] << 3) | (md.messageLength64[0] >>> 28));
+ padBytes.putInt32(md.messageLength64[1] << 3);
+ var s2 = {
+ h0: _state.h0,
+ h1: _state.h1,
+ h2: _state.h2,
+ h3: _state.h3,
+ h4: _state.h4
+ };
+ _update(s2, _w, padBytes);
+ var rval = forge.util.createBuffer();
+ rval.putInt32(s2.h0);
+ rval.putInt32(s2.h1);
+ rval.putInt32(s2.h2);
+ rval.putInt32(s2.h3);
+ rval.putInt32(s2.h4);
+ return rval;
+ };
+
+ return md;
+};
+
+// sha-1 padding bytes not initialized yet
+var _padding = null;
+var _initialized = false;
+
+/**
+ * Initializes the constant tables.
+ */
+function _init() {
+ // create padding
+ _padding = String.fromCharCode(128);
+ _padding += forge.util.fillString(String.fromCharCode(0x00), 64);
+
+ // now initialized
+ _initialized = true;
+}
+
+/**
+ * Updates a SHA-1 state with the given byte buffer.
+ *
+ * @param s the SHA-1 state to update.
+ * @param w the array to use to store words.
+ * @param bytes the byte buffer to update with.
+ */
+function _update(s, w, bytes) {
+ // consume 512 bit (64 byte) chunks
+ var t, a, b, c, d, e, f, i;
+ var len = bytes.length();
+ while(len >= 64) {
+ // the w array will be populated with sixteen 32-bit big-endian words
+ // and then extended into 80 32-bit words according to SHA-1 algorithm
+ // and for 32-79 using Max Locktyukhin's optimization
+
+ // initialize hash value for this chunk
+ a = s.h0;
+ b = s.h1;
+ c = s.h2;
+ d = s.h3;
+ e = s.h4;
+
+ // round 1
+ for(i = 0; i < 16; ++i) {
+ t = bytes.getInt32();
+ w[i] = t;
+ f = d ^ (b & (c ^ d));
+ t = ((a << 5) | (a >>> 27)) + f + e + 0x5A827999 + t;
+ e = d;
+ d = c;
+ c = (b << 30) | (b >>> 2);
+ b = a;
+ a = t;
+ }
+ for(; i < 20; ++i) {
+ t = (w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]);
+ t = (t << 1) | (t >>> 31);
+ w[i] = t;
+ f = d ^ (b & (c ^ d));
+ t = ((a << 5) | (a >>> 27)) + f + e + 0x5A827999 + t;
+ e = d;
+ d = c;
+ c = (b << 30) | (b >>> 2);
+ b = a;
+ a = t;
+ }
+ // round 2
+ for(; i < 32; ++i) {
+ t = (w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]);
+ t = (t << 1) | (t >>> 31);
+ w[i] = t;
+ f = b ^ c ^ d;
+ t = ((a << 5) | (a >>> 27)) + f + e + 0x6ED9EBA1 + t;
+ e = d;
+ d = c;
+ c = (b << 30) | (b >>> 2);
+ b = a;
+ a = t;
+ }
+ for(; i < 40; ++i) {
+ t = (w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]);
+ t = (t << 2) | (t >>> 30);
+ w[i] = t;
+ f = b ^ c ^ d;
+ t = ((a << 5) | (a >>> 27)) + f + e + 0x6ED9EBA1 + t;
+ e = d;
+ d = c;
+ c = (b << 30) | (b >>> 2);
+ b = a;
+ a = t;
+ }
+ // round 3
+ for(; i < 60; ++i) {
+ t = (w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]);
+ t = (t << 2) | (t >>> 30);
+ w[i] = t;
+ f = (b & c) | (d & (b ^ c));
+ t = ((a << 5) | (a >>> 27)) + f + e + 0x8F1BBCDC + t;
+ e = d;
+ d = c;
+ c = (b << 30) | (b >>> 2);
+ b = a;
+ a = t;
+ }
+ // round 4
+ for(; i < 80; ++i) {
+ t = (w[i - 6] ^ w[i - 16] ^ w[i - 28] ^ w[i - 32]);
+ t = (t << 2) | (t >>> 30);
+ w[i] = t;
+ f = b ^ c ^ d;
+ t = ((a << 5) | (a >>> 27)) + f + e + 0xCA62C1D6 + t;
+ e = d;
+ d = c;
+ c = (b << 30) | (b >>> 2);
+ b = a;
+ a = t;
+ }
+
+ // update hash state
+ s.h0 = (s.h0 + a) | 0;
+ s.h1 = (s.h1 + b) | 0;
+ s.h2 = (s.h2 + c) | 0;
+ s.h3 = (s.h3 + d) | 0;
+ s.h4 = (s.h4 + e) | 0;
+
+ len -= 64;
+ }
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'sha1';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha256.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha256.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha256.js
new file mode 100644
index 0000000..fdbc4fc
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha256.js
@@ -0,0 +1,352 @@
+/**
+ * Secure Hash Algorithm with 256-bit digest (SHA-256) implementation.
+ *
+ * See FIPS 180-2 for details.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+var sha256 = forge.sha256 = forge.sha256 || {};
+forge.md = forge.md || {};
+forge.md.algorithms = forge.md.algorithms || {};
+forge.md.sha256 = forge.md.algorithms.sha256 = sha256;
+
+/**
+ * Creates a SHA-256 message digest object.
+ *
+ * @return a message digest object.
+ */
+sha256.create = function() {
+ // do initialization as necessary
+ if(!_initialized) {
+ _init();
+ }
+
+ // SHA-256 state contains eight 32-bit integers
+ var _state = null;
+
+ // input buffer
+ var _input = forge.util.createBuffer();
+
+ // used for word storage
+ var _w = new Array(64);
+
+ // message digest object
+ var md = {
+ algorithm: 'sha256',
+ blockLength: 64,
+ digestLength: 32,
+ // 56-bit length of message so far (does not including padding)
+ messageLength: 0,
+ // true 64-bit message length as two 32-bit ints
+ messageLength64: [0, 0]
+ };
+
+ /**
+ * Starts the digest.
+ *
+ * @return this digest object.
+ */
+ md.start = function() {
+ md.messageLength = 0;
+ md.messageLength64 = [0, 0];
+ _input = forge.util.createBuffer();
+ _state = {
+ h0: 0x6A09E667,
+ h1: 0xBB67AE85,
+ h2: 0x3C6EF372,
+ h3: 0xA54FF53A,
+ h4: 0x510E527F,
+ h5: 0x9B05688C,
+ h6: 0x1F83D9AB,
+ h7: 0x5BE0CD19
+ };
+ return md;
+ };
+ // start digest automatically for first time
+ md.start();
+
+ /**
+ * Updates the digest with the given message input. The given input can
+ * treated as raw input (no encoding will be applied) or an encoding of
+ * 'utf8' maybe given to encode the input using UTF-8.
+ *
+ * @param msg the message input to update with.
+ * @param encoding the encoding to use (default: 'raw', other: 'utf8').
+ *
+ * @return this digest object.
+ */
+ md.update = function(msg, encoding) {
+ if(encoding === 'utf8') {
+ msg = forge.util.encodeUtf8(msg);
+ }
+
+ // update message length
+ md.messageLength += msg.length;
+ md.messageLength64[0] += (msg.length / 0x100000000) >>> 0;
+ md.messageLength64[1] += msg.length >>> 0;
+
+ // add bytes to input buffer
+ _input.putBytes(msg);
+
+ // process bytes
+ _update(_state, _w, _input);
+
+ // compact input buffer every 2K or if empty
+ if(_input.read > 2048 || _input.length() === 0) {
+ _input.compact();
+ }
+
+ return md;
+ };
+
+ /**
+ * Produces the digest.
+ *
+ * @return a byte buffer containing the digest value.
+ */
+ md.digest = function() {
+ /* Note: Here we copy the remaining bytes in the input buffer and
+ add the appropriate SHA-256 padding. Then we do the final update
+ on a copy of the state so that if the user wants to get
+ intermediate digests they can do so. */
+
+ /* Determine the number of bytes that must be added to the message
+ to ensure its length is congruent to 448 mod 512. In other words,
+ the data to be digested must be a multiple of 512 bits (or 128 bytes).
+ This data includes the message, some padding, and the length of the
+ message. Since the length of the message will be encoded as 8 bytes (64
+ bits), that means that the last segment of the data must have 56 bytes
+ (448 bits) of message and padding. Therefore, the length of the message
+ plus the padding must be congruent to 448 mod 512 because
+ 512 - 128 = 448.
+
+ In order to fill up the message length it must be filled with
+ padding that begins with 1 bit followed by all 0 bits. Padding
+ must *always* be present, so if the message length is already
+ congruent to 448 mod 512, then 512 padding bits must be added. */
+
+ // 512 bits == 64 bytes, 448 bits == 56 bytes, 64 bits = 8 bytes
+ // _padding starts with 1 byte with first bit is set in it which
+ // is byte value 128, then there may be up to 63 other pad bytes
+ var padBytes = forge.util.createBuffer();
+ padBytes.putBytes(_input.bytes());
+ // 64 - (remaining msg + 8 bytes msg length) mod 64
+ padBytes.putBytes(
+ _padding.substr(0, 64 - ((md.messageLength64[1] + 8) & 0x3F)));
+
+ /* Now append length of the message. The length is appended in bits
+ as a 64-bit number in big-endian order. Since we store the length in
+ bytes, we must multiply the 64-bit length by 8 (or left shift by 3). */
+ padBytes.putInt32(
+ (md.messageLength64[0] << 3) | (md.messageLength64[0] >>> 28));
+ padBytes.putInt32(md.messageLength64[1] << 3);
+ var s2 = {
+ h0: _state.h0,
+ h1: _state.h1,
+ h2: _state.h2,
+ h3: _state.h3,
+ h4: _state.h4,
+ h5: _state.h5,
+ h6: _state.h6,
+ h7: _state.h7
+ };
+ _update(s2, _w, padBytes);
+ var rval = forge.util.createBuffer();
+ rval.putInt32(s2.h0);
+ rval.putInt32(s2.h1);
+ rval.putInt32(s2.h2);
+ rval.putInt32(s2.h3);
+ rval.putInt32(s2.h4);
+ rval.putInt32(s2.h5);
+ rval.putInt32(s2.h6);
+ rval.putInt32(s2.h7);
+ return rval;
+ };
+
+ return md;
+};
+
+// sha-256 padding bytes not initialized yet
+var _padding = null;
+var _initialized = false;
+
+// table of constants
+var _k = null;
+
+/**
+ * Initializes the constant tables.
+ */
+function _init() {
+ // create padding
+ _padding = String.fromCharCode(128);
+ _padding += forge.util.fillString(String.fromCharCode(0x00), 64);
+
+ // create K table for SHA-256
+ _k = [
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];
+
+ // now initialized
+ _initialized = true;
+}
+
+/**
+ * Updates a SHA-256 state with the given byte buffer.
+ *
+ * @param s the SHA-256 state to update.
+ * @param w the array to use to store words.
+ * @param bytes the byte buffer to update with.
+ */
+function _update(s, w, bytes) {
+ // consume 512 bit (64 byte) chunks
+ var t1, t2, s0, s1, ch, maj, i, a, b, c, d, e, f, g, h;
+ var len = bytes.length();
+ while(len >= 64) {
+ // the w array will be populated with sixteen 32-bit big-endian words
+ // and then extended into 64 32-bit words according to SHA-256
+ for(i = 0; i < 16; ++i) {
+ w[i] = bytes.getInt32();
+ }
+ for(; i < 64; ++i) {
+ // XOR word 2 words ago rot right 17, rot right 19, shft right 10
+ t1 = w[i - 2];
+ t1 =
+ ((t1 >>> 17) | (t1 << 15)) ^
+ ((t1 >>> 19) | (t1 << 13)) ^
+ (t1 >>> 10);
+ // XOR word 15 words ago rot right 7, rot right 18, shft right 3
+ t2 = w[i - 15];
+ t2 =
+ ((t2 >>> 7) | (t2 << 25)) ^
+ ((t2 >>> 18) | (t2 << 14)) ^
+ (t2 >>> 3);
+ // sum(t1, word 7 ago, t2, word 16 ago) modulo 2^32
+ w[i] = (t1 + w[i - 7] + t2 + w[i - 16]) | 0;
+ }
+
+ // initialize hash value for this chunk
+ a = s.h0;
+ b = s.h1;
+ c = s.h2;
+ d = s.h3;
+ e = s.h4;
+ f = s.h5;
+ g = s.h6;
+ h = s.h7;
+
+ // round function
+ for(i = 0; i < 64; ++i) {
+ // Sum1(e)
+ s1 =
+ ((e >>> 6) | (e << 26)) ^
+ ((e >>> 11) | (e << 21)) ^
+ ((e >>> 25) | (e << 7));
+ // Ch(e, f, g) (optimized the same way as SHA-1)
+ ch = g ^ (e & (f ^ g));
+ // Sum0(a)
+ s0 =
+ ((a >>> 2) | (a << 30)) ^
+ ((a >>> 13) | (a << 19)) ^
+ ((a >>> 22) | (a << 10));
+ // Maj(a, b, c) (optimized the same way as SHA-1)
+ maj = (a & b) | (c & (a ^ b));
+
+ // main algorithm
+ t1 = h + s1 + ch + _k[i] + w[i];
+ t2 = s0 + maj;
+ h = g;
+ g = f;
+ f = e;
+ e = (d + t1) | 0;
+ d = c;
+ c = b;
+ b = a;
+ a = (t1 + t2) | 0;
+ }
+
+ // update hash state
+ s.h0 = (s.h0 + a) | 0;
+ s.h1 = (s.h1 + b) | 0;
+ s.h2 = (s.h2 + c) | 0;
+ s.h3 = (s.h3 + d) | 0;
+ s.h4 = (s.h4 + e) | 0;
+ s.h5 = (s.h5 + f) | 0;
+ s.h6 = (s.h6 + g) | 0;
+ s.h7 = (s.h7 + h) | 0;
+ len -= 64;
+ }
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'sha256';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[47/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/.gitmodules
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/.gitmodules b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/.gitmodules
new file mode 100644
index 0000000..15339d4
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "src/test/tests"]
+ path = src/test/tests
+ url = git://github.com/lloyd/JSONSelectTests
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/.npmignore b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/.npmignore
new file mode 100644
index 0000000..0e2021f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/.npmignore
@@ -0,0 +1,5 @@
+*~
+\#*\#
+.DS_Store
+/src/dist
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/JSONSelect.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/JSONSelect.md b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/JSONSelect.md
new file mode 100644
index 0000000..bdd8580
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/JSONSelect.md
@@ -0,0 +1,214 @@
+**WARNING**: This document is a work in progress, just like JSONSelect itself.
+View or contribute to the latest version [on github](http://github.com/lloyd/JSONSelect/blob/master/JSONSelect.md)
+
+# JSONSelect
+
+ 1. [introduction](#introduction)
+ 1. [levels](#levels)
+ 1. [language overview](#overview)
+ 1. [grouping](#grouping)
+ 1. [selectors](#selectors)
+ 1. [pseudo classes](#pseudo)
+ 1. [expressions](#expressions)
+ 1. [combinators](#combinators)
+ 1. [grammar](#grammar)
+ 1. [conformance tests](#tests)
+ 1. [references](#references)
+
+## Introduction<a name="introduction"></a>
+
+JSONSelect defines a language very similar in syntax and structure to
+[CSS3 Selectors](http://www.w3.org/TR/css3-selectors/). JSONSelect
+expressions are patterns which can be matched against JSON documents.
+
+Potential applications of JSONSelect include:
+
+ * Simplified programmatic matching of nodes within JSON documents.
+ * Stream filtering, allowing efficient and incremental matching of documents.
+ * As a query language for a document database.
+
+## Levels<a name="levels"></a>
+
+The specification of JSONSelect is broken into three levels. Higher
+levels include more powerful constructs, and are likewise more
+complicated to implement and use.
+
+**JSONSelect Level 1** is a small subset of CSS3. Every feature is
+derived from a CSS construct that directly maps to JSON. A level 1
+implementation is not particularly complicated while providing basic
+querying features.
+
+**JSONSelect Level 2** builds upon Level 1 adapting more complex CSS
+constructs which allow expressions to include constraints such as
+patterns that match against values, and those which consider a node's
+siblings. Level 2 is still a direct adaptation of CSS, but includes
+constructs whose semantic meaning is significantly changed.
+
+**JSONSelect Level 3** adds constructs which do not necessarily have a
+direct analog in CSS, and are added to increase the power and convenience
+of the selector language. These include aliases, wholly new pseudo
+class functions, and more blue sky dreaming.
+
+## Language Overview<a name="overview"></a>
+
+<table>
+<tr><th>pattern</th><th>meaning</th><th>level</th></tr>
+<tr><td>*</td><td>Any node</td><td>1</td></tr>
+<tr><td>T</td><td>A node of type T, where T is one string, number, object, array, boolean, or null</td><td>1</td></tr>
+<tr><td>T.key</td><td>A node of type T which is the child of an object and is the value its parents key property</td><td>1</td></tr>
+<tr><td>T."complex key"</td><td>Same as previous, but with property name specified as a JSON string</td><td>1</td></tr>
+<tr><td>T:root</td><td>A node of type T which is the root of the JSON document</td><td>1</td></tr>
+<tr><td>T:nth-child(n)</td><td>A node of type T which is the nth child of an array parent</td><td>1</td></tr>
+<tr><td>T:nth-last-child(n)</td><td>A node of type T which is the nth child of an array parent counting from the end</td><td>2</td></tr>
+<tr><td>T:first-child</td><td>A node of type T which is the first child of an array parent (equivalent to T:nth-child(1)</td><td>1</td></tr>
+<tr><td>T:last-child</td><td>A node of type T which is the last child of an array parent (equivalent to T:nth-last-child(1)</td><td>2</td></tr>
+<tr><td>T:only-child</td><td>A node of type T which is the only child of an array parent</td><td>2</td></tr>
+<tr><td>T:empty</td><td>A node of type T which is an array or object with no child</td><td>2</td></tr>
+<tr><td>T U</td><td>A node of type U with an ancestor of type T</td><td>1</td></tr>
+<tr><td>T > U</td><td>A node of type U with a parent of type T</td><td>1</td></tr>
+<tr><td>T ~ U</td><td>A node of type U with a sibling of type T</td><td>2</td></tr>
+<tr><td>S1, S2</td><td>Any node which matches either selector S1 or S2</td><td>1</td></tr>
+<tr><td>T:has(S)</td><td>A node of type T which has a child node satisfying the selector S</td><td>3</td></tr>
+<tr><td>T:expr(E)</td><td>A node of type T with a value that satisfies the expression E</td><td>3</td></tr>
+<tr><td>T:val(V)</td><td>A node of type T with a value that is equal to V</td><td>3</td></tr>
+<tr><td>T:contains(S)</td><td>A node of type T with a string value contains the substring S</td><td>3</td></tr>
+</table>
+
+## Grouping<a name="grouping"></a>
+
+## Selectors<a name="selectors"></a>
+
+## Pseudo Classes<a name="pseudo"></a>
+
+## Expressions<a name="expressions"></a>
+
+## Combinators<a name="combinators"></a>
+
+## Grammar<a name="grammar"></a>
+
+(Adapted from [CSS3](http://www.w3.org/TR/css3-selectors/#descendant-combinators) and
+ [json.org](http://json.org/))
+
+ selectors_group
+ : selector [ `,` selector ]*
+ ;
+
+ selector
+ : simple_selector_sequence [ combinator simple_selector_sequence ]*
+ ;
+
+ combinator
+ : `>` | \s+
+ ;
+
+ simple_selector_sequence
+ /* why allow multiple HASH entities in the grammar? */
+ : [ type_selector | universal ]
+ [ class | pseudo ]*
+ | [ class | pseudo ]+
+ ;
+
+ type_selector
+ : `object` | `array` | `number` | `string` | `boolean` | `null`
+ ;
+
+ universal
+ : '*'
+ ;
+
+ class
+ : `.` name
+ | `.` json_string
+ ;
+
+ pseudo
+ /* Note that pseudo-elements are restricted to one per selector and */
+ /* occur only in the last simple_selector_sequence. */
+ : `:` pseudo_class_name
+ | `:` nth_function_name `(` nth_expression `)`
+ | `:has` `(` selectors_group `)`
+ | `:expr` `(` expr `)`
+ | `:contains` `(` json_string `)`
+ | `:val` `(` val `)`
+ ;
+
+ pseudo_class_name
+ : `root` | `first-child` | `last-child` | `only-child`
+
+ nth_function_name
+ : `nth-child` | `nth-last-child`
+
+ nth_expression
+ /* expression is and of the form "an+b" */
+ : TODO
+ ;
+
+ expr
+ : expr binop expr
+ | '(' expr ')'
+ | val
+ ;
+
+ binop
+ : '*' | '/' | '%' | '+' | '-' | '<=' | '>=' | '$='
+ | '^=' | '*=' | '>' | '<' | '=' | '!=' | '&&' | '||'
+ ;
+
+ val
+ : json_number | json_string | 'true' | 'false' | 'null' | 'x'
+ ;
+
+ json_string
+ : `"` json_chars* `"`
+ ;
+
+ json_chars
+ : any-Unicode-character-except-"-or-\-or-control-character
+ | `\"`
+ | `\\`
+ | `\/`
+ | `\b`
+ | `\f`
+ | `\n`
+ | `\r`
+ | `\t`
+ | \u four-hex-digits
+ ;
+
+ name
+ : nmstart nmchar*
+ ;
+
+ nmstart
+ : escape | [_a-zA-Z] | nonascii
+ ;
+
+ nmchar
+ : [_a-zA-Z0-9-]
+ | escape
+ | nonascii
+ ;
+
+ escape
+ : \\[^\r\n\f0-9a-fA-F]
+ ;
+
+ nonascii
+ : [^\0-0177]
+ ;
+
+## Conformance Tests<a name="tests"></a>
+
+See [https://github.com/lloyd/JSONSelectTests](https://github.com/lloyd/JSONSelectTests)
+
+## References<a name="references"></a>
+
+In no particular order.
+
+ * [http://json.org/](http://json.org/)
+ * [http://www.w3.org/TR/css3-selectors/](http://www.w3.org/TR/css3-selectors/)
+ * [http://ejohn.org/blog/selectors-that-people-actually-use/](http://ejohn.org/blog/selectors-that-people-actually-use/)
+ * [http://shauninman.com/archive/2008/05/05/css\_qualified\_selectors]( * http://shauninman.com/archive/2008/05/05/css_qualified_selectors)
+ * [http://snook.ca/archives/html\_and\_css/css-parent-selectors](http://snook.ca/archives/html_and_css/css-parent-selectors)
+ * [http://remysharp.com/2010/10/11/css-parent-selector/](http://remysharp.com/2010/10/11/css-parent-selector/)
+ * [https://github.com/jquery/sizzle/wiki/Sizzle-Home](https://github.com/jquery/sizzle/wiki/Sizzle-Home)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/README.md b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/README.md
new file mode 100644
index 0000000..00a573e
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/README.md
@@ -0,0 +1,33 @@
+JSONSelect is *EXPERIMENTAL*, *ALPHA*, etc.
+
+JSONSelect defines a selector language similar to CSS intended for
+JSON documents. For an introduction to the project see
+[jsonselect.org](http://jsonselect.org) or the [documentation](https://github.com/lloyd/JSONSelect/blob/master/JSONSelect.md).
+
+## Project Overview
+
+JSONSelect is an attempt to create a selector language similar to
+CSS for JSON objects. A couple key goals of the project's include:
+
+ * **intuitive** - JSONSelect is meant to *feel like* CSS, meaning a developers with an understanding of CSS can probably guess most of the syntax.
+ * **expressive** - As JSONSelect evolves, it will include more of the most popular constructs from the CSS spec and popular implementations (like [sizzle](http://sizzlejs.com/)). A successful result will be a good balance of simplicity and power.
+ * **language independence** - The project will avoid features which are unnecessarily tied to a particular implementation language.
+ * **incremental adoption** - JSONSelect features are broken in to conformance levels, to make it easier to build basic support and to allow incremental stabilization of the language.
+ * **efficient** - As many constructs of the language as possible will be able to be evaluated in a single document traversal. This allows for efficient stream filtering.
+
+JSONSelect should make common operations easy, complex operations possible,
+but haughtily ignore weird shit.
+
+## What's Here
+
+This repository is the home to many things related to JSONSelect:
+
+ * [Documentation](https://github.com/lloyd/JSONSelect/blob/master/JSONSelect.md) which describes the language
+ * The [jsonselect.org](http://jsonselect.org) [site source](https://github.com/lloyd/JSONSelect/blob/master/site/)
+ * A [reference implementation](https://github.com/lloyd/JSONSelect/blob/master/src/jsonselect.js) in JavaScript
+
+## Related projects
+
+Conformance tests are broken out into a [separate
+repository](https://github.com/lloyd/JSONSelectTests) and may be used
+by other implementations.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/package.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/package.json
new file mode 100644
index 0000000..fae9d34
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/package.json
@@ -0,0 +1,49 @@
+{
+ "author": {
+ "name": "Lloyd Hilaiel",
+ "email": "lloyd@hilaiel.com",
+ "url": "http://trickyco.de"
+ },
+ "name": "JSONSelect",
+ "description": "CSS-like selectors for JSON",
+ "version": "0.2.1",
+ "homepage": "http://jsonselect.org",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/lloyd/JSONSelect.git"
+ },
+ "main": "src/jsonselect",
+ "engines": {
+ "node": ">=0.4.7"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "files": [
+ "src/jsonselect.js",
+ "src/test/run.js",
+ "src/test/tests",
+ "tests",
+ "README.md",
+ "JSONSelect.md",
+ "package.json",
+ "LICENSE"
+ ],
+ "_id": "JSONSelect@0.2.1",
+ "_engineSupported": true,
+ "_npmVersion": "1.0.6",
+ "_nodeVersion": "v0.4.7",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "415418a526d33fe31d74b4defa3c836d485ec203",
+ "tarball": "http://registry.npmjs.org/JSONSelect/-/JSONSelect-0.2.1.tgz"
+ },
+ "scripts": {},
+ "directories": {},
+ "_shasum": "415418a526d33fe31d74b4defa3c836d485ec203",
+ "_from": "JSONSelect@0.2.1",
+ "_resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.2.1.tgz",
+ "bugs": {
+ "url": "https://github.com/lloyd/JSONSelect/issues"
+ },
+ "readme": "ERROR: No README data found!"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/droid_sans.css
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/droid_sans.css b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/droid_sans.css
new file mode 100644
index 0000000..0826445
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/droid_sans.css
@@ -0,0 +1,6 @@
+@font-face {
+ font-family: 'Droid Sans';
+ font-style: normal;
+ font-weight: normal;
+ src: local('Droid Sans'), local('DroidSans'), url('droid_sans.tt') format('truetype');
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/droid_sans.tt
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/droid_sans.tt b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/droid_sans.tt
new file mode 100644
index 0000000..efd1f8b
Binary files /dev/null and b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/droid_sans.tt differ
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/style.css
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/style.css b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/style.css
new file mode 100644
index 0000000..b4fbaa6
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/css/style.css
@@ -0,0 +1,209 @@
+body {
+ background-color: #191919;
+ color: #a1a1a1;
+ font-family: 'Droid Sans', arial, serif;
+ font-size: 14px;
+}
+
+#header {
+ position: fixed;
+ background-color: #191919;
+ opacity: .7;
+ color: #ccc;
+ width: 100%;
+ top: 0px;
+ left: 0px;
+ margin: 0px;
+ padding: 4px 10px 4px 10px;
+}
+
+#main {
+ margin-top: 100px;
+}
+
+#header b {
+ font-weight: bold;
+ color: #fff;
+}
+
+a {
+ color: #999;
+ text-decoration: underline;
+}
+
+a:hover {
+ color: #fff;
+}
+
+#header .title {
+ font-size: 400%;
+}
+
+#header .subtitle {
+ font-size: 150%;
+ margin-left: 1em;
+ font-style: italic;
+}
+
+#header .nav {
+ float: right;
+ margin-right: 100px;
+}
+
+div.content {
+ max-width: 850px;
+ min-width: 675px;
+ margin: auto;
+}
+
+div#tryit {
+ min-width: 825px;
+}
+
+#splash {
+ max-width: 700px;
+}
+
+.json {
+ background-color: #333;
+ padding: .5em 1em .5em 1em;
+ border: 3px solid #444;
+ border-radius: 1em;
+ -moz-border-radius: 1em;
+ -webkit-border-radius: 1em;
+}
+
+#splash .sample {
+ width: 250px;
+ float: right;
+ margin-left: 1em;
+ margin-top: 3em;
+ font-size: 90%;
+}
+
+#doc {
+ margin-top: 140px;
+}
+
+#doc table {
+ width: 100%;
+}
+
+#doc table th {
+ background-color: #aaa;
+ color: #333;
+ padding: 10px;
+}
+
+#doc table tr td:first-child {
+ font-family: "andale mono",monospace;
+}
+
+#doc table td {
+ padding-top: 3px;
+}
+
+#splash .sample tt {
+ font-size: 90%;
+ padding: 0 .2em 0 .2em;
+}
+
+#splash .sample pre {
+ border-top: 1px dashed #aaa;
+ padding-top: 1em;
+}
+
+#splash .pitch {
+ padding-top: 2em;
+ font-size: 170%;
+}
+
+.selected {
+ opacity: .7;
+ padding: 8px;
+ margin: -10px;
+ background-color: #fff475;
+ color: #000;
+ border: 2px solid white;
+ border-radius: 4px;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+}
+
+div.current input, div.selector, pre, code, tt {
+ font-family: "andale mono",monospace;
+ font-size: .9em;
+}
+
+div.current {
+ width: 100%;
+ padding: 1em;
+}
+
+div.current input {
+ color: #fff;
+ font-size: 110%;
+ background-color: #333;
+ border: 1px solid #444;
+ padding: 8px;
+ width: 400px;
+ margin-left: 1em;
+ margin-right: 1em;
+ border-radius: 4px;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+}
+
+pre.doc {
+ float: right;
+ padding: 1em 3em 1em 3em;
+ padding-right: 160px;
+ font-size: 90%;
+}
+
+.selectors {
+ margin: 1em;
+ background-color: #444;
+ width: 300px;
+ padding: 8px;
+ border-radius: 4px;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+
+}
+.selectors .selector {
+ background-color: #333;
+ padding: .4em;
+ margin: 1px;
+ cursor: pointer;
+}
+
+.selectors .selector.inuse {
+ border: 1px solid #9f9;
+ margin: -1px;
+ margin-left: 0px;
+}
+
+.results.error {
+ color: #f99;
+}
+
+.results {
+ color: #9f9;
+ font-size: 90%;
+ width: 300px;
+}
+
+#cred, #code {
+ padding-top: 2em;
+}
+
+p.psst {
+ margin-top: 4em;
+ font-size: .9em;
+}
+
+p.item {
+ margin-top: 2em;
+ margin-left: 1em;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/index.html
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/index.html b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/index.html
new file mode 100644
index 0000000..984e184
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/index.html
@@ -0,0 +1,139 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title> JSONSelect </title>
+ <link href='css/droid_sans.css' rel='stylesheet' type='text/css'>
+ <link href='css/style.css' type='text/css' rel='stylesheet'>
+ </head>
+ <body>
+ <div id="header">
+ <div class="content">
+ <div class="title">json<b>:</b>select<b>()</b></div>
+ <div class="nav"> <a href="#overview">Overview</a> | <a href="#tryit">Try It!</a> | <a href="#docs">Docs</a> | <a href="#code">Code</a> | <a href="mailto:jsonselect@librelist.com">Contact</a> | <a href="#cred">Credit</a> </div>
+ <div class="subtitle">CSS-like selectors for JSON.</div>
+ </div>
+ </div>
+ <div id="main">
+ <div style="display: none" id="splash" class="content">
+ <div class="sample json">
+ <tt>".author .drinkPref :first-child"</tt>
+ <pre>{
+ "author": {
+ "name": {
+ "first": "Lloyd",
+ "last": "Hilaiel"
+ },
+ "drinkPref": [
+ <span class="selected">"whiskey"</span>,
+ "beer",
+ "wine"
+ ],
+ },
+ "thing": "JSONSelect site",
+ "license": "<a href="http://creativecommons.org/licenses/by-sa/3.0/us/">(cc) BY-SA</a>"
+}</pre></div>
+ <div class="pitch">
+ <p>JSONSelect is an <i>experimental</i> selector language for JSON.</p>
+ <p>It makes it easy to access data in complex JSON documents.</p>
+ <p>It <i>feels like</i> CSS.</p>
+ <p>Why not <a href="#tryit">give it a try</a>?
+ </div>
+ </div>
+ <div id="tryit" style="display: none" class="content">
+ <div class="current"> Current Selector (click to edit): <input type="text"></input><span class="results"></span></div>
+ <pre class="doc json">
+{
+ "name": {
+ "first": "Lloyd",
+ "last": "Hilaiel"
+ },
+ "favoriteColor": "yellow",
+ "languagesSpoken": [
+ {
+ "lang": "Bulgarian",
+ "level": "advanced"
+ },
+ {
+ "lang": "English",
+ "level": "native",
+ "preferred": true
+ },
+ {
+ "lang": "Spanish",
+ "level": "beginner"
+ }
+ ],
+ "seatingPreference": [
+ "window",
+ "aisle"
+ ],
+ "drinkPreference": [
+ "whiskey",
+ "beer",
+ "wine"
+ ],
+ "weight": 172
+}
+ </pre>
+ <div class="selectors">
+ <div class="title"> Choose A Selector... </div>
+ <div class="selector">.languagesSpoken .lang</div>
+ <div class="selector">.drinkPreference :first-child</div>
+ <div class="selector">."weight"</div>
+ <div class="selector">.lang</div>
+ <div class="selector">.favoriteColor</div>
+ <div class="selector">string.favoriteColor</div>
+ <div class="selector">string:last-child</div>
+ <div class="selector">string:nth-child(-n+2)</div>
+ <div class="selector">string:nth-child(odd)</div>
+ <div class="selector">string:nth-last-child(1)</div>
+ <div class="selector">:root</div>
+ <div class="selector">number</div>
+ <div class="selector">:has(:root > .preferred)</div>
+ <div class="selector">.preferred ~ .lang</div>
+ <div class="selector">:has(.lang:val("Spanish")) > .level</div>
+ <div class="selector">.lang:val("Bulgarian") ~ .level</div>
+ <div class="selector">.seatingPreference :nth-child(1)</div>
+ <div class="selector">.weight:expr(x<180) ~ .name .first</div>
+ </div>
+ </div>
+ <div style="display: none" id="cred" class="content">
+ <p>JSONSelect is dedicated to sad code everywhere that looks like this:</p>
+ <pre class="json">if (foo && foo.bar && foo.bar.baz && foo.bar.baz.length > 2)
+ return foo.bar.baz[2];
+return undefined;</pre>
+ <p><a href="http://trickyco.de/">Lloyd Hilaiel</a> started it, and is surrounded by many <a href="https://github.com/lloyd/JSONSelect/contributors">awesome contributors</a>.</p>
+ <p><a href="http://blog.mozilla.com/dherman/">Dave Herman</a> provided the name, and lots of encouragement.</p>
+ <p><a href="http://open-mike.org/">Mike Hanson</a> gave deep feedback and ideas.</p>
+ <p><a href="http://ejohn.org/">John Resig</a> unwittingly contributed his <a href="http://ejohn.org/blog/selectors-that-people-actually-use/">design thoughts</a>.</p>
+ <p>The jsonselect.org site design was inspired by <a href="http://www.stephenwildish.co.uk/">Stephen Wildish</a>.</p>
+ <p><a href="http://json.org/">JSON</a> and <a href="http://www.w3.org/TR/css3-selectors/">CSS3 Selectors</a> are the prerequisites to JSONSelect's existence, so thanks to you guys too.</p>
+ <p></p>
+ </div>
+ <div style="display: none" id="doc" class="content">
+ Loading documentation...
+ </div>
+ <div style="display: none" id="code" class="content">
+ <p>Several different implementations of JSONSelect are available:</p>
+ <p class="item"><b>JavaScript:</b> Get it <a href="js/jsonselect.js">documented</a>, or <a href="js/jsonselect.min.js">minified</a> (<i>2.9k</i> minified and gzipped).
+ The code is <a href="https://github.com/lloyd/JSONSelect">on github</a>.</p>
+ <p class="item"><b>node.js:</b> <tt>npm install JSONSelect</tt></p>
+ <p class="item"><b>ruby:</b> A gem by <a href="https://github.com/fd">Simon Menke</a>: <a href="https://github.com/fd/json_select">https://github.com/fd/json_select</a></p>
+ <p class="psst">
+ Something missing from this list? Please, <a href="https://github.com/lloyd/JSONSelect/issues">tell me about it</a>.
+ </p>
+ </div>
+
+ </div>
+
+
+<a href="https://github.com/lloyd/JSONSelect"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://d3nwyuy0nl342s.cloudfront.net/img/4c7dc970b89fd04b81c8e221ba88ff99a06c6b61/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub"></a>
+ </body>
+ <script src="js/json2.js"></script>
+ <script src="js/showdown.js"></script>
+ <script src="js/jquery-1.6.1.min.js"></script>
+ <script src="js/jquery.ba-hashchange.min.js"></script>
+ <script src="js/jsonselect.js"></script>
+ <script src="js/nav.js"></script>
+ <script src="js/demo.js"></script>
+</html>
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/demo.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/demo.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/demo.js
new file mode 100644
index 0000000..7462cf9
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/site/js/demo.js
@@ -0,0 +1,64 @@
+window.jsel = JSONSelect;
+
+$(document).ready(function() {
+ var theDoc = JSON.parse($("pre.doc").text());
+
+ function highlightMatches(ar) {
+ // first calculate match offsets
+ var wrk = [];
+ var html = $.trim(JSON.stringify(theDoc, undefined, 4));
+ var ss = "<span class=\"selected\">";
+ var es = "</span>";
+ for (var i = 0; i < ar.length; i++) {
+ var found = $.trim(JSON.stringify(ar[i], undefined, 4));
+ // turn the string into a regex to handle indentation
+ found = found.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&").replace(/\s+/gm, "\\s*");
+ var re = new RegExp(found, "m");
+ var m = re.exec(html);
+ if (!m) continue;
+ wrk.push({ off: m.index, typ: "s" });
+ wrk.push({ off: m[0].length+m.index, typ: "e" });
+ }
+ // sort by offset
+ wrk = wrk.sort(function(a,b) { return a.off - b.off; });
+
+ // now start injecting spans into the text
+ var cur = 0;
+ var cons = 0;
+ for (var i = 0; i < wrk.length; i++) {
+ var diff = wrk[i].off - cons;
+ cons = wrk[i].off;
+ var tag = (wrk[i].typ == 's' ? ss : es);
+ cur += diff;
+ html = html.substr(0, cur) + tag + html.substr(cur);
+ cur += tag.length;
+ }
+ return html;
+ }
+
+ // when a selector is chosen, update the text box
+ $(".selectors .selector").click(function() {
+ $(".current input").val($(this).text()).keyup();
+ });
+
+ var lastSel;
+ $(".current input").keyup(function () {
+ try {
+ var sel = $(".current input").val()
+ if (lastSel === $.trim(sel)) return;
+ lastSel = $.trim(sel);
+ var ar = jsel.match(sel, theDoc);
+ $(".current .results").text(ar.length + " match" + (ar.length == 1 ? "" : "es"))
+ .removeClass("error");
+ $("pre.doc").html(highlightMatches(ar));
+ $("pre.doc .selected").hide().fadeIn(700);
+ } catch(e) {
+ $(".current .results").text(e.toString()).addClass("error");
+ $("pre.doc").text($.trim(JSON.stringify(theDoc, undefined, 4)));
+ }
+ $(".selectors .selector").removeClass("inuse");
+ $(".selectors div.selector").each(function() {
+ if ($(this).text() === sel) $(this).addClass("inuse");
+ });
+ });
+});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[20/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/filter.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/filter.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/filter.js
new file mode 100644
index 0000000..a4b8ae7
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/filter.js
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+ var isArray = require("./util.js").isArray;
+
+ function Promise$_filter(booleans) {
+ var values = this._settledValue;
+ var len = values.length;
+ var ret = new Array(len);
+ var j = 0;
+
+ for (var i = 0; i < len; ++i) {
+ if (booleans[i]) ret[j++] = values[i];
+
+ }
+ ret.length = j;
+ return ret;
+ }
+
+ var ref = {ref: null};
+ Promise.filter = function Promise$Filter(promises, fn) {
+ return Promise.map(promises, fn, ref)
+ ._then(Promise$_filter, void 0, void 0,
+ ref.ref, void 0, Promise.filter);
+ };
+
+ Promise.prototype.filter = function Promise$filter(fn) {
+ return this.map(fn, ref)
+ ._then(Promise$_filter, void 0, void 0,
+ ref.ref, void 0, this.filter);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/finally.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/finally.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/finally.js
new file mode 100644
index 0000000..ef1e0ef
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/finally.js
@@ -0,0 +1,132 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, NEXT_FILTER) {
+ var util = require("./util.js");
+ var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;
+ var isPrimitive = util.isPrimitive;
+ var thrower = util.thrower;
+
+
+ function returnThis() {
+ return this;
+ }
+ function throwThis() {
+ throw this;
+ }
+ function makeReturner(r) {
+ return function Promise$_returner() {
+ return r;
+ };
+ }
+ function makeThrower(r) {
+ return function Promise$_thrower() {
+ throw r;
+ };
+ }
+ function promisedFinally(ret, reasonOrValue, isFulfilled) {
+ var useConstantFunction =
+ wrapsPrimitiveReceiver && isPrimitive(reasonOrValue);
+
+ if (isFulfilled) {
+ return ret._then(
+ useConstantFunction
+ ? returnThis
+ : makeReturner(reasonOrValue),
+ thrower, void 0, reasonOrValue, void 0, promisedFinally);
+ }
+ else {
+ return ret._then(
+ useConstantFunction
+ ? throwThis
+ : makeThrower(reasonOrValue),
+ thrower, void 0, reasonOrValue, void 0, promisedFinally);
+ }
+ }
+
+ function finallyHandler(reasonOrValue) {
+ var promise = this.promise;
+ var handler = this.handler;
+
+ var ret = promise._isBound()
+ ? handler.call(promise._boundTo)
+ : handler();
+
+ if (ret !== void 0) {
+ var maybePromise = Promise._cast(ret, finallyHandler, void 0);
+ if (maybePromise instanceof Promise) {
+ return promisedFinally(maybePromise, reasonOrValue,
+ promise.isFulfilled());
+ }
+ }
+
+ if (promise.isRejected()) {
+ NEXT_FILTER.e = reasonOrValue;
+ return NEXT_FILTER;
+ }
+ else {
+ return reasonOrValue;
+ }
+ }
+
+ function tapHandler(value) {
+ var promise = this.promise;
+ var handler = this.handler;
+
+ var ret = promise._isBound()
+ ? handler.call(promise._boundTo, value)
+ : handler(value);
+
+ if (ret !== void 0) {
+ var maybePromise = Promise._cast(ret, tapHandler, void 0);
+ if (maybePromise instanceof Promise) {
+ return promisedFinally(maybePromise, value, true);
+ }
+ }
+ return value;
+ }
+
+ Promise.prototype._passThroughHandler =
+ function Promise$_passThroughHandler(handler, isFinally, caller) {
+ if (typeof handler !== "function") return this.then();
+
+ var promiseAndHandler = {
+ promise: this,
+ handler: handler
+ };
+
+ return this._then(
+ isFinally ? finallyHandler : tapHandler,
+ isFinally ? finallyHandler : void 0, void 0,
+ promiseAndHandler, void 0, caller);
+ };
+
+ Promise.prototype.lastly =
+ Promise.prototype["finally"] = function Promise$finally(handler) {
+ return this._passThroughHandler(handler, true, this.lastly);
+ };
+
+ Promise.prototype.tap = function Promise$tap(handler) {
+ return this._passThroughHandler(handler, false, this.tap);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/generators.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/generators.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/generators.js
new file mode 100644
index 0000000..9632ae7
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/generators.js
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, apiRejection, INTERNAL) {
+ var PromiseSpawn = require("./promise_spawn.js")(Promise, INTERNAL);
+ var errors = require("./errors.js");
+ var TypeError = errors.TypeError;
+ var deprecated = require("./util.js").deprecated;
+
+ Promise.coroutine = function Promise$Coroutine(generatorFunction) {
+ if (typeof generatorFunction !== "function") {
+ throw new TypeError("generatorFunction must be a function");
+ }
+ var PromiseSpawn$ = PromiseSpawn;
+ return function anonymous() {
+ var generator = generatorFunction.apply(this, arguments);
+ var spawn = new PromiseSpawn$(void 0, void 0, anonymous);
+ spawn._generator = generator;
+ spawn._next(void 0);
+ return spawn.promise();
+ };
+ };
+
+ Promise.coroutine.addYieldHandler = PromiseSpawn.addYieldHandler;
+
+ Promise.spawn = function Promise$Spawn(generatorFunction) {
+ deprecated("Promise.spawn is deprecated. Use Promise.coroutine instead.");
+ if (typeof generatorFunction !== "function") {
+ return apiRejection("generatorFunction must be a function");
+ }
+ var spawn = new PromiseSpawn(generatorFunction, this, Promise.spawn);
+ var ret = spawn.promise();
+ spawn._run(Promise.spawn);
+ return ret;
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/global.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/global.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/global.js
new file mode 100644
index 0000000..1ab1947
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/global.js
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = (function(){
+ if (typeof this !== "undefined") {
+ return this;
+ }
+ if (typeof process !== "undefined" &&
+ typeof global !== "undefined" &&
+ typeof process.execPath === "string") {
+ return global;
+ }
+ if (typeof window !== "undefined" &&
+ typeof document !== "undefined" &&
+ typeof navigator !== "undefined" && navigator !== null &&
+ typeof navigator.appName === "string") {
+ if(window.wrappedJSObject !== undefined){
+ return window.wrappedJSObject;
+ }
+ return window;
+ }
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/map.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/map.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/map.js
new file mode 100644
index 0000000..b2a36b0
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/map.js
@@ -0,0 +1,127 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(
+ Promise, Promise$_CreatePromiseArray, PromiseArray, apiRejection) {
+
+ function Promise$_mapper(values) {
+ var fn = this;
+ var receiver = void 0;
+
+ if (typeof fn !== "function") {
+ receiver = fn.receiver;
+ fn = fn.fn;
+ }
+ var shouldDefer = false;
+
+ var ret = new Array(values.length);
+
+ if (receiver === void 0) {
+ for (var i = 0, len = values.length; i < len; ++i) {
+ var value = fn(values[i], i, len);
+ if (!shouldDefer) {
+ var maybePromise = Promise._cast(value,
+ Promise$_mapper, void 0);
+ if (maybePromise instanceof Promise) {
+ if (maybePromise.isFulfilled()) {
+ ret[i] = maybePromise._settledValue;
+ continue;
+ }
+ else {
+ shouldDefer = true;
+ }
+ value = maybePromise;
+ }
+ }
+ ret[i] = value;
+ }
+ }
+ else {
+ for (var i = 0, len = values.length; i < len; ++i) {
+ var value = fn.call(receiver, values[i], i, len);
+ if (!shouldDefer) {
+ var maybePromise = Promise._cast(value,
+ Promise$_mapper, void 0);
+ if (maybePromise instanceof Promise) {
+ if (maybePromise.isFulfilled()) {
+ ret[i] = maybePromise._settledValue;
+ continue;
+ }
+ else {
+ shouldDefer = true;
+ }
+ value = maybePromise;
+ }
+ }
+ ret[i] = value;
+ }
+ }
+ return shouldDefer
+ ? Promise$_CreatePromiseArray(ret, PromiseArray,
+ Promise$_mapper, void 0).promise()
+ : ret;
+ }
+
+ function Promise$_Map(promises, fn, useBound, caller, ref) {
+ if (typeof fn !== "function") {
+ return apiRejection("fn must be a function");
+ }
+
+ if (useBound === true && promises._isBound()) {
+ fn = {
+ fn: fn,
+ receiver: promises._boundTo
+ };
+ }
+
+ var ret = Promise$_CreatePromiseArray(
+ promises,
+ PromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ ).promise();
+
+ if (ref !== void 0) {
+ ref.ref = ret;
+ }
+
+ return ret._then(
+ Promise$_mapper,
+ void 0,
+ void 0,
+ fn,
+ void 0,
+ caller
+ );
+ }
+
+ Promise.prototype.map = function Promise$map(fn, ref) {
+ return Promise$_Map(this, fn, true, this.map, ref);
+ };
+
+ Promise.map = function Promise$Map(promises, fn, ref) {
+ return Promise$_Map(promises, fn, false, Promise.map, ref);
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/nodeify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/nodeify.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/nodeify.js
new file mode 100644
index 0000000..9fe25f9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/nodeify.js
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise) {
+ var util = require("./util.js");
+ var async = require("./async.js");
+ var tryCatch2 = util.tryCatch2;
+ var tryCatch1 = util.tryCatch1;
+ var errorObj = util.errorObj;
+
+ function thrower(r) {
+ throw r;
+ }
+
+ function Promise$_successAdapter(val, receiver) {
+ var nodeback = this;
+ var ret = tryCatch2(nodeback, receiver, null, val);
+ if (ret === errorObj) {
+ async.invokeLater(thrower, void 0, ret.e);
+ }
+ }
+ function Promise$_errorAdapter(reason, receiver) {
+ var nodeback = this;
+ var ret = tryCatch1(nodeback, receiver, reason);
+ if (ret === errorObj) {
+ async.invokeLater(thrower, void 0, ret.e);
+ }
+ }
+
+ Promise.prototype.nodeify = function Promise$nodeify(nodeback) {
+ if (typeof nodeback == "function") {
+ this._then(
+ Promise$_successAdapter,
+ Promise$_errorAdapter,
+ void 0,
+ nodeback,
+ this._isBound() ? this._boundTo : null,
+ this.nodeify
+ );
+ return;
+ }
+ return this;
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/progress.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/progress.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/progress.js
new file mode 100644
index 0000000..668f5f7
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/progress.js
@@ -0,0 +1,111 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, isPromiseArrayProxy) {
+ var util = require("./util.js");
+ var async = require("./async.js");
+ var errors = require("./errors.js");
+ var tryCatch1 = util.tryCatch1;
+ var errorObj = util.errorObj;
+
+ Promise.prototype.progressed = function Promise$progressed(handler) {
+ return this._then(void 0, void 0, handler,
+ void 0, void 0, this.progressed);
+ };
+
+ Promise.prototype._progress = function Promise$_progress(progressValue) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._progressUnchecked(progressValue);
+
+ };
+
+ Promise.prototype._progressHandlerAt =
+ function Promise$_progressHandlerAt(index) {
+ if (index === 0) return this._progressHandler0;
+ return this[index + 2 - 5];
+ };
+
+ Promise.prototype._doProgressWith =
+ function Promise$_doProgressWith(progression) {
+ var progressValue = progression.value;
+ var handler = progression.handler;
+ var promise = progression.promise;
+ var receiver = progression.receiver;
+
+ this._pushContext();
+ var ret = tryCatch1(handler, receiver, progressValue);
+ this._popContext();
+
+ if (ret === errorObj) {
+ if (ret.e != null &&
+ ret.e.name !== "StopProgressPropagation") {
+ var trace = errors.canAttach(ret.e)
+ ? ret.e : new Error(ret.e + "");
+ promise._attachExtraTrace(trace);
+ promise._progress(ret.e);
+ }
+ }
+ else if (Promise.is(ret)) {
+ ret._then(promise._progress, null, null, promise, void 0,
+ this._progress);
+ }
+ else {
+ promise._progress(ret);
+ }
+ };
+
+
+ Promise.prototype._progressUnchecked =
+ function Promise$_progressUnchecked(progressValue) {
+ if (!this.isPending()) return;
+ var len = this._length();
+
+ for (var i = 0; i < len; i += 5) {
+ var handler = this._progressHandlerAt(i);
+ var promise = this._promiseAt(i);
+ if (!Promise.is(promise)) {
+ var receiver = this._receiverAt(i);
+ if (typeof handler === "function") {
+ handler.call(receiver, progressValue, promise);
+ }
+ else if (Promise.is(receiver) && receiver._isProxied()) {
+ receiver._progressUnchecked(progressValue);
+ }
+ else if (isPromiseArrayProxy(receiver, promise)) {
+ receiver._promiseProgressed(progressValue, promise);
+ }
+ continue;
+ }
+
+ if (typeof handler === "function") {
+ this._doProgressWith(({handler: handler,
+promise: promise,
+receiver: this._receiverAt(i),
+value: progressValue}));
+ }
+ else {
+ promise._progress(progressValue);
+ }
+ }
+ };
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise.js
new file mode 100644
index 0000000..f1c9ddc
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise.js
@@ -0,0 +1,1167 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function() {
+var global = require("./global.js");
+var util = require("./util.js");
+var async = require("./async.js");
+var errors = require("./errors.js");
+
+var INTERNAL = function(){};
+var APPLY = {};
+var NEXT_FILTER = {e: null};
+
+var PromiseArray = require("./promise_array.js")(Promise, INTERNAL);
+var CapturedTrace = require("./captured_trace.js")();
+var CatchFilter = require("./catch_filter.js")(NEXT_FILTER);
+var PromiseResolver = require("./promise_resolver.js");
+
+var isArray = util.isArray;
+
+var errorObj = util.errorObj;
+var tryCatch1 = util.tryCatch1;
+var tryCatch2 = util.tryCatch2;
+var tryCatchApply = util.tryCatchApply;
+var RangeError = errors.RangeError;
+var TypeError = errors.TypeError;
+var CancellationError = errors.CancellationError;
+var TimeoutError = errors.TimeoutError;
+var RejectionError = errors.RejectionError;
+var originatesFromRejection = errors.originatesFromRejection;
+var markAsOriginatingFromRejection = errors.markAsOriginatingFromRejection;
+var canAttach = errors.canAttach;
+var thrower = util.thrower;
+var apiRejection = require("./errors_api_rejection")(Promise);
+
+
+var makeSelfResolutionError = function Promise$_makeSelfResolutionError() {
+ return new TypeError("circular promise resolution chain");
+};
+
+function isPromise(obj) {
+ if (obj === void 0) return false;
+ return obj instanceof Promise;
+}
+
+function isPromiseArrayProxy(receiver, promiseSlotValue) {
+ if (receiver instanceof PromiseArray) {
+ return promiseSlotValue >= 0;
+ }
+ return false;
+}
+
+function Promise(resolver) {
+ if (typeof resolver !== "function") {
+ throw new TypeError("the promise constructor requires a resolver function");
+ }
+ if (this.constructor !== Promise) {
+ throw new TypeError("the promise constructor cannot be invoked directly");
+ }
+ this._bitField = 0;
+ this._fulfillmentHandler0 = void 0;
+ this._rejectionHandler0 = void 0;
+ this._promise0 = void 0;
+ this._receiver0 = void 0;
+ this._settledValue = void 0;
+ this._boundTo = void 0;
+ if (resolver !== INTERNAL) this._resolveFromResolver(resolver);
+}
+
+Promise.prototype.bind = function Promise$bind(thisArg) {
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(this.bind, this);
+ ret._follow(this);
+ ret._setBoundTo(thisArg);
+ if (this._cancellable()) {
+ ret._setCancellable();
+ ret._cancellationParent = this;
+ }
+ return ret;
+};
+
+Promise.prototype.toString = function Promise$toString() {
+ return "[object Promise]";
+};
+
+Promise.prototype.caught = Promise.prototype["catch"] =
+function Promise$catch(fn) {
+ var len = arguments.length;
+ if (len > 1) {
+ var catchInstances = new Array(len - 1),
+ j = 0, i;
+ for (i = 0; i < len - 1; ++i) {
+ var item = arguments[i];
+ if (typeof item === "function") {
+ catchInstances[j++] = item;
+ }
+ else {
+ var catchFilterTypeError =
+ new TypeError(
+ "A catch filter must be an error constructor "
+ + "or a filter function");
+
+ this._attachExtraTrace(catchFilterTypeError);
+ this._reject(catchFilterTypeError);
+ return;
+ }
+ }
+ catchInstances.length = j;
+ fn = arguments[i];
+
+ this._resetTrace(this.caught);
+ var catchFilter = new CatchFilter(catchInstances, fn, this);
+ return this._then(void 0, catchFilter.doFilter, void 0,
+ catchFilter, void 0, this.caught);
+ }
+ return this._then(void 0, fn, void 0, void 0, void 0, this.caught);
+};
+
+Promise.prototype.then =
+function Promise$then(didFulfill, didReject, didProgress) {
+ return this._then(didFulfill, didReject, didProgress,
+ void 0, void 0, this.then);
+};
+
+
+Promise.prototype.done =
+function Promise$done(didFulfill, didReject, didProgress) {
+ var promise = this._then(didFulfill, didReject, didProgress,
+ void 0, void 0, this.done);
+ promise._setIsFinal();
+};
+
+Promise.prototype.spread = function Promise$spread(didFulfill, didReject) {
+ return this._then(didFulfill, didReject, void 0,
+ APPLY, void 0, this.spread);
+};
+
+Promise.prototype.isFulfilled = function Promise$isFulfilled() {
+ return (this._bitField & 268435456) > 0;
+};
+
+
+Promise.prototype.isRejected = function Promise$isRejected() {
+ return (this._bitField & 134217728) > 0;
+};
+
+Promise.prototype.isPending = function Promise$isPending() {
+ return !this.isResolved();
+};
+
+
+Promise.prototype.isResolved = function Promise$isResolved() {
+ return (this._bitField & 402653184) > 0;
+};
+
+
+Promise.prototype.isCancellable = function Promise$isCancellable() {
+ return !this.isResolved() &&
+ this._cancellable();
+};
+
+Promise.prototype.toJSON = function Promise$toJSON() {
+ var ret = {
+ isFulfilled: false,
+ isRejected: false,
+ fulfillmentValue: void 0,
+ rejectionReason: void 0
+ };
+ if (this.isFulfilled()) {
+ ret.fulfillmentValue = this._settledValue;
+ ret.isFulfilled = true;
+ }
+ else if (this.isRejected()) {
+ ret.rejectionReason = this._settledValue;
+ ret.isRejected = true;
+ }
+ return ret;
+};
+
+Promise.prototype.all = function Promise$all() {
+ return Promise$_all(this, true, this.all);
+};
+
+
+Promise.is = isPromise;
+
+function Promise$_all(promises, useBound, caller) {
+ return Promise$_CreatePromiseArray(
+ promises,
+ PromiseArray,
+ caller,
+ useBound === true && promises._isBound()
+ ? promises._boundTo
+ : void 0
+ ).promise();
+}
+Promise.all = function Promise$All(promises) {
+ return Promise$_all(promises, false, Promise.all);
+};
+
+Promise.join = function Promise$Join() {
+ var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
+ return Promise$_CreatePromiseArray(
+ args, PromiseArray, Promise.join, void 0).promise();
+};
+
+Promise.resolve = Promise.fulfilled =
+function Promise$Resolve(value, caller) {
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(typeof caller === "function"
+ ? caller
+ : Promise.resolve, void 0);
+ if (ret._tryFollow(value)) {
+ return ret;
+ }
+ ret._cleanValues();
+ ret._setFulfilled();
+ ret._settledValue = value;
+ return ret;
+};
+
+Promise.reject = Promise.rejected = function Promise$Reject(reason) {
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(Promise.reject, void 0);
+ markAsOriginatingFromRejection(reason);
+ ret._cleanValues();
+ ret._setRejected();
+ ret._settledValue = reason;
+ if (!canAttach(reason)) {
+ var trace = new Error(reason + "");
+ ret._setCarriedStackTrace(trace);
+ }
+ ret._ensurePossibleRejectionHandled();
+ return ret;
+};
+
+Promise.prototype.error = function Promise$_error(fn) {
+ return this.caught(originatesFromRejection, fn);
+};
+
+Promise.prototype._resolveFromSyncValue =
+function Promise$_resolveFromSyncValue(value, caller) {
+ if (value === errorObj) {
+ this._cleanValues();
+ this._setRejected();
+ this._settledValue = value.e;
+ this._ensurePossibleRejectionHandled();
+ }
+ else {
+ var maybePromise = Promise._cast(value, caller, void 0);
+ if (maybePromise instanceof Promise) {
+ this._follow(maybePromise);
+ }
+ else {
+ this._cleanValues();
+ this._setFulfilled();
+ this._settledValue = value;
+ }
+ }
+};
+
+Promise.method = function Promise$_Method(fn) {
+ if (typeof fn !== "function") {
+ throw new TypeError("fn must be a function");
+ }
+ return function Promise$_method() {
+ var value;
+ switch(arguments.length) {
+ case 0: value = tryCatch1(fn, this, void 0); break;
+ case 1: value = tryCatch1(fn, this, arguments[0]); break;
+ case 2: value = tryCatch2(fn, this, arguments[0], arguments[1]); break;
+ default:
+ var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
+ value = tryCatchApply(fn, args, this); break;
+ }
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(Promise$_method, void 0);
+ ret._resolveFromSyncValue(value, Promise$_method);
+ return ret;
+ };
+};
+
+Promise.attempt = Promise["try"] = function Promise$_Try(fn, args, ctx) {
+
+ if (typeof fn !== "function") {
+ return apiRejection("fn must be a function");
+ }
+ var value = isArray(args)
+ ? tryCatchApply(fn, args, ctx)
+ : tryCatch1(fn, ctx, args);
+
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(Promise.attempt, void 0);
+ ret._resolveFromSyncValue(value, Promise.attempt);
+ return ret;
+};
+
+Promise.defer = Promise.pending = function Promise$Defer(caller) {
+ var promise = new Promise(INTERNAL);
+ if (debugging) promise._setTrace(typeof caller === "function"
+ ? caller : Promise.defer, void 0);
+ return new PromiseResolver(promise);
+};
+
+Promise.bind = function Promise$Bind(thisArg) {
+ var ret = new Promise(INTERNAL);
+ if (debugging) ret._setTrace(Promise.bind, void 0);
+ ret._setFulfilled();
+ ret._setBoundTo(thisArg);
+ return ret;
+};
+
+Promise.cast = function Promise$_Cast(obj, caller) {
+ if (typeof caller !== "function") {
+ caller = Promise.cast;
+ }
+ var ret = Promise._cast(obj, caller, void 0);
+ if (!(ret instanceof Promise)) {
+ return Promise.resolve(ret, caller);
+ }
+ return ret;
+};
+
+Promise.onPossiblyUnhandledRejection =
+function Promise$OnPossiblyUnhandledRejection(fn) {
+ if (typeof fn === "function") {
+ CapturedTrace.possiblyUnhandledRejection = fn;
+ }
+ else {
+ CapturedTrace.possiblyUnhandledRejection = void 0;
+ }
+};
+
+var debugging = false || !!(
+ typeof process !== "undefined" &&
+ typeof process.execPath === "string" &&
+ typeof process.env === "object" &&
+ (process.env["BLUEBIRD_DEBUG"] ||
+ process.env["NODE_ENV"] === "development")
+);
+
+
+Promise.longStackTraces = function Promise$LongStackTraces() {
+ if (async.haveItemsQueued() &&
+ debugging === false
+ ) {
+ throw new Error("cannot enable long stack traces after promises have been created");
+ }
+ debugging = CapturedTrace.isSupported();
+};
+
+Promise.hasLongStackTraces = function Promise$HasLongStackTraces() {
+ return debugging && CapturedTrace.isSupported();
+};
+
+Promise.prototype._setProxyHandlers =
+function Promise$_setProxyHandlers(receiver, promiseSlotValue) {
+ var index = this._length();
+
+ if (index >= 1048575 - 5) {
+ index = 0;
+ this._setLength(0);
+ }
+ if (index === 0) {
+ this._promise0 = promiseSlotValue;
+ this._receiver0 = receiver;
+ }
+ else {
+ var i = index - 5;
+ this[i + 3] = promiseSlotValue;
+ this[i + 4] = receiver;
+ this[i + 0] =
+ this[i + 1] =
+ this[i + 2] = void 0;
+ }
+ this._setLength(index + 5);
+};
+
+Promise.prototype._proxyPromiseArray =
+function Promise$_proxyPromiseArray(promiseArray, index) {
+ this._setProxyHandlers(promiseArray, index);
+};
+
+Promise.prototype._proxyPromise = function Promise$_proxyPromise(promise) {
+ promise._setProxied();
+ this._setProxyHandlers(promise, -1);
+};
+
+Promise.prototype._then =
+function Promise$_then(
+ didFulfill,
+ didReject,
+ didProgress,
+ receiver,
+ internalData,
+ caller
+) {
+ var haveInternalData = internalData !== void 0;
+ var ret = haveInternalData ? internalData : new Promise(INTERNAL);
+
+ if (debugging && !haveInternalData) {
+ var haveSameContext = this._peekContext() === this._traceParent;
+ ret._traceParent = haveSameContext ? this._traceParent : this;
+ ret._setTrace(typeof caller === "function"
+ ? caller
+ : this._then, this);
+ }
+
+ if (!haveInternalData && this._isBound()) {
+ ret._setBoundTo(this._boundTo);
+ }
+
+ var callbackIndex =
+ this._addCallbacks(didFulfill, didReject, didProgress, ret, receiver);
+
+ if (!haveInternalData && this._cancellable()) {
+ ret._setCancellable();
+ ret._cancellationParent = this;
+ }
+
+ if (this.isResolved()) {
+ this._queueSettleAt(callbackIndex);
+ }
+
+ return ret;
+};
+
+Promise.prototype._length = function Promise$_length() {
+ return this._bitField & 1048575;
+};
+
+Promise.prototype._isFollowingOrFulfilledOrRejected =
+function Promise$_isFollowingOrFulfilledOrRejected() {
+ return (this._bitField & 939524096) > 0;
+};
+
+Promise.prototype._isFollowing = function Promise$_isFollowing() {
+ return (this._bitField & 536870912) === 536870912;
+};
+
+Promise.prototype._setLength = function Promise$_setLength(len) {
+ this._bitField = (this._bitField & -1048576) |
+ (len & 1048575);
+};
+
+Promise.prototype._setFulfilled = function Promise$_setFulfilled() {
+ this._bitField = this._bitField | 268435456;
+};
+
+Promise.prototype._setRejected = function Promise$_setRejected() {
+ this._bitField = this._bitField | 134217728;
+};
+
+Promise.prototype._setFollowing = function Promise$_setFollowing() {
+ this._bitField = this._bitField | 536870912;
+};
+
+Promise.prototype._setIsFinal = function Promise$_setIsFinal() {
+ this._bitField = this._bitField | 33554432;
+};
+
+Promise.prototype._isFinal = function Promise$_isFinal() {
+ return (this._bitField & 33554432) > 0;
+};
+
+Promise.prototype._cancellable = function Promise$_cancellable() {
+ return (this._bitField & 67108864) > 0;
+};
+
+Promise.prototype._setCancellable = function Promise$_setCancellable() {
+ this._bitField = this._bitField | 67108864;
+};
+
+Promise.prototype._unsetCancellable = function Promise$_unsetCancellable() {
+ this._bitField = this._bitField & (~67108864);
+};
+
+Promise.prototype._setRejectionIsUnhandled =
+function Promise$_setRejectionIsUnhandled() {
+ this._bitField = this._bitField | 2097152;
+};
+
+Promise.prototype._unsetRejectionIsUnhandled =
+function Promise$_unsetRejectionIsUnhandled() {
+ this._bitField = this._bitField & (~2097152);
+};
+
+Promise.prototype._isRejectionUnhandled =
+function Promise$_isRejectionUnhandled() {
+ return (this._bitField & 2097152) > 0;
+};
+
+Promise.prototype._setCarriedStackTrace =
+function Promise$_setCarriedStackTrace(capturedTrace) {
+ this._bitField = this._bitField | 1048576;
+ this._fulfillmentHandler0 = capturedTrace;
+};
+
+Promise.prototype._unsetCarriedStackTrace =
+function Promise$_unsetCarriedStackTrace() {
+ this._bitField = this._bitField & (~1048576);
+ this._fulfillmentHandler0 = void 0;
+};
+
+Promise.prototype._isCarryingStackTrace =
+function Promise$_isCarryingStackTrace() {
+ return (this._bitField & 1048576) > 0;
+};
+
+Promise.prototype._getCarriedStackTrace =
+function Promise$_getCarriedStackTrace() {
+ return this._isCarryingStackTrace()
+ ? this._fulfillmentHandler0
+ : void 0;
+};
+
+Promise.prototype._receiverAt = function Promise$_receiverAt(index) {
+ var ret;
+ if (index === 0) {
+ ret = this._receiver0;
+ }
+ else {
+ ret = this[index + 4 - 5];
+ }
+ if (this._isBound() && ret === void 0) {
+ return this._boundTo;
+ }
+ return ret;
+};
+
+Promise.prototype._promiseAt = function Promise$_promiseAt(index) {
+ if (index === 0) return this._promise0;
+ return this[index + 3 - 5];
+};
+
+Promise.prototype._fulfillmentHandlerAt =
+function Promise$_fulfillmentHandlerAt(index) {
+ if (index === 0) return this._fulfillmentHandler0;
+ return this[index + 0 - 5];
+};
+
+Promise.prototype._rejectionHandlerAt =
+function Promise$_rejectionHandlerAt(index) {
+ if (index === 0) return this._rejectionHandler0;
+ return this[index + 1 - 5];
+};
+
+Promise.prototype._unsetAt = function Promise$_unsetAt(index) {
+ if (index === 0) {
+ this._rejectionHandler0 =
+ this._progressHandler0 =
+ this._promise0 =
+ this._receiver0 = void 0;
+ if (!this._isCarryingStackTrace()) {
+ this._fulfillmentHandler0 = void 0;
+ }
+ }
+ else {
+ this[index - 5 + 0] =
+ this[index - 5 + 1] =
+ this[index - 5 + 2] =
+ this[index - 5 + 3] =
+ this[index - 5 + 4] = void 0;
+ }
+};
+
+Promise.prototype._resolveFromResolver =
+function Promise$_resolveFromResolver(resolver) {
+ var promise = this;
+ var localDebugging = debugging;
+ if (localDebugging) {
+ this._setTrace(this._resolveFromResolver, void 0);
+ this._pushContext();
+ }
+ function Promise$_resolver(val) {
+ if (promise._tryFollow(val)) {
+ return;
+ }
+ promise._fulfill(val);
+ }
+ function Promise$_rejecter(val) {
+ var trace = canAttach(val) ? val : new Error(val + "");
+ promise._attachExtraTrace(trace);
+ markAsOriginatingFromRejection(val);
+ promise._reject(val, trace === val ? void 0 : trace);
+ }
+ var r = tryCatch2(resolver, void 0, Promise$_resolver, Promise$_rejecter);
+ if (localDebugging) this._popContext();
+
+ if (r !== void 0 && r === errorObj) {
+ var e = r.e;
+ var trace = canAttach(e) ? e : new Error(e + "");
+ promise._reject(e, trace);
+ }
+};
+
+Promise.prototype._addCallbacks = function Promise$_addCallbacks(
+ fulfill,
+ reject,
+ progress,
+ promise,
+ receiver
+) {
+ var index = this._length();
+
+ if (index >= 1048575 - 5) {
+ index = 0;
+ this._setLength(0);
+ }
+
+ if (index === 0) {
+ this._promise0 = promise;
+ if (receiver !== void 0) this._receiver0 = receiver;
+ if (typeof fulfill === "function" && !this._isCarryingStackTrace())
+ this._fulfillmentHandler0 = fulfill;
+ if (typeof reject === "function") this._rejectionHandler0 = reject;
+ if (typeof progress === "function") this._progressHandler0 = progress;
+ }
+ else {
+ var i = index - 5;
+ this[i + 3] = promise;
+ this[i + 4] = receiver;
+ this[i + 0] = typeof fulfill === "function"
+ ? fulfill : void 0;
+ this[i + 1] = typeof reject === "function"
+ ? reject : void 0;
+ this[i + 2] = typeof progress === "function"
+ ? progress : void 0;
+ }
+ this._setLength(index + 5);
+ return index;
+};
+
+
+
+Promise.prototype._setBoundTo = function Promise$_setBoundTo(obj) {
+ if (obj !== void 0) {
+ this._bitField = this._bitField | 8388608;
+ this._boundTo = obj;
+ }
+ else {
+ this._bitField = this._bitField & (~8388608);
+ }
+};
+
+Promise.prototype._isBound = function Promise$_isBound() {
+ return (this._bitField & 8388608) === 8388608;
+};
+
+Promise.prototype._spreadSlowCase =
+function Promise$_spreadSlowCase(targetFn, promise, values, boundTo) {
+ var promiseForAll =
+ Promise$_CreatePromiseArray
+ (values, PromiseArray, this._spreadSlowCase, boundTo)
+ .promise()
+ ._then(function() {
+ return targetFn.apply(boundTo, arguments);
+ }, void 0, void 0, APPLY, void 0, this._spreadSlowCase);
+
+ promise._follow(promiseForAll);
+};
+
+Promise.prototype._callSpread =
+function Promise$_callSpread(handler, promise, value, localDebugging) {
+ var boundTo = this._isBound() ? this._boundTo : void 0;
+ if (isArray(value)) {
+ var caller = this._settlePromiseFromHandler;
+ for (var i = 0, len = value.length; i < len; ++i) {
+ if (isPromise(Promise._cast(value[i], caller, void 0))) {
+ this._spreadSlowCase(handler, promise, value, boundTo);
+ return;
+ }
+ }
+ }
+ if (localDebugging) promise._pushContext();
+ return tryCatchApply(handler, value, boundTo);
+};
+
+Promise.prototype._callHandler =
+function Promise$_callHandler(
+ handler, receiver, promise, value, localDebugging) {
+ var x;
+ if (receiver === APPLY && !this.isRejected()) {
+ x = this._callSpread(handler, promise, value, localDebugging);
+ }
+ else {
+ if (localDebugging) promise._pushContext();
+ x = tryCatch1(handler, receiver, value);
+ }
+ if (localDebugging) promise._popContext();
+ return x;
+};
+
+Promise.prototype._settlePromiseFromHandler =
+function Promise$_settlePromiseFromHandler(
+ handler, receiver, value, promise
+) {
+ if (!isPromise(promise)) {
+ handler.call(receiver, value, promise);
+ return;
+ }
+
+ var localDebugging = debugging;
+ var x = this._callHandler(handler, receiver,
+ promise, value, localDebugging);
+
+ if (promise._isFollowing()) return;
+
+ if (x === errorObj || x === promise || x === NEXT_FILTER) {
+ var err = x === promise
+ ? makeSelfResolutionError()
+ : x.e;
+ var trace = canAttach(err) ? err : new Error(err + "");
+ if (x !== NEXT_FILTER) promise._attachExtraTrace(trace);
+ promise._rejectUnchecked(err, trace);
+ }
+ else {
+ var castValue = Promise._cast(x,
+ localDebugging ? this._settlePromiseFromHandler : void 0,
+ promise);
+
+ if (isPromise(castValue)) {
+ if (castValue.isRejected() &&
+ !castValue._isCarryingStackTrace() &&
+ !canAttach(castValue._settledValue)) {
+ var trace = new Error(castValue._settledValue + "");
+ promise._attachExtraTrace(trace);
+ castValue._setCarriedStackTrace(trace);
+ }
+ promise._follow(castValue);
+ if (castValue._cancellable()) {
+ promise._cancellationParent = castValue;
+ promise._setCancellable();
+ }
+ }
+ else {
+ promise._fulfillUnchecked(x);
+ }
+ }
+};
+
+Promise.prototype._follow =
+function Promise$_follow(promise) {
+ this._setFollowing();
+
+ if (promise.isPending()) {
+ if (promise._cancellable() ) {
+ this._cancellationParent = promise;
+ this._setCancellable();
+ }
+ promise._proxyPromise(this);
+ }
+ else if (promise.isFulfilled()) {
+ this._fulfillUnchecked(promise._settledValue);
+ }
+ else {
+ this._rejectUnchecked(promise._settledValue,
+ promise._getCarriedStackTrace());
+ }
+
+ if (promise._isRejectionUnhandled()) promise._unsetRejectionIsUnhandled();
+
+ if (debugging &&
+ promise._traceParent == null) {
+ promise._traceParent = this;
+ }
+};
+
+Promise.prototype._tryFollow =
+function Promise$_tryFollow(value) {
+ if (this._isFollowingOrFulfilledOrRejected() ||
+ value === this) {
+ return false;
+ }
+ var maybePromise = Promise._cast(value, this._tryFollow, void 0);
+ if (!isPromise(maybePromise)) {
+ return false;
+ }
+ this._follow(maybePromise);
+ return true;
+};
+
+Promise.prototype._resetTrace = function Promise$_resetTrace(caller) {
+ if (debugging) {
+ var context = this._peekContext();
+ var isTopLevel = context === void 0;
+ this._trace = new CapturedTrace(
+ typeof caller === "function"
+ ? caller
+ : this._resetTrace,
+ isTopLevel
+ );
+ }
+};
+
+Promise.prototype._setTrace = function Promise$_setTrace(caller, parent) {
+ if (debugging) {
+ var context = this._peekContext();
+ this._traceParent = context;
+ var isTopLevel = context === void 0;
+ if (parent !== void 0 &&
+ parent._traceParent === context) {
+ this._trace = parent._trace;
+ }
+ else {
+ this._trace = new CapturedTrace(
+ typeof caller === "function"
+ ? caller
+ : this._setTrace,
+ isTopLevel
+ );
+ }
+ }
+ return this;
+};
+
+Promise.prototype._attachExtraTrace =
+function Promise$_attachExtraTrace(error) {
+ if (debugging) {
+ var promise = this;
+ var stack = error.stack;
+ stack = typeof stack === "string"
+ ? stack.split("\n") : [];
+ var headerLineCount = 1;
+
+ while(promise != null &&
+ promise._trace != null) {
+ stack = CapturedTrace.combine(
+ stack,
+ promise._trace.stack.split("\n")
+ );
+ promise = promise._traceParent;
+ }
+
+ var max = Error.stackTraceLimit + headerLineCount;
+ var len = stack.length;
+ if (len > max) {
+ stack.length = max;
+ }
+ if (stack.length <= headerLineCount) {
+ error.stack = "(No stack trace)";
+ }
+ else {
+ error.stack = stack.join("\n");
+ }
+ }
+};
+
+Promise.prototype._cleanValues = function Promise$_cleanValues() {
+ if (this._cancellable()) {
+ this._cancellationParent = void 0;
+ }
+};
+
+Promise.prototype._fulfill = function Promise$_fulfill(value) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._fulfillUnchecked(value);
+};
+
+Promise.prototype._reject =
+function Promise$_reject(reason, carriedStackTrace) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._rejectUnchecked(reason, carriedStackTrace);
+};
+
+Promise.prototype._settlePromiseAt = function Promise$_settlePromiseAt(index) {
+ var handler = this.isFulfilled()
+ ? this._fulfillmentHandlerAt(index)
+ : this._rejectionHandlerAt(index);
+
+ var value = this._settledValue;
+ var receiver = this._receiverAt(index);
+ var promise = this._promiseAt(index);
+
+ if (typeof handler === "function") {
+ this._settlePromiseFromHandler(handler, receiver, value, promise);
+ }
+ else {
+ var done = false;
+ var isFulfilled = this.isFulfilled();
+ if (receiver !== void 0) {
+ if (receiver instanceof Promise &&
+ receiver._isProxied()) {
+ receiver._unsetProxied();
+
+ if (isFulfilled) receiver._fulfillUnchecked(value);
+ else receiver._rejectUnchecked(value,
+ this._getCarriedStackTrace());
+ done = true;
+ }
+ else if (isPromiseArrayProxy(receiver, promise)) {
+
+ if (isFulfilled) receiver._promiseFulfilled(value, promise);
+ else receiver._promiseRejected(value, promise);
+
+ done = true;
+ }
+ }
+
+ if (!done) {
+
+ if (isFulfilled) promise._fulfill(value);
+ else promise._reject(value, this._getCarriedStackTrace());
+
+ }
+ }
+
+ if (index >= 256) {
+ this._queueGC();
+ }
+};
+
+Promise.prototype._isProxied = function Promise$_isProxied() {
+ return (this._bitField & 4194304) === 4194304;
+};
+
+Promise.prototype._setProxied = function Promise$_setProxied() {
+ this._bitField = this._bitField | 4194304;
+};
+
+Promise.prototype._unsetProxied = function Promise$_unsetProxied() {
+ this._bitField = this._bitField & (~4194304);
+};
+
+Promise.prototype._isGcQueued = function Promise$_isGcQueued() {
+ return (this._bitField & -1073741824) === -1073741824;
+};
+
+Promise.prototype._setGcQueued = function Promise$_setGcQueued() {
+ this._bitField = this._bitField | -1073741824;
+};
+
+Promise.prototype._unsetGcQueued = function Promise$_unsetGcQueued() {
+ this._bitField = this._bitField & (~-1073741824);
+};
+
+Promise.prototype._queueGC = function Promise$_queueGC() {
+ if (this._isGcQueued()) return;
+ this._setGcQueued();
+ async.invokeLater(this._gc, this, void 0);
+};
+
+Promise.prototype._gc = function Promise$gc() {
+ var len = this._length();
+ this._unsetAt(0);
+ for (var i = 0; i < len; i++) {
+ delete this[i];
+ }
+ this._setLength(0);
+ this._unsetGcQueued();
+};
+
+Promise.prototype._queueSettleAt = function Promise$_queueSettleAt(index) {
+ if (this._isRejectionUnhandled()) this._unsetRejectionIsUnhandled();
+ this._settlePromiseAt(index);
+};
+
+Promise.prototype._fulfillUnchecked =
+function Promise$_fulfillUnchecked(value) {
+ if (!this.isPending()) return;
+ if (value === this) {
+ var err = makeSelfResolutionError();
+ this._attachExtraTrace(err);
+ return this._rejectUnchecked(err, void 0);
+ }
+ this._cleanValues();
+ this._setFulfilled();
+ this._settledValue = value;
+ var len = this._length();
+
+ if (len > 0) {
+ this._fulfillPromises(len);
+ }
+};
+
+Promise.prototype._rejectUncheckedCheckError =
+function Promise$_rejectUncheckedCheckError(reason) {
+ var trace = canAttach(reason) ? reason : new Error(reason + "");
+ this._rejectUnchecked(reason, trace === reason ? void 0 : trace);
+};
+
+Promise.prototype._rejectUnchecked =
+function Promise$_rejectUnchecked(reason, trace) {
+ if (!this.isPending()) return;
+ if (reason === this) {
+ var err = makeSelfResolutionError();
+ this._attachExtraTrace(err);
+ return this._rejectUnchecked(err);
+ }
+ this._cleanValues();
+ this._setRejected();
+ this._settledValue = reason;
+
+ if (this._isFinal()) {
+ async.invokeLater(thrower, void 0, trace === void 0 ? reason : trace);
+ return;
+ }
+ var len = this._length();
+
+ if (trace !== void 0) this._setCarriedStackTrace(trace);
+
+ if (len > 0) {
+ this._rejectPromises(null);
+ }
+ else {
+ this._ensurePossibleRejectionHandled();
+ }
+};
+
+Promise.prototype._rejectPromises = function Promise$_rejectPromises() {
+ var len = this._length();
+ for (var i = 0; i < len; i+= 5) {
+ this._settlePromiseAt(i);
+ }
+ this._unsetCarriedStackTrace();
+};
+
+Promise.prototype._fulfillPromises = function Promise$_fulfillPromises(len) {
+ len = this._length();
+ for (var i = 0; i < len; i+= 5) {
+ this._settlePromiseAt(i);
+ }
+};
+
+Promise.prototype._ensurePossibleRejectionHandled =
+function Promise$_ensurePossibleRejectionHandled() {
+ this._setRejectionIsUnhandled();
+ if (CapturedTrace.possiblyUnhandledRejection !== void 0) {
+ async.invokeLater(this._notifyUnhandledRejection, this, void 0);
+ }
+};
+
+Promise.prototype._notifyUnhandledRejection =
+function Promise$_notifyUnhandledRejection() {
+ if (this._isRejectionUnhandled()) {
+ var reason = this._settledValue;
+ var trace = this._getCarriedStackTrace();
+
+ this._unsetRejectionIsUnhandled();
+
+ if (trace !== void 0) {
+ this._unsetCarriedStackTrace();
+ reason = trace;
+ }
+ if (typeof CapturedTrace.possiblyUnhandledRejection === "function") {
+ CapturedTrace.possiblyUnhandledRejection(reason, this);
+ }
+ }
+};
+
+var contextStack = [];
+Promise.prototype._peekContext = function Promise$_peekContext() {
+ var lastIndex = contextStack.length - 1;
+ if (lastIndex >= 0) {
+ return contextStack[lastIndex];
+ }
+ return void 0;
+
+};
+
+Promise.prototype._pushContext = function Promise$_pushContext() {
+ if (!debugging) return;
+ contextStack.push(this);
+};
+
+Promise.prototype._popContext = function Promise$_popContext() {
+ if (!debugging) return;
+ contextStack.pop();
+};
+
+function Promise$_CreatePromiseArray(
+ promises, PromiseArrayConstructor, caller, boundTo) {
+
+ var list = null;
+ if (isArray(promises)) {
+ list = promises;
+ }
+ else {
+ list = Promise._cast(promises, caller, void 0);
+ if (list !== promises) {
+ list._setBoundTo(boundTo);
+ }
+ else if (!isPromise(list)) {
+ list = null;
+ }
+ }
+ if (list !== null) {
+ return new PromiseArrayConstructor(
+ list,
+ typeof caller === "function"
+ ? caller
+ : Promise$_CreatePromiseArray,
+ boundTo
+ );
+ }
+ return {
+ promise: function() {return apiRejection("expecting an array, a promise or a thenable");}
+ };
+}
+
+var old = global.Promise;
+
+Promise.noConflict = function() {
+ if (global.Promise === Promise) {
+ global.Promise = old;
+ }
+ return Promise;
+};
+
+if (!CapturedTrace.isSupported()) {
+ Promise.longStackTraces = function(){};
+ debugging = false;
+}
+
+Promise._makeSelfResolutionError = makeSelfResolutionError;
+require("./finally.js")(Promise, NEXT_FILTER);
+require("./direct_resolve.js")(Promise);
+require("./thenables.js")(Promise, INTERNAL);
+Promise.RangeError = RangeError;
+Promise.CancellationError = CancellationError;
+Promise.TimeoutError = TimeoutError;
+Promise.TypeError = TypeError;
+Promise.RejectionError = RejectionError;
+
+util.toFastProperties(Promise);
+util.toFastProperties(Promise.prototype);
+require('./timers.js')(Promise,INTERNAL);
+require('./synchronous_inspection.js')(Promise);
+require('./any.js')(Promise,Promise$_CreatePromiseArray,PromiseArray);
+require('./race.js')(Promise,INTERNAL);
+require('./call_get.js')(Promise);
+require('./filter.js')(Promise,Promise$_CreatePromiseArray,PromiseArray,apiRejection);
+require('./generators.js')(Promise,apiRejection,INTERNAL);
+require('./map.js')(Promise,Promise$_CreatePromiseArray,PromiseArray,apiRejection);
+require('./nodeify.js')(Promise);
+require('./promisify.js')(Promise,INTERNAL);
+require('./props.js')(Promise,PromiseArray);
+require('./reduce.js')(Promise,Promise$_CreatePromiseArray,PromiseArray,apiRejection,INTERNAL);
+require('./settle.js')(Promise,Promise$_CreatePromiseArray,PromiseArray);
+require('./some.js')(Promise,Promise$_CreatePromiseArray,PromiseArray,apiRejection);
+require('./progress.js')(Promise,isPromiseArrayProxy);
+require('./cancel.js')(Promise,INTERNAL);
+
+Promise.prototype = Promise.prototype;
+return Promise;
+
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_array.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_array.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_array.js
new file mode 100644
index 0000000..6d43606
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_array.js
@@ -0,0 +1,233 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var canAttach = require("./errors.js").canAttach;
+var util = require("./util.js");
+var async = require("./async.js");
+var hasOwn = {}.hasOwnProperty;
+var isArray = util.isArray;
+
+function toResolutionValue(val) {
+ switch(val) {
+ case -1: return void 0;
+ case -2: return [];
+ case -3: return {};
+ }
+}
+
+function PromiseArray(values, caller, boundTo) {
+ var promise = this._promise = new Promise(INTERNAL);
+ var parent = void 0;
+ if (Promise.is(values)) {
+ parent = values;
+ if (values._cancellable()) {
+ promise._setCancellable();
+ promise._cancellationParent = values;
+ }
+ if (values._isBound()) {
+ promise._setBoundTo(boundTo);
+ }
+ }
+ promise._setTrace(caller, parent);
+ this._values = values;
+ this._length = 0;
+ this._totalResolved = 0;
+ this._init(void 0, -2);
+}
+PromiseArray.PropertiesPromiseArray = function() {};
+
+PromiseArray.prototype.length = function PromiseArray$length() {
+ return this._length;
+};
+
+PromiseArray.prototype.promise = function PromiseArray$promise() {
+ return this._promise;
+};
+
+PromiseArray.prototype._init =
+function PromiseArray$_init(_, resolveValueIfEmpty) {
+ var values = this._values;
+ if (Promise.is(values)) {
+ if (values.isFulfilled()) {
+ values = values._settledValue;
+ if (!isArray(values)) {
+ var err = new Promise.TypeError("expecting an array, a promise or a thenable");
+ this.__hardReject__(err);
+ return;
+ }
+ this._values = values;
+ }
+ else if (values.isPending()) {
+ values._then(
+ this._init,
+ this._reject,
+ void 0,
+ this,
+ resolveValueIfEmpty,
+ this.constructor
+ );
+ return;
+ }
+ else {
+ this._reject(values._settledValue);
+ return;
+ }
+ }
+
+ if (values.length === 0) {
+ this._resolve(toResolutionValue(resolveValueIfEmpty));
+ return;
+ }
+ var len = values.length;
+ var newLen = len;
+ var newValues;
+ if (this instanceof PromiseArray.PropertiesPromiseArray) {
+ newValues = this._values;
+ }
+ else {
+ newValues = new Array(len);
+ }
+ var isDirectScanNeeded = false;
+ for (var i = 0; i < len; ++i) {
+ var promise = values[i];
+ if (promise === void 0 && !hasOwn.call(values, i)) {
+ newLen--;
+ continue;
+ }
+ var maybePromise = Promise._cast(promise, void 0, void 0);
+ if (maybePromise instanceof Promise) {
+ if (maybePromise.isPending()) {
+ maybePromise._proxyPromiseArray(this, i);
+ }
+ else {
+ maybePromise._unsetRejectionIsUnhandled();
+ isDirectScanNeeded = true;
+ }
+ }
+ else {
+ isDirectScanNeeded = true;
+ }
+ newValues[i] = maybePromise;
+ }
+ if (newLen === 0) {
+ if (resolveValueIfEmpty === -2) {
+ this._resolve(newValues);
+ }
+ else {
+ this._resolve(toResolutionValue(resolveValueIfEmpty));
+ }
+ return;
+ }
+ this._values = newValues;
+ this._length = newLen;
+ if (isDirectScanNeeded) {
+ var scanMethod = newLen === len
+ ? this._scanDirectValues
+ : this._scanDirectValuesHoled;
+ scanMethod.call(this, len);
+ }
+};
+
+PromiseArray.prototype._settlePromiseAt =
+function PromiseArray$_settlePromiseAt(index) {
+ var value = this._values[index];
+ if (!Promise.is(value)) {
+ this._promiseFulfilled(value, index);
+ }
+ else if (value.isFulfilled()) {
+ this._promiseFulfilled(value._settledValue, index);
+ }
+ else if (value.isRejected()) {
+ this._promiseRejected(value._settledValue, index);
+ }
+};
+
+PromiseArray.prototype._scanDirectValuesHoled =
+function PromiseArray$_scanDirectValuesHoled(len) {
+ for (var i = 0; i < len; ++i) {
+ if (this._isResolved()) {
+ break;
+ }
+ if (hasOwn.call(this._values, i)) {
+ this._settlePromiseAt(i);
+ }
+ }
+};
+
+PromiseArray.prototype._scanDirectValues =
+function PromiseArray$_scanDirectValues(len) {
+ for (var i = 0; i < len; ++i) {
+ if (this._isResolved()) {
+ break;
+ }
+ this._settlePromiseAt(i);
+ }
+};
+
+PromiseArray.prototype._isResolved = function PromiseArray$_isResolved() {
+ return this._values === null;
+};
+
+PromiseArray.prototype._resolve = function PromiseArray$_resolve(value) {
+ this._values = null;
+ this._promise._fulfill(value);
+};
+
+PromiseArray.prototype.__hardReject__ =
+PromiseArray.prototype._reject = function PromiseArray$_reject(reason) {
+ this._values = null;
+ var trace = canAttach(reason) ? reason : new Error(reason + "");
+ this._promise._attachExtraTrace(trace);
+ this._promise._reject(reason, trace);
+};
+
+PromiseArray.prototype._promiseProgressed =
+function PromiseArray$_promiseProgressed(progressValue, index) {
+ if (this._isResolved()) return;
+ this._promise._progress({
+ index: index,
+ value: progressValue
+ });
+};
+
+
+PromiseArray.prototype._promiseFulfilled =
+function PromiseArray$_promiseFulfilled(value, index) {
+ if (this._isResolved()) return;
+ this._values[index] = value;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ this._resolve(this._values);
+ }
+};
+
+PromiseArray.prototype._promiseRejected =
+function PromiseArray$_promiseRejected(reason, index) {
+ if (this._isResolved()) return;
+ this._totalResolved++;
+ this._reject(reason);
+};
+
+return PromiseArray;
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_inspection.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_inspection.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_inspection.js
new file mode 100644
index 0000000..0aa233b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_inspection.js
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var TypeError = require("./errors.js").TypeError;
+
+function PromiseInspection(promise) {
+ if (promise !== void 0) {
+ this._bitField = promise._bitField;
+ this._settledValue = promise.isResolved()
+ ? promise._settledValue
+ : void 0;
+ }
+ else {
+ this._bitField = 0;
+ this._settledValue = void 0;
+ }
+}
+PromiseInspection.prototype.isFulfilled =
+function PromiseInspection$isFulfilled() {
+ return (this._bitField & 268435456) > 0;
+};
+
+PromiseInspection.prototype.isRejected =
+function PromiseInspection$isRejected() {
+ return (this._bitField & 134217728) > 0;
+};
+
+PromiseInspection.prototype.isPending = function PromiseInspection$isPending() {
+ return (this._bitField & 402653184) === 0;
+};
+
+PromiseInspection.prototype.value = function PromiseInspection$value() {
+ if (!this.isFulfilled()) {
+ throw new TypeError("cannot get fulfillment value of a non-fulfilled promise");
+ }
+ return this._settledValue;
+};
+
+PromiseInspection.prototype.error = function PromiseInspection$error() {
+ if (!this.isRejected()) {
+ throw new TypeError("cannot get rejection reason of a non-rejected promise");
+ }
+ return this._settledValue;
+};
+
+module.exports = PromiseInspection;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_resolver.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_resolver.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_resolver.js
new file mode 100644
index 0000000..ea14069
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_resolver.js
@@ -0,0 +1,152 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+var util = require("./util.js");
+var maybeWrapAsError = util.maybeWrapAsError;
+var errors = require("./errors.js");
+var TimeoutError = errors.TimeoutError;
+var RejectionError = errors.RejectionError;
+var async = require("./async.js");
+var haveGetters = util.haveGetters;
+var es5 = require("./es5.js");
+
+function isUntypedError(obj) {
+ return obj instanceof Error &&
+ es5.getPrototypeOf(obj) === Error.prototype;
+}
+
+function wrapAsRejectionError(obj) {
+ var ret;
+ if (isUntypedError(obj)) {
+ ret = new RejectionError(obj);
+ }
+ else {
+ ret = obj;
+ }
+ errors.markAsOriginatingFromRejection(ret);
+ return ret;
+}
+
+function nodebackForPromise(promise) {
+ function PromiseResolver$_callback(err, value) {
+ if (promise === null) return;
+
+ if (err) {
+ var wrapped = wrapAsRejectionError(maybeWrapAsError(err));
+ promise._attachExtraTrace(wrapped);
+ promise._reject(wrapped);
+ }
+ else {
+ if (arguments.length > 2) {
+ var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
+ promise._fulfill(args);
+ }
+ else {
+ promise._fulfill(value);
+ }
+ }
+
+ promise = null;
+ }
+ return PromiseResolver$_callback;
+}
+
+
+var PromiseResolver;
+if (!haveGetters) {
+ PromiseResolver = function PromiseResolver(promise) {
+ this.promise = promise;
+ this.asCallback = nodebackForPromise(promise);
+ this.callback = this.asCallback;
+ };
+}
+else {
+ PromiseResolver = function PromiseResolver(promise) {
+ this.promise = promise;
+ };
+}
+if (haveGetters) {
+ var prop = {
+ get: function() {
+ return nodebackForPromise(this.promise);
+ }
+ };
+ es5.defineProperty(PromiseResolver.prototype, "asCallback", prop);
+ es5.defineProperty(PromiseResolver.prototype, "callback", prop);
+}
+
+PromiseResolver._nodebackForPromise = nodebackForPromise;
+
+PromiseResolver.prototype.toString = function PromiseResolver$toString() {
+ return "[object PromiseResolver]";
+};
+
+PromiseResolver.prototype.resolve =
+PromiseResolver.prototype.fulfill = function PromiseResolver$resolve(value) {
+ var promise = this.promise;
+ if (promise._tryFollow(value)) {
+ return;
+ }
+ promise._fulfill(value);
+};
+
+PromiseResolver.prototype.reject = function PromiseResolver$reject(reason) {
+ var promise = this.promise;
+ errors.markAsOriginatingFromRejection(reason);
+ var trace = errors.canAttach(reason) ? reason : new Error(reason + "");
+ promise._attachExtraTrace(trace);
+ promise._reject(reason);
+ if (trace !== reason) {
+ this._setCarriedStackTrace(trace);
+ }
+};
+
+PromiseResolver.prototype.progress =
+function PromiseResolver$progress(value) {
+ this.promise._progress(value);
+};
+
+PromiseResolver.prototype.cancel = function PromiseResolver$cancel() {
+ this.promise.cancel((void 0));
+};
+
+PromiseResolver.prototype.timeout = function PromiseResolver$timeout() {
+ this.reject(new TimeoutError("timeout"));
+};
+
+PromiseResolver.prototype.isResolved = function PromiseResolver$isResolved() {
+ return this.promise.isResolved();
+};
+
+PromiseResolver.prototype.toJSON = function PromiseResolver$toJSON() {
+ return this.promise.toJSON();
+};
+
+PromiseResolver.prototype._setCarriedStackTrace =
+function PromiseResolver$_setCarriedStackTrace(trace) {
+ if (this.promise.isRejected()) {
+ this.promise._setCarriedStackTrace(trace);
+ }
+};
+
+module.exports = PromiseResolver;
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_spawn.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_spawn.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_spawn.js
new file mode 100644
index 0000000..2d6525f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/bluebird/js/zalgo/promise_spawn.js
@@ -0,0 +1,131 @@
+/**
+ * Copyright (c) 2014 Petka Antonov
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:</p>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var errors = require("./errors.js");
+var TypeError = errors.TypeError;
+var util = require("./util.js");
+var isArray = util.isArray;
+var errorObj = util.errorObj;
+var tryCatch1 = util.tryCatch1;
+var yieldHandlers = [];
+
+function promiseFromYieldHandler(value) {
+ var _yieldHandlers = yieldHandlers;
+ var _errorObj = errorObj;
+ var _Promise = Promise;
+ var len = _yieldHandlers.length;
+ for (var i = 0; i < len; ++i) {
+ var result = tryCatch1(_yieldHandlers[i], void 0, value);
+ if (result === _errorObj) {
+ return _Promise.reject(_errorObj.e);
+ }
+ var maybePromise = _Promise._cast(result,
+ promiseFromYieldHandler, void 0);
+ if (maybePromise instanceof _Promise) return maybePromise;
+ }
+ return null;
+}
+
+function PromiseSpawn(generatorFunction, receiver, caller) {
+ var promise = this._promise = new Promise(INTERNAL);
+ promise._setTrace(caller, void 0);
+ this._generatorFunction = generatorFunction;
+ this._receiver = receiver;
+ this._generator = void 0;
+}
+
+PromiseSpawn.prototype.promise = function PromiseSpawn$promise() {
+ return this._promise;
+};
+
+PromiseSpawn.prototype._run = function PromiseSpawn$_run() {
+ this._generator = this._generatorFunction.call(this._receiver);
+ this._receiver =
+ this._generatorFunction = void 0;
+ this._next(void 0);
+};
+
+PromiseSpawn.prototype._continue = function PromiseSpawn$_continue(result) {
+ if (result === errorObj) {
+ this._generator = void 0;
+ var trace = errors.canAttach(result.e)
+ ? result.e : new Error(result.e + "");
+ this._promise._attachExtraTrace(trace);
+ this._promise._reject(result.e, trace);
+ return;
+ }
+
+ var value = result.value;
+ if (result.done === true) {
+ this._generator = void 0;
+ if (!this._promise._tryFollow(value)) {
+ this._promise._fulfill(value);
+ }
+ }
+ else {
+ var maybePromise = Promise._cast(value, PromiseSpawn$_continue, void 0);
+ if (!(maybePromise instanceof Promise)) {
+ if (isArray(maybePromise)) {
+ maybePromise = Promise.all(maybePromise);
+ }
+ else {
+ maybePromise = promiseFromYieldHandler(maybePromise);
+ }
+ if (maybePromise === null) {
+ this._throw(new TypeError("A value was yielded that could not be treated as a promise"));
+ return;
+ }
+ }
+ maybePromise._then(
+ this._next,
+ this._throw,
+ void 0,
+ this,
+ null,
+ void 0
+ );
+ }
+};
+
+PromiseSpawn.prototype._throw = function PromiseSpawn$_throw(reason) {
+ if (errors.canAttach(reason))
+ this._promise._attachExtraTrace(reason);
+ this._continue(
+ tryCatch1(this._generator["throw"], this._generator, reason)
+ );
+};
+
+PromiseSpawn.prototype._next = function PromiseSpawn$_next(value) {
+ this._continue(
+ tryCatch1(this._generator.next, this._generator, value)
+ );
+};
+
+PromiseSpawn.addYieldHandler = function PromiseSpawn$AddYieldHandler(fn) {
+ if (typeof fn !== "function") throw new TypeError("fn must be a function");
+ yieldHandlers.push(fn);
+};
+
+return PromiseSpawn;
+};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[04/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/aes.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/aes.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/aes.js
new file mode 100644
index 0000000..ddd91a4
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/aes.js
@@ -0,0 +1,1213 @@
+(function() {
+
+function Tests(ASSERT, CIPHER, AES, UTIL) {
+ describe('aes', function() {
+ it('should encrypt a single block with a 128-bit key', function() {
+ var key = [0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f];
+ var block = [0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff];
+
+ var output = [];
+ var w = AES._expandKey(key, false);
+ AES._updateBlock(w, block, output, false);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '69c4e0d86a7b0430d8cdb78070b4c55a');
+ });
+
+ it('should decrypt a single block with a 128-bit key', function() {
+ var key = [0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f];
+ var block = [0x69c4e0d8, 0x6a7b0430, 0xd8cdb780, 0x70b4c55a];
+
+ var output = [];
+ var w = AES._expandKey(key, true);
+ AES._updateBlock(w, block, output, true);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '00112233445566778899aabbccddeeff');
+ });
+
+ it('should encrypt a single block with a 192-bit key', function() {
+ var key = [
+ 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+ 0x10111213, 0x14151617];
+ var block = [0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff];
+
+ var output = [];
+ var w = AES._expandKey(key, false);
+ AES._updateBlock(w, block, output, false);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), 'dda97ca4864cdfe06eaf70a0ec0d7191');
+ });
+
+ it('should decrypt a single block with a 192-bit key', function() {
+ var key = [
+ 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+ 0x10111213, 0x14151617];
+ var block = [0xdda97ca4, 0x864cdfe0, 0x6eaf70a0, 0xec0d7191];
+
+ var output = [];
+ var w = AES._expandKey(key, true);
+ AES._updateBlock(w, block, output, true);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '00112233445566778899aabbccddeeff');
+ });
+
+ it('should encrypt a single block with a 256-bit key', function() {
+ var key = [
+ 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+ 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f];
+ var block = [0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff];
+
+ var output = [];
+ var w = AES._expandKey(key, false);
+ AES._updateBlock(w, block, output, false);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '8ea2b7ca516745bfeafc49904b496089');
+ });
+
+ it('should decrypt a single block with a 256-bit key', function() {
+ var key = [
+ 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+ 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f];
+ var block = [0x8ea2b7ca, 0x516745bf, 0xeafc4990, 0x4b496089];
+
+ var output = [];
+ var w = AES._expandKey(key, true);
+ AES._updateBlock(w, block, output, true);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '00112233445566778899aabbccddeeff');
+ });
+
+ // AES-128-CBC
+ (function() {
+ var keys = [
+ '06a9214036b8a15b512e03d534120006',
+ 'c286696d887c9aa0611bbb3e2025a45a',
+ '6c3ea0477630ce21a2ce334aa746c2cd',
+ '56e47a38c5598974bc46903dba290349'
+ ];
+
+ var ivs = [
+ '3dafba429d9eb430b422da802c9fac41',
+ '562e17996d093d28ddb3ba695a2e6f58',
+ 'c782dc4c098c66cbd9cd27d825682c81',
+ '8ce82eefbea0da3c44699ed7db51b7d9'
+ ];
+
+ var inputs = [
+ 'Single block msg',
+ '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
+ 'This is a 48-byte message (exactly 3 AES blocks)',
+ 'a0a1a2a3a4a5a6a7a8a9aaabacadaeaf' +
+ 'b0b1b2b3b4b5b6b7b8b9babbbcbdbebf' +
+ 'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf' +
+ 'd0d1d2d3d4d5d6d7d8d9dadbdcdddedf'
+ ];
+
+ var outputs = [
+ 'e353779c1079aeb82708942dbe77181a',
+ 'd296cd94c2cccf8a3a863028b5e1dc0a7586602d253cfff91b8266bea6d61ab1',
+ 'd0a02b3836451753d493665d33f0e886' +
+ '2dea54cdb293abc7506939276772f8d5' +
+ '021c19216bad525c8579695d83ba2684',
+ 'c30e32ffedc0774e6aff6af0869f71aa' +
+ '0f3af07a9a31a9c684db207eb0ef8e4e' +
+ '35907aa632c3ffdf868bb7b29d3d46ad' +
+ '83ce9f9a102ee99d49a53e87f4c3da55'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = (i & 1) ? UTIL.hexToBytes(inputs[i]) : inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-cbc encrypt: ' + inputs[i], function() {
+ // encrypt w/no padding
+ var cipher = CIPHER.createCipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish(function(){return true;});
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-128-cbc decrypt: ' + outputs[i], function() {
+ // decrypt w/no padding
+ var cipher = CIPHER.createDecipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish(function(){return true;});
+ var out = (i & 1) ? cipher.output.toHex() : cipher.output.bytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-CBC
+ (function() {
+ var keys = [
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ '4F021DB243BC633D7178183A9FA071E8',
+ 'B4D9ADA9AD7DEDF4E5E738763F69145A',
+ '571B242012FB7AE07FA9BAAC3DF102E0'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ '4f021db243bc633d7178183a9fa071e8',
+ 'b4d9ada9ad7dedf4e5e738763f69145a',
+ '571b242012fb7ae07fa9baac3df102e0',
+ '08b0e27988598881d920a9e64f5615cd'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-192-cbc encrypt: ' + inputs[i], function() {
+ // encrypt w/no padding
+ var cipher = CIPHER.createCipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish(function(){return true;});
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-192-cbc decrypt: ' + outputs[i], function() {
+ // decrypt w/no padding
+ var cipher = CIPHER.createDecipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish(function(){return true;});
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-CBC
+ (function() {
+ var keys = [
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ 'F58C4C04D6E5F1BA779EABFB5F7BFBD6',
+ '9CFC4E967EDB808D679F777BC6702C7D',
+ '39F23369A9D9BACFA530E26304231461'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ 'f58c4c04d6e5f1ba779eabfb5f7bfbd6',
+ '9cfc4e967edb808d679f777bc6702c7d',
+ '39f23369a9d9bacfa530e26304231461',
+ 'b2eb05e2c39be9fcda6c19078c6a9d1b'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-256-cbc encrypt: ' + inputs[i], function() {
+ // encrypt w/no padding
+ var cipher = CIPHER.createCipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish(function(){return true;});
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-256-cbc decrypt: ' + outputs[i], function() {
+ // decrypt w/no padding
+ var cipher = CIPHER.createDecipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish(function(){return true;});
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-128-CFB
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000',
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '00000000000000000000000000000000'
+ ];
+
+ var ivs = [
+ '80000000000000000000000000000000',
+ '000102030405060708090a0b0c0d0e0f',
+ '3B3FD92EB72DAD20333449F8E83CFB4A',
+ 'C8A64537A0B3A93FCDE3CDAD9F1CE58B',
+ '26751F67A3CBB140B1808CF187A4F4DF',
+ '60f9ff04fac1a25657bf5b36b5efaf75'
+ ];
+
+ var inputs = [
+ '00000000000000000000000000000000',
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710',
+ 'This is a 48-byte message (exactly 3 AES blocks)'
+ ];
+
+ var outputs = [
+ '3ad78e726c1ec02b7ebfe92b23d9ec34',
+ '3b3fd92eb72dad20333449f8e83cfb4a',
+ 'c8a64537a0b3a93fcde3cdad9f1ce58b',
+ '26751f67a3cbb140b1808cf187a4f4df',
+ 'c04b05357c5d1c0eeac4c66f9ff7f2e6',
+ '52396a2ba1ba420c5e5b699a814944d8' +
+ 'f4e7fbf984a038319fbc0b4ee45cfa6f' +
+ '07b2564beab5b5e92dbd44cb345f49b4'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = (i !== 5) ? UTIL.hexToBytes(inputs[i]) : inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-cfb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-128-cfb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = (i !== 5) ?
+ cipher.output.toHex() : cipher.output.getBytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-CFB
+ (function() {
+ var keys = [
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ 'CDC80D6FDDF18CAB34C25909C99A4174',
+ '67CE7F7F81173621961A2B70171D3D7A',
+ '2E1E8A1DD59B88B1C8E60FED1EFAC4C9'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ 'cdc80d6fddf18cab34c25909c99a4174',
+ '67ce7f7f81173621961a2b70171d3d7a',
+ '2e1e8a1dd59b88b1c8e60fed1efac4c9',
+ 'c05f9f9ca9834fa042ae8fba584b09ff'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-192-cfb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-192-cfb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-CFB
+ (function() {
+ var keys = [
+ '861009ec4d599fab1f40abc76e6f89880cff5833c79c548c99f9045f191cd90b'
+ ];
+
+ var ivs = [
+ 'd927ad81199aa7dcadfdb4e47b6dc694'
+ ];
+
+ var inputs = [
+ 'MY-DATA-AND-HERE-IS-MORE-DATA'
+ ];
+
+ var outputs = [
+ '80eb666a9fc9e263faf71e87ffc94451d7d8df7cfcf2606470351dd5ac'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-256-cfb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-256-cfb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.getBytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-128-OFB
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000',
+ '00000000000000000000000000000000'
+ ];
+
+ var ivs = [
+ '80000000000000000000000000000000',
+ 'c8ca0d6a35dbeac776e911ee16bea7d3'
+ ];
+
+ var inputs = [
+ '00000000000000000000000000000000',
+ 'This is a 48-byte message (exactly 3 AES blocks)'
+ ];
+
+ var outputs = [
+ '3ad78e726c1ec02b7ebfe92b23d9ec34',
+ '39c0190727a76b2a90963426f63689cf' +
+ 'cdb8a2be8e20c5e877a81a724e3611f6' +
+ '2ecc386f2e941b2441c838906002be19'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = (i !== 1) ? UTIL.hexToBytes(inputs[i]) : inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-ofb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-128-ofb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = (i !== 1) ?
+ cipher.output.toHex() : cipher.output.getBytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-OFB
+ (function() {
+ var keys = [
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ 'A609B38DF3B1133DDDFF2718BA09565E',
+ '52EF01DA52602FE0975F78AC84BF8A50',
+ 'BD5286AC63AABD7EB067AC54B553F71D'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ 'cdc80d6fddf18cab34c25909c99a4174',
+ 'fcc28b8d4c63837c09e81700c1100401',
+ '8d9a9aeac0f6596f559c6d4daf59a5f2',
+ '6d9f200857ca6c3e9cac524bd9acc92a'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-192-ofb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-192-ofb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-OFB
+ (function() {
+ var keys = [
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ 'B7BF3A5DF43989DD97F0FA97EBCE2F4A',
+ 'E1C656305ED1A7A6563805746FE03EDC',
+ '41635BE625B48AFC1666DD42A09D96E7'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ 'dc7e84bfda79164b7ecd8486985d3860',
+ '4febdc6740d20b3ac88f6ad82a4fb08d',
+ '71ab47a086e86eedf39d1c5bba97c408',
+ '0126141d67f37be8538f5a8be740e484'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-256-ofb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-256-ofb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-128-CTR
+ (function() {
+ var keys = [
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '00000000000000000000000000000000'
+ ];
+
+ var ivs = [
+ 'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff',
+ '650cdb80ff9fc758342d2bd99ee2abcf'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'This is a 48-byte message (exactly 3 AES blocks)'
+ ];
+
+ var outputs = [
+ '874d6191b620e3261bef6864990db6ce',
+ '5ede11d00e9a76ec1d5e7e811ea3dd1c' +
+ 'e09ee941210f825d35718d3282796f1c' +
+ '07c3f1cb424f2b365766ab5229f5b5a4'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = (i !== 1) ? UTIL.hexToBytes(inputs[i]) : inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-ctr encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-128-ctr decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = (i !== 1) ?
+ cipher.output.toHex() : cipher.output.getBytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-CTR
+ (function() {
+ var keys = [
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
+ ];
+
+ var ivs = [
+ 'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a' +
+ 'ae2d8a571e03ac9c9eb76fac45af8e51' +
+ '30c81c46a35ce411e5fbc1191a0a52ef' +
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ '1abc932417521ca24f2b0459fe7e6e0b' +
+ '090339ec0aa6faefd5ccc2c6f4ce8e94' +
+ '1e36b26bd1ebc670d1bd1d665620abf7' +
+ '4f78a7f6d29809585a97daec58c6b050'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-192-ctr encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-192-ctr decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-CTR
+ (function() {
+ var keys = [
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
+ ];
+
+ var ivs = [
+ 'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a' +
+ 'ae2d8a571e03ac9c9eb76fac45af8e51' +
+ '30c81c46a35ce411e5fbc1191a0a52ef' +
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ '601ec313775789a5b7a7f504bbf3d228' +
+ 'f443e3ca4d62b59aca84e990cacaf5c5' +
+ '2b0930daa23de94ce87017ba2d84988d' +
+ 'dfc9c58db67aada613c2dd08457941a6'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-256-ctr encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-256-ctr decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-128-GCM
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000',
+ '00000000000000000000000000000000',
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308'
+ ];
+
+ var ivs = [
+ '000000000000000000000000',
+ '000000000000000000000000',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbad',
+ '9313225df88406e555909c5aff5269aa' +
+ '6a7a9538534f7da1e4c303d2a318a728' +
+ 'c3c0c95156809539fcf0e2429a6b5254' +
+ '16aedbf5a0de6a57a637b39b'
+ ];
+
+ var adatas = [
+ '',
+ '',
+ '',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2'
+ ];
+
+ var inputs = [
+ '',
+ '00000000000000000000000000000000',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b391aafd255',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39'
+ ];
+
+ var outputs = [
+ '',
+ '0388dace60b6a392f328c2b971b2fe78',
+ '42831ec2217774244b7221b784d0d49c' +
+ 'e3aa212f2c02a4e035c17e2329aca12e' +
+ '21d514b25466931c7d8f6a5aac84aa05' +
+ '1ba30b396a0aac973d58e091473f5985',
+ '42831ec2217774244b7221b784d0d49c' +
+ 'e3aa212f2c02a4e035c17e2329aca12e' +
+ '21d514b25466931c7d8f6a5aac84aa05' +
+ '1ba30b396a0aac973d58e091',
+ '61353b4c2806934a777ff51fa22a4755' +
+ '699b2a714fcdc6f83766e5f97b6c7423' +
+ '73806900e49f24b22b097544d4896b42' +
+ '4989b5e1ebac0f07c23f4598',
+ '8ce24998625615b603a033aca13fb894' +
+ 'be9112a5c3a211a8ba262a3cca7e2ca7' +
+ '01e4a9a4fba43c90ccdcb281d48c7c6f' +
+ 'd62875d2aca417034c34aee5'
+ ];
+
+ var tags = [
+ '58e2fccefa7e3061367f1d57a4e7455a',
+ 'ab6e47d42cec13bdf53a67b21257bddf',
+ '4d5c2af327cd64a62cf35abd2ba6fab4',
+ '5bc94fbc3221a5db94fae95ae7121a47',
+ '3612d2e79e3b0785561be14aaca2fccb',
+ '619cc5aefffe0bfa462af43c1699d050'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var adata = UTIL.hexToBytes(adatas[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-gcm encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-GCM', key);
+ cipher.start({iv: iv, additionalData: adata});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ });
+
+ it('should aes-128-gcm decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-GCM', key);
+ cipher.start({
+ iv: iv,
+ additionalData: adata,
+ tag: UTIL.hexToBytes(tags[i])
+ });
+ cipher.update(UTIL.createBuffer(output));
+ var pass = cipher.finish();
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ ASSERT.equal(pass, true);
+ ASSERT.equal(cipher.output.toHex(), inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-GCM
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000' +
+ '0000000000000000',
+ '00000000000000000000000000000000' +
+ '0000000000000000',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c'
+ ];
+
+ var ivs = [
+ '000000000000000000000000',
+ '000000000000000000000000',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbad',
+ '9313225df88406e555909c5aff5269aa' +
+ '6a7a9538534f7da1e4c303d2a318a728' +
+ 'c3c0c95156809539fcf0e2429a6b5254' +
+ '16aedbf5a0de6a57a637b39b'
+ ];
+
+ var adatas = [
+ '',
+ '',
+ '',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2'
+ ];
+
+ var inputs = [
+ '',
+ '00000000000000000000000000000000',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b391aafd255',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39'
+ ];
+
+ var outputs = [
+ '',
+ '98e7247c07f0fe411c267e4384b0f600',
+ '3980ca0b3c00e841eb06fac4872a2757' +
+ '859e1ceaa6efd984628593b40ca1e19c' +
+ '7d773d00c144c525ac619d18c84a3f47' +
+ '18e2448b2fe324d9ccda2710acade256',
+ '3980ca0b3c00e841eb06fac4872a2757' +
+ '859e1ceaa6efd984628593b40ca1e19c' +
+ '7d773d00c144c525ac619d18c84a3f47' +
+ '18e2448b2fe324d9ccda2710',
+ '0f10f599ae14a154ed24b36e25324db8' +
+ 'c566632ef2bbb34f8347280fc4507057' +
+ 'fddc29df9a471f75c66541d4d4dad1c9' +
+ 'e93a19a58e8b473fa0f062f7',
+ 'd27e88681ce3243c4830165a8fdcf9ff' +
+ '1de9a1d8e6b447ef6ef7b79828666e45' +
+ '81e79012af34ddd9e2f037589b292db3' +
+ 'e67c036745fa22e7e9b7373b'
+ ];
+
+ var tags = [
+ 'cd33b28ac773f74ba00ed1f312572435',
+ '2ff58d80033927ab8ef4d4587514f0fb',
+ '9924a7c8587336bfb118024db8674a14',
+ '2519498e80f1478f37ba55bd6d27618c',
+ '65dcc57fcf623a24094fcca40d3533f8',
+ 'dcf566ff291c25bbb8568fc3d376a6d9'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var adata = UTIL.hexToBytes(adatas[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-gcm encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-GCM', key);
+ cipher.start({iv: iv, additionalData: adata});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ });
+
+ it('should aes-128-gcm decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-GCM', key);
+ cipher.start({
+ iv: iv,
+ additionalData: adata,
+ tag: UTIL.hexToBytes(tags[i])
+ });
+ cipher.update(UTIL.createBuffer(output));
+ var pass = cipher.finish();
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ ASSERT.equal(pass, true);
+ ASSERT.equal(cipher.output.toHex(), inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-GCM
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000' +
+ '00000000000000000000000000000000',
+ '00000000000000000000000000000000' +
+ '00000000000000000000000000000000',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c6d6a8f9467308308'
+ ];
+
+ var ivs = [
+ '000000000000000000000000',
+ '000000000000000000000000',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbad',
+ '9313225df88406e555909c5aff5269aa' +
+ '6a7a9538534f7da1e4c303d2a318a728' +
+ 'c3c0c95156809539fcf0e2429a6b5254' +
+ '16aedbf5a0de6a57a637b39b'
+ ];
+
+ var adatas = [
+ '',
+ '',
+ '',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2'
+ ];
+
+ var inputs = [
+ '',
+ '00000000000000000000000000000000',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b391aafd255',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39'
+ ];
+
+ var outputs = [
+ '',
+ 'cea7403d4d606b6e074ec5d3baf39d18',
+ '522dc1f099567d07f47f37a32a84427d' +
+ '643a8cdcbfe5c0c97598a2bd2555d1aa' +
+ '8cb08e48590dbb3da7b08b1056828838' +
+ 'c5f61e6393ba7a0abcc9f662898015ad',
+ '522dc1f099567d07f47f37a32a84427d' +
+ '643a8cdcbfe5c0c97598a2bd2555d1aa' +
+ '8cb08e48590dbb3da7b08b1056828838' +
+ 'c5f61e6393ba7a0abcc9f662',
+ 'c3762df1ca787d32ae47c13bf19844cb' +
+ 'af1ae14d0b976afac52ff7d79bba9de0' +
+ 'feb582d33934a4f0954cc2363bc73f78' +
+ '62ac430e64abe499f47c9b1f',
+ '5a8def2f0c9e53f1f75d7853659e2a20' +
+ 'eeb2b22aafde6419a058ab4f6f746bf4' +
+ '0fc0c3b780f244452da3ebf1c5d82cde' +
+ 'a2418997200ef82e44ae7e3f'
+ ];
+
+ var tags = [
+ '530f8afbc74536b9a963b4f1c4cb738b',
+ 'd0d1c8a799996bf0265b98b5d48ab919',
+ 'b094dac5d93471bdec1a502270e3cc6c',
+ '76fc6ece0f4e1768cddf8853bb2d551b',
+ '3a337dbf46a792c45e454913fe2ea8f2',
+ 'a44a8266ee1c8eb0c8b5d4cf5ae9f19a'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var adata = UTIL.hexToBytes(adatas[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-gcm encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-GCM', key);
+ cipher.start({iv: iv, additionalData: adata});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ });
+
+ it('should aes-128-gcm decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-GCM', key);
+ cipher.start({
+ iv: iv,
+ additionalData: adata,
+ tag: UTIL.hexToBytes(tags[i])
+ });
+ cipher.update(UTIL.createBuffer(output));
+ var pass = cipher.finish();
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ ASSERT.equal(pass, true);
+ ASSERT.equal(cipher.output.toHex(), inputs[i]);
+ });
+ })(i);
+ }
+ })();
+ });
+}
+
+// check for AMD
+var forge = {};
+if(typeof define === 'function') {
+ define([
+ 'forge/cipher',
+ 'forge/aes',
+ 'forge/util'
+ ], function(CIPHER, AES, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ CIPHER(forge),
+ AES(forge),
+ UTIL(forge)
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/cipher')(forge),
+ require('../../js/aes')(forge),
+ require('../../js/util')(forge));
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/asn1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/asn1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/asn1.js
new file mode 100644
index 0000000..7d0880e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/asn1.js
@@ -0,0 +1,262 @@
+(function() {
+
+function Tests(ASSERT, ASN1, UTIL) {
+ describe('asn1', function() {
+ // TODO: add more ASN.1 coverage
+
+ it('should convert an OID to DER', function() {
+ ASSERT.equal(ASN1.oidToDer('1.2.840.113549').toHex(), '2a864886f70d');
+ });
+
+ it('should convert an OID from DER', function() {
+ var der = UTIL.hexToBytes('2a864886f70d');
+ ASSERT.equal(ASN1.derToOid(der), '1.2.840.113549');
+ });
+
+ it('should convert INTEGER 0 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(0).toHex(), '00');
+ });
+
+ it('should convert INTEGER 1 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(1).toHex(), '01');
+ });
+
+ it('should convert INTEGER 127 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(127).toHex(), '7f');
+ });
+
+ it('should convert INTEGER 128 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(128).toHex(), '0080');
+ });
+
+ it('should convert INTEGER 256 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(256).toHex(), '0100');
+ });
+
+ it('should convert INTEGER -128 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-128).toHex(), '80');
+ });
+
+ it('should convert INTEGER -129 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-129).toHex(), 'ff7f');
+ });
+
+ it('should convert INTEGER 32768 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(32768).toHex(), '008000');
+ });
+
+ it('should convert INTEGER -32768 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-32768).toHex(), '8000');
+ });
+
+ it('should convert INTEGER -32769 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-32769).toHex(), 'ff7fff');
+ });
+
+ it('should convert INTEGER 8388608 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(8388608).toHex(), '00800000');
+ });
+
+ it('should convert INTEGER -8388608 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-8388608).toHex(), '800000');
+ });
+
+ it('should convert INTEGER -8388609 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-8388609).toHex(), 'ff7fffff');
+ });
+
+ it('should convert INTEGER 2147483647 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(2147483647).toHex(), '7fffffff');
+ });
+
+ it('should convert INTEGER -2147483648 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-2147483648).toHex(), '80000000');
+ });
+
+ it('should convert INTEGER 0 from DER', function() {
+ var der = UTIL.hexToBytes('00');
+ ASSERT.equal(ASN1.derToInteger(der), 0);
+ });
+
+ it('should convert INTEGER 1 from DER', function() {
+ var der = UTIL.hexToBytes('01');
+ ASSERT.equal(ASN1.derToInteger(der), 1);
+ });
+
+ it('should convert INTEGER 127 from DER', function() {
+ var der = UTIL.hexToBytes('7f');
+ ASSERT.equal(ASN1.derToInteger(der), 127);
+ });
+
+ it('should convert INTEGER 128 from DER', function() {
+ var der = UTIL.hexToBytes('0080');
+ ASSERT.equal(ASN1.derToInteger(der), 128);
+ });
+
+ it('should convert INTEGER 256 from DER', function() {
+ var der = UTIL.hexToBytes('0100');
+ ASSERT.equal(ASN1.derToInteger(der), 256);
+ });
+
+ it('should convert INTEGER -128 from DER', function() {
+ var der = UTIL.hexToBytes('80');
+ ASSERT.equal(ASN1.derToInteger(der), -128);
+ });
+
+ it('should convert INTEGER -129 from DER', function() {
+ var der = UTIL.hexToBytes('ff7f');
+ ASSERT.equal(ASN1.derToInteger(der), -129);
+ });
+
+ it('should convert INTEGER 32768 from DER', function() {
+ var der = UTIL.hexToBytes('008000');
+ ASSERT.equal(ASN1.derToInteger(der), 32768);
+ });
+
+ it('should convert INTEGER -32768 from DER', function() {
+ var der = UTIL.hexToBytes('8000');
+ ASSERT.equal(ASN1.derToInteger(der), -32768);
+ });
+
+ it('should convert INTEGER -32769 from DER', function() {
+ var der = UTIL.hexToBytes('ff7fff');
+ ASSERT.equal(ASN1.derToInteger(der), -32769);
+ });
+
+ it('should convert INTEGER 8388608 from DER', function() {
+ var der = UTIL.hexToBytes('00800000');
+ ASSERT.equal(ASN1.derToInteger(der), 8388608);
+ });
+
+ it('should convert INTEGER -8388608 from DER', function() {
+ var der = UTIL.hexToBytes('800000');
+ ASSERT.equal(ASN1.derToInteger(der), -8388608);
+ });
+
+ it('should convert INTEGER -8388609 from DER', function() {
+ var der = UTIL.hexToBytes('ff7fffff');
+ ASSERT.equal(ASN1.derToInteger(der), -8388609);
+ });
+
+ it('should convert INTEGER 2147483647 from DER', function() {
+ var der = UTIL.hexToBytes('7fffffff');
+ ASSERT.equal(ASN1.derToInteger(der), 2147483647);
+ });
+
+ it('should convert INTEGER -2147483648 from DER', function() {
+ var der = UTIL.hexToBytes('80000000');
+ ASSERT.equal(ASN1.derToInteger(der), -2147483648);
+ });
+
+ (function() {
+ var tests = [{
+ in: '20110223123400',
+ out: 1298464440000
+ }, {
+ in: '20110223123400.1',
+ out: 1298464440100
+ }, {
+ in: '20110223123400.123',
+ out: 1298464440123
+ }];
+ for(var i = 0; i < tests.length; ++i) {
+ var test = tests[i];
+ it('should convert local generalized time "' + test.in + '" to a Date', function() {
+ var d = ASN1.generalizedTimeToDate(test.in);
+ var localOffset = d.getTimezoneOffset() * 60000;
+ ASSERT.equal(d.getTime(), test.out + localOffset);
+ });
+ }
+ })();
+
+ (function() {
+ var tests = [{
+ in: '20110223123400Z', // Wed Feb 23 12:34:00.000 UTC 2011
+ out: 1298464440000
+ }, {
+ in: '20110223123400.1Z', // Wed Feb 23 12:34:00.100 UTC 2011
+ out: 1298464440100
+ }, {
+ in: '20110223123400.123Z', // Wed Feb 23 12:34:00.123 UTC 2011
+ out: 1298464440123
+ }, {
+ in: '20110223123400+0200', // Wed Feb 23 10:34:00.000 UTC 2011
+ out: 1298457240000
+ }, {
+ in: '20110223123400.1+0200', // Wed Feb 23 10:34:00.100 UTC 2011
+ out: 1298457240100
+ }, {
+ in: '20110223123400.123+0200', // Wed Feb 23 10:34:00.123 UTC 2011
+ out: 1298457240123
+ }, {
+ in: '20110223123400-0200', // Wed Feb 23 14:34:00.000 UTC 2011
+ out: 1298471640000
+ }, {
+ in: '20110223123400.1-0200', // Wed Feb 23 14:34:00.100 UTC 2011
+ out: 1298471640100
+ }, {
+ in: '20110223123400.123-0200', // Wed Feb 23 14:34:00.123 UTC 2011
+ out: 1298471640123
+ }];
+ for(var i = 0; i < tests.length; ++i) {
+ var test = tests[i];
+ it('should convert utc generalized time "' + test.in + '" to a Date', function() {
+ var d = ASN1.generalizedTimeToDate(test.in);
+ ASSERT.equal(d.getTime(), test.out);
+ });
+ }
+ })();
+
+ (function() {
+ var tests = [{
+ in: '1102231234Z', // Wed Feb 23 12:34:00 UTC 2011
+ out: 1298464440000
+ }, {
+ in: '1102231234+0200', // Wed Feb 23 10:34:00 UTC 2011
+ out: 1298457240000
+ }, {
+ in: '1102231234-0200', // Wed Feb 23 14:34:00 UTC 2011
+ out: 1298471640000
+ }, {
+ in: '110223123456Z', // Wed Feb 23 12:34:56 UTC 2011
+ out: 1298464496000
+ }, {
+ in: '110223123456+0200', // Wed Feb 23 10:34:56 UTC 2011
+ out: 1298457296000
+ }, {
+ in: '110223123456-0200', // Wed Feb 23 14:34:56 UTC 2011
+ out: 1298471696000
+ }];
+ for(var i = 0; i < tests.length; ++i) {
+ var test = tests[i];
+ it('should convert utc time "' + test.in + '" to a Date', function() {
+ var d = ASN1.utcTimeToDate(test.in);
+ ASSERT.equal(d.getTime(), test.out);
+ });
+ }
+ })();
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/asn1',
+ 'forge/util'
+ ], function(ASN1, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ ASN1(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/asn1')(),
+ require('../../js/util')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/browser.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/browser.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/browser.js
new file mode 100644
index 0000000..a96b2d6
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/browser.js
@@ -0,0 +1,41 @@
+var server = require('../server');
+var grunt = require('grunt');
+
+describe('browser', function() {
+ it('should run tests', function(done) {
+ this.timeout(60 * 1000 * 5);
+
+ return server.main(function(err, info) {
+ if(err) {
+ return done(err);
+ }
+
+ grunt.initConfig({
+ mocha: {
+ all: {
+ options: {
+ reporter: 'List',
+ urls: ['http://localhost:' + info.port + '/index.html']
+ }
+ }
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-mocha');
+
+ grunt.registerInitTask('default', function() {
+ grunt.task.run(['mocha']);
+ });
+ grunt.tasks(['default'], {
+ //debug: true
+ }, function() {
+ if(err) {
+ return done(err);
+ }
+ // finish immediately
+ done(null);
+ return info.server.close();
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/csr.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/csr.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/csr.js
new file mode 100644
index 0000000..340c09f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/csr.js
@@ -0,0 +1,148 @@
+(function() {
+
+function Tests(ASSERT, PKI) {
+ var _pem = {
+ privateKey: '-----BEGIN RSA PRIVATE KEY-----\r\n' +
+ 'MIICXQIBAAKBgQDL0EugUiNGMWscLAVM0VoMdhDZEJOqdsUMpx9U0YZI7szokJqQ\r\n' +
+ 'NIwokiQ6EonNnWSMlIvy46AhnlRYn+ezeTeU7eMGTkP3VF29vXBo+dLq5e+8VyAy\r\n' +
+ 'Q3FzM1wI4ts4hRACF8w6mqygXQ7i/SDu8/rXqRGtvnM+z0MYDdKo80efzwIDAQAB\r\n' +
+ 'AoGAIzkGONi5G+JifmXlLJdplom486p3upf4Ce2/7mqfaG9MnkyPSairKD/JXvfh\r\n' +
+ 'NNWkkN8DKKDKBcVVElPgORYT0qwrWc7ueLBMUCbRXb1ZyfEulimG0R3kjUh7NYau\r\n' +
+ 'DaIkVgfykXGSQMZx8FoaT6L080zd+0emKDDYRrb+/kgJNJECQQDoUZoiC2K/DWNY\r\n' +
+ 'h3/ppZ0ane2y4SBmJUHJVMPQ2CEgxsrJTxet668ckNCKaOP/3VFPoWC41f17DvKq\r\n' +
+ 'noYINNntAkEA4JbZBZBVUrQFhHlrpXT4jzqtO2RlKZzEq8qmFZfEErxOT1WMyyCi\r\n' +
+ 'lAQ5gUKardo1Kf0omC8Xq/uO9ZYdED55KwJBALs6cJ65UFaq4oLJiQPzLd7yokuE\r\n' +
+ 'dcj8g71PLBTW6jPxIiMFNA89nz3FU9wIVp+xbMNhSoMMKqIPVPC+m0Rn260CQQDA\r\n' +
+ 'I83fWK/mZWUjBM33a68KumRiH238v8XyQxj7+C8i6D8G2GXvkigFAehAkb7LZZd+\r\n' +
+ 'KLuGFyPlWv3fVWHf99KpAkBQFKk3MRMl6IGJZUEFQe4l5whm8LkGU4acSqv9B3xt\r\n' +
+ 'qROkCrsFrMPqjuuzEmyHoQZ64r2PLJg7FOuyhBnQUOt4\r\n' +
+ '-----END RSA PRIVATE KEY-----\r\n',
+ publicKey: '-----BEGIN PUBLIC KEY-----\r\n' +
+ 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDL0EugUiNGMWscLAVM0VoMdhDZ\r\n' +
+ 'EJOqdsUMpx9U0YZI7szokJqQNIwokiQ6EonNnWSMlIvy46AhnlRYn+ezeTeU7eMG\r\n' +
+ 'TkP3VF29vXBo+dLq5e+8VyAyQ3FzM1wI4ts4hRACF8w6mqygXQ7i/SDu8/rXqRGt\r\n' +
+ 'vnM+z0MYDdKo80efzwIDAQAB\r\n' +
+ '-----END PUBLIC KEY-----\r\n'
+ };
+
+ describe('csr', function() {
+ it('should generate a certification request', function() {
+ var keys = {
+ privateKey: PKI.privateKeyFromPem(_pem.privateKey),
+ publicKey: PKI.publicKeyFromPem(_pem.publicKey)
+ };
+ var csr = PKI.createCertificationRequest();
+ csr.publicKey = keys.publicKey;
+ csr.setSubject([{
+ name: 'commonName',
+ value: 'example.org'
+ }, {
+ name: 'countryName',
+ value: 'US'
+ }, {
+ shortName: 'ST',
+ value: 'Virginia'
+ }, {
+ name: 'localityName',
+ value: 'Blacksburg'
+ }, {
+ name: 'organizationName',
+ value: 'Test'
+ }, {
+ shortName: 'OU',
+ value: 'Test'
+ }]);
+ // add optional attributes
+ csr.setAttributes([{
+ name: 'challengePassword',
+ value: 'password'
+ }, {
+ name: 'unstructuredName',
+ value: 'My company'
+ }, {
+ name: 'extensionRequest',
+ extensions: [{
+ name: 'subjectAltName',
+ altNames: [{
+ // type 2 is DNS
+ type: 2,
+ value: 'test.domain.com'
+ }, {
+ type: 2,
+ value: 'other.domain.com'
+ }, {
+ type: 2,
+ value: 'www.domain.net'
+ }]
+ }]
+ }]);
+
+ // sign certification request
+ csr.sign(keys.privateKey);
+
+ var pem = PKI.certificationRequestToPem(csr);
+ csr = PKI.certificationRequestFromPem(pem);
+ ASSERT.ok(csr.getAttribute({name: 'extensionRequest'}));
+ ASSERT.equal(csr.getAttribute({name: 'extensionRequest'}).extensions[0].name, 'subjectAltName');
+ ASSERT.deepEqual(csr.getAttribute({name: 'extensionRequest'}).extensions[0].altNames, [{
+ // type 2 is DNS
+ type: 2,
+ value: 'test.domain.com'
+ }, {
+ type: 2,
+ value: 'other.domain.com'
+ }, {
+ type: 2,
+ value: 'www.domain.net'
+ }]);
+ ASSERT.ok(csr.verify());
+ });
+
+ it('should load an OpenSSL-generated certification request', function() {
+ var pem = '-----BEGIN CERTIFICATE REQUEST-----\r\n' +
+ 'MIICdTCCAV0CAQAwMDEVMBMGA1UEAwwMTXlDb21tb25OYW1lMRcwFQYDVQQKDA5N\r\n' +
+ 'eU9yZ2FuaXphdGlvbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKRU\r\n' +
+ 'zrAMbiiSjAYYl3PWsOrNwY0VtemgRZc0t7+3FlWp1e8uIA3KxZFZY875wo0QOvD+\r\n' +
+ 'AdNv5+YnokgzOi83F3T4yewBSR0TiO3Pa4tL4C7CzWnhYliC/owk5bHCV0HLkYUW\r\n' +
+ 'F6z7Lx3HyhoxlKmrHySSPPZRLKp7KcwxbjFc2EfhQV21I73Z1mCG6MEp7cN2qBbQ\r\n' +
+ 'PyOMNjAUibOWs4JJEdUjWhm86EZm9+qfgpL5tlpZCe+kXySrKTp56mMsfSOQvlol\r\n' +
+ 'pRO8pP9AUjaEqRikCZ745I/9W7dHNPUoyxkWV5jRDwcT7s652+L6oxtoqVOXpg28\r\n' +
+ 'uAL0kUZQMa8wkYUKZiMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4IBAQCXQH+ut6tr\r\n' +
+ 'Z/FdIDOljrc7uh8XpFRKS3GqC/PJsEwrV7d3CX5HuWPTuPc9FU5FQ88w6evXEA0o\r\n' +
+ 'ijxHuydeXmdjpy433vXWo1TaRSXh1WaBMG5pW/SlGZK9/Hr1P0v7KN/KCY5nXxoQ\r\n' +
+ 'k3Ndg9HzGrYnRoJVXzvdQeBGwCoJFk4FH+Rxa/F03VTUU5nwx66TsL9JUp9pnbI7\r\n' +
+ 'MR6DIA97LnTmut8Xp0Uurw+zsS5rif9iv0BKHd7eGpNNGl0RXu8E5dbT0zD90TSa\r\n' +
+ 'P5WjxjvY+Udg8XZU+UwT3kcyTEFpiQdkzTIKXg0dFurfUE9XG/9aic9oMZ/IBZz9\r\n' +
+ 'a535a7e9RkbJ\r\n' +
+ '-----END CERTIFICATE REQUEST-----\r\n';
+
+ var csr = PKI.certificationRequestFromPem(pem);
+ ASSERT.equal(csr.subject.getField('CN').value, 'MyCommonName');
+ ASSERT.equal(csr.subject.getField('O').value, 'MyOrganization');
+ ASSERT.equal(csr.signatureOid, PKI.oids.sha1WithRSAEncryption);
+ ASSERT.equal(csr.publicKey.e.toString(16), '10001');
+ ASSERT.equal(csr.publicKey.n.toString(16).toUpperCase(), 'A454CEB00C6E28928C06189773D6B0EACDC18D15B5E9A0459734B7BFB71655A9D5EF2E200DCAC5915963CEF9C28D103AF0FE01D36FE7E627A248333A2F371774F8C9EC01491D1388EDCF6B8B4BE02EC2CD69E1625882FE8C24E5B1C25741CB91851617ACFB2F1DC7CA1A3194A9AB1F24923CF6512CAA7B29CC316E315CD847E1415DB523BDD9D66086E8C129EDC376A816D03F238C36301489B396B3824911D5235A19BCE84666F7EA9F8292F9B65A5909EFA45F24AB293A79EA632C7D2390BE5A25A513BCA4FF40523684A918A4099EF8E48FFD5BB74734F528CB19165798D10F0713EECEB9DBE2FAA31B68A95397A60DBCB802F491465031AF3091850A6623');
+ ASSERT.ok(csr.verify());
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/pki'
+ ], function(PKI) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ PKI()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/pki')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/des.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/des.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/des.js
new file mode 100644
index 0000000..8be2c68
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/des.js
@@ -0,0 +1,155 @@
+(function() {
+
+function Tests(ASSERT, CIPHER, DES, UTIL) {
+ describe('des', function() {
+ // OpenSSL equivalent:
+ // openssl enc -des-ecb -K a1c06b381adf3651 -nosalt
+ it('should des-ecb encrypt: foobar', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf3651'));
+
+ var cipher = CIPHER.createCipher('DES-ECB', key);
+ cipher.start();
+ cipher.update(UTIL.createBuffer('foobar'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), 'b705ffcf3dff06b3');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -d -des-ecb -K a1c06b381adf3651 -nosalt
+ it('should des-ecb decrypt: b705ffcf3dff06b3', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf3651'));
+
+ var decipher = CIPHER.createDecipher('DES-ECB', key);
+ decipher.start();
+ decipher.update(UTIL.createBuffer(UTIL.hexToBytes('b705ffcf3dff06b3')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -des -K a1c06b381adf3651 -iv 818bcf76efc59662 -nosalt
+ it('should des-cbc encrypt: foobar', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf3651'));
+ var iv = new UTIL.createBuffer(
+ UTIL.hexToBytes('818bcf76efc59662'));
+
+ var cipher = CIPHER.createCipher('DES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer('foobar'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), '3261e5839a990454');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -d -des -K a1c06b381adf3651 -iv 818bcf76efc59662 -nosalt
+ it('should des-cbc decrypt: 3261e5839a990454', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf3651'));
+ var iv = new UTIL.createBuffer(
+ UTIL.hexToBytes('818bcf76efc59662'));
+
+ var decipher = CIPHER.createDecipher('DES-CBC', key);
+ decipher.start({iv: iv});
+ decipher.update(UTIL.createBuffer(UTIL.hexToBytes('3261e5839a990454')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -des-ede3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -nosalt
+ it('should 3des-ecb encrypt: foobar', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));
+
+ var cipher = CIPHER.createCipher('3DES-ECB', key);
+ cipher.start();
+ cipher.update(UTIL.createBuffer('foobar'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), 'fce8b1ee8c6440d1');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -d -des-ede3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -nosalt
+ it('should 3des-ecb decrypt: fce8b1ee8c6440d1', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));
+
+ var decipher = CIPHER.createDecipher('3DES-ECB', key);
+ decipher.start();
+ decipher.update(UTIL.createBuffer(UTIL.hexToBytes('fce8b1ee8c6440d1')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -des3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -iv 818bcf76efc59662 -nosalt
+ it('should 3des-cbc encrypt "foobar", restart, and encrypt "foobar,,"', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));
+ var iv = new UTIL.createBuffer(
+ UTIL.hexToBytes('818bcf76efc59662'));
+
+ var cipher = CIPHER.createCipher('3DES-CBC', key);
+ cipher.start({iv: iv.copy()});
+ cipher.update(UTIL.createBuffer('foobar'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), '209225f7687ca0b2');
+
+ cipher.start({iv: iv.copy()});
+ cipher.update(UTIL.createBuffer('foobar,,'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), '57156174c48dfc37293831bf192a6742');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -d -des3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -iv 818bcf76efc59662 -nosalt
+ it('should 3des-cbc decrypt "209225f7687ca0b2", restart, and decrypt "57156174c48dfc37293831bf192a6742,,"', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));
+ var iv = new UTIL.createBuffer(
+ UTIL.hexToBytes('818bcf76efc59662'));
+
+ var decipher = CIPHER.createDecipher('3DES-CBC', key);
+ decipher.start({iv: iv.copy()});
+ decipher.update(UTIL.createBuffer(UTIL.hexToBytes('209225f7687ca0b2')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar');
+
+ decipher.start({iv: iv.copy()});
+ decipher.update(
+ UTIL.createBuffer(UTIL.hexToBytes('57156174c48dfc37293831bf192a6742')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar,,');
+ });
+ });
+}
+
+// check for AMD
+var forge = {};
+if(typeof define === 'function') {
+ define([
+ 'forge/cipher',
+ 'forge/des',
+ 'forge/util'
+ ], function(CIPHER, DES, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ CIPHER(forge),
+ DES(forge),
+ UTIL(forge)
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/cipher')(forge),
+ require('../../js/des')(forge),
+ require('../../js/util')(forge));
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/hmac.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/hmac.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/hmac.js
new file mode 100644
index 0000000..404b36b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/hmac.js
@@ -0,0 +1,85 @@
+(function() {
+
+function Tests(ASSERT, HMAC, UTIL) {
+ describe('hmac', function() {
+ it('should md5 hash "Hi There", 16-byte key', function() {
+ var key = UTIL.hexToBytes('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b');
+ var hmac = HMAC.create();
+ hmac.start('MD5', key);
+ hmac.update('Hi There');
+ ASSERT.equal(hmac.digest().toHex(), '9294727a3638bb1c13f48ef8158bfc9d');
+ });
+
+ it('should md5 hash "what do ya want for nothing?", "Jefe" key', function() {
+ var hmac = HMAC.create();
+ hmac.start('MD5', 'Jefe');
+ hmac.update('what do ya want for nothing?');
+ ASSERT.equal(hmac.digest().toHex(), '750c783e6ab0b503eaa86e310a5db738');
+ });
+
+ it('should md5 hash "Test Using Larger Than Block-Size Key - Hash Key First", 80-byte key', function() {
+ var key = UTIL.hexToBytes(
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+ var hmac = HMAC.create();
+ hmac.start('MD5', key);
+ hmac.update('Test Using Larger Than Block-Size Key - Hash Key First');
+ ASSERT.equal(hmac.digest().toHex(), '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd');
+ });
+
+ it('should sha1 hash "Hi There", 20-byte key', function() {
+ var key = UTIL.hexToBytes('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b');
+ var hmac = HMAC.create();
+ hmac.start('SHA1', key);
+ hmac.update('Hi There');
+ ASSERT.equal(
+ hmac.digest().toHex(), 'b617318655057264e28bc0b6fb378c8ef146be00');
+ });
+
+ it('should sha1 hash "what do ya want for nothing?", "Jefe" key', function() {
+ var hmac = HMAC.create();
+ hmac.start('SHA1', 'Jefe');
+ hmac.update('what do ya want for nothing?');
+ ASSERT.equal(
+ hmac.digest().toHex(), 'effcdf6ae5eb2fa2d27416d5f184df9c259a7c79');
+ });
+
+ it('should sha1 hash "Test Using Larger Than Block-Size Key - Hash Key First", 80-byte key', function() {
+ var key = UTIL.hexToBytes(
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+ var hmac = HMAC.create();
+ hmac.start('SHA1', key);
+ hmac.update('Test Using Larger Than Block-Size Key - Hash Key First');
+ ASSERT.equal(
+ hmac.digest().toHex(), 'aa4ae5e15272d00e95705637ce8a3b55ed402112');
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/hmac',
+ 'forge/util'
+ ], function(HMAC, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ HMAC(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/hmac')(),
+ require('../../js/util')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/kem.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/kem.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/kem.js
new file mode 100644
index 0000000..0415abe
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/kem.js
@@ -0,0 +1,198 @@
+(function() {
+
+function Tests(ASSERT, KEM, MD, RSA, UTIL, JSBN, RANDOM) {
+
+ function FixedSecureRandom(str) {
+ var bytes = UTIL.hexToBytes(str);
+ this.getBytesSync = function(count) {
+ // prepend zeros
+ return UTIL.fillString(String.fromCharCode(0), bytes.length - count) +
+ bytes;
+ };
+ }
+
+ describe('kem', function() {
+ it('should generate and encrypt a symmetric key and decrypt it 10x', function() {
+ for(var i = 0; i < 10; ++i) {
+ var kdf = new KEM.kdf1(MD.sha256.create());
+ var kem = KEM.rsa.create(kdf);
+
+ var pair = RSA.generateKeyPair(512);
+
+ var result = kem.encrypt(pair.publicKey, 256);
+ var key1 = result.key;
+ var key2 = kem.decrypt(pair.privateKey, result.encapsulation, 256);
+
+ ASSERT.equal(UTIL.bytesToHex(key1), UTIL.bytesToHex(key2));
+ }
+ });
+ });
+
+ /**
+ * According to section "C.6 Test vectors for RSA-KEM" from ISO-18033-2 final
+ * draft.
+ */
+ describe('C.6 Test vectors for RSA-KEM from ISO-18033-2 final', function() {
+ it('should pass test vector C.6.1', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '4603e5324cab9cef8365c817052d954d44447b1667099edc69942d32cd594e4ffcf268ae3836e2c35744aaa53ae201fe499806b67dedaa26bf72ecbd117a6fc0';
+ var K = '5f8de105b5e96b2e490ddecbd147dd1def7e3b8e0e6a26eb7b956ccb8b3bdc1ca975bc57c3989e8fbad31a224655d800c46954840ff32052cdf0d640562bdfadfa263cfccf3c52b29f2af4a1869959bc77f854cf15bd7a25192985a842dbff8e13efee5b7e7e55bbe4d389647c686a9a9ab3fb889b2d7767d3837eea4e0a2f04';
+
+ var kdf = new KEM.kdf1(MD.sha1.create());
+ var rnd = new FixedSecureRandom('032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+
+ it('should pass test vector C.6.2', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '4603e5324cab9cef8365c817052d954d44447b1667099edc69942d32cd594e4ffcf268ae3836e2c35744aaa53ae201fe499806b67dedaa26bf72ecbd117a6fc0';
+ var K = '0e6a26eb7b956ccb8b3bdc1ca975bc57c3989e8fbad31a224655d800c46954840ff32052cdf0d640562bdfadfa263cfccf3c52b29f2af4a1869959bc77f854cf15bd7a25192985a842dbff8e13efee5b7e7e55bbe4d389647c686a9a9ab3fb889b2d7767d3837eea4e0a2f04b53ca8f50fb31225c1be2d0126c8c7a4753b0807';
+
+ var kdf = new KEM.kdf2(MD.sha1.create());
+ var rnd = new FixedSecureRandom('032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+
+ it('should pass test vector C.6.3', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '4603e5324cab9cef8365c817052d954d44447b1667099edc69942d32cd594e4ffcf268ae3836e2c35744aaa53ae201fe499806b67dedaa26bf72ecbd117a6fc0';
+ var K = '09e2decf2a6e1666c2f6071ff4298305e2643fd510a2403db42a8743cb989de86e668d168cbe604611ac179f819a3d18412e9eb45668f2923c087c12fee0c5a0d2a8aa70185401fbbd99379ec76c663e875a60b4aacb1319fa11c3365a8b79a44669f26fb555c80391847b05eca1cb5cf8c2d531448d33fbaca19f6410ee1fcb';
+
+ var kdf = new KEM.kdf1(MD.sha256.create(), 20);
+ var rnd = new FixedSecureRandom('032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+
+ it('should pass test vector C.6.4', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '4603e5324cab9cef8365c817052d954d44447b1667099edc69942d32cd594e4ffcf268ae3836e2c35744aaa53ae201fe499806b67dedaa26bf72ecbd117a6fc0';
+ var K = '10a2403db42a8743cb989de86e668d168cbe604611ac179f819a3d18412e9eb45668f2923c087c12fee0c5a0d2a8aa70185401fbbd99379ec76c663e875a60b4aacb1319fa11c3365a8b79a44669f26fb555c80391847b05eca1cb5cf8c2d531448d33fbaca19f6410ee1fcb260892670e0814c348664f6a7248aaf998a3acc6';
+
+ var kdf = new KEM.kdf2(MD.sha256.create(), 20);
+ var rnd = new FixedSecureRandom('00032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+ });
+
+ describe('prepended zeros test', function() {
+ it('should pass when random has leading zeros', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '5f268a76c1aed04bc195a143d7ee768bee0aad308d16196274a02d9c1a72bbe10cbf718de323fc0135c5f8129f96ac8f504d9623960dc54cd87bddee94f5a0b2';
+ var K = '8bf41e59dc1b83142ee32569a347a94539e48c98347c685a29e3aa8b7a3ea714d68c1a43c4a760c9d4a45149b0ce8b681e98076bdd4393394c7832a7fa71848257772ac38a4e7fbe96e8bb383becbb7242841946e82e35d9ef1667245fc82601e7edf53b897f5ce2b6bce8e1e3212abd5a8a99a0c9b99472e22a313dac396383';
+
+ var kdf = new KEM.kdf1(MD.sha1.create());
+ var rnd = new FixedSecureRandom('000e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/kem',
+ 'forge/md',
+ 'forge/rsa',
+ 'forge/util',
+ 'forge/jsbn',
+ 'forge/random'
+ ], function(KEM, MD, RSA, UTIL, JSBN, RANDOM) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ KEM(),
+ MD(),
+ RSA(),
+ UTIL(),
+ JSBN(),
+ RANDOM()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/kem')(),
+ require('../../js/md')(),
+ require('../../js/rsa')(),
+ require('../../js/util')(),
+ require('../../js/jsbn')(),
+ require('../../js/random')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/md5.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/md5.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/md5.js
new file mode 100644
index 0000000..5ab3d58
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/md5.js
@@ -0,0 +1,117 @@
+(function() {
+
+function Tests(ASSERT, MD5, UTIL) {
+ describe('md5', function() {
+ it('should digest the empty string', function() {
+ var md = MD5.create();
+ ASSERT.equal(md.digest().toHex(), 'd41d8cd98f00b204e9800998ecf8427e');
+ });
+
+ it('should digest "abc"', function() {
+ var md = MD5.create();
+ md.update('abc');
+ ASSERT.equal(md.digest().toHex(), '900150983cd24fb0d6963f7d28e17f72');
+ });
+
+ it('should digest "The quick brown fox jumps over the lazy dog"', function() {
+ var md = MD5.create();
+ md.update('The quick brown fox jumps over the lazy dog');
+ ASSERT.equal(md.digest().toHex(), '9e107d9d372bb6826bd81d3542a419d6');
+ });
+
+ it('should digest "c\'\u00e8"', function() {
+ var md = MD5.create();
+ md.update("c\'\u00e8", 'utf8');
+ ASSERT.equal(md.digest().toHex(), '8ef7c2941d78fe89f31e614437c9db59');
+ });
+
+ it('should digest "THIS IS A MESSAGE"', function() {
+ var md = MD5.create();
+ md.start();
+ md.update('THIS IS ');
+ md.update('A MESSAGE');
+ // do twice to check continuing digest
+ ASSERT.equal(md.digest().toHex(), '78eebfd9d42958e3f31244f116ab7bbe');
+ ASSERT.equal(md.digest().toHex(), '78eebfd9d42958e3f31244f116ab7bbe');
+ });
+
+ it('should digest a long message', function() {
+ var input = UTIL.hexToBytes(
+ '0100002903018d32e9c6dc423774c4c39a5a1b78f44cc2cab5f676d39' +
+ 'f703d29bfa27dfeb870000002002f01000200004603014c2c1e835d39' +
+ 'da71bc0857eb04c2b50fe90dbb2a8477fe7364598d6f0575999c20a6c' +
+ '7248c5174da6d03ac711888f762fc4ed54f7254b32273690de849c843' +
+ '073d002f000b0003d20003cf0003cc308203c8308202b0a0030201020' +
+ '20100300d06092a864886f70d0101050500308186310b300906035504' +
+ '0613025553311d301b060355040a13144469676974616c2042617a616' +
+ '1722c20496e632e31443042060355040b133b4269746d756e6b206c6f' +
+ '63616c686f73742d6f6e6c7920436572746966696361746573202d204' +
+ '17574686f72697a6174696f6e20766961204254503112301006035504' +
+ '0313096c6f63616c686f7374301e170d3130303231343137303931395' +
+ 'a170d3230303231333137303931395a308186310b3009060355040613' +
+ '025553311d301b060355040a13144469676974616c2042617a6161722' +
+ 'c20496e632e31443042060355040b133b4269746d756e6b206c6f6361' +
+ '6c686f73742d6f6e6c7920436572746966696361746573202d2041757' +
+ '4686f72697a6174696f6e207669612042545031123010060355040313' +
+ '096c6f63616c686f737430820122300d06092a864886f70d010101050' +
+ '00382010f003082010a0282010100dc436f17d6909d8a9d6186ea218e' +
+ 'b5c86b848bae02219bd56a71203daf07e81bc19e7e98134136bcb0128' +
+ '81864bf03b3774652ad5eab85dba411a5114ffeac09babce75f313143' +
+ '45512cd87c91318b2e77433270a52185fc16f428c3ca412ad6e9484bc' +
+ '2fb87abb4e8fb71bf0f619e31a42340b35967f06c24a741a31c979c0b' +
+ 'b8921a90a47025fbeb8adca576979e70a56830c61170c9647c18c0794' +
+ 'd68c0df38f3aac5fc3b530e016ea5659715339f3f3c209cdee9dbe794' +
+ 'b5af92530c5754c1d874b78974bfad994e0dfc582275e79feb522f6e4' +
+ 'bcc2b2945baedfb0dbdaebb605f9483ff0bea29ecd5f4d6f2769965d1' +
+ 'b3e04f8422716042680011ff676f0203010001a33f303d300c0603551' +
+ 'd130101ff04023000300e0603551d0f0101ff0404030204f0301d0603' +
+ '551d250416301406082b0601050507030106082b06010505070302300' +
+ 'd06092a864886f70d010105050003820101009c4562be3f2d8d8e3880' +
+ '85a697f2f106eaeff4992a43f198fe3dcf15c8229cf1043f061a38204' +
+ 'f73d86f4fb6348048cc5279ed719873aa10e3773d92b629c2c3fcce04' +
+ '012c81ba3b4ec451e9644ec5191078402d845e05d02c7b4d974b45882' +
+ '76e5037aba7ef26a8bddeb21e10698c82f425e767dc401adf722fa73a' +
+ 'b78cfa069bd69052d7ca6a75cc9225550e315d71c5f8764362ea4dbc6' +
+ 'ecb837a8471043c5a7f826a71af145a053090bd4bccca6a2c552841cd' +
+ 'b1908a8352f49283d2e641acdef667c7543af441a16f8294251e2ac37' +
+ '6fa507b53ae418dd038cd20cef1e7bfbf5ae03a7c88d93d843abaabbd' +
+ 'c5f3431132f3e559d2dd414c3eda38a210b80e0000001000010201002' +
+ '6a220b7be857402819b78d81080d01a682599bbd00902985cc64edf8e' +
+ '520e4111eb0e1729a14ffa3498ca259cc9ad6fc78fa130d968ebdb78d' +
+ 'c0b950c0aa44355f13ba678419185d7e4608fe178ca6b2cef33e41937' +
+ '78d1a70fe4d0dfcb110be4bbb4dbaa712177655728f914ab4c0f6c4ae' +
+ 'f79a46b3d996c82b2ebe9ed1748eb5cace7dc44fb67e73f452a047f2e' +
+ 'd199b3d50d5db960acf03244dc8efa4fc129faf8b65f9e52e62b55447' +
+ '22bd17d2358e817a777618a4265a3db277fc04851a82a91fe6cdcb812' +
+ '7f156e0b4a5d1f54ce2742eb70c895f5f8b85f5febe69bc73e891f928' +
+ '0826860a0c2ef94c7935e6215c3c4cd6b0e43e80cca396d913d36be');
+
+ var md = MD5.create();
+ md.update(input);
+ ASSERT.equal(md.digest().toHex(), 'd15a2da0e92c3da55dc573f885b6e653');
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/md5',
+ 'forge/util'
+ ], function(MD5, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ MD5(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/md5')(),
+ require('../../js/util')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/mgf1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/mgf1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/mgf1.js
new file mode 100644
index 0000000..6c54ff1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/mgf1.js
@@ -0,0 +1,39 @@
+(function() {
+
+function Tests(ASSERT, MGF, MD, UTIL) {
+ describe('mgf1', function() {
+ it('should digest the empty string', function() {
+ var seed = UTIL.hexToBytes('032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var expect = UTIL.hexToBytes('5f8de105b5e96b2e490ddecbd147dd1def7e3b8e0e6a26eb7b956ccb8b3bdc1ca975bc57c3989e8fbad31a224655d800c46954840ff32052cdf0d640562bdfadfa263cfccf3c52b29f2af4a1869959bc77f854cf15bd7a25192985a842dbff8e13efee5b7e7e55bbe4d389647c686a9a9ab3fb889b2d7767d3837eea4e0a2f04');
+ var mgf = MGF.mgf1.create(MD.sha1.create());
+ var result = mgf.generate(seed, expect.length);
+ ASSERT.equal(result, expect);
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/mgf',
+ 'forge/md',
+ 'forge/util'
+ ], function(MGF, MD, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ MGF(),
+ MD(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/mgf')(),
+ require('../../js/md')(),
+ require('../../js/util')());
+}
+
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[36/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_null-eq.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_null-eq.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_null-eq.selector
new file mode 100644
index 0000000..d015ac3
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_null-eq.selector
@@ -0,0 +1,4 @@
+:expr(null=x)
+
+
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_number-eq.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_number-eq.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_number-eq.output
new file mode 100644
index 0000000..d81cc07
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_number-eq.output
@@ -0,0 +1 @@
+42
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_number-eq.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_number-eq.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_number-eq.selector
new file mode 100644
index 0000000..4440ecb
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_number-eq.selector
@@ -0,0 +1 @@
+:expr(42 = x)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-1.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-1.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-1.output
new file mode 100644
index 0000000..f32a580
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-1.output
@@ -0,0 +1 @@
+true
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-1.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-1.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-1.selector
new file mode 100644
index 0000000..eb214ef
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-1.selector
@@ -0,0 +1 @@
+.true:expr( 4 + 5 * 6 / 5 + 3 * 2 = 16 )
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-2.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-2.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-2.output
new file mode 100644
index 0000000..27ba77d
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-2.output
@@ -0,0 +1 @@
+true
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-2.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-2.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-2.selector
new file mode 100644
index 0000000..79c7f2c
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_precedence-2.selector
@@ -0,0 +1 @@
+.true:expr( (4 + 5) * 6 / (2 + 1) * 2 = 36 )
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple-false.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple-false.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple-false.output
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple-false.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple-false.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple-false.selector
new file mode 100644
index 0000000..d39a80a
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple-false.selector
@@ -0,0 +1 @@
+.true:expr(1=2)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple.output
new file mode 100644
index 0000000..27ba77d
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple.output
@@ -0,0 +1 @@
+true
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple.selector
new file mode 100644
index 0000000..d912927
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_simple.selector
@@ -0,0 +1 @@
+.true:expr(1=1)
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_starts-with.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_starts-with.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_starts-with.output
new file mode 100644
index 0000000..f07ea50
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_starts-with.output
@@ -0,0 +1 @@
+"foo.exe"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_starts-with.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_starts-with.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_starts-with.selector
new file mode 100644
index 0000000..f76cd75
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_starts-with.selector
@@ -0,0 +1 @@
+:expr(x ^= "foo")
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_string-eq.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_string-eq.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_string-eq.output
new file mode 100644
index 0000000..f07ea50
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_string-eq.output
@@ -0,0 +1 @@
+"foo.exe"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_string-eq.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_string-eq.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_string-eq.selector
new file mode 100644
index 0000000..0f19d62
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_string-eq.selector
@@ -0,0 +1 @@
+:expr(x = "foo.exe")
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_true-eq.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_true-eq.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_true-eq.output
new file mode 100644
index 0000000..28b0c28
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_true-eq.output
@@ -0,0 +1,3 @@
+true
+
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_true-eq.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_true-eq.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_true-eq.selector
new file mode 100644
index 0000000..02e1841
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/expr_true-eq.selector
@@ -0,0 +1,2 @@
+:expr(true = x)
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids.json
new file mode 100644
index 0000000..2429d0f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids.json
@@ -0,0 +1,15 @@
+[
+ {
+ "language": "Bulgarian",
+ "level": "advanced"
+ },
+ {
+ "language": "English",
+ "level": "native",
+ "preferred": true
+ },
+ {
+ "language": "Spanish",
+ "level": "beginner"
+ }
+]
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_has-with_descendant.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_has-with_descendant.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_has-with_descendant.output
new file mode 100644
index 0000000..9699f99
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_has-with_descendant.output
@@ -0,0 +1 @@
+"English"
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_has-with_descendant.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_has-with_descendant.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_has-with_descendant.selector
new file mode 100644
index 0000000..84d51be
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_has-with_descendant.selector
@@ -0,0 +1 @@
+:has(.preferred) > .language
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_val.output
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_val.output b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_val.output
new file mode 100644
index 0000000..fd1d03f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_val.output
@@ -0,0 +1,2 @@
+"advanced"
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_val.selector
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_val.selector b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_val.selector
new file mode 100644
index 0000000..076f443
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/JSONSelect/src/test/tests/level_3/polykids_val.selector
@@ -0,0 +1 @@
+:has(:root > .language:val("Bulgarian")) > .level
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/.npmignore
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/.npmignore b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/.npmignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/.npmignore
@@ -0,0 +1 @@
+node_modules
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/LICENSE
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/LICENSE b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/LICENSE
new file mode 100644
index 0000000..7b75500
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/LICENSE
@@ -0,0 +1,24 @@
+Copyright 2010 James Halliday (mail@substack.net)
+
+This project is free software released under the MIT/X11 license:
+http://www.opensource.org/licenses/mit-license.php
+
+Copyright 2010 James Halliday (mail@substack.net)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/README.markdown
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/README.markdown b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/README.markdown
new file mode 100644
index 0000000..0734006
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/README.markdown
@@ -0,0 +1,273 @@
+traverse
+========
+
+Traverse and transform objects by visiting every node on a recursive walk.
+
+examples
+========
+
+transform negative numbers in-place
+-----------------------------------
+
+negative.js
+
+````javascript
+var traverse = require('traverse');
+var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];
+
+traverse(obj).forEach(function (x) {
+ if (x < 0) this.update(x + 128);
+});
+
+console.dir(obj);
+````
+
+Output:
+
+ [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ]
+
+collect leaf nodes
+------------------
+
+leaves.js
+
+````javascript
+var traverse = require('traverse');
+
+var obj = {
+ a : [1,2,3],
+ b : 4,
+ c : [5,6],
+ d : { e : [7,8], f : 9 },
+};
+
+var leaves = traverse(obj).reduce(function (acc, x) {
+ if (this.isLeaf) acc.push(x);
+ return acc;
+}, []);
+
+console.dir(leaves);
+````
+
+Output:
+
+ [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
+
+scrub circular references
+-------------------------
+
+scrub.js:
+
+````javascript
+var traverse = require('traverse');
+
+var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+obj.c.push(obj);
+
+var scrubbed = traverse(obj).map(function (x) {
+ if (this.circular) this.remove()
+});
+console.dir(scrubbed);
+````
+
+output:
+
+ { a: 1, b: 2, c: [ 3, 4 ] }
+
+context
+=======
+
+Each method that takes a callback has a context (its `this` object) with these
+attributes:
+
+this.node
+---------
+
+The present node on the recursive walk
+
+this.path
+---------
+
+An array of string keys from the root to the present node
+
+this.parent
+-----------
+
+The context of the node's parent.
+This is `undefined` for the root node.
+
+this.key
+--------
+
+The name of the key of the present node in its parent.
+This is `undefined` for the root node.
+
+this.isRoot, this.notRoot
+-------------------------
+
+Whether the present node is the root node
+
+this.isLeaf, this.notLeaf
+-------------------------
+
+Whether or not the present node is a leaf node (has no children)
+
+this.level
+----------
+
+Depth of the node within the traversal
+
+this.circular
+-------------
+
+If the node equals one of its parents, the `circular` attribute is set to the
+context of that parent and the traversal progresses no deeper.
+
+this.update(value, stopHere=false)
+----------------------------------
+
+Set a new value for the present node.
+
+All the elements in `value` will be recursively traversed unless `stopHere` is
+true.
+
+this.remove()
+-------------
+
+Remove the current element from the output. If the node is in an Array it will
+be spliced off. Otherwise it will be deleted from its parent.
+
+this.delete()
+-------------
+
+Delete the current element from its parent in the output. Calls `delete` even on
+Arrays.
+
+this.before(fn)
+---------------
+
+Call this function before any of the children are traversed.
+
+You can assign into `this.keys` here to traverse in a custom order.
+
+this.after(fn)
+--------------
+
+Call this function after any of the children are traversed.
+
+this.pre(fn)
+------------
+
+Call this function before each of the children are traversed.
+
+this.post(fn)
+-------------
+
+Call this function after each of the children are traversed.
+
+methods
+=======
+
+.map(fn)
+--------
+
+Execute `fn` for each node in the object and return a new object with the
+results of the walk. To update nodes in the result use `this.update(value)`.
+
+.forEach(fn)
+------------
+
+Execute `fn` for each node in the object but unlike `.map()`, when
+`this.update()` is called it updates the object in-place.
+
+.reduce(fn, acc)
+----------------
+
+For each node in the object, perform a
+[left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function))
+with the return value of `fn(acc, node)`.
+
+If `acc` isn't specified, `acc` is set to the root object for the first step
+and the root element is skipped.
+
+.deepEqual(obj)
+---------------
+
+Returns a boolean, whether the instance value is equal to the supplied object
+along a deep traversal using some opinionated choices.
+
+Some notes:
+
+* RegExps are equal if their .toString()s match, but not functions since
+functions can close over different variables.
+
+* Date instances are compared using `.getTime()` just like `assert.deepEqual()`.
+
+* Circular references must refer to the same paths within the data structure for
+both objects. For instance, in this snippet:
+
+````javascript
+var a = [1];
+a.push(a); // a = [ 1, *a ]
+
+var b = [1];
+b.push(a); // b = [ 1, [ 1, *a ] ]
+````
+
+`a` is not the same as `b` since even though the expansion is the same, the
+circular references in each refer to different paths into the data structure.
+
+However, in:
+
+````javascript
+var c = [1];
+c.push(c); // c = [ 1, *c ];
+````
+
+`c` is equal to `a` in a `deepEqual()` because they have the same terminal node
+structure.
+
+* Arguments objects are not arrays and neither are they the same as regular
+objects.
+
+* Instances created with `new` of String, Boolean, and Number types are never
+equal to the native versions.
+
+.paths()
+--------
+
+Return an `Array` of every possible non-cyclic path in the object.
+Paths are `Array`s of string keys.
+
+.nodes()
+--------
+
+Return an `Array` of every node in the object.
+
+.clone()
+--------
+
+Create a deep clone of the object.
+
+installation
+============
+
+Using npm:
+ npm install traverse
+
+Or check out the repository and link your development copy:
+ git clone http://github.com/substack/js-traverse.git
+ cd js-traverse
+ npm link .
+
+You can test traverse with "expresso":http://github.com/visionmedia/expresso
+(`npm install expresso`):
+ js-traverse $ expresso
+
+ 100% wahoo, your stuff is not broken!
+
+hash transforms
+===============
+
+This library formerly had a hash transformation component. It has been
+[moved to the hashish package](https://github.com/substack/node-hashish).
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/json.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/json.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/json.js
new file mode 100755
index 0000000..50d612e
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/json.js
@@ -0,0 +1,16 @@
+var traverse = require('traverse');
+
+var id = 54;
+var callbacks = {};
+var obj = { moo : function () {}, foo : [2,3,4, function () {}] };
+
+var scrubbed = traverse(obj).map(function (x) {
+ if (typeof x === 'function') {
+ callbacks[id] = { id : id, f : x, path : this.path };
+ this.update('[Function]');
+ id++;
+ }
+});
+
+console.dir(scrubbed);
+console.dir(callbacks);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/leaves.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/leaves.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/leaves.js
new file mode 100755
index 0000000..c1b310b
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/leaves.js
@@ -0,0 +1,15 @@
+var traverse = require('traverse');
+
+var obj = {
+ a : [1,2,3],
+ b : 4,
+ c : [5,6],
+ d : { e : [7,8], f : 9 },
+};
+
+var leaves = traverse(obj).reduce(function (acc, x) {
+ if (this.isLeaf) acc.push(x);
+ return acc;
+}, []);
+
+console.dir(leaves);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/negative.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/negative.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/negative.js
new file mode 100755
index 0000000..78608a0
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/negative.js
@@ -0,0 +1,8 @@
+var traverse = require('traverse');
+var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];
+
+traverse(obj).forEach(function (x) {
+ if (x < 0) this.update(x + 128);
+});
+
+console.dir(obj);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/scrub.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/scrub.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/scrub.js
new file mode 100755
index 0000000..5d15b91
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/scrub.js
@@ -0,0 +1,10 @@
+// scrub out circular references
+var traverse = require('traverse');
+
+var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+obj.c.push(obj);
+
+var scrubbed = traverse(obj).map(function (x) {
+ if (this.circular) this.remove()
+});
+console.dir(scrubbed);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/stringify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/stringify.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/stringify.js
new file mode 100755
index 0000000..167b68b
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/examples/stringify.js
@@ -0,0 +1,38 @@
+#!/usr/bin/env node
+var traverse = require('traverse');
+
+var obj = [ 'five', 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];
+
+var s = '';
+traverse(obj).forEach(function to_s (node) {
+ if (Array.isArray(node)) {
+ this.before(function () { s += '[' });
+ this.post(function (child) {
+ if (!child.isLast) s += ',';
+ });
+ this.after(function () { s += ']' });
+ }
+ else if (typeof node == 'object') {
+ this.before(function () { s += '{' });
+ this.pre(function (x, key) {
+ to_s(key);
+ s += ':';
+ });
+ this.post(function (child) {
+ if (!child.isLast) s += ',';
+ });
+ this.after(function () { s += '}' });
+ }
+ else if (typeof node == 'string') {
+ s += '"' + node.toString().replace(/"/g, '\\"') + '"';
+ }
+ else if (typeof node == 'function') {
+ s += 'null';
+ }
+ else {
+ s += node.toString();
+ }
+});
+
+console.log('JSON.stringify: ' + JSON.stringify(obj));
+console.log('this stringify: ' + s);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/index.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/index.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/index.js
new file mode 100644
index 0000000..7161685
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/index.js
@@ -0,0 +1,332 @@
+module.exports = Traverse;
+function Traverse (obj) {
+ if (!(this instanceof Traverse)) return new Traverse(obj);
+ this.value = obj;
+}
+
+Traverse.prototype.get = function (ps) {
+ var node = this.value;
+ for (var i = 0; i < ps.length; i ++) {
+ var key = ps[i];
+ if (!Object.hasOwnProperty.call(node, key)) {
+ node = undefined;
+ break;
+ }
+ node = node[key];
+ }
+ return node;
+};
+
+Traverse.prototype.set = function (ps, value) {
+ var node = this.value;
+ for (var i = 0; i < ps.length - 1; i ++) {
+ var key = ps[i];
+ if (!Object.hasOwnProperty.call(node, key)) node[key] = {};
+ node = node[key];
+ }
+ node[ps[i]] = value;
+ return value;
+};
+
+Traverse.prototype.map = function (cb) {
+ return walk(this.value, cb, true);
+};
+
+Traverse.prototype.forEach = function (cb) {
+ this.value = walk(this.value, cb, false);
+ return this.value;
+};
+
+Traverse.prototype.reduce = function (cb, init) {
+ var skip = arguments.length === 1;
+ var acc = skip ? this.value : init;
+ this.forEach(function (x) {
+ if (!this.isRoot || !skip) {
+ acc = cb.call(this, acc, x);
+ }
+ });
+ return acc;
+};
+
+Traverse.prototype.deepEqual = function (obj) {
+ if (arguments.length !== 1) {
+ throw new Error(
+ 'deepEqual requires exactly one object to compare against'
+ );
+ }
+
+ var equal = true;
+ var node = obj;
+
+ this.forEach(function (y) {
+ var notEqual = (function () {
+ equal = false;
+ //this.stop();
+ return undefined;
+ }).bind(this);
+
+ //if (node === undefined || node === null) return notEqual();
+
+ if (!this.isRoot) {
+ /*
+ if (!Object.hasOwnProperty.call(node, this.key)) {
+ return notEqual();
+ }
+ */
+ if (typeof node !== 'object') return notEqual();
+ node = node[this.key];
+ }
+
+ var x = node;
+
+ this.post(function () {
+ node = x;
+ });
+
+ var toS = function (o) {
+ return Object.prototype.toString.call(o);
+ };
+
+ if (this.circular) {
+ if (Traverse(obj).get(this.circular.path) !== x) notEqual();
+ }
+ else if (typeof x !== typeof y) {
+ notEqual();
+ }
+ else if (x === null || y === null || x === undefined || y === undefined) {
+ if (x !== y) notEqual();
+ }
+ else if (x.__proto__ !== y.__proto__) {
+ notEqual();
+ }
+ else if (x === y) {
+ // nop
+ }
+ else if (typeof x === 'function') {
+ if (x instanceof RegExp) {
+ // both regexps on account of the __proto__ check
+ if (x.toString() != y.toString()) notEqual();
+ }
+ else if (x !== y) notEqual();
+ }
+ else if (typeof x === 'object') {
+ if (toS(y) === '[object Arguments]'
+ || toS(x) === '[object Arguments]') {
+ if (toS(x) !== toS(y)) {
+ notEqual();
+ }
+ }
+ else if (x instanceof Date || y instanceof Date) {
+ if (!(x instanceof Date) || !(y instanceof Date)
+ || x.getTime() !== y.getTime()) {
+ notEqual();
+ }
+ }
+ else {
+ var kx = Object.keys(x);
+ var ky = Object.keys(y);
+ if (kx.length !== ky.length) return notEqual();
+ for (var i = 0; i < kx.length; i++) {
+ var k = kx[i];
+ if (!Object.hasOwnProperty.call(y, k)) {
+ notEqual();
+ }
+ }
+ }
+ }
+ });
+
+ return equal;
+};
+
+Traverse.prototype.paths = function () {
+ var acc = [];
+ this.forEach(function (x) {
+ acc.push(this.path);
+ });
+ return acc;
+};
+
+Traverse.prototype.nodes = function () {
+ var acc = [];
+ this.forEach(function (x) {
+ acc.push(this.node);
+ });
+ return acc;
+};
+
+Traverse.prototype.clone = function () {
+ var parents = [], nodes = [];
+
+ return (function clone (src) {
+ for (var i = 0; i < parents.length; i++) {
+ if (parents[i] === src) {
+ return nodes[i];
+ }
+ }
+
+ if (typeof src === 'object' && src !== null) {
+ var dst = copy(src);
+
+ parents.push(src);
+ nodes.push(dst);
+
+ Object.keys(src).forEach(function (key) {
+ dst[key] = clone(src[key]);
+ });
+
+ parents.pop();
+ nodes.pop();
+ return dst;
+ }
+ else {
+ return src;
+ }
+ })(this.value);
+};
+
+function walk (root, cb, immutable) {
+ var path = [];
+ var parents = [];
+ var alive = true;
+
+ return (function walker (node_) {
+ var node = immutable ? copy(node_) : node_;
+ var modifiers = {};
+
+ var keepGoing = true;
+
+ var state = {
+ node : node,
+ node_ : node_,
+ path : [].concat(path),
+ parent : parents[parents.length - 1],
+ parents : parents,
+ key : path.slice(-1)[0],
+ isRoot : path.length === 0,
+ level : path.length,
+ circular : null,
+ update : function (x, stopHere) {
+ if (!state.isRoot) {
+ state.parent.node[state.key] = x;
+ }
+ state.node = x;
+ if (stopHere) keepGoing = false;
+ },
+ 'delete' : function () {
+ delete state.parent.node[state.key];
+ },
+ remove : function () {
+ if (Array.isArray(state.parent.node)) {
+ state.parent.node.splice(state.key, 1);
+ }
+ else {
+ delete state.parent.node[state.key];
+ }
+ },
+ keys : null,
+ before : function (f) { modifiers.before = f },
+ after : function (f) { modifiers.after = f },
+ pre : function (f) { modifiers.pre = f },
+ post : function (f) { modifiers.post = f },
+ stop : function () { alive = false },
+ block : function () { keepGoing = false }
+ };
+
+ if (!alive) return state;
+
+ if (typeof node === 'object' && node !== null) {
+ state.keys = Object.keys(node);
+
+ state.isLeaf = state.keys.length == 0;
+
+ for (var i = 0; i < parents.length; i++) {
+ if (parents[i].node_ === node_) {
+ state.circular = parents[i];
+ break;
+ }
+ }
+ }
+ else {
+ state.isLeaf = true;
+ }
+
+ state.notLeaf = !state.isLeaf;
+ state.notRoot = !state.isRoot;
+
+ // use return values to update if defined
+ var ret = cb.call(state, state.node);
+ if (ret !== undefined && state.update) state.update(ret);
+
+ if (modifiers.before) modifiers.before.call(state, state.node);
+
+ if (!keepGoing) return state;
+
+ if (typeof state.node == 'object'
+ && state.node !== null && !state.circular) {
+ parents.push(state);
+
+ state.keys.forEach(function (key, i) {
+ path.push(key);
+
+ if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);
+
+ var child = walker(state.node[key]);
+ if (immutable && Object.hasOwnProperty.call(state.node, key)) {
+ state.node[key] = child.node;
+ }
+
+ child.isLast = i == state.keys.length - 1;
+ child.isFirst = i == 0;
+
+ if (modifiers.post) modifiers.post.call(state, child);
+
+ path.pop();
+ });
+ parents.pop();
+ }
+
+ if (modifiers.after) modifiers.after.call(state, state.node);
+
+ return state;
+ })(root).node;
+}
+
+Object.keys(Traverse.prototype).forEach(function (key) {
+ Traverse[key] = function (obj) {
+ var args = [].slice.call(arguments, 1);
+ var t = Traverse(obj);
+ return t[key].apply(t, args);
+ };
+});
+
+function copy (src) {
+ if (typeof src === 'object' && src !== null) {
+ var dst;
+
+ if (Array.isArray(src)) {
+ dst = [];
+ }
+ else if (src instanceof Date) {
+ dst = new Date(src);
+ }
+ else if (src instanceof Boolean) {
+ dst = new Boolean(src);
+ }
+ else if (src instanceof Number) {
+ dst = new Number(src);
+ }
+ else if (src instanceof String) {
+ dst = new String(src);
+ }
+ else {
+ dst = Object.create(Object.getPrototypeOf(src));
+ }
+
+ Object.keys(src).forEach(function (key) {
+ dst[key] = src[key];
+ });
+ return dst;
+ }
+ else return src;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/package.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/package.json
new file mode 100644
index 0000000..e337200
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "traverse",
+ "version": "0.4.6",
+ "description": "Traverse and transform objects by visiting every node on a recursive walk",
+ "author": {
+ "name": "James Halliday"
+ },
+ "license": "MIT/X11",
+ "main": "./index",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/substack/js-traverse.git"
+ },
+ "devDependencies": {
+ "expresso": "0.7.x"
+ },
+ "scripts": {
+ "test": "expresso"
+ },
+ "_id": "traverse@0.4.6",
+ "dependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "_engineSupported": true,
+ "_npmVersion": "1.0.10",
+ "_nodeVersion": "v0.5.0-pre",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "d04b2280e4c792a5815429ef7b8b60c64c9ccc34",
+ "tarball": "http://registry.npmjs.org/traverse/-/traverse-0.4.6.tgz"
+ },
+ "directories": {},
+ "_shasum": "d04b2280e4c792a5815429ef7b8b60c64c9ccc34",
+ "_from": "traverse@0.4.x",
+ "_resolved": "https://registry.npmjs.org/traverse/-/traverse-0.4.6.tgz",
+ "bugs": {
+ "url": "https://github.com/substack/js-traverse/issues"
+ },
+ "readme": "ERROR: No README data found!",
+ "homepage": "https://github.com/substack/js-traverse"
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/circular.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/circular.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/circular.js
new file mode 100644
index 0000000..e1eef3f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/circular.js
@@ -0,0 +1,114 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+var util = require('util');
+
+exports.circular = function () {
+ var obj = { x : 3 };
+ obj.y = obj;
+ var foundY = false;
+ Traverse(obj).forEach(function (x) {
+ if (this.path.join('') == 'y') {
+ assert.equal(
+ util.inspect(this.circular.node),
+ util.inspect(obj)
+ );
+ foundY = true;
+ }
+ });
+ assert.ok(foundY);
+};
+
+exports.deepCirc = function () {
+ var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] };
+ obj.y[2] = obj;
+
+ var times = 0;
+ Traverse(obj).forEach(function (x) {
+ if (this.circular) {
+ assert.deepEqual(this.circular.path, []);
+ assert.deepEqual(this.path, [ 'y', 2 ]);
+ times ++;
+ }
+ });
+
+ assert.deepEqual(times, 1);
+};
+
+exports.doubleCirc = function () {
+ var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] };
+ obj.y[2] = obj;
+ obj.x.push(obj.y);
+
+ var circs = [];
+ Traverse(obj).forEach(function (x) {
+ if (this.circular) {
+ circs.push({ circ : this.circular, self : this, node : x });
+ }
+ });
+
+ assert.deepEqual(circs[0].self.path, [ 'x', 3, 2 ]);
+ assert.deepEqual(circs[0].circ.path, []);
+
+ assert.deepEqual(circs[1].self.path, [ 'y', 2 ]);
+ assert.deepEqual(circs[1].circ.path, []);
+
+ assert.deepEqual(circs.length, 2);
+};
+
+exports.circDubForEach = function () {
+ var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] };
+ obj.y[2] = obj;
+ obj.x.push(obj.y);
+
+ Traverse(obj).forEach(function (x) {
+ if (this.circular) this.update('...');
+ });
+
+ assert.deepEqual(obj, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] });
+};
+
+exports.circDubMap = function () {
+ var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] };
+ obj.y[2] = obj;
+ obj.x.push(obj.y);
+
+ var c = Traverse(obj).map(function (x) {
+ if (this.circular) {
+ this.update('...');
+ }
+ });
+
+ assert.deepEqual(c, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] });
+};
+
+exports.circClone = function () {
+ var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] };
+ obj.y[2] = obj;
+ obj.x.push(obj.y);
+
+ var clone = Traverse.clone(obj);
+ assert.ok(obj !== clone);
+
+ assert.ok(clone.y[2] === clone);
+ assert.ok(clone.y[2] !== obj);
+ assert.ok(clone.x[3][2] === clone);
+ assert.ok(clone.x[3][2] !== obj);
+ assert.deepEqual(clone.x.slice(0,3), [1,2,3]);
+ assert.deepEqual(clone.y.slice(0,2), [4,5]);
+};
+
+exports.circMapScrub = function () {
+ var obj = { a : 1, b : 2 };
+ obj.c = obj;
+
+ var scrubbed = Traverse(obj).map(function (node) {
+ if (this.circular) this.remove();
+ });
+ assert.deepEqual(
+ Object.keys(scrubbed).sort(),
+ [ 'a', 'b' ]
+ );
+ assert.ok(Traverse.deepEqual(scrubbed, { a : 1, b : 2 }));
+
+ assert.equal(obj.c, obj);
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/date.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/date.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/date.js
new file mode 100644
index 0000000..2cb8252
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/date.js
@@ -0,0 +1,35 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+
+exports.dateEach = function () {
+ var obj = { x : new Date, y : 10, z : 5 };
+
+ var counts = {};
+
+ Traverse(obj).forEach(function (node) {
+ var t = (node instanceof Date && 'Date') || typeof node;
+ counts[t] = (counts[t] || 0) + 1;
+ });
+
+ assert.deepEqual(counts, {
+ object : 1,
+ Date : 1,
+ number : 2,
+ });
+};
+
+exports.dateMap = function () {
+ var obj = { x : new Date, y : 10, z : 5 };
+
+ var res = Traverse(obj).map(function (node) {
+ if (typeof node === 'number') this.update(node + 100);
+ });
+
+ assert.ok(obj.x !== res.x);
+ assert.deepEqual(res, {
+ x : obj.x,
+ y : 110,
+ z : 105,
+ });
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/equal.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/equal.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/equal.js
new file mode 100644
index 0000000..4d732fa
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/equal.js
@@ -0,0 +1,219 @@
+var assert = require('assert');
+var traverse = require('traverse');
+
+exports.deepDates = function () {
+ assert.ok(
+ traverse.deepEqual(
+ { d : new Date, x : [ 1, 2, 3 ] },
+ { d : new Date, x : [ 1, 2, 3 ] }
+ ),
+ 'dates should be equal'
+ );
+
+ var d0 = new Date;
+ setTimeout(function () {
+ assert.ok(
+ !traverse.deepEqual(
+ { d : d0, x : [ 1, 2, 3 ], },
+ { d : new Date, x : [ 1, 2, 3 ] }
+ ),
+ 'microseconds should count in date equality'
+ );
+ }, 5);
+};
+
+exports.deepCircular = function () {
+ var a = [1];
+ a.push(a); // a = [ 1, *a ]
+
+ var b = [1];
+ b.push(a); // b = [ 1, [ 1, *a ] ]
+
+ assert.ok(
+ !traverse.deepEqual(a, b),
+ 'circular ref mount points count towards equality'
+ );
+
+ var c = [1];
+ c.push(c); // c = [ 1, *c ]
+ assert.ok(
+ traverse.deepEqual(a, c),
+ 'circular refs are structurally the same here'
+ );
+
+ var d = [1];
+ d.push(a); // c = [ 1, [ 1, *d ] ]
+ assert.ok(
+ traverse.deepEqual(b, d),
+ 'non-root circular ref structural comparison'
+ );
+};
+
+exports.deepInstances = function () {
+ assert.ok(
+ !traverse.deepEqual([ new Boolean(false) ], [ false ]),
+ 'boolean instances are not real booleans'
+ );
+
+ assert.ok(
+ !traverse.deepEqual([ new String('x') ], [ 'x' ]),
+ 'string instances are not real strings'
+ );
+
+ assert.ok(
+ !traverse.deepEqual([ new Number(4) ], [ 4 ]),
+ 'number instances are not real numbers'
+ );
+
+ assert.ok(
+ traverse.deepEqual([ new RegExp('x') ], [ /x/ ]),
+ 'regexp instances are real regexps'
+ );
+
+ assert.ok(
+ !traverse.deepEqual([ new RegExp(/./) ], [ /../ ]),
+ 'these regexps aren\'t the same'
+ );
+
+ assert.ok(
+ !traverse.deepEqual(
+ [ function (x) { return x * 2 } ],
+ [ function (x) { return x * 2 } ]
+ ),
+ 'functions with the same .toString() aren\'t necessarily the same'
+ );
+
+ var f = function (x) { return x * 2 };
+ assert.ok(
+ traverse.deepEqual([ f ], [ f ]),
+ 'these functions are actually equal'
+ );
+};
+
+exports.deepEqual = function () {
+ assert.ok(
+ !traverse.deepEqual([ 1, 2, 3 ], { 0 : 1, 1 : 2, 2 : 3 }),
+ 'arrays are not objects'
+ );
+};
+
+exports.falsy = function () {
+ assert.ok(
+ !traverse.deepEqual([ undefined ], [ null ]),
+ 'null is not undefined!'
+ );
+
+ assert.ok(
+ !traverse.deepEqual([ null ], [ undefined ]),
+ 'undefined is not null!'
+ );
+
+ assert.ok(
+ !traverse.deepEqual(
+ { a : 1, b : 2, c : [ 3, undefined, 5 ] },
+ { a : 1, b : 2, c : [ 3, null, 5 ] }
+ ),
+ 'undefined is not null, however deeply!'
+ );
+
+ assert.ok(
+ !traverse.deepEqual(
+ { a : 1, b : 2, c : [ 3, undefined, 5 ] },
+ { a : 1, b : 2, c : [ 3, null, 5 ] }
+ ),
+ 'null is not undefined, however deeply!'
+ );
+
+ assert.ok(
+ !traverse.deepEqual(
+ { a : 1, b : 2, c : [ 3, undefined, 5 ] },
+ { a : 1, b : 2, c : [ 3, null, 5 ] }
+ ),
+ 'null is not undefined, however deeply!'
+ );
+};
+
+exports.deletedArrayEqual = function () {
+ var xs = [ 1, 2, 3, 4 ];
+ delete xs[2];
+
+ var ys = Object.create(Array.prototype);
+ ys[0] = 1;
+ ys[1] = 2;
+ ys[3] = 4;
+
+ assert.ok(
+ traverse.deepEqual(xs, ys),
+ 'arrays with deleted elements are only equal to'
+ + ' arrays with similarly deleted elements'
+ );
+
+ assert.ok(
+ !traverse.deepEqual(xs, [ 1, 2, undefined, 4 ]),
+ 'deleted array elements cannot be undefined'
+ );
+
+ assert.ok(
+ !traverse.deepEqual(xs, [ 1, 2, null, 4 ]),
+ 'deleted array elements cannot be null'
+ );
+};
+
+exports.deletedObjectEqual = function () {
+ var obj = { a : 1, b : 2, c : 3 };
+ delete obj.c;
+
+ assert.ok(
+ traverse.deepEqual(obj, { a : 1, b : 2 }),
+ 'deleted object elements should not show up'
+ );
+
+ assert.ok(
+ !traverse.deepEqual(obj, { a : 1, b : 2, c : undefined }),
+ 'deleted object elements are not undefined'
+ );
+
+ assert.ok(
+ !traverse.deepEqual(obj, { a : 1, b : 2, c : null }),
+ 'deleted object elements are not null'
+ );
+};
+
+exports.emptyKeyEqual = function () {
+ assert.ok(!traverse.deepEqual(
+ { a : 1 }, { a : 1, '' : 55 }
+ ));
+};
+
+exports.deepArguments = function () {
+ assert.ok(
+ !traverse.deepEqual(
+ [ 4, 5, 6 ],
+ (function () { return arguments })(4, 5, 6)
+ ),
+ 'arguments are not arrays'
+ );
+
+ assert.ok(
+ traverse.deepEqual(
+ (function () { return arguments })(4, 5, 6),
+ (function () { return arguments })(4, 5, 6)
+ ),
+ 'arguments should equal'
+ );
+};
+
+exports.deepUn = function () {
+ assert.ok(!traverse.deepEqual({ a : 1, b : 2 }, undefined));
+ assert.ok(!traverse.deepEqual({ a : 1, b : 2 }, {}));
+ assert.ok(!traverse.deepEqual(undefined, { a : 1, b : 2 }));
+ assert.ok(!traverse.deepEqual({}, { a : 1, b : 2 }));
+ assert.ok(traverse.deepEqual(undefined, undefined));
+ assert.ok(traverse.deepEqual(null, null));
+ assert.ok(!traverse.deepEqual(undefined, null));
+};
+
+exports.deepLevels = function () {
+ var xs = [ 1, 2, [ 3, 4, [ 5, 6 ] ] ];
+ assert.ok(!traverse.deepEqual(xs, []));
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/instance.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/instance.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/instance.js
new file mode 100644
index 0000000..501981f
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/instance.js
@@ -0,0 +1,17 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+var EventEmitter = require('events').EventEmitter;
+
+exports['check instanceof on node elems'] = function () {
+
+ var counts = { emitter : 0 };
+
+ Traverse([ new EventEmitter, 3, 4, { ev : new EventEmitter }])
+ .forEach(function (node) {
+ if (node instanceof EventEmitter) counts.emitter ++;
+ })
+ ;
+
+ assert.equal(counts.emitter, 2);
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/interface.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/interface.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/interface.js
new file mode 100644
index 0000000..df5b037
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/interface.js
@@ -0,0 +1,42 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+
+exports['interface map'] = function () {
+ var obj = { a : [ 5,6,7 ], b : { c : [8] } };
+
+ assert.deepEqual(
+ Traverse.paths(obj)
+ .sort()
+ .map(function (path) { return path.join('/') })
+ .slice(1)
+ .join(' ')
+ ,
+ 'a a/0 a/1 a/2 b b/c b/c/0'
+ );
+
+ assert.deepEqual(
+ Traverse.nodes(obj),
+ [
+ { a: [ 5, 6, 7 ], b: { c: [ 8 ] } },
+ [ 5, 6, 7 ], 5, 6, 7,
+ { c: [ 8 ] }, [ 8 ], 8
+ ]
+ );
+
+ assert.deepEqual(
+ Traverse.map(obj, function (node) {
+ if (typeof node == 'number') {
+ return node + 1000;
+ }
+ else if (Array.isArray(node)) {
+ return node.join(' ');
+ }
+ }),
+ { a: '5 6 7', b: { c: '8' } }
+ );
+
+ var nodes = 0;
+ Traverse.forEach(obj, function (node) { nodes ++ });
+ assert.deepEqual(nodes, 8);
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/json.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/json.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/json.js
new file mode 100644
index 0000000..bf36620
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/json.js
@@ -0,0 +1,47 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+
+exports['json test'] = function () {
+ var id = 54;
+ var callbacks = {};
+ var obj = { moo : function () {}, foo : [2,3,4, function () {}] };
+
+ var scrubbed = Traverse(obj).map(function (x) {
+ if (typeof x === 'function') {
+ callbacks[id] = { id : id, f : x, path : this.path };
+ this.update('[Function]');
+ id++;
+ }
+ });
+
+ assert.equal(
+ scrubbed.moo, '[Function]',
+ 'obj.moo replaced with "[Function]"'
+ );
+
+ assert.equal(
+ scrubbed.foo[3], '[Function]',
+ 'obj.foo[3] replaced with "[Function]"'
+ );
+
+ assert.deepEqual(scrubbed, {
+ moo : '[Function]',
+ foo : [ 2, 3, 4, "[Function]" ]
+ }, 'Full JSON string matches');
+
+ assert.deepEqual(
+ typeof obj.moo, 'function',
+ 'Original obj.moo still a function'
+ );
+
+ assert.deepEqual(
+ typeof obj.foo[3], 'function',
+ 'Original obj.foo[3] still a function'
+ );
+
+ assert.deepEqual(callbacks, {
+ 54: { id: 54, f : obj.moo, path: [ 'moo' ] },
+ 55: { id: 55, f : obj.foo[3], path: [ 'foo', '3' ] },
+ }, 'Check the generated callbacks list');
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/keys.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/keys.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/keys.js
new file mode 100644
index 0000000..8bf88ed
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/keys.js
@@ -0,0 +1,29 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+
+exports['sort test'] = function () {
+ var acc = [];
+ Traverse({
+ a: 30,
+ b: 22,
+ id: 9
+ }).forEach(function (node) {
+ if ((! Array.isArray(node)) && typeof node === 'object') {
+ this.before(function(node) {
+ this.keys = Object.keys(node);
+ this.keys.sort(function(a, b) {
+ a = [a === "id" ? 0 : 1, a];
+ b = [b === "id" ? 0 : 1, b];
+ return a < b ? -1 : a > b ? 1 : 0;
+ });
+ });
+ }
+ if (this.isLeaf) acc.push(node);
+ });
+
+ assert.equal(
+ acc.join(' '),
+ '9 30 22',
+ 'Traversal in a custom order'
+ );
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/leaves.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/leaves.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/leaves.js
new file mode 100644
index 0000000..4e8d280
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/leaves.js
@@ -0,0 +1,21 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+
+exports['leaves test'] = function () {
+ var acc = [];
+ Traverse({
+ a : [1,2,3],
+ b : 4,
+ c : [5,6],
+ d : { e : [7,8], f : 9 }
+ }).forEach(function (x) {
+ if (this.isLeaf) acc.push(x);
+ });
+
+ assert.equal(
+ acc.join(' '),
+ '1 2 3 4 5 6 7 8 9',
+ 'Traversal in the right(?) order'
+ );
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/mutability.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/mutability.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/mutability.js
new file mode 100644
index 0000000..5a4d6dd
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/mutability.js
@@ -0,0 +1,203 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+
+exports.mutate = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse(obj).forEach(function (x) {
+ if (typeof x === 'number' && x % 2 === 0) {
+ this.update(x * 10);
+ }
+ });
+ assert.deepEqual(obj, res);
+ assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] });
+};
+
+exports.mutateT = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse.forEach(obj, function (x) {
+ if (typeof x === 'number' && x % 2 === 0) {
+ this.update(x * 10);
+ }
+ });
+ assert.deepEqual(obj, res);
+ assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] });
+};
+
+exports.map = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse(obj).map(function (x) {
+ if (typeof x === 'number' && x % 2 === 0) {
+ this.update(x * 10);
+ }
+ });
+ assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
+ assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] });
+};
+
+exports.mapT = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse.map(obj, function (x) {
+ if (typeof x === 'number' && x % 2 === 0) {
+ this.update(x * 10);
+ }
+ });
+ assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
+ assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] });
+};
+
+exports.clone = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse(obj).clone();
+ assert.deepEqual(obj, res);
+ assert.ok(obj !== res);
+ obj.a ++;
+ assert.deepEqual(res.a, 1);
+ obj.c.push(5);
+ assert.deepEqual(res.c, [ 3, 4 ]);
+};
+
+exports.cloneT = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse.clone(obj);
+ assert.deepEqual(obj, res);
+ assert.ok(obj !== res);
+ obj.a ++;
+ assert.deepEqual(res.a, 1);
+ obj.c.push(5);
+ assert.deepEqual(res.c, [ 3, 4 ]);
+};
+
+exports.reduce = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse(obj).reduce(function (acc, x) {
+ if (this.isLeaf) acc.push(x);
+ return acc;
+ }, []);
+ assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
+ assert.deepEqual(res, [ 1, 2, 3, 4 ]);
+};
+
+exports.reduceInit = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse(obj).reduce(function (acc, x) {
+ if (this.isRoot) assert.fail('got root');
+ return acc;
+ });
+ assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
+ assert.deepEqual(res, obj);
+};
+
+exports.remove = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ Traverse(obj).forEach(function (x) {
+ if (this.isLeaf && x % 2 == 0) this.remove();
+ });
+
+ assert.deepEqual(obj, { a : 1, c : [ 3 ] });
+};
+
+exports.removeMap = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse(obj).map(function (x) {
+ if (this.isLeaf && x % 2 == 0) this.remove();
+ });
+
+ assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] });
+ assert.deepEqual(res, { a : 1, c : [ 3 ] });
+};
+
+exports.delete = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ Traverse(obj).forEach(function (x) {
+ if (this.isLeaf && x % 2 == 0) this.delete();
+ });
+
+ assert.ok(!Traverse.deepEqual(
+ obj, { a : 1, c : [ 3, undefined ] }
+ ));
+
+ assert.ok(Traverse.deepEqual(
+ obj, { a : 1, c : [ 3 ] }
+ ));
+
+ assert.ok(!Traverse.deepEqual(
+ obj, { a : 1, c : [ 3, null ] }
+ ));
+};
+
+exports.deleteRedux = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] };
+ Traverse(obj).forEach(function (x) {
+ if (this.isLeaf && x % 2 == 0) this.delete();
+ });
+
+ assert.ok(!Traverse.deepEqual(
+ obj, { a : 1, c : [ 3, undefined, 5 ] }
+ ));
+
+ assert.ok(Traverse.deepEqual(
+ obj, { a : 1, c : [ 3 ,, 5 ] }
+ ));
+
+ assert.ok(!Traverse.deepEqual(
+ obj, { a : 1, c : [ 3, null, 5 ] }
+ ));
+
+ assert.ok(!Traverse.deepEqual(
+ obj, { a : 1, c : [ 3, 5 ] }
+ ));
+};
+
+exports.deleteMap = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4 ] };
+ var res = Traverse(obj).map(function (x) {
+ if (this.isLeaf && x % 2 == 0) this.delete();
+ });
+
+ assert.ok(Traverse.deepEqual(
+ obj,
+ { a : 1, b : 2, c : [ 3, 4 ] }
+ ));
+
+ var xs = [ 3, 4 ];
+ delete xs[1];
+
+ assert.ok(Traverse.deepEqual(
+ res, { a : 1, c : xs }
+ ));
+
+ assert.ok(Traverse.deepEqual(
+ res, { a : 1, c : [ 3, ] }
+ ));
+
+ assert.ok(Traverse.deepEqual(
+ res, { a : 1, c : [ 3 ] }
+ ));
+};
+
+exports.deleteMapRedux = function () {
+ var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] };
+ var res = Traverse(obj).map(function (x) {
+ if (this.isLeaf && x % 2 == 0) this.delete();
+ });
+
+ assert.ok(Traverse.deepEqual(
+ obj,
+ { a : 1, b : 2, c : [ 3, 4, 5 ] }
+ ));
+
+ var xs = [ 3, 4, 5 ];
+ delete xs[1];
+
+ assert.ok(Traverse.deepEqual(
+ res, { a : 1, c : xs }
+ ));
+
+ assert.ok(!Traverse.deepEqual(
+ res, { a : 1, c : [ 3, 5 ] }
+ ));
+
+ assert.ok(Traverse.deepEqual(
+ res, { a : 1, c : [ 3 ,, 5 ] }
+ ));
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/negative.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/negative.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/negative.js
new file mode 100644
index 0000000..6cf287d
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/negative.js
@@ -0,0 +1,20 @@
+var Traverse = require('traverse');
+var assert = require('assert');
+
+exports['negative update test'] = function () {
+ var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];
+ var fixed = Traverse.map(obj, function (x) {
+ if (x < 0) this.update(x + 128);
+ });
+
+ assert.deepEqual(fixed,
+ [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ],
+ 'Negative values += 128'
+ );
+
+ assert.deepEqual(obj,
+ [ 5, 6, -3, [ 7, 8, -2, 1 ], { f: 10, g: -13 } ],
+ 'Original references not modified'
+ );
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/obj.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/obj.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/obj.js
new file mode 100644
index 0000000..9c3b0db
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/obj.js
@@ -0,0 +1,15 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+
+exports['traverse an object with nested functions'] = function () {
+ var to = setTimeout(function () {
+ assert.fail('never ran');
+ }, 1000);
+
+ function Cons (x) {
+ clearTimeout(to);
+ assert.equal(x, 10);
+ };
+ Traverse(new Cons(10));
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/siblings.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/siblings.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/siblings.js
new file mode 100644
index 0000000..1236834
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/siblings.js
@@ -0,0 +1,35 @@
+var assert = require('assert');
+var traverse = require('traverse');
+
+exports.siblings = function () {
+ var obj = { a : 1, b : 2, c : [ 4, 5, 6 ] };
+
+ var res = traverse(obj).reduce(function (acc, x) {
+ var p = '/' + this.path.join('/');
+ if (this.parent) {
+ acc[p] = {
+ siblings : this.parent.keys,
+ key : this.key,
+ index : this.parent.keys.indexOf(this.key)
+ };
+ }
+ else {
+ acc[p] = {
+ siblings : [],
+ key : this.key,
+ index : -1
+ }
+ }
+ return acc;
+ }, {});
+
+ assert.deepEqual(res, {
+ '/' : { siblings : [], key : undefined, index : -1 },
+ '/a' : { siblings : [ 'a', 'b', 'c' ], key : 'a', index : 0 },
+ '/b' : { siblings : [ 'a', 'b', 'c' ], key : 'b', index : 1 },
+ '/c' : { siblings : [ 'a', 'b', 'c' ], key : 'c', index : 2 },
+ '/c/0' : { siblings : [ '0', '1', '2' ], key : '0', index : 0 },
+ '/c/1' : { siblings : [ '0', '1', '2' ], key : '1', index : 1 },
+ '/c/2' : { siblings : [ '0', '1', '2' ], key : '2', index : 2 }
+ });
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/stop.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/stop.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/stop.js
new file mode 100644
index 0000000..ef6b36e
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/stop.js
@@ -0,0 +1,41 @@
+var assert = require('assert');
+var traverse = require('traverse');
+
+exports.stop = function () {
+ var visits = 0;
+ traverse('abcdefghij'.split('')).forEach(function (node) {
+ if (typeof node === 'string') {
+ visits ++;
+ if (node === 'e') this.stop()
+ }
+ });
+
+ assert.equal(visits, 5);
+};
+
+exports.stopMap = function () {
+ var s = traverse('abcdefghij'.split('')).map(function (node) {
+ if (typeof node === 'string') {
+ if (node === 'e') this.stop()
+ return node.toUpperCase();
+ }
+ }).join('');
+
+ assert.equal(s, 'ABCDEfghij');
+};
+
+exports.stopReduce = function () {
+ var obj = {
+ a : [ 4, 5 ],
+ b : [ 6, [ 7, 8, 9 ] ]
+ };
+ var xs = traverse(obj).reduce(function (acc, node) {
+ if (this.isLeaf) {
+ if (node === 7) this.stop();
+ else acc.push(node)
+ }
+ return acc;
+ }, []);
+
+ assert.deepEqual(xs, [ 4, 5, 6 ]);
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/stringify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/stringify.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/stringify.js
new file mode 100644
index 0000000..bf36f63
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/stringify.js
@@ -0,0 +1,36 @@
+var assert = require('assert');
+var Traverse = require('traverse');
+
+exports.stringify = function () {
+ var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];
+
+ var s = '';
+ Traverse(obj).forEach(function (node) {
+ if (Array.isArray(node)) {
+ this.before(function () { s += '[' });
+ this.post(function (child) {
+ if (!child.isLast) s += ',';
+ });
+ this.after(function () { s += ']' });
+ }
+ else if (typeof node == 'object') {
+ this.before(function () { s += '{' });
+ this.pre(function (x, key) {
+ s += '"' + key + '"' + ':';
+ });
+ this.post(function (child) {
+ if (!child.isLast) s += ',';
+ });
+ this.after(function () { s += '}' });
+ }
+ else if (typeof node == 'function') {
+ s += 'null';
+ }
+ else {
+ s += node.toString();
+ }
+ });
+
+ assert.equal(s, JSON.stringify(obj));
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/subexpr.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/subexpr.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/subexpr.js
new file mode 100644
index 0000000..a4960fb
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/subexpr.js
@@ -0,0 +1,34 @@
+var traverse = require('traverse');
+var assert = require('assert');
+
+exports.subexpr = function () {
+ var obj = [ 'a', 4, 'b', 5, 'c', 6 ];
+ var r = traverse(obj).map(function (x) {
+ if (typeof x === 'number') {
+ this.update([ x - 0.1, x, x + 0.1 ], true);
+ }
+ });
+
+ assert.deepEqual(obj, [ 'a', 4, 'b', 5, 'c', 6 ]);
+ assert.deepEqual(r, [
+ 'a', [ 3.9, 4, 4.1 ],
+ 'b', [ 4.9, 5, 5.1 ],
+ 'c', [ 5.9, 6, 6.1 ],
+ ]);
+};
+
+exports.block = function () {
+ var obj = [ [ 1 ], [ 2 ], [ 3 ] ];
+ var r = traverse(obj).map(function (x) {
+ if (Array.isArray(x) && !this.isRoot) {
+ if (x[0] === 5) this.block()
+ else this.update([ [ x[0] + 1 ] ])
+ }
+ });
+
+ assert.deepEqual(r, [
+ [ [ [ [ [ 5 ] ] ] ] ],
+ [ [ [ [ 5 ] ] ] ],
+ [ [ [ 5 ] ] ],
+ ]);
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/super_deep.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/super_deep.js b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/super_deep.js
new file mode 100644
index 0000000..974181e
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/node_modules/traverse/test/super_deep.js
@@ -0,0 +1,54 @@
+var assert = require('assert');
+var traverse = require('traverse');
+
+exports.super_deep = function () {
+ var util = require('util');
+ var a0 = make();
+ var a1 = make();
+ assert.ok(traverse.deepEqual(a0, a1));
+
+ a0.c.d.moo = true;
+ assert.ok(!traverse.deepEqual(a0, a1));
+
+ a1.c.d.moo = true;
+ assert.ok(traverse.deepEqual(a0, a1));
+
+ // TODO: this one
+ //a0.c.a = a1;
+ //assert.ok(!traverse.deepEqual(a0, a1));
+};
+
+function make () {
+ var a = { self : 'a' };
+ var b = { self : 'b' };
+ var c = { self : 'c' };
+ var d = { self : 'd' };
+ var e = { self : 'e' };
+
+ a.a = a;
+ a.b = b;
+ a.c = c;
+
+ b.a = a;
+ b.b = b;
+ b.c = c;
+
+ c.a = a;
+ c.b = b;
+ c.c = c;
+ c.d = d;
+
+ d.a = a;
+ d.b = b;
+ d.c = c;
+ d.d = d;
+ d.e = e;
+
+ e.a = a;
+ e.b = b;
+ e.c = c;
+ e.d = d;
+ e.e = e;
+
+ return a;
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/package.json b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/package.json
new file mode 100644
index 0000000..074b9db
--- /dev/null
+++ b/node_modules/node-firefox-connect/node_modules/firefox-client/node_modules/js-select/package.json
@@ -0,0 +1,51 @@
+{
+ "name": "js-select",
+ "description": "Traverse and modify objects with JSONSelect selectors",
+ "version": "0.6.0",
+ "author": {
+ "name": "Heather Arthur",
+ "email": "fayearthur@gmail.com"
+ },
+ "repository": {
+ "type": "git",
+ "url": "http://github.com/harthur/js-select.git"
+ },
+ "main": "./index",
+ "dependencies": {
+ "traverse": "0.4.x",
+ "JSONSelect": "0.2.1"
+ },
+ "devDependencies": {
+ "nomnom": "0.6.x",
+ "color": "0.3.x"
+ },
+ "keywords": [
+ "json"
+ ],
+ "readme": "# js-select\n\njs-select uses [js-traverse](https://github.com/substack/js-traverse) to traverse and modify JavaScript object nodes that match [JSONSelect](http://jsonselect.org/) selectors.\n\n```javascript\nvar people = {\n george: {\n age : 35,\n movie: \"Repo Man\"\n },\n mary: {\n age: 15,\n movie: \"Twilight\"\n }\n};\n```\n\n### .forEach(fn)\n\nIterates over all matching nodes in the object. The callback gets a special `this` context. See [js-traverse](https://github.com/substack/js-traverse) for all the things you can do to modify and inspect the node with this context. In addition, js-select adds a `this.matches()` which will test if the node matches a selector:\n\n```javascript\nselect(people).forEach(function(node) {\n if (this.matches(\".mary > .movie\")) {\n this.remove();\n }\n});\n```\n\n### .nodes()\n\nReturns all matching nodes from the object.\n\n```javascript\nselect(people, \".age\").nodes(); // [35, 15]\n```\n\n#
## .remove()\n\nRemoves matching elements from the original object.\n\n```javascript\nselect(people, \".age\").remove();\n```\n\n### .update(fn)\n\nUpdates all matching nodes using the given callback.\n\n```javascript\nselect(people, \".age\").update(function(age) {\n return age - 5;\n});\n```\n\n### .condense()\n\nReduces the original object down to only the matching elements (the hierarchy is maintained).\n\n```javascript\nselect(people, \".age\").condense();\n```\n\n```javascript\n{\n george: { age: 35 },\n mary: { age: 15 }\n}\n```\n\n## Selectors\n\njs-select supports the following [JSONSelect](http://jsonselect.org/) selectors:\n\n```\n*\ntype\n.key\nancestor selector\nparent > selector\nsibling ~ selector\nselector1, selector2\n:root\n:nth-child(n)\n:nth-child(even)\n:nth-child(odd)\n:nth-last-child(n)\n:first-child\n:last-child\n:only-child\n:has(selector)\n:val(\"string\")\n:contains(\"substring\")\n```\n\nSee [details](http://jsonselect.org/#docs/overview) on each
selector, and [try them](http://jsonselect.org/#tryit) out on the JSONSelect website.\n\n## Install\n\nFor [node](http://nodejs.org), install with [npm](http://npmjs.org):\n\n```bash\nnpm install js-select\n```\n\nFor the browser, download the select.js file or fetch the latest version from [npm](http://npmjs.org) and build a browser file using [browserify](https://github.com/substack/node-browserify):\n\n```bash\nnpm install browserify -g\nnpm install js-select\n\nbrowserify --require js-select --outfile select.js\n```\nthis will build a browser file with `require('js-select')` available.\n\n## Propers\n\nHuge thanks to [@substack](http://github.com/substack) for the ingenious [js-traverse](https://github.com/substack/js-traverse) and [@lloyd](https://github.com/lloyd) for the ingenious [JSONSelect spec](http://http://jsonselect.org/) and [selector parser](http://search.npmjs.org/#/JSONSelect).",
+ "readmeFilename": "README.md",
+ "_id": "js-select@0.6.0",
+ "dist": {
+ "shasum": "c284e22824d5927aec962dcdf247174aefb0d190",
+ "tarball": "http://registry.npmjs.org/js-select/-/js-select-0.6.0.tgz"
+ },
+ "_from": "js-select@~0.6.0",
+ "_npmVersion": "1.2.14",
+ "_npmUser": {
+ "name": "harth",
+ "email": "fayearthur@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "harth",
+ "email": "fayearthur@gmail.com"
+ }
+ ],
+ "directories": {},
+ "_shasum": "c284e22824d5927aec962dcdf247174aefb0d190",
+ "_resolved": "https://registry.npmjs.org/js-select/-/js-select-0.6.0.tgz",
+ "bugs": {
+ "url": "https://github.com/harthur/js-select/issues"
+ },
+ "homepage": "https://github.com/harthur/js-select"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[05/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/xhr.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/xhr.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/xhr.js
new file mode 100644
index 0000000..96082ad
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/xhr.js
@@ -0,0 +1,739 @@
+/**
+ * XmlHttpRequest implementation that uses TLS and flash SocketPool.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2013 Digital Bazaar, Inc.
+ */
+(function($) {
+
+// logging category
+var cat = 'forge.xhr';
+
+/*
+XMLHttpRequest interface definition from:
+http://www.w3.org/TR/XMLHttpRequest
+
+interface XMLHttpRequest {
+ // event handler
+ attribute EventListener onreadystatechange;
+
+ // state
+ const unsigned short UNSENT = 0;
+ const unsigned short OPENED = 1;
+ const unsigned short HEADERS_RECEIVED = 2;
+ const unsigned short LOADING = 3;
+ const unsigned short DONE = 4;
+ readonly attribute unsigned short readyState;
+
+ // request
+ void open(in DOMString method, in DOMString url);
+ void open(in DOMString method, in DOMString url, in boolean async);
+ void open(in DOMString method, in DOMString url,
+ in boolean async, in DOMString user);
+ void open(in DOMString method, in DOMString url,
+ in boolean async, in DOMString user, in DOMString password);
+ void setRequestHeader(in DOMString header, in DOMString value);
+ void send();
+ void send(in DOMString data);
+ void send(in Document data);
+ void abort();
+
+ // response
+ DOMString getAllResponseHeaders();
+ DOMString getResponseHeader(in DOMString header);
+ readonly attribute DOMString responseText;
+ readonly attribute Document responseXML;
+ readonly attribute unsigned short status;
+ readonly attribute DOMString statusText;
+};
+*/
+
+// readyStates
+var UNSENT = 0;
+var OPENED = 1;
+var HEADERS_RECEIVED = 2;
+var LOADING = 3;
+var DONE = 4;
+
+// exceptions
+var INVALID_STATE_ERR = 11;
+var SYNTAX_ERR = 12;
+var SECURITY_ERR = 18;
+var NETWORK_ERR = 19;
+var ABORT_ERR = 20;
+
+// private flash socket pool vars
+var _sp = null;
+var _policyPort = 0;
+var _policyUrl = null;
+
+// default client (used if no special URL provided when creating an XHR)
+var _client = null;
+
+// all clients including the default, key'd by full base url
+// (multiple cross-domain http clients are permitted so there may be more
+// than one client in this map)
+// TODO: provide optional clean up API for non-default clients
+var _clients = {};
+
+// the default maximum number of concurrents connections per client
+var _maxConnections = 10;
+
+// local aliases
+if(typeof forge === 'undefined') {
+ forge = {};
+}
+var net = forge.net;
+var http = forge.http;
+
+// define the xhr interface
+var xhrApi = {};
+
+/**
+ * Initializes flash XHR support.
+ *
+ * @param options:
+ * url: the default base URL to connect to if xhr URLs are relative,
+ * ie: https://myserver.com.
+ * flashId: the dom ID of the flash SocketPool.
+ * policyPort: the port that provides the server's flash policy, 0 to use
+ * the flash default.
+ * policyUrl: the policy file URL to use instead of a policy port.
+ * msie: true if browser is internet explorer, false if not.
+ * connections: the maximum number of concurrent connections.
+ * caCerts: a list of PEM-formatted certificates to trust.
+ * cipherSuites: an optional array of cipher suites to use,
+ * see forge.tls.CipherSuites.
+ * verify: optional TLS certificate verify callback to use (see forge.tls
+ * for details).
+ * getCertificate: an optional callback used to get a client-side
+ * certificate (see forge.tls for details).
+ * getPrivateKey: an optional callback used to get a client-side private
+ * key (see forge.tls for details).
+ * getSignature: an optional callback used to get a client-side signature
+ * (see forge.tls for details).
+ * persistCookies: true to use persistent cookies via flash local storage,
+ * false to only keep cookies in javascript.
+ * primeTlsSockets: true to immediately connect TLS sockets on their
+ * creation so that they will cache TLS sessions for reuse.
+ */
+xhrApi.init = function(options) {
+ forge.log.debug(cat, 'initializing', options);
+
+ // update default policy port and max connections
+ _policyPort = options.policyPort || _policyPort;
+ _policyUrl = options.policyUrl || _policyUrl;
+ _maxConnections = options.connections || _maxConnections;
+
+ // create the flash socket pool
+ _sp = net.createSocketPool({
+ flashId: options.flashId,
+ policyPort: _policyPort,
+ policyUrl: _policyUrl,
+ msie: options.msie || false
+ });
+
+ // create default http client
+ _client = http.createClient({
+ url: options.url || (
+ window.location.protocol + '//' + window.location.host),
+ socketPool: _sp,
+ policyPort: _policyPort,
+ policyUrl: _policyUrl,
+ connections: options.connections || _maxConnections,
+ caCerts: options.caCerts,
+ cipherSuites: options.cipherSuites,
+ persistCookies: options.persistCookies || true,
+ primeTlsSockets: options.primeTlsSockets || false,
+ verify: options.verify,
+ getCertificate: options.getCertificate,
+ getPrivateKey: options.getPrivateKey,
+ getSignature: options.getSignature
+ });
+ _clients[_client.url.full] = _client;
+
+ forge.log.debug(cat, 'ready');
+};
+
+/**
+ * Called to clean up the clients and socket pool.
+ */
+xhrApi.cleanup = function() {
+ // destroy all clients
+ for(var key in _clients) {
+ _clients[key].destroy();
+ }
+ _clients = {};
+ _client = null;
+
+ // destroy socket pool
+ _sp.destroy();
+ _sp = null;
+};
+
+/**
+ * Sets a cookie.
+ *
+ * @param cookie the cookie with parameters:
+ * name: the name of the cookie.
+ * value: the value of the cookie.
+ * comment: an optional comment string.
+ * maxAge: the age of the cookie in seconds relative to created time.
+ * secure: true if the cookie must be sent over a secure protocol.
+ * httpOnly: true to restrict access to the cookie from javascript
+ * (inaffective since the cookies are stored in javascript).
+ * path: the path for the cookie.
+ * domain: optional domain the cookie belongs to (must start with dot).
+ * version: optional version of the cookie.
+ * created: creation time, in UTC seconds, of the cookie.
+ */
+xhrApi.setCookie = function(cookie) {
+ // default cookie expiration to never
+ cookie.maxAge = cookie.maxAge || -1;
+
+ // if the cookie's domain is set, use the appropriate client
+ if(cookie.domain) {
+ // add the cookies to the applicable domains
+ for(var key in _clients) {
+ var client = _clients[key];
+ if(http.withinCookieDomain(client.url, cookie) &&
+ client.secure === cookie.secure) {
+ client.setCookie(cookie);
+ }
+ }
+ } else {
+ // use the default domain
+ // FIXME: should a null domain cookie be added to all clients? should
+ // this be an option?
+ _client.setCookie(cookie);
+ }
+};
+
+/**
+ * Gets a cookie.
+ *
+ * @param name the name of the cookie.
+ * @param path an optional path for the cookie (if there are multiple cookies
+ * with the same name but different paths).
+ * @param domain an optional domain for the cookie (if not using the default
+ * domain).
+ *
+ * @return the cookie, cookies (if multiple matches), or null if not found.
+ */
+xhrApi.getCookie = function(name, path, domain) {
+ var rval = null;
+
+ if(domain) {
+ // get the cookies from the applicable domains
+ for(var key in _clients) {
+ var client = _clients[key];
+ if(http.withinCookieDomain(client.url, domain)) {
+ var cookie = client.getCookie(name, path);
+ if(cookie !== null) {
+ if(rval === null) {
+ rval = cookie;
+ } else if(!forge.util.isArray(rval)) {
+ rval = [rval, cookie];
+ } else {
+ rval.push(cookie);
+ }
+ }
+ }
+ }
+ } else {
+ // get cookie from default domain
+ rval = _client.getCookie(name, path);
+ }
+
+ return rval;
+};
+
+/**
+ * Removes a cookie.
+ *
+ * @param name the name of the cookie.
+ * @param path an optional path for the cookie (if there are multiple cookies
+ * with the same name but different paths).
+ * @param domain an optional domain for the cookie (if not using the default
+ * domain).
+ *
+ * @return true if a cookie was removed, false if not.
+ */
+xhrApi.removeCookie = function(name, path, domain) {
+ var rval = false;
+
+ if(domain) {
+ // remove the cookies from the applicable domains
+ for(var key in _clients) {
+ var client = _clients[key];
+ if(http.withinCookieDomain(client.url, domain)) {
+ if(client.removeCookie(name, path)) {
+ rval = true;
+ }
+ }
+ }
+ } else {
+ // remove cookie from default domain
+ rval = _client.removeCookie(name, path);
+ }
+
+ return rval;
+};
+
+/**
+ * Creates a new XmlHttpRequest. By default the base URL, flash policy port,
+ * etc, will be used. However, an XHR can be created to point at another
+ * cross-domain URL.
+ *
+ * @param options:
+ * logWarningOnError: If true and an HTTP error status code is received then
+ * log a warning, otherwise log a verbose message.
+ * verbose: If true be very verbose in the output including the response
+ * event and response body, otherwise only include status, timing, and
+ * data size.
+ * logError: a multi-var log function for warnings that takes the log
+ * category as the first var.
+ * logWarning: a multi-var log function for warnings that takes the log
+ * category as the first var.
+ * logDebug: a multi-var log function for warnings that takes the log
+ * category as the first var.
+ * logVerbose: a multi-var log function for warnings that takes the log
+ * category as the first var.
+ * url: the default base URL to connect to if xhr URLs are relative,
+ * eg: https://myserver.com, and note that the following options will be
+ * ignored if the URL is absent or the same as the default base URL.
+ * policyPort: the port that provides the server's flash policy, 0 to use
+ * the flash default.
+ * policyUrl: the policy file URL to use instead of a policy port.
+ * connections: the maximum number of concurrent connections.
+ * caCerts: a list of PEM-formatted certificates to trust.
+ * cipherSuites: an optional array of cipher suites to use, see
+ * forge.tls.CipherSuites.
+ * verify: optional TLS certificate verify callback to use (see forge.tls
+ * for details).
+ * getCertificate: an optional callback used to get a client-side
+ * certificate.
+ * getPrivateKey: an optional callback used to get a client-side private key.
+ * getSignature: an optional callback used to get a client-side signature.
+ * persistCookies: true to use persistent cookies via flash local storage,
+ * false to only keep cookies in javascript.
+ * primeTlsSockets: true to immediately connect TLS sockets on their
+ * creation so that they will cache TLS sessions for reuse.
+ *
+ * @return the XmlHttpRequest.
+ */
+xhrApi.create = function(options) {
+ // set option defaults
+ options = $.extend({
+ logWarningOnError: true,
+ verbose: false,
+ logError: function(){},
+ logWarning: function(){},
+ logDebug: function(){},
+ logVerbose: function(){},
+ url: null
+ }, options || {});
+
+ // private xhr state
+ var _state = {
+ // the http client to use
+ client: null,
+ // request storage
+ request: null,
+ // response storage
+ response: null,
+ // asynchronous, true if doing asynchronous communication
+ asynchronous: true,
+ // sendFlag, true if send has been called
+ sendFlag: false,
+ // errorFlag, true if a network error occurred
+ errorFlag: false
+ };
+
+ // private log functions
+ var _log = {
+ error: options.logError || forge.log.error,
+ warning: options.logWarning || forge.log.warning,
+ debug: options.logDebug || forge.log.debug,
+ verbose: options.logVerbose || forge.log.verbose
+ };
+
+ // create public xhr interface
+ var xhr = {
+ // an EventListener
+ onreadystatechange: null,
+ // readonly, the current readyState
+ readyState: UNSENT,
+ // a string with the response entity-body
+ responseText: '',
+ // a Document for response entity-bodies that are XML
+ responseXML: null,
+ // readonly, returns the HTTP status code (i.e. 404)
+ status: 0,
+ // readonly, returns the HTTP status message (i.e. 'Not Found')
+ statusText: ''
+ };
+
+ // determine which http client to use
+ if(options.url === null) {
+ // use default
+ _state.client = _client;
+ } else {
+ var url = http.parseUrl(options.url);
+ if(!url) {
+ var error = new Error('Invalid url.');
+ error.details = {
+ url: options.url
+ };
+ }
+
+ // find client
+ if(url.full in _clients) {
+ // client found
+ _state.client = _clients[url.full];
+ } else {
+ // create client
+ _state.client = http.createClient({
+ url: options.url,
+ socketPool: _sp,
+ policyPort: options.policyPort || _policyPort,
+ policyUrl: options.policyUrl || _policyUrl,
+ connections: options.connections || _maxConnections,
+ caCerts: options.caCerts,
+ cipherSuites: options.cipherSuites,
+ persistCookies: options.persistCookies || true,
+ primeTlsSockets: options.primeTlsSockets || false,
+ verify: options.verify,
+ getCertificate: options.getCertificate,
+ getPrivateKey: options.getPrivateKey,
+ getSignature: options.getSignature
+ });
+ _clients[url.full] = _state.client;
+ }
+ }
+
+ /**
+ * Opens the request. This method will create the HTTP request to send.
+ *
+ * @param method the HTTP method (i.e. 'GET').
+ * @param url the relative url (the HTTP request path).
+ * @param async always true, ignored.
+ * @param user always null, ignored.
+ * @param password always null, ignored.
+ */
+ xhr.open = function(method, url, async, user, password) {
+ // 1. validate Document if one is associated
+ // TODO: not implemented (not used yet)
+
+ // 2. validate method token
+ // 3. change method to uppercase if it matches a known
+ // method (here we just require it to be uppercase, and
+ // we do not allow the standard methods)
+ // 4. disallow CONNECT, TRACE, or TRACK with a security error
+ switch(method) {
+ case 'DELETE':
+ case 'GET':
+ case 'HEAD':
+ case 'OPTIONS':
+ case 'PATCH':
+ case 'POST':
+ case 'PUT':
+ // valid method
+ break;
+ case 'CONNECT':
+ case 'TRACE':
+ case 'TRACK':
+ throw new Error('CONNECT, TRACE and TRACK methods are disallowed');
+ default:
+ throw new Error('Invalid method: ' + method);;
+ }
+
+ // TODO: other validation steps in algorithm are not implemented
+
+ // 19. set send flag to false
+ // set response body to null
+ // empty list of request headers
+ // set request method to given method
+ // set request URL
+ // set username, password
+ // set asychronous flag
+ _state.sendFlag = false;
+ xhr.responseText = '';
+ xhr.responseXML = null;
+
+ // custom: reset status and statusText
+ xhr.status = 0;
+ xhr.statusText = '';
+
+ // create the HTTP request
+ _state.request = http.createRequest({
+ method: method,
+ path: url
+ });
+
+ // 20. set state to OPENED
+ xhr.readyState = OPENED;
+
+ // 21. dispatch onreadystatechange
+ if(xhr.onreadystatechange) {
+ xhr.onreadystatechange();
+ }
+ };
+
+ /**
+ * Adds an HTTP header field to the request.
+ *
+ * @param header the name of the header field.
+ * @param value the value of the header field.
+ */
+ xhr.setRequestHeader = function(header, value) {
+ // 1. if state is not OPENED or send flag is true, raise exception
+ if(xhr.readyState != OPENED || _state.sendFlag) {
+ throw new Error('XHR not open or sending');
+ }
+
+ // TODO: other validation steps in spec aren't implemented
+
+ // set header
+ _state.request.setField(header, value);
+ };
+
+ /**
+ * Sends the request and any associated data.
+ *
+ * @param data a string or Document object to send, null to send no data.
+ */
+ xhr.send = function(data) {
+ // 1. if state is not OPENED or 2. send flag is true, raise
+ // an invalid state exception
+ if(xhr.readyState != OPENED || _state.sendFlag) {
+ throw new Error('XHR not open or sending');
+ }
+
+ // 3. ignore data if method is GET or HEAD
+ if(data &&
+ _state.request.method !== 'GET' &&
+ _state.request.method !== 'HEAD') {
+ // handle non-IE case
+ if(typeof(XMLSerializer) !== 'undefined') {
+ if(data instanceof Document) {
+ var xs = new XMLSerializer();
+ _state.request.body = xs.serializeToString(data);
+ } else {
+ _state.request.body = data;
+ }
+ } else {
+ // poorly implemented IE case
+ if(typeof(data.xml) !== 'undefined') {
+ _state.request.body = data.xml;
+ } else {
+ _state.request.body = data;
+ }
+ }
+ }
+
+ // 4. release storage mutex (not used)
+
+ // 5. set error flag to false
+ _state.errorFlag = false;
+
+ // 6. if asynchronous is true (must be in this implementation)
+
+ // 6.1 set send flag to true
+ _state.sendFlag = true;
+
+ // 6.2 dispatch onreadystatechange
+ if(xhr.onreadystatechange) {
+ xhr.onreadystatechange();
+ }
+
+ // create send options
+ var options = {};
+ options.request = _state.request;
+ options.headerReady = function(e) {
+ // make cookies available for ease of use/iteration
+ xhr.cookies = _state.client.cookies;
+
+ // TODO: update document.cookie with any cookies where the
+ // script's domain matches
+
+ // headers received
+ xhr.readyState = HEADERS_RECEIVED;
+ xhr.status = e.response.code;
+ xhr.statusText = e.response.message;
+ _state.response = e.response;
+ if(xhr.onreadystatechange) {
+ xhr.onreadystatechange();
+ }
+ if(!_state.response.aborted) {
+ // now loading body
+ xhr.readyState = LOADING;
+ if(xhr.onreadystatechange) {
+ xhr.onreadystatechange();
+ }
+ }
+ };
+ options.bodyReady = function(e) {
+ xhr.readyState = DONE;
+ var ct = e.response.getField('Content-Type');
+ // Note: this null/undefined check is done outside because IE
+ // dies otherwise on a "'null' is null" error
+ if(ct) {
+ if(ct.indexOf('text/xml') === 0 ||
+ ct.indexOf('application/xml') === 0 ||
+ ct.indexOf('+xml') !== -1) {
+ try {
+ var doc = new ActiveXObject('MicrosoftXMLDOM');
+ doc.async = false;
+ doc.loadXML(e.response.body);
+ xhr.responseXML = doc;
+ } catch(ex) {
+ var parser = new DOMParser();
+ xhr.responseXML = parser.parseFromString(ex.body, 'text/xml');
+ }
+ }
+ }
+
+ var length = 0;
+ if(e.response.body !== null) {
+ xhr.responseText = e.response.body;
+ length = e.response.body.length;
+ }
+ // build logging output
+ var req = _state.request;
+ var output =
+ req.method + ' ' + req.path + ' ' +
+ xhr.status + ' ' + xhr.statusText + ' ' +
+ length + 'B ' +
+ (e.request.connectTime + e.request.time + e.response.time) +
+ 'ms';
+ var lFunc;
+ if(options.verbose) {
+ lFunc = (xhr.status >= 400 && options.logWarningOnError) ?
+ _log.warning : _log.verbose;
+ lFunc(cat, output,
+ e, e.response.body ? '\n' + e.response.body : '\nNo content');
+ } else {
+ lFunc = (xhr.status >= 400 && options.logWarningOnError) ?
+ _log.warning : _log.debug;
+ lFunc(cat, output);
+ }
+ if(xhr.onreadystatechange) {
+ xhr.onreadystatechange();
+ }
+ };
+ options.error = function(e) {
+ var req = _state.request;
+ _log.error(cat, req.method + ' ' + req.path, e);
+
+ // 1. set response body to null
+ xhr.responseText = '';
+ xhr.responseXML = null;
+
+ // 2. set error flag to true (and reset status)
+ _state.errorFlag = true;
+ xhr.status = 0;
+ xhr.statusText = '';
+
+ // 3. set state to done
+ xhr.readyState = DONE;
+
+ // 4. asyc flag is always true, so dispatch onreadystatechange
+ if(xhr.onreadystatechange) {
+ xhr.onreadystatechange();
+ }
+ };
+
+ // 7. send request
+ _state.client.send(options);
+ };
+
+ /**
+ * Aborts the request.
+ */
+ xhr.abort = function() {
+ // 1. abort send
+ // 2. stop network activity
+ _state.request.abort();
+
+ // 3. set response to null
+ xhr.responseText = '';
+ xhr.responseXML = null;
+
+ // 4. set error flag to true (and reset status)
+ _state.errorFlag = true;
+ xhr.status = 0;
+ xhr.statusText = '';
+
+ // 5. clear user headers
+ _state.request = null;
+ _state.response = null;
+
+ // 6. if state is DONE or UNSENT, or if OPENED and send flag is false
+ if(xhr.readyState === DONE || xhr.readyState === UNSENT ||
+ (xhr.readyState === OPENED && !_state.sendFlag)) {
+ // 7. set ready state to unsent
+ xhr.readyState = UNSENT;
+ } else {
+ // 6.1 set state to DONE
+ xhr.readyState = DONE;
+
+ // 6.2 set send flag to false
+ _state.sendFlag = false;
+
+ // 6.3 dispatch onreadystatechange
+ if(xhr.onreadystatechange) {
+ xhr.onreadystatechange();
+ }
+
+ // 7. set state to UNSENT
+ xhr.readyState = UNSENT;
+ }
+ };
+
+ /**
+ * Gets all response headers as a string.
+ *
+ * @return the HTTP-encoded response header fields.
+ */
+ xhr.getAllResponseHeaders = function() {
+ var rval = '';
+ if(_state.response !== null) {
+ var fields = _state.response.fields;
+ $.each(fields, function(name, array) {
+ $.each(array, function(i, value) {
+ rval += name + ': ' + value + '\r\n';
+ });
+ });
+ }
+ return rval;
+ };
+
+ /**
+ * Gets a single header field value or, if there are multiple
+ * fields with the same name, a comma-separated list of header
+ * values.
+ *
+ * @return the header field value(s) or null.
+ */
+ xhr.getResponseHeader = function(header) {
+ var rval = null;
+ if(_state.response !== null) {
+ if(header in _state.response.fields) {
+ rval = _state.response.fields[header];
+ if(forge.util.isArray(rval)) {
+ rval = rval.join();
+ }
+ }
+ }
+ return rval;
+ };
+
+ return xhr;
+};
+
+// expose public api
+forge.xhr = xhrApi;
+
+})(jQuery);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/minify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/minify.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/minify.js
new file mode 100644
index 0000000..36430a2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/minify.js
@@ -0,0 +1,10 @@
+({
+ name: 'node_modules/almond/almond',
+ include: ['js/forge'],
+ out: 'js/forge.min.js',
+ wrap: {
+ startFile: 'start.frag',
+ endFile: 'end.frag'
+ },
+ preserveLicenseComments: false
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/README
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/README b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/README
new file mode 100644
index 0000000..0331e01
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/README
@@ -0,0 +1,135 @@
+=======
+mod_fsp
+=======
+
+mod_fsp is an Apache2 module for providing a Flash Socket Policy on the
+same port that HTTP is served. The cross-domain policy that is served is
+specified via a configuration option 'FSPPolicyFile'.
+
+If a flash application sends a policy file request to an Apache server
+that has enabled and configured the mod_fsp module over its HTTP port,
+then the configured cross-domain policy will be returned as the response.
+
+========
+Building
+========
+
+To build the mod_fsp source code you can use Apache2's module
+build and installation tool: 'apxs2' which is, at the time of
+this writing, available on debian in the package:
+
+apache2-threaded-dev
+
+To compile mod_fsp you would run the following command:
+
+apxs2 -c mod_fsp.c
+
+============
+Installation
+============
+
+To install mod_fsp you the following command as root:
+
+apxs2 -c -i -a mod_fsp.c
+
+You must then restart your apache2 process, typically like so:
+
+/etc/init.d/apache2 restart
+
+===================
+Manual Installation
+===================
+
+To manually enable mod_dsp on your Apache2 server, you must copy the
+module file to the appropriate directory and create a load file.
+
+The module file:
+
+fsp.so (The library extension may vary if you are not using linux).
+
+Must be copied to Apache's module installation directory which is
+typically located (on a debian system):
+
+/usr/lib/apache2/modules
+
+The load file:
+
+fsp.load
+
+Must be created in Apache2's 'mods-available' directory, typically
+located (on a debian system):
+
+/etc/apache2/mods-available
+
+The load file should contain:
+
+LoadModule fsp_module /usr/lib/apache2/modules/mod_fsp.so
+
+If your Apache module installation directory is different from
+the one listed above, you will need to set the correct one in the
+fsp.load file.
+
+To actually enable the module you must create a symbolic link in
+Apache's 'mods-enabled' directory, typically located (on debian):
+
+/etc/apache2/mods-enabled
+
+By typing (from that directory):
+
+ln -s ../mods-available/fsp.load fsp.load
+
+=============
+Configuration
+=============
+
+Once mod_fsp is installed, it must be configured. There is currently
+only one configuration option for mod_fsp: 'FSPPolicyFile'. This
+configuration option will set the file that mod_fsp will look in
+on apache startup for the cross-domain policy to serve. This option
+can be provided on a per-port basis. Each port can use a different
+one, but VirtualServers on a single port will use the same one. This
+is a limitation of the design by Adobe.
+
+Note: The cross-domain policy may fail to be served if the configuration
+option isn't added in the first VirtualHost entry (for a given port) read
+by Apache.
+
+An example of this configuration in use:
+
+<VirtualHost *:80>
+ ServerName example.com
+ DocumentRoot /var/www/example.com
+ ErrorLog /var/log/apache2/example.com-error.log
+ CustomLog /var/log/apache2/example.com-access.log vhost_combined
+
+ # mod_fsp config option
+ FSPPolicyFile /etc/apache2/crossdomain/crossdomain.xml
+
+ <Directory /var/www/example.com>
+ Options Indexes FollowSymLinks MultiViews
+ AllowOverride All
+ Order allow,deny
+ allow from all
+ </Directory>
+
+</VirtualHost>
+
+And example of the most permissive cross-domain policy file for flash:
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE cross-domain-policy SYSTEM
+"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
+<cross-domain-policy>
+<site-control permitted-cross-domain-policies="all"/>
+<allow-access-from domain="*" to-ports="*"/>
+<allow-http-request-headers-from domain="*" headers="*"/>
+</cross-domain-policy>
+
+==================
+Note about SSL/TLS
+==================
+
+Flash currently has no built-in SSL/TLS support so there is no
+reason to specify an 'FSPPolicyFile' option for SSL servers. The
+Flash player cannot directly communicate with them when doing
+internal look ups of policy files.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/mod_fsp.c
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/mod_fsp.c b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/mod_fsp.c
new file mode 100644
index 0000000..8beb824
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/mod_fsp/mod_fsp.c
@@ -0,0 +1,415 @@
+/**
+ * Flash Socket Policy Apache Module.
+ *
+ * This module provides a flash socket policy file on the same port that
+ * serves HTTP on Apache. This can help simplify setting up a server that
+ * supports cross-domain communication with flash.
+ *
+ * Quick note about Apache memory handling: Data is allocated from pools and
+ * is not manually returned to those pools. The pools are typically considered
+ * short-lived and will be cleaned up automatically by Apache.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010 Digital Bazaar, Inc. All rights reserved.
+ */
+#include "httpd.h"
+#include "http_config.h"
+#include "http_core.h"
+
+#include "ap_compat.h"
+
+#include <string.h>
+
+// length of a policy file request
+#define PFR_LENGTH 23
+
+// declare main module
+module AP_MODULE_DECLARE_DATA fsp_module;
+
+// configuration for the module
+typedef struct fsp_config
+{
+ // the cross-domain policy to serve
+ char* policy;
+ apr_size_t policy_length;
+} fsp_config;
+
+// filter state for keeping track of detected policy file requests
+typedef struct filter_state
+{
+ fsp_config* cfg;
+ int checked;
+ int found;
+} filter_state;
+
+// for registering hooks, filters, etc.
+static void fsp_register_hooks(apr_pool_t *p);
+static int fsp_pre_connection(conn_rec *c, void *csd);
+
+// filter handler declarations
+static apr_status_t fsp_input_filter(
+ ap_filter_t* f, apr_bucket_brigade* bb,
+ ap_input_mode_t mode, apr_read_type_e block, apr_off_t nbytes);
+static int fsp_output_filter(ap_filter_t* f, apr_bucket_brigade* bb);
+
+/**
+ * Registers the hooks for this module.
+ *
+ * @param p the pool to allocate from, if necessary.
+ */
+static void fsp_register_hooks(apr_pool_t* p)
+{
+ // registers the pre-connection hook to handle adding filters
+ ap_hook_pre_connection(
+ fsp_pre_connection, NULL, NULL, APR_HOOK_MIDDLE);
+
+ // will parse a policy file request, to be added in pre_connection
+ ap_register_input_filter(
+ "fsp_request", fsp_input_filter,
+ NULL, AP_FTYPE_CONNECTION);
+
+ // will emit a cross-domain policy response to be added in pre_connection
+ ap_register_output_filter(
+ "fsp_response", fsp_output_filter,
+ NULL, AP_FTYPE_CONNECTION);
+}
+
+/**
+ * A hook that is called before a connection is handled. This function will
+ * get the module configuration and add the flash socket policy filters if
+ * a cross-domain policy has been specified in the configuration.
+ *
+ * @param c the connection.
+ * @param csd the connection socket descriptor.
+ *
+ * @return OK on success.
+ */
+static int fsp_pre_connection(conn_rec* c, void* csd)
+{
+ // only install filters if a policy was specified in the module config
+ fsp_config* cfg = ap_get_module_config(
+ c->base_server->module_config, &fsp_module);
+ if(cfg->policy != NULL)
+ {
+ // allocate filter state
+ filter_state* state = apr_palloc(c->pool, sizeof(filter_state));
+ if(state != NULL)
+ {
+ // initialize state
+ state->cfg = cfg;
+ state->checked = state->found = 0;
+
+ // add filters
+ ap_add_input_filter("fsp_request", state, NULL, c);
+ ap_add_output_filter("fsp_response", state, NULL, c);
+ }
+ }
+
+ return OK;
+}
+
+/**
+ * Searches the input request for a flash socket policy request. This request,
+ * unfortunately, does not follow the HTTP protocol and cannot be handled
+ * via a special HTTP handler. Instead, it is a short xml string followed by
+ * a null character:
+ *
+ * '<policy-file-request/>\0'
+ *
+ * A peek into the incoming data checks the first character of the stream to
+ * see if it is '<' (as opposed to typically something else for HTTP). If it
+ * is not, then this function returns and HTTP input is read normally. If it
+ * is, then the remaining bytes in the policy-file-request are read and
+ * checked. If a match is found, then the filter state will be updated to
+ * inform the output filter to send a cross-domain policy as a response. If
+ * no match is found, HTTP traffic will proceed as usual.
+ *
+ * @param f the input filter.
+ * @param state the filter state.
+ *
+ * @return APR_SUCCESS on success, some other status on failure.
+ */
+static apr_status_t find_policy_file_request(
+ ap_filter_t* f, filter_state* state)
+{
+ apr_status_t rval = APR_SUCCESS;
+
+ // create a temp buffer for speculative reads
+ apr_bucket_brigade* tmp = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
+
+ // FIXME: not sure how blocking mode works ... can it return fewer than
+ // the number of specified bytes?
+
+ // peek at the first PFR_LENGTH bytes
+ rval = ap_get_brigade(
+ f->next, tmp, AP_MODE_SPECULATIVE, APR_BLOCK_READ, PFR_LENGTH);
+ if(rval == APR_SUCCESS)
+ {
+ // quickly check the first bucket for the beginning of a pfr
+ const char* data;
+ apr_size_t length;
+ apr_bucket* b = APR_BRIGADE_FIRST(tmp);
+ rval = apr_bucket_read(b, &data, &length, APR_BLOCK_READ);
+ if(rval == APR_SUCCESS && length > 0 && data[0] == '<')
+ {
+ // possible policy file request, fill local buffer
+ char pfr[PFR_LENGTH];
+ char* ptr = pfr;
+ memcpy(ptr, data, length);
+ ptr += length;
+ memset(ptr, '\0', PFR_LENGTH - length);
+ b = APR_BUCKET_NEXT(b);
+ while(rval == APR_SUCCESS && b != APR_BRIGADE_SENTINEL(tmp))
+ {
+ rval = apr_bucket_read(b, &data, &length, APR_BLOCK_READ);
+ if(rval == APR_SUCCESS)
+ {
+ memcpy(ptr, data, length);
+ ptr += length;
+ b = APR_BUCKET_NEXT(b);
+ }
+ }
+
+ if(rval == APR_SUCCESS)
+ {
+ // see if pfr is a policy file request: '<policy-file-request/>\0'
+ if((ptr - pfr == PFR_LENGTH) && (pfr[PFR_LENGTH - 1] == '\0') &&
+ (strncmp(pfr, "<policy-file-request/>", PFR_LENGTH -1) == 0))
+ {
+ // pfr found
+ state->found = 1;
+ }
+ }
+ }
+ }
+
+ return rval;
+}
+
+/**
+ * Handles incoming data. If an attempt has not yet been made to look for
+ * a policy request (it is the beginning of the connection), then one is
+ * made. Otherwise this filter does nothing.
+ *
+ * If an attempt is made to find a policy request and one is not found, then
+ * reads proceed as normal. If one is found, then the filter state is modified
+ * to inform the output filter to send a policy request and the return value
+ * of this filter is EOF indicating that the connection should close after
+ * sending the cross-domain policy.
+ *
+ * @param f the input filter.
+ * @param bb the brigate to fill with input from the next filters in the chain
+ * and then process (look for a policy file request).
+ * @param mode the type of read requested (ie: AP_MODE_GETLINE means read until
+ * a CRLF is found, AP_MODE_GETBYTES means 'nbytes' of data, etc).
+ * @param block APR_BLOCK_READ or APR_NONBLOCK_READ, indicates the type of
+ * blocking to do when trying to read.
+ * @param nbytes used if the read mode is appropriate to specify the number of
+ * bytes to read (set to 0 for AP_MODE_GETLINE).
+ *
+ * @return the status of the input (ie: APR_SUCCESS for read success, APR_EOF
+ * for end of stream, APR_EAGAIN to read again when non-blocking).
+ */
+static apr_status_t fsp_input_filter(
+ ap_filter_t* f, apr_bucket_brigade* bb,
+ ap_input_mode_t mode, apr_read_type_e block, apr_off_t nbytes)
+{
+ apr_status_t rval = APR_SUCCESS;
+
+ filter_state* state = f->ctx;
+ if(state->checked == 1)
+ {
+ // already checked for policy file request, just read from other filters
+ rval = ap_get_brigade(f->next, bb, mode, block, nbytes);
+ }
+ else
+ {
+ // try to find a policy file request
+ rval = find_policy_file_request(f, state);
+ state->checked = 1;
+
+ if(rval == APR_SUCCESS)
+ {
+ if(state->found)
+ {
+ // do read of PFR_LENGTH bytes, consider end of stream
+ rval = ap_get_brigade(
+ f->next, bb, AP_MODE_READBYTES, APR_BLOCK_READ, PFR_LENGTH);
+ rval = APR_EOF;
+ }
+ else
+ {
+ // do normal read
+ rval = ap_get_brigade(f->next, bb, mode, block, nbytes);
+ }
+ }
+ }
+
+ return rval;
+}
+
+/**
+ * Handles outgoing data. If the filter state indicates that a cross-domain
+ * policy should be sent then it is added to the outgoing brigade of data. If
+ * a policy request was not detected, then this filter makes no changes to
+ * the outgoing data.
+ *
+ * @param f the output filter.
+ * @param bb the outgoing brigade of data.
+ *
+ * @return APR_SUCCESS on success, some other status on error.
+ */
+static int fsp_output_filter(ap_filter_t* f, apr_bucket_brigade* bb)
+{
+ apr_status_t rval = APR_SUCCESS;
+
+ filter_state* state = f->ctx;
+ if(state->found)
+ {
+ // found policy-file-request, add response bucket
+ // bucket is immortal because the data is stored in the configuration
+ // and doesn't need to be copied
+ apr_bucket* head = apr_bucket_immortal_create(
+ state->cfg->policy, state->cfg->policy_length, bb->bucket_alloc);
+ APR_BRIGADE_INSERT_HEAD(bb, head);
+ }
+
+ if(rval == APR_SUCCESS)
+ {
+ // pass brigade to next filter
+ rval = ap_pass_brigade(f->next, bb);
+ }
+
+ return rval;
+}
+
+/**
+ * Creates the configuration for this module.
+ *
+ * @param p the pool to allocate from.
+ * @param s the server the configuration is for.
+ *
+ * @return the configuration data.
+ */
+static void* fsp_create_config(apr_pool_t* p, server_rec* s)
+{
+ // allocate config
+ fsp_config* cfg = apr_palloc(p, sizeof(fsp_config));
+
+ // no default policy
+ cfg->policy = NULL;
+ cfg->policy_length = 0;
+ return cfg;
+}
+
+/**
+ * Sets the policy file to use from the configuration.
+ *
+ * @param parms the command directive parameters.
+ * @param userdata NULL, not used.
+ * @param arg the string argument to the command directive (the file with
+ * the cross-domain policy to serve as content).
+ *
+ * @return NULL on success, otherwise an error string to display.
+ */
+static const char* fsp_set_policy_file(
+ cmd_parms* parms, void* userdata, const char* arg)
+{
+ const char* rval = NULL;
+
+ apr_pool_t* pool = (apr_pool_t*)parms->pool;
+ fsp_config* cfg = ap_get_module_config(
+ parms->server->module_config, &fsp_module);
+
+ // ensure command is in the correct context
+ rval = ap_check_cmd_context(parms, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
+ if(rval == NULL)
+ {
+ // get canonical file name
+ char* fname = ap_server_root_relative(pool, arg);
+ if(fname == NULL)
+ {
+ rval = (const char*)apr_psprintf(
+ pool, "%s: Invalid policy file '%s'",
+ parms->cmd->name, arg);
+ }
+ else
+ {
+ // try to open the file
+ apr_status_t rv;
+ apr_file_t* fd;
+ apr_finfo_t finfo;
+ rv = apr_file_open(&fd, fname, APR_READ, APR_OS_DEFAULT, pool);
+ if(rv == APR_SUCCESS)
+ {
+ // stat file
+ rv = apr_file_info_get(&finfo, APR_FINFO_NORM, fd);
+ if(rv == APR_SUCCESS)
+ {
+ // ensure file is not empty
+ apr_size_t length = (apr_size_t)finfo.size;
+ if(length <= 0)
+ {
+ rval = (const char*)apr_psprintf(
+ pool, "%s: policy file '%s' is empty",
+ parms->cmd->name, fname);
+ }
+ // read file
+ else
+ {
+ char* buf = (char*)apr_palloc(pool, length + 1);
+ buf[length] = '\0';
+ rv = apr_file_read_full(fd, buf, length, NULL);
+ if(rv == APR_SUCCESS)
+ {
+ // TODO: validate file
+ // save policy string
+ cfg->policy = buf;
+ cfg->policy_length = length + 1;
+ }
+ }
+
+ // close the file
+ apr_file_close(fd);
+ }
+ }
+
+ // handle error case
+ if(rv != APR_SUCCESS)
+ {
+ char errmsg[120];
+ rval = (const char*)apr_psprintf(
+ pool, "%s: Invalid policy file '%s' (%s)",
+ parms->cmd->name, fname,
+ apr_strerror(rv, errmsg, sizeof(errmsg)));
+ }
+ }
+ }
+
+ return rval;
+}
+
+// table of configuration directives
+static const command_rec fsp_cmds[] =
+{
+ AP_INIT_TAKE1(
+ "FSPPolicyFile", /* the directive */
+ fsp_set_policy_file, /* function to call when directive is found */
+ NULL, /* user data to pass to function, not used */
+ RSRC_CONF, /* indicates the directive appears outside of <Location> */
+ "FSPPolicyFile (string) The cross-domain policy file to use"), /* docs */
+ {NULL}
+};
+
+// module setup
+module AP_MODULE_DECLARE_DATA fsp_module =
+{
+ STANDARD20_MODULE_STUFF, /* stuff declared in every 2.0 mod */
+ NULL, /* create per-directory config structure */
+ NULL, /* merge per-directory config structures */
+ fsp_create_config, /* create per-server config structure */
+ NULL, /* merge per-server config structures */
+ fsp_cmds, /* command apr_table_t */
+ fsp_register_hooks /* register hooks */
+};
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/README.md
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/README.md b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/README.md
new file mode 100644
index 0000000..1be00fa
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/README.md
@@ -0,0 +1,34 @@
+Running all the tests (headless-browser and node.js)
+====================================================
+
+ npm install
+ npm test
+
+Running the browser-based tests
+===============================
+
+ npm install
+ node server.js
+
+Then go to http://localhost:8083/.
+
+Testing Require.js optimised version of the JavaScript
+------------------------------------------------------
+
+ npm install -g requirejs
+ r.js -o build.js
+
+You will now have a single optimised JS file at ui/test.min.js, containing the
+tests and all the forge dependencies.
+
+Now edit ui/index.html and change `data-main="test"` to `data-main="test.min"`,
+then reload http://localhost:8083/.
+
+Building a minimized single file for all forge modules
+------------------------------------------------------
+
+ npm install -g requirejs
+ r.js -o minify.js
+
+You will now have forge.min.js, in the 'js' directory, which will contain all
+forge modules.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/build.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/build.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/build.js
new file mode 100644
index 0000000..30ba7b5
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/build.js
@@ -0,0 +1,8 @@
+({
+ paths: {
+ forge: '../js'
+ },
+ name: 'ui/test.js',
+ out: 'ui/test.min.js',
+ preserveLicenseComments: false
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/minify.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/minify.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/minify.js
new file mode 100644
index 0000000..69d96a9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/minify.js
@@ -0,0 +1,8 @@
+({
+ paths: {
+ forge: '../js'
+ },
+ name: '../js/forge',
+ out: '../js/forge.min.js',
+ preserveLicenseComments: false
+})
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/package.json
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/package.json b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/package.json
new file mode 100644
index 0000000..f60f52a
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/package.json
@@ -0,0 +1,17 @@
+{
+ "name": "forge-nodejs-example",
+ "version": "0.1.0",
+ "private": true,
+ "main": "server.js",
+ "dependencies": {
+ "express": "~3.1.0",
+ "mocha": "~1.8.2",
+ "chai": "~1.5.0",
+ "grunt": "~0.4.1",
+ "grunt-mocha": "~0.3.1"
+ },
+ "scripts": {
+ "test": "mocha -t 20000 -R spec test/*.js",
+ "run": "node server"
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/server.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/server.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/server.js
new file mode 100644
index 0000000..175bd56
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/server.js
@@ -0,0 +1,46 @@
+var PATH = require('path');
+var express = require('express');
+var PORT = 8083;
+
+exports.main = function(callback) {
+ try {
+ var app = express();
+
+ mountStaticDir(app, /^\/forge\/(.*)$/, PATH.join(__dirname, '../js'));
+ mountStaticDir(app, /^\/test\/(.*)$/, PATH.join(__dirname, 'test'));
+ mountStaticDir(app, /^\/mocha\/(.*)$/, PATH.join(__dirname, 'node_modules/mocha'));
+ mountStaticDir(app, /^\/chai\/(.*)$/, PATH.join(__dirname, 'node_modules/chai'));
+ app.get(/^\//, express.static(PATH.join(__dirname, 'ui')));
+
+ var server = app.listen(PORT);
+
+ console.log('open http://localhost:' + PORT + '/');
+
+ return callback(null, {
+ server: server,
+ port: PORT
+ });
+ } catch(err) {
+ return callback(err);
+ }
+};
+
+function mountStaticDir(app, route, path) {
+ app.get(route, function(req, res, next) {
+ var originalUrl = req.url;
+ req.url = req.params[0];
+ express.static(path)(req, res, function() {
+ req.url = originalUrl;
+ return next.apply(null, arguments);
+ });
+ });
+}
+
+if(require.main === module) {
+ exports.main(function(err) {
+ if(err) {
+ console.error(err.stack);
+ process.exit(1);
+ }
+ });
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[06/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/x509.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/x509.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/x509.js
new file mode 100644
index 0000000..6cd8585
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/x509.js
@@ -0,0 +1,3178 @@
+/**
+ * Javascript implementation of X.509 and related components (such as
+ * Certification Signing Requests) of a Public Key Infrastructure.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
+ *
+ * The ASN.1 representation of an X.509v3 certificate is as follows
+ * (see RFC 2459):
+ *
+ * Certificate ::= SEQUENCE {
+ * tbsCertificate TBSCertificate,
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signatureValue BIT STRING
+ * }
+ *
+ * TBSCertificate ::= SEQUENCE {
+ * version [0] EXPLICIT Version DEFAULT v1,
+ * serialNumber CertificateSerialNumber,
+ * signature AlgorithmIdentifier,
+ * issuer Name,
+ * validity Validity,
+ * subject Name,
+ * subjectPublicKeyInfo SubjectPublicKeyInfo,
+ * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,
+ * -- If present, version shall be v2 or v3
+ * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,
+ * -- If present, version shall be v2 or v3
+ * extensions [3] EXPLICIT Extensions OPTIONAL
+ * -- If present, version shall be v3
+ * }
+ *
+ * Version ::= INTEGER { v1(0), v2(1), v3(2) }
+ *
+ * CertificateSerialNumber ::= INTEGER
+ *
+ * Name ::= CHOICE {
+ * // only one possible choice for now
+ * RDNSequence
+ * }
+ *
+ * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
+ *
+ * RelativeDistinguishedName ::= SET OF AttributeTypeAndValue
+ *
+ * AttributeTypeAndValue ::= SEQUENCE {
+ * type AttributeType,
+ * value AttributeValue
+ * }
+ * AttributeType ::= OBJECT IDENTIFIER
+ * AttributeValue ::= ANY DEFINED BY AttributeType
+ *
+ * Validity ::= SEQUENCE {
+ * notBefore Time,
+ * notAfter Time
+ * }
+ *
+ * Time ::= CHOICE {
+ * utcTime UTCTime,
+ * generalTime GeneralizedTime
+ * }
+ *
+ * UniqueIdentifier ::= BIT STRING
+ *
+ * SubjectPublicKeyInfo ::= SEQUENCE {
+ * algorithm AlgorithmIdentifier,
+ * subjectPublicKey BIT STRING
+ * }
+ *
+ * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
+ *
+ * Extension ::= SEQUENCE {
+ * extnID OBJECT IDENTIFIER,
+ * critical BOOLEAN DEFAULT FALSE,
+ * extnValue OCTET STRING
+ * }
+ *
+ * The only key algorithm currently supported for PKI is RSA.
+ *
+ * RSASSA-PSS signatures are described in RFC 3447 and RFC 4055.
+ *
+ * PKCS#10 v1.7 describes certificate signing requests:
+ *
+ * CertificationRequestInfo:
+ *
+ * CertificationRequestInfo ::= SEQUENCE {
+ * version INTEGER { v1(0) } (v1,...),
+ * subject Name,
+ * subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},
+ * attributes [0] Attributes{{ CRIAttributes }}
+ * }
+ *
+ * Attributes { ATTRIBUTE:IOSet } ::= SET OF Attribute{{ IOSet }}
+ *
+ * CRIAttributes ATTRIBUTE ::= {
+ * ... -- add any locally defined attributes here -- }
+ *
+ * Attribute { ATTRIBUTE:IOSet } ::= SEQUENCE {
+ * type ATTRIBUTE.&id({IOSet}),
+ * values SET SIZE(1..MAX) OF ATTRIBUTE.&Type({IOSet}{@type})
+ * }
+ *
+ * CertificationRequest ::= SEQUENCE {
+ * certificationRequestInfo CertificationRequestInfo,
+ * signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }},
+ * signature BIT STRING
+ * }
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// shortcut for asn.1 API
+var asn1 = forge.asn1;
+
+/* Public Key Infrastructure (PKI) implementation. */
+var pki = forge.pki = forge.pki || {};
+var oids = pki.oids;
+
+// short name OID mappings
+var _shortNames = {};
+_shortNames['CN'] = oids['commonName'];
+_shortNames['commonName'] = 'CN';
+_shortNames['C'] = oids['countryName'];
+_shortNames['countryName'] = 'C';
+_shortNames['L'] = oids['localityName'];
+_shortNames['localityName'] = 'L';
+_shortNames['ST'] = oids['stateOrProvinceName'];
+_shortNames['stateOrProvinceName'] = 'ST';
+_shortNames['O'] = oids['organizationName'];
+_shortNames['organizationName'] = 'O';
+_shortNames['OU'] = oids['organizationalUnitName'];
+_shortNames['organizationalUnitName'] = 'OU';
+_shortNames['E'] = oids['emailAddress'];
+_shortNames['emailAddress'] = 'E';
+
+// validator for an SubjectPublicKeyInfo structure
+// Note: Currently only works with an RSA public key
+var publicKeyValidator = forge.pki.rsa.publicKeyValidator;
+
+// validator for an X.509v3 certificate
+var x509CertificateValidator = {
+ name: 'Certificate',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'Certificate.TBSCertificate',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'tbsCertificate',
+ value: [{
+ name: 'Certificate.TBSCertificate.version',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 0,
+ constructed: true,
+ optional: true,
+ value: [{
+ name: 'Certificate.TBSCertificate.version.integer',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'certVersion'
+ }]
+ }, {
+ name: 'Certificate.TBSCertificate.serialNumber',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'certSerialNumber'
+ }, {
+ name: 'Certificate.TBSCertificate.signature',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'Certificate.TBSCertificate.signature.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'certinfoSignatureOid'
+ }, {
+ name: 'Certificate.TBSCertificate.signature.parameters',
+ tagClass: asn1.Class.UNIVERSAL,
+ optional: true,
+ captureAsn1: 'certinfoSignatureParams'
+ }]
+ }, {
+ name: 'Certificate.TBSCertificate.issuer',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'certIssuer'
+ }, {
+ name: 'Certificate.TBSCertificate.validity',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ // Note: UTC and generalized times may both appear so the capture
+ // names are based on their detected order, the names used below
+ // are only for the common case, which validity time really means
+ // "notBefore" and which means "notAfter" will be determined by order
+ value: [{
+ // notBefore (Time) (UTC time case)
+ name: 'Certificate.TBSCertificate.validity.notBefore (utc)',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.UTCTIME,
+ constructed: false,
+ optional: true,
+ capture: 'certValidity1UTCTime'
+ }, {
+ // notBefore (Time) (generalized time case)
+ name: 'Certificate.TBSCertificate.validity.notBefore (generalized)',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.GENERALIZEDTIME,
+ constructed: false,
+ optional: true,
+ capture: 'certValidity2GeneralizedTime'
+ }, {
+ // notAfter (Time) (only UTC time is supported)
+ name: 'Certificate.TBSCertificate.validity.notAfter (utc)',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.UTCTIME,
+ constructed: false,
+ optional: true,
+ capture: 'certValidity3UTCTime'
+ }, {
+ // notAfter (Time) (only UTC time is supported)
+ name: 'Certificate.TBSCertificate.validity.notAfter (generalized)',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.GENERALIZEDTIME,
+ constructed: false,
+ optional: true,
+ capture: 'certValidity4GeneralizedTime'
+ }]
+ }, {
+ // Name (subject) (RDNSequence)
+ name: 'Certificate.TBSCertificate.subject',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'certSubject'
+ },
+ // SubjectPublicKeyInfo
+ publicKeyValidator,
+ {
+ // issuerUniqueID (optional)
+ name: 'Certificate.TBSCertificate.issuerUniqueID',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 1,
+ constructed: true,
+ optional: true,
+ value: [{
+ name: 'Certificate.TBSCertificate.issuerUniqueID.id',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.BITSTRING,
+ constructed: false,
+ capture: 'certIssuerUniqueId'
+ }]
+ }, {
+ // subjectUniqueID (optional)
+ name: 'Certificate.TBSCertificate.subjectUniqueID',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 2,
+ constructed: true,
+ optional: true,
+ value: [{
+ name: 'Certificate.TBSCertificate.subjectUniqueID.id',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.BITSTRING,
+ constructed: false,
+ capture: 'certSubjectUniqueId'
+ }]
+ }, {
+ // Extensions (optional)
+ name: 'Certificate.TBSCertificate.extensions',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 3,
+ constructed: true,
+ captureAsn1: 'certExtensions',
+ optional: true
+ }]
+ }, {
+ // AlgorithmIdentifier (signature algorithm)
+ name: 'Certificate.signatureAlgorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ // algorithm
+ name: 'Certificate.signatureAlgorithm.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'certSignatureOid'
+ }, {
+ name: 'Certificate.TBSCertificate.signature.parameters',
+ tagClass: asn1.Class.UNIVERSAL,
+ optional: true,
+ captureAsn1: 'certSignatureParams'
+ }]
+ }, {
+ // SignatureValue
+ name: 'Certificate.signatureValue',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.BITSTRING,
+ constructed: false,
+ capture: 'certSignature'
+ }]
+};
+
+var rsassaPssParameterValidator = {
+ name: 'rsapss',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'rsapss.hashAlgorithm',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 0,
+ constructed: true,
+ value: [{
+ name: 'rsapss.hashAlgorithm.AlgorithmIdentifier',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Class.SEQUENCE,
+ constructed: true,
+ optional: true,
+ value: [{
+ name: 'rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'hashOid'
+ /* parameter block omitted, for SHA1 NULL anyhow. */
+ }]
+ }]
+ }, {
+ name: 'rsapss.maskGenAlgorithm',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 1,
+ constructed: true,
+ value: [{
+ name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Class.SEQUENCE,
+ constructed: true,
+ optional: true,
+ value: [{
+ name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'maskGenOid'
+ }, {
+ name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.params',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'maskGenHashOid'
+ /* parameter block omitted, for SHA1 NULL anyhow. */
+ }]
+ }]
+ }]
+ }, {
+ name: 'rsapss.saltLength',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 2,
+ optional: true,
+ value: [{
+ name: 'rsapss.saltLength.saltLength',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Class.INTEGER,
+ constructed: false,
+ capture: 'saltLength'
+ }]
+ }, {
+ name: 'rsapss.trailerField',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 3,
+ optional: true,
+ value: [{
+ name: 'rsapss.trailer.trailer',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Class.INTEGER,
+ constructed: false,
+ capture: 'trailer'
+ }]
+ }]
+};
+
+// validator for a CertificationRequestInfo structure
+var certificationRequestInfoValidator = {
+ name: 'CertificationRequestInfo',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'certificationRequestInfo',
+ value: [{
+ name: 'CertificationRequestInfo.integer',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ constructed: false,
+ capture: 'certificationRequestInfoVersion'
+ }, {
+ // Name (subject) (RDNSequence)
+ name: 'CertificationRequestInfo.subject',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'certificationRequestInfoSubject'
+ },
+ // SubjectPublicKeyInfo
+ publicKeyValidator,
+ {
+ name: 'CertificationRequestInfo.attributes',
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 0,
+ constructed: true,
+ optional: true,
+ capture: 'certificationRequestInfoAttributes',
+ value: [{
+ name: 'CertificationRequestInfo.attributes',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'CertificationRequestInfo.attributes.type',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false
+ }, {
+ name: 'CertificationRequestInfo.attributes.value',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SET,
+ constructed: true
+ }]
+ }]
+ }]
+};
+
+// validator for a CertificationRequest structure
+var certificationRequestValidator = {
+ name: 'CertificationRequest',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ captureAsn1: 'csr',
+ value: [
+ certificationRequestInfoValidator, {
+ // AlgorithmIdentifier (signature algorithm)
+ name: 'CertificationRequest.signatureAlgorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ // algorithm
+ name: 'CertificationRequest.signatureAlgorithm.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ constructed: false,
+ capture: 'csrSignatureOid'
+ }, {
+ name: 'CertificationRequest.signatureAlgorithm.parameters',
+ tagClass: asn1.Class.UNIVERSAL,
+ optional: true,
+ captureAsn1: 'csrSignatureParams'
+ }]
+ }, {
+ // signature
+ name: 'CertificationRequest.signature',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.BITSTRING,
+ constructed: false,
+ capture: 'csrSignature'
+ }]
+};
+
+/**
+ * Converts an RDNSequence of ASN.1 DER-encoded RelativeDistinguishedName
+ * sets into an array with objects that have type and value properties.
+ *
+ * @param rdn the RDNSequence to convert.
+ * @param md a message digest to append type and value to if provided.
+ */
+pki.RDNAttributesAsArray = function(rdn, md) {
+ var rval = [];
+
+ // each value in 'rdn' in is a SET of RelativeDistinguishedName
+ var set, attr, obj;
+ for(var si = 0; si < rdn.value.length; ++si) {
+ // get the RelativeDistinguishedName set
+ set = rdn.value[si];
+
+ // each value in the SET is an AttributeTypeAndValue sequence
+ // containing first a type (an OID) and second a value (defined by
+ // the OID)
+ for(var i = 0; i < set.value.length; ++i) {
+ obj = {};
+ attr = set.value[i];
+ obj.type = asn1.derToOid(attr.value[0].value);
+ obj.value = attr.value[1].value;
+ obj.valueTagClass = attr.value[1].type;
+ // if the OID is known, get its name and short name
+ if(obj.type in oids) {
+ obj.name = oids[obj.type];
+ if(obj.name in _shortNames) {
+ obj.shortName = _shortNames[obj.name];
+ }
+ }
+ if(md) {
+ md.update(obj.type);
+ md.update(obj.value);
+ }
+ rval.push(obj);
+ }
+ }
+
+ return rval;
+};
+
+/**
+ * Converts ASN.1 CRIAttributes into an array with objects that have type and
+ * value properties.
+ *
+ * @param attributes the CRIAttributes to convert.
+ */
+pki.CRIAttributesAsArray = function(attributes) {
+ var rval = [];
+
+ // each value in 'attributes' in is a SEQUENCE with an OID and a SET
+ for(var si = 0; si < attributes.length; ++si) {
+ // get the attribute sequence
+ var seq = attributes[si];
+
+ // each value in the SEQUENCE containing first a type (an OID) and
+ // second a set of values (defined by the OID)
+ var type = asn1.derToOid(seq.value[0].value);
+ var values = seq.value[1].value;
+ for(var vi = 0; vi < values.length; ++vi) {
+ var obj = {};
+ obj.type = type;
+ obj.value = values[vi].value;
+ obj.valueTagClass = values[vi].type;
+ // if the OID is known, get its name and short name
+ if(obj.type in oids) {
+ obj.name = oids[obj.type];
+ if(obj.name in _shortNames) {
+ obj.shortName = _shortNames[obj.name];
+ }
+ }
+ // parse extensions
+ if(obj.type === oids.extensionRequest) {
+ obj.extensions = [];
+ for(var ei = 0; ei < obj.value.length; ++ei) {
+ obj.extensions.push(pki.certificateExtensionFromAsn1(obj.value[ei]));
+ }
+ }
+ rval.push(obj);
+ }
+ }
+
+ return rval;
+};
+
+/**
+ * Gets an issuer or subject attribute from its name, type, or short name.
+ *
+ * @param obj the issuer or subject object.
+ * @param options a short name string or an object with:
+ * shortName the short name for the attribute.
+ * name the name for the attribute.
+ * type the type for the attribute.
+ *
+ * @return the attribute.
+ */
+function _getAttribute(obj, options) {
+ if(typeof options === 'string') {
+ options = {shortName: options};
+ }
+
+ var rval = null;
+ var attr;
+ for(var i = 0; rval === null && i < obj.attributes.length; ++i) {
+ attr = obj.attributes[i];
+ if(options.type && options.type === attr.type) {
+ rval = attr;
+ } else if(options.name && options.name === attr.name) {
+ rval = attr;
+ } else if(options.shortName && options.shortName === attr.shortName) {
+ rval = attr;
+ }
+ }
+ return rval;
+}
+
+/**
+ * Converts signature parameters from ASN.1 structure.
+ *
+ * Currently only RSASSA-PSS supported. The PKCS#1 v1.5 signature scheme had
+ * no parameters.
+ *
+ * RSASSA-PSS-params ::= SEQUENCE {
+ * hashAlgorithm [0] HashAlgorithm DEFAULT
+ * sha1Identifier,
+ * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT
+ * mgf1SHA1Identifier,
+ * saltLength [2] INTEGER DEFAULT 20,
+ * trailerField [3] INTEGER DEFAULT 1
+ * }
+ *
+ * HashAlgorithm ::= AlgorithmIdentifier
+ *
+ * MaskGenAlgorithm ::= AlgorithmIdentifier
+ *
+ * AlgorithmIdentifer ::= SEQUENCE {
+ * algorithm OBJECT IDENTIFIER,
+ * parameters ANY DEFINED BY algorithm OPTIONAL
+ * }
+ *
+ * @param oid The OID specifying the signature algorithm
+ * @param obj The ASN.1 structure holding the parameters
+ * @param fillDefaults Whether to use return default values where omitted
+ * @return signature parameter object
+ */
+var _readSignatureParameters = function(oid, obj, fillDefaults) {
+ var params = {};
+
+ if(oid !== oids['RSASSA-PSS']) {
+ return params;
+ }
+
+ if(fillDefaults) {
+ params = {
+ hash: {
+ algorithmOid: oids['sha1']
+ },
+ mgf: {
+ algorithmOid: oids['mgf1'],
+ hash: {
+ algorithmOid: oids['sha1']
+ }
+ },
+ saltLength: 20
+ };
+ }
+
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(obj, rsassaPssParameterValidator, capture, errors)) {
+ var error = new Error('Cannot read RSASSA-PSS parameter block.');
+ error.errors = errors;
+ throw error;
+ }
+
+ if(capture.hashOid !== undefined) {
+ params.hash = params.hash || {};
+ params.hash.algorithmOid = asn1.derToOid(capture.hashOid);
+ }
+
+ if(capture.maskGenOid !== undefined) {
+ params.mgf = params.mgf || {};
+ params.mgf.algorithmOid = asn1.derToOid(capture.maskGenOid);
+ params.mgf.hash = params.mgf.hash || {};
+ params.mgf.hash.algorithmOid = asn1.derToOid(capture.maskGenHashOid);
+ }
+
+ if(capture.saltLength !== undefined) {
+ params.saltLength = capture.saltLength.charCodeAt(0);
+ }
+
+ return params;
+};
+
+/**
+ * Converts an X.509 certificate from PEM format.
+ *
+ * Note: If the certificate is to be verified then compute hash should
+ * be set to true. This will scan the TBSCertificate part of the ASN.1
+ * object while it is converted so it doesn't need to be converted back
+ * to ASN.1-DER-encoding later.
+ *
+ * @param pem the PEM-formatted certificate.
+ * @param computeHash true to compute the hash for verification.
+ * @param strict true to be strict when checking ASN.1 value lengths, false to
+ * allow truncated values (default: true).
+ *
+ * @return the certificate.
+ */
+pki.certificateFromPem = function(pem, computeHash, strict) {
+ var msg = forge.pem.decode(pem)[0];
+
+ if(msg.type !== 'CERTIFICATE' &&
+ msg.type !== 'X509 CERTIFICATE' &&
+ msg.type !== 'TRUSTED CERTIFICATE') {
+ var error = new Error('Could not convert certificate from PEM; PEM header type ' +
+ 'is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');
+ error.headerType = msg.type;
+ throw error;
+ }
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
+ throw new Error('Could not convert certificate from PEM; PEM is encrypted.');
+ }
+
+ // convert DER to ASN.1 object
+ var obj = asn1.fromDer(msg.body, strict);
+
+ return pki.certificateFromAsn1(obj, computeHash);
+};
+
+/**
+ * Converts an X.509 certificate to PEM format.
+ *
+ * @param cert the certificate.
+ * @param maxline the maximum characters per line, defaults to 64.
+ *
+ * @return the PEM-formatted certificate.
+ */
+pki.certificateToPem = function(cert, maxline) {
+ // convert to ASN.1, then DER, then PEM-encode
+ var msg = {
+ type: 'CERTIFICATE',
+ body: asn1.toDer(pki.certificateToAsn1(cert)).getBytes()
+ };
+ return forge.pem.encode(msg, {maxline: maxline});
+};
+
+/**
+ * Converts an RSA public key from PEM format.
+ *
+ * @param pem the PEM-formatted public key.
+ *
+ * @return the public key.
+ */
+pki.publicKeyFromPem = function(pem) {
+ var msg = forge.pem.decode(pem)[0];
+
+ if(msg.type !== 'PUBLIC KEY' && msg.type !== 'RSA PUBLIC KEY') {
+ var error = new Error('Could not convert public key from PEM; PEM header ' +
+ 'type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');
+ error.headerType = msg.type;
+ throw error;
+ }
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
+ throw new Error('Could not convert public key from PEM; PEM is encrypted.');
+ }
+
+ // convert DER to ASN.1 object
+ var obj = asn1.fromDer(msg.body);
+
+ return pki.publicKeyFromAsn1(obj);
+};
+
+/**
+ * Converts an RSA public key to PEM format (using a SubjectPublicKeyInfo).
+ *
+ * @param key the public key.
+ * @param maxline the maximum characters per line, defaults to 64.
+ *
+ * @return the PEM-formatted public key.
+ */
+pki.publicKeyToPem = function(key, maxline) {
+ // convert to ASN.1, then DER, then PEM-encode
+ var msg = {
+ type: 'PUBLIC KEY',
+ body: asn1.toDer(pki.publicKeyToAsn1(key)).getBytes()
+ };
+ return forge.pem.encode(msg, {maxline: maxline});
+};
+
+/**
+ * Converts an RSA public key to PEM format (using an RSAPublicKey).
+ *
+ * @param key the public key.
+ * @param maxline the maximum characters per line, defaults to 64.
+ *
+ * @return the PEM-formatted public key.
+ */
+pki.publicKeyToRSAPublicKeyPem = function(key, maxline) {
+ // convert to ASN.1, then DER, then PEM-encode
+ var msg = {
+ type: 'RSA PUBLIC KEY',
+ body: asn1.toDer(pki.publicKeyToRSAPublicKey(key)).getBytes()
+ };
+ return forge.pem.encode(msg, {maxline: maxline});
+};
+
+/**
+ * Gets a fingerprint for the given public key.
+ *
+ * @param options the options to use.
+ * [md] the message digest object to use (defaults to forge.md.sha1).
+ * [type] the type of fingerprint, such as 'RSAPublicKey',
+ * 'SubjectPublicKeyInfo' (defaults to 'RSAPublicKey').
+ * [encoding] an alternative output encoding, such as 'hex'
+ * (defaults to none, outputs a byte buffer).
+ * [delimiter] the delimiter to use between bytes for 'hex' encoded
+ * output, eg: ':' (defaults to none).
+ *
+ * @return the fingerprint as a byte buffer or other encoding based on options.
+ */
+pki.getPublicKeyFingerprint = function(key, options) {
+ options = options || {};
+ var md = options.md || forge.md.sha1.create();
+ var type = options.type || 'RSAPublicKey';
+
+ var bytes;
+ switch(type) {
+ case 'RSAPublicKey':
+ bytes = asn1.toDer(pki.publicKeyToRSAPublicKey(key)).getBytes();
+ break;
+ case 'SubjectPublicKeyInfo':
+ bytes = asn1.toDer(pki.publicKeyToAsn1(key)).getBytes();
+ break;
+ default:
+ throw new Error('Unknown fingerprint type "' + options.type + '".');
+ }
+
+ // hash public key bytes
+ md.start();
+ md.update(bytes);
+ var digest = md.digest();
+ if(options.encoding === 'hex') {
+ var hex = digest.toHex();
+ if(options.delimiter) {
+ return hex.match(/.{2}/g).join(options.delimiter);
+ }
+ return hex;
+ } else if(options.encoding === 'binary') {
+ return digest.getBytes();
+ } else if(options.encoding) {
+ throw new Error('Unknown encoding "' + options.encoding + '".');
+ }
+ return digest;
+};
+
+/**
+ * Converts a PKCS#10 certification request (CSR) from PEM format.
+ *
+ * Note: If the certification request is to be verified then compute hash
+ * should be set to true. This will scan the CertificationRequestInfo part of
+ * the ASN.1 object while it is converted so it doesn't need to be converted
+ * back to ASN.1-DER-encoding later.
+ *
+ * @param pem the PEM-formatted certificate.
+ * @param computeHash true to compute the hash for verification.
+ * @param strict true to be strict when checking ASN.1 value lengths, false to
+ * allow truncated values (default: true).
+ *
+ * @return the certification request (CSR).
+ */
+pki.certificationRequestFromPem = function(pem, computeHash, strict) {
+ var msg = forge.pem.decode(pem)[0];
+
+ if(msg.type !== 'CERTIFICATE REQUEST') {
+ var error = new Error('Could not convert certification request from PEM; ' +
+ 'PEM header type is not "CERTIFICATE REQUEST".');
+ error.headerType = msg.type;
+ throw error;
+ }
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
+ throw new Error('Could not convert certification request from PEM; ' +
+ 'PEM is encrypted.');
+ }
+
+ // convert DER to ASN.1 object
+ var obj = asn1.fromDer(msg.body, strict);
+
+ return pki.certificationRequestFromAsn1(obj, computeHash);
+};
+
+/**
+ * Converts a PKCS#10 certification request (CSR) to PEM format.
+ *
+ * @param csr the certification request.
+ * @param maxline the maximum characters per line, defaults to 64.
+ *
+ * @return the PEM-formatted certification request.
+ */
+pki.certificationRequestToPem = function(csr, maxline) {
+ // convert to ASN.1, then DER, then PEM-encode
+ var msg = {
+ type: 'CERTIFICATE REQUEST',
+ body: asn1.toDer(pki.certificationRequestToAsn1(csr)).getBytes()
+ };
+ return forge.pem.encode(msg, {maxline: maxline});
+};
+
+/**
+ * Creates an empty X.509v3 RSA certificate.
+ *
+ * @return the certificate.
+ */
+pki.createCertificate = function() {
+ var cert = {};
+ cert.version = 0x02;
+ cert.serialNumber = '00';
+ cert.signatureOid = null;
+ cert.signature = null;
+ cert.siginfo = {};
+ cert.siginfo.algorithmOid = null;
+ cert.validity = {};
+ cert.validity.notBefore = new Date();
+ cert.validity.notAfter = new Date();
+
+ cert.issuer = {};
+ cert.issuer.getField = function(sn) {
+ return _getAttribute(cert.issuer, sn);
+ };
+ cert.issuer.addField = function(attr) {
+ _fillMissingFields([attr]);
+ cert.issuer.attributes.push(attr);
+ };
+ cert.issuer.attributes = [];
+ cert.issuer.hash = null;
+
+ cert.subject = {};
+ cert.subject.getField = function(sn) {
+ return _getAttribute(cert.subject, sn);
+ };
+ cert.subject.addField = function(attr) {
+ _fillMissingFields([attr]);
+ cert.subject.attributes.push(attr);
+ };
+ cert.subject.attributes = [];
+ cert.subject.hash = null;
+
+ cert.extensions = [];
+ cert.publicKey = null;
+ cert.md = null;
+
+ /**
+ * Sets the subject of this certificate.
+ *
+ * @param attrs the array of subject attributes to use.
+ * @param uniqueId an optional a unique ID to use.
+ */
+ cert.setSubject = function(attrs, uniqueId) {
+ // set new attributes, clear hash
+ _fillMissingFields(attrs);
+ cert.subject.attributes = attrs;
+ delete cert.subject.uniqueId;
+ if(uniqueId) {
+ cert.subject.uniqueId = uniqueId;
+ }
+ cert.subject.hash = null;
+ };
+
+ /**
+ * Sets the issuer of this certificate.
+ *
+ * @param attrs the array of issuer attributes to use.
+ * @param uniqueId an optional a unique ID to use.
+ */
+ cert.setIssuer = function(attrs, uniqueId) {
+ // set new attributes, clear hash
+ _fillMissingFields(attrs);
+ cert.issuer.attributes = attrs;
+ delete cert.issuer.uniqueId;
+ if(uniqueId) {
+ cert.issuer.uniqueId = uniqueId;
+ }
+ cert.issuer.hash = null;
+ };
+
+ /**
+ * Sets the extensions of this certificate.
+ *
+ * @param exts the array of extensions to use.
+ */
+ cert.setExtensions = function(exts) {
+ for(var i = 0; i < exts.length; ++i) {
+ _fillMissingExtensionFields(exts[i], {cert: cert});
+ }
+ // set new extensions
+ cert.extensions = exts;
+ };
+
+ /**
+ * Gets an extension by its name or id.
+ *
+ * @param options the name to use or an object with:
+ * name the name to use.
+ * id the id to use.
+ *
+ * @return the extension or null if not found.
+ */
+ cert.getExtension = function(options) {
+ if(typeof options === 'string') {
+ options = {name: options};
+ }
+
+ var rval = null;
+ var ext;
+ for(var i = 0; rval === null && i < cert.extensions.length; ++i) {
+ ext = cert.extensions[i];
+ if(options.id && ext.id === options.id) {
+ rval = ext;
+ } else if(options.name && ext.name === options.name) {
+ rval = ext;
+ }
+ }
+ return rval;
+ };
+
+ /**
+ * Signs this certificate using the given private key.
+ *
+ * @param key the private key to sign with.
+ * @param md the message digest object to use (defaults to forge.md.sha1).
+ */
+ cert.sign = function(key, md) {
+ // TODO: get signature OID from private key
+ cert.md = md || forge.md.sha1.create();
+ var algorithmOid = oids[cert.md.algorithm + 'WithRSAEncryption'];
+ if(!algorithmOid) {
+ var error = new Error('Could not compute certificate digest. ' +
+ 'Unknown message digest algorithm OID.');
+ error.algorithm = cert.md.algorithm;
+ throw error;
+ }
+ cert.signatureOid = cert.siginfo.algorithmOid = algorithmOid;
+
+ // get TBSCertificate, convert to DER
+ cert.tbsCertificate = pki.getTBSCertificate(cert);
+ var bytes = asn1.toDer(cert.tbsCertificate);
+
+ // digest and sign
+ cert.md.update(bytes.getBytes());
+ cert.signature = key.sign(cert.md);
+ };
+
+ /**
+ * Attempts verify the signature on the passed certificate using this
+ * certificate's public key.
+ *
+ * @param child the certificate to verify.
+ *
+ * @return true if verified, false if not.
+ */
+ cert.verify = function(child) {
+ var rval = false;
+
+ if(!cert.issued(child)) {
+ var issuer = child.issuer;
+ var subject = cert.subject;
+ var error = new Error('The parent certificate did not issue the given child ' +
+ 'certificate; the child certificate\'s issuer does not match the ' +
+ 'parent\'s subject.');
+ error.expectedIssuer = issuer.attributes;
+ error.actualIssuer = subject.attributes;
+ throw error;
+ }
+
+ var md = child.md;
+ if(md === null) {
+ // check signature OID for supported signature types
+ if(child.signatureOid in oids) {
+ var oid = oids[child.signatureOid];
+ switch(oid) {
+ case 'sha1WithRSAEncryption':
+ md = forge.md.sha1.create();
+ break;
+ case 'md5WithRSAEncryption':
+ md = forge.md.md5.create();
+ break;
+ case 'sha256WithRSAEncryption':
+ md = forge.md.sha256.create();
+ break;
+ case 'RSASSA-PSS':
+ md = forge.md.sha256.create();
+ break;
+ }
+ }
+ if(md === null) {
+ var error = new Error('Could not compute certificate digest. ' +
+ 'Unknown signature OID.');
+ error.signatureOid = child.signatureOid;
+ throw error;
+ }
+
+ // produce DER formatted TBSCertificate and digest it
+ var tbsCertificate = child.tbsCertificate || pki.getTBSCertificate(child);
+ var bytes = asn1.toDer(tbsCertificate);
+ md.update(bytes.getBytes());
+ }
+
+ if(md !== null) {
+ var scheme;
+
+ switch(child.signatureOid) {
+ case oids.sha1WithRSAEncryption:
+ scheme = undefined; /* use PKCS#1 v1.5 padding scheme */
+ break;
+ case oids['RSASSA-PSS']:
+ var hash, mgf;
+
+ /* initialize mgf */
+ hash = oids[child.signatureParameters.mgf.hash.algorithmOid];
+ if(hash === undefined || forge.md[hash] === undefined) {
+ var error = new Error('Unsupported MGF hash function.');
+ error.oid = child.signatureParameters.mgf.hash.algorithmOid;
+ error.name = hash;
+ throw error;
+ }
+
+ mgf = oids[child.signatureParameters.mgf.algorithmOid];
+ if(mgf === undefined || forge.mgf[mgf] === undefined) {
+ var error = new Error('Unsupported MGF function.');
+ error.oid = child.signatureParameters.mgf.algorithmOid;
+ error.name = mgf;
+ throw error;
+ }
+
+ mgf = forge.mgf[mgf].create(forge.md[hash].create());
+
+ /* initialize hash function */
+ hash = oids[child.signatureParameters.hash.algorithmOid];
+ if(hash === undefined || forge.md[hash] === undefined) {
+ throw {
+ message: 'Unsupported RSASSA-PSS hash function.',
+ oid: child.signatureParameters.hash.algorithmOid,
+ name: hash
+ };
+ }
+
+ scheme = forge.pss.create(forge.md[hash].create(), mgf,
+ child.signatureParameters.saltLength);
+ break;
+ }
+
+ // verify signature on cert using public key
+ rval = cert.publicKey.verify(
+ md.digest().getBytes(), child.signature, scheme);
+ }
+
+ return rval;
+ };
+
+ /**
+ * Returns true if this certificate's issuer matches the passed
+ * certificate's subject. Note that no signature check is performed.
+ *
+ * @param parent the certificate to check.
+ *
+ * @return true if this certificate's issuer matches the passed certificate's
+ * subject.
+ */
+ cert.isIssuer = function(parent) {
+ var rval = false;
+
+ var i = cert.issuer;
+ var s = parent.subject;
+
+ // compare hashes if present
+ if(i.hash && s.hash) {
+ rval = (i.hash === s.hash);
+ } else if(i.attributes.length === s.attributes.length) {
+ // all attributes are the same so issuer matches subject
+ rval = true;
+ var iattr, sattr;
+ for(var n = 0; rval && n < i.attributes.length; ++n) {
+ iattr = i.attributes[n];
+ sattr = s.attributes[n];
+ if(iattr.type !== sattr.type || iattr.value !== sattr.value) {
+ // attribute mismatch
+ rval = false;
+ }
+ }
+ }
+
+ return rval;
+ };
+
+ /**
+ * Returns true if this certificate's subject matches the issuer of the
+ * given certificate). Note that not signature check is performed.
+ *
+ * @param child the certificate to check.
+ *
+ * @return true if this certificate's subject matches the passed
+ * certificate's issuer.
+ */
+ cert.issued = function(child) {
+ return child.isIssuer(cert);
+ };
+
+ /**
+ * Generates the subjectKeyIdentifier for this certificate as byte buffer.
+ *
+ * @return the subjectKeyIdentifier for this certificate as byte buffer.
+ */
+ cert.generateSubjectKeyIdentifier = function() {
+ /* See: 4.2.1.2 section of the the RFC3280, keyIdentifier is either:
+
+ (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the
+ value of the BIT STRING subjectPublicKey (excluding the tag,
+ length, and number of unused bits).
+
+ (2) The keyIdentifier is composed of a four bit type field with
+ the value 0100 followed by the least significant 60 bits of the
+ SHA-1 hash of the value of the BIT STRING subjectPublicKey
+ (excluding the tag, length, and number of unused bit string bits).
+ */
+
+ // skipping the tag, length, and number of unused bits is the same
+ // as just using the RSAPublicKey (for RSA keys, which are the
+ // only ones supported)
+ return pki.getPublicKeyFingerprint(cert.publicKey, {type: 'RSAPublicKey'});
+ };
+
+ /**
+ * Verifies the subjectKeyIdentifier extension value for this certificate
+ * against its public key. If no extension is found, false will be
+ * returned.
+ *
+ * @return true if verified, false if not.
+ */
+ cert.verifySubjectKeyIdentifier = function() {
+ var oid = oids['subjectKeyIdentifier'];
+ for(var i = 0; i < cert.extensions.length; ++i) {
+ var ext = cert.extensions[i];
+ if(ext.id === oid) {
+ var ski = cert.generateSubjectKeyIdentifier().getBytes();
+ return (forge.util.hexToBytes(ext.subjectKeyIdentifier) === ski);
+ }
+ }
+ return false;
+ };
+
+ return cert;
+};
+
+/**
+ * Converts an X.509v3 RSA certificate from an ASN.1 object.
+ *
+ * Note: If the certificate is to be verified then compute hash should
+ * be set to true. There is currently no implementation for converting
+ * a certificate back to ASN.1 so the TBSCertificate part of the ASN.1
+ * object needs to be scanned before the cert object is created.
+ *
+ * @param obj the asn1 representation of an X.509v3 RSA certificate.
+ * @param computeHash true to compute the hash for verification.
+ *
+ * @return the certificate.
+ */
+pki.certificateFromAsn1 = function(obj, computeHash) {
+ // validate certificate and capture data
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(obj, x509CertificateValidator, capture, errors)) {
+ var error = new Error('Cannot read X.509 certificate. ' +
+ 'ASN.1 object is not an X509v3 Certificate.');
+ error.errors = errors;
+ throw error;
+ }
+
+ // ensure signature is not interpreted as an embedded ASN.1 object
+ if(typeof capture.certSignature !== 'string') {
+ var certSignature = '\x00';
+ for(var i = 0; i < capture.certSignature.length; ++i) {
+ certSignature += asn1.toDer(capture.certSignature[i]).getBytes();
+ }
+ capture.certSignature = certSignature;
+ }
+
+ // get oid
+ var oid = asn1.derToOid(capture.publicKeyOid);
+ if(oid !== pki.oids['rsaEncryption']) {
+ throw new Error('Cannot read public key. OID is not RSA.');
+ }
+
+ // create certificate
+ var cert = pki.createCertificate();
+ cert.version = capture.certVersion ?
+ capture.certVersion.charCodeAt(0) : 0;
+ var serial = forge.util.createBuffer(capture.certSerialNumber);
+ cert.serialNumber = serial.toHex();
+ cert.signatureOid = forge.asn1.derToOid(capture.certSignatureOid);
+ cert.signatureParameters = _readSignatureParameters(
+ cert.signatureOid, capture.certSignatureParams, true);
+ cert.siginfo.algorithmOid = forge.asn1.derToOid(capture.certinfoSignatureOid);
+ cert.siginfo.parameters = _readSignatureParameters(cert.siginfo.algorithmOid,
+ capture.certinfoSignatureParams, false);
+ // skip "unused bits" in signature value BITSTRING
+ var signature = forge.util.createBuffer(capture.certSignature);
+ ++signature.read;
+ cert.signature = signature.getBytes();
+
+ var validity = [];
+ if(capture.certValidity1UTCTime !== undefined) {
+ validity.push(asn1.utcTimeToDate(capture.certValidity1UTCTime));
+ }
+ if(capture.certValidity2GeneralizedTime !== undefined) {
+ validity.push(asn1.generalizedTimeToDate(
+ capture.certValidity2GeneralizedTime));
+ }
+ if(capture.certValidity3UTCTime !== undefined) {
+ validity.push(asn1.utcTimeToDate(capture.certValidity3UTCTime));
+ }
+ if(capture.certValidity4GeneralizedTime !== undefined) {
+ validity.push(asn1.generalizedTimeToDate(
+ capture.certValidity4GeneralizedTime));
+ }
+ if(validity.length > 2) {
+ throw new Error('Cannot read notBefore/notAfter validity times; more ' +
+ 'than two times were provided in the certificate.');
+ }
+ if(validity.length < 2) {
+ throw new Error('Cannot read notBefore/notAfter validity times; they ' +
+ 'were not provided as either UTCTime or GeneralizedTime.');
+ }
+ cert.validity.notBefore = validity[0];
+ cert.validity.notAfter = validity[1];
+
+ // keep TBSCertificate to preserve signature when exporting
+ cert.tbsCertificate = capture.tbsCertificate;
+
+ if(computeHash) {
+ // check signature OID for supported signature types
+ cert.md = null;
+ if(cert.signatureOid in oids) {
+ var oid = oids[cert.signatureOid];
+ switch(oid) {
+ case 'sha1WithRSAEncryption':
+ cert.md = forge.md.sha1.create();
+ break;
+ case 'md5WithRSAEncryption':
+ cert.md = forge.md.md5.create();
+ break;
+ case 'sha256WithRSAEncryption':
+ cert.md = forge.md.sha256.create();
+ break;
+ case 'RSASSA-PSS':
+ cert.md = forge.md.sha256.create();
+ break;
+ }
+ }
+ if(cert.md === null) {
+ var error = new Error('Could not compute certificate digest. ' +
+ 'Unknown signature OID.');
+ error.signatureOid = cert.signatureOid;
+ throw error;
+ }
+
+ // produce DER formatted TBSCertificate and digest it
+ var bytes = asn1.toDer(cert.tbsCertificate);
+ cert.md.update(bytes.getBytes());
+ }
+
+ // handle issuer, build issuer message digest
+ var imd = forge.md.sha1.create();
+ cert.issuer.getField = function(sn) {
+ return _getAttribute(cert.issuer, sn);
+ };
+ cert.issuer.addField = function(attr) {
+ _fillMissingFields([attr]);
+ cert.issuer.attributes.push(attr);
+ };
+ cert.issuer.attributes = pki.RDNAttributesAsArray(capture.certIssuer, imd);
+ if(capture.certIssuerUniqueId) {
+ cert.issuer.uniqueId = capture.certIssuerUniqueId;
+ }
+ cert.issuer.hash = imd.digest().toHex();
+
+ // handle subject, build subject message digest
+ var smd = forge.md.sha1.create();
+ cert.subject.getField = function(sn) {
+ return _getAttribute(cert.subject, sn);
+ };
+ cert.subject.addField = function(attr) {
+ _fillMissingFields([attr]);
+ cert.subject.attributes.push(attr);
+ };
+ cert.subject.attributes = pki.RDNAttributesAsArray(capture.certSubject, smd);
+ if(capture.certSubjectUniqueId) {
+ cert.subject.uniqueId = capture.certSubjectUniqueId;
+ }
+ cert.subject.hash = smd.digest().toHex();
+
+ // handle extensions
+ if(capture.certExtensions) {
+ cert.extensions = pki.certificateExtensionsFromAsn1(capture.certExtensions);
+ } else {
+ cert.extensions = [];
+ }
+
+ // convert RSA public key from ASN.1
+ cert.publicKey = pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);
+
+ return cert;
+};
+
+/**
+ * Converts an ASN.1 extensions object (with extension sequences as its
+ * values) into an array of extension objects with types and values.
+ *
+ * Supported extensions:
+ *
+ * id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }
+ * KeyUsage ::= BIT STRING {
+ * digitalSignature (0),
+ * nonRepudiation (1),
+ * keyEncipherment (2),
+ * dataEncipherment (3),
+ * keyAgreement (4),
+ * keyCertSign (5),
+ * cRLSign (6),
+ * encipherOnly (7),
+ * decipherOnly (8)
+ * }
+ *
+ * id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 }
+ * BasicConstraints ::= SEQUENCE {
+ * cA BOOLEAN DEFAULT FALSE,
+ * pathLenConstraint INTEGER (0..MAX) OPTIONAL
+ * }
+ *
+ * subjectAltName EXTENSION ::= {
+ * SYNTAX GeneralNames
+ * IDENTIFIED BY id-ce-subjectAltName
+ * }
+ *
+ * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
+ *
+ * GeneralName ::= CHOICE {
+ * otherName [0] INSTANCE OF OTHER-NAME,
+ * rfc822Name [1] IA5String,
+ * dNSName [2] IA5String,
+ * x400Address [3] ORAddress,
+ * directoryName [4] Name,
+ * ediPartyName [5] EDIPartyName,
+ * uniformResourceIdentifier [6] IA5String,
+ * IPAddress [7] OCTET STRING,
+ * registeredID [8] OBJECT IDENTIFIER
+ * }
+ *
+ * OTHER-NAME ::= TYPE-IDENTIFIER
+ *
+ * EDIPartyName ::= SEQUENCE {
+ * nameAssigner [0] DirectoryString {ub-name} OPTIONAL,
+ * partyName [1] DirectoryString {ub-name}
+ * }
+ *
+ * @param exts the extensions ASN.1 with extension sequences to parse.
+ *
+ * @return the array.
+ */
+pki.certificateExtensionsFromAsn1 = function(exts) {
+ var rval = [];
+ for(var i = 0; i < exts.value.length; ++i) {
+ // get extension sequence
+ var extseq = exts.value[i];
+ for(var ei = 0; ei < extseq.value.length; ++ei) {
+ rval.push(pki.certificateExtensionFromAsn1(extseq.value[ei]));
+ }
+ }
+
+ return rval;
+};
+
+/**
+ * Parses a single certificate extension from ASN.1.
+ *
+ * @param ext the extension in ASN.1 format.
+ *
+ * @return the parsed extension as an object.
+ */
+pki.certificateExtensionFromAsn1 = function(ext) {
+ // an extension has:
+ // [0] extnID OBJECT IDENTIFIER
+ // [1] critical BOOLEAN DEFAULT FALSE
+ // [2] extnValue OCTET STRING
+ var e = {};
+ e.id = asn1.derToOid(ext.value[0].value);
+ e.critical = false;
+ if(ext.value[1].type === asn1.Type.BOOLEAN) {
+ e.critical = (ext.value[1].value.charCodeAt(0) !== 0x00);
+ e.value = ext.value[2].value;
+ } else {
+ e.value = ext.value[1].value;
+ }
+ // if the oid is known, get its name
+ if(e.id in oids) {
+ e.name = oids[e.id];
+
+ // handle key usage
+ if(e.name === 'keyUsage') {
+ // get value as BIT STRING
+ var ev = asn1.fromDer(e.value);
+ var b2 = 0x00;
+ var b3 = 0x00;
+ if(ev.value.length > 1) {
+ // skip first byte, just indicates unused bits which
+ // will be padded with 0s anyway
+ // get bytes with flag bits
+ b2 = ev.value.charCodeAt(1);
+ b3 = ev.value.length > 2 ? ev.value.charCodeAt(2) : 0;
+ }
+ // set flags
+ e.digitalSignature = (b2 & 0x80) === 0x80;
+ e.nonRepudiation = (b2 & 0x40) === 0x40;
+ e.keyEncipherment = (b2 & 0x20) === 0x20;
+ e.dataEncipherment = (b2 & 0x10) === 0x10;
+ e.keyAgreement = (b2 & 0x08) === 0x08;
+ e.keyCertSign = (b2 & 0x04) === 0x04;
+ e.cRLSign = (b2 & 0x02) === 0x02;
+ e.encipherOnly = (b2 & 0x01) === 0x01;
+ e.decipherOnly = (b3 & 0x80) === 0x80;
+ } else if(e.name === 'basicConstraints') {
+ // handle basic constraints
+ // get value as SEQUENCE
+ var ev = asn1.fromDer(e.value);
+ // get cA BOOLEAN flag (defaults to false)
+ if(ev.value.length > 0 && ev.value[0].type === asn1.Type.BOOLEAN) {
+ e.cA = (ev.value[0].value.charCodeAt(0) !== 0x00);
+ } else {
+ e.cA = false;
+ }
+ // get path length constraint
+ var value = null;
+ if(ev.value.length > 0 && ev.value[0].type === asn1.Type.INTEGER) {
+ value = ev.value[0].value;
+ } else if(ev.value.length > 1) {
+ value = ev.value[1].value;
+ }
+ if(value !== null) {
+ e.pathLenConstraint = asn1.derToInteger(value);
+ }
+ } else if(e.name === 'extKeyUsage') {
+ // handle extKeyUsage
+ // value is a SEQUENCE of OIDs
+ var ev = asn1.fromDer(e.value);
+ for(var vi = 0; vi < ev.value.length; ++vi) {
+ var oid = asn1.derToOid(ev.value[vi].value);
+ if(oid in oids) {
+ e[oids[oid]] = true;
+ } else {
+ e[oid] = true;
+ }
+ }
+ } else if(e.name === 'nsCertType') {
+ // handle nsCertType
+ // get value as BIT STRING
+ var ev = asn1.fromDer(e.value);
+ var b2 = 0x00;
+ if(ev.value.length > 1) {
+ // skip first byte, just indicates unused bits which
+ // will be padded with 0s anyway
+ // get bytes with flag bits
+ b2 = ev.value.charCodeAt(1);
+ }
+ // set flags
+ e.client = (b2 & 0x80) === 0x80;
+ e.server = (b2 & 0x40) === 0x40;
+ e.email = (b2 & 0x20) === 0x20;
+ e.objsign = (b2 & 0x10) === 0x10;
+ e.reserved = (b2 & 0x08) === 0x08;
+ e.sslCA = (b2 & 0x04) === 0x04;
+ e.emailCA = (b2 & 0x02) === 0x02;
+ e.objCA = (b2 & 0x01) === 0x01;
+ } else if(
+ e.name === 'subjectAltName' ||
+ e.name === 'issuerAltName') {
+ // handle subjectAltName/issuerAltName
+ e.altNames = [];
+
+ // ev is a SYNTAX SEQUENCE
+ var gn;
+ var ev = asn1.fromDer(e.value);
+ for(var n = 0; n < ev.value.length; ++n) {
+ // get GeneralName
+ gn = ev.value[n];
+
+ var altName = {
+ type: gn.type,
+ value: gn.value
+ };
+ e.altNames.push(altName);
+
+ // Note: Support for types 1,2,6,7,8
+ switch(gn.type) {
+ // rfc822Name
+ case 1:
+ // dNSName
+ case 2:
+ // uniformResourceIdentifier (URI)
+ case 6:
+ break;
+ // IPAddress
+ case 7:
+ // convert to IPv4/IPv6 string representation
+ altName.ip = forge.util.bytesToIP(gn.value);
+ break;
+ // registeredID
+ case 8:
+ altName.oid = asn1.derToOid(gn.value);
+ break;
+ default:
+ // unsupported
+ }
+ }
+ } else if(e.name === 'subjectKeyIdentifier') {
+ // value is an OCTETSTRING w/the hash of the key-type specific
+ // public key structure (eg: RSAPublicKey)
+ var ev = asn1.fromDer(e.value);
+ e.subjectKeyIdentifier = forge.util.bytesToHex(ev.value);
+ }
+ }
+ return e;
+};
+
+/**
+ * Converts a PKCS#10 certification request (CSR) from an ASN.1 object.
+ *
+ * Note: If the certification request is to be verified then compute hash
+ * should be set to true. There is currently no implementation for converting
+ * a certificate back to ASN.1 so the CertificationRequestInfo part of the
+ * ASN.1 object needs to be scanned before the csr object is created.
+ *
+ * @param obj the asn1 representation of a PKCS#10 certification request (CSR).
+ * @param computeHash true to compute the hash for verification.
+ *
+ * @return the certification request (CSR).
+ */
+pki.certificationRequestFromAsn1 = function(obj, computeHash) {
+ // validate certification request and capture data
+ var capture = {};
+ var errors = [];
+ if(!asn1.validate(obj, certificationRequestValidator, capture, errors)) {
+ var error = new Error('Cannot read PKCS#10 certificate request. ' +
+ 'ASN.1 object is not a PKCS#10 CertificationRequest.');
+ error.errors = errors;
+ throw error;
+ }
+
+ // ensure signature is not interpreted as an embedded ASN.1 object
+ if(typeof capture.csrSignature !== 'string') {
+ var csrSignature = '\x00';
+ for(var i = 0; i < capture.csrSignature.length; ++i) {
+ csrSignature += asn1.toDer(capture.csrSignature[i]).getBytes();
+ }
+ capture.csrSignature = csrSignature;
+ }
+
+ // get oid
+ var oid = asn1.derToOid(capture.publicKeyOid);
+ if(oid !== pki.oids.rsaEncryption) {
+ throw new Error('Cannot read public key. OID is not RSA.');
+ }
+
+ // create certification request
+ var csr = pki.createCertificationRequest();
+ csr.version = capture.csrVersion ? capture.csrVersion.charCodeAt(0) : 0;
+ csr.signatureOid = forge.asn1.derToOid(capture.csrSignatureOid);
+ csr.signatureParameters = _readSignatureParameters(
+ csr.signatureOid, capture.csrSignatureParams, true);
+ csr.siginfo.algorithmOid = forge.asn1.derToOid(capture.csrSignatureOid);
+ csr.siginfo.parameters = _readSignatureParameters(
+ csr.siginfo.algorithmOid, capture.csrSignatureParams, false);
+ // skip "unused bits" in signature value BITSTRING
+ var signature = forge.util.createBuffer(capture.csrSignature);
+ ++signature.read;
+ csr.signature = signature.getBytes();
+
+ // keep CertificationRequestInfo to preserve signature when exporting
+ csr.certificationRequestInfo = capture.certificationRequestInfo;
+
+ if(computeHash) {
+ // check signature OID for supported signature types
+ csr.md = null;
+ if(csr.signatureOid in oids) {
+ var oid = oids[csr.signatureOid];
+ switch(oid) {
+ case 'sha1WithRSAEncryption':
+ csr.md = forge.md.sha1.create();
+ break;
+ case 'md5WithRSAEncryption':
+ csr.md = forge.md.md5.create();
+ break;
+ case 'sha256WithRSAEncryption':
+ csr.md = forge.md.sha256.create();
+ break;
+ case 'RSASSA-PSS':
+ csr.md = forge.md.sha256.create();
+ break;
+ }
+ }
+ if(csr.md === null) {
+ var error = new Error('Could not compute certification request digest. ' +
+ 'Unknown signature OID.');
+ error.signatureOid = csr.signatureOid;
+ throw error;
+ }
+
+ // produce DER formatted CertificationRequestInfo and digest it
+ var bytes = asn1.toDer(csr.certificationRequestInfo);
+ csr.md.update(bytes.getBytes());
+ }
+
+ // handle subject, build subject message digest
+ var smd = forge.md.sha1.create();
+ csr.subject.getField = function(sn) {
+ return _getAttribute(csr.subject, sn);
+ };
+ csr.subject.addField = function(attr) {
+ _fillMissingFields([attr]);
+ csr.subject.attributes.push(attr);
+ };
+ csr.subject.attributes = pki.RDNAttributesAsArray(
+ capture.certificationRequestInfoSubject, smd);
+ csr.subject.hash = smd.digest().toHex();
+
+ // convert RSA public key from ASN.1
+ csr.publicKey = pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);
+
+ // convert attributes from ASN.1
+ csr.getAttribute = function(sn) {
+ return _getAttribute(csr, sn);
+ };
+ csr.addAttribute = function(attr) {
+ _fillMissingFields([attr]);
+ csr.attributes.push(attr);
+ };
+ csr.attributes = pki.CRIAttributesAsArray(
+ capture.certificationRequestInfoAttributes || []);
+
+ return csr;
+};
+
+/**
+ * Creates an empty certification request (a CSR or certificate signing
+ * request). Once created, its public key and attributes can be set and then
+ * it can be signed.
+ *
+ * @return the empty certification request.
+ */
+pki.createCertificationRequest = function() {
+ var csr = {};
+ csr.version = 0x00;
+ csr.signatureOid = null;
+ csr.signature = null;
+ csr.siginfo = {};
+ csr.siginfo.algorithmOid = null;
+
+ csr.subject = {};
+ csr.subject.getField = function(sn) {
+ return _getAttribute(csr.subject, sn);
+ };
+ csr.subject.addField = function(attr) {
+ _fillMissingFields([attr]);
+ csr.subject.attributes.push(attr);
+ };
+ csr.subject.attributes = [];
+ csr.subject.hash = null;
+
+ csr.publicKey = null;
+ csr.attributes = [];
+ csr.getAttribute = function(sn) {
+ return _getAttribute(csr, sn);
+ };
+ csr.addAttribute = function(attr) {
+ _fillMissingFields([attr]);
+ csr.attributes.push(attr);
+ };
+ csr.md = null;
+
+ /**
+ * Sets the subject of this certification request.
+ *
+ * @param attrs the array of subject attributes to use.
+ */
+ csr.setSubject = function(attrs) {
+ // set new attributes
+ _fillMissingFields(attrs);
+ csr.subject.attributes = attrs;
+ csr.subject.hash = null;
+ };
+
+ /**
+ * Sets the attributes of this certification request.
+ *
+ * @param attrs the array of attributes to use.
+ */
+ csr.setAttributes = function(attrs) {
+ // set new attributes
+ _fillMissingFields(attrs);
+ csr.attributes = attrs;
+ };
+
+ /**
+ * Signs this certification request using the given private key.
+ *
+ * @param key the private key to sign with.
+ * @param md the message digest object to use (defaults to forge.md.sha1).
+ */
+ csr.sign = function(key, md) {
+ // TODO: get signature OID from private key
+ csr.md = md || forge.md.sha1.create();
+ var algorithmOid = oids[csr.md.algorithm + 'WithRSAEncryption'];
+ if(!algorithmOid) {
+ var error = new Error('Could not compute certification request digest. ' +
+ 'Unknown message digest algorithm OID.');
+ error.algorithm = csr.md.algorithm;
+ throw error;
+ }
+ csr.signatureOid = csr.siginfo.algorithmOid = algorithmOid;
+
+ // get CertificationRequestInfo, convert to DER
+ csr.certificationRequestInfo = pki.getCertificationRequestInfo(csr);
+ var bytes = asn1.toDer(csr.certificationRequestInfo);
+
+ // digest and sign
+ csr.md.update(bytes.getBytes());
+ csr.signature = key.sign(csr.md);
+ };
+
+ /**
+ * Attempts verify the signature on the passed certification request using
+ * its public key.
+ *
+ * A CSR that has been exported to a file in PEM format can be verified using
+ * OpenSSL using this command:
+ *
+ * openssl req -in <the-csr-pem-file> -verify -noout -text
+ *
+ * @return true if verified, false if not.
+ */
+ csr.verify = function() {
+ var rval = false;
+
+ var md = csr.md;
+ if(md === null) {
+ // check signature OID for supported signature types
+ if(csr.signatureOid in oids) {
+ var oid = oids[csr.signatureOid];
+ switch(oid) {
+ case 'sha1WithRSAEncryption':
+ md = forge.md.sha1.create();
+ break;
+ case 'md5WithRSAEncryption':
+ md = forge.md.md5.create();
+ break;
+ case 'sha256WithRSAEncryption':
+ md = forge.md.sha256.create();
+ break;
+ case 'RSASSA-PSS':
+ md = forge.md.sha256.create();
+ break;
+ }
+ }
+ if(md === null) {
+ var error = new Error('Could not compute certification request digest. ' +
+ 'Unknown signature OID.');
+ error.signatureOid = csr.signatureOid;
+ throw error;
+ }
+
+ // produce DER formatted CertificationRequestInfo and digest it
+ var cri = csr.certificationRequestInfo ||
+ pki.getCertificationRequestInfo(csr);
+ var bytes = asn1.toDer(cri);
+ md.update(bytes.getBytes());
+ }
+
+ if(md !== null) {
+ var scheme;
+
+ switch(csr.signatureOid) {
+ case oids.sha1WithRSAEncryption:
+ /* use PKCS#1 v1.5 padding scheme */
+ break;
+ case oids['RSASSA-PSS']:
+ var hash, mgf;
+
+ /* initialize mgf */
+ hash = oids[csr.signatureParameters.mgf.hash.algorithmOid];
+ if(hash === undefined || forge.md[hash] === undefined) {
+ var error = new Error('Unsupported MGF hash function.');
+ error.oid = csr.signatureParameters.mgf.hash.algorithmOid;
+ error.name = hash;
+ throw error;
+ }
+
+ mgf = oids[csr.signatureParameters.mgf.algorithmOid];
+ if(mgf === undefined || forge.mgf[mgf] === undefined) {
+ var error = new Error('Unsupported MGF function.');
+ error.oid = csr.signatureParameters.mgf.algorithmOid;
+ error.name = mgf;
+ throw error;
+ }
+
+ mgf = forge.mgf[mgf].create(forge.md[hash].create());
+
+ /* initialize hash function */
+ hash = oids[csr.signatureParameters.hash.algorithmOid];
+ if(hash === undefined || forge.md[hash] === undefined) {
+ var error = new Error('Unsupported RSASSA-PSS hash function.');
+ error.oid = csr.signatureParameters.hash.algorithmOid;
+ error.name = hash;
+ throw error;
+ }
+
+ scheme = forge.pss.create(forge.md[hash].create(), mgf,
+ csr.signatureParameters.saltLength);
+ break;
+ }
+
+ // verify signature on csr using its public key
+ rval = csr.publicKey.verify(
+ md.digest().getBytes(), csr.signature, scheme);
+ }
+
+ return rval;
+ };
+
+ return csr;
+};
+
+/**
+ * Converts an X.509 subject or issuer to an ASN.1 RDNSequence.
+ *
+ * @param obj the subject or issuer (distinguished name).
+ *
+ * @return the ASN.1 RDNSequence.
+ */
+function _dnToAsn1(obj) {
+ // create an empty RDNSequence
+ var rval = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
+
+ // iterate over attributes
+ var attr, set;
+ var attrs = obj.attributes;
+ for(var i = 0; i < attrs.length; ++i) {
+ attr = attrs[i];
+ var value = attr.value;
+
+ // reuse tag class for attribute value if available
+ var valueTagClass = asn1.Type.PRINTABLESTRING;
+ if('valueTagClass' in attr) {
+ valueTagClass = attr.valueTagClass;
+
+ if(valueTagClass === asn1.Type.UTF8) {
+ value = forge.util.encodeUtf8(value);
+ }
+ // FIXME: handle more encodings
+ }
+
+ // create a RelativeDistinguishedName set
+ // each value in the set is an AttributeTypeAndValue first
+ // containing the type (an OID) and second the value
+ set = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // AttributeType
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(attr.type).getBytes()),
+ // AttributeValue
+ asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)
+ ])
+ ]);
+ rval.value.push(set);
+ }
+
+ return rval;
+}
+
+/**
+ * Gets all printable attributes (typically of an issuer or subject) in a
+ * simplified JSON format for display.
+ *
+ * @param attrs the attributes.
+ *
+ * @return the JSON for display.
+ */
+function _getAttributesAsJson(attrs) {
+ var rval = {};
+ for(var i = 0; i < attrs.length; ++i) {
+ var attr = attrs[i];
+ if(attr.shortName && (
+ attr.valueTagClass === asn1.Type.UTF8 ||
+ attr.valueTagClass === asn1.Type.PRINTABLESTRING ||
+ attr.valueTagClass === asn1.Type.IA5STRING)) {
+ var value = attr.value;
+ if(attr.valueTagClass === asn1.Type.UTF8) {
+ value = forge.util.encodeUtf8(attr.value);
+ }
+ if(!(attr.shortName in rval)) {
+ rval[attr.shortName] = value;
+ } else if(forge.util.isArray(rval[attr.shortName])) {
+ rval[attr.shortName].push(value);
+ } else {
+ rval[attr.shortName] = [rval[attr.shortName], value];
+ }
+ }
+ }
+ return rval;
+}
+
+/**
+ * Fills in missing fields in attributes.
+ *
+ * @param attrs the attributes to fill missing fields in.
+ */
+function _fillMissingFields(attrs) {
+ var attr;
+ for(var i = 0; i < attrs.length; ++i) {
+ attr = attrs[i];
+
+ // populate missing name
+ if(typeof attr.name === 'undefined') {
+ if(attr.type && attr.type in pki.oids) {
+ attr.name = pki.oids[attr.type];
+ } else if(attr.shortName && attr.shortName in _shortNames) {
+ attr.name = pki.oids[_shortNames[attr.shortName]];
+ }
+ }
+
+ // populate missing type (OID)
+ if(typeof attr.type === 'undefined') {
+ if(attr.name && attr.name in pki.oids) {
+ attr.type = pki.oids[attr.name];
+ } else {
+ var error = new Error('Attribute type not specified.');
+ error.attribute = attr;
+ throw error;
+ }
+ }
+
+ // populate missing shortname
+ if(typeof attr.shortName === 'undefined') {
+ if(attr.name && attr.name in _shortNames) {
+ attr.shortName = _shortNames[attr.name];
+ }
+ }
+
+ // convert extensions to value
+ if(attr.type === oids.extensionRequest) {
+ attr.valueConstructed = true;
+ attr.valueTagClass = asn1.Type.SEQUENCE;
+ if(!attr.value && attr.extensions) {
+ attr.value = [];
+ for(var ei = 0; ei < attr.extensions.length; ++ei) {
+ attr.value.push(pki.certificateExtensionToAsn1(
+ _fillMissingExtensionFields(attr.extensions[ei])));
+ }
+ }
+ }
+
+ if(typeof attr.value === 'undefined') {
+ var error = new Error('Attribute value not specified.');
+ error.attribute = attr;
+ throw error;
+ }
+ }
+}
+
+/**
+ * Fills in missing fields in certificate extensions.
+ *
+ * @param e the extension.
+ * @param [options] the options to use.
+ * [cert] the certificate the extensions are for.
+ *
+ * @return the extension.
+ */
+function _fillMissingExtensionFields(e, options) {
+ options = options || {};
+
+ // populate missing name
+ if(typeof e.name === 'undefined') {
+ if(e.id && e.id in pki.oids) {
+ e.name = pki.oids[e.id];
+ }
+ }
+
+ // populate missing id
+ if(typeof e.id === 'undefined') {
+ if(e.name && e.name in pki.oids) {
+ e.id = pki.oids[e.name];
+ } else {
+ var error = new Error('Extension ID not specified.');
+ error.extension = e;
+ throw error;
+ }
+ }
+
+ if(typeof e.value !== 'undefined') {
+ return;
+ }
+
+ // handle missing value:
+
+ // value is a BIT STRING
+ if(e.name === 'keyUsage') {
+ // build flags
+ var unused = 0;
+ var b2 = 0x00;
+ var b3 = 0x00;
+ if(e.digitalSignature) {
+ b2 |= 0x80;
+ unused = 7;
+ }
+ if(e.nonRepudiation) {
+ b2 |= 0x40;
+ unused = 6;
+ }
+ if(e.keyEncipherment) {
+ b2 |= 0x20;
+ unused = 5;
+ }
+ if(e.dataEncipherment) {
+ b2 |= 0x10;
+ unused = 4;
+ }
+ if(e.keyAgreement) {
+ b2 |= 0x08;
+ unused = 3;
+ }
+ if(e.keyCertSign) {
+ b2 |= 0x04;
+ unused = 2;
+ }
+ if(e.cRLSign) {
+ b2 |= 0x02;
+ unused = 1;
+ }
+ if(e.encipherOnly) {
+ b2 |= 0x01;
+ unused = 0;
+ }
+ if(e.decipherOnly) {
+ b3 |= 0x80;
+ unused = 7;
+ }
+
+ // create bit string
+ var value = String.fromCharCode(unused);
+ if(b3 !== 0) {
+ value += String.fromCharCode(b2) + String.fromCharCode(b3);
+ } else if(b2 !== 0) {
+ value += String.fromCharCode(b2);
+ }
+ e.value = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, value);
+ } else if(e.name === 'basicConstraints') {
+ // basicConstraints is a SEQUENCE
+ e.value = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
+ // cA BOOLEAN flag defaults to false
+ if(e.cA) {
+ e.value.value.push(asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,
+ String.fromCharCode(0xFF)));
+ }
+ if('pathLenConstraint' in e) {
+ e.value.value.push(asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(e.pathLenConstraint).getBytes()));
+ }
+ } else if(e.name === 'extKeyUsage') {
+ // extKeyUsage is a SEQUENCE of OIDs
+ e.value = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
+ var seq = e.value.value;
+ for(var key in e) {
+ if(e[key] !== true) {
+ continue;
+ }
+ // key is name in OID map
+ if(key in oids) {
+ seq.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID,
+ false, asn1.oidToDer(oids[key]).getBytes()));
+ } else if(key.indexOf('.') !== -1) {
+ // assume key is an OID
+ seq.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID,
+ false, asn1.oidToDer(key).getBytes()));
+ }
+ }
+ } else if(e.name === 'nsCertType') {
+ // nsCertType is a BIT STRING
+ // build flags
+ var unused = 0;
+ var b2 = 0x00;
+
+ if(e.client) {
+ b2 |= 0x80;
+ unused = 7;
+ }
+ if(e.server) {
+ b2 |= 0x40;
+ unused = 6;
+ }
+ if(e.email) {
+ b2 |= 0x20;
+ unused = 5;
+ }
+ if(e.objsign) {
+ b2 |= 0x10;
+ unused = 4;
+ }
+ if(e.reserved) {
+ b2 |= 0x08;
+ unused = 3;
+ }
+ if(e.sslCA) {
+ b2 |= 0x04;
+ unused = 2;
+ }
+ if(e.emailCA) {
+ b2 |= 0x02;
+ unused = 1;
+ }
+ if(e.objCA) {
+ b2 |= 0x01;
+ unused = 0;
+ }
+
+ // create bit string
+ var value = String.fromCharCode(unused);
+ if(b2 !== 0) {
+ value += String.fromCharCode(b2);
+ }
+ e.value = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, value);
+ } else if(e.name === 'subjectAltName' || e.name === 'issuerAltName') {
+ // SYNTAX SEQUENCE
+ e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
+
+ var altName;
+ for(var n = 0; n < e.altNames.length; ++n) {
+ altName = e.altNames[n];
+ var value = altName.value;
+ // handle IP
+ if(altName.type === 7 && altName.ip) {
+ value = forge.util.bytesFromIP(altName.ip);
+ if(value === null) {
+ var error = new Error(
+ 'Extension "ip" value is not a valid IPv4 or IPv6 address.');
+ error.extension = e;
+ throw error;
+ }
+ } else if(altName.type === 8) {
+ // handle OID
+ if(altName.oid) {
+ value = asn1.oidToDer(asn1.oidToDer(altName.oid));
+ } else {
+ // deprecated ... convert value to OID
+ value = asn1.oidToDer(value);
+ }
+ }
+ e.value.value.push(asn1.create(
+ asn1.Class.CONTEXT_SPECIFIC, altName.type, false,
+ value));
+ }
+ } else if(e.name === 'subjectKeyIdentifier' && options.cert) {
+ var ski = options.cert.generateSubjectKeyIdentifier();
+ e.subjectKeyIdentifier = ski.toHex();
+ // OCTETSTRING w/digest
+ e.value = asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, ski.getBytes());
+ }
+
+ // ensure value has been defined by now
+ if(typeof e.value === 'undefined') {
+ var error = new Error('Extension value not specified.');
+ error.extension = e;
+ throw error;
+ }
+
+ return e;
+}
+
+/**
+ * Convert signature parameters object to ASN.1
+ *
+ * @param {String} oid Signature algorithm OID
+ * @param params The signature parametrs object
+ * @return ASN.1 object representing signature parameters
+ */
+function _signatureParametersToAsn1(oid, params) {
+ switch(oid) {
+ case oids['RSASSA-PSS']:
+ var parts = [];
+
+ if(params.hash.algorithmOid !== undefined) {
+ parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(params.hash.algorithmOid).getBytes()),
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
+ ])
+ ]));
+ }
+
+ if(params.mgf.algorithmOid !== undefined) {
+ parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(params.mgf.algorithmOid).getBytes()),
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(params.mgf.hash.algorithmOid).getBytes()),
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
+ ])
+ ])
+ ]));
+ }
+
+ if(params.saltLength !== undefined) {
+ parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(params.saltLength).getBytes())
+ ]));
+ }
+
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, parts);
+
+ default:
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '');
+ }
+}
+
+/**
+ * Converts a certification request's attributes to an ASN.1 set of
+ * CRIAttributes.
+ *
+ * @param csr certification request.
+ *
+ * @return the ASN.1 set of CRIAttributes.
+ */
+function _CRIAttributesToAsn1(csr) {
+ // create an empty context-specific container
+ var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, []);
+
+ // no attributes, return empty container
+ if(csr.attributes.length === 0) {
+ return rval;
+ }
+
+ // each attribute has a sequence with a type and a set of values
+ var attrs = csr.attributes;
+ for(var i = 0; i < attrs.length; ++i) {
+ var attr = attrs[i];
+ var value = attr.value;
+
+ // reuse tag class for attribute value if available
+ var valueTagClass = asn1.Type.UTF8;
+ if('valueTagClass' in attr) {
+ valueTagClass = attr.valueTagClass;
+ }
+ if(valueTagClass === asn1.Type.UTF8) {
+ value = forge.util.encodeUtf8(value);
+ }
+ var valueConstructed = false;
+ if('valueConstructed' in attr) {
+ valueConstructed = attr.valueConstructed;
+ }
+ // FIXME: handle more encodings
+
+ // create a RelativeDistinguishedName set
+ // each value in the set is an AttributeTypeAndValue first
+ // containing the type (an OID) and second the value
+ var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // AttributeType
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(attr.type).getBytes()),
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
+ // AttributeValue
+ asn1.create(
+ asn1.Class.UNIVERSAL, valueTagClass, valueConstructed, value)
+ ])
+ ]);
+ rval.value.push(seq);
+ }
+
+ return rval;
+}
+
+/**
+ * Gets the ASN.1 TBSCertificate part of an X.509v3 certificate.
+ *
+ * @param cert the certificate.
+ *
+ * @return the asn1 TBSCertificate.
+ */
+pki.getTBSCertificate = function(cert) {
+ // TBSCertificate
+ var tbs = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // version
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
+ // integer
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(cert.version).getBytes())
+ ]),
+ // serialNumber
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ forge.util.hexToBytes(cert.serialNumber)),
+ // signature
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // algorithm
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(cert.siginfo.algorithmOid).getBytes()),
+ // parameters
+ _signatureParametersToAsn1(
+ cert.siginfo.algorithmOid, cert.siginfo.parameters)
+ ]),
+ // issuer
+ _dnToAsn1(cert.issuer),
+ // validity
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // notBefore
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.UTCTIME, false,
+ asn1.dateToUtcTime(cert.validity.notBefore)),
+ // notAfter
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.UTCTIME, false,
+ asn1.dateToUtcTime(cert.validity.notAfter))
+ ]),
+ // subject
+ _dnToAsn1(cert.subject),
+ // SubjectPublicKeyInfo
+ pki.publicKeyToAsn1(cert.publicKey)
+ ]);
+
+ if(cert.issuer.uniqueId) {
+ // issuerUniqueID (optional)
+ tbs.value.push(
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,
+ String.fromCharCode(0x00) +
+ cert.issuer.uniqueId
+ )
+ ])
+ );
+ }
+ if(cert.subject.uniqueId) {
+ // subjectUniqueID (optional)
+ tbs.value.push(
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,
+ String.fromCharCode(0x00) +
+ cert.subject.uniqueId
+ )
+ ])
+ );
+ }
+
+ if(cert.extensions.length > 0) {
+ // extensions (optional)
+ tbs.value.push(pki.certificateExtensionsToAsn1(cert.extensions));
+ }
+
+ return tbs;
+};
+
+/**
+ * Gets the ASN.1 CertificationRequestInfo part of a
+ * PKCS#10 CertificationRequest.
+ *
+ * @param csr the certification request.
+ *
+ * @return the asn1 CertificationRequestInfo.
+ */
+pki.getCertificationRequestInfo = function(csr) {
+ // CertificationRequestInfo
+ var cri = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // version
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
+ asn1.integerToDer(csr.version).getBytes()),
+ // subject
+ _dnToAsn1(csr.subject),
+ // SubjectPublicKeyInfo
+ pki.publicKeyToAsn1(csr.publicKey),
+ // attributes
+ _CRIAttributesToAsn1(csr)
+ ]);
+
+ return cri;
+};
+
+/**
+ * Converts a DistinguishedName (subject or issuer) to an ASN.1 object.
+ *
+ * @param dn the DistinguishedName.
+ *
+ * @return the asn1 representation of a DistinguishedName.
+ */
+pki.distinguishedNameToAsn1 = function(dn) {
+ return _dnToAsn1(dn);
+};
+
+/**
+ * Converts an X.509v3 RSA certificate to an ASN.1 object.
+ *
+ * @param cert the certificate.
+ *
+ * @return the asn1 representation of an X.509v3 RSA certificate.
+ */
+pki.certificateToAsn1 = function(cert) {
+ // prefer cached TBSCertificate over generating one
+ var tbsCertificate = cert.tbsCertificate || pki.getTBSCertificate(cert);
+
+ // Certificate
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // TBSCertificate
+ tbsCertificate,
+ // AlgorithmIdentifier (signature algorithm)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // algorithm
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(cert.signatureOid).getBytes()),
+ // parameters
+ _signatureParametersToAsn1(cert.signatureOid, cert.signatureParameters)
+ ]),
+ // SignatureValue
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,
+ String.fromCharCode(0x00) + cert.signature)
+ ]);
+};
+
+/**
+ * Converts X.509v3 certificate extensions to ASN.1.
+ *
+ * @param exts the extensions to convert.
+ *
+ * @return the extensions in ASN.1 format.
+ */
+pki.certificateExtensionsToAsn1 = function(exts) {
+ // create top-level extension container
+ var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 3, true, []);
+
+ // create extension sequence (stores a sequence for each extension)
+ var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
+ rval.value.push(seq);
+
+ for(var i = 0; i < exts.length; ++i) {
+ seq.value.push(pki.certificateExtensionToAsn1(exts[i]));
+ }
+
+ return rval;
+};
+
+/**
+ * Converts a single certificate extension to ASN.1.
+ *
+ * @param ext the extension to convert.
+ *
+ * @return the extension in ASN.1 format.
+ */
+pki.certificateExtensionToAsn1 = function(ext) {
+ // create a sequence for each extension
+ var extseq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
+
+ // extnID (OID)
+ extseq.value.push(asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(ext.id).getBytes()));
+
+ // critical defaults to false
+ if(ext.critical) {
+ // critical BOOLEAN DEFAULT FALSE
+ extseq.value.push(asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,
+ String.fromCharCode(0xFF)));
+ }
+
+ var value = ext.value;
+ if(typeof ext.value !== 'string') {
+ // value is asn.1
+ value = asn1.toDer(value).getBytes();
+ }
+
+ // extnValue (OCTET STRING)
+ extseq.value.push(asn1.create(
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, value));
+
+ return extseq;
+};
+
+/**
+ * Converts a PKCS#10 certification request to an ASN.1 object.
+ *
+ * @param csr the certification request.
+ *
+ * @return the asn1 representation of a certification request.
+ */
+pki.certificationRequestToAsn1 = function(csr) {
+ // prefer cached CertificationRequestInfo over generating one
+ var cri = csr.certificationRequestInfo ||
+ pki.getCertificationRequestInfo(csr);
+
+ // Certificate
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // CertificationRequestInfo
+ cri,
+ // AlgorithmIdentifier (signature algorithm)
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ // algorithm
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(csr.signatureOid).getBytes()),
+ // parameters
+ _signatureParametersToAsn1(csr.signatureOid, csr.signatureParameters)
+ ]),
+ // signature
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,
+ String.fromCharCode(0x00) + csr.signature)
+ ]);
+};
+
+/**
+ * Creates a CA store.
+ *
+ * @param certs an optional array of certificate objects or PEM-formatted
+ * certificate strings to add to the CA store.
+ *
+ * @return the CA store.
+ */
+pki.createCaStore = function(certs) {
+ // create CA store
+ var caStore = {
+ // stored certificates
+ certs: {}
+ };
+
+ /**
+ * Gets the certificate that issued the passed certificate or its
+ * 'parent'.
+ *
+ * @param cert the certificate to get the parent for.
+ *
+ * @return the parent certificate or null if none was found.
+ */
+ caStore.getIssuer = function(cert) {
+ var rval = getBySubject(cert.issuer);
+
+ // see if there are multiple matches
+ /*if(forge.util.isArray(rval)) {
+ // TODO: resolve multiple matches by checking
+ // authorityKey/subjectKey/issuerUniqueID/other identifiers, etc.
+ // FIXME: or alternatively do authority key mapping
+ // if possible (X.509v1 certs can't work?)
+ throw new Error('Resolving multiple issuer matches not implemented yet.');
+ }*/
+
+ return rval;
+ };
+
+ /**
+ * Adds a trusted certificate to the store.
+ *
+ * @param cert the certificate to add as a trusted certificate (either a
+ * pki.certificate object or a PEM-formatted certificate).
+ */
+ caStore.addCertificate = function(cert) {
+ // convert from pem if necessary
+ if(typeof cert === 'string') {
+ cert = forge.pki.certificateFromPem(cert);
+ }
+
+ // produce subject hash if it doesn't exist
+ if(!cert.subject.hash) {
+ var md = forge.md.sha1.create();
+ cert.subject.attributes = pki.RDNAttributesAsArray(
+ _dnToAsn1(cert.subject), md);
+ cert.subject.hash = md.digest().toHex();
+ }
+
+ if(cert.subject.hash in caStore.certs) {
+ // subject hash already exists, append to array
+ var tmp = caStore.certs[cert.subject.hash];
+ if(!forge.util.isArray(tmp)) {
+ tmp = [tmp];
+ }
+ tmp.push(cert);
+ } else {
+ caStore.certs[cert.subject.hash] = cert;
+ }
+ };
+
+ /**
+ * Checks to see if the given certificate is in the store.
+ *
+ * @param cert the certificate to check.
+ *
+ * @return true if the certificate is in the store, false if not.
+ */
+ caStore.hasCertificate = function(cert) {
+ var match = getBySubject(cert.subject);
+ if(!match) {
+ return false;
+ }
+ if(!forge.util.isArray(match)) {
+ match = [match];
+ }
+ // compare DER-encoding of certificates
+ var der1 = asn1.toDer(pki.certificateToAsn1(cert)).getBytes();
+ for(var i = 0; i < match.length; ++i) {
+ var der2 = asn1.toDer(pki.certificateToAsn1(match[i])).getBytes();
+ if(der1 === der2) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ function getBySubject(subject) {
+ // produce subject hash if it doesn't exist
+ if(!subject.hash) {
+ var md = forge.md.sha1.create();
+ subject.attributes = pki.RDNAttributesAsArray(_dnToAsn1(subject), md);
+ subject.hash = md.digest().toHex();
+ }
+ return caStore.certs[subject.hash] || null;
+ }
+
+ // auto-add passed in certs
+ if(certs) {
+ // parse PEM-formatted certificates as necessary
+ for(var i = 0; i < certs.length; ++i) {
+ var cert = certs[i];
+ caStore.addCertificate(cert);
+ }
+ }
+
+ return caStore;
+};
+
+/**
+ * Certificate verification errors, based on TLS.
+ */
+pki.certificateError = {
+ bad_certificate: 'forge.pki.BadCertificate',
+ unsupported_certificate: 'forge.pki.UnsupportedCertificate',
+ certificate_revoked: 'forge.pki.CertificateRevoked',
+ certificate_expired: 'forge.pki.CertificateExpired',
+ certificate_unknown: 'forge.pki.CertificateUnknown',
+ unknown_ca: 'forge.pki.UnknownCertificateAuthority'
+};
+
+/**
+ * Verifies a certificate chain against the given Certificate Authority store
+ * with an optional custom verify callback.
+ *
+ * @param caStore a certificate store to verify against.
+ * @param chain the certificate chain to verify, with the root or highest
+ * authority at the end (an array of certificates).
+ * @param verify called for every certificate in the chain.
+ *
+ * The verify callback has the following signature:
+ *
+ * verified - Set to true if certificate was verified, otherwise the
+ * pki.certificateError for why the certificate failed.
+ * depth - The current index in the chain, where 0 is the end point's cert.
+ * certs - The certificate chain, *NOTE* an empty chain indicates an anonymous
+ * end point.
+ *
+ * The function returns true on success and on failure either the appropriate
+ * pki.certificateError or an object with 'error' set to the appropriate
+ * pki.certificateError and 'message' set to a custom error message.
+ *
+ * @return true if successful, error thrown if not.
+ */
+pki.verifyCertificateChain = function(caStore, chain, verify) {
+ /* From: RFC3280 - Internet X.509 Public Key Infrastructure Certificate
+ Section 6: Certification Path Validation
+ See inline parentheticals related to this particular implementation.
+
+ The primary goal of path validation is to verify the binding between
+ a subject distinguished name or a subject alternative name and subject
+ public key, as represented in the end entity certificate, based on the
+ public key of the trust anchor. This requires obtaining a sequence of
+ certificates that support that binding. That sequence should be provided
+ in the passed 'chain'. The trust anchor should be in the given CA
+ store. The 'end entity' certificate is the certificate provided by the
+ end point (typically a server) and is the first in the chain.
+
+ To meet this goal, the path validation process verifies, among other
+ things, that a prospective certification path (a sequence of n
+ certificates or a 'chain') satisfies the following conditions:
+
+ (a) for all x in {1, ..., n-1}, the subject of certificate x is
+ the issuer of certificate x+1;
+
+ (b) certificate 1 is issued by the trust anchor;
+
+ (c) certificate n is the certificate to be validated; and
+
+ (d) for all x in {1, ..., n}, the certificate was valid at the
+ time in question.
+
+ Note that here 'n' is index 0 in the chain and 1 is the last certificate
+ in the chain and it must be signed by a certificate in the connection's
+ CA store.
+
+ The path validation process also determines the set of certificate
+ policies that are valid for this path, based on the certificate policies
+ extension, policy mapping extension, policy constraints extension, and
+ inhibit any-policy extension.
+
+ Note: Policy mapping extension not supported (Not Required).
+
+ Note: If the certificate has an unsupported critical extension, then it
+ must be rejected.
+
+ Note: A certificate is self-issued if the DNs that appear in the subject
+ and issuer fields are identical and are not empty.
+
+ The path validation algorithm assumes the following seven inputs are
+
<TRUNCATED>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[09/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha512.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha512.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha512.js
new file mode 100644
index 0000000..12a9d94
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/sha512.js
@@ -0,0 +1,590 @@
+/**
+ * Secure Hash Algorithm with a 1024-bit block size implementation.
+ *
+ * This includes: SHA-512, SHA-384, SHA-512/224, and SHA-512/256. For
+ * SHA-256 (block size 512 bits), see sha256.js.
+ *
+ * See FIPS 180-4 for details.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2014 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+var sha512 = forge.sha512 = forge.sha512 || {};
+forge.md = forge.md || {};
+forge.md.algorithms = forge.md.algorithms || {};
+
+// SHA-512
+forge.md.sha512 = forge.md.algorithms.sha512 = sha512;
+
+// SHA-384
+var sha384 = forge.sha384 = forge.sha512.sha384 = forge.sha512.sha384 || {};
+sha384.create = function() {
+ return sha512.create('SHA-384');
+};
+forge.md.sha384 = forge.md.algorithms.sha384 = sha384;
+
+// SHA-512/256
+forge.sha512.sha256 = forge.sha512.sha256 || {
+ create: function() {
+ return sha512.create('SHA-512/256');
+ }
+};
+forge.md['sha512/256'] = forge.md.algorithms['sha512/256'] =
+ forge.sha512.sha256;
+
+// SHA-512/224
+forge.sha512.sha224 = forge.sha512.sha224 || {
+ create: function() {
+ return sha512.create('SHA-512/224');
+ }
+};
+forge.md['sha512/224'] = forge.md.algorithms['sha512/224'] =
+ forge.sha512.sha224;
+
+/**
+ * Creates a SHA-2 message digest object.
+ *
+ * @param algorithm the algorithm to use (SHA-512, SHA-384, SHA-512/224,
+ * SHA-512/256).
+ *
+ * @return a message digest object.
+ */
+sha512.create = function(algorithm) {
+ // do initialization as necessary
+ if(!_initialized) {
+ _init();
+ }
+
+ if(typeof algorithm === 'undefined') {
+ algorithm = 'SHA-512';
+ }
+
+ if(!(algorithm in _states)) {
+ throw new Error('Invalid SHA-512 algorithm: ' + algorithm);
+ }
+
+ // SHA-512 state contains eight 64-bit integers (each as two 32-bit ints)
+ var _state = _states[algorithm];
+ var _h = null;
+
+ // input buffer
+ var _input = forge.util.createBuffer();
+
+ // used for 64-bit word storage
+ var _w = new Array(80);
+ for(var wi = 0; wi < 80; ++wi) {
+ _w[wi] = new Array(2);
+ }
+
+ // message digest object
+ var md = {
+ // SHA-512 => sha512
+ algorithm: algorithm.replace('-', '').toLowerCase(),
+ blockLength: 128,
+ digestLength: 64,
+ // 56-bit length of message so far (does not including padding)
+ messageLength: 0,
+ // true 128-bit message length as four 32-bit ints
+ messageLength128: [0, 0, 0, 0]
+ };
+
+ /**
+ * Starts the digest.
+ *
+ * @return this digest object.
+ */
+ md.start = function() {
+ md.messageLength = 0;
+ md.messageLength128 = [0, 0, 0, 0];
+ _input = forge.util.createBuffer();
+ _h = new Array(_state.length);
+ for(var i = 0; i < _state.length; ++i) {
+ _h[i] = _state[i].slice(0);
+ }
+ return md;
+ };
+ // start digest automatically for first time
+ md.start();
+
+ /**
+ * Updates the digest with the given message input. The given input can
+ * treated as raw input (no encoding will be applied) or an encoding of
+ * 'utf8' maybe given to encode the input using UTF-8.
+ *
+ * @param msg the message input to update with.
+ * @param encoding the encoding to use (default: 'raw', other: 'utf8').
+ *
+ * @return this digest object.
+ */
+ md.update = function(msg, encoding) {
+ if(encoding === 'utf8') {
+ msg = forge.util.encodeUtf8(msg);
+ }
+
+ // update message length
+ md.messageLength += msg.length;
+ var len = msg.length;
+ len = [(len / 0x100000000) >>> 0, len >>> 0];
+ for(var i = 3; i >= 0; --i) {
+ md.messageLength128[i] += len[1];
+ len[1] = len[0] + ((md.messageLength128[i] / 0x100000000) >>> 0);
+ md.messageLength128[i] = md.messageLength128[i] >>> 0;
+ len[0] = ((len[1] / 0x100000000) >>> 0);
+ }
+
+ // add bytes to input buffer
+ _input.putBytes(msg);
+
+ // process bytes
+ _update(_h, _w, _input);
+
+ // compact input buffer every 2K or if empty
+ if(_input.read > 2048 || _input.length() === 0) {
+ _input.compact();
+ }
+
+ return md;
+ };
+
+ /**
+ * Produces the digest.
+ *
+ * @return a byte buffer containing the digest value.
+ */
+ md.digest = function() {
+ /* Note: Here we copy the remaining bytes in the input buffer and
+ add the appropriate SHA-512 padding. Then we do the final update
+ on a copy of the state so that if the user wants to get
+ intermediate digests they can do so. */
+
+ /* Determine the number of bytes that must be added to the message
+ to ensure its length is congruent to 896 mod 1024. In other words,
+ the data to be digested must be a multiple of 1024 bits (or 128 bytes).
+ This data includes the message, some padding, and the length of the
+ message. Since the length of the message will be encoded as 16 bytes (128
+ bits), that means that the last segment of the data must have 112 bytes
+ (896 bits) of message and padding. Therefore, the length of the message
+ plus the padding must be congruent to 896 mod 1024 because
+ 1024 - 128 = 896.
+
+ In order to fill up the message length it must be filled with
+ padding that begins with 1 bit followed by all 0 bits. Padding
+ must *always* be present, so if the message length is already
+ congruent to 896 mod 1024, then 1024 padding bits must be added. */
+
+ // 1024 bits == 128 bytes, 896 bits == 112 bytes, 128 bits = 16 bytes
+ // _padding starts with 1 byte with first bit is set in it which
+ // is byte value 128, then there may be up to 127 other pad bytes
+ var padBytes = forge.util.createBuffer();
+ padBytes.putBytes(_input.bytes());
+ // 128 - (remaining msg + 16 bytes msg length) mod 128
+ padBytes.putBytes(
+ _padding.substr(0, 128 - ((md.messageLength128[3] + 16) & 0x7F)));
+
+ /* Now append length of the message. The length is appended in bits
+ as a 128-bit number in big-endian order. Since we store the length in
+ bytes, we must multiply the 128-bit length by 8 (or left shift by 3). */
+ var bitLength = [];
+ for(var i = 0; i < 3; ++i) {
+ bitLength[i] = ((md.messageLength128[i] << 3) |
+ (md.messageLength128[i - 1] >>> 28));
+ }
+ // shift the last integer normally
+ bitLength[3] = md.messageLength128[3] << 3;
+ padBytes.putInt32(bitLength[0]);
+ padBytes.putInt32(bitLength[1]);
+ padBytes.putInt32(bitLength[2]);
+ padBytes.putInt32(bitLength[3]);
+ var h = new Array(_h.length);
+ for(var i = 0; i < _h.length; ++i) {
+ h[i] = _h[i].slice(0);
+ }
+ _update(h, _w, padBytes);
+ var rval = forge.util.createBuffer();
+ var hlen;
+ if(algorithm === 'SHA-512') {
+ hlen = h.length;
+ } else if(algorithm === 'SHA-384') {
+ hlen = h.length - 2;
+ } else {
+ hlen = h.length - 4;
+ }
+ for(var i = 0; i < hlen; ++i) {
+ rval.putInt32(h[i][0]);
+ if(i !== hlen - 1 || algorithm !== 'SHA-512/224') {
+ rval.putInt32(h[i][1]);
+ }
+ }
+ return rval;
+ };
+
+ return md;
+};
+
+// sha-512 padding bytes not initialized yet
+var _padding = null;
+var _initialized = false;
+
+// table of constants
+var _k = null;
+
+// initial hash states
+var _states = null;
+
+/**
+ * Initializes the constant tables.
+ */
+function _init() {
+ // create padding
+ _padding = String.fromCharCode(128);
+ _padding += forge.util.fillString(String.fromCharCode(0x00), 128);
+
+ // create K table for SHA-512
+ _k = [
+ [0x428a2f98, 0xd728ae22], [0x71374491, 0x23ef65cd],
+ [0xb5c0fbcf, 0xec4d3b2f], [0xe9b5dba5, 0x8189dbbc],
+ [0x3956c25b, 0xf348b538], [0x59f111f1, 0xb605d019],
+ [0x923f82a4, 0xaf194f9b], [0xab1c5ed5, 0xda6d8118],
+ [0xd807aa98, 0xa3030242], [0x12835b01, 0x45706fbe],
+ [0x243185be, 0x4ee4b28c], [0x550c7dc3, 0xd5ffb4e2],
+ [0x72be5d74, 0xf27b896f], [0x80deb1fe, 0x3b1696b1],
+ [0x9bdc06a7, 0x25c71235], [0xc19bf174, 0xcf692694],
+ [0xe49b69c1, 0x9ef14ad2], [0xefbe4786, 0x384f25e3],
+ [0x0fc19dc6, 0x8b8cd5b5], [0x240ca1cc, 0x77ac9c65],
+ [0x2de92c6f, 0x592b0275], [0x4a7484aa, 0x6ea6e483],
+ [0x5cb0a9dc, 0xbd41fbd4], [0x76f988da, 0x831153b5],
+ [0x983e5152, 0xee66dfab], [0xa831c66d, 0x2db43210],
+ [0xb00327c8, 0x98fb213f], [0xbf597fc7, 0xbeef0ee4],
+ [0xc6e00bf3, 0x3da88fc2], [0xd5a79147, 0x930aa725],
+ [0x06ca6351, 0xe003826f], [0x14292967, 0x0a0e6e70],
+ [0x27b70a85, 0x46d22ffc], [0x2e1b2138, 0x5c26c926],
+ [0x4d2c6dfc, 0x5ac42aed], [0x53380d13, 0x9d95b3df],
+ [0x650a7354, 0x8baf63de], [0x766a0abb, 0x3c77b2a8],
+ [0x81c2c92e, 0x47edaee6], [0x92722c85, 0x1482353b],
+ [0xa2bfe8a1, 0x4cf10364], [0xa81a664b, 0xbc423001],
+ [0xc24b8b70, 0xd0f89791], [0xc76c51a3, 0x0654be30],
+ [0xd192e819, 0xd6ef5218], [0xd6990624, 0x5565a910],
+ [0xf40e3585, 0x5771202a], [0x106aa070, 0x32bbd1b8],
+ [0x19a4c116, 0xb8d2d0c8], [0x1e376c08, 0x5141ab53],
+ [0x2748774c, 0xdf8eeb99], [0x34b0bcb5, 0xe19b48a8],
+ [0x391c0cb3, 0xc5c95a63], [0x4ed8aa4a, 0xe3418acb],
+ [0x5b9cca4f, 0x7763e373], [0x682e6ff3, 0xd6b2b8a3],
+ [0x748f82ee, 0x5defb2fc], [0x78a5636f, 0x43172f60],
+ [0x84c87814, 0xa1f0ab72], [0x8cc70208, 0x1a6439ec],
+ [0x90befffa, 0x23631e28], [0xa4506ceb, 0xde82bde9],
+ [0xbef9a3f7, 0xb2c67915], [0xc67178f2, 0xe372532b],
+ [0xca273ece, 0xea26619c], [0xd186b8c7, 0x21c0c207],
+ [0xeada7dd6, 0xcde0eb1e], [0xf57d4f7f, 0xee6ed178],
+ [0x06f067aa, 0x72176fba], [0x0a637dc5, 0xa2c898a6],
+ [0x113f9804, 0xbef90dae], [0x1b710b35, 0x131c471b],
+ [0x28db77f5, 0x23047d84], [0x32caab7b, 0x40c72493],
+ [0x3c9ebe0a, 0x15c9bebc], [0x431d67c4, 0x9c100d4c],
+ [0x4cc5d4be, 0xcb3e42b6], [0x597f299c, 0xfc657e2a],
+ [0x5fcb6fab, 0x3ad6faec], [0x6c44198c, 0x4a475817]
+ ];
+
+ // initial hash states
+ _states = {};
+ _states['SHA-512'] = [
+ [0x6a09e667, 0xf3bcc908],
+ [0xbb67ae85, 0x84caa73b],
+ [0x3c6ef372, 0xfe94f82b],
+ [0xa54ff53a, 0x5f1d36f1],
+ [0x510e527f, 0xade682d1],
+ [0x9b05688c, 0x2b3e6c1f],
+ [0x1f83d9ab, 0xfb41bd6b],
+ [0x5be0cd19, 0x137e2179]
+ ];
+ _states['SHA-384'] = [
+ [0xcbbb9d5d, 0xc1059ed8],
+ [0x629a292a, 0x367cd507],
+ [0x9159015a, 0x3070dd17],
+ [0x152fecd8, 0xf70e5939],
+ [0x67332667, 0xffc00b31],
+ [0x8eb44a87, 0x68581511],
+ [0xdb0c2e0d, 0x64f98fa7],
+ [0x47b5481d, 0xbefa4fa4]
+ ];
+ _states['SHA-512/256'] = [
+ [0x22312194, 0xFC2BF72C],
+ [0x9F555FA3, 0xC84C64C2],
+ [0x2393B86B, 0x6F53B151],
+ [0x96387719, 0x5940EABD],
+ [0x96283EE2, 0xA88EFFE3],
+ [0xBE5E1E25, 0x53863992],
+ [0x2B0199FC, 0x2C85B8AA],
+ [0x0EB72DDC, 0x81C52CA2]
+ ];
+ _states['SHA-512/224'] = [
+ [0x8C3D37C8, 0x19544DA2],
+ [0x73E19966, 0x89DCD4D6],
+ [0x1DFAB7AE, 0x32FF9C82],
+ [0x679DD514, 0x582F9FCF],
+ [0x0F6D2B69, 0x7BD44DA8],
+ [0x77E36F73, 0x04C48942],
+ [0x3F9D85A8, 0x6A1D36C8],
+ [0x1112E6AD, 0x91D692A1]
+ ];
+
+ // now initialized
+ _initialized = true;
+}
+
+/**
+ * Updates a SHA-512 state with the given byte buffer.
+ *
+ * @param s the SHA-512 state to update.
+ * @param w the array to use to store words.
+ * @param bytes the byte buffer to update with.
+ */
+function _update(s, w, bytes) {
+ // consume 512 bit (128 byte) chunks
+ var t1_hi, t1_lo;
+ var t2_hi, t2_lo;
+ var s0_hi, s0_lo;
+ var s1_hi, s1_lo;
+ var ch_hi, ch_lo;
+ var maj_hi, maj_lo;
+ var a_hi, a_lo;
+ var b_hi, b_lo;
+ var c_hi, c_lo;
+ var d_hi, d_lo;
+ var e_hi, e_lo;
+ var f_hi, f_lo;
+ var g_hi, g_lo;
+ var h_hi, h_lo;
+ var i, hi, lo, w2, w7, w15, w16;
+ var len = bytes.length();
+ while(len >= 128) {
+ // the w array will be populated with sixteen 64-bit big-endian words
+ // and then extended into 64 64-bit words according to SHA-512
+ for(i = 0; i < 16; ++i) {
+ w[i][0] = bytes.getInt32() >>> 0;
+ w[i][1] = bytes.getInt32() >>> 0;
+ }
+ for(; i < 80; ++i) {
+ // for word 2 words ago: ROTR 19(x) ^ ROTR 61(x) ^ SHR 6(x)
+ w2 = w[i - 2];
+ hi = w2[0];
+ lo = w2[1];
+
+ // high bits
+ t1_hi = (
+ ((hi >>> 19) | (lo << 13)) ^ // ROTR 19
+ ((lo >>> 29) | (hi << 3)) ^ // ROTR 61/(swap + ROTR 29)
+ (hi >>> 6)) >>> 0; // SHR 6
+ // low bits
+ t1_lo = (
+ ((hi << 13) | (lo >>> 19)) ^ // ROTR 19
+ ((lo << 3) | (hi >>> 29)) ^ // ROTR 61/(swap + ROTR 29)
+ ((hi << 26) | (lo >>> 6))) >>> 0; // SHR 6
+
+ // for word 15 words ago: ROTR 1(x) ^ ROTR 8(x) ^ SHR 7(x)
+ w15 = w[i - 15];
+ hi = w15[0];
+ lo = w15[1];
+
+ // high bits
+ t2_hi = (
+ ((hi >>> 1) | (lo << 31)) ^ // ROTR 1
+ ((hi >>> 8) | (lo << 24)) ^ // ROTR 8
+ (hi >>> 7)) >>> 0; // SHR 7
+ // low bits
+ t2_lo = (
+ ((hi << 31) | (lo >>> 1)) ^ // ROTR 1
+ ((hi << 24) | (lo >>> 8)) ^ // ROTR 8
+ ((hi << 25) | (lo >>> 7))) >>> 0; // SHR 7
+
+ // sum(t1, word 7 ago, t2, word 16 ago) modulo 2^64 (carry lo overflow)
+ w7 = w[i - 7];
+ w16 = w[i - 16];
+ lo = (t1_lo + w7[1] + t2_lo + w16[1]);
+ w[i][0] = (t1_hi + w7[0] + t2_hi + w16[0] +
+ ((lo / 0x100000000) >>> 0)) >>> 0;
+ w[i][1] = lo >>> 0;
+ }
+
+ // initialize hash value for this chunk
+ a_hi = s[0][0];
+ a_lo = s[0][1];
+ b_hi = s[1][0];
+ b_lo = s[1][1];
+ c_hi = s[2][0];
+ c_lo = s[2][1];
+ d_hi = s[3][0];
+ d_lo = s[3][1];
+ e_hi = s[4][0];
+ e_lo = s[4][1];
+ f_hi = s[5][0];
+ f_lo = s[5][1];
+ g_hi = s[6][0];
+ g_lo = s[6][1];
+ h_hi = s[7][0];
+ h_lo = s[7][1];
+
+ // round function
+ for(i = 0; i < 80; ++i) {
+ // Sum1(e) = ROTR 14(e) ^ ROTR 18(e) ^ ROTR 41(e)
+ s1_hi = (
+ ((e_hi >>> 14) | (e_lo << 18)) ^ // ROTR 14
+ ((e_hi >>> 18) | (e_lo << 14)) ^ // ROTR 18
+ ((e_lo >>> 9) | (e_hi << 23))) >>> 0; // ROTR 41/(swap + ROTR 9)
+ s1_lo = (
+ ((e_hi << 18) | (e_lo >>> 14)) ^ // ROTR 14
+ ((e_hi << 14) | (e_lo >>> 18)) ^ // ROTR 18
+ ((e_lo << 23) | (e_hi >>> 9))) >>> 0; // ROTR 41/(swap + ROTR 9)
+
+ // Ch(e, f, g) (optimized the same way as SHA-1)
+ ch_hi = (g_hi ^ (e_hi & (f_hi ^ g_hi))) >>> 0;
+ ch_lo = (g_lo ^ (e_lo & (f_lo ^ g_lo))) >>> 0;
+
+ // Sum0(a) = ROTR 28(a) ^ ROTR 34(a) ^ ROTR 39(a)
+ s0_hi = (
+ ((a_hi >>> 28) | (a_lo << 4)) ^ // ROTR 28
+ ((a_lo >>> 2) | (a_hi << 30)) ^ // ROTR 34/(swap + ROTR 2)
+ ((a_lo >>> 7) | (a_hi << 25))) >>> 0; // ROTR 39/(swap + ROTR 7)
+ s0_lo = (
+ ((a_hi << 4) | (a_lo >>> 28)) ^ // ROTR 28
+ ((a_lo << 30) | (a_hi >>> 2)) ^ // ROTR 34/(swap + ROTR 2)
+ ((a_lo << 25) | (a_hi >>> 7))) >>> 0; // ROTR 39/(swap + ROTR 7)
+
+ // Maj(a, b, c) (optimized the same way as SHA-1)
+ maj_hi = ((a_hi & b_hi) | (c_hi & (a_hi ^ b_hi))) >>> 0;
+ maj_lo = ((a_lo & b_lo) | (c_lo & (a_lo ^ b_lo))) >>> 0;
+
+ // main algorithm
+ // t1 = (h + s1 + ch + _k[i] + _w[i]) modulo 2^64 (carry lo overflow)
+ lo = (h_lo + s1_lo + ch_lo + _k[i][1] + w[i][1]);
+ t1_hi = (h_hi + s1_hi + ch_hi + _k[i][0] + w[i][0] +
+ ((lo / 0x100000000) >>> 0)) >>> 0;
+ t1_lo = lo >>> 0;
+
+ // t2 = s0 + maj modulo 2^64 (carry lo overflow)
+ lo = s0_lo + maj_lo;
+ t2_hi = (s0_hi + maj_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ t2_lo = lo >>> 0;
+
+ h_hi = g_hi;
+ h_lo = g_lo;
+
+ g_hi = f_hi;
+ g_lo = f_lo;
+
+ f_hi = e_hi;
+ f_lo = e_lo;
+
+ // e = (d + t1) modulo 2^64 (carry lo overflow)
+ lo = d_lo + t1_lo;
+ e_hi = (d_hi + t1_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ e_lo = lo >>> 0;
+
+ d_hi = c_hi;
+ d_lo = c_lo;
+
+ c_hi = b_hi;
+ c_lo = b_lo;
+
+ b_hi = a_hi;
+ b_lo = a_lo;
+
+ // a = (t1 + t2) modulo 2^64 (carry lo overflow)
+ lo = t1_lo + t2_lo;
+ a_hi = (t1_hi + t2_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ a_lo = lo >>> 0;
+ }
+
+ // update hash state (additional modulo 2^64)
+ lo = s[0][1] + a_lo;
+ s[0][0] = (s[0][0] + a_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ s[0][1] = lo >>> 0;
+
+ lo = s[1][1] + b_lo;
+ s[1][0] = (s[1][0] + b_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ s[1][1] = lo >>> 0;
+
+ lo = s[2][1] + c_lo;
+ s[2][0] = (s[2][0] + c_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ s[2][1] = lo >>> 0;
+
+ lo = s[3][1] + d_lo;
+ s[3][0] = (s[3][0] + d_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ s[3][1] = lo >>> 0;
+
+ lo = s[4][1] + e_lo;
+ s[4][0] = (s[4][0] + e_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ s[4][1] = lo >>> 0;
+
+ lo = s[5][1] + f_lo;
+ s[5][0] = (s[5][0] + f_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ s[5][1] = lo >>> 0;
+
+ lo = s[6][1] + g_lo;
+ s[6][0] = (s[6][0] + g_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ s[6][1] = lo >>> 0;
+
+ lo = s[7][1] + h_lo;
+ s[7][0] = (s[7][0] + h_hi + ((lo / 0x100000000) >>> 0)) >>> 0;
+ s[7][1] = lo >>> 0;
+
+ len -= 128;
+ }
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'sha512';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/socket.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/socket.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/socket.js
new file mode 100644
index 0000000..e50e1aa
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/socket.js
@@ -0,0 +1,342 @@
+/**
+ * Socket implementation that uses flash SocketPool class as a backend.
+ *
+ * @author Dave Longley
+ *
+ * Copyright (c) 2010-2013 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// define net namespace
+var net = forge.net = forge.net || {};
+
+// map of flash ID to socket pool
+net.socketPools = {};
+
+/**
+ * Creates a flash socket pool.
+ *
+ * @param options:
+ * flashId: the dom ID for the flash object element.
+ * policyPort: the default policy port for sockets, 0 to use the
+ * flash default.
+ * policyUrl: the default policy file URL for sockets (if provided
+ * used instead of a policy port).
+ * msie: true if the browser is msie, false if not.
+ *
+ * @return the created socket pool.
+ */
+net.createSocketPool = function(options) {
+ // set default
+ options.msie = options.msie || false;
+
+ // initialize the flash interface
+ var spId = options.flashId;
+ var api = document.getElementById(spId);
+ api.init({marshallExceptions: !options.msie});
+
+ // create socket pool entry
+ var sp = {
+ // ID of the socket pool
+ id: spId,
+ // flash interface
+ flashApi: api,
+ // map of socket ID to sockets
+ sockets: {},
+ // default policy port
+ policyPort: options.policyPort || 0,
+ // default policy URL
+ policyUrl: options.policyUrl || null
+ };
+ net.socketPools[spId] = sp;
+
+ // create event handler, subscribe to flash events
+ if(options.msie === true) {
+ sp.handler = function(e) {
+ if(e.id in sp.sockets) {
+ // get handler function
+ var f;
+ switch(e.type) {
+ case 'connect':
+ f = 'connected';
+ break;
+ case 'close':
+ f = 'closed';
+ break;
+ case 'socketData':
+ f = 'data';
+ break;
+ default:
+ f = 'error';
+ break;
+ }
+ /* IE calls javascript on the thread of the external object
+ that triggered the event (in this case flash) ... which will
+ either run concurrently with other javascript or pre-empt any
+ running javascript in the middle of its execution (BAD!) ...
+ calling setTimeout() will schedule the javascript to run on
+ the javascript thread and solve this EVIL problem. */
+ setTimeout(function(){sp.sockets[e.id][f](e);}, 0);
+ }
+ };
+ } else {
+ sp.handler = function(e) {
+ if(e.id in sp.sockets) {
+ // get handler function
+ var f;
+ switch(e.type) {
+ case 'connect':
+ f = 'connected';
+ break;
+ case 'close':
+ f = 'closed';
+ break;
+ case 'socketData':
+ f = 'data';
+ break;
+ default:
+ f = 'error';
+ break;
+ }
+ sp.sockets[e.id][f](e);
+ }
+ };
+ }
+ var handler = 'forge.net.socketPools[\'' + spId + '\'].handler';
+ api.subscribe('connect', handler);
+ api.subscribe('close', handler);
+ api.subscribe('socketData', handler);
+ api.subscribe('ioError', handler);
+ api.subscribe('securityError', handler);
+
+ /**
+ * Destroys a socket pool. The socket pool still needs to be cleaned
+ * up via net.cleanup().
+ */
+ sp.destroy = function() {
+ delete net.socketPools[options.flashId];
+ for(var id in sp.sockets) {
+ sp.sockets[id].destroy();
+ }
+ sp.sockets = {};
+ api.cleanup();
+ };
+
+ /**
+ * Creates a new socket.
+ *
+ * @param options:
+ * connected: function(event) called when the socket connects.
+ * closed: function(event) called when the socket closes.
+ * data: function(event) called when socket data has arrived,
+ * it can be read from the socket using receive().
+ * error: function(event) called when a socket error occurs.
+ */
+ sp.createSocket = function(options) {
+ // default to empty options
+ options = options || {};
+
+ // create flash socket
+ var id = api.create();
+
+ // create javascript socket wrapper
+ var socket = {
+ id: id,
+ // set handlers
+ connected: options.connected || function(e){},
+ closed: options.closed || function(e){},
+ data: options.data || function(e){},
+ error: options.error || function(e){}
+ };
+
+ /**
+ * Destroys this socket.
+ */
+ socket.destroy = function() {
+ api.destroy(id);
+ delete sp.sockets[id];
+ };
+
+ /**
+ * Connects this socket.
+ *
+ * @param options:
+ * host: the host to connect to.
+ * port: the port to connect to.
+ * policyPort: the policy port to use (if non-default), 0 to
+ * use the flash default.
+ * policyUrl: the policy file URL to use (instead of port).
+ */
+ socket.connect = function(options) {
+ // give precedence to policy URL over policy port
+ // if no policy URL and passed port isn't 0, use default port,
+ // otherwise use 0 for the port
+ var policyUrl = options.policyUrl || null;
+ var policyPort = 0;
+ if(policyUrl === null && options.policyPort !== 0) {
+ policyPort = options.policyPort || sp.policyPort;
+ }
+ api.connect(id, options.host, options.port, policyPort, policyUrl);
+ };
+
+ /**
+ * Closes this socket.
+ */
+ socket.close = function() {
+ api.close(id);
+ socket.closed({
+ id: socket.id,
+ type: 'close',
+ bytesAvailable: 0
+ });
+ };
+
+ /**
+ * Determines if the socket is connected or not.
+ *
+ * @return true if connected, false if not.
+ */
+ socket.isConnected = function() {
+ return api.isConnected(id);
+ };
+
+ /**
+ * Writes bytes to this socket.
+ *
+ * @param bytes the bytes (as a string) to write.
+ *
+ * @return true on success, false on failure.
+ */
+ socket.send = function(bytes) {
+ return api.send(id, forge.util.encode64(bytes));
+ };
+
+ /**
+ * Reads bytes from this socket (non-blocking). Fewer than the number
+ * of bytes requested may be read if enough bytes are not available.
+ *
+ * This method should be called from the data handler if there are
+ * enough bytes available. To see how many bytes are available, check
+ * the 'bytesAvailable' property on the event in the data handler or
+ * call the bytesAvailable() function on the socket. If the browser is
+ * msie, then the bytesAvailable() function should be used to avoid
+ * race conditions. Otherwise, using the property on the data handler's
+ * event may be quicker.
+ *
+ * @param count the maximum number of bytes to read.
+ *
+ * @return the bytes read (as a string) or null on error.
+ */
+ socket.receive = function(count) {
+ var rval = api.receive(id, count).rval;
+ return (rval === null) ? null : forge.util.decode64(rval);
+ };
+
+ /**
+ * Gets the number of bytes available for receiving on the socket.
+ *
+ * @return the number of bytes available for receiving.
+ */
+ socket.bytesAvailable = function() {
+ return api.getBytesAvailable(id);
+ };
+
+ // store and return socket
+ sp.sockets[id] = socket;
+ return socket;
+ };
+
+ return sp;
+};
+
+/**
+ * Destroys a flash socket pool.
+ *
+ * @param options:
+ * flashId: the dom ID for the flash object element.
+ */
+net.destroySocketPool = function(options) {
+ if(options.flashId in net.socketPools) {
+ var sp = net.socketPools[options.flashId];
+ sp.destroy();
+ }
+};
+
+/**
+ * Creates a new socket.
+ *
+ * @param options:
+ * flashId: the dom ID for the flash object element.
+ * connected: function(event) called when the socket connects.
+ * closed: function(event) called when the socket closes.
+ * data: function(event) called when socket data has arrived, it
+ * can be read from the socket using receive().
+ * error: function(event) called when a socket error occurs.
+ *
+ * @return the created socket.
+ */
+net.createSocket = function(options) {
+ var socket = null;
+ if(options.flashId in net.socketPools) {
+ // get related socket pool
+ var sp = net.socketPools[options.flashId];
+ socket = sp.createSocket(options);
+ }
+ return socket;
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'net';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/ssh.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/ssh.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/ssh.js
new file mode 100644
index 0000000..ef76c82
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/ssh.js
@@ -0,0 +1,295 @@
+/**
+ * Functions to output keys in SSH-friendly formats.
+ *
+ * This is part of the Forge project which may be used under the terms of
+ * either the BSD License or the GNU General Public License (GPL) Version 2.
+ *
+ * See: https://github.com/digitalbazaar/forge/blob/cbebca3780658703d925b61b2caffb1d263a6c1d/LICENSE
+ *
+ * @author https://github.com/shellac
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+var ssh = forge.ssh = forge.ssh || {};
+
+/**
+ * Encodes (and optionally encrypts) a private RSA key as a Putty PPK file.
+ *
+ * @param privateKey the key.
+ * @param passphrase a passphrase to protect the key (falsy for no encryption).
+ * @param comment a comment to include in the key file.
+ *
+ * @return the PPK file as a string.
+ */
+ssh.privateKeyToPutty = function(privateKey, passphrase, comment) {
+ comment = comment || '';
+ passphrase = passphrase || '';
+ var algorithm = 'ssh-rsa';
+ var encryptionAlgorithm = (passphrase === '') ? 'none' : 'aes256-cbc';
+
+ var ppk = 'PuTTY-User-Key-File-2: ' + algorithm + '\r\n';
+ ppk += 'Encryption: ' + encryptionAlgorithm + '\r\n';
+ ppk += 'Comment: ' + comment + '\r\n';
+
+ // public key into buffer for ppk
+ var pubbuffer = forge.util.createBuffer();
+ _addStringToBuffer(pubbuffer, algorithm);
+ _addBigIntegerToBuffer(pubbuffer, privateKey.e);
+ _addBigIntegerToBuffer(pubbuffer, privateKey.n);
+
+ // write public key
+ var pub = forge.util.encode64(pubbuffer.bytes(), 64);
+ var length = Math.floor(pub.length / 66) + 1; // 66 = 64 + \r\n
+ ppk += 'Public-Lines: ' + length + '\r\n';
+ ppk += pub;
+
+ // private key into a buffer
+ var privbuffer = forge.util.createBuffer();
+ _addBigIntegerToBuffer(privbuffer, privateKey.d);
+ _addBigIntegerToBuffer(privbuffer, privateKey.p);
+ _addBigIntegerToBuffer(privbuffer, privateKey.q);
+ _addBigIntegerToBuffer(privbuffer, privateKey.qInv);
+
+ // optionally encrypt the private key
+ var priv;
+ if(!passphrase) {
+ // use the unencrypted buffer
+ priv = forge.util.encode64(privbuffer.bytes(), 64);
+ } else {
+ // encrypt RSA key using passphrase
+ var encLen = privbuffer.length() + 16 - 1;
+ encLen -= encLen % 16;
+
+ // pad private key with sha1-d data -- needs to be a multiple of 16
+ var padding = _sha1(privbuffer.bytes());
+
+ padding.truncate(padding.length() - encLen + privbuffer.length());
+ privbuffer.putBuffer(padding);
+
+ var aeskey = forge.util.createBuffer();
+ aeskey.putBuffer(_sha1('\x00\x00\x00\x00', passphrase));
+ aeskey.putBuffer(_sha1('\x00\x00\x00\x01', passphrase));
+
+ // encrypt some bytes using CBC mode
+ // key is 40 bytes, so truncate *by* 8 bytes
+ var cipher = forge.aes.createEncryptionCipher(aeskey.truncate(8), 'CBC');
+ cipher.start(forge.util.createBuffer().fillWithByte(0, 16));
+ cipher.update(privbuffer.copy());
+ cipher.finish();
+ var encrypted = cipher.output;
+
+ // Note: this appears to differ from Putty -- is forge wrong, or putty?
+ // due to padding we finish as an exact multiple of 16
+ encrypted.truncate(16); // all padding
+
+ priv = forge.util.encode64(encrypted.bytes(), 64);
+ }
+
+ // output private key
+ length = Math.floor(priv.length / 66) + 1; // 64 + \r\n
+ ppk += '\r\nPrivate-Lines: ' + length + '\r\n';
+ ppk += priv;
+
+ // MAC
+ var mackey = _sha1('putty-private-key-file-mac-key', passphrase);
+
+ var macbuffer = forge.util.createBuffer();
+ _addStringToBuffer(macbuffer, algorithm);
+ _addStringToBuffer(macbuffer, encryptionAlgorithm);
+ _addStringToBuffer(macbuffer, comment);
+ macbuffer.putInt32(pubbuffer.length());
+ macbuffer.putBuffer(pubbuffer);
+ macbuffer.putInt32(privbuffer.length());
+ macbuffer.putBuffer(privbuffer);
+
+ var hmac = forge.hmac.create();
+ hmac.start('sha1', mackey);
+ hmac.update(macbuffer.bytes());
+
+ ppk += '\r\nPrivate-MAC: ' + hmac.digest().toHex() + '\r\n';
+
+ return ppk;
+};
+
+/**
+ * Encodes a public RSA key as an OpenSSH file.
+ *
+ * @param key the key.
+ * @param comment a comment.
+ *
+ * @return the public key in OpenSSH format.
+ */
+ssh.publicKeyToOpenSSH = function(key, comment) {
+ var type = 'ssh-rsa';
+ comment = comment || '';
+
+ var buffer = forge.util.createBuffer();
+ _addStringToBuffer(buffer, type);
+ _addBigIntegerToBuffer(buffer, key.e);
+ _addBigIntegerToBuffer(buffer, key.n);
+
+ return type + ' ' + forge.util.encode64(buffer.bytes()) + ' ' + comment;
+};
+
+/**
+ * Encodes a private RSA key as an OpenSSH file.
+ *
+ * @param key the key.
+ * @param passphrase a passphrase to protect the key (falsy for no encryption).
+ *
+ * @return the public key in OpenSSH format.
+ */
+ssh.privateKeyToOpenSSH = function(privateKey, passphrase) {
+ if(!passphrase) {
+ return forge.pki.privateKeyToPem(privateKey);
+ }
+ // OpenSSH private key is just a legacy format, it seems
+ return forge.pki.encryptRsaPrivateKey(privateKey, passphrase,
+ {legacy: true, algorithm: 'aes128'});
+};
+
+/**
+ * Gets the SSH fingerprint for the given public key.
+ *
+ * @param options the options to use.
+ * [md] the message digest object to use (defaults to forge.md.md5).
+ * [encoding] an alternative output encoding, such as 'hex'
+ * (defaults to none, outputs a byte buffer).
+ * [delimiter] the delimiter to use between bytes for 'hex' encoded
+ * output, eg: ':' (defaults to none).
+ *
+ * @return the fingerprint as a byte buffer or other encoding based on options.
+ */
+ssh.getPublicKeyFingerprint = function(key, options) {
+ options = options || {};
+ var md = options.md || forge.md.md5.create();
+
+ var type = 'ssh-rsa';
+ var buffer = forge.util.createBuffer();
+ _addStringToBuffer(buffer, type);
+ _addBigIntegerToBuffer(buffer, key.e);
+ _addBigIntegerToBuffer(buffer, key.n);
+
+ // hash public key bytes
+ md.start();
+ md.update(buffer.getBytes());
+ var digest = md.digest();
+ if(options.encoding === 'hex') {
+ var hex = digest.toHex();
+ if(options.delimiter) {
+ return hex.match(/.{2}/g).join(options.delimiter);
+ }
+ return hex;
+ } else if(options.encoding === 'binary') {
+ return digest.getBytes();
+ } else if(options.encoding) {
+ throw new Error('Unknown encoding "' + options.encoding + '".');
+ }
+ return digest;
+};
+
+/**
+ * Adds len(val) then val to a buffer.
+ *
+ * @param buffer the buffer to add to.
+ * @param val a big integer.
+ */
+function _addBigIntegerToBuffer(buffer, val) {
+ var hexVal = val.toString(16);
+ // ensure 2s complement +ve
+ if(hexVal[0] >= '8') {
+ hexVal = '00' + hexVal;
+ }
+ var bytes = forge.util.hexToBytes(hexVal);
+ buffer.putInt32(bytes.length);
+ buffer.putBytes(bytes);
+}
+
+/**
+ * Adds len(val) then val to a buffer.
+ *
+ * @param buffer the buffer to add to.
+ * @param val a string.
+ */
+function _addStringToBuffer(buffer, val) {
+ buffer.putInt32(val.length);
+ buffer.putString(val);
+}
+
+/**
+ * Hashes the arguments into one value using SHA-1.
+ *
+ * @return the sha1 hash of the provided arguments.
+ */
+function _sha1() {
+ var sha = forge.md.sha1.create();
+ var num = arguments.length;
+ for (var i = 0; i < num; ++i) {
+ sha.update(arguments[i]);
+ }
+ return sha.digest();
+}
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'ssh';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define([
+ 'require',
+ 'module',
+ './aes',
+ './hmac',
+ './md5',
+ './sha1',
+ './util'
+], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/task.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/task.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/task.js
new file mode 100644
index 0000000..f49bbf7
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/js/task.js
@@ -0,0 +1,778 @@
+/**
+ * Support for concurrent task management and synchronization in web
+ * applications.
+ *
+ * @author Dave Longley
+ * @author David I. Lehn <dl...@digitalbazaar.com>
+ *
+ * Copyright (c) 2009-2013 Digital Bazaar, Inc.
+ */
+(function() {
+/* ########## Begin module implementation ########## */
+function initModule(forge) {
+
+// logging category
+var cat = 'forge.task';
+
+// verbose level
+// 0: off, 1: a little, 2: a whole lot
+// Verbose debug logging is surrounded by a level check to avoid the
+// performance issues with even calling the logging code regardless if it
+// is actually logged. For performance reasons this should not be set to 2
+// for production use.
+// ex: if(sVL >= 2) forge.log.verbose(....)
+var sVL = 0;
+
+// track tasks for debugging
+var sTasks = {};
+var sNextTaskId = 0;
+// debug access
+forge.debug.set(cat, 'tasks', sTasks);
+
+// a map of task type to task queue
+var sTaskQueues = {};
+// debug access
+forge.debug.set(cat, 'queues', sTaskQueues);
+
+// name for unnamed tasks
+var sNoTaskName = '?';
+
+// maximum number of doNext() recursions before a context swap occurs
+// FIXME: might need to tweak this based on the browser
+var sMaxRecursions = 30;
+
+// time slice for doing tasks before a context swap occurs
+// FIXME: might need to tweak this based on the browser
+var sTimeSlice = 20;
+
+/**
+ * Task states.
+ *
+ * READY: ready to start processing
+ * RUNNING: task or a subtask is running
+ * BLOCKED: task is waiting to acquire N permits to continue
+ * SLEEPING: task is sleeping for a period of time
+ * DONE: task is done
+ * ERROR: task has an error
+ */
+var READY = 'ready';
+var RUNNING = 'running';
+var BLOCKED = 'blocked';
+var SLEEPING = 'sleeping';
+var DONE = 'done';
+var ERROR = 'error';
+
+/**
+ * Task actions. Used to control state transitions.
+ *
+ * STOP: stop processing
+ * START: start processing tasks
+ * BLOCK: block task from continuing until 1 or more permits are released
+ * UNBLOCK: release one or more permits
+ * SLEEP: sleep for a period of time
+ * WAKEUP: wakeup early from SLEEPING state
+ * CANCEL: cancel further tasks
+ * FAIL: a failure occured
+ */
+var STOP = 'stop';
+var START = 'start';
+var BLOCK = 'block';
+var UNBLOCK = 'unblock';
+var SLEEP = 'sleep';
+var WAKEUP = 'wakeup';
+var CANCEL = 'cancel';
+var FAIL = 'fail';
+
+/**
+ * State transition table.
+ *
+ * nextState = sStateTable[currentState][action]
+ */
+var sStateTable = {};
+
+sStateTable[READY] = {};
+sStateTable[READY][STOP] = READY;
+sStateTable[READY][START] = RUNNING;
+sStateTable[READY][CANCEL] = DONE;
+sStateTable[READY][FAIL] = ERROR;
+
+sStateTable[RUNNING] = {};
+sStateTable[RUNNING][STOP] = READY;
+sStateTable[RUNNING][START] = RUNNING;
+sStateTable[RUNNING][BLOCK] = BLOCKED;
+sStateTable[RUNNING][UNBLOCK] = RUNNING;
+sStateTable[RUNNING][SLEEP] = SLEEPING;
+sStateTable[RUNNING][WAKEUP] = RUNNING;
+sStateTable[RUNNING][CANCEL] = DONE;
+sStateTable[RUNNING][FAIL] = ERROR;
+
+sStateTable[BLOCKED] = {};
+sStateTable[BLOCKED][STOP] = BLOCKED;
+sStateTable[BLOCKED][START] = BLOCKED;
+sStateTable[BLOCKED][BLOCK] = BLOCKED;
+sStateTable[BLOCKED][UNBLOCK] = BLOCKED;
+sStateTable[BLOCKED][SLEEP] = BLOCKED;
+sStateTable[BLOCKED][WAKEUP] = BLOCKED;
+sStateTable[BLOCKED][CANCEL] = DONE;
+sStateTable[BLOCKED][FAIL] = ERROR;
+
+sStateTable[SLEEPING] = {};
+sStateTable[SLEEPING][STOP] = SLEEPING;
+sStateTable[SLEEPING][START] = SLEEPING;
+sStateTable[SLEEPING][BLOCK] = SLEEPING;
+sStateTable[SLEEPING][UNBLOCK] = SLEEPING;
+sStateTable[SLEEPING][SLEEP] = SLEEPING;
+sStateTable[SLEEPING][WAKEUP] = SLEEPING;
+sStateTable[SLEEPING][CANCEL] = DONE;
+sStateTable[SLEEPING][FAIL] = ERROR;
+
+sStateTable[DONE] = {};
+sStateTable[DONE][STOP] = DONE;
+sStateTable[DONE][START] = DONE;
+sStateTable[DONE][BLOCK] = DONE;
+sStateTable[DONE][UNBLOCK] = DONE;
+sStateTable[DONE][SLEEP] = DONE;
+sStateTable[DONE][WAKEUP] = DONE;
+sStateTable[DONE][CANCEL] = DONE;
+sStateTable[DONE][FAIL] = ERROR;
+
+sStateTable[ERROR] = {};
+sStateTable[ERROR][STOP] = ERROR;
+sStateTable[ERROR][START] = ERROR;
+sStateTable[ERROR][BLOCK] = ERROR;
+sStateTable[ERROR][UNBLOCK] = ERROR;
+sStateTable[ERROR][SLEEP] = ERROR;
+sStateTable[ERROR][WAKEUP] = ERROR;
+sStateTable[ERROR][CANCEL] = ERROR;
+sStateTable[ERROR][FAIL] = ERROR;
+
+/**
+ * Creates a new task.
+ *
+ * @param options options for this task
+ * run: the run function for the task (required)
+ * name: the run function for the task (optional)
+ * parent: parent of this task (optional)
+ *
+ * @return the empty task.
+ */
+var Task = function(options) {
+ // task id
+ this.id = -1;
+
+ // task name
+ this.name = options.name || sNoTaskName;
+
+ // task has no parent
+ this.parent = options.parent || null;
+
+ // save run function
+ this.run = options.run;
+
+ // create a queue of subtasks to run
+ this.subtasks = [];
+
+ // error flag
+ this.error = false;
+
+ // state of the task
+ this.state = READY;
+
+ // number of times the task has been blocked (also the number
+ // of permits needed to be released to continue running)
+ this.blocks = 0;
+
+ // timeout id when sleeping
+ this.timeoutId = null;
+
+ // no swap time yet
+ this.swapTime = null;
+
+ // no user data
+ this.userData = null;
+
+ // initialize task
+ // FIXME: deal with overflow
+ this.id = sNextTaskId++;
+ sTasks[this.id] = this;
+ if(sVL >= 1) {
+ forge.log.verbose(cat, '[%s][%s] init', this.id, this.name, this);
+ }
+};
+
+/**
+ * Logs debug information on this task and the system state.
+ */
+Task.prototype.debug = function(msg) {
+ msg = msg || '';
+ forge.log.debug(cat, msg,
+ '[%s][%s] task:', this.id, this.name, this,
+ 'subtasks:', this.subtasks.length,
+ 'queue:', sTaskQueues);
+};
+
+/**
+ * Adds a subtask to run after task.doNext() or task.fail() is called.
+ *
+ * @param name human readable name for this task (optional).
+ * @param subrun a function to run that takes the current task as
+ * its first parameter.
+ *
+ * @return the current task (useful for chaining next() calls).
+ */
+Task.prototype.next = function(name, subrun) {
+ // juggle parameters if it looks like no name is given
+ if(typeof(name) === 'function') {
+ subrun = name;
+
+ // inherit parent's name
+ name = this.name;
+ }
+ // create subtask, set parent to this task, propagate callbacks
+ var subtask = new Task({
+ run: subrun,
+ name: name,
+ parent: this
+ });
+ // start subtasks running
+ subtask.state = RUNNING;
+ subtask.type = this.type;
+ subtask.successCallback = this.successCallback || null;
+ subtask.failureCallback = this.failureCallback || null;
+
+ // queue a new subtask
+ this.subtasks.push(subtask);
+
+ return this;
+};
+
+/**
+ * Adds subtasks to run in parallel after task.doNext() or task.fail()
+ * is called.
+ *
+ * @param name human readable name for this task (optional).
+ * @param subrun functions to run that take the current task as
+ * their first parameter.
+ *
+ * @return the current task (useful for chaining next() calls).
+ */
+Task.prototype.parallel = function(name, subrun) {
+ // juggle parameters if it looks like no name is given
+ if(forge.util.isArray(name)) {
+ subrun = name;
+
+ // inherit parent's name
+ name = this.name;
+ }
+ // Wrap parallel tasks in a regular task so they are started at the
+ // proper time.
+ return this.next(name, function(task) {
+ // block waiting for subtasks
+ var ptask = task;
+ ptask.block(subrun.length);
+
+ // we pass the iterator from the loop below as a parameter
+ // to a function because it is otherwise included in the
+ // closure and changes as the loop changes -- causing i
+ // to always be set to its highest value
+ var startParallelTask = function(pname, pi) {
+ forge.task.start({
+ type: pname,
+ run: function(task) {
+ subrun[pi](task);
+ },
+ success: function(task) {
+ ptask.unblock();
+ },
+ failure: function(task) {
+ ptask.unblock();
+ }
+ });
+ };
+
+ for(var i = 0; i < subrun.length; i++) {
+ // Type must be unique so task starts in parallel:
+ // name + private string + task id + sub-task index
+ // start tasks in parallel and unblock when the finish
+ var pname = name + '__parallel-' + task.id + '-' + i;
+ var pi = i;
+ startParallelTask(pname, pi);
+ }
+ });
+};
+
+/**
+ * Stops a running task.
+ */
+Task.prototype.stop = function() {
+ this.state = sStateTable[this.state][STOP];
+};
+
+/**
+ * Starts running a task.
+ */
+Task.prototype.start = function() {
+ this.error = false;
+ this.state = sStateTable[this.state][START];
+
+ // try to restart
+ if(this.state === RUNNING) {
+ this.start = new Date();
+ this.run(this);
+ runNext(this, 0);
+ }
+};
+
+/**
+ * Blocks a task until it one or more permits have been released. The
+ * task will not resume until the requested number of permits have
+ * been released with call(s) to unblock().
+ *
+ * @param n number of permits to wait for(default: 1).
+ */
+Task.prototype.block = function(n) {
+ n = typeof(n) === 'undefined' ? 1 : n;
+ this.blocks += n;
+ if(this.blocks > 0) {
+ this.state = sStateTable[this.state][BLOCK];
+ }
+};
+
+/**
+ * Releases a permit to unblock a task. If a task was blocked by
+ * requesting N permits via block(), then it will only continue
+ * running once enough permits have been released via unblock() calls.
+ *
+ * If multiple processes need to synchronize with a single task then
+ * use a condition variable (see forge.task.createCondition). It is
+ * an error to unblock a task more times than it has been blocked.
+ *
+ * @param n number of permits to release (default: 1).
+ *
+ * @return the current block count (task is unblocked when count is 0)
+ */
+Task.prototype.unblock = function(n) {
+ n = typeof(n) === 'undefined' ? 1 : n;
+ this.blocks -= n;
+ if(this.blocks === 0 && this.state !== DONE) {
+ this.state = RUNNING;
+ runNext(this, 0);
+ }
+ return this.blocks;
+};
+
+/**
+ * Sleep for a period of time before resuming tasks.
+ *
+ * @param n number of milliseconds to sleep (default: 0).
+ */
+Task.prototype.sleep = function(n) {
+ n = typeof(n) === 'undefined' ? 0 : n;
+ this.state = sStateTable[this.state][SLEEP];
+ var self = this;
+ this.timeoutId = setTimeout(function() {
+ self.timeoutId = null;
+ self.state = RUNNING;
+ runNext(self, 0);
+ }, n);
+};
+
+/**
+ * Waits on a condition variable until notified. The next task will
+ * not be scheduled until notification. A condition variable can be
+ * created with forge.task.createCondition().
+ *
+ * Once cond.notify() is called, the task will continue.
+ *
+ * @param cond the condition variable to wait on.
+ */
+Task.prototype.wait = function(cond) {
+ cond.wait(this);
+};
+
+/**
+ * If sleeping, wakeup and continue running tasks.
+ */
+Task.prototype.wakeup = function() {
+ if(this.state === SLEEPING) {
+ cancelTimeout(this.timeoutId);
+ this.timeoutId = null;
+ this.state = RUNNING;
+ runNext(this, 0);
+ }
+};
+
+/**
+ * Cancel all remaining subtasks of this task.
+ */
+Task.prototype.cancel = function() {
+ this.state = sStateTable[this.state][CANCEL];
+ // remove permits needed
+ this.permitsNeeded = 0;
+ // cancel timeouts
+ if(this.timeoutId !== null) {
+ cancelTimeout(this.timeoutId);
+ this.timeoutId = null;
+ }
+ // remove subtasks
+ this.subtasks = [];
+};
+
+/**
+ * Finishes this task with failure and sets error flag. The entire
+ * task will be aborted unless the next task that should execute
+ * is passed as a parameter. This allows levels of subtasks to be
+ * skipped. For instance, to abort only this tasks's subtasks, then
+ * call fail(task.parent). To abort this task's subtasks and its
+ * parent's subtasks, call fail(task.parent.parent). To abort
+ * all tasks and simply call the task callback, call fail() or
+ * fail(null).
+ *
+ * The task callback (success or failure) will always, eventually, be
+ * called.
+ *
+ * @param next the task to continue at, or null to abort entirely.
+ */
+Task.prototype.fail = function(next) {
+ // set error flag
+ this.error = true;
+
+ // finish task
+ finish(this, true);
+
+ if(next) {
+ // propagate task info
+ next.error = this.error;
+ next.swapTime = this.swapTime;
+ next.userData = this.userData;
+
+ // do next task as specified
+ runNext(next, 0);
+ } else {
+ if(this.parent !== null) {
+ // finish root task (ensures it is removed from task queue)
+ var parent = this.parent;
+ while(parent.parent !== null) {
+ // propagate task info
+ parent.error = this.error;
+ parent.swapTime = this.swapTime;
+ parent.userData = this.userData;
+ parent = parent.parent;
+ }
+ finish(parent, true);
+ }
+
+ // call failure callback if one exists
+ if(this.failureCallback) {
+ this.failureCallback(this);
+ }
+ }
+};
+
+/**
+ * Asynchronously start a task.
+ *
+ * @param task the task to start.
+ */
+var start = function(task) {
+ task.error = false;
+ task.state = sStateTable[task.state][START];
+ setTimeout(function() {
+ if(task.state === RUNNING) {
+ task.swapTime = +new Date();
+ task.run(task);
+ runNext(task, 0);
+ }
+ }, 0);
+};
+
+/**
+ * Run the next subtask or finish this task.
+ *
+ * @param task the task to process.
+ * @param recurse the recursion count.
+ */
+var runNext = function(task, recurse) {
+ // get time since last context swap (ms), if enough time has passed set
+ // swap to true to indicate that doNext was performed asynchronously
+ // also, if recurse is too high do asynchronously
+ var swap =
+ (recurse > sMaxRecursions) ||
+ (+new Date() - task.swapTime) > sTimeSlice;
+
+ var doNext = function(recurse) {
+ recurse++;
+ if(task.state === RUNNING) {
+ if(swap) {
+ // update swap time
+ task.swapTime = +new Date();
+ }
+
+ if(task.subtasks.length > 0) {
+ // run next subtask
+ var subtask = task.subtasks.shift();
+ subtask.error = task.error;
+ subtask.swapTime = task.swapTime;
+ subtask.userData = task.userData;
+ subtask.run(subtask);
+ if(!subtask.error) {
+ runNext(subtask, recurse);
+ }
+ } else {
+ finish(task);
+
+ if(!task.error) {
+ // chain back up and run parent
+ if(task.parent !== null) {
+ // propagate task info
+ task.parent.error = task.error;
+ task.parent.swapTime = task.swapTime;
+ task.parent.userData = task.userData;
+
+ // no subtasks left, call run next subtask on parent
+ runNext(task.parent, recurse);
+ }
+ }
+ }
+ }
+ };
+
+ if(swap) {
+ // we're swapping, so run asynchronously
+ setTimeout(doNext, 0);
+ } else {
+ // not swapping, so run synchronously
+ doNext(recurse);
+ }
+};
+
+/**
+ * Finishes a task and looks for the next task in the queue to start.
+ *
+ * @param task the task to finish.
+ * @param suppressCallbacks true to suppress callbacks.
+ */
+var finish = function(task, suppressCallbacks) {
+ // subtask is now done
+ task.state = DONE;
+
+ delete sTasks[task.id];
+ if(sVL >= 1) {
+ forge.log.verbose(cat, '[%s][%s] finish',
+ task.id, task.name, task);
+ }
+
+ // only do queue processing for root tasks
+ if(task.parent === null) {
+ // report error if queue is missing
+ if(!(task.type in sTaskQueues)) {
+ forge.log.error(cat,
+ '[%s][%s] task queue missing [%s]',
+ task.id, task.name, task.type);
+ } else if(sTaskQueues[task.type].length === 0) {
+ // report error if queue is empty
+ forge.log.error(cat,
+ '[%s][%s] task queue empty [%s]',
+ task.id, task.name, task.type);
+ } else if(sTaskQueues[task.type][0] !== task) {
+ // report error if this task isn't the first in the queue
+ forge.log.error(cat,
+ '[%s][%s] task not first in queue [%s]',
+ task.id, task.name, task.type);
+ } else {
+ // remove ourselves from the queue
+ sTaskQueues[task.type].shift();
+ // clean up queue if it is empty
+ if(sTaskQueues[task.type].length === 0) {
+ if(sVL >= 1) {
+ forge.log.verbose(cat, '[%s][%s] delete queue [%s]',
+ task.id, task.name, task.type);
+ }
+ /* Note: Only a task can delete a queue of its own type. This
+ is used as a way to synchronize tasks. If a queue for a certain
+ task type exists, then a task of that type is running.
+ */
+ delete sTaskQueues[task.type];
+ } else {
+ // dequeue the next task and start it
+ if(sVL >= 1) {
+ forge.log.verbose(cat,
+ '[%s][%s] queue start next [%s] remain:%s',
+ task.id, task.name, task.type,
+ sTaskQueues[task.type].length);
+ }
+ sTaskQueues[task.type][0].start();
+ }
+ }
+
+ if(!suppressCallbacks) {
+ // call final callback if one exists
+ if(task.error && task.failureCallback) {
+ task.failureCallback(task);
+ } else if(!task.error && task.successCallback) {
+ task.successCallback(task);
+ }
+ }
+ }
+};
+
+/* Tasks API */
+forge.task = forge.task || {};
+
+/**
+ * Starts a new task that will run the passed function asynchronously.
+ *
+ * In order to finish the task, either task.doNext() or task.fail()
+ * *must* be called.
+ *
+ * The task must have a type (a string identifier) that can be used to
+ * synchronize it with other tasks of the same type. That type can also
+ * be used to cancel tasks that haven't started yet.
+ *
+ * To start a task, the following object must be provided as a parameter
+ * (each function takes a task object as its first parameter):
+ *
+ * {
+ * type: the type of task.
+ * run: the function to run to execute the task.
+ * success: a callback to call when the task succeeds (optional).
+ * failure: a callback to call when the task fails (optional).
+ * }
+ *
+ * @param options the object as described above.
+ */
+forge.task.start = function(options) {
+ // create a new task
+ var task = new Task({
+ run: options.run,
+ name: options.name || sNoTaskName
+ });
+ task.type = options.type;
+ task.successCallback = options.success || null;
+ task.failureCallback = options.failure || null;
+
+ // append the task onto the appropriate queue
+ if(!(task.type in sTaskQueues)) {
+ if(sVL >= 1) {
+ forge.log.verbose(cat, '[%s][%s] create queue [%s]',
+ task.id, task.name, task.type);
+ }
+ // create the queue with the new task
+ sTaskQueues[task.type] = [task];
+ start(task);
+ } else {
+ // push the task onto the queue, it will be run after a task
+ // with the same type completes
+ sTaskQueues[options.type].push(task);
+ }
+};
+
+/**
+ * Cancels all tasks of the given type that haven't started yet.
+ *
+ * @param type the type of task to cancel.
+ */
+forge.task.cancel = function(type) {
+ // find the task queue
+ if(type in sTaskQueues) {
+ // empty all but the current task from the queue
+ sTaskQueues[type] = [sTaskQueues[type][0]];
+ }
+};
+
+/**
+ * Creates a condition variable to synchronize tasks. To make a task wait
+ * on the condition variable, call task.wait(condition). To notify all
+ * tasks that are waiting, call condition.notify().
+ *
+ * @return the condition variable.
+ */
+forge.task.createCondition = function() {
+ var cond = {
+ // all tasks that are blocked
+ tasks: {}
+ };
+
+ /**
+ * Causes the given task to block until notify is called. If the task
+ * is already waiting on this condition then this is a no-op.
+ *
+ * @param task the task to cause to wait.
+ */
+ cond.wait = function(task) {
+ // only block once
+ if(!(task.id in cond.tasks)) {
+ task.block();
+ cond.tasks[task.id] = task;
+ }
+ };
+
+ /**
+ * Notifies all waiting tasks to wake up.
+ */
+ cond.notify = function() {
+ // since unblock() will run the next task from here, make sure to
+ // clear the condition's blocked task list before unblocking
+ var tmp = cond.tasks;
+ cond.tasks = {};
+ for(var id in tmp) {
+ tmp[id].unblock();
+ }
+ };
+
+ return cond;
+};
+
+} // end module implementation
+
+/* ########## Begin module wrapper ########## */
+var name = 'task';
+if(typeof define !== 'function') {
+ // NodeJS -> AMD
+ if(typeof module === 'object' && module.exports) {
+ var nodeJS = true;
+ define = function(ids, factory) {
+ factory(require, module);
+ };
+ } else {
+ // <script>
+ if(typeof forge === 'undefined') {
+ forge = {};
+ }
+ return initModule(forge);
+ }
+}
+// AMD
+var deps;
+var defineFunc = function(require, module) {
+ module.exports = function(forge) {
+ var mods = deps.map(function(dep) {
+ return require(dep);
+ }).concat(initModule);
+ // handle circular dependencies
+ forge = forge || {};
+ forge.defined = forge.defined || {};
+ if(forge.defined[name]) {
+ return forge[name];
+ }
+ forge.defined[name] = true;
+ for(var i = 0; i < mods.length; ++i) {
+ mods[i](forge);
+ }
+ return forge[name];
+ };
+};
+var tmpDefine = define;
+define = function(ids, factory) {
+ deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
+ if(nodeJS) {
+ delete define;
+ return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
+ }
+ define = tmpDefine;
+ return define.apply(null, Array.prototype.slice.call(arguments, 0));
+};
+define(['require', 'module', './debug', './log', './util'], function() {
+ defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
+});
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[30/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/client.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/client.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/client.js
new file mode 100644
index 0000000..abfc40e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/client.js
@@ -0,0 +1,552 @@
+(function() {
+ var ClearCommand, Client, Connection, ForwardCommand, FrameBufferCommand, GetDevicePathCommand, GetFeaturesCommand, GetPackagesCommand, GetPropertiesCommand, GetSerialNoCommand, GetStateCommand, HostConnectCommand, HostDevicesCommand, HostDevicesWithPathsCommand, HostDisconnectCommand, HostKillCommand, HostTrackDevicesCommand, HostTransportCommand, HostVersionCommand, InstallCommand, IsInstalledCommand, ListForwardsCommand, LocalCommand, LogCommand, Logcat, LogcatCommand, Monkey, MonkeyCommand, Parser, ProcStat, Promise, RebootCommand, RemountCommand, ScreencapCommand, ShellCommand, StartActivityCommand, StartServiceCommand, Sync, SyncCommand, TcpCommand, TcpIpCommand, TcpUsbServer, TrackJdwpCommand, UninstallCommand, UsbCommand, WaitBootCompleteCommand, WaitForDeviceCommand, debug;
+
+ Monkey = require('adbkit-monkey');
+
+ Logcat = require('adbkit-logcat');
+
+ Promise = require('bluebird');
+
+ debug = require('debug')('adb:client');
+
+ Connection = require('./connection');
+
+ Sync = require('./sync');
+
+ Parser = require('./parser');
+
+ ProcStat = require('./proc/stat');
+
+ HostVersionCommand = require('./command/host/version');
+
+ HostConnectCommand = require('./command/host/connect');
+
+ HostDevicesCommand = require('./command/host/devices');
+
+ HostDevicesWithPathsCommand = require('./command/host/deviceswithpaths');
+
+ HostDisconnectCommand = require('./command/host/disconnect');
+
+ HostTrackDevicesCommand = require('./command/host/trackdevices');
+
+ HostKillCommand = require('./command/host/kill');
+
+ HostTransportCommand = require('./command/host/transport');
+
+ ClearCommand = require('./command/host-transport/clear');
+
+ FrameBufferCommand = require('./command/host-transport/framebuffer');
+
+ GetFeaturesCommand = require('./command/host-transport/getfeatures');
+
+ GetPackagesCommand = require('./command/host-transport/getpackages');
+
+ GetPropertiesCommand = require('./command/host-transport/getproperties');
+
+ InstallCommand = require('./command/host-transport/install');
+
+ IsInstalledCommand = require('./command/host-transport/isinstalled');
+
+ LocalCommand = require('./command/host-transport/local');
+
+ LogcatCommand = require('./command/host-transport/logcat');
+
+ LogCommand = require('./command/host-transport/log');
+
+ MonkeyCommand = require('./command/host-transport/monkey');
+
+ RebootCommand = require('./command/host-transport/reboot');
+
+ RemountCommand = require('./command/host-transport/remount');
+
+ ScreencapCommand = require('./command/host-transport/screencap');
+
+ ShellCommand = require('./command/host-transport/shell');
+
+ StartActivityCommand = require('./command/host-transport/startactivity');
+
+ StartServiceCommand = require('./command/host-transport/startservice');
+
+ SyncCommand = require('./command/host-transport/sync');
+
+ TcpCommand = require('./command/host-transport/tcp');
+
+ TcpIpCommand = require('./command/host-transport/tcpip');
+
+ TrackJdwpCommand = require('./command/host-transport/trackjdwp');
+
+ UninstallCommand = require('./command/host-transport/uninstall');
+
+ UsbCommand = require('./command/host-transport/usb');
+
+ WaitBootCompleteCommand = require('./command/host-transport/waitbootcomplete');
+
+ ForwardCommand = require('./command/host-serial/forward');
+
+ GetDevicePathCommand = require('./command/host-serial/getdevicepath');
+
+ GetSerialNoCommand = require('./command/host-serial/getserialno');
+
+ GetStateCommand = require('./command/host-serial/getstate');
+
+ ListForwardsCommand = require('./command/host-serial/listforwards');
+
+ WaitForDeviceCommand = require('./command/host-serial/waitfordevice');
+
+ TcpUsbServer = require('./tcpusb/server');
+
+ Client = (function() {
+ var NoUserOptionError;
+
+ function Client(options) {
+ var _base, _base1;
+ this.options = options != null ? options : {};
+ (_base = this.options).port || (_base.port = 5037);
+ (_base1 = this.options).bin || (_base1.bin = 'adb');
+ }
+
+ Client.prototype.createTcpUsbBridge = function(serial, options) {
+ return new TcpUsbServer(this, serial, options);
+ };
+
+ Client.prototype.connection = function() {
+ var conn, connectListener, errorListener, resolver;
+ resolver = Promise.defer();
+ conn = new Connection(this.options).on('error', errorListener = function(err) {
+ return resolver.reject(err);
+ }).on('connect', connectListener = function() {
+ return resolver.resolve(conn);
+ }).connect();
+ return resolver.promise["finally"](function() {
+ conn.removeListener('error', errorListener);
+ return conn.removeListener('connect', connectListener);
+ });
+ };
+
+ Client.prototype.version = function(callback) {
+ return this.connection().then(function(conn) {
+ return new HostVersionCommand(conn).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.connect = function(host, port, callback) {
+ var _ref;
+ if (port == null) {
+ port = 5555;
+ }
+ if (typeof port === 'function') {
+ callback = port;
+ port = 5555;
+ }
+ if (host.indexOf(':') !== -1) {
+ _ref = host.split(':', 2), host = _ref[0], port = _ref[1];
+ }
+ return this.connection().then(function(conn) {
+ return new HostConnectCommand(conn).execute(host, port);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.disconnect = function(host, port, callback) {
+ var _ref;
+ if (port == null) {
+ port = 5555;
+ }
+ if (typeof port === 'function') {
+ callback = port;
+ port = 5555;
+ }
+ if (host.indexOf(':') !== -1) {
+ _ref = host.split(':', 2), host = _ref[0], port = _ref[1];
+ }
+ return this.connection().then(function(conn) {
+ return new HostDisconnectCommand(conn).execute(host, port);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.listDevices = function(callback) {
+ return this.connection().then(function(conn) {
+ return new HostDevicesCommand(conn).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.listDevicesWithPaths = function(callback) {
+ return this.connection().then(function(conn) {
+ return new HostDevicesWithPathsCommand(conn).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.trackDevices = function(callback) {
+ return this.connection().then(function(conn) {
+ return new HostTrackDevicesCommand(conn).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.kill = function(callback) {
+ return this.connection().then(function(conn) {
+ return new HostKillCommand(conn).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.getSerialNo = function(serial, callback) {
+ return this.connection().then(function(conn) {
+ return new GetSerialNoCommand(conn).execute(serial);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.getDevicePath = function(serial, callback) {
+ return this.connection().then(function(conn) {
+ return new GetDevicePathCommand(conn).execute(serial);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.getState = function(serial, callback) {
+ return this.connection().then(function(conn) {
+ return new GetStateCommand(conn).execute(serial);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.getProperties = function(serial, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new GetPropertiesCommand(transport).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.getFeatures = function(serial, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new GetFeaturesCommand(transport).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.getPackages = function(serial, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new GetPackagesCommand(transport).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.getDHCPIpAddress = function(serial, iface, callback) {
+ if (iface == null) {
+ iface = 'wlan0';
+ }
+ if (typeof iface === 'function') {
+ callback = iface;
+ iface = 'wlan0';
+ }
+ return this.getProperties(serial).then(function(properties) {
+ var ip;
+ if (ip = properties["dhcp." + iface + ".ipaddress"]) {
+ return ip;
+ }
+ throw new Error("Unable to find ipaddress for '" + iface + "'");
+ });
+ };
+
+ Client.prototype.forward = function(serial, local, remote, callback) {
+ return this.connection().then(function(conn) {
+ return new ForwardCommand(conn).execute(serial, local, remote);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.listForwards = function(serial, callback) {
+ return this.connection().then(function(conn) {
+ return new ListForwardsCommand(conn).execute(serial);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.transport = function(serial, callback) {
+ return this.connection().then(function(conn) {
+ return new HostTransportCommand(conn).execute(serial)["return"](conn);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.shell = function(serial, command, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new ShellCommand(transport).execute(command);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.reboot = function(serial, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new RebootCommand(transport).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.remount = function(serial, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new RemountCommand(transport).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.trackJdwp = function(serial, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new TrackJdwpCommand(transport).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.framebuffer = function(serial, format, callback) {
+ if (format == null) {
+ format = 'raw';
+ }
+ if (typeof format === 'function') {
+ callback = format;
+ format = 'raw';
+ }
+ return this.transport(serial).then(function(transport) {
+ return new FrameBufferCommand(transport).execute(format);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.screencap = function(serial, callback) {
+ return this.transport(serial).then((function(_this) {
+ return function(transport) {
+ return new ScreencapCommand(transport).execute()["catch"](function(err) {
+ debug("Emulating screencap command due to '" + err + "'");
+ return _this.framebuffer(serial, 'png');
+ });
+ };
+ })(this)).nodeify(callback);
+ };
+
+ Client.prototype.openLocal = function(serial, path, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new LocalCommand(transport).execute(path);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.openLog = function(serial, name, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new LogCommand(transport).execute(name);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.openTcp = function(serial, port, host, callback) {
+ if (typeof host === 'function') {
+ callback = host;
+ host = void 0;
+ }
+ return this.transport(serial).then(function(transport) {
+ return new TcpCommand(transport).execute(port, host);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.openMonkey = function(serial, port, callback) {
+ var tryConnect;
+ if (port == null) {
+ port = 1080;
+ }
+ if (typeof port === 'function') {
+ callback = port;
+ port = 1080;
+ }
+ tryConnect = (function(_this) {
+ return function(times) {
+ return _this.openTcp(serial, port).then(function(stream) {
+ return Monkey.connectStream(stream);
+ })["catch"](function(err) {
+ if (times -= 1) {
+ debug("Monkey can't be reached, trying " + times + " more times");
+ return Promise.delay(100).then(function() {
+ return tryConnect(times);
+ });
+ } else {
+ throw err;
+ }
+ });
+ };
+ })(this);
+ return tryConnect(1)["catch"]((function(_this) {
+ return function(err) {
+ return _this.transport(serial).then(function(transport) {
+ return new MonkeyCommand(transport).execute(port);
+ }).then(function(out) {
+ return tryConnect(20).then(function(monkey) {
+ return monkey.once('end', function() {
+ return out.end();
+ });
+ });
+ });
+ };
+ })(this)).nodeify(callback);
+ };
+
+ Client.prototype.openLogcat = function(serial, options, callback) {
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+ return this.transport(serial).then(function(transport) {
+ return new LogcatCommand(transport).execute(options);
+ }).then(function(stream) {
+ return Logcat.readStream(stream, {
+ fixLineFeeds: false
+ });
+ }).nodeify(callback);
+ };
+
+ Client.prototype.openProcStat = function(serial, callback) {
+ return this.syncService(serial).then(function(sync) {
+ return new ProcStat(sync);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.clear = function(serial, pkg, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new ClearCommand(transport).execute(pkg);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.install = function(serial, apk, callback) {
+ var temp;
+ temp = Sync.temp(typeof apk === 'string' ? apk : '_stream.apk');
+ return this.push(serial, apk, temp).then((function(_this) {
+ return function(transfer) {
+ var endListener, errorListener, resolver;
+ resolver = Promise.defer();
+ transfer.on('error', errorListener = function(err) {
+ return resolver.reject(err);
+ });
+ transfer.on('end', endListener = function() {
+ return resolver.resolve(_this.installRemote(serial, temp));
+ });
+ return resolver.promise["finally"](function() {
+ transfer.removeListener('error', errorListener);
+ return transfer.removeListener('end', endListener);
+ });
+ };
+ })(this)).nodeify(callback);
+ };
+
+ Client.prototype.installRemote = function(serial, apk, callback) {
+ return this.transport(serial).then((function(_this) {
+ return function(transport) {
+ return new InstallCommand(transport).execute(apk).then(function() {
+ return _this.shell(serial, ['rm', '-f', apk]);
+ }).then(function(stream) {
+ return new Parser(stream).readAll();
+ }).then(function(out) {
+ return true;
+ });
+ };
+ })(this)).nodeify(callback);
+ };
+
+ Client.prototype.uninstall = function(serial, pkg, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new UninstallCommand(transport).execute(pkg);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.isInstalled = function(serial, pkg, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new IsInstalledCommand(transport).execute(pkg);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.startActivity = function(serial, options, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new StartActivityCommand(transport).execute(options);
+ })["catch"](NoUserOptionError, (function(_this) {
+ return function() {
+ options.user = null;
+ return _this.startActivity(serial, options);
+ };
+ })(this)).nodeify(callback);
+ };
+
+ Client.prototype.startService = function(serial, options, callback) {
+ return this.transport(serial).then(function(transport) {
+ if (!(options.user || options.user === null)) {
+ options.user = 0;
+ }
+ return new StartServiceCommand(transport).execute(options);
+ })["catch"](NoUserOptionError, (function(_this) {
+ return function() {
+ options.user = null;
+ return _this.startService(serial, options);
+ };
+ })(this)).nodeify(callback);
+ };
+
+ Client.prototype.syncService = function(serial, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new SyncCommand(transport).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.stat = function(serial, path, callback) {
+ return this.syncService(serial).then(function(sync) {
+ return sync.stat(path)["finally"](function() {
+ return sync.end();
+ });
+ }).nodeify(callback);
+ };
+
+ Client.prototype.readdir = function(serial, path, callback) {
+ return this.syncService(serial).then(function(sync) {
+ return sync.readdir(path)["finally"](function() {
+ return sync.end();
+ });
+ }).nodeify(callback);
+ };
+
+ Client.prototype.pull = function(serial, path, callback) {
+ return this.syncService(serial).then(function(sync) {
+ return sync.pull(path).on('end', function() {
+ return sync.end();
+ });
+ }).nodeify(callback);
+ };
+
+ Client.prototype.push = function(serial, contents, path, mode, callback) {
+ if (typeof mode === 'function') {
+ callback = mode;
+ mode = void 0;
+ }
+ return this.syncService(serial).then(function(sync) {
+ return sync.push(contents, path, mode).on('end', function() {
+ return sync.end();
+ });
+ }).nodeify(callback);
+ };
+
+ Client.prototype.tcpip = function(serial, port, callback) {
+ if (port == null) {
+ port = 5555;
+ }
+ if (typeof port === 'function') {
+ callback = port;
+ port = 5555;
+ }
+ return this.transport(serial).then(function(transport) {
+ return new TcpIpCommand(transport).execute(port);
+ }).nodeify(callback);
+ };
+
+ Client.prototype.usb = function(serial, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new UsbCommand(transport).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.waitBootComplete = function(serial, callback) {
+ return this.transport(serial).then(function(transport) {
+ return new WaitBootCompleteCommand(transport).execute();
+ }).nodeify(callback);
+ };
+
+ Client.prototype.waitForDevice = function(serial, callback) {
+ return this.connection().then(function(conn) {
+ return new WaitForDeviceCommand(conn).execute(serial);
+ }).nodeify(callback);
+ };
+
+ NoUserOptionError = function(err) {
+ return err.message.indexOf('--user') !== -1;
+ };
+
+ return Client;
+
+ })();
+
+ module.exports = Client;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command.js
new file mode 100644
index 0000000..a01f7d3
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command.js
@@ -0,0 +1,48 @@
+(function() {
+ var Command, Parser, Protocol, debug;
+
+ debug = require('debug')('adb:command');
+
+ Parser = require('./parser');
+
+ Protocol = require('./protocol');
+
+ Command = (function() {
+ var RE_SQUOT;
+
+ RE_SQUOT = /'/g;
+
+ function Command(connection) {
+ this.connection = connection;
+ this.parser = this.connection.parser;
+ this.protocol = Protocol;
+ }
+
+ Command.prototype.execute = function() {
+ throw new Exception('Missing implementation');
+ };
+
+ Command.prototype._send = function(data) {
+ var encoded;
+ encoded = Protocol.encodeData(data);
+ debug("Send '" + encoded + "'");
+ this.connection.write(encoded);
+ return this;
+ };
+
+ Command.prototype._escape = function(arg) {
+ switch (typeof arg) {
+ case 'number':
+ return arg;
+ default:
+ return "'" + arg.toString().replace(RE_SQUOT, "'\"'\"'") + "'";
+ }
+ };
+
+ return Command;
+
+ })();
+
+ module.exports = Command;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/forward.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/forward.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/forward.js
new file mode 100644
index 0000000..597d37f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/forward.js
@@ -0,0 +1,48 @@
+(function() {
+ var Command, ForwardCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ ForwardCommand = (function(_super) {
+ __extends(ForwardCommand, _super);
+
+ function ForwardCommand() {
+ return ForwardCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ ForwardCommand.prototype.execute = function(serial, local, remote) {
+ this._send("host-serial:" + serial + ":forward:" + local + ";" + remote);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAscii(4).then(function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return true;
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return ForwardCommand;
+
+ })(Command);
+
+ module.exports = ForwardCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getdevicepath.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getdevicepath.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getdevicepath.js
new file mode 100644
index 0000000..b171cae
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getdevicepath.js
@@ -0,0 +1,41 @@
+(function() {
+ var Command, GetDevicePathCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ GetDevicePathCommand = (function(_super) {
+ __extends(GetDevicePathCommand, _super);
+
+ function GetDevicePathCommand() {
+ return GetDevicePathCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ GetDevicePathCommand.prototype.execute = function(serial) {
+ this._send("host-serial:" + serial + ":get-devpath");
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readValue().then(function(value) {
+ return value.toString();
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return GetDevicePathCommand;
+
+ })(Command);
+
+ module.exports = GetDevicePathCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getserialno.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getserialno.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getserialno.js
new file mode 100644
index 0000000..28f858e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getserialno.js
@@ -0,0 +1,41 @@
+(function() {
+ var Command, GetSerialNoCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ GetSerialNoCommand = (function(_super) {
+ __extends(GetSerialNoCommand, _super);
+
+ function GetSerialNoCommand() {
+ return GetSerialNoCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ GetSerialNoCommand.prototype.execute = function(serial) {
+ this._send("host-serial:" + serial + ":get-serialno");
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readValue().then(function(value) {
+ return value.toString();
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return GetSerialNoCommand;
+
+ })(Command);
+
+ module.exports = GetSerialNoCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getstate.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getstate.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getstate.js
new file mode 100644
index 0000000..fa6378f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/getstate.js
@@ -0,0 +1,41 @@
+(function() {
+ var Command, GetStateCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ GetStateCommand = (function(_super) {
+ __extends(GetStateCommand, _super);
+
+ function GetStateCommand() {
+ return GetStateCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ GetStateCommand.prototype.execute = function(serial) {
+ this._send("host-serial:" + serial + ":get-state");
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readValue().then(function(value) {
+ return value.toString();
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return GetStateCommand;
+
+ })(Command);
+
+ module.exports = GetStateCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/listforwards.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/listforwards.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/listforwards.js
new file mode 100644
index 0000000..e426d9d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/listforwards.js
@@ -0,0 +1,59 @@
+(function() {
+ var Command, ListForwardsCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ ListForwardsCommand = (function(_super) {
+ __extends(ListForwardsCommand, _super);
+
+ function ListForwardsCommand() {
+ return ListForwardsCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ ListForwardsCommand.prototype.execute = function(serial) {
+ this._send("host-serial:" + serial + ":list-forward");
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readValue().then(function(value) {
+ return _this._parseForwards(value);
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ ListForwardsCommand.prototype._parseForwards = function(value) {
+ var forward, forwards, local, remote, serial, _i, _len, _ref, _ref1;
+ forwards = [];
+ _ref = value.toString().split('\n');
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ forward = _ref[_i];
+ if (forward) {
+ _ref1 = forward.split(/\s+/), serial = _ref1[0], local = _ref1[1], remote = _ref1[2];
+ forwards.push({
+ serial: serial,
+ local: local,
+ remote: remote
+ });
+ }
+ }
+ return forwards;
+ };
+
+ return ListForwardsCommand;
+
+ })(Command);
+
+ module.exports = ListForwardsCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/waitfordevice.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/waitfordevice.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/waitfordevice.js
new file mode 100644
index 0000000..efa1a0b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-serial/waitfordevice.js
@@ -0,0 +1,48 @@
+(function() {
+ var Command, Protocol, WaitForDeviceCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ WaitForDeviceCommand = (function(_super) {
+ __extends(WaitForDeviceCommand, _super);
+
+ function WaitForDeviceCommand() {
+ return WaitForDeviceCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ WaitForDeviceCommand.prototype.execute = function(serial) {
+ this._send("host-serial:" + serial + ":wait-for-any");
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAscii(4).then(function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return serial;
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return WaitForDeviceCommand;
+
+ })(Command);
+
+ module.exports = WaitForDeviceCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/clear.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/clear.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/clear.js
new file mode 100644
index 0000000..7a8acb0
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/clear.js
@@ -0,0 +1,47 @@
+(function() {
+ var ClearCommand, Command, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ ClearCommand = (function(_super) {
+ __extends(ClearCommand, _super);
+
+ function ClearCommand() {
+ return ClearCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ ClearCommand.prototype.execute = function(pkg) {
+ this._send("shell:pm clear " + pkg);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.searchLine(/^(Success|Failed)$/).then(function(result) {
+ switch (result[0]) {
+ case 'Success':
+ return true;
+ case 'Failed':
+ _this.connection.end();
+ throw new Error("Package '" + pkg + "' could not be cleared");
+ }
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return ClearCommand;
+
+ })(Command);
+
+ module.exports = ClearCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/framebuffer.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/framebuffer.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/framebuffer.js
new file mode 100644
index 0000000..5689f3c
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/framebuffer.js
@@ -0,0 +1,117 @@
+(function() {
+ var Assert, Command, FrameBufferCommand, Protocol, RgbTransform, debug, spawn,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Assert = require('assert');
+
+ spawn = require('child_process').spawn;
+
+ debug = require('debug')('adb:command:framebuffer');
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ RgbTransform = require('../../framebuffer/rgbtransform');
+
+ FrameBufferCommand = (function(_super) {
+ __extends(FrameBufferCommand, _super);
+
+ function FrameBufferCommand() {
+ return FrameBufferCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ FrameBufferCommand.prototype.execute = function(format) {
+ this._send('framebuffer:');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readBytes(52).then(function(header) {
+ var meta, stream;
+ meta = _this._parseHeader(header);
+ switch (format) {
+ case 'raw':
+ stream = _this.parser.raw();
+ stream.meta = meta;
+ return stream;
+ default:
+ stream = _this._convert(meta);
+ stream.meta = meta;
+ return stream;
+ }
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ FrameBufferCommand.prototype._convert = function(meta, format, raw) {
+ var proc, transform;
+ debug("Converting raw framebuffer stream into " + (format.toUpperCase()));
+ switch (meta.format) {
+ case 'rgb':
+ case 'rgba':
+ break;
+ default:
+ debug("Silently transforming '" + meta.format + "' into 'rgb' for `gm`");
+ transform = new RgbTransform(meta);
+ meta.format = 'rgb';
+ raw = this.parser.raw().pipe(transform);
+ }
+ proc = spawn('gm', ['convert', '-size', "" + meta.width + "x" + meta.height, "" + meta.format + ":-", "" + format + ":-"]);
+ raw.pipe(proc.stdin);
+ return proc.stdout;
+ };
+
+ FrameBufferCommand.prototype._parseHeader = function(header) {
+ var meta, offset;
+ meta = {};
+ offset = 0;
+ meta.version = header.readUInt32LE(offset);
+ if (meta.version === 16) {
+ throw new Error('Old-style raw images are not supported');
+ }
+ offset += 4;
+ meta.bpp = header.readUInt32LE(offset);
+ offset += 4;
+ meta.size = header.readUInt32LE(offset);
+ offset += 4;
+ meta.width = header.readUInt32LE(offset);
+ offset += 4;
+ meta.height = header.readUInt32LE(offset);
+ offset += 4;
+ meta.red_offset = header.readUInt32LE(offset);
+ offset += 4;
+ meta.red_length = header.readUInt32LE(offset);
+ offset += 4;
+ meta.blue_offset = header.readUInt32LE(offset);
+ offset += 4;
+ meta.blue_length = header.readUInt32LE(offset);
+ offset += 4;
+ meta.green_offset = header.readUInt32LE(offset);
+ offset += 4;
+ meta.green_length = header.readUInt32LE(offset);
+ offset += 4;
+ meta.alpha_offset = header.readUInt32LE(offset);
+ offset += 4;
+ meta.alpha_length = header.readUInt32LE(offset);
+ meta.format = meta.blue_offset === 0 ? 'bgr' : 'rgb';
+ if (meta.bpp === 32 || meta.alpha_length) {
+ meta.format += 'a';
+ }
+ return meta;
+ };
+
+ return FrameBufferCommand;
+
+ })(Command);
+
+ module.exports = FrameBufferCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getfeatures.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getfeatures.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getfeatures.js
new file mode 100644
index 0000000..be6083d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getfeatures.js
@@ -0,0 +1,54 @@
+(function() {
+ var Command, GetFeaturesCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ GetFeaturesCommand = (function(_super) {
+ var RE_FEATURE;
+
+ __extends(GetFeaturesCommand, _super);
+
+ function GetFeaturesCommand() {
+ return GetFeaturesCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RE_FEATURE = /^feature:(.*?)(?:=(.*?))?\r?$/gm;
+
+ GetFeaturesCommand.prototype.execute = function() {
+ this._send('shell:pm list features 2>/dev/null');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAll().then(function(data) {
+ return _this._parseFeatures(data.toString());
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ GetFeaturesCommand.prototype._parseFeatures = function(value) {
+ var features, match;
+ features = {};
+ while (match = RE_FEATURE.exec(value)) {
+ features[match[1]] = match[2] || true;
+ }
+ return features;
+ };
+
+ return GetFeaturesCommand;
+
+ })(Command);
+
+ module.exports = GetFeaturesCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getpackages.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getpackages.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getpackages.js
new file mode 100644
index 0000000..6e98fdf
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getpackages.js
@@ -0,0 +1,54 @@
+(function() {
+ var Command, GetPackagesCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ GetPackagesCommand = (function(_super) {
+ var RE_PACKAGE;
+
+ __extends(GetPackagesCommand, _super);
+
+ function GetPackagesCommand() {
+ return GetPackagesCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RE_PACKAGE = /^package:(.*?)\r?$/gm;
+
+ GetPackagesCommand.prototype.execute = function() {
+ this._send('shell:pm list packages 2>/dev/null');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAll().then(function(data) {
+ return _this._parsePackages(data.toString());
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ GetPackagesCommand.prototype._parsePackages = function(value) {
+ var features, match;
+ features = [];
+ while (match = RE_PACKAGE.exec(value)) {
+ features.push(match[1]);
+ }
+ return features;
+ };
+
+ return GetPackagesCommand;
+
+ })(Command);
+
+ module.exports = GetPackagesCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getproperties.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getproperties.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getproperties.js
new file mode 100644
index 0000000..1c3756b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/getproperties.js
@@ -0,0 +1,56 @@
+(function() {
+ var Command, GetPropertiesCommand, LineTransform, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ LineTransform = require('../../linetransform');
+
+ GetPropertiesCommand = (function(_super) {
+ var RE_KEYVAL;
+
+ __extends(GetPropertiesCommand, _super);
+
+ function GetPropertiesCommand() {
+ return GetPropertiesCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RE_KEYVAL = /^\[([\s\S]*?)\]: \[([\s\S]*?)\]\r?$/gm;
+
+ GetPropertiesCommand.prototype.execute = function() {
+ this._send('shell:getprop');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAll().then(function(data) {
+ return _this._parseProperties(data.toString());
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ GetPropertiesCommand.prototype._parseProperties = function(value) {
+ var match, properties;
+ properties = {};
+ while (match = RE_KEYVAL.exec(value)) {
+ properties[match[1]] = match[2];
+ }
+ return properties;
+ };
+
+ return GetPropertiesCommand;
+
+ })(Command);
+
+ module.exports = GetPropertiesCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/install.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/install.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/install.js
new file mode 100644
index 0000000..634dbab
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/install.js
@@ -0,0 +1,51 @@
+(function() {
+ var Command, InstallCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ InstallCommand = (function(_super) {
+ __extends(InstallCommand, _super);
+
+ function InstallCommand() {
+ return InstallCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ InstallCommand.prototype.execute = function(apk) {
+ this._send("shell:pm install -r '" + apk + "'");
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.searchLine(/^(Success|Failure \[(.*?)\])$/).then(function(match) {
+ var code, err;
+ if (match[1] === 'Success') {
+ return true;
+ } else {
+ code = match[2];
+ err = new Error("" + apk + " could not be installed [" + code + "]");
+ err.code = code;
+ throw err;
+ }
+ })["finally"](function() {
+ return _this.parser.readAll();
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return InstallCommand;
+
+ })(Command);
+
+ module.exports = InstallCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/isinstalled.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/isinstalled.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/isinstalled.js
new file mode 100644
index 0000000..463c0f9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/isinstalled.js
@@ -0,0 +1,50 @@
+(function() {
+ var Command, IsInstalledCommand, Parser, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ Parser = require('../../parser');
+
+ IsInstalledCommand = (function(_super) {
+ __extends(IsInstalledCommand, _super);
+
+ function IsInstalledCommand() {
+ return IsInstalledCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ IsInstalledCommand.prototype.execute = function(pkg) {
+ this._send("shell:pm path " + pkg + " 2>/dev/null");
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAscii(8).then(function(reply) {
+ switch (reply) {
+ case 'package:':
+ return true;
+ default:
+ return _this.parser.unexpected(reply, "'package:'");
+ }
+ })["catch"](Parser.PrematureEOFError, function(err) {
+ return false;
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return IsInstalledCommand;
+
+ })(Command);
+
+ module.exports = IsInstalledCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/local.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/local.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/local.js
new file mode 100644
index 0000000..fc764a1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/local.js
@@ -0,0 +1,39 @@
+(function() {
+ var Command, LocalCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ LocalCommand = (function(_super) {
+ __extends(LocalCommand, _super);
+
+ function LocalCommand() {
+ return LocalCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ LocalCommand.prototype.execute = function(path) {
+ this._send(/:/.test(path) ? path : "localfilesystem:" + path);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.raw();
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return LocalCommand;
+
+ })(Command);
+
+ module.exports = LocalCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/log.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/log.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/log.js
new file mode 100644
index 0000000..1e8ddc9
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/log.js
@@ -0,0 +1,39 @@
+(function() {
+ var Command, LogCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ LogCommand = (function(_super) {
+ __extends(LogCommand, _super);
+
+ function LogCommand() {
+ return LogCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ LogCommand.prototype.execute = function(name) {
+ this._send("log:" + name);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.raw();
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return LogCommand;
+
+ })(Command);
+
+ module.exports = LogCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/logcat.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/logcat.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/logcat.js
new file mode 100644
index 0000000..778ec34
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/logcat.js
@@ -0,0 +1,49 @@
+(function() {
+ var Command, LineTransform, LogcatCommand, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ LineTransform = require('../../linetransform');
+
+ LogcatCommand = (function(_super) {
+ __extends(LogcatCommand, _super);
+
+ function LogcatCommand() {
+ return LogcatCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ LogcatCommand.prototype.execute = function(options) {
+ var cmd;
+ if (options == null) {
+ options = {};
+ }
+ cmd = 'logcat -B *:I 2>/dev/null';
+ if (options.clear) {
+ cmd = "logcat -c 2>/dev/null && " + cmd;
+ }
+ this._send("shell:" + cmd);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.raw().pipe(new LineTransform);
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return LogcatCommand;
+
+ })(Command);
+
+ module.exports = LogcatCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/monkey.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/monkey.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/monkey.js
new file mode 100644
index 0000000..d913e9e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/monkey.js
@@ -0,0 +1,45 @@
+(function() {
+ var Command, MonkeyCommand, Promise, Protocol,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Promise = require('bluebird');
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ MonkeyCommand = (function(_super) {
+ __extends(MonkeyCommand, _super);
+
+ function MonkeyCommand() {
+ return MonkeyCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ MonkeyCommand.prototype.execute = function(port) {
+ this._send("shell:EXTERNAL_STORAGE=/data/local/tmp monkey --port " + port + " -v");
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.searchLine(/^:Monkey:/).timeout(1000).then(function() {
+ return _this.parser.raw();
+ })["catch"](Promise.TimeoutError, function(err) {
+ return _this.parser.raw();
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return MonkeyCommand;
+
+ })(Command);
+
+ module.exports = MonkeyCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/reboot.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/reboot.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/reboot.js
new file mode 100644
index 0000000..57a8b51
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/reboot.js
@@ -0,0 +1,39 @@
+(function() {
+ var Command, Protocol, RebootCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ RebootCommand = (function(_super) {
+ __extends(RebootCommand, _super);
+
+ function RebootCommand() {
+ return RebootCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RebootCommand.prototype.execute = function() {
+ this._send('reboot:');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAll()["return"](true);
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return RebootCommand;
+
+ })(Command);
+
+ module.exports = RebootCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/remount.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/remount.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/remount.js
new file mode 100644
index 0000000..173f45d
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/remount.js
@@ -0,0 +1,39 @@
+(function() {
+ var Command, Protocol, RemountCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ RemountCommand = (function(_super) {
+ __extends(RemountCommand, _super);
+
+ function RemountCommand() {
+ return RemountCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RemountCommand.prototype.execute = function() {
+ this._send('remount:');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return true;
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return RemountCommand;
+
+ })(Command);
+
+ module.exports = RemountCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/screencap.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/screencap.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/screencap.js
new file mode 100644
index 0000000..30098c2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/screencap.js
@@ -0,0 +1,57 @@
+(function() {
+ var Command, LineTransform, Parser, Promise, Protocol, ScreencapCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Promise = require('bluebird');
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ Parser = require('../../parser');
+
+ LineTransform = require('../../linetransform');
+
+ ScreencapCommand = (function(_super) {
+ __extends(ScreencapCommand, _super);
+
+ function ScreencapCommand() {
+ return ScreencapCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ ScreencapCommand.prototype.execute = function() {
+ this._send('shell:screencap -p 2>/dev/null');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ var endListener, out, readableListener, resolver;
+ switch (reply) {
+ case Protocol.OKAY:
+ resolver = Promise.defer();
+ out = _this.parser.raw().pipe(new LineTransform);
+ out.on('readable', readableListener = function() {
+ return resolver.resolve(out);
+ });
+ out.on('end', endListener = function() {
+ return resolver.reject(new Error('Unable to run screencap command'));
+ });
+ return resolver.promise["finally"](function() {
+ out.removeListener('end', endListener);
+ return out.removeListener('readable', readableListener);
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return ScreencapCommand;
+
+ })(Command);
+
+ module.exports = ScreencapCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/shell.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/shell.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/shell.js
new file mode 100644
index 0000000..4ac2074
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/shell.js
@@ -0,0 +1,42 @@
+(function() {
+ var Command, Protocol, ShellCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ ShellCommand = (function(_super) {
+ __extends(ShellCommand, _super);
+
+ function ShellCommand() {
+ return ShellCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ ShellCommand.prototype.execute = function(command) {
+ if (Array.isArray(command)) {
+ command = command.map(this._escape).join(' ');
+ }
+ this._send("shell:" + command);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.raw();
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return ShellCommand;
+
+ })(Command);
+
+ module.exports = ShellCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/startactivity.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/startactivity.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/startactivity.js
new file mode 100644
index 0000000..572abda
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/startactivity.js
@@ -0,0 +1,187 @@
+(function() {
+ var Command, Parser, Protocol, StartActivityCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ Parser = require('../../parser');
+
+ StartActivityCommand = (function(_super) {
+ var EXTRA_TYPES, RE_ERROR;
+
+ __extends(StartActivityCommand, _super);
+
+ function StartActivityCommand() {
+ return StartActivityCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RE_ERROR = /^Error: (.*)$/;
+
+ EXTRA_TYPES = {
+ string: 's',
+ "null": 'sn',
+ bool: 'z',
+ int: 'i',
+ long: 'l',
+ float: 'l',
+ uri: 'u',
+ component: 'cn'
+ };
+
+ StartActivityCommand.prototype.execute = function(options) {
+ var args;
+ args = this._intentArgs(options);
+ if (options.debug) {
+ args.push('-D');
+ }
+ if (options.wait) {
+ args.push('-W');
+ }
+ if (options.user || options.user === 0) {
+ args.push('--user', this._escape(options.user));
+ }
+ return this._run('start', args);
+ };
+
+ StartActivityCommand.prototype._run = function(command, args) {
+ this._send("shell:am " + command + " " + (args.join(' ')));
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.searchLine(RE_ERROR)["finally"](function() {
+ return _this.connection.end();
+ }).then(function(match) {
+ throw new Error(match[1]);
+ })["catch"](Parser.PrematureEOFError, function(err) {
+ return true;
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ StartActivityCommand.prototype._intentArgs = function(options) {
+ var args;
+ args = [];
+ if (options.extras) {
+ args.push.apply(args, this._formatExtras(options.extras));
+ }
+ if (options.action) {
+ args.push('-a', this._escape(options.action));
+ }
+ if (options.data) {
+ args.push('-d', this._escape(options.data));
+ }
+ if (options.mimeType) {
+ args.push('-t', this._escape(options.mimeType));
+ }
+ if (options.category) {
+ if (Array.isArray(options.category)) {
+ options.category.forEach((function(_this) {
+ return function(category) {
+ return args.push('-c', _this._escape(category));
+ };
+ })(this));
+ } else {
+ args.push('-c', this._escape(options.category));
+ }
+ }
+ if (options.component) {
+ args.push('-n', this._escape(options.component));
+ }
+ if (options.flags) {
+ args.push('-f', this._escape(options.flags));
+ }
+ return args;
+ };
+
+ StartActivityCommand.prototype._formatExtras = function(extras) {
+ if (!extras) {
+ return [];
+ }
+ if (Array.isArray(extras)) {
+ return extras.reduce((function(_this) {
+ return function(all, extra) {
+ return all.concat(_this._formatLongExtra(extra));
+ };
+ })(this), []);
+ } else {
+ return Object.keys(extras).reduce((function(_this) {
+ return function(all, key) {
+ return all.concat(_this._formatShortExtra(key, extras[key]));
+ };
+ })(this), []);
+ }
+ };
+
+ StartActivityCommand.prototype._formatShortExtra = function(key, value) {
+ var sugared;
+ sugared = {
+ key: key
+ };
+ if (value === null) {
+ sugared.type = 'null';
+ } else if (Array.isArray(value)) {
+ throw new Error("Refusing to format array value '" + key + "' using short syntax; empty array would cause unpredictable results due to unknown type. Please use long syntax instead.");
+ } else {
+ switch (typeof value) {
+ case 'string':
+ sugared.type = 'string';
+ sugared.value = value;
+ break;
+ case 'boolean':
+ sugared.type = 'bool';
+ sugared.value = value;
+ break;
+ case 'number':
+ sugared.type = 'int';
+ sugared.value = value;
+ break;
+ case 'object':
+ sugared = value;
+ sugared.key = key;
+ }
+ }
+ return this._formatLongExtra(sugared);
+ };
+
+ StartActivityCommand.prototype._formatLongExtra = function(extra) {
+ var args, type;
+ args = [];
+ if (!extra.type) {
+ extra.type = 'string';
+ }
+ type = EXTRA_TYPES[extra.type];
+ if (!type) {
+ throw new Error("Unsupported type '" + extra.type + "' for extra '" + extra.key + "'");
+ }
+ if (extra.type === 'null') {
+ args.push("--e" + type);
+ args.push(this._escape(extra.key));
+ } else if (Array.isArray(extra.value)) {
+ args.push("--e" + type + "a");
+ args.push(this._escape(extra.key));
+ args.push(this._escape(extra.value.join(',')));
+ } else {
+ args.push("--e" + type);
+ args.push(this._escape(extra.key));
+ args.push(this._escape(extra.value));
+ }
+ return args;
+ };
+
+ return StartActivityCommand;
+
+ })(Command);
+
+ module.exports = StartActivityCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/startservice.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/startservice.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/startservice.js
new file mode 100644
index 0000000..a119a36
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/startservice.js
@@ -0,0 +1,36 @@
+(function() {
+ var Command, Parser, Protocol, StartActivityCommand, StartServiceCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ Parser = require('../../parser');
+
+ StartActivityCommand = require('./startactivity');
+
+ StartServiceCommand = (function(_super) {
+ __extends(StartServiceCommand, _super);
+
+ function StartServiceCommand() {
+ return StartServiceCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ StartServiceCommand.prototype.execute = function(options) {
+ var args;
+ args = this._intentArgs(options);
+ if (options.user || options.user === 0) {
+ args.push('--user', this._escape(options.user));
+ }
+ return this._run('startservice', args);
+ };
+
+ return StartServiceCommand;
+
+ })(StartActivityCommand);
+
+ module.exports = StartServiceCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/sync.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/sync.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/sync.js
new file mode 100644
index 0000000..638cc6e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/sync.js
@@ -0,0 +1,41 @@
+(function() {
+ var Command, Protocol, Sync, SyncCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ Sync = require('../../sync');
+
+ SyncCommand = (function(_super) {
+ __extends(SyncCommand, _super);
+
+ function SyncCommand() {
+ return SyncCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ SyncCommand.prototype.execute = function() {
+ this._send('sync:');
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return new Sync(_this.connection);
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return SyncCommand;
+
+ })(Command);
+
+ module.exports = SyncCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/tcp.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/tcp.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/tcp.js
new file mode 100644
index 0000000..05c7ec2
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/tcp.js
@@ -0,0 +1,39 @@
+(function() {
+ var Command, Protocol, TcpCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ TcpCommand = (function(_super) {
+ __extends(TcpCommand, _super);
+
+ function TcpCommand() {
+ return TcpCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ TcpCommand.prototype.execute = function(port, host) {
+ this._send(("tcp:" + port) + (host ? ":" + host : ''));
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.raw();
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return TcpCommand;
+
+ })(Command);
+
+ module.exports = TcpCommand;
+
+}).call(this);
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/tcpip.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/tcpip.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/tcpip.js
new file mode 100644
index 0000000..821b5fa
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/lib/adb/command/host-transport/tcpip.js
@@ -0,0 +1,51 @@
+(function() {
+ var Command, LineTransform, Protocol, TcpIpCommand,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Command = require('../../command');
+
+ Protocol = require('../../protocol');
+
+ LineTransform = require('../../linetransform');
+
+ TcpIpCommand = (function(_super) {
+ var RE_OK;
+
+ __extends(TcpIpCommand, _super);
+
+ function TcpIpCommand() {
+ return TcpIpCommand.__super__.constructor.apply(this, arguments);
+ }
+
+ RE_OK = /restarting in/;
+
+ TcpIpCommand.prototype.execute = function(port) {
+ this._send("tcpip:" + port);
+ return this.parser.readAscii(4).then((function(_this) {
+ return function(reply) {
+ switch (reply) {
+ case Protocol.OKAY:
+ return _this.parser.readAll().then(function(value) {
+ if (RE_OK.test(value)) {
+ return port;
+ } else {
+ throw new Error(value.toString().trim());
+ }
+ });
+ case Protocol.FAIL:
+ return _this.parser.readError();
+ default:
+ return _this.parser.unexpected(reply, 'OKAY or FAIL');
+ }
+ };
+ })(this));
+ };
+
+ return TcpIpCommand;
+
+ })(Command);
+
+ module.exports = TcpIpCommand;
+
+}).call(this);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org