fsevents 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fsevents might be problematic. Click here for more details.
- package/node_modules/ansi/History.md +7 -0
- package/node_modules/ansi/LICENSE +24 -0
- package/node_modules/ansi/lib/ansi.js +2 -2
- package/node_modules/ansi/package.json +15 -10
- package/node_modules/ansi-regex/package.json +1 -0
- package/node_modules/ansi-styles/package.json +1 -0
- package/node_modules/are-we-there-yet/.npmignore +2 -0
- package/node_modules/are-we-there-yet/index.js +20 -18
- package/node_modules/are-we-there-yet/package.json +15 -13
- package/node_modules/asn1/package.json +3 -1
- package/node_modules/assert-plus/README.md +50 -21
- package/node_modules/assert-plus/assert.js +168 -207
- package/node_modules/assert-plus/package.json +55 -15
- package/node_modules/async/README.md +86 -4
- package/node_modules/async/dist/async.js +4 -3
- package/node_modules/async/dist/async.min.js +1 -1
- package/node_modules/async/lib/async.js +4 -3
- package/node_modules/async/package.json +10 -10
- package/node_modules/aws-sign2/package.json +1 -0
- package/node_modules/aws4/.npmignore +3 -0
- package/node_modules/aws4/.tern-port +1 -0
- package/node_modules/{tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match → aws4}/.travis.yml +2 -0
- package/node_modules/{tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md → aws4/LICENSE} +1 -3
- package/node_modules/aws4/README.md +510 -0
- package/node_modules/aws4/aws4.js +313 -0
- package/node_modules/aws4/example.js +372 -0
- package/node_modules/aws4/node_modules/lru-cache/.npmignore +1 -0
- package/node_modules/aws4/node_modules/lru-cache/.travis.yml +8 -0
- package/node_modules/aws4/node_modules/lru-cache/CONTRIBUTORS +14 -0
- package/node_modules/aws4/node_modules/lru-cache/README.md +137 -0
- package/node_modules/aws4/node_modules/lru-cache/lib/lru-cache.js +334 -0
- package/node_modules/aws4/node_modules/lru-cache/package.json +66 -0
- package/node_modules/aws4/node_modules/lru-cache/test/basic.js +396 -0
- package/node_modules/aws4/node_modules/lru-cache/test/foreach.js +120 -0
- package/node_modules/aws4/node_modules/lru-cache/test/memory-leak.js +51 -0
- package/node_modules/aws4/node_modules/lru-cache/test/serialize.js +216 -0
- package/node_modules/aws4/package.json +113 -0
- package/node_modules/bl/.travis.yml +5 -6
- package/node_modules/bl/bl.js +5 -0
- package/node_modules/bl/package.json +16 -13
- package/node_modules/bl/test/test.js +554 -6
- package/node_modules/block-stream/package.json +1 -0
- package/node_modules/boom/package.json +1 -0
- package/node_modules/caseless/package.json +1 -0
- package/node_modules/chalk/package.json +1 -0
- package/node_modules/combined-stream/package.json +1 -0
- package/node_modules/commander/package.json +1 -0
- package/node_modules/core-util-is/package.json +2 -2
- package/node_modules/cryptiles/package.json +1 -0
- package/node_modules/dashdash/README.md +70 -7
- package/node_modules/dashdash/etc/dashdash.bash_completion.in +388 -0
- package/node_modules/dashdash/lib/dashdash.js +202 -2
- package/node_modules/dashdash/package.json +12 -9
- package/node_modules/debug/.jshintrc +3 -0
- package/node_modules/debug/.npmignore +6 -0
- package/node_modules/debug/History.md +195 -0
- package/node_modules/debug/Makefile +36 -0
- package/node_modules/debug/Readme.md +86 -13
- package/node_modules/debug/bower.json +28 -0
- package/node_modules/debug/browser.js +168 -0
- package/node_modules/debug/component.json +19 -0
- package/node_modules/debug/debug.js +132 -72
- package/node_modules/debug/node.js +209 -0
- package/node_modules/debug/package.json +32 -22
- package/node_modules/deep-extend/README.md +51 -50
- package/node_modules/deep-extend/package.json +14 -16
- package/node_modules/delayed-stream/package.json +1 -0
- package/node_modules/delegates/History.md +6 -0
- package/node_modules/delegates/License +20 -0
- package/node_modules/delegates/package.json +17 -13
- package/node_modules/ecc-jsbn/package.json +3 -1
- package/node_modules/escape-string-regexp/package.json +2 -2
- package/node_modules/extend/package.json +1 -0
- package/node_modules/extsprintf/package.json +4 -2
- package/node_modules/forever-agent/package.json +1 -0
- package/node_modules/form-data/package.json +1 -0
- package/node_modules/fstream/package.json +1 -0
- package/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +1 -0
- package/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +1 -0
- package/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/package.json +1 -0
- package/node_modules/fstream-ignore/node_modules/minimatch/package.json +1 -0
- package/node_modules/fstream-ignore/package.json +3 -1
- package/node_modules/gauge/package.json +14 -12
- package/node_modules/gauge/progress-bar.js +4 -5
- package/node_modules/gauge/test/progress-bar.js +1 -1
- package/node_modules/generate-function/package.json +1 -0
- package/node_modules/generate-object-property/package.json +1 -0
- package/node_modules/graceful-fs/README.md +17 -0
- package/node_modules/graceful-fs/graceful-fs.js +2 -0
- package/node_modules/graceful-fs/package.json +16 -11
- package/node_modules/graceful-readlink/package.json +1 -0
- package/node_modules/har-validator/README.md +45 -122
- package/node_modules/har-validator/package.json +16 -16
- package/node_modules/has-ansi/package.json +1 -0
- package/node_modules/has-unicode/README.md +6 -3
- package/node_modules/has-unicode/index.js +7 -3
- package/node_modules/has-unicode/package.json +15 -13
- package/node_modules/has-unicode/test/index.js +1 -1
- package/node_modules/hawk/README.md +634 -634
- package/node_modules/hawk/bower.json +24 -24
- package/node_modules/hawk/component.json +18 -18
- package/node_modules/hawk/dist/client.js +343 -340
- package/node_modules/hawk/example/usage.js +78 -78
- package/node_modules/hawk/lib/browser.js +637 -637
- package/node_modules/hawk/lib/client.js +369 -369
- package/node_modules/hawk/lib/crypto.js +126 -126
- package/node_modules/hawk/lib/index.js +15 -15
- package/node_modules/hawk/lib/server.js +548 -540
- package/node_modules/hawk/lib/utils.js +184 -164
- package/node_modules/hawk/package.json +9 -8
- package/node_modules/hawk/test/browser.js +1492 -1492
- package/node_modules/hawk/test/client.js +440 -440
- package/node_modules/hawk/test/crypto.js +70 -70
- package/node_modules/hawk/test/index.js +378 -378
- package/node_modules/hawk/test/readme.js +95 -95
- package/node_modules/hawk/test/server.js +1329 -1302
- package/node_modules/hawk/test/uri.js +838 -838
- package/node_modules/hawk/test/utils.js +149 -121
- package/node_modules/hoek/package.json +1 -0
- package/node_modules/http-signature/CHANGES.md +7 -0
- package/node_modules/http-signature/http_signing.md +71 -3
- package/node_modules/http-signature/lib/signer.js +5 -0
- package/node_modules/http-signature/package.json +13 -11
- package/node_modules/ini/package.json +3 -1
- package/node_modules/is-my-json-valid/formats.js +1 -1
- package/node_modules/is-my-json-valid/package.json +11 -10
- package/node_modules/is-property/package.json +1 -0
- package/node_modules/is-typedarray/package.json +3 -1
- package/node_modules/isarray/package.json +2 -2
- package/node_modules/isstream/package.json +1 -0
- package/node_modules/jodid25519/package.json +3 -1
- package/node_modules/jsbn/package.json +3 -1
- package/node_modules/json-schema/package.json +2 -1
- package/node_modules/json-stringify-safe/package.json +1 -0
- package/node_modules/jsonpointer/package.json +1 -0
- package/node_modules/jsprim/package.json +3 -1
- package/node_modules/lodash._basetostring/package.json +4 -4
- package/node_modules/lodash._createpadding/package.json +3 -2
- package/node_modules/lodash._root/LICENSE +22 -0
- package/node_modules/lodash._root/README.md +18 -0
- package/node_modules/lodash._root/index.js +53 -0
- package/node_modules/lodash._root/package.json +77 -0
- package/node_modules/lodash.pad/LICENSE +2 -2
- package/node_modules/lodash.pad/README.md +4 -6
- package/node_modules/lodash.pad/index.js +347 -15
- package/node_modules/lodash.pad/package.json +20 -34
- package/node_modules/lodash.padleft/package.json +3 -1
- package/node_modules/lodash.padright/package.json +3 -1
- package/node_modules/lodash.repeat/LICENSE +2 -2
- package/node_modules/lodash.repeat/README.md +4 -6
- package/node_modules/lodash.repeat/index.js +262 -11
- package/node_modules/lodash.repeat/package.json +21 -34
- package/node_modules/mime-db/package.json +2 -2
- package/node_modules/mime-types/package.json +2 -2
- package/node_modules/ms/.npmignore +5 -0
- package/node_modules/{deep-extend → ms}/LICENSE +2 -2
- package/node_modules/ms/README.md +35 -0
- package/node_modules/ms/index.js +125 -0
- package/node_modules/ms/package.json +56 -0
- package/node_modules/node-pre-gyp/CHANGELOG.md +8 -0
- package/node_modules/node-pre-gyp/LICENSE +27 -0
- package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +36 -0
- package/node_modules/node-pre-gyp/package.json +23 -22
- package/node_modules/node-uuid/package.json +1 -0
- package/node_modules/npmlog/package.json +18 -16
- package/node_modules/oauth-sign/index.js +2 -0
- package/node_modules/oauth-sign/package.json +10 -9
- package/node_modules/once/README.md +18 -0
- package/node_modules/once/once.js +8 -6
- package/node_modules/once/package.json +20 -12
- package/node_modules/pinkie/index.js +3 -3
- package/node_modules/pinkie/package.json +10 -9
- package/node_modules/pinkie/readme.md +1 -1
- package/node_modules/pinkie-promise/package.json +1 -0
- package/node_modules/process-nextick-args/package.json +2 -2
- package/node_modules/qs/.eslintrc +17 -0
- package/node_modules/qs/.travis.yml +66 -5
- package/node_modules/qs/CHANGELOG.md +86 -75
- package/node_modules/qs/README.md +85 -81
- package/node_modules/qs/bower.json +1 -1
- package/node_modules/qs/component.json +1 -1
- package/node_modules/qs/dist/qs.js +108 -177
- package/node_modules/qs/lib/index.js +1 -7
- package/node_modules/qs/lib/parse.js +26 -49
- package/node_modules/qs/lib/stringify.js +22 -46
- package/node_modules/qs/lib/utils.js +45 -73
- package/node_modules/qs/package.json +51 -28
- package/node_modules/qs/test/index.js +5 -0
- package/node_modules/qs/test/parse.js +236 -321
- package/node_modules/qs/test/stringify.js +139 -197
- package/node_modules/qs/test/utils.js +6 -25
- package/node_modules/rc/node_modules/minimist/package.json +1 -0
- package/node_modules/rc/package.json +1 -0
- package/node_modules/readable-stream/package.json +1 -0
- package/node_modules/request/CHANGELOG.md +16 -1
- package/node_modules/request/README.md +1 -1
- package/node_modules/request/lib/har.js +3 -2
- package/node_modules/request/lib/multipart.js +3 -0
- package/node_modules/request/lib/tunnel.js +0 -2
- package/node_modules/request/package.json +20 -17
- package/node_modules/request/request.js +50 -26
- package/node_modules/rimraf/README.md +1 -1
- package/node_modules/rimraf/node_modules/glob/README.md +2 -2
- package/node_modules/rimraf/node_modules/glob/glob.js +14 -1
- package/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +1 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/inflight/package.json +1 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json +2 -1
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +1 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +1 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +1 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/package.json +1 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +1 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/once/package.json +1 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/path-is-absolute/package.json +1 -0
- package/node_modules/rimraf/node_modules/glob/package.json +11 -11
- package/node_modules/rimraf/package.json +13 -12
- package/node_modules/semver/package.json +3 -1
- package/node_modules/sntp/package.json +1 -0
- package/node_modules/sshpk/.npmignore +1 -0
- package/node_modules/sshpk/bin/sshpk-sign +176 -0
- package/node_modules/sshpk/bin/sshpk-verify +166 -0
- package/node_modules/sshpk/lib/ed-compat.js +2 -0
- package/node_modules/sshpk/lib/key.js +6 -0
- package/node_modules/sshpk/man/man1/sshpk-conv.1 +135 -0
- package/node_modules/sshpk/man/man1/sshpk-sign.1 +81 -0
- package/node_modules/sshpk/man/man1/sshpk-verify.1 +68 -0
- package/node_modules/sshpk/package.json +18 -9
- package/node_modules/string_decoder/package.json +2 -2
- package/node_modules/stringstream/package.json +1 -0
- package/node_modules/strip-ansi/package.json +1 -0
- package/node_modules/strip-json-comments/package.json +1 -0
- package/node_modules/supports-color/package.json +1 -0
- package/node_modules/tar/package.json +1 -0
- package/node_modules/tar-pack/README.md +2 -2
- package/node_modules/tar-pack/package.json +25 -26
- package/node_modules/tough-cookie/package.json +1 -0
- package/node_modules/tunnel-agent/package.json +1 -0
- package/node_modules/tweetnacl/README.md +1 -1
- package/node_modules/tweetnacl/package.json +13 -11
- package/node_modules/uid-number/package.json +14 -13
- package/node_modules/uid-number/uid-number.js +9 -4
- package/node_modules/util-deprecate/package.json +2 -2
- package/node_modules/verror/package.json +1 -0
- package/node_modules/{tar-pack/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy → wrappy}/package.json +3 -2
- package/node_modules/xtend/package.json +1 -0
- package/package.json +2 -2
- package/node_modules/are-we-there-yet/README.md~ +0 -183
- package/node_modules/bl/test/basic-test.js +0 -541
- package/node_modules/bl/test/sauce.js +0 -38
- package/node_modules/debug/index.js +0 -5
- package/node_modules/debug/lib/debug.js +0 -147
- package/node_modules/deep-extend/test/index.spec.js +0 -220
- package/node_modules/deep-extend/test/mocha.opts +0 -1
- package/node_modules/gauge/README.md~ +0 -161
- package/node_modules/has-unicode/README.md~ +0 -4
- package/node_modules/once/LICENSE +0 -27
- package/node_modules/once/test/once.js +0 -18
- package/node_modules/sshpk/node_modules/assert-plus/README.md +0 -155
- package/node_modules/sshpk/node_modules/assert-plus/assert.js +0 -206
- package/node_modules/sshpk/node_modules/assert-plus/package.json +0 -88
- package/node_modules/tar-pack/node_modules/rimraf/README.md +0 -43
- package/node_modules/tar-pack/node_modules/rimraf/bin.js +0 -40
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/README.md +0 -359
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/common.js +0 -226
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/glob.js +0 -752
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/.eslintrc +0 -17
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/README.md +0 -37
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/inflight.js +0 -44
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +0 -58
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/package.json +0 -67
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/test.js +0 -97
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inherits/LICENSE +0 -16
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inherits/README.md +0 -42
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits.js +0 -1
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits_browser.js +0 -23
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json +0 -58
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inherits/test.js +0 -25
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/README.md +0 -216
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/minimatch.js +0 -912
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +0 -3
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +0 -122
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +0 -8
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +0 -191
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +0 -2
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +0 -6
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +0 -89
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +0 -5
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +0 -50
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +0 -79
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +0 -84
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml +0 -4
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +0 -18
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +0 -62
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +0 -6
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +0 -13
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +0 -90
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +0 -39
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +0 -81
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/minimatch/package.json +0 -66
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/once/README.md +0 -51
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE +0 -15
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +0 -36
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +0 -51
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +0 -33
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/once/once.js +0 -21
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/once/package.json +0 -70
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/path-is-absolute/index.js +0 -20
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/path-is-absolute/package.json +0 -78
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/node_modules/path-is-absolute/readme.md +0 -51
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/package.json +0 -79
- package/node_modules/tar-pack/node_modules/rimraf/node_modules/glob/sync.js +0 -460
- package/node_modules/tar-pack/node_modules/rimraf/package.json +0 -69
- package/node_modules/tar-pack/node_modules/rimraf/rimraf.js +0 -333
- package/node_modules/uid-number/LICENCE +0 -25
- /package/node_modules/{sshpk/node_modules/assert-plus → assert-plus}/AUTHORS +0 -0
- /package/node_modules/{sshpk/node_modules/assert-plus → assert-plus}/CHANGES.md +0 -0
- /package/node_modules/{tar-pack/node_modules/rimraf → aws4/node_modules/lru-cache}/LICENSE +0 -0
- /package/node_modules/{tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight → uid-number}/LICENSE +0 -0
- /package/node_modules/{tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy → wrappy}/LICENSE +0 -0
- /package/node_modules/{tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy → wrappy}/README.md +0 -0
- /package/node_modules/{tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy → wrappy}/test/basic.js +0 -0
- /package/node_modules/{tar-pack/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy → wrappy}/wrappy.js +0 -0
@@ -1,369 +1,369 @@
|
|
1
|
-
// Load modules
|
2
|
-
|
3
|
-
var Url = require('url');
|
4
|
-
var Hoek = require('hoek');
|
5
|
-
var Cryptiles = require('cryptiles');
|
6
|
-
var Crypto = require('./crypto');
|
7
|
-
var Utils = require('./utils');
|
8
|
-
|
9
|
-
|
10
|
-
// Declare internals
|
11
|
-
|
12
|
-
var internals = {};
|
13
|
-
|
14
|
-
|
15
|
-
// Generate an Authorization header for a given request
|
16
|
-
|
17
|
-
/*
|
18
|
-
uri: 'http://example.com/resource?a=b' or object from Url.parse()
|
19
|
-
method: HTTP verb (e.g. 'GET', 'POST')
|
20
|
-
options: {
|
21
|
-
|
22
|
-
// Required
|
23
|
-
|
24
|
-
credentials: {
|
25
|
-
id: 'dh37fgj492je',
|
26
|
-
key: 'aoijedoaijsdlaksjdl',
|
27
|
-
algorithm: 'sha256' // 'sha1', 'sha256'
|
28
|
-
},
|
29
|
-
|
30
|
-
// Optional
|
31
|
-
|
32
|
-
ext: 'application-specific', // Application specific data sent via the ext attribute
|
33
|
-
timestamp: Date.now(), // A pre-calculated timestamp
|
34
|
-
nonce: '2334f34f', // A pre-generated nonce
|
35
|
-
localtimeOffsetMsec: 400, // Time offset to sync with server time (ignored if timestamp provided)
|
36
|
-
payload: '{"some":"payload"}', // UTF-8 encoded string for body hash generation (ignored if hash provided)
|
37
|
-
contentType: 'application/json', // Payload content-type (ignored if hash provided)
|
38
|
-
hash: 'U4MKKSmiVxk37JCCrAVIjV=', // Pre-calculated payload hash
|
39
|
-
app: '24s23423f34dx', // Oz application id
|
40
|
-
dlg: '234sz34tww3sd' // Oz delegated-by application id
|
41
|
-
}
|
42
|
-
*/
|
43
|
-
|
44
|
-
exports.header = function (uri, method, options) {
|
45
|
-
|
46
|
-
var result = {
|
47
|
-
field: '',
|
48
|
-
artifacts: {}
|
49
|
-
};
|
50
|
-
|
51
|
-
// Validate inputs
|
52
|
-
|
53
|
-
if (!uri || (typeof uri !== 'string' && typeof uri !== 'object') ||
|
54
|
-
!method || typeof method !== 'string' ||
|
55
|
-
!options || typeof options !== 'object') {
|
56
|
-
|
57
|
-
result.err = 'Invalid argument type';
|
58
|
-
return result;
|
59
|
-
}
|
60
|
-
|
61
|
-
// Application time
|
62
|
-
|
63
|
-
var timestamp = options.timestamp || Utils.nowSecs(options.localtimeOffsetMsec);
|
64
|
-
|
65
|
-
// Validate credentials
|
66
|
-
|
67
|
-
var credentials = options.credentials;
|
68
|
-
if (!credentials ||
|
69
|
-
!credentials.id ||
|
70
|
-
!credentials.key ||
|
71
|
-
!credentials.algorithm) {
|
72
|
-
|
73
|
-
result.err = 'Invalid credential object';
|
74
|
-
return result;
|
75
|
-
}
|
76
|
-
|
77
|
-
if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
78
|
-
result.err = 'Unknown algorithm';
|
79
|
-
return result;
|
80
|
-
}
|
81
|
-
|
82
|
-
// Parse URI
|
83
|
-
|
84
|
-
if (typeof uri === 'string') {
|
85
|
-
uri = Url.parse(uri);
|
86
|
-
}
|
87
|
-
|
88
|
-
// Calculate signature
|
89
|
-
|
90
|
-
var artifacts = {
|
91
|
-
ts: timestamp,
|
92
|
-
nonce: options.nonce || Cryptiles.randomString(6),
|
93
|
-
method: method,
|
94
|
-
resource: uri.pathname + (uri.search || ''), // Maintain trailing '?'
|
95
|
-
host: uri.hostname,
|
96
|
-
port: uri.port || (uri.protocol === 'http:' ? 80 : 443),
|
97
|
-
hash: options.hash,
|
98
|
-
ext: options.ext,
|
99
|
-
app: options.app,
|
100
|
-
dlg: options.dlg
|
101
|
-
};
|
102
|
-
|
103
|
-
result.artifacts = artifacts;
|
104
|
-
|
105
|
-
// Calculate payload hash
|
106
|
-
|
107
|
-
if (!artifacts.hash &&
|
108
|
-
(options.payload || options.payload === '')) {
|
109
|
-
|
110
|
-
artifacts.hash = Crypto.calculatePayloadHash(options.payload, credentials.algorithm, options.contentType);
|
111
|
-
}
|
112
|
-
|
113
|
-
var mac = Crypto.calculateMac('header', credentials, artifacts);
|
114
|
-
|
115
|
-
// Construct header
|
116
|
-
|
117
|
-
var hasExt = artifacts.ext !== null && artifacts.ext !== undefined && artifacts.ext !== ''; // Other falsey values allowed
|
118
|
-
var header = 'Hawk id="' + credentials.id +
|
119
|
-
'", ts="' + artifacts.ts +
|
120
|
-
'", nonce="' + artifacts.nonce +
|
121
|
-
(artifacts.hash ? '", hash="' + artifacts.hash : '') +
|
122
|
-
(hasExt ? '", ext="' + Hoek.escapeHeaderAttribute(artifacts.ext) : '') +
|
123
|
-
'", mac="' + mac + '"';
|
124
|
-
|
125
|
-
if (artifacts.app) {
|
126
|
-
header += ', app="' + artifacts.app +
|
127
|
-
(artifacts.dlg ? '", dlg="' + artifacts.dlg : '') + '"';
|
128
|
-
}
|
129
|
-
|
130
|
-
result.field = header;
|
131
|
-
|
132
|
-
return result;
|
133
|
-
};
|
134
|
-
|
135
|
-
|
136
|
-
// Validate server response
|
137
|
-
|
138
|
-
/*
|
139
|
-
res: node's response object
|
140
|
-
artifacts: object received from header().artifacts
|
141
|
-
options: {
|
142
|
-
payload: optional payload received
|
143
|
-
required: specifies if a Server-Authorization header is required. Defaults to 'false'
|
144
|
-
}
|
145
|
-
*/
|
146
|
-
|
147
|
-
exports.authenticate = function (res, credentials, artifacts, options) {
|
148
|
-
|
149
|
-
artifacts = Hoek.clone(artifacts);
|
150
|
-
options = options || {};
|
151
|
-
|
152
|
-
if (res.headers['www-authenticate']) {
|
153
|
-
|
154
|
-
// Parse HTTP WWW-Authenticate header
|
155
|
-
|
156
|
-
var wwwAttributes = Utils.parseAuthorizationHeader(res.headers['www-authenticate'], ['ts', 'tsm', 'error']);
|
157
|
-
if (wwwAttributes instanceof Error) {
|
158
|
-
return false;
|
159
|
-
}
|
160
|
-
|
161
|
-
// Validate server timestamp (not used to update clock since it is done via the SNPT client)
|
162
|
-
|
163
|
-
if (wwwAttributes.ts) {
|
164
|
-
var tsm = Crypto.calculateTsMac(wwwAttributes.ts, credentials);
|
165
|
-
if (tsm !== wwwAttributes.tsm) {
|
166
|
-
return false;
|
167
|
-
}
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
// Parse HTTP Server-Authorization header
|
172
|
-
|
173
|
-
if (!res.headers['server-authorization'] &&
|
174
|
-
!options.required) {
|
175
|
-
|
176
|
-
return true;
|
177
|
-
}
|
178
|
-
|
179
|
-
var attributes = Utils.parseAuthorizationHeader(res.headers['server-authorization'], ['mac', 'ext', 'hash']);
|
180
|
-
if (attributes instanceof Error) {
|
181
|
-
return false;
|
182
|
-
}
|
183
|
-
|
184
|
-
artifacts.ext = attributes.ext;
|
185
|
-
artifacts.hash = attributes.hash;
|
186
|
-
|
187
|
-
var mac = Crypto.calculateMac('response', credentials, artifacts);
|
188
|
-
if (mac !== attributes.mac) {
|
189
|
-
return false;
|
190
|
-
}
|
191
|
-
|
192
|
-
if (!options.payload &&
|
193
|
-
options.payload !== '') {
|
194
|
-
|
195
|
-
return true;
|
196
|
-
}
|
197
|
-
|
198
|
-
if (!attributes.hash) {
|
199
|
-
return false;
|
200
|
-
}
|
201
|
-
|
202
|
-
var calculatedHash = Crypto.calculatePayloadHash(options.payload, credentials.algorithm, res.headers['content-type']);
|
203
|
-
return (calculatedHash === attributes.hash);
|
204
|
-
};
|
205
|
-
|
206
|
-
|
207
|
-
// Generate a bewit value for a given URI
|
208
|
-
|
209
|
-
/*
|
210
|
-
uri: 'http://example.com/resource?a=b' or object from Url.parse()
|
211
|
-
options: {
|
212
|
-
|
213
|
-
// Required
|
214
|
-
|
215
|
-
credentials: {
|
216
|
-
id: 'dh37fgj492je',
|
217
|
-
key: 'aoijedoaijsdlaksjdl',
|
218
|
-
algorithm: 'sha256' // 'sha1', 'sha256'
|
219
|
-
},
|
220
|
-
ttlSec: 60 * 60, // TTL in seconds
|
221
|
-
|
222
|
-
// Optional
|
223
|
-
|
224
|
-
ext: 'application-specific', // Application specific data sent via the ext attribute
|
225
|
-
localtimeOffsetMsec: 400 // Time offset to sync with server time
|
226
|
-
};
|
227
|
-
*/
|
228
|
-
|
229
|
-
exports.getBewit = function (uri, options) {
|
230
|
-
|
231
|
-
// Validate inputs
|
232
|
-
|
233
|
-
if (!uri ||
|
234
|
-
(typeof uri !== 'string' && typeof uri !== 'object') ||
|
235
|
-
!options ||
|
236
|
-
typeof options !== 'object' ||
|
237
|
-
!options.ttlSec) {
|
238
|
-
|
239
|
-
return '';
|
240
|
-
}
|
241
|
-
|
242
|
-
options.ext = (options.ext === null || options.ext === undefined ? '' : options.ext); // Zero is valid value
|
243
|
-
|
244
|
-
// Application time
|
245
|
-
|
246
|
-
var now = Utils.now(options.localtimeOffsetMsec);
|
247
|
-
|
248
|
-
// Validate credentials
|
249
|
-
|
250
|
-
var credentials = options.credentials;
|
251
|
-
if (!credentials ||
|
252
|
-
!credentials.id ||
|
253
|
-
!credentials.key ||
|
254
|
-
!credentials.algorithm) {
|
255
|
-
|
256
|
-
return '';
|
257
|
-
}
|
258
|
-
|
259
|
-
if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
260
|
-
return '';
|
261
|
-
}
|
262
|
-
|
263
|
-
// Parse URI
|
264
|
-
|
265
|
-
if (typeof uri === 'string') {
|
266
|
-
uri = Url.parse(uri);
|
267
|
-
}
|
268
|
-
|
269
|
-
// Calculate signature
|
270
|
-
|
271
|
-
var exp = Math.floor(now / 1000) + options.ttlSec;
|
272
|
-
var mac = Crypto.calculateMac('bewit', credentials, {
|
273
|
-
ts: exp,
|
274
|
-
nonce: '',
|
275
|
-
method: 'GET',
|
276
|
-
resource: uri.pathname + (uri.search || ''), // Maintain trailing '?'
|
277
|
-
host: uri.hostname,
|
278
|
-
port: uri.port || (uri.protocol === 'http:' ? 80 : 443),
|
279
|
-
ext: options.ext
|
280
|
-
});
|
281
|
-
|
282
|
-
// Construct bewit: id\exp\mac\ext
|
283
|
-
|
284
|
-
var bewit = credentials.id + '\\' + exp + '\\' + mac + '\\' + options.ext;
|
285
|
-
return Hoek.base64urlEncode(bewit);
|
286
|
-
};
|
287
|
-
|
288
|
-
|
289
|
-
// Generate an authorization string for a message
|
290
|
-
|
291
|
-
/*
|
292
|
-
host: 'example.com',
|
293
|
-
port: 8000,
|
294
|
-
message: '{"some":"payload"}', // UTF-8 encoded string for body hash generation
|
295
|
-
options: {
|
296
|
-
|
297
|
-
// Required
|
298
|
-
|
299
|
-
credentials: {
|
300
|
-
id: 'dh37fgj492je',
|
301
|
-
key: 'aoijedoaijsdlaksjdl',
|
302
|
-
algorithm: 'sha256' // 'sha1', 'sha256'
|
303
|
-
},
|
304
|
-
|
305
|
-
// Optional
|
306
|
-
|
307
|
-
timestamp: Date.now(), // A pre-calculated timestamp
|
308
|
-
nonce: '2334f34f', // A pre-generated nonce
|
309
|
-
localtimeOffsetMsec: 400, // Time offset to sync with server time (ignored if timestamp provided)
|
310
|
-
}
|
311
|
-
*/
|
312
|
-
|
313
|
-
exports.message = function (host, port, message, options) {
|
314
|
-
|
315
|
-
// Validate inputs
|
316
|
-
|
317
|
-
if (!host || typeof host !== 'string' ||
|
318
|
-
!port || typeof port !== 'number' ||
|
319
|
-
message === null || message === undefined || typeof message !== 'string' ||
|
320
|
-
!options || typeof options !== 'object') {
|
321
|
-
|
322
|
-
return null;
|
323
|
-
}
|
324
|
-
|
325
|
-
// Application time
|
326
|
-
|
327
|
-
var timestamp = options.timestamp || Utils.nowSecs(options.localtimeOffsetMsec);
|
328
|
-
|
329
|
-
// Validate credentials
|
330
|
-
|
331
|
-
var credentials = options.credentials;
|
332
|
-
if (!credentials ||
|
333
|
-
!credentials.id ||
|
334
|
-
!credentials.key ||
|
335
|
-
!credentials.algorithm) {
|
336
|
-
|
337
|
-
// Invalid credential object
|
338
|
-
return null;
|
339
|
-
}
|
340
|
-
|
341
|
-
if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
342
|
-
return null;
|
343
|
-
}
|
344
|
-
|
345
|
-
// Calculate signature
|
346
|
-
|
347
|
-
var artifacts = {
|
348
|
-
ts: timestamp,
|
349
|
-
nonce: options.nonce || Cryptiles.randomString(6),
|
350
|
-
host: host,
|
351
|
-
port: port,
|
352
|
-
hash: Crypto.calculatePayloadHash(message, credentials.algorithm)
|
353
|
-
};
|
354
|
-
|
355
|
-
// Construct authorization
|
356
|
-
|
357
|
-
var result = {
|
358
|
-
id: credentials.id,
|
359
|
-
ts: artifacts.ts,
|
360
|
-
nonce: artifacts.nonce,
|
361
|
-
hash: artifacts.hash,
|
362
|
-
mac: Crypto.calculateMac('message', credentials, artifacts)
|
363
|
-
};
|
364
|
-
|
365
|
-
return result;
|
366
|
-
};
|
367
|
-
|
368
|
-
|
369
|
-
|
1
|
+
// Load modules
|
2
|
+
|
3
|
+
var Url = require('url');
|
4
|
+
var Hoek = require('hoek');
|
5
|
+
var Cryptiles = require('cryptiles');
|
6
|
+
var Crypto = require('./crypto');
|
7
|
+
var Utils = require('./utils');
|
8
|
+
|
9
|
+
|
10
|
+
// Declare internals
|
11
|
+
|
12
|
+
var internals = {};
|
13
|
+
|
14
|
+
|
15
|
+
// Generate an Authorization header for a given request
|
16
|
+
|
17
|
+
/*
|
18
|
+
uri: 'http://example.com/resource?a=b' or object from Url.parse()
|
19
|
+
method: HTTP verb (e.g. 'GET', 'POST')
|
20
|
+
options: {
|
21
|
+
|
22
|
+
// Required
|
23
|
+
|
24
|
+
credentials: {
|
25
|
+
id: 'dh37fgj492je',
|
26
|
+
key: 'aoijedoaijsdlaksjdl',
|
27
|
+
algorithm: 'sha256' // 'sha1', 'sha256'
|
28
|
+
},
|
29
|
+
|
30
|
+
// Optional
|
31
|
+
|
32
|
+
ext: 'application-specific', // Application specific data sent via the ext attribute
|
33
|
+
timestamp: Date.now(), // A pre-calculated timestamp
|
34
|
+
nonce: '2334f34f', // A pre-generated nonce
|
35
|
+
localtimeOffsetMsec: 400, // Time offset to sync with server time (ignored if timestamp provided)
|
36
|
+
payload: '{"some":"payload"}', // UTF-8 encoded string for body hash generation (ignored if hash provided)
|
37
|
+
contentType: 'application/json', // Payload content-type (ignored if hash provided)
|
38
|
+
hash: 'U4MKKSmiVxk37JCCrAVIjV=', // Pre-calculated payload hash
|
39
|
+
app: '24s23423f34dx', // Oz application id
|
40
|
+
dlg: '234sz34tww3sd' // Oz delegated-by application id
|
41
|
+
}
|
42
|
+
*/
|
43
|
+
|
44
|
+
exports.header = function (uri, method, options) {
|
45
|
+
|
46
|
+
var result = {
|
47
|
+
field: '',
|
48
|
+
artifacts: {}
|
49
|
+
};
|
50
|
+
|
51
|
+
// Validate inputs
|
52
|
+
|
53
|
+
if (!uri || (typeof uri !== 'string' && typeof uri !== 'object') ||
|
54
|
+
!method || typeof method !== 'string' ||
|
55
|
+
!options || typeof options !== 'object') {
|
56
|
+
|
57
|
+
result.err = 'Invalid argument type';
|
58
|
+
return result;
|
59
|
+
}
|
60
|
+
|
61
|
+
// Application time
|
62
|
+
|
63
|
+
var timestamp = options.timestamp || Utils.nowSecs(options.localtimeOffsetMsec);
|
64
|
+
|
65
|
+
// Validate credentials
|
66
|
+
|
67
|
+
var credentials = options.credentials;
|
68
|
+
if (!credentials ||
|
69
|
+
!credentials.id ||
|
70
|
+
!credentials.key ||
|
71
|
+
!credentials.algorithm) {
|
72
|
+
|
73
|
+
result.err = 'Invalid credential object';
|
74
|
+
return result;
|
75
|
+
}
|
76
|
+
|
77
|
+
if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
78
|
+
result.err = 'Unknown algorithm';
|
79
|
+
return result;
|
80
|
+
}
|
81
|
+
|
82
|
+
// Parse URI
|
83
|
+
|
84
|
+
if (typeof uri === 'string') {
|
85
|
+
uri = Url.parse(uri);
|
86
|
+
}
|
87
|
+
|
88
|
+
// Calculate signature
|
89
|
+
|
90
|
+
var artifacts = {
|
91
|
+
ts: timestamp,
|
92
|
+
nonce: options.nonce || Cryptiles.randomString(6),
|
93
|
+
method: method,
|
94
|
+
resource: uri.pathname + (uri.search || ''), // Maintain trailing '?'
|
95
|
+
host: uri.hostname,
|
96
|
+
port: uri.port || (uri.protocol === 'http:' ? 80 : 443),
|
97
|
+
hash: options.hash,
|
98
|
+
ext: options.ext,
|
99
|
+
app: options.app,
|
100
|
+
dlg: options.dlg
|
101
|
+
};
|
102
|
+
|
103
|
+
result.artifacts = artifacts;
|
104
|
+
|
105
|
+
// Calculate payload hash
|
106
|
+
|
107
|
+
if (!artifacts.hash &&
|
108
|
+
(options.payload || options.payload === '')) {
|
109
|
+
|
110
|
+
artifacts.hash = Crypto.calculatePayloadHash(options.payload, credentials.algorithm, options.contentType);
|
111
|
+
}
|
112
|
+
|
113
|
+
var mac = Crypto.calculateMac('header', credentials, artifacts);
|
114
|
+
|
115
|
+
// Construct header
|
116
|
+
|
117
|
+
var hasExt = artifacts.ext !== null && artifacts.ext !== undefined && artifacts.ext !== ''; // Other falsey values allowed
|
118
|
+
var header = 'Hawk id="' + credentials.id +
|
119
|
+
'", ts="' + artifacts.ts +
|
120
|
+
'", nonce="' + artifacts.nonce +
|
121
|
+
(artifacts.hash ? '", hash="' + artifacts.hash : '') +
|
122
|
+
(hasExt ? '", ext="' + Hoek.escapeHeaderAttribute(artifacts.ext) : '') +
|
123
|
+
'", mac="' + mac + '"';
|
124
|
+
|
125
|
+
if (artifacts.app) {
|
126
|
+
header += ', app="' + artifacts.app +
|
127
|
+
(artifacts.dlg ? '", dlg="' + artifacts.dlg : '') + '"';
|
128
|
+
}
|
129
|
+
|
130
|
+
result.field = header;
|
131
|
+
|
132
|
+
return result;
|
133
|
+
};
|
134
|
+
|
135
|
+
|
136
|
+
// Validate server response
|
137
|
+
|
138
|
+
/*
|
139
|
+
res: node's response object
|
140
|
+
artifacts: object received from header().artifacts
|
141
|
+
options: {
|
142
|
+
payload: optional payload received
|
143
|
+
required: specifies if a Server-Authorization header is required. Defaults to 'false'
|
144
|
+
}
|
145
|
+
*/
|
146
|
+
|
147
|
+
exports.authenticate = function (res, credentials, artifacts, options) {
|
148
|
+
|
149
|
+
artifacts = Hoek.clone(artifacts);
|
150
|
+
options = options || {};
|
151
|
+
|
152
|
+
if (res.headers['www-authenticate']) {
|
153
|
+
|
154
|
+
// Parse HTTP WWW-Authenticate header
|
155
|
+
|
156
|
+
var wwwAttributes = Utils.parseAuthorizationHeader(res.headers['www-authenticate'], ['ts', 'tsm', 'error']);
|
157
|
+
if (wwwAttributes instanceof Error) {
|
158
|
+
return false;
|
159
|
+
}
|
160
|
+
|
161
|
+
// Validate server timestamp (not used to update clock since it is done via the SNPT client)
|
162
|
+
|
163
|
+
if (wwwAttributes.ts) {
|
164
|
+
var tsm = Crypto.calculateTsMac(wwwAttributes.ts, credentials);
|
165
|
+
if (tsm !== wwwAttributes.tsm) {
|
166
|
+
return false;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
// Parse HTTP Server-Authorization header
|
172
|
+
|
173
|
+
if (!res.headers['server-authorization'] &&
|
174
|
+
!options.required) {
|
175
|
+
|
176
|
+
return true;
|
177
|
+
}
|
178
|
+
|
179
|
+
var attributes = Utils.parseAuthorizationHeader(res.headers['server-authorization'], ['mac', 'ext', 'hash']);
|
180
|
+
if (attributes instanceof Error) {
|
181
|
+
return false;
|
182
|
+
}
|
183
|
+
|
184
|
+
artifacts.ext = attributes.ext;
|
185
|
+
artifacts.hash = attributes.hash;
|
186
|
+
|
187
|
+
var mac = Crypto.calculateMac('response', credentials, artifacts);
|
188
|
+
if (mac !== attributes.mac) {
|
189
|
+
return false;
|
190
|
+
}
|
191
|
+
|
192
|
+
if (!options.payload &&
|
193
|
+
options.payload !== '') {
|
194
|
+
|
195
|
+
return true;
|
196
|
+
}
|
197
|
+
|
198
|
+
if (!attributes.hash) {
|
199
|
+
return false;
|
200
|
+
}
|
201
|
+
|
202
|
+
var calculatedHash = Crypto.calculatePayloadHash(options.payload, credentials.algorithm, res.headers['content-type']);
|
203
|
+
return (calculatedHash === attributes.hash);
|
204
|
+
};
|
205
|
+
|
206
|
+
|
207
|
+
// Generate a bewit value for a given URI
|
208
|
+
|
209
|
+
/*
|
210
|
+
uri: 'http://example.com/resource?a=b' or object from Url.parse()
|
211
|
+
options: {
|
212
|
+
|
213
|
+
// Required
|
214
|
+
|
215
|
+
credentials: {
|
216
|
+
id: 'dh37fgj492je',
|
217
|
+
key: 'aoijedoaijsdlaksjdl',
|
218
|
+
algorithm: 'sha256' // 'sha1', 'sha256'
|
219
|
+
},
|
220
|
+
ttlSec: 60 * 60, // TTL in seconds
|
221
|
+
|
222
|
+
// Optional
|
223
|
+
|
224
|
+
ext: 'application-specific', // Application specific data sent via the ext attribute
|
225
|
+
localtimeOffsetMsec: 400 // Time offset to sync with server time
|
226
|
+
};
|
227
|
+
*/
|
228
|
+
|
229
|
+
exports.getBewit = function (uri, options) {
|
230
|
+
|
231
|
+
// Validate inputs
|
232
|
+
|
233
|
+
if (!uri ||
|
234
|
+
(typeof uri !== 'string' && typeof uri !== 'object') ||
|
235
|
+
!options ||
|
236
|
+
typeof options !== 'object' ||
|
237
|
+
!options.ttlSec) {
|
238
|
+
|
239
|
+
return '';
|
240
|
+
}
|
241
|
+
|
242
|
+
options.ext = (options.ext === null || options.ext === undefined ? '' : options.ext); // Zero is valid value
|
243
|
+
|
244
|
+
// Application time
|
245
|
+
|
246
|
+
var now = Utils.now(options.localtimeOffsetMsec);
|
247
|
+
|
248
|
+
// Validate credentials
|
249
|
+
|
250
|
+
var credentials = options.credentials;
|
251
|
+
if (!credentials ||
|
252
|
+
!credentials.id ||
|
253
|
+
!credentials.key ||
|
254
|
+
!credentials.algorithm) {
|
255
|
+
|
256
|
+
return '';
|
257
|
+
}
|
258
|
+
|
259
|
+
if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
260
|
+
return '';
|
261
|
+
}
|
262
|
+
|
263
|
+
// Parse URI
|
264
|
+
|
265
|
+
if (typeof uri === 'string') {
|
266
|
+
uri = Url.parse(uri);
|
267
|
+
}
|
268
|
+
|
269
|
+
// Calculate signature
|
270
|
+
|
271
|
+
var exp = Math.floor(now / 1000) + options.ttlSec;
|
272
|
+
var mac = Crypto.calculateMac('bewit', credentials, {
|
273
|
+
ts: exp,
|
274
|
+
nonce: '',
|
275
|
+
method: 'GET',
|
276
|
+
resource: uri.pathname + (uri.search || ''), // Maintain trailing '?'
|
277
|
+
host: uri.hostname,
|
278
|
+
port: uri.port || (uri.protocol === 'http:' ? 80 : 443),
|
279
|
+
ext: options.ext
|
280
|
+
});
|
281
|
+
|
282
|
+
// Construct bewit: id\exp\mac\ext
|
283
|
+
|
284
|
+
var bewit = credentials.id + '\\' + exp + '\\' + mac + '\\' + options.ext;
|
285
|
+
return Hoek.base64urlEncode(bewit);
|
286
|
+
};
|
287
|
+
|
288
|
+
|
289
|
+
// Generate an authorization string for a message
|
290
|
+
|
291
|
+
/*
|
292
|
+
host: 'example.com',
|
293
|
+
port: 8000,
|
294
|
+
message: '{"some":"payload"}', // UTF-8 encoded string for body hash generation
|
295
|
+
options: {
|
296
|
+
|
297
|
+
// Required
|
298
|
+
|
299
|
+
credentials: {
|
300
|
+
id: 'dh37fgj492je',
|
301
|
+
key: 'aoijedoaijsdlaksjdl',
|
302
|
+
algorithm: 'sha256' // 'sha1', 'sha256'
|
303
|
+
},
|
304
|
+
|
305
|
+
// Optional
|
306
|
+
|
307
|
+
timestamp: Date.now(), // A pre-calculated timestamp
|
308
|
+
nonce: '2334f34f', // A pre-generated nonce
|
309
|
+
localtimeOffsetMsec: 400, // Time offset to sync with server time (ignored if timestamp provided)
|
310
|
+
}
|
311
|
+
*/
|
312
|
+
|
313
|
+
exports.message = function (host, port, message, options) {
|
314
|
+
|
315
|
+
// Validate inputs
|
316
|
+
|
317
|
+
if (!host || typeof host !== 'string' ||
|
318
|
+
!port || typeof port !== 'number' ||
|
319
|
+
message === null || message === undefined || typeof message !== 'string' ||
|
320
|
+
!options || typeof options !== 'object') {
|
321
|
+
|
322
|
+
return null;
|
323
|
+
}
|
324
|
+
|
325
|
+
// Application time
|
326
|
+
|
327
|
+
var timestamp = options.timestamp || Utils.nowSecs(options.localtimeOffsetMsec);
|
328
|
+
|
329
|
+
// Validate credentials
|
330
|
+
|
331
|
+
var credentials = options.credentials;
|
332
|
+
if (!credentials ||
|
333
|
+
!credentials.id ||
|
334
|
+
!credentials.key ||
|
335
|
+
!credentials.algorithm) {
|
336
|
+
|
337
|
+
// Invalid credential object
|
338
|
+
return null;
|
339
|
+
}
|
340
|
+
|
341
|
+
if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
342
|
+
return null;
|
343
|
+
}
|
344
|
+
|
345
|
+
// Calculate signature
|
346
|
+
|
347
|
+
var artifacts = {
|
348
|
+
ts: timestamp,
|
349
|
+
nonce: options.nonce || Cryptiles.randomString(6),
|
350
|
+
host: host,
|
351
|
+
port: port,
|
352
|
+
hash: Crypto.calculatePayloadHash(message, credentials.algorithm)
|
353
|
+
};
|
354
|
+
|
355
|
+
// Construct authorization
|
356
|
+
|
357
|
+
var result = {
|
358
|
+
id: credentials.id,
|
359
|
+
ts: artifacts.ts,
|
360
|
+
nonce: artifacts.nonce,
|
361
|
+
hash: artifacts.hash,
|
362
|
+
mac: Crypto.calculateMac('message', credentials, artifacts)
|
363
|
+
};
|
364
|
+
|
365
|
+
return result;
|
366
|
+
};
|
367
|
+
|
368
|
+
|
369
|
+
|