Commit bf137ad8 authored by Patrick's avatar Patrick
Browse files

CHANGES.md, README.md und 248 weitere dateien aktualisiert...

parent 0081cef7
Showing with 147 additions and 749 deletions
+147 -749
parserOptions:
ecmaVersion: 6
globals:
beforeEach: false
describe: false
it: false
'use strict';
var schema = {
additionalItems: subschema('additionalItems'),
items: subschema('items'),
contains: subschema('contains'),
additionalProperties: subschema('additionalProperties'),
propertyNames: subschema('propertyNames'),
not: subschema('not'),
allOf: [
subschema('allOf_0'),
subschema('allOf_1'),
{
items: [
subschema('items_0'),
subschema('items_1'),
]
}
],
anyOf: [
subschema('anyOf_0'),
subschema('anyOf_1'),
],
oneOf: [
subschema('oneOf_0'),
subschema('oneOf_1'),
],
definitions: {
foo: subschema('definitions_foo'),
bar: subschema('definitions_bar'),
},
properties: {
foo: subschema('properties_foo'),
bar: subschema('properties_bar'),
},
patternProperties: {
foo: subschema('patternProperties_foo'),
bar: subschema('patternProperties_bar'),
},
dependencies: {
foo: subschema('dependencies_foo'),
bar: subschema('dependencies_bar'),
},
required: ['foo', 'bar']
};
function subschema(keyword) {
var sch = {
properties: {},
additionalProperties: false,
additionalItems: false,
anyOf: [
{format: 'email'},
{format: 'hostname'}
]
};
sch.properties['foo_' + keyword] = {title: 'foo'};
sch.properties['bar_' + keyword] = {title: 'bar'};
return sch;
}
module.exports = {
schema: schema,
// schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex
expectedCalls: [[schema, '', schema, undefined, undefined, undefined, undefined]]
.concat(expectedCalls('additionalItems'))
.concat(expectedCalls('items'))
.concat(expectedCalls('contains'))
.concat(expectedCalls('additionalProperties'))
.concat(expectedCalls('propertyNames'))
.concat(expectedCalls('not'))
.concat(expectedCallsChild('allOf', 0))
.concat(expectedCallsChild('allOf', 1))
.concat([
[schema.allOf[2], '/allOf/2', schema, '', 'allOf', schema, 2],
[schema.allOf[2].items[0], '/allOf/2/items/0', schema, '/allOf/2', 'items', schema.allOf[2], 0],
[schema.allOf[2].items[0].properties.foo_items_0, '/allOf/2/items/0/properties/foo_items_0', schema, '/allOf/2/items/0', 'properties', schema.allOf[2].items[0], 'foo_items_0'],
[schema.allOf[2].items[0].properties.bar_items_0, '/allOf/2/items/0/properties/bar_items_0', schema, '/allOf/2/items/0', 'properties', schema.allOf[2].items[0], 'bar_items_0'],
[schema.allOf[2].items[0].anyOf[0], '/allOf/2/items/0/anyOf/0', schema, '/allOf/2/items/0', 'anyOf', schema.allOf[2].items[0], 0],
[schema.allOf[2].items[0].anyOf[1], '/allOf/2/items/0/anyOf/1', schema, '/allOf/2/items/0', 'anyOf', schema.allOf[2].items[0], 1],
[schema.allOf[2].items[1], '/allOf/2/items/1', schema, '/allOf/2', 'items', schema.allOf[2], 1],
[schema.allOf[2].items[1].properties.foo_items_1, '/allOf/2/items/1/properties/foo_items_1', schema, '/allOf/2/items/1', 'properties', schema.allOf[2].items[1], 'foo_items_1'],
[schema.allOf[2].items[1].properties.bar_items_1, '/allOf/2/items/1/properties/bar_items_1', schema, '/allOf/2/items/1', 'properties', schema.allOf[2].items[1], 'bar_items_1'],
[schema.allOf[2].items[1].anyOf[0], '/allOf/2/items/1/anyOf/0', schema, '/allOf/2/items/1', 'anyOf', schema.allOf[2].items[1], 0],
[schema.allOf[2].items[1].anyOf[1], '/allOf/2/items/1/anyOf/1', schema, '/allOf/2/items/1', 'anyOf', schema.allOf[2].items[1], 1]
])
.concat(expectedCallsChild('anyOf', 0))
.concat(expectedCallsChild('anyOf', 1))
.concat(expectedCallsChild('oneOf', 0))
.concat(expectedCallsChild('oneOf', 1))
.concat(expectedCallsChild('definitions', 'foo'))
.concat(expectedCallsChild('definitions', 'bar'))
.concat(expectedCallsChild('properties', 'foo'))
.concat(expectedCallsChild('properties', 'bar'))
.concat(expectedCallsChild('patternProperties', 'foo'))
.concat(expectedCallsChild('patternProperties', 'bar'))
.concat(expectedCallsChild('dependencies', 'foo'))
.concat(expectedCallsChild('dependencies', 'bar'))
};
function expectedCalls(keyword) {
return [
[schema[keyword], `/${keyword}`, schema, '', keyword, schema, undefined],
[schema[keyword].properties[`foo_${keyword}`], `/${keyword}/properties/foo_${keyword}`, schema, `/${keyword}`, 'properties', schema[keyword], `foo_${keyword}`],
[schema[keyword].properties[`bar_${keyword}`], `/${keyword}/properties/bar_${keyword}`, schema, `/${keyword}`, 'properties', schema[keyword], `bar_${keyword}`],
[schema[keyword].anyOf[0], `/${keyword}/anyOf/0`, schema, `/${keyword}`, 'anyOf', schema[keyword], 0],
[schema[keyword].anyOf[1], `/${keyword}/anyOf/1`, schema, `/${keyword}`, 'anyOf', schema[keyword], 1]
];
}
function expectedCallsChild(keyword, i) {
return [
[schema[keyword][i], `/${keyword}/${i}`, schema, '', keyword, schema, i],
[schema[keyword][i].properties[`foo_${keyword}_${i}`], `/${keyword}/${i}/properties/foo_${keyword}_${i}`, schema, `/${keyword}/${i}`, 'properties', schema[keyword][i], `foo_${keyword}_${i}`],
[schema[keyword][i].properties[`bar_${keyword}_${i}`], `/${keyword}/${i}/properties/bar_${keyword}_${i}`, schema, `/${keyword}/${i}`, 'properties', schema[keyword][i], `bar_${keyword}_${i}`],
[schema[keyword][i].anyOf[0], `/${keyword}/${i}/anyOf/0`, schema, `/${keyword}/${i}`, 'anyOf', schema[keyword][i], 0],
[schema[keyword][i].anyOf[1], `/${keyword}/${i}/anyOf/1`, schema, `/${keyword}/${i}`, 'anyOf', schema[keyword][i], 1]
];
}
'use strict';
var traverse = require('../index');
var assert = require('assert');
describe('json-schema-traverse', function() {
var calls;
beforeEach(function() {
calls = [];
});
it('should traverse all keywords containing schemas recursively', function() {
var schema = require('./fixtures/schema').schema;
var expectedCalls = require('./fixtures/schema').expectedCalls;
traverse(schema, {cb: callback});
assert.deepStrictEqual(calls, expectedCalls);
});
describe('Legacy v0.3.1 API', function() {
it('should traverse all keywords containing schemas recursively', function() {
var schema = require('./fixtures/schema').schema;
var expectedCalls = require('./fixtures/schema').expectedCalls;
traverse(schema, callback);
assert.deepStrictEqual(calls, expectedCalls);
});
it('should work when an options object is provided', function() {
// schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex
var schema = require('./fixtures/schema').schema;
var expectedCalls = require('./fixtures/schema').expectedCalls;
traverse(schema, {}, callback);
assert.deepStrictEqual(calls, expectedCalls);
});
});
describe('allKeys option', function() {
var schema = {
someObject: {
minimum: 1,
maximum: 2
}
};
it('should traverse objects with allKeys: true option', function() {
// schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex
var expectedCalls = [
[schema, '', schema, undefined, undefined, undefined, undefined],
[schema.someObject, '/someObject', schema, '', 'someObject', schema, undefined]
];
traverse(schema, {allKeys: true, cb: callback});
assert.deepStrictEqual(calls, expectedCalls);
});
it('should NOT traverse objects with allKeys: false option', function() {
// schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex
var expectedCalls = [
[schema, '', schema, undefined, undefined, undefined, undefined]
];
traverse(schema, {allKeys: false, cb: callback});
assert.deepStrictEqual(calls, expectedCalls);
});
it('should NOT traverse objects without allKeys option', function() {
// schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex
var expectedCalls = [
[schema, '', schema, undefined, undefined, undefined, undefined]
];
traverse(schema, {cb: callback});
assert.deepStrictEqual(calls, expectedCalls);
});
it('should NOT travers objects in standard keywords which value is not a schema', function() {
var schema2 = {
const: {foo: 'bar'},
enum: ['a', 'b'],
required: ['foo'],
another: {
},
patternProperties: {}, // will not traverse - no properties
dependencies: true, // will not traverse - invalid
properties: {
smaller: {
type: 'number'
},
larger: {
type: 'number',
minimum: {$data: '1/smaller'}
}
}
};
// schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex
var expectedCalls = [
[schema2, '', schema2, undefined, undefined, undefined, undefined],
[schema2.another, '/another', schema2, '', 'another', schema2, undefined],
[schema2.properties.smaller, '/properties/smaller', schema2, '', 'properties', schema2, 'smaller'],
[schema2.properties.larger, '/properties/larger', schema2, '', 'properties', schema2, 'larger'],
];
traverse(schema2, {allKeys: true, cb: callback});
assert.deepStrictEqual(calls, expectedCalls);
});
});
describe('pre and post', function() {
var schema = {
type: 'object',
properties: {
name: {type: 'string'},
age: {type: 'number'}
}
};
it('should traverse schema in pre-order', function() {
traverse(schema, {cb: {pre}});
var expectedCalls = [
['pre', schema, '', schema, undefined, undefined, undefined, undefined],
['pre', schema.properties.name, '/properties/name', schema, '', 'properties', schema, 'name'],
['pre', schema.properties.age, '/properties/age', schema, '', 'properties', schema, 'age'],
];
assert.deepStrictEqual(calls, expectedCalls);
});
it('should traverse schema in post-order', function() {
traverse(schema, {cb: {post}});
var expectedCalls = [
['post', schema.properties.name, '/properties/name', schema, '', 'properties', schema, 'name'],
['post', schema.properties.age, '/properties/age', schema, '', 'properties', schema, 'age'],
['post', schema, '', schema, undefined, undefined, undefined, undefined],
];
assert.deepStrictEqual(calls, expectedCalls);
});
it('should traverse schema in pre- and post-order at the same time', function() {
traverse(schema, {cb: {pre, post}});
var expectedCalls = [
['pre', schema, '', schema, undefined, undefined, undefined, undefined],
['pre', schema.properties.name, '/properties/name', schema, '', 'properties', schema, 'name'],
['post', schema.properties.name, '/properties/name', schema, '', 'properties', schema, 'name'],
['pre', schema.properties.age, '/properties/age', schema, '', 'properties', schema, 'age'],
['post', schema.properties.age, '/properties/age', schema, '', 'properties', schema, 'age'],
['post', schema, '', schema, undefined, undefined, undefined, undefined],
];
assert.deepStrictEqual(calls, expectedCalls);
});
});
function callback() {
calls.push(Array.prototype.slice.call(arguments));
}
function pre() {
calls.push(['pre'].concat(Array.prototype.slice.call(arguments)));
}
function post() {
calls.push(['post'].concat(Array.prototype.slice.call(arguments)));
}
});
{
"_from": "har-validator@~5.1.3",
"_id": "har-validator@5.1.3",
"_from": "har-validator@~4.2.1",
"_id": "har-validator@4.2.1",
"_inBundle": false,
"_integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==",
"_integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=",
"_location": "/har-validator",
"_phantomChildren": {
"fast-json-stable-stringify": "2.0.0",
"uri-js": "4.2.2"
"co": "4.6.0",
"json-stable-stringify": "1.0.1"
},
"_requested": {
"type": "range",
"registry": true,
"raw": "har-validator@~5.1.3",
"raw": "har-validator@~4.2.1",
"name": "har-validator",
"escapedName": "har-validator",
"rawSpec": "~5.1.3",
"rawSpec": "~4.2.1",
"saveSpec": null,
"fetchSpec": "~5.1.3"
"fetchSpec": "~4.2.1"
},
"_requiredBy": [
"/request"
],
"_resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz",
"_shasum": "1ef89ebd3e4996557675eed9893110dc350fa080",
"_spec": "har-validator@~5.1.3",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\dev\\node_modules\\request",
"_resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz",
"_shasum": "33481d0f1bbff600dd203d75812a6a5fba002e2a",
"_spec": "har-validator@~4.2.1",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\Main\\02_Plattform_Main\\m4labplatform\\node_modules\\request",
"author": {
"name": "Ahmad Nassri",
"email": "ahmad@ahmadnassri.com",
"url": "https://www.ahmadnassri.com/"
},
"bugs": {
"url": "https://github.com/ahmadnassri/node-har-validator/issues"
"url": "https://github.com/ahmadnassri/har-validator/issues"
},
"bundleDependencies": false,
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"dependencies": {
"ajv": "^6.5.5",
"har-schema": "^2.0.0"
"ajv": "^4.9.1",
"har-schema": "^1.0.5"
},
"deprecated": false,
"deprecated": "this library is no longer supported",
"description": "Extremely fast HTTP Archive (HAR) validator using JSON Schema",
"devDependencies": {
"tap": "^12.0.1"
"babel-cli": "^6.18.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-env": "1.1.10",
"babel-register": "^6.18.0",
"codeclimate-test-reporter": "^0.4.0",
"cz-conventional-changelog": "^1.2.0",
"echint": "^4.0.1",
"semantic-release": "^6.3.2",
"snazzy": "^6.0.0",
"tap": "^10.0.0"
},
"echint": {
"ignore": [
"lib/**"
]
},
"engines": {
"node": ">=6"
"node": ">=4"
},
"files": [
"lib"
"lib",
"src"
],
"homepage": "https://github.com/ahmadnassri/node-har-validator",
"homepage": "https://github.com/ahmadnassri/har-validator",
"keywords": [
"har",
"cli",
......@@ -59,21 +79,26 @@
"validate",
"validator"
],
"license": "MIT",
"main": "lib/promise.js",
"license": "ISC",
"main": "lib/node4/promise.js",
"name": "har-validator",
"repository": {
"type": "git",
"url": "git+https://github.com/ahmadnassri/node-har-validator.git"
"url": "git+https://github.com/ahmadnassri/har-validator.git"
},
"scripts": {
"lint": "npx run-p lint:*",
"lint:deps": "npx updated",
"lint:ec": "npx editorconfig-checker .",
"lint:js": "npx eslint .",
"lint:md": "npx remark --quiet --frail .",
"open:coverage": "opener coverage/lcov-report/index.html",
"test": "tap test --coverage-report=lcov --no-browser"
"codeclimate": "BABEL_ENV=test tap --coverage-report=text-lcov | codeclimate-test-reporter",
"compile": "babel -q src",
"coverage": "BABEL_ENV=test tap test --reporter silent --coverage --nyc-arg=--require --nyc-arg=babel-register",
"pretest": "snazzy && echint",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"test": "BABEL_ENV=test tap test --reporter spec --node-arg=--require --node-arg=babel-register",
"test-one": "BABEL_ENV=test tap --reporter spec --node-arg=--require --node-arg=babel-register"
},
"standard": {
"ignore": [
"lib/**"
]
},
"version": "5.1.3"
"version": "4.2.1"
}
......@@ -116,14 +116,11 @@ module.exports = {
}
assert.object(options, 'options');
assert.arrayOfString(options.headers, 'options.headers');
assert.optionalFinite(options.clockSkew, 'options.clockSkew');
assert.optionalNumber(options.clockSkew, 'options.clockSkew');
var authzHeaderName = options.authorizationHeaderName || 'authorization';
if (!request.headers[authzHeaderName]) {
throw new MissingHeaderError('no ' + authzHeaderName + ' header ' +
'present in the request');
}
if (!request.headers.authorization)
throw new MissingHeaderError('no authorization header present in ' +
'the request');
options.clockSkew = options.clockSkew || 300;
......@@ -137,10 +134,18 @@ module.exports = {
var parsed = {
scheme: '',
params: {},
signingString: ''
signingString: '',
get algorithm() {
return this.params.algorithm.toUpperCase();
},
get keyId() {
return this.params.keyId;
}
};
var authz = request.headers[authzHeaderName];
var authz = request.headers.authorization;
for (i = 0; i < authz.length; i++) {
var c = authz.charAt(i);
......@@ -297,7 +302,7 @@ module.exports = {
options.headers.forEach(function (hdr) {
// Remember that we already checked any headers in the params
// were in the request, so if this passes we're good.
if (parsed.params.headers.indexOf(hdr.toLowerCase()) < 0)
if (parsed.params.headers.indexOf(hdr) < 0)
throw new MissingHeaderError(hdr + ' was not a signed header');
});
......@@ -307,8 +312,6 @@ module.exports = {
' is not a supported algorithm');
}
parsed.algorithm = parsed.params.algorithm.toUpperCase();
parsed.keyId = parsed.params.keyId;
return parsed;
}
......
......@@ -387,9 +387,7 @@ module.exports = {
assert.notStrictEqual(signature, '', 'empty signature produced');
}
var authzHeaderName = options.authorizationHeaderName || 'Authorization';
request.setHeader(authzHeaderName, sprintf(AUTHZ_FMT,
request.setHeader('Authorization', sprintf(AUTHZ_FMT,
options.keyId,
options.algorithm,
options.headers.join(' '),
......
{
"_from": "http-signature@~1.2.0",
"_id": "http-signature@1.2.0",
"_from": "http-signature@~1.1.0",
"_id": "http-signature@1.1.1",
"_inBundle": false,
"_integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
"_integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=",
"_location": "/http-signature",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "http-signature@~1.2.0",
"raw": "http-signature@~1.1.0",
"name": "http-signature",
"escapedName": "http-signature",
"rawSpec": "~1.2.0",
"rawSpec": "~1.1.0",
"saveSpec": null,
"fetchSpec": "~1.2.0"
"fetchSpec": "~1.1.0"
},
"_requiredBy": [
"/request"
],
"_resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
"_shasum": "9aecd925114772f3d95b65a60abb8f7c18fbace1",
"_spec": "http-signature@~1.2.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\dev\\node_modules\\request",
"_resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz",
"_shasum": "df72e267066cd0ac67fb76adf8e134a8fbcf91bf",
"_spec": "http-signature@~1.1.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\Main\\02_Plattform_Main\\m4labplatform\\node_modules\\request",
"author": {
"name": "Joyent, Inc"
},
......@@ -44,15 +44,15 @@
}
],
"dependencies": {
"assert-plus": "^1.0.0",
"assert-plus": "^0.2.0",
"jsprim": "^1.2.2",
"sshpk": "^1.7.0"
},
"deprecated": false,
"description": "Reference implementation of Joyent's HTTP Signature scheme.",
"devDependencies": {
"tap": "0.4.2",
"uuid": "^2.0.2"
"node-uuid": "^1.4.1",
"tap": "0.4.2"
},
"engines": {
"node": ">=0.8",
......@@ -73,5 +73,5 @@
"scripts": {
"test": "tap test/*.js"
},
"version": "1.2.0"
"version": "1.1.1"
}
ISC License (ISC)
Copyright 2018 Isaac Z. Schlueter
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# natives
Do stuff with Node.js's native JavaScript modules
## Caveat
Dear Beloved User,
I feel compelled to give you a word of warning if you are considering
using this module.
This module lets you do some creative things with the JavaScript code
in Node.js. There are some things here that are basically a recipe
for memory leaks, or at the very least, being broken with each new
release of Node, since none of these API surfaces are "technically"
"supported" by the team managing the Node.js project.
This module does not ship a _copy_ of Node's internals. It does its
thing by using the exposed source code that lives in Node.js itself.
So, running this on different versions of Node.js will produce
different results.
When your program is broken by changes to Node's internals, or when
Node changes in such a way that this module becomes fundamentally
broken, you will likely get little sympathy. Many people in the Node
community consider this sort of behavior to be unwise and unseemly, if
not outright hostile and morally wrong.
At the very least, you probably just want to run Node with the
(undocumented!) `--expose-internals` flag, rather than go to such
lengths.
Don't use unless you know what you're doing, or at least, are ok with
the risks. Don't say I didn't warn you.
Eternally Yours in OSS,
Isaac Z. Schlueter
## USAGE
```javascript
var natives = require('natives')
// get the source code
var fsCode = natives.source('fs')
// get a evaluated copy of the module
var fsCopy = natives.require('fs')
// you can pass in a whitelist to NOT shim certain things
var fsCopyWithNativeStreams = natives.require('fs', ['stream'])
// note that this is not the same as the "real" fs
assert(fsCopy !== require('fs'))
// but it does have all the same entries
fsCopy.readFileSync(__filename, 'utf8') // etc
```
## Another Caveat
You can't use this to override `require("buffer")` because everything
depends on `Buffer.isBuffer` working properly, so it's important for
that one to be given a pass.
var natives = process.binding('natives')
var module = require('module')
var normalRequire = require
exports.source = src
exports.require = req
var vm = require('vm')
// fallback for 0.x support
var runInThisContext, ContextifyScript, Script
/*istanbul ignore next*/
try {
ContextifyScript = process.binding('contextify').ContextifyScript;
/*istanbul ignore next*/
if (process.version.split('.')[0].length > 2) { // v10.0.0 and above
runInThisContext = vm.runInThisContext;
} else {
runInThisContext = function runInThisContext(code, options) {
var script = new ContextifyScript(code, options);
return script.runInThisContext();
}
}
} catch (er) {
Script = process.binding('evals').NodeScript;
runInThisContext = Script.runInThisContext;
}
var wrap = [
'(function (internalBinding) {' +
' return function (exports, require, module, __filename, __dirname) { ',
'\n };\n});'
];
// Basically the same functionality as node's (buried deep)
// NativeModule class, but without caching, or internal/ blocking,
// or a class, since that's not really necessary. I assume that if
// you're loading something with this module, it's because you WANT
// a separate copy. However, to preserve semantics, any require()
// calls made throughout the internal module load IS cached.
function req (id, whitelist) {
var cache = Object.create(null)
if (Array.isArray(whitelist)) {
// a whitelist of things to pull from the "actual" native modules
whitelist.forEach(function (id) {
cache[id] = {
loading: false,
loaded: true,
filename: id + '.js',
exports: require(id)
}
})
}
return req_(id, cache)
}
function req_ (id, cache) {
// Buffer is special, because it's a type rather than a "normal"
// class, and many things depend on `Buffer.isBuffer` working.
if (id === 'buffer') {
return require('buffer')
}
// native_module isn't actually a natives binding.
// weird, right?
if (id === 'native_module') {
return {
getSource: src,
wrap: function (script) {
return wrap[0] + script + wrap[1]
},
wrapper: wrap,
_cache: cache,
_source: natives,
nonInternalExists: function (id) {
return id.indexOf('internal/') !== 0;
}
}
}
var source = src(id)
if (!source) {
return undefined
}
source = wrap[0] + source + wrap[1]
var internalBinding = function(name) {
if (name === 'types') {
return process.binding('util');
} else {
try {
return process.binding(name);
} catch (e) {}
return {};
}
}
var cachingRequire = function require (id) {
if (cache[id]) {
return cache[id].exports
}
if (id === 'internal/bootstrap/loaders' || id === 'internal/process') {
// Provide just enough to keep `graceful-fs@3` working and tests passing.
// For now.
return {
internalBinding: internalBinding,
NativeModule: {
_source: process.binding('natives'),
nonInternalExists: function(id) {
return !id.startsWith('internal/');
}
}
};
}
return req_(id, cache)
}
var nm = {
exports: {},
loading: true,
loaded: false,
filename: id + '.js'
}
cache[id] = nm
var fn
var setV8Flags = false
try {
require('v8').setFlagsFromString('--allow_natives_syntax')
setV8Flags = true
} catch (e) {}
try {
/* istanbul ignore else */
if (ContextifyScript) {
fn = runInThisContext(source, {
filename: nm.filename,
lineOffset: 0,
displayErrors: true
});
} else {
fn = runInThisContext(source, nm.filename, true);
}
fn(internalBinding)(nm.exports, cachingRequire, nm, nm.filename, '<no dirname available>')
nm.loaded = true
} finally {
nm.loading = false
/*istanbul ignore next*/
if (setV8Flags) {
// Ref: https://github.com/nodejs/node/blob/591a24b819d53a555463b1cbf9290a6d8bcc1bcb/lib/internal/bootstrap_node.js#L429-L434
var re = /^--allow[-_]natives[-_]syntax$/
if (!process.execArgv.some(function (s) { return re.test(s) }))
require('v8').setFlagsFromString('--noallow_natives_syntax')
}
}
return nm.exports
}
function src (id) {
return natives[id]
}
{
"_from": "natives@^1.1.3",
"_id": "natives@1.1.6",
"_inBundle": false,
"_integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==",
"_location": "/natives",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "natives@^1.1.3",
"name": "natives",
"escapedName": "natives",
"rawSpec": "^1.1.3",
"saveSpec": null,
"fetchSpec": "^1.1.3"
},
"_requiredBy": [
"/vinyl-fs/graceful-fs"
],
"_resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz",
"_shasum": "a603b4a498ab77173612b9ea1acdec4d980f00bb",
"_spec": "natives@^1.1.3",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\vinyl-fs\\node_modules\\graceful-fs",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"bugs": {
"url": "https://github.com/addaleax/natives/issues"
},
"bundleDependencies": false,
"deprecated": "This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.",
"description": "Do stuff with Node.js's native JavaScript modules",
"devDependencies": {
"tap": "^11.0.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/addaleax/natives#readme",
"license": "ISC",
"main": "index.js",
"name": "natives",
"repository": {
"type": "git",
"url": "git+https://github.com/addaleax/natives.git"
},
"scripts": {
"test": "tap test/*.js"
},
"version": "1.1.6"
}
......@@ -2,10 +2,3 @@ oauth-sign
==========
OAuth 1 signing. Formerly a vendor lib in mikeal/request, now a standalone module.
## Supported Method Signatures
- HMAC-SHA1
- HMAC-SHA256
- RSA-SHA1
- PLAINTEXT
\ No newline at end of file
var crypto = require('crypto')
, qs = require('querystring')
;
function sha (key, body, algorithm) {
return crypto.createHmac(algorithm, key).update(body).digest('base64')
function sha1 (key, body) {
return crypto.createHmac('sha1', key).update(body).digest('base64')
}
function rsa (key, body) {
return crypto.createSign('RSA-SHA1').update(body).sign(key, 'base64')
return crypto.createSign("RSA-SHA1").update(body).sign(key, 'base64');
}
function rfc3986 (str) {
......@@ -15,6 +17,7 @@ function rfc3986 (str) {
.replace(/\(/g,'%28')
.replace(/\)/g,'%29')
.replace(/'/g,'%27')
;
}
// Maps object to bi-dimensional array
......@@ -27,9 +30,9 @@ function map (obj) {
if (Array.isArray(val))
for (var i = 0; i < val.length; i++)
arr.push([key, val[i]])
else if (typeof val === 'object')
else if (typeof val === "object")
for (var prop in val)
arr.push([key + '[' + prop + ']', val[prop]])
arr.push([key + '[' + prop + ']', val[prop]]);
else
arr.push([key, val])
}
......@@ -83,17 +86,7 @@ function hmacsign (httpMethod, base_uri, params, consumer_secret, token_secret)
token_secret || ''
].map(rfc3986).join('&')
return sha(key, base, 'sha1')
}
function hmacsign256 (httpMethod, base_uri, params, consumer_secret, token_secret) {
var base = generateBase(httpMethod, base_uri, params)
var key = [
consumer_secret || '',
token_secret || ''
].map(rfc3986).join('&')
return sha(key, base, 'sha256')
return sha1(key, base)
}
function rsasign (httpMethod, base_uri, params, private_key, token_secret) {
......@@ -123,24 +116,21 @@ function sign (signMethod, httpMethod, base_uri, params, consumer_secret, token_
case 'HMAC-SHA1':
method = hmacsign
break
case 'HMAC-SHA256':
method = hmacsign256
break
case 'PLAINTEXT':
method = plaintext
skipArgs = 4
break
default:
throw new Error('Signature method not supported: ' + signMethod)
throw new Error("Signature method not supported: " + signMethod)
}
return method.apply(null, [].slice.call(arguments, skipArgs))
}
exports.hmacsign = hmacsign
exports.hmacsign256 = hmacsign256
exports.rsasign = rsasign
exports.plaintext = plaintext
exports.sign = sign
exports.rfc3986 = rfc3986
exports.generateBase = generateBase
\ No newline at end of file
exports.generateBase = generateBase
{
"_from": "oauth-sign@~0.9.0",
"_id": "oauth-sign@0.9.0",
"_from": "oauth-sign@~0.8.1",
"_id": "oauth-sign@0.8.2",
"_inBundle": false,
"_integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==",
"_integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=",
"_location": "/oauth-sign",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "oauth-sign@~0.9.0",
"raw": "oauth-sign@~0.8.1",
"name": "oauth-sign",
"escapedName": "oauth-sign",
"rawSpec": "~0.9.0",
"rawSpec": "~0.8.1",
"saveSpec": null,
"fetchSpec": "~0.9.0"
"fetchSpec": "~0.8.1"
},
"_requiredBy": [
"/request"
],
"_resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
"_shasum": "47a7b016baa68b5fa0ecf3dee08a85c679ac6455",
"_spec": "oauth-sign@~0.9.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\dev\\node_modules\\request",
"_resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
"_shasum": "46a6ab7f0aead8deae9ec0565780b7d4efeb9d43",
"_spec": "oauth-sign@~0.8.1",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\Main\\02_Plattform_Main\\m4labplatform\\node_modules\\request",
"author": {
"name": "Mikeal Rogers",
"email": "mikeal.rogers@gmail.com",
......@@ -52,5 +52,5 @@
"scripts": {
"test": "node test.js"
},
"version": "0.9.0"
"version": "0.8.2"
}
language: node_js
node_js:
- "node"
- "6"
- "4"
- "0.12"
- "0.10"
- "0.8"
\ No newline at end of file
# performance-now [![Build Status](https://travis-ci.org/braveg1rl/performance-now.png?branch=master)](https://travis-ci.org/braveg1rl/performance-now) [![Dependency Status](https://david-dm.org/braveg1rl/performance-now.png)](https://david-dm.org/braveg1rl/performance-now)
# performance-now [![Build Status](https://travis-ci.org/meryn/performance-now.png?branch=master)](https://travis-ci.org/meryn/performance-now) [![Dependency Status](https://david-dm.org/meryn/performance-now.png)](https://david-dm.org/meryn/performance-now)
Implements a function similar to `performance.now` (based on `process.hrtime`).
Modern browsers have a `window.performance` object with - among others - a `now` method which gives time in milliseconds, but with sub-millisecond precision. This module offers the same function based on the Node.js native `process.hrtime` function.
Modern browsers have a `window.performance` object with - among others - a `now` method which gives time in miliseconds, but with sub-milisecond precision. This module offers the same function based on the Node.js native `process.hrtime` function.
Using `process.hrtime` means that the reported time will be monotonically increasing, and not subject to clock-drift.
According to the [High Resolution Time specification](http://www.w3.org/TR/hr-time/), the number of milliseconds reported by `performance.now` should be relative to the value of `performance.timing.navigationStart`.
In the current version of the module (2.0) the reported time is relative to the time the current Node process has started (inferred from `process.uptime()`).
According to the [High Resolution Time specification](http://www.w3.org/TR/hr-time/), the number of miliseconds reported by `performance.now` should be relative to the value of `performance.timing.navigationStart`. For this module, it's relative to when the time when this module got loaded. Right after requiring this module for the first time, the reported time is expected to have a near-zero value.
Version 1.0 reported a different time. The reported time was relative to the time the module was loaded (i.e. the time it was first `require`d). If you need this functionality, version 1.0 is still available on NPM.
Using `process.hrtime` means that the reported time will be monotonically increasing, and not subject to clock-drift.
## Example usage
......@@ -18,13 +14,17 @@ Version 1.0 reported a different time. The reported time was relative to the tim
var now = require("performance-now")
var start = now()
var end = now()
console.log(start.toFixed(3)) // the number of milliseconds the current node process is running
console.log(start.toFixed(3)) // ~ 0.05 on my system
console.log((start-end).toFixed(3)) // ~ 0.002 on my system
```
Running the now function two times right after each other yields a time difference of a few microseconds. Given this overhead, I think it's best to assume that the precision of intervals computed with this method is not higher than 10 microseconds, if you don't know the exact overhead on your own system.
## Credits
The initial structure of this module was generated by [Jumpstart](https://github.com/meryn/jumpstart), using the [Jumpstart Black Coffee](https://github.com/meryn/jumpstart-black-coffee) template.
## License
performance-now is released under the [MIT License](http://opensource.org/licenses/MIT).
Copyright (c) 2017 Braveg1rl
performance-now is released under the [MIT License](http://opensource.org/licenses/MIT).
Copyright (c) 2013 Meryn Stol
\ No newline at end of file
// Generated by CoffeeScript 1.12.2
// Generated by CoffeeScript 1.7.1
(function() {
var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;
var getNanoSeconds, hrtime, loadTime;
if ((typeof performance !== "undefined" && performance !== null) && performance.now) {
module.exports = function() {
......@@ -8,7 +8,7 @@
};
} else if ((typeof process !== "undefined" && process !== null) && process.hrtime) {
module.exports = function() {
return (getNanoSeconds() - nodeLoadTime) / 1e6;
return (getNanoSeconds() - loadTime) / 1e6;
};
hrtime = process.hrtime;
getNanoSeconds = function() {
......@@ -16,9 +16,7 @@
hr = hrtime();
return hr[0] * 1e9 + hr[1];
};
moduleLoadTime = getNanoSeconds();
upTime = process.uptime() * 1e9;
nodeLoadTime = moduleLoadTime - upTime;
loadTime = getNanoSeconds();
} else if (Date.now) {
module.exports = function() {
return Date.now() - loadTime;
......@@ -32,5 +30,3 @@
}
}).call(this);
//# sourceMappingURL=performance-now.js.map
{
"version": 3,
"file": "performance-now.js",
"sourceRoot": "..",
"sources": [
"src/performance-now.coffee"
],
"names": [],
"mappings": ";AAAA;AAAA,MAAA;;EAAA,IAAG,4DAAA,IAAiB,WAAW,CAAC,GAAhC;IACE,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAG,WAAW,CAAC,GAAZ,CAAA;IAAH,EADnB;GAAA,MAEK,IAAG,oDAAA,IAAa,OAAO,CAAC,MAAxB;IACH,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAG,CAAC,cAAA,CAAA,CAAA,GAAmB,YAApB,CAAA,GAAoC;IAAvC;IACjB,MAAA,GAAS,OAAO,CAAC;IACjB,cAAA,GAAiB,SAAA;AACf,UAAA;MAAA,EAAA,GAAK,MAAA,CAAA;aACL,EAAG,CAAA,CAAA,CAAH,GAAQ,GAAR,GAAc,EAAG,CAAA,CAAA;IAFF;IAGjB,cAAA,GAAiB,cAAA,CAAA;IACjB,MAAA,GAAS,OAAO,CAAC,MAAR,CAAA,CAAA,GAAmB;IAC5B,YAAA,GAAe,cAAA,GAAiB,OAR7B;GAAA,MASA,IAAG,IAAI,CAAC,GAAR;IACH,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAG,IAAI,CAAC,GAAL,CAAA,CAAA,GAAa;IAAhB;IACjB,QAAA,GAAW,IAAI,CAAC,GAAL,CAAA,EAFR;GAAA,MAAA;IAIH,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAO,IAAA,IAAA,CAAA,CAAM,CAAC,OAAP,CAAA,CAAJ,GAAuB;IAA1B;IACjB,QAAA,GAAe,IAAA,IAAA,CAAA,CAAM,CAAC,OAAP,CAAA,EALZ;;AAXL"
}
\ No newline at end of file
Copyright (c) 2013 Braveg1rl
Copyright (c) 2013 Meryn Stol
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:
......
{
"_from": "performance-now@^2.1.0",
"_id": "performance-now@2.1.0",
"_from": "performance-now@^0.2.0",
"_id": "performance-now@0.2.0",
"_inBundle": false,
"_integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
"_integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=",
"_location": "/performance-now",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "performance-now@^2.1.0",
"raw": "performance-now@^0.2.0",
"name": "performance-now",
"escapedName": "performance-now",
"rawSpec": "^2.1.0",
"rawSpec": "^0.2.0",
"saveSpec": null,
"fetchSpec": "^2.1.0"
"fetchSpec": "^0.2.0"
},
"_requiredBy": [
"/request"
],
"_resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"_shasum": "6309f4e0e5fa913ec1c69307ae364b4b377c9e7b",
"_spec": "performance-now@^2.1.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\dev\\node_modules\\request",
"_resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz",
"_shasum": "33ef30c5c77d4ea21c5a53869d91b56d8f2555e5",
"_spec": "performance-now@^0.2.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\Main\\02_Plattform_Main\\m4labplatform\\node_modules\\request",
"author": {
"name": "Braveg1rl",
"email": "braveg1rl@outlook.com"
"name": "Meryn Stol",
"email": "merynstol@gmail.com"
},
"bugs": {
"url": "https://github.com/braveg1rl/performance-now/issues"
"url": "https://github.com/meryn/performance-now/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Implements performance.now (based on process.hrtime).",
"devDependencies": {
"bluebird": "^3.4.7",
"call-delayed": "^1.0.0",
"chai": "^3.5.0",
"chai-increasing": "^1.2.0",
"coffee-script": "~1.12.2",
"mocha": "~3.2.0",
"pre-commit": "^1.2.2"
"coffee-script": "~1.7.1",
"mocha": "~1.21.0"
},
"homepage": "https://github.com/braveg1rl/performance-now",
"homepage": "https://github.com/meryn/performance-now",
"keywords": [],
"license": "MIT",
"main": "lib/performance-now.js",
......@@ -51,15 +46,12 @@
"private": false,
"repository": {
"type": "git",
"url": "git://github.com/braveg1rl/performance-now.git"
"url": "git://github.com/meryn/performance-now.git"
},
"scripts": {
"build": "mkdir -p lib && rm -rf lib/* && node_modules/.bin/coffee --compile -m --output lib/ src/",
"prepublish": "npm test",
"pretest": "npm run build",
"test": "mocha",
"watch": "coffee --watch --compile --output lib/ src/"
"pretest": "make build",
"test": "make test"
},
"typings": "src/index.d.ts",
"version": "2.1.0"
"version": "0.2.0"
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment