mirror of
https://github.com/crazy-max/ghaction-import-gpg.git
synced 2024-11-25 14:31:03 -05:00
Fix code transpilation with openpgpjs (#9)
This commit is contained in:
parent
f551cecdaa
commit
1504429173
25 changed files with 5857 additions and 2 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,6 +1,9 @@
|
|||
/.dev
|
||||
node_modules/
|
||||
lib
|
||||
/lib
|
||||
/node_modules/*
|
||||
!/node_modules/asn1.js/
|
||||
!/node_modules/bn.js/
|
||||
!/node_modules/minimalistic-assert.js/
|
||||
|
||||
# Jetbrains
|
||||
/.idea
|
||||
|
|
27
node_modules/asn1.js/.eslintrc.js
generated
vendored
Normal file
27
node_modules/asn1.js/.eslintrc.js
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
module.exports = {
|
||||
'env': {
|
||||
'browser': false,
|
||||
'commonjs': true,
|
||||
'es6': true,
|
||||
'node': true
|
||||
},
|
||||
'extends': 'eslint:recommended',
|
||||
'rules': {
|
||||
'indent': [
|
||||
'error',
|
||||
2
|
||||
],
|
||||
'linebreak-style': [
|
||||
'error',
|
||||
'unix'
|
||||
],
|
||||
'quotes': [
|
||||
'error',
|
||||
'single'
|
||||
],
|
||||
'semi': [
|
||||
'error',
|
||||
'always'
|
||||
]
|
||||
}
|
||||
};
|
21
node_modules/asn1.js/LICENSE
generated
vendored
Normal file
21
node_modules/asn1.js/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Fedor Indutny
|
||||
|
||||
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.
|
100
node_modules/asn1.js/README.md
generated
vendored
Normal file
100
node_modules/asn1.js/README.md
generated
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
# ASN1.js
|
||||
|
||||
ASN.1 DER Encoder/Decoder and DSL.
|
||||
|
||||
## Example
|
||||
|
||||
Define model:
|
||||
|
||||
```javascript
|
||||
var asn = require('asn1.js');
|
||||
|
||||
var Human = asn.define('Human', function() {
|
||||
this.seq().obj(
|
||||
this.key('firstName').octstr(),
|
||||
this.key('lastName').octstr(),
|
||||
this.key('age').int(),
|
||||
this.key('gender').enum({ 0: 'male', 1: 'female' }),
|
||||
this.key('bio').seqof(Bio)
|
||||
);
|
||||
});
|
||||
|
||||
var Bio = asn.define('Bio', function() {
|
||||
this.seq().obj(
|
||||
this.key('time').gentime(),
|
||||
this.key('description').octstr()
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
Encode data:
|
||||
|
||||
```javascript
|
||||
var output = Human.encode({
|
||||
firstName: 'Thomas',
|
||||
lastName: 'Anderson',
|
||||
age: 28,
|
||||
gender: 'male',
|
||||
bio: [
|
||||
{
|
||||
time: +new Date('31 March 1999'),
|
||||
description: 'freedom of mind'
|
||||
}
|
||||
]
|
||||
}, 'der');
|
||||
```
|
||||
|
||||
Decode data:
|
||||
|
||||
```javascript
|
||||
var human = Human.decode(output, 'der');
|
||||
console.log(human);
|
||||
/*
|
||||
{ firstName: <Buffer 54 68 6f 6d 61 73>,
|
||||
lastName: <Buffer 41 6e 64 65 72 73 6f 6e>,
|
||||
age: 28,
|
||||
gender: 'male',
|
||||
bio:
|
||||
[ { time: 922820400000,
|
||||
description: <Buffer 66 72 65 65 64 6f 6d 20 6f 66 20 6d 69 6e 64> } ] }
|
||||
*/
|
||||
```
|
||||
|
||||
### Partial decode
|
||||
|
||||
Its possible to parse data without stopping on first error. In order to do it,
|
||||
you should call:
|
||||
|
||||
```javascript
|
||||
var human = Human.decode(output, 'der', { partial: true });
|
||||
console.log(human);
|
||||
/*
|
||||
{ result: { ... },
|
||||
errors: [ ... ] }
|
||||
*/
|
||||
```
|
||||
|
||||
#### LICENSE
|
||||
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
Copyright Fedor Indutny, 2017.
|
||||
|
||||
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.
|
11
node_modules/asn1.js/lib/asn1.js
generated
vendored
Normal file
11
node_modules/asn1.js/lib/asn1.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
const asn1 = exports;
|
||||
|
||||
asn1.bignum = require('bn.js');
|
||||
|
||||
asn1.define = require('./asn1/api').define;
|
||||
asn1.base = require('./asn1/base');
|
||||
asn1.constants = require('./asn1/constants');
|
||||
asn1.decoders = require('./asn1/decoders');
|
||||
asn1.encoders = require('./asn1/encoders');
|
57
node_modules/asn1.js/lib/asn1/api.js
generated
vendored
Normal file
57
node_modules/asn1.js/lib/asn1/api.js
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
'use strict';
|
||||
|
||||
const encoders = require('./encoders');
|
||||
const decoders = require('./decoders');
|
||||
const inherits = require('inherits');
|
||||
|
||||
const 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) {
|
||||
const name = this.name;
|
||||
|
||||
function Generated(entity) {
|
||||
this._initNamed(entity, name);
|
||||
}
|
||||
inherits(Generated, Base);
|
||||
Generated.prototype._initNamed = function _initNamed(entity, name) {
|
||||
Base.call(this, entity, name);
|
||||
};
|
||||
|
||||
return new Generated(this);
|
||||
};
|
||||
|
||||
Entity.prototype._getDecoder = function _getDecoder(enc) {
|
||||
enc = enc || 'der';
|
||||
// Lazily create decoder
|
||||
if (!this.decoders.hasOwnProperty(enc))
|
||||
this.decoders[enc] = this._createNamed(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(encoders[enc]);
|
||||
return this.encoders[enc];
|
||||
};
|
||||
|
||||
Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
|
||||
return this._getEncoder(enc).encode(data, reporter);
|
||||
};
|
153
node_modules/asn1.js/lib/asn1/base/buffer.js
generated
vendored
Normal file
153
node_modules/asn1.js/lib/asn1/base/buffer.js
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
'use strict';
|
||||
|
||||
const inherits = require('inherits');
|
||||
const Reporter = require('../base/reporter').Reporter;
|
||||
const Buffer = require('safer-buffer').Buffer;
|
||||
|
||||
function DecoderBuffer(base, options) {
|
||||
Reporter.call(this, options);
|
||||
if (!Buffer.isBuffer(base)) {
|
||||
this.error('Input not Buffer');
|
||||
return;
|
||||
}
|
||||
|
||||
this.base = base;
|
||||
this.offset = 0;
|
||||
this.length = base.length;
|
||||
}
|
||||
inherits(DecoderBuffer, Reporter);
|
||||
exports.DecoderBuffer = DecoderBuffer;
|
||||
|
||||
DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) {
|
||||
if (data instanceof DecoderBuffer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Or accept compatible API
|
||||
const isCompatible = typeof data === 'object' &&
|
||||
Buffer.isBuffer(data.base) &&
|
||||
data.constructor.name === 'DecoderBuffer' &&
|
||||
typeof data.offset === 'number' &&
|
||||
typeof data.length === 'number' &&
|
||||
typeof data.save === 'function' &&
|
||||
typeof data.restore === 'function' &&
|
||||
typeof data.isEmpty === 'function' &&
|
||||
typeof data.readUInt8 === 'function' &&
|
||||
typeof data.skip === 'function' &&
|
||||
typeof data.raw === 'function';
|
||||
|
||||
return isCompatible;
|
||||
};
|
||||
|
||||
DecoderBuffer.prototype.save = function save() {
|
||||
return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
|
||||
};
|
||||
|
||||
DecoderBuffer.prototype.restore = function restore(save) {
|
||||
// Return skipped data
|
||||
const res = new DecoderBuffer(this.base);
|
||||
res.offset = save.offset;
|
||||
res.length = this.offset;
|
||||
|
||||
this.offset = save.offset;
|
||||
Reporter.prototype.restore.call(this, save.reporter);
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
DecoderBuffer.prototype.isEmpty = function isEmpty() {
|
||||
return this.offset === this.length;
|
||||
};
|
||||
|
||||
DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
|
||||
if (this.offset + 1 <= this.length)
|
||||
return this.base.readUInt8(this.offset++, true);
|
||||
else
|
||||
return this.error(fail || 'DecoderBuffer overrun');
|
||||
};
|
||||
|
||||
DecoderBuffer.prototype.skip = function skip(bytes, fail) {
|
||||
if (!(this.offset + bytes <= this.length))
|
||||
return this.error(fail || 'DecoderBuffer overrun');
|
||||
|
||||
const res = new DecoderBuffer(this.base);
|
||||
|
||||
// Share reporter state
|
||||
res._reporterState = this._reporterState;
|
||||
|
||||
res.offset = this.offset;
|
||||
res.length = this.offset + bytes;
|
||||
this.offset += bytes;
|
||||
return res;
|
||||
};
|
||||
|
||||
DecoderBuffer.prototype.raw = function raw(save) {
|
||||
return this.base.slice(save ? save.offset : this.offset, this.length);
|
||||
};
|
||||
|
||||
function EncoderBuffer(value, reporter) {
|
||||
if (Array.isArray(value)) {
|
||||
this.length = 0;
|
||||
this.value = value.map(function(item) {
|
||||
if (!EncoderBuffer.isEncoderBuffer(item))
|
||||
item = new EncoderBuffer(item, reporter);
|
||||
this.length += item.length;
|
||||
return item;
|
||||
}, this);
|
||||
} else if (typeof value === 'number') {
|
||||
if (!(0 <= value && value <= 0xff))
|
||||
return reporter.error('non-byte EncoderBuffer value');
|
||||
this.value = value;
|
||||
this.length = 1;
|
||||
} else if (typeof value === 'string') {
|
||||
this.value = value;
|
||||
this.length = Buffer.byteLength(value);
|
||||
} else if (Buffer.isBuffer(value)) {
|
||||
this.value = value;
|
||||
this.length = value.length;
|
||||
} else {
|
||||
return reporter.error('Unsupported type: ' + typeof value);
|
||||
}
|
||||
}
|
||||
exports.EncoderBuffer = EncoderBuffer;
|
||||
|
||||
EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) {
|
||||
if (data instanceof EncoderBuffer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Or accept compatible API
|
||||
const isCompatible = typeof data === 'object' &&
|
||||
data.constructor.name === 'EncoderBuffer' &&
|
||||
typeof data.length === 'number' &&
|
||||
typeof data.join === 'function';
|
||||
|
||||
return isCompatible;
|
||||
};
|
||||
|
||||
EncoderBuffer.prototype.join = function join(out, offset) {
|
||||
if (!out)
|
||||
out = Buffer.alloc(this.length);
|
||||
if (!offset)
|
||||
offset = 0;
|
||||
|
||||
if (this.length === 0)
|
||||
return out;
|
||||
|
||||
if (Array.isArray(this.value)) {
|
||||
this.value.forEach(function(item) {
|
||||
item.join(out, offset);
|
||||
offset += item.length;
|
||||
});
|
||||
} else {
|
||||
if (typeof this.value === 'number')
|
||||
out[offset] = this.value;
|
||||
else if (typeof this.value === 'string')
|
||||
out.write(this.value, offset);
|
||||
else if (Buffer.isBuffer(this.value))
|
||||
this.value.copy(out, offset);
|
||||
offset += this.length;
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
8
node_modules/asn1.js/lib/asn1/base/index.js
generated
vendored
Normal file
8
node_modules/asn1.js/lib/asn1/base/index.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
const base = exports;
|
||||
|
||||
base.Reporter = require('./reporter').Reporter;
|
||||
base.DecoderBuffer = require('./buffer').DecoderBuffer;
|
||||
base.EncoderBuffer = require('./buffer').EncoderBuffer;
|
||||
base.Node = require('./node');
|
638
node_modules/asn1.js/lib/asn1/base/node.js
generated
vendored
Normal file
638
node_modules/asn1.js/lib/asn1/base/node.js
generated
vendored
Normal file
|
@ -0,0 +1,638 @@
|
|||
'use strict';
|
||||
|
||||
const Reporter = require('../base/reporter').Reporter;
|
||||
const EncoderBuffer = require('../base/buffer').EncoderBuffer;
|
||||
const DecoderBuffer = require('../base/buffer').DecoderBuffer;
|
||||
const assert = require('minimalistic-assert');
|
||||
|
||||
// Supported tags
|
||||
const tags = [
|
||||
'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
|
||||
'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
|
||||
'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
|
||||
'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
|
||||
];
|
||||
|
||||
// Public methods list
|
||||
const methods = [
|
||||
'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
|
||||
'any', 'contains'
|
||||
].concat(tags);
|
||||
|
||||
// Overrided methods list
|
||||
const overrided = [
|
||||
'_peekTag', '_decodeTag', '_use',
|
||||
'_decodeStr', '_decodeObjid', '_decodeTime',
|
||||
'_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
|
||||
|
||||
'_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
|
||||
'_encodeNull', '_encodeInt', '_encodeBool'
|
||||
];
|
||||
|
||||
function Node(enc, parent, name) {
|
||||
const state = {};
|
||||
this._baseState = state;
|
||||
|
||||
state.name = name;
|
||||
state.enc = enc;
|
||||
|
||||
state.parent = parent || null;
|
||||
state.children = null;
|
||||
|
||||
// State
|
||||
state.tag = null;
|
||||
state.args = null;
|
||||
state.reverseArgs = null;
|
||||
state.choice = null;
|
||||
state.optional = false;
|
||||
state.any = false;
|
||||
state.obj = false;
|
||||
state.use = null;
|
||||
state.useDecoder = null;
|
||||
state.key = null;
|
||||
state['default'] = null;
|
||||
state.explicit = null;
|
||||
state.implicit = null;
|
||||
state.contains = null;
|
||||
|
||||
// Should create new instance on each method
|
||||
if (!state.parent) {
|
||||
state.children = [];
|
||||
this._wrap();
|
||||
}
|
||||
}
|
||||
module.exports = Node;
|
||||
|
||||
const stateProps = [
|
||||
'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
|
||||
'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
|
||||
'implicit', 'contains'
|
||||
];
|
||||
|
||||
Node.prototype.clone = function clone() {
|
||||
const state = this._baseState;
|
||||
const cstate = {};
|
||||
stateProps.forEach(function(prop) {
|
||||
cstate[prop] = state[prop];
|
||||
});
|
||||
const res = new this.constructor(cstate.parent);
|
||||
res._baseState = cstate;
|
||||
return res;
|
||||
};
|
||||
|
||||
Node.prototype._wrap = function wrap() {
|
||||
const state = this._baseState;
|
||||
methods.forEach(function(method) {
|
||||
this[method] = function _wrappedMethod() {
|
||||
const clone = new this.constructor(this);
|
||||
state.children.push(clone);
|
||||
return clone[method].apply(clone, arguments);
|
||||
};
|
||||
}, this);
|
||||
};
|
||||
|
||||
Node.prototype._init = function init(body) {
|
||||
const state = this._baseState;
|
||||
|
||||
assert(state.parent === null);
|
||||
body.call(this);
|
||||
|
||||
// Filter children
|
||||
state.children = state.children.filter(function(child) {
|
||||
return child._baseState.parent === this;
|
||||
}, this);
|
||||
assert.equal(state.children.length, 1, 'Root node can have only one child');
|
||||
};
|
||||
|
||||
Node.prototype._useArgs = function useArgs(args) {
|
||||
const state = this._baseState;
|
||||
|
||||
// Filter children and args
|
||||
const children = args.filter(function(arg) {
|
||||
return arg instanceof this.constructor;
|
||||
}, this);
|
||||
args = args.filter(function(arg) {
|
||||
return !(arg instanceof this.constructor);
|
||||
}, this);
|
||||
|
||||
if (children.length !== 0) {
|
||||
assert(state.children === null);
|
||||
state.children = children;
|
||||
|
||||
// Replace parent to maintain backward link
|
||||
children.forEach(function(child) {
|
||||
child._baseState.parent = this;
|
||||
}, this);
|
||||
}
|
||||
if (args.length !== 0) {
|
||||
assert(state.args === null);
|
||||
state.args = args;
|
||||
state.reverseArgs = args.map(function(arg) {
|
||||
if (typeof arg !== 'object' || arg.constructor !== Object)
|
||||
return arg;
|
||||
|
||||
const res = {};
|
||||
Object.keys(arg).forEach(function(key) {
|
||||
if (key == (key | 0))
|
||||
key |= 0;
|
||||
const value = arg[key];
|
||||
res[value] = key;
|
||||
});
|
||||
return res;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Overrided methods
|
||||
//
|
||||
|
||||
overrided.forEach(function(method) {
|
||||
Node.prototype[method] = function _overrided() {
|
||||
const state = this._baseState;
|
||||
throw new Error(method + ' not implemented for encoding: ' + state.enc);
|
||||
};
|
||||
});
|
||||
|
||||
//
|
||||
// Public methods
|
||||
//
|
||||
|
||||
tags.forEach(function(tag) {
|
||||
Node.prototype[tag] = function _tagMethod() {
|
||||
const state = this._baseState;
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
|
||||
assert(state.tag === null);
|
||||
state.tag = tag;
|
||||
|
||||
this._useArgs(args);
|
||||
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
Node.prototype.use = function use(item) {
|
||||
assert(item);
|
||||
const state = this._baseState;
|
||||
|
||||
assert(state.use === null);
|
||||
state.use = item;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.optional = function optional() {
|
||||
const state = this._baseState;
|
||||
|
||||
state.optional = true;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.def = function def(val) {
|
||||
const state = this._baseState;
|
||||
|
||||
assert(state['default'] === null);
|
||||
state['default'] = val;
|
||||
state.optional = true;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.explicit = function explicit(num) {
|
||||
const state = this._baseState;
|
||||
|
||||
assert(state.explicit === null && state.implicit === null);
|
||||
state.explicit = num;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.implicit = function implicit(num) {
|
||||
const state = this._baseState;
|
||||
|
||||
assert(state.explicit === null && state.implicit === null);
|
||||
state.implicit = num;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.obj = function obj() {
|
||||
const state = this._baseState;
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
|
||||
state.obj = true;
|
||||
|
||||
if (args.length !== 0)
|
||||
this._useArgs(args);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.key = function key(newKey) {
|
||||
const state = this._baseState;
|
||||
|
||||
assert(state.key === null);
|
||||
state.key = newKey;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.any = function any() {
|
||||
const state = this._baseState;
|
||||
|
||||
state.any = true;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.choice = function choice(obj) {
|
||||
const state = this._baseState;
|
||||
|
||||
assert(state.choice === null);
|
||||
state.choice = obj;
|
||||
this._useArgs(Object.keys(obj).map(function(key) {
|
||||
return obj[key];
|
||||
}));
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.contains = function contains(item) {
|
||||
const state = this._baseState;
|
||||
|
||||
assert(state.use === null);
|
||||
state.contains = item;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
//
|
||||
// Decoding
|
||||
//
|
||||
|
||||
Node.prototype._decode = function decode(input, options) {
|
||||
const state = this._baseState;
|
||||
|
||||
// Decode root node
|
||||
if (state.parent === null)
|
||||
return input.wrapResult(state.children[0]._decode(input, options));
|
||||
|
||||
let result = state['default'];
|
||||
let present = true;
|
||||
|
||||
let prevKey = null;
|
||||
if (state.key !== null)
|
||||
prevKey = input.enterKey(state.key);
|
||||
|
||||
// Check if tag is there
|
||||
if (state.optional) {
|
||||
let tag = null;
|
||||
if (state.explicit !== null)
|
||||
tag = state.explicit;
|
||||
else if (state.implicit !== null)
|
||||
tag = state.implicit;
|
||||
else if (state.tag !== null)
|
||||
tag = state.tag;
|
||||
|
||||
if (tag === null && !state.any) {
|
||||
// Trial and Error
|
||||
const save = input.save();
|
||||
try {
|
||||
if (state.choice === null)
|
||||
this._decodeGeneric(state.tag, input, options);
|
||||
else
|
||||
this._decodeChoice(input, options);
|
||||
present = true;
|
||||
} catch (e) {
|
||||
present = false;
|
||||
}
|
||||
input.restore(save);
|
||||
} else {
|
||||
present = this._peekTag(input, tag, state.any);
|
||||
|
||||
if (input.isError(present))
|
||||
return present;
|
||||
}
|
||||
}
|
||||
|
||||
// Push object on stack
|
||||
let prevObj;
|
||||
if (state.obj && present)
|
||||
prevObj = input.enterObject();
|
||||
|
||||
if (present) {
|
||||
// Unwrap explicit values
|
||||
if (state.explicit !== null) {
|
||||
const explicit = this._decodeTag(input, state.explicit);
|
||||
if (input.isError(explicit))
|
||||
return explicit;
|
||||
input = explicit;
|
||||
}
|
||||
|
||||
const start = input.offset;
|
||||
|
||||
// Unwrap implicit and normal values
|
||||
if (state.use === null && state.choice === null) {
|
||||
let save;
|
||||
if (state.any)
|
||||
save = input.save();
|
||||
const body = this._decodeTag(
|
||||
input,
|
||||
state.implicit !== null ? state.implicit : state.tag,
|
||||
state.any
|
||||
);
|
||||
if (input.isError(body))
|
||||
return body;
|
||||
|
||||
if (state.any)
|
||||
result = input.raw(save);
|
||||
else
|
||||
input = body;
|
||||
}
|
||||
|
||||
if (options && options.track && state.tag !== null)
|
||||
options.track(input.path(), start, input.length, 'tagged');
|
||||
|
||||
if (options && options.track && state.tag !== null)
|
||||
options.track(input.path(), input.offset, input.length, 'content');
|
||||
|
||||
// Select proper method for tag
|
||||
if (state.any) {
|
||||
// no-op
|
||||
} else if (state.choice === null) {
|
||||
result = this._decodeGeneric(state.tag, input, options);
|
||||
} else {
|
||||
result = this._decodeChoice(input, options);
|
||||
}
|
||||
|
||||
if (input.isError(result))
|
||||
return result;
|
||||
|
||||
// Decode children
|
||||
if (!state.any && state.choice === null && state.children !== null) {
|
||||
state.children.forEach(function decodeChildren(child) {
|
||||
// NOTE: We are ignoring errors here, to let parser continue with other
|
||||
// parts of encoded data
|
||||
child._decode(input, options);
|
||||
});
|
||||
}
|
||||
|
||||
// Decode contained/encoded by schema, only in bit or octet strings
|
||||
if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
|
||||
const data = new DecoderBuffer(result);
|
||||
result = this._getUse(state.contains, input._reporterState.obj)
|
||||
._decode(data, options);
|
||||
}
|
||||
}
|
||||
|
||||
// Pop object
|
||||
if (state.obj && present)
|
||||
result = input.leaveObject(prevObj);
|
||||
|
||||
// Set key
|
||||
if (state.key !== null && (result !== null || present === true))
|
||||
input.leaveKey(prevKey, state.key, result);
|
||||
else if (prevKey !== null)
|
||||
input.exitKey(prevKey);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
|
||||
const state = this._baseState;
|
||||
|
||||
if (tag === 'seq' || tag === 'set')
|
||||
return null;
|
||||
if (tag === 'seqof' || tag === 'setof')
|
||||
return this._decodeList(input, tag, state.args[0], options);
|
||||
else if (/str$/.test(tag))
|
||||
return this._decodeStr(input, tag, options);
|
||||
else if (tag === 'objid' && state.args)
|
||||
return this._decodeObjid(input, state.args[0], state.args[1], options);
|
||||
else if (tag === 'objid')
|
||||
return this._decodeObjid(input, null, null, options);
|
||||
else if (tag === 'gentime' || tag === 'utctime')
|
||||
return this._decodeTime(input, tag, options);
|
||||
else if (tag === 'null_')
|
||||
return this._decodeNull(input, options);
|
||||
else if (tag === 'bool')
|
||||
return this._decodeBool(input, options);
|
||||
else if (tag === 'objDesc')
|
||||
return this._decodeStr(input, tag, options);
|
||||
else if (tag === 'int' || tag === 'enum')
|
||||
return this._decodeInt(input, state.args && state.args[0], options);
|
||||
|
||||
if (state.use !== null) {
|
||||
return this._getUse(state.use, input._reporterState.obj)
|
||||
._decode(input, options);
|
||||
} else {
|
||||
return input.error('unknown tag: ' + tag);
|
||||
}
|
||||
};
|
||||
|
||||
Node.prototype._getUse = function _getUse(entity, obj) {
|
||||
|
||||
const state = this._baseState;
|
||||
// Create altered use decoder if implicit is set
|
||||
state.useDecoder = this._use(entity, obj);
|
||||
assert(state.useDecoder._baseState.parent === null);
|
||||
state.useDecoder = state.useDecoder._baseState.children[0];
|
||||
if (state.implicit !== state.useDecoder._baseState.implicit) {
|
||||
state.useDecoder = state.useDecoder.clone();
|
||||
state.useDecoder._baseState.implicit = state.implicit;
|
||||
}
|
||||
return state.useDecoder;
|
||||
};
|
||||
|
||||
Node.prototype._decodeChoice = function decodeChoice(input, options) {
|
||||
const state = this._baseState;
|
||||
let result = null;
|
||||
let match = false;
|
||||
|
||||
Object.keys(state.choice).some(function(key) {
|
||||
const save = input.save();
|
||||
const node = state.choice[key];
|
||||
try {
|
||||
const value = node._decode(input, options);
|
||||
if (input.isError(value))
|
||||
return false;
|
||||
|
||||
result = { type: key, value: value };
|
||||
match = true;
|
||||
} catch (e) {
|
||||
input.restore(save);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
if (!match)
|
||||
return input.error('Choice not matched');
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
//
|
||||
// Encoding
|
||||
//
|
||||
|
||||
Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
|
||||
return new EncoderBuffer(data, this.reporter);
|
||||
};
|
||||
|
||||
Node.prototype._encode = function encode(data, reporter, parent) {
|
||||
const state = this._baseState;
|
||||
if (state['default'] !== null && state['default'] === data)
|
||||
return;
|
||||
|
||||
const result = this._encodeValue(data, reporter, parent);
|
||||
if (result === undefined)
|
||||
return;
|
||||
|
||||
if (this._skipDefault(result, reporter, parent))
|
||||
return;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Node.prototype._encodeValue = function encode(data, reporter, parent) {
|
||||
const state = this._baseState;
|
||||
|
||||
// Decode root node
|
||||
if (state.parent === null)
|
||||
return state.children[0]._encode(data, reporter || new Reporter());
|
||||
|
||||
let result = null;
|
||||
|
||||
// Set reporter to share it with a child class
|
||||
this.reporter = reporter;
|
||||
|
||||
// Check if data is there
|
||||
if (state.optional && data === undefined) {
|
||||
if (state['default'] !== null)
|
||||
data = state['default'];
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
// Encode children first
|
||||
let content = null;
|
||||
let primitive = false;
|
||||
if (state.any) {
|
||||
// Anything that was given is translated to buffer
|
||||
result = this._createEncoderBuffer(data);
|
||||
} else if (state.choice) {
|
||||
result = this._encodeChoice(data, reporter);
|
||||
} else if (state.contains) {
|
||||
content = this._getUse(state.contains, parent)._encode(data, reporter);
|
||||
primitive = true;
|
||||
} else if (state.children) {
|
||||
content = state.children.map(function(child) {
|
||||
if (child._baseState.tag === 'null_')
|
||||
return child._encode(null, reporter, data);
|
||||
|
||||
if (child._baseState.key === null)
|
||||
return reporter.error('Child should have a key');
|
||||
const prevKey = reporter.enterKey(child._baseState.key);
|
||||
|
||||
if (typeof data !== 'object')
|
||||
return reporter.error('Child expected, but input is not object');
|
||||
|
||||
const res = child._encode(data[child._baseState.key], reporter, data);
|
||||
reporter.leaveKey(prevKey);
|
||||
|
||||
return res;
|
||||
}, this).filter(function(child) {
|
||||
return child;
|
||||
});
|
||||
content = this._createEncoderBuffer(content);
|
||||
} else {
|
||||
if (state.tag === 'seqof' || state.tag === 'setof') {
|
||||
// TODO(indutny): this should be thrown on DSL level
|
||||
if (!(state.args && state.args.length === 1))
|
||||
return reporter.error('Too many args for : ' + state.tag);
|
||||
|
||||
if (!Array.isArray(data))
|
||||
return reporter.error('seqof/setof, but data is not Array');
|
||||
|
||||
const child = this.clone();
|
||||
child._baseState.implicit = null;
|
||||
content = this._createEncoderBuffer(data.map(function(item) {
|
||||
const state = this._baseState;
|
||||
|
||||
return this._getUse(state.args[0], data)._encode(item, reporter);
|
||||
}, child));
|
||||
} else if (state.use !== null) {
|
||||
result = this._getUse(state.use, parent)._encode(data, reporter);
|
||||
} else {
|
||||
content = this._encodePrimitive(state.tag, data);
|
||||
primitive = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Encode data itself
|
||||
if (!state.any && state.choice === null) {
|
||||
const tag = state.implicit !== null ? state.implicit : state.tag;
|
||||
const cls = state.implicit === null ? 'universal' : 'context';
|
||||
|
||||
if (tag === null) {
|
||||
if (state.use === null)
|
||||
reporter.error('Tag could be omitted only for .use()');
|
||||
} else {
|
||||
if (state.use === null)
|
||||
result = this._encodeComposite(tag, primitive, cls, content);
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap in explicit
|
||||
if (state.explicit !== null)
|
||||
result = this._encodeComposite(state.explicit, false, 'context', result);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
|
||||
const state = this._baseState;
|
||||
|
||||
const node = state.choice[data.type];
|
||||
if (!node) {
|
||||
assert(
|
||||
false,
|
||||
data.type + ' not found in ' +
|
||||
JSON.stringify(Object.keys(state.choice)));
|
||||
}
|
||||
return node._encode(data.value, reporter);
|
||||
};
|
||||
|
||||
Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
|
||||
const state = this._baseState;
|
||||
|
||||
if (/str$/.test(tag))
|
||||
return this._encodeStr(data, tag);
|
||||
else if (tag === 'objid' && state.args)
|
||||
return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
|
||||
else if (tag === 'objid')
|
||||
return this._encodeObjid(data, null, null);
|
||||
else if (tag === 'gentime' || tag === 'utctime')
|
||||
return this._encodeTime(data, tag);
|
||||
else if (tag === 'null_')
|
||||
return this._encodeNull();
|
||||
else if (tag === 'int' || tag === 'enum')
|
||||
return this._encodeInt(data, state.args && state.reverseArgs[0]);
|
||||
else if (tag === 'bool')
|
||||
return this._encodeBool(data);
|
||||
else if (tag === 'objDesc')
|
||||
return this._encodeStr(data, tag);
|
||||
else
|
||||
throw new Error('Unsupported tag: ' + tag);
|
||||
};
|
||||
|
||||
Node.prototype._isNumstr = function isNumstr(str) {
|
||||
return /^[0-9 ]*$/.test(str);
|
||||
};
|
||||
|
||||
Node.prototype._isPrintstr = function isPrintstr(str) {
|
||||
return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str);
|
||||
};
|
123
node_modules/asn1.js/lib/asn1/base/reporter.js
generated
vendored
Normal file
123
node_modules/asn1.js/lib/asn1/base/reporter.js
generated
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
'use strict';
|
||||
|
||||
const inherits = require('inherits');
|
||||
|
||||
function Reporter(options) {
|
||||
this._reporterState = {
|
||||
obj: null,
|
||||
path: [],
|
||||
options: options || {},
|
||||
errors: []
|
||||
};
|
||||
}
|
||||
exports.Reporter = Reporter;
|
||||
|
||||
Reporter.prototype.isError = function isError(obj) {
|
||||
return obj instanceof ReporterError;
|
||||
};
|
||||
|
||||
Reporter.prototype.save = function save() {
|
||||
const state = this._reporterState;
|
||||
|
||||
return { obj: state.obj, pathLen: state.path.length };
|
||||
};
|
||||
|
||||
Reporter.prototype.restore = function restore(data) {
|
||||
const state = this._reporterState;
|
||||
|
||||
state.obj = data.obj;
|
||||
state.path = state.path.slice(0, data.pathLen);
|
||||
};
|
||||
|
||||
Reporter.prototype.enterKey = function enterKey(key) {
|
||||
return this._reporterState.path.push(key);
|
||||
};
|
||||
|
||||
Reporter.prototype.exitKey = function exitKey(index) {
|
||||
const state = this._reporterState;
|
||||
|
||||
state.path = state.path.slice(0, index - 1);
|
||||
};
|
||||
|
||||
Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
|
||||
const state = this._reporterState;
|
||||
|
||||
this.exitKey(index);
|
||||
if (state.obj !== null)
|
||||
state.obj[key] = value;
|
||||
};
|
||||
|
||||
Reporter.prototype.path = function path() {
|
||||
return this._reporterState.path.join('/');
|
||||
};
|
||||
|
||||
Reporter.prototype.enterObject = function enterObject() {
|
||||
const state = this._reporterState;
|
||||
|
||||
const prev = state.obj;
|
||||
state.obj = {};
|
||||
return prev;
|
||||
};
|
||||
|
||||
Reporter.prototype.leaveObject = function leaveObject(prev) {
|
||||
const state = this._reporterState;
|
||||
|
||||
const now = state.obj;
|
||||
state.obj = prev;
|
||||
return now;
|
||||
};
|
||||
|
||||
Reporter.prototype.error = function error(msg) {
|
||||
let err;
|
||||
const state = this._reporterState;
|
||||
|
||||
const inherited = msg instanceof ReporterError;
|
||||
if (inherited) {
|
||||
err = msg;
|
||||
} else {
|
||||
err = new ReporterError(state.path.map(function(elem) {
|
||||
return '[' + JSON.stringify(elem) + ']';
|
||||
}).join(''), msg.message || msg, msg.stack);
|
||||
}
|
||||
|
||||
if (!state.options.partial)
|
||||
throw err;
|
||||
|
||||
if (!inherited)
|
||||
state.errors.push(err);
|
||||
|
||||
return err;
|
||||
};
|
||||
|
||||
Reporter.prototype.wrapResult = function wrapResult(result) {
|
||||
const state = this._reporterState;
|
||||
if (!state.options.partial)
|
||||
return result;
|
||||
|
||||
return {
|
||||
result: this.isError(result) ? null : result,
|
||||
errors: state.errors
|
||||
};
|
||||
};
|
||||
|
||||
function ReporterError(path, msg) {
|
||||
this.path = path;
|
||||
this.rethrow(msg);
|
||||
}
|
||||
inherits(ReporterError, Error);
|
||||
|
||||
ReporterError.prototype.rethrow = function rethrow(msg) {
|
||||
this.message = msg + ' at: ' + (this.path || '(shallow)');
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, ReporterError);
|
||||
|
||||
if (!this.stack) {
|
||||
try {
|
||||
// IE only adds stack when thrown
|
||||
throw new Error(this.message);
|
||||
} catch (e) {
|
||||
this.stack = e.stack;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
58
node_modules/asn1.js/lib/asn1/constants/der.js
generated
vendored
Normal file
58
node_modules/asn1.js/lib/asn1/constants/der.js
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
'use strict';
|
||||
|
||||
// Helper
|
||||
function reverse(map) {
|
||||
const res = {};
|
||||
|
||||
Object.keys(map).forEach(function(key) {
|
||||
// Convert key to integer if it is stringified
|
||||
if ((key | 0) == key)
|
||||
key = key | 0;
|
||||
|
||||
const value = map[key];
|
||||
res[value] = key;
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
exports.tagClass = {
|
||||
0: 'universal',
|
||||
1: 'application',
|
||||
2: 'context',
|
||||
3: 'private'
|
||||
};
|
||||
exports.tagClassByName = reverse(exports.tagClass);
|
||||
|
||||
exports.tag = {
|
||||
0x00: 'end',
|
||||
0x01: 'bool',
|
||||
0x02: 'int',
|
||||
0x03: 'bitstr',
|
||||
0x04: 'octstr',
|
||||
0x05: 'null_',
|
||||
0x06: 'objid',
|
||||
0x07: 'objDesc',
|
||||
0x08: 'external',
|
||||
0x09: 'real',
|
||||
0x0a: 'enum',
|
||||
0x0b: 'embed',
|
||||
0x0c: 'utf8str',
|
||||
0x0d: 'relativeOid',
|
||||
0x10: 'seq',
|
||||
0x11: 'set',
|
||||
0x12: 'numstr',
|
||||
0x13: 'printstr',
|
||||
0x14: 't61str',
|
||||
0x15: 'videostr',
|
||||
0x16: 'ia5str',
|
||||
0x17: 'utctime',
|
||||
0x18: 'gentime',
|
||||
0x19: 'graphstr',
|
||||
0x1a: 'iso646str',
|
||||
0x1b: 'genstr',
|
||||
0x1c: 'unistr',
|
||||
0x1d: 'charstr',
|
||||
0x1e: 'bmpstr'
|
||||
};
|
||||
exports.tagByName = reverse(exports.tag);
|
21
node_modules/asn1.js/lib/asn1/constants/index.js
generated
vendored
Normal file
21
node_modules/asn1.js/lib/asn1/constants/index.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
const constants = exports;
|
||||
|
||||
// Helper
|
||||
constants._reverse = function reverse(map) {
|
||||
const res = {};
|
||||
|
||||
Object.keys(map).forEach(function(key) {
|
||||
// Convert key to integer if it is stringified
|
||||
if ((key | 0) == key)
|
||||
key = key | 0;
|
||||
|
||||
const value = map[key];
|
||||
res[value] = key;
|
||||
});
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
constants.der = require('./der');
|
335
node_modules/asn1.js/lib/asn1/decoders/der.js
generated
vendored
Normal file
335
node_modules/asn1.js/lib/asn1/decoders/der.js
generated
vendored
Normal file
|
@ -0,0 +1,335 @@
|
|||
'use strict';
|
||||
|
||||
const inherits = require('inherits');
|
||||
|
||||
const bignum = require('bn.js');
|
||||
const DecoderBuffer = require('../base/buffer').DecoderBuffer;
|
||||
const Node = require('../base/node');
|
||||
|
||||
// Import DER constants
|
||||
const der = require('../constants/der');
|
||||
|
||||
function DERDecoder(entity) {
|
||||
this.enc = 'der';
|
||||
this.name = entity.name;
|
||||
this.entity = entity;
|
||||
|
||||
// Construct base tree
|
||||
this.tree = new DERNode();
|
||||
this.tree._init(entity.body);
|
||||
}
|
||||
module.exports = DERDecoder;
|
||||
|
||||
DERDecoder.prototype.decode = function decode(data, options) {
|
||||
if (!DecoderBuffer.isDecoderBuffer(data)) {
|
||||
data = new DecoderBuffer(data, options);
|
||||
}
|
||||
|
||||
return this.tree._decode(data, options);
|
||||
};
|
||||
|
||||
// Tree methods
|
||||
|
||||
function DERNode(parent) {
|
||||
Node.call(this, 'der', parent);
|
||||
}
|
||||
inherits(DERNode, Node);
|
||||
|
||||
DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
|
||||
if (buffer.isEmpty())
|
||||
return false;
|
||||
|
||||
const state = buffer.save();
|
||||
const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
|
||||
if (buffer.isError(decodedTag))
|
||||
return decodedTag;
|
||||
|
||||
buffer.restore(state);
|
||||
|
||||
return decodedTag.tag === tag || decodedTag.tagStr === tag ||
|
||||
(decodedTag.tagStr + 'of') === tag || any;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
|
||||
const decodedTag = derDecodeTag(buffer,
|
||||
'Failed to decode tag of "' + tag + '"');
|
||||
if (buffer.isError(decodedTag))
|
||||
return decodedTag;
|
||||
|
||||
let len = derDecodeLen(buffer,
|
||||
decodedTag.primitive,
|
||||
'Failed to get length of "' + tag + '"');
|
||||
|
||||
// Failure
|
||||
if (buffer.isError(len))
|
||||
return len;
|
||||
|
||||
if (!any &&
|
||||
decodedTag.tag !== tag &&
|
||||
decodedTag.tagStr !== tag &&
|
||||
decodedTag.tagStr + 'of' !== tag) {
|
||||
return buffer.error('Failed to match tag: "' + tag + '"');
|
||||
}
|
||||
|
||||
if (decodedTag.primitive || len !== null)
|
||||
return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
|
||||
|
||||
// Indefinite length... find END tag
|
||||
const state = buffer.save();
|
||||
const res = this._skipUntilEnd(
|
||||
buffer,
|
||||
'Failed to skip indefinite length body: "' + this.tag + '"');
|
||||
if (buffer.isError(res))
|
||||
return res;
|
||||
|
||||
len = buffer.offset - state.offset;
|
||||
buffer.restore(state);
|
||||
return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
|
||||
};
|
||||
|
||||
DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
|
||||
for (;;) {
|
||||
const tag = derDecodeTag(buffer, fail);
|
||||
if (buffer.isError(tag))
|
||||
return tag;
|
||||
const len = derDecodeLen(buffer, tag.primitive, fail);
|
||||
if (buffer.isError(len))
|
||||
return len;
|
||||
|
||||
let res;
|
||||
if (tag.primitive || len !== null)
|
||||
res = buffer.skip(len);
|
||||
else
|
||||
res = this._skipUntilEnd(buffer, fail);
|
||||
|
||||
// Failure
|
||||
if (buffer.isError(res))
|
||||
return res;
|
||||
|
||||
if (tag.tagStr === 'end')
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
|
||||
options) {
|
||||
const result = [];
|
||||
while (!buffer.isEmpty()) {
|
||||
const possibleEnd = this._peekTag(buffer, 'end');
|
||||
if (buffer.isError(possibleEnd))
|
||||
return possibleEnd;
|
||||
|
||||
const res = decoder.decode(buffer, 'der', options);
|
||||
if (buffer.isError(res) && possibleEnd)
|
||||
break;
|
||||
result.push(res);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
|
||||
if (tag === 'bitstr') {
|
||||
const unused = buffer.readUInt8();
|
||||
if (buffer.isError(unused))
|
||||
return unused;
|
||||
return { unused: unused, data: buffer.raw() };
|
||||
} else if (tag === 'bmpstr') {
|
||||
const raw = buffer.raw();
|
||||
if (raw.length % 2 === 1)
|
||||
return buffer.error('Decoding of string type: bmpstr length mismatch');
|
||||
|
||||
let str = '';
|
||||
for (let i = 0; i < raw.length / 2; i++) {
|
||||
str += String.fromCharCode(raw.readUInt16BE(i * 2));
|
||||
}
|
||||
return str;
|
||||
} else if (tag === 'numstr') {
|
||||
const numstr = buffer.raw().toString('ascii');
|
||||
if (!this._isNumstr(numstr)) {
|
||||
return buffer.error('Decoding of string type: ' +
|
||||
'numstr unsupported characters');
|
||||
}
|
||||
return numstr;
|
||||
} else if (tag === 'octstr') {
|
||||
return buffer.raw();
|
||||
} else if (tag === 'objDesc') {
|
||||
return buffer.raw();
|
||||
} else if (tag === 'printstr') {
|
||||
const printstr = buffer.raw().toString('ascii');
|
||||
if (!this._isPrintstr(printstr)) {
|
||||
return buffer.error('Decoding of string type: ' +
|
||||
'printstr unsupported characters');
|
||||
}
|
||||
return printstr;
|
||||
} else if (/str$/.test(tag)) {
|
||||
return buffer.raw().toString();
|
||||
} else {
|
||||
return buffer.error('Decoding of string type: ' + tag + ' unsupported');
|
||||
}
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
|
||||
let result;
|
||||
const identifiers = [];
|
||||
let ident = 0;
|
||||
let subident = 0;
|
||||
while (!buffer.isEmpty()) {
|
||||
subident = buffer.readUInt8();
|
||||
ident <<= 7;
|
||||
ident |= subident & 0x7f;
|
||||
if ((subident & 0x80) === 0) {
|
||||
identifiers.push(ident);
|
||||
ident = 0;
|
||||
}
|
||||
}
|
||||
if (subident & 0x80)
|
||||
identifiers.push(ident);
|
||||
|
||||
const first = (identifiers[0] / 40) | 0;
|
||||
const second = identifiers[0] % 40;
|
||||
|
||||
if (relative)
|
||||
result = identifiers;
|
||||
else
|
||||
result = [first, second].concat(identifiers.slice(1));
|
||||
|
||||
if (values) {
|
||||
let tmp = values[result.join(' ')];
|
||||
if (tmp === undefined)
|
||||
tmp = values[result.join('.')];
|
||||
if (tmp !== undefined)
|
||||
result = tmp;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
|
||||
const str = buffer.raw().toString();
|
||||
|
||||
let year;
|
||||
let mon;
|
||||
let day;
|
||||
let hour;
|
||||
let min;
|
||||
let sec;
|
||||
if (tag === 'gentime') {
|
||||
year = str.slice(0, 4) | 0;
|
||||
mon = str.slice(4, 6) | 0;
|
||||
day = str.slice(6, 8) | 0;
|
||||
hour = str.slice(8, 10) | 0;
|
||||
min = str.slice(10, 12) | 0;
|
||||
sec = str.slice(12, 14) | 0;
|
||||
} else if (tag === 'utctime') {
|
||||
year = str.slice(0, 2) | 0;
|
||||
mon = str.slice(2, 4) | 0;
|
||||
day = str.slice(4, 6) | 0;
|
||||
hour = str.slice(6, 8) | 0;
|
||||
min = str.slice(8, 10) | 0;
|
||||
sec = str.slice(10, 12) | 0;
|
||||
if (year < 70)
|
||||
year = 2000 + year;
|
||||
else
|
||||
year = 1900 + year;
|
||||
} else {
|
||||
return buffer.error('Decoding ' + tag + ' time is not supported yet');
|
||||
}
|
||||
|
||||
return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeNull = function decodeNull() {
|
||||
return null;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeBool = function decodeBool(buffer) {
|
||||
const res = buffer.readUInt8();
|
||||
if (buffer.isError(res))
|
||||
return res;
|
||||
else
|
||||
return res !== 0;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
|
||||
// Bigint, return as it is (assume big endian)
|
||||
const raw = buffer.raw();
|
||||
let res = new bignum(raw);
|
||||
|
||||
if (values)
|
||||
res = values[res.toString(10)] || res;
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
DERNode.prototype._use = function use(entity, obj) {
|
||||
if (typeof entity === 'function')
|
||||
entity = entity(obj);
|
||||
return entity._getDecoder('der').tree;
|
||||
};
|
||||
|
||||
// Utility methods
|
||||
|
||||
function derDecodeTag(buf, fail) {
|
||||
let tag = buf.readUInt8(fail);
|
||||
if (buf.isError(tag))
|
||||
return tag;
|
||||
|
||||
const cls = der.tagClass[tag >> 6];
|
||||
const primitive = (tag & 0x20) === 0;
|
||||
|
||||
// Multi-octet tag - load
|
||||
if ((tag & 0x1f) === 0x1f) {
|
||||
let oct = tag;
|
||||
tag = 0;
|
||||
while ((oct & 0x80) === 0x80) {
|
||||
oct = buf.readUInt8(fail);
|
||||
if (buf.isError(oct))
|
||||
return oct;
|
||||
|
||||
tag <<= 7;
|
||||
tag |= oct & 0x7f;
|
||||
}
|
||||
} else {
|
||||
tag &= 0x1f;
|
||||
}
|
||||
const tagStr = der.tag[tag];
|
||||
|
||||
return {
|
||||
cls: cls,
|
||||
primitive: primitive,
|
||||
tag: tag,
|
||||
tagStr: tagStr
|
||||
};
|
||||
}
|
||||
|
||||
function derDecodeLen(buf, primitive, fail) {
|
||||
let len = buf.readUInt8(fail);
|
||||
if (buf.isError(len))
|
||||
return len;
|
||||
|
||||
// Indefinite form
|
||||
if (!primitive && len === 0x80)
|
||||
return null;
|
||||
|
||||
// Definite form
|
||||
if ((len & 0x80) === 0) {
|
||||
// Short form
|
||||
return len;
|
||||
}
|
||||
|
||||
// Long form
|
||||
const num = len & 0x7f;
|
||||
if (num > 4)
|
||||
return buf.error('length octect is too long');
|
||||
|
||||
len = 0;
|
||||
for (let i = 0; i < num; i++) {
|
||||
len <<= 8;
|
||||
const j = buf.readUInt8(fail);
|
||||
if (buf.isError(j))
|
||||
return j;
|
||||
len |= j;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
6
node_modules/asn1.js/lib/asn1/decoders/index.js
generated
vendored
Normal file
6
node_modules/asn1.js/lib/asn1/decoders/index.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const decoders = exports;
|
||||
|
||||
decoders.der = require('./der');
|
||||
decoders.pem = require('./pem');
|
51
node_modules/asn1.js/lib/asn1/decoders/pem.js
generated
vendored
Normal file
51
node_modules/asn1.js/lib/asn1/decoders/pem.js
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
'use strict';
|
||||
|
||||
const inherits = require('inherits');
|
||||
const Buffer = require('safer-buffer').Buffer;
|
||||
|
||||
const DERDecoder = require('./der');
|
||||
|
||||
function PEMDecoder(entity) {
|
||||
DERDecoder.call(this, entity);
|
||||
this.enc = 'pem';
|
||||
}
|
||||
inherits(PEMDecoder, DERDecoder);
|
||||
module.exports = PEMDecoder;
|
||||
|
||||
PEMDecoder.prototype.decode = function decode(data, options) {
|
||||
const lines = data.toString().split(/[\r\n]+/g);
|
||||
|
||||
const label = options.label.toUpperCase();
|
||||
|
||||
const re = /^-----(BEGIN|END) ([^-]+)-----$/;
|
||||
let start = -1;
|
||||
let end = -1;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const match = lines[i].match(re);
|
||||
if (match === null)
|
||||
continue;
|
||||
|
||||
if (match[2] !== label)
|
||||
continue;
|
||||
|
||||
if (start === -1) {
|
||||
if (match[1] !== 'BEGIN')
|
||||
break;
|
||||
start = i;
|
||||
} else {
|
||||
if (match[1] !== 'END')
|
||||
break;
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start === -1 || end === -1)
|
||||
throw new Error('PEM section not found for: ' + label);
|
||||
|
||||
const base64 = lines.slice(start + 1, end).join('');
|
||||
// Remove excessive symbols
|
||||
base64.replace(/[^a-z0-9+/=]+/gi, '');
|
||||
|
||||
const input = Buffer.from(base64, 'base64');
|
||||
return DERDecoder.prototype.decode.call(this, input, options);
|
||||
};
|
295
node_modules/asn1.js/lib/asn1/encoders/der.js
generated
vendored
Normal file
295
node_modules/asn1.js/lib/asn1/encoders/der.js
generated
vendored
Normal file
|
@ -0,0 +1,295 @@
|
|||
'use strict';
|
||||
|
||||
const inherits = require('inherits');
|
||||
const Buffer = require('safer-buffer').Buffer;
|
||||
const Node = require('../base/node');
|
||||
|
||||
// Import DER constants
|
||||
const der = require('../constants/der');
|
||||
|
||||
function DEREncoder(entity) {
|
||||
this.enc = 'der';
|
||||
this.name = entity.name;
|
||||
this.entity = entity;
|
||||
|
||||
// Construct base tree
|
||||
this.tree = new DERNode();
|
||||
this.tree._init(entity.body);
|
||||
}
|
||||
module.exports = DEREncoder;
|
||||
|
||||
DEREncoder.prototype.encode = function encode(data, reporter) {
|
||||
return this.tree._encode(data, reporter).join();
|
||||
};
|
||||
|
||||
// Tree methods
|
||||
|
||||
function DERNode(parent) {
|
||||
Node.call(this, 'der', parent);
|
||||
}
|
||||
inherits(DERNode, Node);
|
||||
|
||||
DERNode.prototype._encodeComposite = function encodeComposite(tag,
|
||||
primitive,
|
||||
cls,
|
||||
content) {
|
||||
const encodedTag = encodeTag(tag, primitive, cls, this.reporter);
|
||||
|
||||
// Short form
|
||||
if (content.length < 0x80) {
|
||||
const header = Buffer.alloc(2);
|
||||
header[0] = encodedTag;
|
||||
header[1] = content.length;
|
||||
return this._createEncoderBuffer([ header, content ]);
|
||||
}
|
||||
|
||||
// Long form
|
||||
// Count octets required to store length
|
||||
let lenOctets = 1;
|
||||
for (let i = content.length; i >= 0x100; i >>= 8)
|
||||
lenOctets++;
|
||||
|
||||
const header = Buffer.alloc(1 + 1 + lenOctets);
|
||||
header[0] = encodedTag;
|
||||
header[1] = 0x80 | lenOctets;
|
||||
|
||||
for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
|
||||
header[i] = j & 0xff;
|
||||
|
||||
return this._createEncoderBuffer([ header, content ]);
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeStr = function encodeStr(str, tag) {
|
||||
if (tag === 'bitstr') {
|
||||
return this._createEncoderBuffer([ str.unused | 0, str.data ]);
|
||||
} else if (tag === 'bmpstr') {
|
||||
const buf = Buffer.alloc(str.length * 2);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
buf.writeUInt16BE(str.charCodeAt(i), i * 2);
|
||||
}
|
||||
return this._createEncoderBuffer(buf);
|
||||
} else if (tag === 'numstr') {
|
||||
if (!this._isNumstr(str)) {
|
||||
return this.reporter.error('Encoding of string type: numstr supports ' +
|
||||
'only digits and space');
|
||||
}
|
||||
return this._createEncoderBuffer(str);
|
||||
} else if (tag === 'printstr') {
|
||||
if (!this._isPrintstr(str)) {
|
||||
return this.reporter.error('Encoding of string type: printstr supports ' +
|
||||
'only latin upper and lower case letters, ' +
|
||||
'digits, space, apostrophe, left and rigth ' +
|
||||
'parenthesis, plus sign, comma, hyphen, ' +
|
||||
'dot, slash, colon, equal sign, ' +
|
||||
'question mark');
|
||||
}
|
||||
return this._createEncoderBuffer(str);
|
||||
} else if (/str$/.test(tag)) {
|
||||
return this._createEncoderBuffer(str);
|
||||
} else if (tag === 'objDesc') {
|
||||
return this._createEncoderBuffer(str);
|
||||
} else {
|
||||
return this.reporter.error('Encoding of string type: ' + tag +
|
||||
' unsupported');
|
||||
}
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
|
||||
if (typeof id === 'string') {
|
||||
if (!values)
|
||||
return this.reporter.error('string objid given, but no values map found');
|
||||
if (!values.hasOwnProperty(id))
|
||||
return this.reporter.error('objid not found in values map');
|
||||
id = values[id].split(/[\s.]+/g);
|
||||
for (let i = 0; i < id.length; i++)
|
||||
id[i] |= 0;
|
||||
} else if (Array.isArray(id)) {
|
||||
id = id.slice();
|
||||
for (let i = 0; i < id.length; i++)
|
||||
id[i] |= 0;
|
||||
}
|
||||
|
||||
if (!Array.isArray(id)) {
|
||||
return this.reporter.error('objid() should be either array or string, ' +
|
||||
'got: ' + JSON.stringify(id));
|
||||
}
|
||||
|
||||
if (!relative) {
|
||||
if (id[1] >= 40)
|
||||
return this.reporter.error('Second objid identifier OOB');
|
||||
id.splice(0, 2, id[0] * 40 + id[1]);
|
||||
}
|
||||
|
||||
// Count number of octets
|
||||
let size = 0;
|
||||
for (let i = 0; i < id.length; i++) {
|
||||
let ident = id[i];
|
||||
for (size++; ident >= 0x80; ident >>= 7)
|
||||
size++;
|
||||
}
|
||||
|
||||
const objid = Buffer.alloc(size);
|
||||
let offset = objid.length - 1;
|
||||
for (let i = id.length - 1; i >= 0; i--) {
|
||||
let ident = id[i];
|
||||
objid[offset--] = ident & 0x7f;
|
||||
while ((ident >>= 7) > 0)
|
||||
objid[offset--] = 0x80 | (ident & 0x7f);
|
||||
}
|
||||
|
||||
return this._createEncoderBuffer(objid);
|
||||
};
|
||||
|
||||
function two(num) {
|
||||
if (num < 10)
|
||||
return '0' + num;
|
||||
else
|
||||
return num;
|
||||
}
|
||||
|
||||
DERNode.prototype._encodeTime = function encodeTime(time, tag) {
|
||||
let str;
|
||||
const date = new Date(time);
|
||||
|
||||
if (tag === 'gentime') {
|
||||
str = [
|
||||
two(date.getUTCFullYear()),
|
||||
two(date.getUTCMonth() + 1),
|
||||
two(date.getUTCDate()),
|
||||
two(date.getUTCHours()),
|
||||
two(date.getUTCMinutes()),
|
||||
two(date.getUTCSeconds()),
|
||||
'Z'
|
||||
].join('');
|
||||
} else if (tag === 'utctime') {
|
||||
str = [
|
||||
two(date.getUTCFullYear() % 100),
|
||||
two(date.getUTCMonth() + 1),
|
||||
two(date.getUTCDate()),
|
||||
two(date.getUTCHours()),
|
||||
two(date.getUTCMinutes()),
|
||||
two(date.getUTCSeconds()),
|
||||
'Z'
|
||||
].join('');
|
||||
} else {
|
||||
this.reporter.error('Encoding ' + tag + ' time is not supported yet');
|
||||
}
|
||||
|
||||
return this._encodeStr(str, 'octstr');
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeNull = function encodeNull() {
|
||||
return this._createEncoderBuffer('');
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeInt = function encodeInt(num, values) {
|
||||
if (typeof num === 'string') {
|
||||
if (!values)
|
||||
return this.reporter.error('String int or enum given, but no values map');
|
||||
if (!values.hasOwnProperty(num)) {
|
||||
return this.reporter.error('Values map doesn\'t contain: ' +
|
||||
JSON.stringify(num));
|
||||
}
|
||||
num = values[num];
|
||||
}
|
||||
|
||||
// Bignum, assume big endian
|
||||
if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
|
||||
const numArray = num.toArray();
|
||||
if (!num.sign && numArray[0] & 0x80) {
|
||||
numArray.unshift(0);
|
||||
}
|
||||
num = Buffer.from(numArray);
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(num)) {
|
||||
let size = num.length;
|
||||
if (num.length === 0)
|
||||
size++;
|
||||
|
||||
const out = Buffer.alloc(size);
|
||||
num.copy(out);
|
||||
if (num.length === 0)
|
||||
out[0] = 0;
|
||||
return this._createEncoderBuffer(out);
|
||||
}
|
||||
|
||||
if (num < 0x80)
|
||||
return this._createEncoderBuffer(num);
|
||||
|
||||
if (num < 0x100)
|
||||
return this._createEncoderBuffer([0, num]);
|
||||
|
||||
let size = 1;
|
||||
for (let i = num; i >= 0x100; i >>= 8)
|
||||
size++;
|
||||
|
||||
const out = new Array(size);
|
||||
for (let i = out.length - 1; i >= 0; i--) {
|
||||
out[i] = num & 0xff;
|
||||
num >>= 8;
|
||||
}
|
||||
if(out[0] & 0x80) {
|
||||
out.unshift(0);
|
||||
}
|
||||
|
||||
return this._createEncoderBuffer(Buffer.from(out));
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeBool = function encodeBool(value) {
|
||||
return this._createEncoderBuffer(value ? 0xff : 0);
|
||||
};
|
||||
|
||||
DERNode.prototype._use = function use(entity, obj) {
|
||||
if (typeof entity === 'function')
|
||||
entity = entity(obj);
|
||||
return entity._getEncoder('der').tree;
|
||||
};
|
||||
|
||||
DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
|
||||
const state = this._baseState;
|
||||
let i;
|
||||
if (state['default'] === null)
|
||||
return false;
|
||||
|
||||
const data = dataBuffer.join();
|
||||
if (state.defaultBuffer === undefined)
|
||||
state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
|
||||
|
||||
if (data.length !== state.defaultBuffer.length)
|
||||
return false;
|
||||
|
||||
for (i=0; i < data.length; i++)
|
||||
if (data[i] !== state.defaultBuffer[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// Utility methods
|
||||
|
||||
function encodeTag(tag, primitive, cls, reporter) {
|
||||
let res;
|
||||
|
||||
if (tag === 'seqof')
|
||||
tag = 'seq';
|
||||
else if (tag === 'setof')
|
||||
tag = 'set';
|
||||
|
||||
if (der.tagByName.hasOwnProperty(tag))
|
||||
res = der.tagByName[tag];
|
||||
else if (typeof tag === 'number' && (tag | 0) === tag)
|
||||
res = tag;
|
||||
else
|
||||
return reporter.error('Unknown tag: ' + tag);
|
||||
|
||||
if (res >= 0x1f)
|
||||
return reporter.error('Multi-octet tag encoding unsupported');
|
||||
|
||||
if (!primitive)
|
||||
res |= 0x20;
|
||||
|
||||
res |= (der.tagClassByName[cls || 'universal'] << 6);
|
||||
|
||||
return res;
|
||||
}
|
6
node_modules/asn1.js/lib/asn1/encoders/index.js
generated
vendored
Normal file
6
node_modules/asn1.js/lib/asn1/encoders/index.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const encoders = exports;
|
||||
|
||||
encoders.der = require('./der');
|
||||
encoders.pem = require('./pem');
|
23
node_modules/asn1.js/lib/asn1/encoders/pem.js
generated
vendored
Normal file
23
node_modules/asn1.js/lib/asn1/encoders/pem.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
const inherits = require('inherits');
|
||||
|
||||
const DEREncoder = require('./der');
|
||||
|
||||
function PEMEncoder(entity) {
|
||||
DEREncoder.call(this, entity);
|
||||
this.enc = 'pem';
|
||||
}
|
||||
inherits(PEMEncoder, DEREncoder);
|
||||
module.exports = PEMEncoder;
|
||||
|
||||
PEMEncoder.prototype.encode = function encode(data, options) {
|
||||
const buf = DEREncoder.prototype.encode.call(this, data);
|
||||
|
||||
const p = buf.toString('base64');
|
||||
const out = [ '-----BEGIN ' + options.label + '-----' ];
|
||||
for (let i = 0; i < p.length; i += 64)
|
||||
out.push(p.slice(i, i + 64));
|
||||
out.push('-----END ' + options.label + '-----');
|
||||
return out.join('\n');
|
||||
};
|
66
node_modules/asn1.js/package.json
generated
vendored
Normal file
66
node_modules/asn1.js/package.json
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"asn1.js@5.3.0",
|
||||
"X:\\dev\\neard\\www\\github\\ghaction\\ghaction-import-gpg"
|
||||
]
|
||||
],
|
||||
"_from": "asn1.js@5.3.0",
|
||||
"_id": "asn1.js@5.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-WHnQJFcOrIWT1RLOkFFBQkFVvyt9BPOOrH+Dp152Zk4R993rSzXUGPmkybIcUFhHE2d/iHH+nCaOWVCDbO8fgA==",
|
||||
"_location": "/asn1.js",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "asn1.js@5.3.0",
|
||||
"name": "asn1.js",
|
||||
"escapedName": "asn1.js",
|
||||
"rawSpec": "5.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "5.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/openpgp"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.3.0.tgz",
|
||||
"_spec": "5.3.0",
|
||||
"_where": "X:\\dev\\neard\\www\\github\\ghaction\\ghaction-import-gpg",
|
||||
"author": {
|
||||
"name": "Fedor Indutny"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/indutny/asn1.js/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"bn.js": "^4.0.0",
|
||||
"inherits": "^2.0.1",
|
||||
"minimalistic-assert": "^1.0.0",
|
||||
"safer-buffer": "^2.1.0"
|
||||
},
|
||||
"description": "ASN.1 encoder and decoder",
|
||||
"devDependencies": {
|
||||
"eslint": "^4.10.0",
|
||||
"mocha": "^7.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/indutny/asn1.js",
|
||||
"keywords": [
|
||||
"asn.1",
|
||||
"der"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/asn1.js",
|
||||
"name": "asn1.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/indutny/asn1.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --fix lib/*.js lib/**/*.js lib/**/**/*.js && npm run lint-2560 && npm run lint-5280",
|
||||
"lint-2560": "eslint --fix rfc/2560/*.js rfc/2560/test/*.js",
|
||||
"lint-5280": "eslint --fix rfc/5280/*.js rfc/5280/test/*.js",
|
||||
"test": "mocha --reporter spec test/*-test.js && cd rfc/2560 && npm i && npm test && cd ../../rfc/5280 && npm i && npm test && cd ../../ && npm run lint"
|
||||
},
|
||||
"version": "5.3.0"
|
||||
}
|
8
node_modules/bn.js/.npmignore
generated
vendored
Normal file
8
node_modules/bn.js/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
benchmarks/
|
||||
coverage/
|
||||
test/
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
1.js
|
||||
logo.png
|
||||
.travis.yml
|
221
node_modules/bn.js/README.md
generated
vendored
Normal file
221
node_modules/bn.js/README.md
generated
vendored
Normal file
|
@ -0,0 +1,221 @@
|
|||
# <img src="./logo.png" alt="bn.js" width="160" height="160" />
|
||||
|
||||
> BigNum in pure javascript
|
||||
|
||||
[![Build Status](https://secure.travis-ci.org/indutny/bn.js.png)](http://travis-ci.org/indutny/bn.js)
|
||||
|
||||
## Install
|
||||
`npm install --save bn.js`
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const BN = require('bn.js');
|
||||
|
||||
var a = new BN('dead', 16);
|
||||
var b = new BN('101010', 2);
|
||||
|
||||
var res = a.add(b);
|
||||
console.log(res.toString(10)); // 57047
|
||||
```
|
||||
|
||||
**Note**: decimals are not supported in this library.
|
||||
|
||||
## Notation
|
||||
|
||||
### Prefixes
|
||||
|
||||
There are several prefixes to instructions that affect the way the work. Here
|
||||
is the list of them in the order of appearance in the function name:
|
||||
|
||||
* `i` - perform operation in-place, storing the result in the host object (on
|
||||
which the method was invoked). Might be used to avoid number allocation costs
|
||||
* `u` - unsigned, ignore the sign of operands when performing operation, or
|
||||
always return positive value. Second case applies to reduction operations
|
||||
like `mod()`. In such cases if the result will be negative - modulo will be
|
||||
added to the result to make it positive
|
||||
|
||||
### Postfixes
|
||||
|
||||
The only available postfix at the moment is:
|
||||
|
||||
* `n` - which means that the argument of the function must be a plain JavaScript
|
||||
Number. Decimals are not supported.
|
||||
|
||||
### Examples
|
||||
|
||||
* `a.iadd(b)` - perform addition on `a` and `b`, storing the result in `a`
|
||||
* `a.umod(b)` - reduce `a` modulo `b`, returning positive value
|
||||
* `a.iushln(13)` - shift bits of `a` left by 13
|
||||
|
||||
## Instructions
|
||||
|
||||
Prefixes/postfixes are put in parens at the of the line. `endian` - could be
|
||||
either `le` (little-endian) or `be` (big-endian).
|
||||
|
||||
### Utilities
|
||||
|
||||
* `a.clone()` - clone number
|
||||
* `a.toString(base, length)` - convert to base-string and pad with zeroes
|
||||
* `a.toNumber()` - convert to Javascript Number (limited to 53 bits)
|
||||
* `a.toJSON()` - convert to JSON compatible hex string (alias of `toString(16)`)
|
||||
* `a.toArray(endian, length)` - convert to byte `Array`, and optionally zero
|
||||
pad to length, throwing if already exceeding
|
||||
* `a.toArrayLike(type, endian, length)` - convert to an instance of `type`,
|
||||
which must behave like an `Array`
|
||||
* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available). For
|
||||
compatibility with browserify and similar tools, use this instead:
|
||||
`a.toArrayLike(Buffer, endian, length)`
|
||||
* `a.bitLength()` - get number of bits occupied
|
||||
* `a.zeroBits()` - return number of less-significant consequent zero bits
|
||||
(example: `1010000` has 4 zero bits)
|
||||
* `a.byteLength()` - return number of bytes occupied
|
||||
* `a.isNeg()` - true if the number is negative
|
||||
* `a.isEven()` - no comments
|
||||
* `a.isOdd()` - no comments
|
||||
* `a.isZero()` - no comments
|
||||
* `a.cmp(b)` - compare numbers and return `-1` (a `<` b), `0` (a `==` b), or `1` (a `>` b)
|
||||
depending on the comparison result (`ucmp`, `cmpn`)
|
||||
* `a.lt(b)` - `a` less than `b` (`n`)
|
||||
* `a.lte(b)` - `a` less than or equals `b` (`n`)
|
||||
* `a.gt(b)` - `a` greater than `b` (`n`)
|
||||
* `a.gte(b)` - `a` greater than or equals `b` (`n`)
|
||||
* `a.eq(b)` - `a` equals `b` (`n`)
|
||||
* `a.toTwos(width)` - convert to two's complement representation, where `width` is bit width
|
||||
* `a.fromTwos(width)` - convert from two's complement representation, where `width` is the bit width
|
||||
* `BN.isBN(object)` - returns true if the supplied `object` is a BN.js instance
|
||||
|
||||
### Arithmetics
|
||||
|
||||
* `a.neg()` - negate sign (`i`)
|
||||
* `a.abs()` - absolute value (`i`)
|
||||
* `a.add(b)` - addition (`i`, `n`, `in`)
|
||||
* `a.sub(b)` - subtraction (`i`, `n`, `in`)
|
||||
* `a.mul(b)` - multiply (`i`, `n`, `in`)
|
||||
* `a.sqr()` - square (`i`)
|
||||
* `a.pow(b)` - raise `a` to the power of `b`
|
||||
* `a.div(b)` - divide (`divn`, `idivn`)
|
||||
* `a.mod(b)` - reduct (`u`, `n`) (but no `umodn`)
|
||||
* `a.divRound(b)` - rounded division
|
||||
|
||||
### Bit operations
|
||||
|
||||
* `a.or(b)` - or (`i`, `u`, `iu`)
|
||||
* `a.and(b)` - and (`i`, `u`, `iu`, `andln`) (NOTE: `andln` is going to be replaced
|
||||
with `andn` in future)
|
||||
* `a.xor(b)` - xor (`i`, `u`, `iu`)
|
||||
* `a.setn(b)` - set specified bit to `1`
|
||||
* `a.shln(b)` - shift left (`i`, `u`, `iu`)
|
||||
* `a.shrn(b)` - shift right (`i`, `u`, `iu`)
|
||||
* `a.testn(b)` - test if specified bit is set
|
||||
* `a.maskn(b)` - clear bits with indexes higher or equal to `b` (`i`)
|
||||
* `a.bincn(b)` - add `1 << b` to the number
|
||||
* `a.notn(w)` - not (for the width specified by `w`) (`i`)
|
||||
|
||||
### Reduction
|
||||
|
||||
* `a.gcd(b)` - GCD
|
||||
* `a.egcd(b)` - Extended GCD results (`{ a: ..., b: ..., gcd: ... }`)
|
||||
* `a.invm(b)` - inverse `a` modulo `b`
|
||||
|
||||
## Fast reduction
|
||||
|
||||
When doing lots of reductions using the same modulo, it might be beneficial to
|
||||
use some tricks: like [Montgomery multiplication][0], or using special algorithm
|
||||
for [Mersenne Prime][1].
|
||||
|
||||
### Reduction context
|
||||
|
||||
To enable this tricks one should create a reduction context:
|
||||
|
||||
```js
|
||||
var red = BN.red(num);
|
||||
```
|
||||
where `num` is just a BN instance.
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.red(primeName);
|
||||
```
|
||||
|
||||
Where `primeName` is either of these [Mersenne Primes][1]:
|
||||
|
||||
* `'k256'`
|
||||
* `'p224'`
|
||||
* `'p192'`
|
||||
* `'p25519'`
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.mont(num);
|
||||
```
|
||||
|
||||
To reduce numbers with [Montgomery trick][0]. `.mont()` is generally faster than
|
||||
`.red(num)`, but slower than `BN.red(primeName)`.
|
||||
|
||||
### Converting numbers
|
||||
|
||||
Before performing anything in reduction context - numbers should be converted
|
||||
to it. Usually, this means that one should:
|
||||
|
||||
* Convert inputs to reducted ones
|
||||
* Operate on them in reduction context
|
||||
* Convert outputs back from the reduction context
|
||||
|
||||
Here is how one may convert numbers to `red`:
|
||||
|
||||
```js
|
||||
var redA = a.toRed(red);
|
||||
```
|
||||
Where `red` is a reduction context created using instructions above
|
||||
|
||||
Here is how to convert them back:
|
||||
|
||||
```js
|
||||
var a = redA.fromRed();
|
||||
```
|
||||
|
||||
### Red instructions
|
||||
|
||||
Most of the instructions from the very start of this readme have their
|
||||
counterparts in red context:
|
||||
|
||||
* `a.redAdd(b)`, `a.redIAdd(b)`
|
||||
* `a.redSub(b)`, `a.redISub(b)`
|
||||
* `a.redShl(num)`
|
||||
* `a.redMul(b)`, `a.redIMul(b)`
|
||||
* `a.redSqr()`, `a.redISqr()`
|
||||
* `a.redSqrt()` - square root modulo reduction context's prime
|
||||
* `a.redInvm()` - modular inverse of the number
|
||||
* `a.redNeg()`
|
||||
* `a.redPow(b)` - modular exponentiation
|
||||
|
||||
## LICENSE
|
||||
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
Copyright Fedor Indutny, 2015.
|
||||
|
||||
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.
|
||||
|
||||
[0]: https://en.wikipedia.org/wiki/Montgomery_modular_multiplication
|
||||
[1]: https://en.wikipedia.org/wiki/Mersenne_prime
|
3427
node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
3427
node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
67
node_modules/bn.js/package.json
generated
vendored
Normal file
67
node_modules/bn.js/package.json
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"bn.js@4.11.8",
|
||||
"X:\\dev\\neard\\www\\github\\ghaction\\ghaction-import-gpg"
|
||||
]
|
||||
],
|
||||
"_from": "bn.js@4.11.8",
|
||||
"_id": "bn.js@4.11.8",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==",
|
||||
"_location": "/bn.js",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "bn.js@4.11.8",
|
||||
"name": "bn.js",
|
||||
"escapedName": "bn.js",
|
||||
"rawSpec": "4.11.8",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.11.8"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/asn1.js"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
|
||||
"_spec": "4.11.8",
|
||||
"_where": "X:\\dev\\neard\\www\\github\\ghaction\\ghaction-import-gpg",
|
||||
"author": {
|
||||
"name": "Fedor Indutny",
|
||||
"email": "fedor@indutny.com"
|
||||
},
|
||||
"browser": {
|
||||
"buffer": false
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/indutny/bn.js/issues"
|
||||
},
|
||||
"description": "Big number implementation in pure javascript",
|
||||
"devDependencies": {
|
||||
"istanbul": "^0.3.5",
|
||||
"mocha": "^2.1.0",
|
||||
"semistandard": "^7.0.4"
|
||||
},
|
||||
"homepage": "https://github.com/indutny/bn.js",
|
||||
"keywords": [
|
||||
"BN",
|
||||
"BigNum",
|
||||
"Big number",
|
||||
"Modulo",
|
||||
"Montgomery"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/bn.js",
|
||||
"name": "bn.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/indutny/bn.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "semistandard",
|
||||
"test": "npm run lint && npm run unit",
|
||||
"unit": "mocha --reporter=spec test/*-test.js"
|
||||
},
|
||||
"version": "4.11.8"
|
||||
}
|
65
node_modules/bn.js/util/genCombMulTo.js
generated
vendored
Normal file
65
node_modules/bn.js/util/genCombMulTo.js
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
'use strict';
|
||||
|
||||
// NOTE: This could be potentionally used to generate loop-less multiplications
|
||||
function genCombMulTo (alen, blen) {
|
||||
var len = alen + blen - 1;
|
||||
var src = [
|
||||
'var a = self.words;',
|
||||
'var b = num.words;',
|
||||
'var o = out.words;',
|
||||
'var c = 0;',
|
||||
'var lo;',
|
||||
'var mid;',
|
||||
'var hi;'
|
||||
];
|
||||
for (var i = 0; i < alen; i++) {
|
||||
src.push('var a' + i + ' = a[' + i + '] | 0;');
|
||||
src.push('var al' + i + ' = a' + i + ' & 0x1fff;');
|
||||
src.push('var ah' + i + ' = a' + i + ' >>> 13;');
|
||||
}
|
||||
for (i = 0; i < blen; i++) {
|
||||
src.push('var b' + i + ' = b[' + i + '] | 0;');
|
||||
src.push('var bl' + i + ' = b' + i + ' & 0x1fff;');
|
||||
src.push('var bh' + i + ' = b' + i + ' >>> 13;');
|
||||
}
|
||||
src.push('');
|
||||
src.push('out.negative = self.negative ^ num.negative;');
|
||||
src.push('out.length = ' + len + ';');
|
||||
|
||||
for (var k = 0; k < len; k++) {
|
||||
var minJ = Math.max(0, k - alen + 1);
|
||||
var maxJ = Math.min(k, blen - 1);
|
||||
|
||||
src.push('\/* k = ' + k + ' *\/');
|
||||
src.push('var w' + k + ' = c;');
|
||||
src.push('c = 0;');
|
||||
for (var j = minJ; j <= maxJ; j++) {
|
||||
i = k - j;
|
||||
|
||||
src.push('lo = Math.imul(al' + i + ', bl' + j + ');');
|
||||
src.push('mid = Math.imul(al' + i + ', bh' + j + ');');
|
||||
src.push('mid = (mid + Math.imul(ah' + i + ', bl' + j + ')) | 0;');
|
||||
src.push('hi = Math.imul(ah' + i + ', bh' + j + ');');
|
||||
|
||||
src.push('w' + k + ' = (w' + k + ' + lo) | 0;');
|
||||
src.push('w' + k + ' = (w' + k + ' + ((mid & 0x1fff) << 13)) | 0;');
|
||||
src.push('c = (c + hi) | 0;');
|
||||
src.push('c = (c + (mid >>> 13)) | 0;');
|
||||
src.push('c = (c + (w' + k + ' >>> 26)) | 0;');
|
||||
src.push('w' + k + ' &= 0x3ffffff;');
|
||||
}
|
||||
}
|
||||
// Store in separate step for better memory access
|
||||
for (k = 0; k < len; k++) {
|
||||
src.push('o[' + k + '] = w' + k + ';');
|
||||
}
|
||||
src.push('if (c !== 0) {',
|
||||
' o[' + k + '] = c;',
|
||||
' out.length++;',
|
||||
'}',
|
||||
'return out;');
|
||||
|
||||
return src.join('\n');
|
||||
}
|
||||
|
||||
console.log(genCombMulTo(10, 10));
|
65
node_modules/bn.js/util/genCombMulTo10.js
generated
vendored
Normal file
65
node_modules/bn.js/util/genCombMulTo10.js
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
'use strict';
|
||||
|
||||
function genCombMulTo (alen, blen) {
|
||||
var len = alen + blen - 1;
|
||||
var src = [
|
||||
'var a = self.words;',
|
||||
'var b = num.words;',
|
||||
'var o = out.words;',
|
||||
'var c = 0;',
|
||||
'var lo;',
|
||||
'var mid;',
|
||||
'var hi;'
|
||||
];
|
||||
for (var i = 0; i < alen; i++) {
|
||||
src.push('var a' + i + ' = a[' + i + '] | 0;');
|
||||
src.push('var al' + i + ' = a' + i + ' & 0x1fff;');
|
||||
src.push('var ah' + i + ' = a' + i + ' >>> 13;');
|
||||
}
|
||||
for (i = 0; i < blen; i++) {
|
||||
src.push('var b' + i + ' = b[' + i + '] | 0;');
|
||||
src.push('var bl' + i + ' = b' + i + ' & 0x1fff;');
|
||||
src.push('var bh' + i + ' = b' + i + ' >>> 13;');
|
||||
}
|
||||
src.push('');
|
||||
src.push('out.negative = self.negative ^ num.negative;');
|
||||
src.push('out.length = ' + len + ';');
|
||||
|
||||
for (var k = 0; k < len; k++) {
|
||||
var minJ = Math.max(0, k - alen + 1);
|
||||
var maxJ = Math.min(k, blen - 1);
|
||||
|
||||
src.push('\/* k = ' + k + ' *\/');
|
||||
src.push('lo = Math.imul(al' + (k - minJ) + ', bl' + minJ + ');');
|
||||
src.push('mid = Math.imul(al' + (k - minJ) + ', bh' + minJ + ');');
|
||||
src.push(
|
||||
'mid = (mid + Math.imul(ah' + (k - minJ) + ', bl' + minJ + ')) | 0;');
|
||||
src.push('hi = Math.imul(ah' + (k - minJ) + ', bh' + minJ + ');');
|
||||
|
||||
for (var j = minJ + 1; j <= maxJ; j++) {
|
||||
i = k - j;
|
||||
|
||||
src.push('lo = (lo + Math.imul(al' + i + ', bl' + j + ')) | 0;');
|
||||
src.push('mid = (mid + Math.imul(al' + i + ', bh' + j + ')) | 0;');
|
||||
src.push('mid = (mid + Math.imul(ah' + i + ', bl' + j + ')) | 0;');
|
||||
src.push('hi = (hi + Math.imul(ah' + i + ', bh' + j + ')) | 0;');
|
||||
}
|
||||
|
||||
src.push('var w' + k + ' = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;');
|
||||
src.push('c = (((hi + (mid >>> 13)) | 0) + (w' + k + ' >>> 26)) | 0;');
|
||||
src.push('w' + k + ' &= 0x3ffffff;');
|
||||
}
|
||||
// Store in separate step for better memory access
|
||||
for (k = 0; k < len; k++) {
|
||||
src.push('o[' + k + '] = w' + k + ';');
|
||||
}
|
||||
src.push('if (c !== 0) {',
|
||||
' o[' + k + '] = c;',
|
||||
' out.length++;',
|
||||
'}',
|
||||
'return out;');
|
||||
|
||||
return src.join('\n');
|
||||
}
|
||||
|
||||
console.log(genCombMulTo(10, 10));
|
Loading…
Reference in a new issue