Firebase Update
This commit is contained in:
		
							
								
								
									
										19
									
								
								express-server/node_modules/asn1/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								express-server/node_modules/asn1/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
Copyright (c) 2011 Mark Cavage, 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", 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
 | 
			
		||||
							
								
								
									
										50
									
								
								express-server/node_modules/asn1/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								express-server/node_modules/asn1/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
			
		||||
node-asn1 is a library for encoding and decoding ASN.1 datatypes in pure JS.
 | 
			
		||||
Currently BER encoding is supported; at some point I'll likely have to do DER.
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
Mostly, if you're *actually* needing to read and write ASN.1, you probably don't
 | 
			
		||||
need this readme to explain what and why.  If you have no idea what ASN.1 is,
 | 
			
		||||
see this: ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
 | 
			
		||||
 | 
			
		||||
The source is pretty much self-explanatory, and has read/write methods for the
 | 
			
		||||
common types out there.
 | 
			
		||||
 | 
			
		||||
### Decoding
 | 
			
		||||
 | 
			
		||||
The following reads an ASN.1 sequence with a boolean.
 | 
			
		||||
 | 
			
		||||
    var Ber = require('asn1').Ber;
 | 
			
		||||
 | 
			
		||||
    var reader = new Ber.Reader(Buffer.from([0x30, 0x03, 0x01, 0x01, 0xff]));
 | 
			
		||||
 | 
			
		||||
    reader.readSequence();
 | 
			
		||||
    console.log('Sequence len: ' + reader.length);
 | 
			
		||||
    if (reader.peek() === Ber.Boolean)
 | 
			
		||||
      console.log(reader.readBoolean());
 | 
			
		||||
 | 
			
		||||
### Encoding
 | 
			
		||||
 | 
			
		||||
The following generates the same payload as above.
 | 
			
		||||
 | 
			
		||||
    var Ber = require('asn1').Ber;
 | 
			
		||||
 | 
			
		||||
    var writer = new Ber.Writer();
 | 
			
		||||
 | 
			
		||||
    writer.startSequence();
 | 
			
		||||
    writer.writeBoolean(true);
 | 
			
		||||
    writer.endSequence();
 | 
			
		||||
 | 
			
		||||
    console.log(writer.buffer);
 | 
			
		||||
 | 
			
		||||
## Installation
 | 
			
		||||
 | 
			
		||||
    npm install asn1
 | 
			
		||||
 | 
			
		||||
## License
 | 
			
		||||
 | 
			
		||||
MIT.
 | 
			
		||||
 | 
			
		||||
## Bugs
 | 
			
		||||
 | 
			
		||||
See <https://github.com/joyent/node-asn1/issues>.
 | 
			
		||||
							
								
								
									
										13
									
								
								express-server/node_modules/asn1/lib/ber/errors.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								express-server/node_modules/asn1/lib/ber/errors.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
 | 
			
		||||
  newInvalidAsn1Error: function (msg) {
 | 
			
		||||
    var e = new Error();
 | 
			
		||||
    e.name = 'InvalidAsn1Error';
 | 
			
		||||
    e.message = msg || '';
 | 
			
		||||
    return e;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										27
									
								
								express-server/node_modules/asn1/lib/ber/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								express-server/node_modules/asn1/lib/ber/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
 | 
			
		||||
 | 
			
		||||
var errors = require('./errors');
 | 
			
		||||
var types = require('./types');
 | 
			
		||||
 | 
			
		||||
var Reader = require('./reader');
 | 
			
		||||
var Writer = require('./writer');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// --- Exports
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
 | 
			
		||||
  Reader: Reader,
 | 
			
		||||
 | 
			
		||||
  Writer: Writer
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
for (var t in types) {
 | 
			
		||||
  if (types.hasOwnProperty(t))
 | 
			
		||||
    module.exports[t] = types[t];
 | 
			
		||||
}
 | 
			
		||||
for (var e in errors) {
 | 
			
		||||
  if (errors.hasOwnProperty(e))
 | 
			
		||||
    module.exports[e] = errors[e];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										262
									
								
								express-server/node_modules/asn1/lib/ber/reader.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										262
									
								
								express-server/node_modules/asn1/lib/ber/reader.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,262 @@
 | 
			
		||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
 | 
			
		||||
 | 
			
		||||
var assert = require('assert');
 | 
			
		||||
var Buffer = require('safer-buffer').Buffer;
 | 
			
		||||
 | 
			
		||||
var ASN1 = require('./types');
 | 
			
		||||
var errors = require('./errors');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// --- Globals
 | 
			
		||||
 | 
			
		||||
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// --- API
 | 
			
		||||
 | 
			
		||||
function Reader(data) {
 | 
			
		||||
  if (!data || !Buffer.isBuffer(data))
 | 
			
		||||
    throw new TypeError('data must be a node Buffer');
 | 
			
		||||
 | 
			
		||||
  this._buf = data;
 | 
			
		||||
  this._size = data.length;
 | 
			
		||||
 | 
			
		||||
  // These hold the "current" state
 | 
			
		||||
  this._len = 0;
 | 
			
		||||
  this._offset = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Object.defineProperty(Reader.prototype, 'length', {
 | 
			
		||||
  enumerable: true,
 | 
			
		||||
  get: function () { return (this._len); }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
Object.defineProperty(Reader.prototype, 'offset', {
 | 
			
		||||
  enumerable: true,
 | 
			
		||||
  get: function () { return (this._offset); }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
Object.defineProperty(Reader.prototype, 'remain', {
 | 
			
		||||
  get: function () { return (this._size - this._offset); }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
Object.defineProperty(Reader.prototype, 'buffer', {
 | 
			
		||||
  get: function () { return (this._buf.slice(this._offset)); }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Reads a single byte and advances offset; you can pass in `true` to make this
 | 
			
		||||
 * a "peek" operation (i.e., get the byte, but don't advance the offset).
 | 
			
		||||
 *
 | 
			
		||||
 * @param {Boolean} peek true means don't move offset.
 | 
			
		||||
 * @return {Number} the next byte, null if not enough data.
 | 
			
		||||
 */
 | 
			
		||||
Reader.prototype.readByte = function (peek) {
 | 
			
		||||
  if (this._size - this._offset < 1)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  var b = this._buf[this._offset] & 0xff;
 | 
			
		||||
 | 
			
		||||
  if (!peek)
 | 
			
		||||
    this._offset += 1;
 | 
			
		||||
 | 
			
		||||
  return b;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Reader.prototype.peek = function () {
 | 
			
		||||
  return this.readByte(true);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Reads a (potentially) variable length off the BER buffer.  This call is
 | 
			
		||||
 * not really meant to be called directly, as callers have to manipulate
 | 
			
		||||
 * the internal buffer afterwards.
 | 
			
		||||
 *
 | 
			
		||||
 * As a result of this call, you can call `Reader.length`, until the
 | 
			
		||||
 * next thing called that does a readLength.
 | 
			
		||||
 *
 | 
			
		||||
 * @return {Number} the amount of offset to advance the buffer.
 | 
			
		||||
 * @throws {InvalidAsn1Error} on bad ASN.1
 | 
			
		||||
 */
 | 
			
		||||
Reader.prototype.readLength = function (offset) {
 | 
			
		||||
  if (offset === undefined)
 | 
			
		||||
    offset = this._offset;
 | 
			
		||||
 | 
			
		||||
  if (offset >= this._size)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  var lenB = this._buf[offset++] & 0xff;
 | 
			
		||||
  if (lenB === null)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  if ((lenB & 0x80) === 0x80) {
 | 
			
		||||
    lenB &= 0x7f;
 | 
			
		||||
 | 
			
		||||
    if (lenB === 0)
 | 
			
		||||
      throw newInvalidAsn1Error('Indefinite length not supported');
 | 
			
		||||
 | 
			
		||||
    if (lenB > 4)
 | 
			
		||||
      throw newInvalidAsn1Error('encoding too long');
 | 
			
		||||
 | 
			
		||||
    if (this._size - offset < lenB)
 | 
			
		||||
      return null;
 | 
			
		||||
 | 
			
		||||
    this._len = 0;
 | 
			
		||||
    for (var i = 0; i < lenB; i++)
 | 
			
		||||
      this._len = (this._len << 8) + (this._buf[offset++] & 0xff);
 | 
			
		||||
 | 
			
		||||
  } else {
 | 
			
		||||
    // Wasn't a variable length
 | 
			
		||||
    this._len = lenB;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return offset;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Parses the next sequence in this BER buffer.
 | 
			
		||||
 *
 | 
			
		||||
 * To get the length of the sequence, call `Reader.length`.
 | 
			
		||||
 *
 | 
			
		||||
 * @return {Number} the sequence's tag.
 | 
			
		||||
 */
 | 
			
		||||
Reader.prototype.readSequence = function (tag) {
 | 
			
		||||
  var seq = this.peek();
 | 
			
		||||
  if (seq === null)
 | 
			
		||||
    return null;
 | 
			
		||||
  if (tag !== undefined && tag !== seq)
 | 
			
		||||
    throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
 | 
			
		||||
                              ': got 0x' + seq.toString(16));
 | 
			
		||||
 | 
			
		||||
  var o = this.readLength(this._offset + 1); // stored in `length`
 | 
			
		||||
  if (o === null)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  this._offset = o;
 | 
			
		||||
  return seq;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Reader.prototype.readInt = function () {
 | 
			
		||||
  return this._readTag(ASN1.Integer);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Reader.prototype.readBoolean = function () {
 | 
			
		||||
  return (this._readTag(ASN1.Boolean) === 0 ? false : true);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Reader.prototype.readEnumeration = function () {
 | 
			
		||||
  return this._readTag(ASN1.Enumeration);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Reader.prototype.readString = function (tag, retbuf) {
 | 
			
		||||
  if (!tag)
 | 
			
		||||
    tag = ASN1.OctetString;
 | 
			
		||||
 | 
			
		||||
  var b = this.peek();
 | 
			
		||||
  if (b === null)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  if (b !== tag)
 | 
			
		||||
    throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
 | 
			
		||||
                              ': got 0x' + b.toString(16));
 | 
			
		||||
 | 
			
		||||
  var o = this.readLength(this._offset + 1); // stored in `length`
 | 
			
		||||
 | 
			
		||||
  if (o === null)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  if (this.length > this._size - o)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  this._offset = o;
 | 
			
		||||
 | 
			
		||||
  if (this.length === 0)
 | 
			
		||||
    return retbuf ? Buffer.alloc(0) : '';
 | 
			
		||||
 | 
			
		||||
  var str = this._buf.slice(this._offset, this._offset + this.length);
 | 
			
		||||
  this._offset += this.length;
 | 
			
		||||
 | 
			
		||||
  return retbuf ? str : str.toString('utf8');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Reader.prototype.readOID = function (tag) {
 | 
			
		||||
  if (!tag)
 | 
			
		||||
    tag = ASN1.OID;
 | 
			
		||||
 | 
			
		||||
  var b = this.readString(tag, true);
 | 
			
		||||
  if (b === null)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  var values = [];
 | 
			
		||||
  var value = 0;
 | 
			
		||||
 | 
			
		||||
  for (var i = 0; i < b.length; i++) {
 | 
			
		||||
    var byte = b[i] & 0xff;
 | 
			
		||||
 | 
			
		||||
    value <<= 7;
 | 
			
		||||
    value += byte & 0x7f;
 | 
			
		||||
    if ((byte & 0x80) === 0) {
 | 
			
		||||
      values.push(value);
 | 
			
		||||
      value = 0;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  value = values.shift();
 | 
			
		||||
  values.unshift(value % 40);
 | 
			
		||||
  values.unshift((value / 40) >> 0);
 | 
			
		||||
 | 
			
		||||
  return values.join('.');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Reader.prototype._readTag = function (tag) {
 | 
			
		||||
  assert.ok(tag !== undefined);
 | 
			
		||||
 | 
			
		||||
  var b = this.peek();
 | 
			
		||||
 | 
			
		||||
  if (b === null)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  if (b !== tag)
 | 
			
		||||
    throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
 | 
			
		||||
                              ': got 0x' + b.toString(16));
 | 
			
		||||
 | 
			
		||||
  var o = this.readLength(this._offset + 1); // stored in `length`
 | 
			
		||||
  if (o === null)
 | 
			
		||||
    return null;
 | 
			
		||||
 | 
			
		||||
  if (this.length > 4)
 | 
			
		||||
    throw newInvalidAsn1Error('Integer too long: ' + this.length);
 | 
			
		||||
 | 
			
		||||
  if (this.length > this._size - o)
 | 
			
		||||
    return null;
 | 
			
		||||
  this._offset = o;
 | 
			
		||||
 | 
			
		||||
  var fb = this._buf[this._offset];
 | 
			
		||||
  var value = 0;
 | 
			
		||||
 | 
			
		||||
  for (var i = 0; i < this.length; i++) {
 | 
			
		||||
    value <<= 8;
 | 
			
		||||
    value |= (this._buf[this._offset++] & 0xff);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ((fb & 0x80) === 0x80 && i !== 4)
 | 
			
		||||
    value -= (1 << (i * 8));
 | 
			
		||||
 | 
			
		||||
  return value >> 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// --- Exported API
 | 
			
		||||
 | 
			
		||||
module.exports = Reader;
 | 
			
		||||
							
								
								
									
										36
									
								
								express-server/node_modules/asn1/lib/ber/types.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								express-server/node_modules/asn1/lib/ber/types.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  EOC: 0,
 | 
			
		||||
  Boolean: 1,
 | 
			
		||||
  Integer: 2,
 | 
			
		||||
  BitString: 3,
 | 
			
		||||
  OctetString: 4,
 | 
			
		||||
  Null: 5,
 | 
			
		||||
  OID: 6,
 | 
			
		||||
  ObjectDescriptor: 7,
 | 
			
		||||
  External: 8,
 | 
			
		||||
  Real: 9, // float
 | 
			
		||||
  Enumeration: 10,
 | 
			
		||||
  PDV: 11,
 | 
			
		||||
  Utf8String: 12,
 | 
			
		||||
  RelativeOID: 13,
 | 
			
		||||
  Sequence: 16,
 | 
			
		||||
  Set: 17,
 | 
			
		||||
  NumericString: 18,
 | 
			
		||||
  PrintableString: 19,
 | 
			
		||||
  T61String: 20,
 | 
			
		||||
  VideotexString: 21,
 | 
			
		||||
  IA5String: 22,
 | 
			
		||||
  UTCTime: 23,
 | 
			
		||||
  GeneralizedTime: 24,
 | 
			
		||||
  GraphicString: 25,
 | 
			
		||||
  VisibleString: 26,
 | 
			
		||||
  GeneralString: 28,
 | 
			
		||||
  UniversalString: 29,
 | 
			
		||||
  CharacterString: 30,
 | 
			
		||||
  BMPString: 31,
 | 
			
		||||
  Constructor: 32,
 | 
			
		||||
  Context: 128
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										317
									
								
								express-server/node_modules/asn1/lib/ber/writer.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										317
									
								
								express-server/node_modules/asn1/lib/ber/writer.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,317 @@
 | 
			
		||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
 | 
			
		||||
 | 
			
		||||
var assert = require('assert');
 | 
			
		||||
var Buffer = require('safer-buffer').Buffer;
 | 
			
		||||
var ASN1 = require('./types');
 | 
			
		||||
var errors = require('./errors');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// --- Globals
 | 
			
		||||
 | 
			
		||||
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
 | 
			
		||||
 | 
			
		||||
var DEFAULT_OPTS = {
 | 
			
		||||
  size: 1024,
 | 
			
		||||
  growthFactor: 8
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// --- Helpers
 | 
			
		||||
 | 
			
		||||
function merge(from, to) {
 | 
			
		||||
  assert.ok(from);
 | 
			
		||||
  assert.equal(typeof (from), 'object');
 | 
			
		||||
  assert.ok(to);
 | 
			
		||||
  assert.equal(typeof (to), 'object');
 | 
			
		||||
 | 
			
		||||
  var keys = Object.getOwnPropertyNames(from);
 | 
			
		||||
  keys.forEach(function (key) {
 | 
			
		||||
    if (to[key])
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
    var value = Object.getOwnPropertyDescriptor(from, key);
 | 
			
		||||
    Object.defineProperty(to, key, value);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  return to;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// --- API
 | 
			
		||||
 | 
			
		||||
function Writer(options) {
 | 
			
		||||
  options = merge(DEFAULT_OPTS, options || {});
 | 
			
		||||
 | 
			
		||||
  this._buf = Buffer.alloc(options.size || 1024);
 | 
			
		||||
  this._size = this._buf.length;
 | 
			
		||||
  this._offset = 0;
 | 
			
		||||
  this._options = options;
 | 
			
		||||
 | 
			
		||||
  // A list of offsets in the buffer where we need to insert
 | 
			
		||||
  // sequence tag/len pairs.
 | 
			
		||||
  this._seq = [];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Object.defineProperty(Writer.prototype, 'buffer', {
 | 
			
		||||
  get: function () {
 | 
			
		||||
    if (this._seq.length)
 | 
			
		||||
      throw newInvalidAsn1Error(this._seq.length + ' unended sequence(s)');
 | 
			
		||||
 | 
			
		||||
    return (this._buf.slice(0, this._offset));
 | 
			
		||||
  }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
Writer.prototype.writeByte = function (b) {
 | 
			
		||||
  if (typeof (b) !== 'number')
 | 
			
		||||
    throw new TypeError('argument must be a Number');
 | 
			
		||||
 | 
			
		||||
  this._ensure(1);
 | 
			
		||||
  this._buf[this._offset++] = b;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype.writeInt = function (i, tag) {
 | 
			
		||||
  if (typeof (i) !== 'number')
 | 
			
		||||
    throw new TypeError('argument must be a Number');
 | 
			
		||||
  if (typeof (tag) !== 'number')
 | 
			
		||||
    tag = ASN1.Integer;
 | 
			
		||||
 | 
			
		||||
  var sz = 4;
 | 
			
		||||
 | 
			
		||||
  while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&
 | 
			
		||||
        (sz > 1)) {
 | 
			
		||||
    sz--;
 | 
			
		||||
    i <<= 8;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (sz > 4)
 | 
			
		||||
    throw newInvalidAsn1Error('BER ints cannot be > 0xffffffff');
 | 
			
		||||
 | 
			
		||||
  this._ensure(2 + sz);
 | 
			
		||||
  this._buf[this._offset++] = tag;
 | 
			
		||||
  this._buf[this._offset++] = sz;
 | 
			
		||||
 | 
			
		||||
  while (sz-- > 0) {
 | 
			
		||||
    this._buf[this._offset++] = ((i & 0xff000000) >>> 24);
 | 
			
		||||
    i <<= 8;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype.writeNull = function () {
 | 
			
		||||
  this.writeByte(ASN1.Null);
 | 
			
		||||
  this.writeByte(0x00);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype.writeEnumeration = function (i, tag) {
 | 
			
		||||
  if (typeof (i) !== 'number')
 | 
			
		||||
    throw new TypeError('argument must be a Number');
 | 
			
		||||
  if (typeof (tag) !== 'number')
 | 
			
		||||
    tag = ASN1.Enumeration;
 | 
			
		||||
 | 
			
		||||
  return this.writeInt(i, tag);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype.writeBoolean = function (b, tag) {
 | 
			
		||||
  if (typeof (b) !== 'boolean')
 | 
			
		||||
    throw new TypeError('argument must be a Boolean');
 | 
			
		||||
  if (typeof (tag) !== 'number')
 | 
			
		||||
    tag = ASN1.Boolean;
 | 
			
		||||
 | 
			
		||||
  this._ensure(3);
 | 
			
		||||
  this._buf[this._offset++] = tag;
 | 
			
		||||
  this._buf[this._offset++] = 0x01;
 | 
			
		||||
  this._buf[this._offset++] = b ? 0xff : 0x00;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype.writeString = function (s, tag) {
 | 
			
		||||
  if (typeof (s) !== 'string')
 | 
			
		||||
    throw new TypeError('argument must be a string (was: ' + typeof (s) + ')');
 | 
			
		||||
  if (typeof (tag) !== 'number')
 | 
			
		||||
    tag = ASN1.OctetString;
 | 
			
		||||
 | 
			
		||||
  var len = Buffer.byteLength(s);
 | 
			
		||||
  this.writeByte(tag);
 | 
			
		||||
  this.writeLength(len);
 | 
			
		||||
  if (len) {
 | 
			
		||||
    this._ensure(len);
 | 
			
		||||
    this._buf.write(s, this._offset);
 | 
			
		||||
    this._offset += len;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype.writeBuffer = function (buf, tag) {
 | 
			
		||||
  if (typeof (tag) !== 'number')
 | 
			
		||||
    throw new TypeError('tag must be a number');
 | 
			
		||||
  if (!Buffer.isBuffer(buf))
 | 
			
		||||
    throw new TypeError('argument must be a buffer');
 | 
			
		||||
 | 
			
		||||
  this.writeByte(tag);
 | 
			
		||||
  this.writeLength(buf.length);
 | 
			
		||||
  this._ensure(buf.length);
 | 
			
		||||
  buf.copy(this._buf, this._offset, 0, buf.length);
 | 
			
		||||
  this._offset += buf.length;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype.writeStringArray = function (strings) {
 | 
			
		||||
  if ((!strings instanceof Array))
 | 
			
		||||
    throw new TypeError('argument must be an Array[String]');
 | 
			
		||||
 | 
			
		||||
  var self = this;
 | 
			
		||||
  strings.forEach(function (s) {
 | 
			
		||||
    self.writeString(s);
 | 
			
		||||
  });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// This is really to solve DER cases, but whatever for now
 | 
			
		||||
Writer.prototype.writeOID = function (s, tag) {
 | 
			
		||||
  if (typeof (s) !== 'string')
 | 
			
		||||
    throw new TypeError('argument must be a string');
 | 
			
		||||
  if (typeof (tag) !== 'number')
 | 
			
		||||
    tag = ASN1.OID;
 | 
			
		||||
 | 
			
		||||
  if (!/^([0-9]+\.){3,}[0-9]+$/.test(s))
 | 
			
		||||
    throw new Error('argument is not a valid OID string');
 | 
			
		||||
 | 
			
		||||
  function encodeOctet(bytes, octet) {
 | 
			
		||||
    if (octet < 128) {
 | 
			
		||||
        bytes.push(octet);
 | 
			
		||||
    } else if (octet < 16384) {
 | 
			
		||||
        bytes.push((octet >>> 7) | 0x80);
 | 
			
		||||
        bytes.push(octet & 0x7F);
 | 
			
		||||
    } else if (octet < 2097152) {
 | 
			
		||||
      bytes.push((octet >>> 14) | 0x80);
 | 
			
		||||
      bytes.push(((octet >>> 7) | 0x80) & 0xFF);
 | 
			
		||||
      bytes.push(octet & 0x7F);
 | 
			
		||||
    } else if (octet < 268435456) {
 | 
			
		||||
      bytes.push((octet >>> 21) | 0x80);
 | 
			
		||||
      bytes.push(((octet >>> 14) | 0x80) & 0xFF);
 | 
			
		||||
      bytes.push(((octet >>> 7) | 0x80) & 0xFF);
 | 
			
		||||
      bytes.push(octet & 0x7F);
 | 
			
		||||
    } else {
 | 
			
		||||
      bytes.push(((octet >>> 28) | 0x80) & 0xFF);
 | 
			
		||||
      bytes.push(((octet >>> 21) | 0x80) & 0xFF);
 | 
			
		||||
      bytes.push(((octet >>> 14) | 0x80) & 0xFF);
 | 
			
		||||
      bytes.push(((octet >>> 7) | 0x80) & 0xFF);
 | 
			
		||||
      bytes.push(octet & 0x7F);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  var tmp = s.split('.');
 | 
			
		||||
  var bytes = [];
 | 
			
		||||
  bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));
 | 
			
		||||
  tmp.slice(2).forEach(function (b) {
 | 
			
		||||
    encodeOctet(bytes, parseInt(b, 10));
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  var self = this;
 | 
			
		||||
  this._ensure(2 + bytes.length);
 | 
			
		||||
  this.writeByte(tag);
 | 
			
		||||
  this.writeLength(bytes.length);
 | 
			
		||||
  bytes.forEach(function (b) {
 | 
			
		||||
    self.writeByte(b);
 | 
			
		||||
  });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype.writeLength = function (len) {
 | 
			
		||||
  if (typeof (len) !== 'number')
 | 
			
		||||
    throw new TypeError('argument must be a Number');
 | 
			
		||||
 | 
			
		||||
  this._ensure(4);
 | 
			
		||||
 | 
			
		||||
  if (len <= 0x7f) {
 | 
			
		||||
    this._buf[this._offset++] = len;
 | 
			
		||||
  } else if (len <= 0xff) {
 | 
			
		||||
    this._buf[this._offset++] = 0x81;
 | 
			
		||||
    this._buf[this._offset++] = len;
 | 
			
		||||
  } else if (len <= 0xffff) {
 | 
			
		||||
    this._buf[this._offset++] = 0x82;
 | 
			
		||||
    this._buf[this._offset++] = len >> 8;
 | 
			
		||||
    this._buf[this._offset++] = len;
 | 
			
		||||
  } else if (len <= 0xffffff) {
 | 
			
		||||
    this._buf[this._offset++] = 0x83;
 | 
			
		||||
    this._buf[this._offset++] = len >> 16;
 | 
			
		||||
    this._buf[this._offset++] = len >> 8;
 | 
			
		||||
    this._buf[this._offset++] = len;
 | 
			
		||||
  } else {
 | 
			
		||||
    throw newInvalidAsn1Error('Length too long (> 4 bytes)');
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Writer.prototype.startSequence = function (tag) {
 | 
			
		||||
  if (typeof (tag) !== 'number')
 | 
			
		||||
    tag = ASN1.Sequence | ASN1.Constructor;
 | 
			
		||||
 | 
			
		||||
  this.writeByte(tag);
 | 
			
		||||
  this._seq.push(this._offset);
 | 
			
		||||
  this._ensure(3);
 | 
			
		||||
  this._offset += 3;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype.endSequence = function () {
 | 
			
		||||
  var seq = this._seq.pop();
 | 
			
		||||
  var start = seq + 3;
 | 
			
		||||
  var len = this._offset - start;
 | 
			
		||||
 | 
			
		||||
  if (len <= 0x7f) {
 | 
			
		||||
    this._shift(start, len, -2);
 | 
			
		||||
    this._buf[seq] = len;
 | 
			
		||||
  } else if (len <= 0xff) {
 | 
			
		||||
    this._shift(start, len, -1);
 | 
			
		||||
    this._buf[seq] = 0x81;
 | 
			
		||||
    this._buf[seq + 1] = len;
 | 
			
		||||
  } else if (len <= 0xffff) {
 | 
			
		||||
    this._buf[seq] = 0x82;
 | 
			
		||||
    this._buf[seq + 1] = len >> 8;
 | 
			
		||||
    this._buf[seq + 2] = len;
 | 
			
		||||
  } else if (len <= 0xffffff) {
 | 
			
		||||
    this._shift(start, len, 1);
 | 
			
		||||
    this._buf[seq] = 0x83;
 | 
			
		||||
    this._buf[seq + 1] = len >> 16;
 | 
			
		||||
    this._buf[seq + 2] = len >> 8;
 | 
			
		||||
    this._buf[seq + 3] = len;
 | 
			
		||||
  } else {
 | 
			
		||||
    throw newInvalidAsn1Error('Sequence too long');
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Writer.prototype._shift = function (start, len, shift) {
 | 
			
		||||
  assert.ok(start !== undefined);
 | 
			
		||||
  assert.ok(len !== undefined);
 | 
			
		||||
  assert.ok(shift);
 | 
			
		||||
 | 
			
		||||
  this._buf.copy(this._buf, start + shift, start, start + len);
 | 
			
		||||
  this._offset += shift;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Writer.prototype._ensure = function (len) {
 | 
			
		||||
  assert.ok(len);
 | 
			
		||||
 | 
			
		||||
  if (this._size - this._offset < len) {
 | 
			
		||||
    var sz = this._size * this._options.growthFactor;
 | 
			
		||||
    if (sz - this._offset < len)
 | 
			
		||||
      sz += len;
 | 
			
		||||
 | 
			
		||||
    var buf = Buffer.alloc(sz);
 | 
			
		||||
 | 
			
		||||
    this._buf.copy(buf, 0, 0, this._offset);
 | 
			
		||||
    this._buf = buf;
 | 
			
		||||
    this._size = sz;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// --- Exported API
 | 
			
		||||
 | 
			
		||||
module.exports = Writer;
 | 
			
		||||
							
								
								
									
										20
									
								
								express-server/node_modules/asn1/lib/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								express-server/node_modules/asn1/lib/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
 | 
			
		||||
 | 
			
		||||
// If you have no idea what ASN.1 or BER is, see this:
 | 
			
		||||
// ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
 | 
			
		||||
 | 
			
		||||
var Ber = require('./ber/index');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// --- Exported API
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
 | 
			
		||||
  Ber: Ber,
 | 
			
		||||
 | 
			
		||||
  BerReader: Ber.Reader,
 | 
			
		||||
 | 
			
		||||
  BerWriter: Ber.Writer
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										75
									
								
								express-server/node_modules/asn1/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								express-server/node_modules/asn1/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
{
 | 
			
		||||
  "_from": "asn1@~0.2.3",
 | 
			
		||||
  "_id": "asn1@0.2.4",
 | 
			
		||||
  "_inBundle": false,
 | 
			
		||||
  "_integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
 | 
			
		||||
  "_location": "/asn1",
 | 
			
		||||
  "_phantomChildren": {},
 | 
			
		||||
  "_requested": {
 | 
			
		||||
    "type": "range",
 | 
			
		||||
    "registry": true,
 | 
			
		||||
    "raw": "asn1@~0.2.3",
 | 
			
		||||
    "name": "asn1",
 | 
			
		||||
    "escapedName": "asn1",
 | 
			
		||||
    "rawSpec": "~0.2.3",
 | 
			
		||||
    "saveSpec": null,
 | 
			
		||||
    "fetchSpec": "~0.2.3"
 | 
			
		||||
  },
 | 
			
		||||
  "_requiredBy": [
 | 
			
		||||
    "/sshpk"
 | 
			
		||||
  ],
 | 
			
		||||
  "_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
 | 
			
		||||
  "_shasum": "8d2475dfab553bb33e77b54e59e880bb8ce23136",
 | 
			
		||||
  "_spec": "asn1@~0.2.3",
 | 
			
		||||
  "_where": "D:\\Desktop\\Git\\Firebase\\SmartShopperFirebase\\node_modules\\sshpk",
 | 
			
		||||
  "author": {
 | 
			
		||||
    "name": "Joyent",
 | 
			
		||||
    "url": "joyent.com"
 | 
			
		||||
  },
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/joyent/node-asn1/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "bundleDependencies": false,
 | 
			
		||||
  "contributors": [
 | 
			
		||||
    {
 | 
			
		||||
      "name": "Mark Cavage",
 | 
			
		||||
      "email": "mcavage@gmail.com"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "David Gwynne",
 | 
			
		||||
      "email": "loki@animata.net"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "Yunong Xiao",
 | 
			
		||||
      "email": "yunong@joyent.com"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "name": "Alex Wilson",
 | 
			
		||||
      "email": "alex.wilson@joyent.com"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "safer-buffer": "~2.1.0"
 | 
			
		||||
  },
 | 
			
		||||
  "deprecated": false,
 | 
			
		||||
  "description": "Contains parsers and serializers for ASN.1 (currently BER only)",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "eslint": "2.13.1",
 | 
			
		||||
    "eslint-plugin-joyent": "~1.3.0",
 | 
			
		||||
    "faucet": "0.0.1",
 | 
			
		||||
    "istanbul": "^0.3.6",
 | 
			
		||||
    "tape": "^3.5.0"
 | 
			
		||||
  },
 | 
			
		||||
  "homepage": "https://github.com/joyent/node-asn1#readme",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "main": "lib/index.js",
 | 
			
		||||
  "name": "asn1",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "git://github.com/joyent/node-asn1.git"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "test": "tape ./test/ber/*.test.js"
 | 
			
		||||
  },
 | 
			
		||||
  "version": "0.2.4"
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user