sdfsdfs
This commit is contained in:
61
node_modules/asn1.js/lib/asn1/api.js
generated
vendored
Normal file
61
node_modules/asn1.js/lib/asn1/api.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
var asn1 = require('../asn1');
|
||||
var inherits = require('inherits');
|
||||
|
||||
var api = exports;
|
||||
|
||||
api.define = function define(name, body) {
|
||||
return new Entity(name, body);
|
||||
};
|
||||
|
||||
function Entity(name, body) {
|
||||
this.name = name;
|
||||
this.body = body;
|
||||
|
||||
this.decoders = {};
|
||||
this.encoders = {};
|
||||
};
|
||||
|
||||
Entity.prototype._createNamed = function createNamed(base) {
|
||||
var named;
|
||||
try {
|
||||
named = require('vm').runInThisContext(
|
||||
'(function ' + this.name + '(entity) {\n' +
|
||||
' this._initNamed(entity);\n' +
|
||||
'})'
|
||||
);
|
||||
} catch (e) {
|
||||
named = function (entity) {
|
||||
this._initNamed(entity);
|
||||
};
|
||||
}
|
||||
inherits(named, base);
|
||||
named.prototype._initNamed = function initnamed(entity) {
|
||||
base.call(this, entity);
|
||||
};
|
||||
|
||||
return new named(this);
|
||||
};
|
||||
|
||||
Entity.prototype._getDecoder = function _getDecoder(enc) {
|
||||
enc = enc || 'der';
|
||||
// Lazily create decoder
|
||||
if (!this.decoders.hasOwnProperty(enc))
|
||||
this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
|
||||
return this.decoders[enc];
|
||||
};
|
||||
|
||||
Entity.prototype.decode = function decode(data, enc, options) {
|
||||
return this._getDecoder(enc).decode(data, options);
|
||||
};
|
||||
|
||||
Entity.prototype._getEncoder = function _getEncoder(enc) {
|
||||
enc = enc || 'der';
|
||||
// Lazily create encoder
|
||||
if (!this.encoders.hasOwnProperty(enc))
|
||||
this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
|
||||
return this.encoders[enc];
|
||||
};
|
||||
|
||||
Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
|
||||
return this._getEncoder(enc).encode(data, reporter);
|
||||
};
|
Reference in New Issue
Block a user