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,637 +1,637 @@
|
|
1
|
-
/*
|
2
|
-
HTTP Hawk Authentication Scheme
|
3
|
-
Copyright (c) 2012-2014, Eran Hammer <eran@hammer.io>
|
4
|
-
BSD Licensed
|
5
|
-
*/
|
6
|
-
|
7
|
-
|
8
|
-
// Declare namespace
|
9
|
-
|
10
|
-
var hawk = {
|
11
|
-
internals: {}
|
12
|
-
};
|
13
|
-
|
14
|
-
|
15
|
-
hawk.client = {
|
16
|
-
|
17
|
-
// Generate an Authorization header for a given request
|
18
|
-
|
19
|
-
/*
|
20
|
-
uri: 'http://example.com/resource?a=b' or object generated by hawk.utils.parseUri()
|
21
|
-
method: HTTP verb (e.g. 'GET', 'POST')
|
22
|
-
options: {
|
23
|
-
|
24
|
-
// Required
|
25
|
-
|
26
|
-
credentials: {
|
27
|
-
id: 'dh37fgj492je',
|
28
|
-
key: 'aoijedoaijsdlaksjdl',
|
29
|
-
algorithm: 'sha256' // 'sha1', 'sha256'
|
30
|
-
},
|
31
|
-
|
32
|
-
// Optional
|
33
|
-
|
34
|
-
ext: 'application-specific', // Application specific data sent via the ext attribute
|
35
|
-
timestamp: Date.now() / 1000, // A pre-calculated timestamp in seconds
|
36
|
-
nonce: '2334f34f', // A pre-generated nonce
|
37
|
-
localtimeOffsetMsec: 400, // Time offset to sync with server time (ignored if timestamp provided)
|
38
|
-
payload: '{"some":"payload"}', // UTF-8 encoded string for body hash generation (ignored if hash provided)
|
39
|
-
contentType: 'application/json', // Payload content-type (ignored if hash provided)
|
40
|
-
hash: 'U4MKKSmiVxk37JCCrAVIjV=', // Pre-calculated payload hash
|
41
|
-
app: '24s23423f34dx', // Oz application id
|
42
|
-
dlg: '234sz34tww3sd' // Oz delegated-by application id
|
43
|
-
}
|
44
|
-
*/
|
45
|
-
|
46
|
-
header: function (uri, method, options) {
|
47
|
-
|
48
|
-
var result = {
|
49
|
-
field: '',
|
50
|
-
artifacts: {}
|
51
|
-
};
|
52
|
-
|
53
|
-
// Validate inputs
|
54
|
-
|
55
|
-
if (!uri || (typeof uri !== 'string' && typeof uri !== 'object') ||
|
56
|
-
!method || typeof method !== 'string' ||
|
57
|
-
!options || typeof options !== 'object') {
|
58
|
-
|
59
|
-
result.err = 'Invalid argument type';
|
60
|
-
return result;
|
61
|
-
}
|
62
|
-
|
63
|
-
// Application time
|
64
|
-
|
65
|
-
var timestamp = options.timestamp || hawk.utils.now(options.localtimeOffsetMsec);
|
66
|
-
|
67
|
-
// Validate credentials
|
68
|
-
|
69
|
-
var credentials = options.credentials;
|
70
|
-
if (!credentials ||
|
71
|
-
!credentials.id ||
|
72
|
-
!credentials.key ||
|
73
|
-
!credentials.algorithm) {
|
74
|
-
|
75
|
-
result.err = 'Invalid credentials object';
|
76
|
-
return result;
|
77
|
-
}
|
78
|
-
|
79
|
-
if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
80
|
-
result.err = 'Unknown algorithm';
|
81
|
-
return result;
|
82
|
-
}
|
83
|
-
|
84
|
-
// Parse URI
|
85
|
-
|
86
|
-
if (typeof uri === 'string') {
|
87
|
-
uri = hawk.utils.parseUri(uri);
|
88
|
-
}
|
89
|
-
|
90
|
-
// Calculate signature
|
91
|
-
|
92
|
-
var artifacts = {
|
93
|
-
ts: timestamp,
|
94
|
-
nonce: options.nonce || hawk.utils.randomString(6),
|
95
|
-
method: method,
|
96
|
-
resource: uri.resource,
|
97
|
-
host: uri.host,
|
98
|
-
port: uri.port,
|
99
|
-
hash: options.hash,
|
100
|
-
ext: options.ext,
|
101
|
-
app: options.app,
|
102
|
-
dlg: options.dlg
|
103
|
-
};
|
104
|
-
|
105
|
-
result.artifacts = artifacts;
|
106
|
-
|
107
|
-
// Calculate payload hash
|
108
|
-
|
109
|
-
if (!artifacts.hash &&
|
110
|
-
(options.payload || options.payload === '')) {
|
111
|
-
|
112
|
-
artifacts.hash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, options.contentType);
|
113
|
-
}
|
114
|
-
|
115
|
-
var mac = hawk.crypto.calculateMac('header', credentials, artifacts);
|
116
|
-
|
117
|
-
// Construct header
|
118
|
-
|
119
|
-
var hasExt = artifacts.ext !== null && artifacts.ext !== undefined && artifacts.ext !== ''; // Other falsey values allowed
|
120
|
-
var header = 'Hawk id="' + credentials.id +
|
121
|
-
'", ts="' + artifacts.ts +
|
122
|
-
'", nonce="' + artifacts.nonce +
|
123
|
-
(artifacts.hash ? '", hash="' + artifacts.hash : '') +
|
124
|
-
(hasExt ? '", ext="' + hawk.utils.escapeHeaderAttribute(artifacts.ext) : '') +
|
125
|
-
'", mac="' + mac + '"';
|
126
|
-
|
127
|
-
if (artifacts.app) {
|
128
|
-
header += ', app="' + artifacts.app +
|
129
|
-
(artifacts.dlg ? '", dlg="' + artifacts.dlg : '') + '"';
|
130
|
-
}
|
131
|
-
|
132
|
-
result.field = header;
|
133
|
-
|
134
|
-
return result;
|
135
|
-
},
|
136
|
-
|
137
|
-
// Generate a bewit value for a given URI
|
138
|
-
|
139
|
-
/*
|
140
|
-
uri: 'http://example.com/resource?a=b'
|
141
|
-
options: {
|
142
|
-
|
143
|
-
// Required
|
144
|
-
|
145
|
-
credentials: {
|
146
|
-
id: 'dh37fgj492je',
|
147
|
-
key: 'aoijedoaijsdlaksjdl',
|
148
|
-
algorithm: 'sha256' // 'sha1', 'sha256'
|
149
|
-
},
|
150
|
-
ttlSec: 60 * 60, // TTL in seconds
|
151
|
-
|
152
|
-
// Optional
|
153
|
-
|
154
|
-
ext: 'application-specific', // Application specific data sent via the ext attribute
|
155
|
-
localtimeOffsetMsec: 400 // Time offset to sync with server time
|
156
|
-
};
|
157
|
-
*/
|
158
|
-
|
159
|
-
bewit: function (uri, options) {
|
160
|
-
|
161
|
-
// Validate inputs
|
162
|
-
|
163
|
-
if (!uri ||
|
164
|
-
(typeof uri !== 'string') ||
|
165
|
-
!options ||
|
166
|
-
typeof options !== 'object' ||
|
167
|
-
!options.ttlSec) {
|
168
|
-
|
169
|
-
return '';
|
170
|
-
}
|
171
|
-
|
172
|
-
options.ext = (options.ext === null || options.ext === undefined ? '' : options.ext); // Zero is valid value
|
173
|
-
|
174
|
-
// Application time
|
175
|
-
|
176
|
-
var now = hawk.utils.now(options.localtimeOffsetMsec);
|
177
|
-
|
178
|
-
// Validate credentials
|
179
|
-
|
180
|
-
var credentials = options.credentials;
|
181
|
-
if (!credentials ||
|
182
|
-
!credentials.id ||
|
183
|
-
!credentials.key ||
|
184
|
-
!credentials.algorithm) {
|
185
|
-
|
186
|
-
return '';
|
187
|
-
}
|
188
|
-
|
189
|
-
if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
190
|
-
return '';
|
191
|
-
}
|
192
|
-
|
193
|
-
// Parse URI
|
194
|
-
|
195
|
-
uri = hawk.utils.parseUri(uri);
|
196
|
-
|
197
|
-
// Calculate signature
|
198
|
-
|
199
|
-
var exp = now + options.ttlSec;
|
200
|
-
var mac = hawk.crypto.calculateMac('bewit', credentials, {
|
201
|
-
ts: exp,
|
202
|
-
nonce: '',
|
203
|
-
method: 'GET',
|
204
|
-
resource: uri.resource, // Maintain trailing '?' and query params
|
205
|
-
host: uri.host,
|
206
|
-
port: uri.port,
|
207
|
-
ext: options.ext
|
208
|
-
});
|
209
|
-
|
210
|
-
// Construct bewit: id\exp\mac\ext
|
211
|
-
|
212
|
-
var bewit = credentials.id + '\\' + exp + '\\' + mac + '\\' + options.ext;
|
213
|
-
return hawk.utils.base64urlEncode(bewit);
|
214
|
-
},
|
215
|
-
|
216
|
-
// Validate server response
|
217
|
-
|
218
|
-
/*
|
219
|
-
request: object created via 'new XMLHttpRequest()' after response received
|
220
|
-
artifacts: object received from header().artifacts
|
221
|
-
options: {
|
222
|
-
payload: optional payload received
|
223
|
-
required: specifies if a Server-Authorization header is required. Defaults to 'false'
|
224
|
-
}
|
225
|
-
*/
|
226
|
-
|
227
|
-
authenticate: function (request, credentials, artifacts, options) {
|
228
|
-
|
229
|
-
options = options || {};
|
230
|
-
|
231
|
-
var getHeader = function (name) {
|
232
|
-
|
233
|
-
return request.getResponseHeader ? request.getResponseHeader(name) : request.getHeader(name);
|
234
|
-
};
|
235
|
-
|
236
|
-
var wwwAuthenticate = getHeader('www-authenticate');
|
237
|
-
if (wwwAuthenticate) {
|
238
|
-
|
239
|
-
// Parse HTTP WWW-Authenticate header
|
240
|
-
|
241
|
-
var wwwAttributes = hawk.utils.parseAuthorizationHeader(wwwAuthenticate, ['ts', 'tsm', 'error']);
|
242
|
-
if (!wwwAttributes) {
|
243
|
-
return false;
|
244
|
-
}
|
245
|
-
|
246
|
-
if (wwwAttributes.ts) {
|
247
|
-
var tsm = hawk.crypto.calculateTsMac(wwwAttributes.ts, credentials);
|
248
|
-
if (tsm !== wwwAttributes.tsm) {
|
249
|
-
return false;
|
250
|
-
}
|
251
|
-
|
252
|
-
hawk.utils.setNtpOffset(wwwAttributes.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision
|
253
|
-
}
|
254
|
-
}
|
255
|
-
|
256
|
-
// Parse HTTP Server-Authorization header
|
257
|
-
|
258
|
-
var serverAuthorization = getHeader('server-authorization');
|
259
|
-
if (!serverAuthorization &&
|
260
|
-
!options.required) {
|
261
|
-
|
262
|
-
return true;
|
263
|
-
}
|
264
|
-
|
265
|
-
var attributes = hawk.utils.parseAuthorizationHeader(serverAuthorization, ['mac', 'ext', 'hash']);
|
266
|
-
if (!attributes) {
|
267
|
-
return false;
|
268
|
-
}
|
269
|
-
|
270
|
-
var modArtifacts = {
|
271
|
-
ts: artifacts.ts,
|
272
|
-
nonce: artifacts.nonce,
|
273
|
-
method: artifacts.method,
|
274
|
-
resource: artifacts.resource,
|
275
|
-
host: artifacts.host,
|
276
|
-
port: artifacts.port,
|
277
|
-
hash: attributes.hash,
|
278
|
-
ext: attributes.ext,
|
279
|
-
app: artifacts.app,
|
280
|
-
dlg: artifacts.dlg
|
281
|
-
};
|
282
|
-
|
283
|
-
var mac = hawk.crypto.calculateMac('response', credentials, modArtifacts);
|
284
|
-
if (mac !== attributes.mac) {
|
285
|
-
return false;
|
286
|
-
}
|
287
|
-
|
288
|
-
if (!options.payload &&
|
289
|
-
options.payload !== '') {
|
290
|
-
|
291
|
-
return true;
|
292
|
-
}
|
293
|
-
|
294
|
-
if (!attributes.hash) {
|
295
|
-
return false;
|
296
|
-
}
|
297
|
-
|
298
|
-
var calculatedHash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, getHeader('content-type'));
|
299
|
-
return (calculatedHash === attributes.hash);
|
300
|
-
},
|
301
|
-
|
302
|
-
message: function (host, port, message, options) {
|
303
|
-
|
304
|
-
// Validate inputs
|
305
|
-
|
306
|
-
if (!host || typeof host !== 'string' ||
|
307
|
-
!port || typeof port !== 'number' ||
|
308
|
-
message === null || message === undefined || typeof message !== 'string' ||
|
309
|
-
!options || typeof options !== 'object') {
|
310
|
-
|
311
|
-
return null;
|
312
|
-
}
|
313
|
-
|
314
|
-
// Application time
|
315
|
-
|
316
|
-
var timestamp = options.timestamp || hawk.utils.now(options.localtimeOffsetMsec);
|
317
|
-
|
318
|
-
// Validate credentials
|
319
|
-
|
320
|
-
var credentials = options.credentials;
|
321
|
-
if (!credentials ||
|
322
|
-
!credentials.id ||
|
323
|
-
!credentials.key ||
|
324
|
-
!credentials.algorithm) {
|
325
|
-
|
326
|
-
// Invalid credential object
|
327
|
-
return null;
|
328
|
-
}
|
329
|
-
|
330
|
-
if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
331
|
-
return null;
|
332
|
-
}
|
333
|
-
|
334
|
-
// Calculate signature
|
335
|
-
|
336
|
-
var artifacts = {
|
337
|
-
ts: timestamp,
|
338
|
-
nonce: options.nonce || hawk.utils.randomString(6),
|
339
|
-
host: host,
|
340
|
-
port: port,
|
341
|
-
hash: hawk.crypto.calculatePayloadHash(message, credentials.algorithm)
|
342
|
-
};
|
343
|
-
|
344
|
-
// Construct authorization
|
345
|
-
|
346
|
-
var result = {
|
347
|
-
id: credentials.id,
|
348
|
-
ts: artifacts.ts,
|
349
|
-
nonce: artifacts.nonce,
|
350
|
-
hash: artifacts.hash,
|
351
|
-
mac: hawk.crypto.calculateMac('message', credentials, artifacts)
|
352
|
-
};
|
353
|
-
|
354
|
-
return result;
|
355
|
-
},
|
356
|
-
|
357
|
-
authenticateTimestamp: function (message, credentials, updateClock) { // updateClock defaults to true
|
358
|
-
|
359
|
-
var tsm = hawk.crypto.calculateTsMac(message.ts, credentials);
|
360
|
-
if (tsm !== message.tsm) {
|
361
|
-
return false;
|
362
|
-
}
|
363
|
-
|
364
|
-
if (updateClock !== false) {
|
365
|
-
hawk.utils.setNtpOffset(message.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision
|
366
|
-
}
|
367
|
-
|
368
|
-
return true;
|
369
|
-
}
|
370
|
-
};
|
371
|
-
|
372
|
-
|
373
|
-
hawk.crypto = {
|
374
|
-
|
375
|
-
headerVersion: '1',
|
376
|
-
|
377
|
-
algorithms: ['sha1', 'sha256'],
|
378
|
-
|
379
|
-
calculateMac: function (type, credentials, options) {
|
380
|
-
|
381
|
-
var normalized = hawk.crypto.generateNormalizedString(type, options);
|
382
|
-
|
383
|
-
var hmac = CryptoJS['Hmac' + credentials.algorithm.toUpperCase()](normalized, credentials.key);
|
384
|
-
return hmac.toString(CryptoJS.enc.Base64);
|
385
|
-
},
|
386
|
-
|
387
|
-
generateNormalizedString: function (type, options) {
|
388
|
-
|
389
|
-
var normalized = 'hawk.' + hawk.crypto.headerVersion + '.' + type + '\n' +
|
390
|
-
options.ts + '\n' +
|
391
|
-
options.nonce + '\n' +
|
392
|
-
(options.method || '').toUpperCase() + '\n' +
|
393
|
-
(options.resource || '') + '\n' +
|
394
|
-
options.host.toLowerCase() + '\n' +
|
395
|
-
options.port + '\n' +
|
396
|
-
(options.hash || '') + '\n';
|
397
|
-
|
398
|
-
if (options.ext) {
|
399
|
-
normalized += options.ext.replace('\\', '\\\\').replace('\n', '\\n');
|
400
|
-
}
|
401
|
-
|
402
|
-
normalized += '\n';
|
403
|
-
|
404
|
-
if (options.app) {
|
405
|
-
normalized += options.app + '\n' +
|
406
|
-
(options.dlg || '') + '\n';
|
407
|
-
}
|
408
|
-
|
409
|
-
return normalized;
|
410
|
-
},
|
411
|
-
|
412
|
-
calculatePayloadHash: function (payload, algorithm, contentType) {
|
413
|
-
|
414
|
-
var hash = CryptoJS.algo[algorithm.toUpperCase()].create();
|
415
|
-
hash.update('hawk.' + hawk.crypto.headerVersion + '.payload\n');
|
416
|
-
hash.update(hawk.utils.parseContentType(contentType) + '\n');
|
417
|
-
hash.update(payload);
|
418
|
-
hash.update('\n');
|
419
|
-
return hash.finalize().toString(CryptoJS.enc.Base64);
|
420
|
-
},
|
421
|
-
|
422
|
-
calculateTsMac: function (ts, credentials) {
|
423
|
-
|
424
|
-
var hash = CryptoJS['Hmac' + credentials.algorithm.toUpperCase()]('hawk.' + hawk.crypto.headerVersion + '.ts\n' + ts + '\n', credentials.key);
|
425
|
-
return hash.toString(CryptoJS.enc.Base64);
|
426
|
-
}
|
427
|
-
};
|
428
|
-
|
429
|
-
|
430
|
-
// localStorage compatible interface
|
431
|
-
|
432
|
-
hawk.internals.LocalStorage = function () {
|
433
|
-
|
434
|
-
this._cache = {};
|
435
|
-
this.length = 0;
|
436
|
-
|
437
|
-
this.getItem = function (key) {
|
438
|
-
|
439
|
-
return this._cache.hasOwnProperty(key) ? String(this._cache[key]) : null;
|
440
|
-
};
|
441
|
-
|
442
|
-
this.setItem = function (key, value) {
|
443
|
-
|
444
|
-
this._cache[key] = String(value);
|
445
|
-
this.length = Object.keys(this._cache).length;
|
446
|
-
};
|
447
|
-
|
448
|
-
this.removeItem = function (key) {
|
449
|
-
|
450
|
-
delete this._cache[key];
|
451
|
-
this.length = Object.keys(this._cache).length;
|
452
|
-
};
|
453
|
-
|
454
|
-
this.clear = function () {
|
455
|
-
|
456
|
-
this._cache = {};
|
457
|
-
this.length = 0;
|
458
|
-
};
|
459
|
-
|
460
|
-
this.key = function (i) {
|
461
|
-
|
462
|
-
return Object.keys(this._cache)[i || 0];
|
463
|
-
};
|
464
|
-
};
|
465
|
-
|
466
|
-
|
467
|
-
hawk.utils = {
|
468
|
-
|
469
|
-
storage: new hawk.internals.LocalStorage(),
|
470
|
-
|
471
|
-
setStorage: function (storage) {
|
472
|
-
|
473
|
-
var ntpOffset = hawk.utils.storage.getItem('hawk_ntp_offset');
|
474
|
-
hawk.utils.storage = storage;
|
475
|
-
if (ntpOffset) {
|
476
|
-
hawk.utils.setNtpOffset(ntpOffset);
|
477
|
-
}
|
478
|
-
},
|
479
|
-
|
480
|
-
setNtpOffset: function (offset) {
|
481
|
-
|
482
|
-
try {
|
483
|
-
hawk.utils.storage.setItem('hawk_ntp_offset', offset);
|
484
|
-
}
|
485
|
-
catch (err) {
|
486
|
-
console.error('[hawk] could not write to storage.');
|
487
|
-
console.error(err);
|
488
|
-
}
|
489
|
-
},
|
490
|
-
|
491
|
-
getNtpOffset: function () {
|
492
|
-
|
493
|
-
var offset = hawk.utils.storage.getItem('hawk_ntp_offset');
|
494
|
-
if (!offset) {
|
495
|
-
return 0;
|
496
|
-
}
|
497
|
-
|
498
|
-
return parseInt(offset, 10);
|
499
|
-
},
|
500
|
-
|
501
|
-
now: function (localtimeOffsetMsec) {
|
502
|
-
|
503
|
-
return Math.floor(((new Date()).getTime() + (localtimeOffsetMsec || 0)) / 1000) + hawk.utils.getNtpOffset();
|
504
|
-
},
|
505
|
-
|
506
|
-
escapeHeaderAttribute: function (attribute) {
|
507
|
-
|
508
|
-
return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"');
|
509
|
-
},
|
510
|
-
|
511
|
-
parseContentType: function (header) {
|
512
|
-
|
513
|
-
if (!header) {
|
514
|
-
return '';
|
515
|
-
}
|
516
|
-
|
517
|
-
return header.split(';')[0].replace(/^\s+|\s+$/g, '').toLowerCase();
|
518
|
-
},
|
519
|
-
|
520
|
-
parseAuthorizationHeader: function (header, keys) {
|
521
|
-
|
522
|
-
if (!header) {
|
523
|
-
return null;
|
524
|
-
}
|
525
|
-
|
526
|
-
var headerParts = header.match(/^(\w+)(?:\s+(.*))?$/); // Header: scheme[ something]
|
527
|
-
if (!headerParts) {
|
528
|
-
return null;
|
529
|
-
}
|
530
|
-
|
531
|
-
var scheme = headerParts[1];
|
532
|
-
if (scheme.toLowerCase() !== 'hawk') {
|
533
|
-
return null;
|
534
|
-
}
|
535
|
-
|
536
|
-
var attributesString = headerParts[2];
|
537
|
-
if (!attributesString) {
|
538
|
-
return null;
|
539
|
-
}
|
540
|
-
|
541
|
-
var attributes = {};
|
542
|
-
var verify = attributesString.replace(/(\w+)="([^"\\]*)"\s*(?:,\s*|$)/g, function ($0, $1, $2) {
|
543
|
-
|
544
|
-
// Check valid attribute names
|
545
|
-
|
546
|
-
if (keys.indexOf($1) === -1) {
|
547
|
-
return;
|
548
|
-
}
|
549
|
-
|
550
|
-
// Allowed attribute value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9
|
551
|
-
|
552
|
-
if ($2.match(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~]+$/) === null) {
|
553
|
-
return;
|
554
|
-
}
|
555
|
-
|
556
|
-
// Check for duplicates
|
557
|
-
|
558
|
-
if (attributes.hasOwnProperty($1)) {
|
559
|
-
return;
|
560
|
-
}
|
561
|
-
|
562
|
-
attributes[$1] = $2;
|
563
|
-
return '';
|
564
|
-
});
|
565
|
-
|
566
|
-
if (verify !== '') {
|
567
|
-
return null;
|
568
|
-
}
|
569
|
-
|
570
|
-
return attributes;
|
571
|
-
},
|
572
|
-
|
573
|
-
randomString: function (size) {
|
574
|
-
|
575
|
-
var randomSource = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
576
|
-
var len = randomSource.length;
|
577
|
-
|
578
|
-
var result = [];
|
579
|
-
for (var i = 0; i < size; ++i) {
|
580
|
-
result[i] = randomSource[Math.floor(Math.random() * len)];
|
581
|
-
}
|
582
|
-
|
583
|
-
return result.join('');
|
584
|
-
},
|
585
|
-
|
586
|
-
uriRegex: /^([^:]+)\:\/\/(?:[^@]*@)?([^\/:]+)(?:\:(\d+))?([^#]*)(?:#.*)?$/, // scheme://credentials@host:port/resource#fragment
|
587
|
-
parseUri: function (input) {
|
588
|
-
|
589
|
-
var parts = input.match(hawk.utils.uriRegex);
|
590
|
-
if (!parts) {
|
591
|
-
return { host: '', port: '', resource: '' };
|
592
|
-
}
|
593
|
-
|
594
|
-
var scheme = parts[1].toLowerCase();
|
595
|
-
var uri = {
|
596
|
-
host: parts[2],
|
597
|
-
port: parts[3] || (scheme === 'http' ? '80' : (scheme === 'https' ? '443' : '')),
|
598
|
-
resource: parts[4]
|
599
|
-
};
|
600
|
-
|
601
|
-
return uri;
|
602
|
-
},
|
603
|
-
|
604
|
-
base64urlEncode: function (value) {
|
605
|
-
|
606
|
-
var wordArray = CryptoJS.enc.Utf8.parse(value);
|
607
|
-
var encoded = CryptoJS.enc.Base64.stringify(wordArray);
|
608
|
-
return encoded.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
|
609
|
-
}
|
610
|
-
};
|
611
|
-
|
612
|
-
|
613
|
-
// $lab:coverage:off$
|
614
|
-
/* eslint-disable */
|
615
|
-
|
616
|
-
// Based on: Crypto-JS v3.1.2
|
617
|
-
// Copyright (c) 2009-2013, Jeff Mott. All rights reserved.
|
618
|
-
// http://code.google.com/p/crypto-js/
|
619
|
-
// http://code.google.com/p/crypto-js/wiki/License
|
620
|
-
|
621
|
-
var CryptoJS = CryptoJS || function (h, r) { var k = {}, l = k.lib = {}, n = function () { }, f = l.Base = { extend: function (a) { n.prototype = this; var b = new n; a && b.mixIn(a); b.hasOwnProperty("init") || (b.init = function () { b.$super.init.apply(this, arguments) }); b.init.prototype = b; b.$super = this; return b }, create: function () { var a = this.extend(); a.init.apply(a, arguments); return a }, init: function () { }, mixIn: function (a) { for (var b in a) a.hasOwnProperty(b) && (this[b] = a[b]); a.hasOwnProperty("toString") && (this.toString = a.toString) }, clone: function () { return this.init.prototype.extend(this) } }, j = l.WordArray = f.extend({ init: function (a, b) { a = this.words = a || []; this.sigBytes = b != r ? b : 4 * a.length }, toString: function (a) { return (a || s).stringify(this) }, concat: function (a) { var b = this.words, d = a.words, c = this.sigBytes; a = a.sigBytes; this.clamp(); if (c % 4) for (var e = 0; e < a; e++) b[c + e >>> 2] |= (d[e >>> 2] >>> 24 - 8 * (e % 4) & 255) << 24 - 8 * ((c + e) % 4); else if (65535 < d.length) for (e = 0; e < a; e += 4) b[c + e >>> 2] = d[e >>> 2]; else b.push.apply(b, d); this.sigBytes += a; return this }, clamp: function () { var a = this.words, b = this.sigBytes; a[b >>> 2] &= 4294967295 << 32 - 8 * (b % 4); a.length = h.ceil(b / 4) }, clone: function () { var a = f.clone.call(this); a.words = this.words.slice(0); return a }, random: function (a) { for (var b = [], d = 0; d < a; d += 4) b.push(4294967296 * h.random() | 0); return new j.init(b, a) } }), m = k.enc = {}, s = m.Hex = { stringify: function (a) { var b = a.words; a = a.sigBytes; for (var d = [], c = 0; c < a; c++) { var e = b[c >>> 2] >>> 24 - 8 * (c % 4) & 255; d.push((e >>> 4).toString(16)); d.push((e & 15).toString(16)) } return d.join("") }, parse: function (a) { for (var b = a.length, d = [], c = 0; c < b; c += 2) d[c >>> 3] |= parseInt(a.substr(c, 2), 16) << 24 - 4 * (c % 8); return new j.init(d, b / 2) } }, p = m.Latin1 = { stringify: function (a) { var b = a.words; a = a.sigBytes; for (var d = [], c = 0; c < a; c++) d.push(String.fromCharCode(b[c >>> 2] >>> 24 - 8 * (c % 4) & 255)); return d.join("") }, parse: function (a) { for (var b = a.length, d = [], c = 0; c < b; c++) d[c >>> 2] |= (a.charCodeAt(c) & 255) << 24 - 8 * (c % 4); return new j.init(d, b) } }, t = m.Utf8 = { stringify: function (a) { try { return decodeURIComponent(escape(p.stringify(a))) } catch (b) { throw Error("Malformed UTF-8 data"); } }, parse: function (a) { return p.parse(unescape(encodeURIComponent(a))) } }, q = l.BufferedBlockAlgorithm = f.extend({ reset: function () { this._data = new j.init; this._nDataBytes = 0 }, _append: function (a) { "string" == typeof a && (a = t.parse(a)); this._data.concat(a); this._nDataBytes += a.sigBytes }, _process: function (a) { var b = this._data, d = b.words, c = b.sigBytes, e = this.blockSize, f = c / (4 * e), f = a ? h.ceil(f) : h.max((f | 0) - this._minBufferSize, 0); a = f * e; c = h.min(4 * a, c); if (a) { for (var g = 0; g < a; g += e) this._doProcessBlock(d, g); g = d.splice(0, a); b.sigBytes -= c } return new j.init(g, c) }, clone: function () { var a = f.clone.call(this); a._data = this._data.clone(); return a }, _minBufferSize: 0 }); l.Hasher = q.extend({ cfg: f.extend(), init: function (a) { this.cfg = this.cfg.extend(a); this.reset() }, reset: function () { q.reset.call(this); this._doReset() }, update: function (a) { this._append(a); this._process(); return this }, finalize: function (a) { a && this._append(a); return this._doFinalize() }, blockSize: 16, _createHelper: function (a) { return function (b, d) { return (new a.init(d)).finalize(b) } }, _createHmacHelper: function (a) { return function (b, d) { return (new u.HMAC.init(a, d)).finalize(b) } } }); var u = k.algo = {}; return k }(Math);
|
622
|
-
(function () { var k = CryptoJS, b = k.lib, m = b.WordArray, l = b.Hasher, d = [], b = k.algo.SHA1 = l.extend({ _doReset: function () { this._hash = new m.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function (n, p) { for (var a = this._hash.words, e = a[0], f = a[1], h = a[2], j = a[3], b = a[4], c = 0; 80 > c; c++) { if (16 > c) d[c] = n[p + c] | 0; else { var g = d[c - 3] ^ d[c - 8] ^ d[c - 14] ^ d[c - 16]; d[c] = g << 1 | g >>> 31 } g = (e << 5 | e >>> 27) + b + d[c]; g = 20 > c ? g + ((f & h | ~f & j) + 1518500249) : 40 > c ? g + ((f ^ h ^ j) + 1859775393) : 60 > c ? g + ((f & h | f & j | h & j) - 1894007588) : g + ((f ^ h ^ j) - 899497514); b = j; j = h; h = f << 30 | f >>> 2; f = e; e = g } a[0] = a[0] + e | 0; a[1] = a[1] + f | 0; a[2] = a[2] + h | 0; a[3] = a[3] + j | 0; a[4] = a[4] + b | 0 }, _doFinalize: function () { var b = this._data, d = b.words, a = 8 * this._nDataBytes, e = 8 * b.sigBytes; d[e >>> 5] |= 128 << 24 - e % 32; d[(e + 64 >>> 9 << 4) + 14] = Math.floor(a / 4294967296); d[(e + 64 >>> 9 << 4) + 15] = a; b.sigBytes = 4 * d.length; this._process(); return this._hash }, clone: function () { var b = l.clone.call(this); b._hash = this._hash.clone(); return b } }); k.SHA1 = l._createHelper(b); k.HmacSHA1 = l._createHmacHelper(b) })();
|
623
|
-
(function (k) { for (var g = CryptoJS, h = g.lib, v = h.WordArray, j = h.Hasher, h = g.algo, s = [], t = [], u = function (q) { return 4294967296 * (q - (q | 0)) | 0 }, l = 2, b = 0; 64 > b;) { var d; a: { d = l; for (var w = k.sqrt(d), r = 2; r <= w; r++) if (!(d % r)) { d = !1; break a } d = !0 } d && (8 > b && (s[b] = u(k.pow(l, 0.5))), t[b] = u(k.pow(l, 1 / 3)), b++); l++ } var n = [], h = h.SHA256 = j.extend({ _doReset: function () { this._hash = new v.init(s.slice(0)) }, _doProcessBlock: function (q, h) { for (var a = this._hash.words, c = a[0], d = a[1], b = a[2], k = a[3], f = a[4], g = a[5], j = a[6], l = a[7], e = 0; 64 > e; e++) { if (16 > e) n[e] = q[h + e] | 0; else { var m = n[e - 15], p = n[e - 2]; n[e] = ((m << 25 | m >>> 7) ^ (m << 14 | m >>> 18) ^ m >>> 3) + n[e - 7] + ((p << 15 | p >>> 17) ^ (p << 13 | p >>> 19) ^ p >>> 10) + n[e - 16] } m = l + ((f << 26 | f >>> 6) ^ (f << 21 | f >>> 11) ^ (f << 7 | f >>> 25)) + (f & g ^ ~f & j) + t[e] + n[e]; p = ((c << 30 | c >>> 2) ^ (c << 19 | c >>> 13) ^ (c << 10 | c >>> 22)) + (c & d ^ c & b ^ d & b); l = j; j = g; g = f; f = k + m | 0; k = b; b = d; d = c; c = m + p | 0 } a[0] = a[0] + c | 0; a[1] = a[1] + d | 0; a[2] = a[2] + b | 0; a[3] = a[3] + k | 0; a[4] = a[4] + f | 0; a[5] = a[5] + g | 0; a[6] = a[6] + j | 0; a[7] = a[7] + l | 0 }, _doFinalize: function () { var d = this._data, b = d.words, a = 8 * this._nDataBytes, c = 8 * d.sigBytes; b[c >>> 5] |= 128 << 24 - c % 32; b[(c + 64 >>> 9 << 4) + 14] = k.floor(a / 4294967296); b[(c + 64 >>> 9 << 4) + 15] = a; d.sigBytes = 4 * b.length; this._process(); return this._hash }, clone: function () { var b = j.clone.call(this); b._hash = this._hash.clone(); return b } }); g.SHA256 = j._createHelper(h); g.HmacSHA256 = j._createHmacHelper(h) })(Math);
|
624
|
-
(function () { var c = CryptoJS, k = c.enc.Utf8; c.algo.HMAC = c.lib.Base.extend({ init: function (a, b) { a = this._hasher = new a.init; "string" == typeof b && (b = k.parse(b)); var c = a.blockSize, e = 4 * c; b.sigBytes > e && (b = a.finalize(b)); b.clamp(); for (var f = this._oKey = b.clone(), g = this._iKey = b.clone(), h = f.words, j = g.words, d = 0; d < c; d++) h[d] ^= 1549556828, j[d] ^= 909522486; f.sigBytes = g.sigBytes = e; this.reset() }, reset: function () { var a = this._hasher; a.reset(); a.update(this._iKey) }, update: function (a) { this._hasher.update(a); return this }, finalize: function (a) { var b = this._hasher; a = b.finalize(a); b.reset(); return b.finalize(this._oKey.clone().concat(a)) } }) })();
|
625
|
-
(function () { var h = CryptoJS, j = h.lib.WordArray; h.enc.Base64 = { stringify: function (b) { var e = b.words, f = b.sigBytes, c = this._map; b.clamp(); b = []; for (var a = 0; a < f; a += 3) for (var d = (e[a >>> 2] >>> 24 - 8 * (a % 4) & 255) << 16 | (e[a + 1 >>> 2] >>> 24 - 8 * ((a + 1) % 4) & 255) << 8 | e[a + 2 >>> 2] >>> 24 - 8 * ((a + 2) % 4) & 255, g = 0; 4 > g && a + 0.75 * g < f; g++) b.push(c.charAt(d >>> 6 * (3 - g) & 63)); if (e = c.charAt(64)) for (; b.length % 4;) b.push(e); return b.join("") }, parse: function (b) { var e = b.length, f = this._map, c = f.charAt(64); c && (c = b.indexOf(c), -1 != c && (e = c)); for (var c = [], a = 0, d = 0; d < e; d++) if (d % 4) { var g = f.indexOf(b.charAt(d - 1)) << 2 * (d % 4), h = f.indexOf(b.charAt(d)) >>> 6 - 2 * (d % 4); c[a >>> 2] |= (g | h) << 24 - 8 * (a % 4); a++ } return j.create(c, a) }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" } })();
|
626
|
-
|
627
|
-
hawk.crypto.internals = CryptoJS;
|
628
|
-
|
629
|
-
|
630
|
-
// Export if used as a module
|
631
|
-
|
632
|
-
if (typeof module !== 'undefined' && module.exports) {
|
633
|
-
module.exports = hawk;
|
634
|
-
}
|
635
|
-
|
636
|
-
/* eslint-enable */
|
637
|
-
// $lab:coverage:on$
|
1
|
+
/*
|
2
|
+
HTTP Hawk Authentication Scheme
|
3
|
+
Copyright (c) 2012-2014, Eran Hammer <eran@hammer.io>
|
4
|
+
BSD Licensed
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
// Declare namespace
|
9
|
+
|
10
|
+
var hawk = {
|
11
|
+
internals: {}
|
12
|
+
};
|
13
|
+
|
14
|
+
|
15
|
+
hawk.client = {
|
16
|
+
|
17
|
+
// Generate an Authorization header for a given request
|
18
|
+
|
19
|
+
/*
|
20
|
+
uri: 'http://example.com/resource?a=b' or object generated by hawk.utils.parseUri()
|
21
|
+
method: HTTP verb (e.g. 'GET', 'POST')
|
22
|
+
options: {
|
23
|
+
|
24
|
+
// Required
|
25
|
+
|
26
|
+
credentials: {
|
27
|
+
id: 'dh37fgj492je',
|
28
|
+
key: 'aoijedoaijsdlaksjdl',
|
29
|
+
algorithm: 'sha256' // 'sha1', 'sha256'
|
30
|
+
},
|
31
|
+
|
32
|
+
// Optional
|
33
|
+
|
34
|
+
ext: 'application-specific', // Application specific data sent via the ext attribute
|
35
|
+
timestamp: Date.now() / 1000, // A pre-calculated timestamp in seconds
|
36
|
+
nonce: '2334f34f', // A pre-generated nonce
|
37
|
+
localtimeOffsetMsec: 400, // Time offset to sync with server time (ignored if timestamp provided)
|
38
|
+
payload: '{"some":"payload"}', // UTF-8 encoded string for body hash generation (ignored if hash provided)
|
39
|
+
contentType: 'application/json', // Payload content-type (ignored if hash provided)
|
40
|
+
hash: 'U4MKKSmiVxk37JCCrAVIjV=', // Pre-calculated payload hash
|
41
|
+
app: '24s23423f34dx', // Oz application id
|
42
|
+
dlg: '234sz34tww3sd' // Oz delegated-by application id
|
43
|
+
}
|
44
|
+
*/
|
45
|
+
|
46
|
+
header: function (uri, method, options) {
|
47
|
+
|
48
|
+
var result = {
|
49
|
+
field: '',
|
50
|
+
artifacts: {}
|
51
|
+
};
|
52
|
+
|
53
|
+
// Validate inputs
|
54
|
+
|
55
|
+
if (!uri || (typeof uri !== 'string' && typeof uri !== 'object') ||
|
56
|
+
!method || typeof method !== 'string' ||
|
57
|
+
!options || typeof options !== 'object') {
|
58
|
+
|
59
|
+
result.err = 'Invalid argument type';
|
60
|
+
return result;
|
61
|
+
}
|
62
|
+
|
63
|
+
// Application time
|
64
|
+
|
65
|
+
var timestamp = options.timestamp || hawk.utils.now(options.localtimeOffsetMsec);
|
66
|
+
|
67
|
+
// Validate credentials
|
68
|
+
|
69
|
+
var credentials = options.credentials;
|
70
|
+
if (!credentials ||
|
71
|
+
!credentials.id ||
|
72
|
+
!credentials.key ||
|
73
|
+
!credentials.algorithm) {
|
74
|
+
|
75
|
+
result.err = 'Invalid credentials object';
|
76
|
+
return result;
|
77
|
+
}
|
78
|
+
|
79
|
+
if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
80
|
+
result.err = 'Unknown algorithm';
|
81
|
+
return result;
|
82
|
+
}
|
83
|
+
|
84
|
+
// Parse URI
|
85
|
+
|
86
|
+
if (typeof uri === 'string') {
|
87
|
+
uri = hawk.utils.parseUri(uri);
|
88
|
+
}
|
89
|
+
|
90
|
+
// Calculate signature
|
91
|
+
|
92
|
+
var artifacts = {
|
93
|
+
ts: timestamp,
|
94
|
+
nonce: options.nonce || hawk.utils.randomString(6),
|
95
|
+
method: method,
|
96
|
+
resource: uri.resource,
|
97
|
+
host: uri.host,
|
98
|
+
port: uri.port,
|
99
|
+
hash: options.hash,
|
100
|
+
ext: options.ext,
|
101
|
+
app: options.app,
|
102
|
+
dlg: options.dlg
|
103
|
+
};
|
104
|
+
|
105
|
+
result.artifacts = artifacts;
|
106
|
+
|
107
|
+
// Calculate payload hash
|
108
|
+
|
109
|
+
if (!artifacts.hash &&
|
110
|
+
(options.payload || options.payload === '')) {
|
111
|
+
|
112
|
+
artifacts.hash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, options.contentType);
|
113
|
+
}
|
114
|
+
|
115
|
+
var mac = hawk.crypto.calculateMac('header', credentials, artifacts);
|
116
|
+
|
117
|
+
// Construct header
|
118
|
+
|
119
|
+
var hasExt = artifacts.ext !== null && artifacts.ext !== undefined && artifacts.ext !== ''; // Other falsey values allowed
|
120
|
+
var header = 'Hawk id="' + credentials.id +
|
121
|
+
'", ts="' + artifacts.ts +
|
122
|
+
'", nonce="' + artifacts.nonce +
|
123
|
+
(artifacts.hash ? '", hash="' + artifacts.hash : '') +
|
124
|
+
(hasExt ? '", ext="' + hawk.utils.escapeHeaderAttribute(artifacts.ext) : '') +
|
125
|
+
'", mac="' + mac + '"';
|
126
|
+
|
127
|
+
if (artifacts.app) {
|
128
|
+
header += ', app="' + artifacts.app +
|
129
|
+
(artifacts.dlg ? '", dlg="' + artifacts.dlg : '') + '"';
|
130
|
+
}
|
131
|
+
|
132
|
+
result.field = header;
|
133
|
+
|
134
|
+
return result;
|
135
|
+
},
|
136
|
+
|
137
|
+
// Generate a bewit value for a given URI
|
138
|
+
|
139
|
+
/*
|
140
|
+
uri: 'http://example.com/resource?a=b'
|
141
|
+
options: {
|
142
|
+
|
143
|
+
// Required
|
144
|
+
|
145
|
+
credentials: {
|
146
|
+
id: 'dh37fgj492je',
|
147
|
+
key: 'aoijedoaijsdlaksjdl',
|
148
|
+
algorithm: 'sha256' // 'sha1', 'sha256'
|
149
|
+
},
|
150
|
+
ttlSec: 60 * 60, // TTL in seconds
|
151
|
+
|
152
|
+
// Optional
|
153
|
+
|
154
|
+
ext: 'application-specific', // Application specific data sent via the ext attribute
|
155
|
+
localtimeOffsetMsec: 400 // Time offset to sync with server time
|
156
|
+
};
|
157
|
+
*/
|
158
|
+
|
159
|
+
bewit: function (uri, options) {
|
160
|
+
|
161
|
+
// Validate inputs
|
162
|
+
|
163
|
+
if (!uri ||
|
164
|
+
(typeof uri !== 'string') ||
|
165
|
+
!options ||
|
166
|
+
typeof options !== 'object' ||
|
167
|
+
!options.ttlSec) {
|
168
|
+
|
169
|
+
return '';
|
170
|
+
}
|
171
|
+
|
172
|
+
options.ext = (options.ext === null || options.ext === undefined ? '' : options.ext); // Zero is valid value
|
173
|
+
|
174
|
+
// Application time
|
175
|
+
|
176
|
+
var now = hawk.utils.now(options.localtimeOffsetMsec);
|
177
|
+
|
178
|
+
// Validate credentials
|
179
|
+
|
180
|
+
var credentials = options.credentials;
|
181
|
+
if (!credentials ||
|
182
|
+
!credentials.id ||
|
183
|
+
!credentials.key ||
|
184
|
+
!credentials.algorithm) {
|
185
|
+
|
186
|
+
return '';
|
187
|
+
}
|
188
|
+
|
189
|
+
if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
190
|
+
return '';
|
191
|
+
}
|
192
|
+
|
193
|
+
// Parse URI
|
194
|
+
|
195
|
+
uri = hawk.utils.parseUri(uri);
|
196
|
+
|
197
|
+
// Calculate signature
|
198
|
+
|
199
|
+
var exp = now + options.ttlSec;
|
200
|
+
var mac = hawk.crypto.calculateMac('bewit', credentials, {
|
201
|
+
ts: exp,
|
202
|
+
nonce: '',
|
203
|
+
method: 'GET',
|
204
|
+
resource: uri.resource, // Maintain trailing '?' and query params
|
205
|
+
host: uri.host,
|
206
|
+
port: uri.port,
|
207
|
+
ext: options.ext
|
208
|
+
});
|
209
|
+
|
210
|
+
// Construct bewit: id\exp\mac\ext
|
211
|
+
|
212
|
+
var bewit = credentials.id + '\\' + exp + '\\' + mac + '\\' + options.ext;
|
213
|
+
return hawk.utils.base64urlEncode(bewit);
|
214
|
+
},
|
215
|
+
|
216
|
+
// Validate server response
|
217
|
+
|
218
|
+
/*
|
219
|
+
request: object created via 'new XMLHttpRequest()' after response received
|
220
|
+
artifacts: object received from header().artifacts
|
221
|
+
options: {
|
222
|
+
payload: optional payload received
|
223
|
+
required: specifies if a Server-Authorization header is required. Defaults to 'false'
|
224
|
+
}
|
225
|
+
*/
|
226
|
+
|
227
|
+
authenticate: function (request, credentials, artifacts, options) {
|
228
|
+
|
229
|
+
options = options || {};
|
230
|
+
|
231
|
+
var getHeader = function (name) {
|
232
|
+
|
233
|
+
return request.getResponseHeader ? request.getResponseHeader(name) : request.getHeader(name);
|
234
|
+
};
|
235
|
+
|
236
|
+
var wwwAuthenticate = getHeader('www-authenticate');
|
237
|
+
if (wwwAuthenticate) {
|
238
|
+
|
239
|
+
// Parse HTTP WWW-Authenticate header
|
240
|
+
|
241
|
+
var wwwAttributes = hawk.utils.parseAuthorizationHeader(wwwAuthenticate, ['ts', 'tsm', 'error']);
|
242
|
+
if (!wwwAttributes) {
|
243
|
+
return false;
|
244
|
+
}
|
245
|
+
|
246
|
+
if (wwwAttributes.ts) {
|
247
|
+
var tsm = hawk.crypto.calculateTsMac(wwwAttributes.ts, credentials);
|
248
|
+
if (tsm !== wwwAttributes.tsm) {
|
249
|
+
return false;
|
250
|
+
}
|
251
|
+
|
252
|
+
hawk.utils.setNtpOffset(wwwAttributes.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
// Parse HTTP Server-Authorization header
|
257
|
+
|
258
|
+
var serverAuthorization = getHeader('server-authorization');
|
259
|
+
if (!serverAuthorization &&
|
260
|
+
!options.required) {
|
261
|
+
|
262
|
+
return true;
|
263
|
+
}
|
264
|
+
|
265
|
+
var attributes = hawk.utils.parseAuthorizationHeader(serverAuthorization, ['mac', 'ext', 'hash']);
|
266
|
+
if (!attributes) {
|
267
|
+
return false;
|
268
|
+
}
|
269
|
+
|
270
|
+
var modArtifacts = {
|
271
|
+
ts: artifacts.ts,
|
272
|
+
nonce: artifacts.nonce,
|
273
|
+
method: artifacts.method,
|
274
|
+
resource: artifacts.resource,
|
275
|
+
host: artifacts.host,
|
276
|
+
port: artifacts.port,
|
277
|
+
hash: attributes.hash,
|
278
|
+
ext: attributes.ext,
|
279
|
+
app: artifacts.app,
|
280
|
+
dlg: artifacts.dlg
|
281
|
+
};
|
282
|
+
|
283
|
+
var mac = hawk.crypto.calculateMac('response', credentials, modArtifacts);
|
284
|
+
if (mac !== attributes.mac) {
|
285
|
+
return false;
|
286
|
+
}
|
287
|
+
|
288
|
+
if (!options.payload &&
|
289
|
+
options.payload !== '') {
|
290
|
+
|
291
|
+
return true;
|
292
|
+
}
|
293
|
+
|
294
|
+
if (!attributes.hash) {
|
295
|
+
return false;
|
296
|
+
}
|
297
|
+
|
298
|
+
var calculatedHash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, getHeader('content-type'));
|
299
|
+
return (calculatedHash === attributes.hash);
|
300
|
+
},
|
301
|
+
|
302
|
+
message: function (host, port, message, options) {
|
303
|
+
|
304
|
+
// Validate inputs
|
305
|
+
|
306
|
+
if (!host || typeof host !== 'string' ||
|
307
|
+
!port || typeof port !== 'number' ||
|
308
|
+
message === null || message === undefined || typeof message !== 'string' ||
|
309
|
+
!options || typeof options !== 'object') {
|
310
|
+
|
311
|
+
return null;
|
312
|
+
}
|
313
|
+
|
314
|
+
// Application time
|
315
|
+
|
316
|
+
var timestamp = options.timestamp || hawk.utils.now(options.localtimeOffsetMsec);
|
317
|
+
|
318
|
+
// Validate credentials
|
319
|
+
|
320
|
+
var credentials = options.credentials;
|
321
|
+
if (!credentials ||
|
322
|
+
!credentials.id ||
|
323
|
+
!credentials.key ||
|
324
|
+
!credentials.algorithm) {
|
325
|
+
|
326
|
+
// Invalid credential object
|
327
|
+
return null;
|
328
|
+
}
|
329
|
+
|
330
|
+
if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
331
|
+
return null;
|
332
|
+
}
|
333
|
+
|
334
|
+
// Calculate signature
|
335
|
+
|
336
|
+
var artifacts = {
|
337
|
+
ts: timestamp,
|
338
|
+
nonce: options.nonce || hawk.utils.randomString(6),
|
339
|
+
host: host,
|
340
|
+
port: port,
|
341
|
+
hash: hawk.crypto.calculatePayloadHash(message, credentials.algorithm)
|
342
|
+
};
|
343
|
+
|
344
|
+
// Construct authorization
|
345
|
+
|
346
|
+
var result = {
|
347
|
+
id: credentials.id,
|
348
|
+
ts: artifacts.ts,
|
349
|
+
nonce: artifacts.nonce,
|
350
|
+
hash: artifacts.hash,
|
351
|
+
mac: hawk.crypto.calculateMac('message', credentials, artifacts)
|
352
|
+
};
|
353
|
+
|
354
|
+
return result;
|
355
|
+
},
|
356
|
+
|
357
|
+
authenticateTimestamp: function (message, credentials, updateClock) { // updateClock defaults to true
|
358
|
+
|
359
|
+
var tsm = hawk.crypto.calculateTsMac(message.ts, credentials);
|
360
|
+
if (tsm !== message.tsm) {
|
361
|
+
return false;
|
362
|
+
}
|
363
|
+
|
364
|
+
if (updateClock !== false) {
|
365
|
+
hawk.utils.setNtpOffset(message.ts - Math.floor((new Date()).getTime() / 1000)); // Keep offset at 1 second precision
|
366
|
+
}
|
367
|
+
|
368
|
+
return true;
|
369
|
+
}
|
370
|
+
};
|
371
|
+
|
372
|
+
|
373
|
+
hawk.crypto = {
|
374
|
+
|
375
|
+
headerVersion: '1',
|
376
|
+
|
377
|
+
algorithms: ['sha1', 'sha256'],
|
378
|
+
|
379
|
+
calculateMac: function (type, credentials, options) {
|
380
|
+
|
381
|
+
var normalized = hawk.crypto.generateNormalizedString(type, options);
|
382
|
+
|
383
|
+
var hmac = CryptoJS['Hmac' + credentials.algorithm.toUpperCase()](normalized, credentials.key);
|
384
|
+
return hmac.toString(CryptoJS.enc.Base64);
|
385
|
+
},
|
386
|
+
|
387
|
+
generateNormalizedString: function (type, options) {
|
388
|
+
|
389
|
+
var normalized = 'hawk.' + hawk.crypto.headerVersion + '.' + type + '\n' +
|
390
|
+
options.ts + '\n' +
|
391
|
+
options.nonce + '\n' +
|
392
|
+
(options.method || '').toUpperCase() + '\n' +
|
393
|
+
(options.resource || '') + '\n' +
|
394
|
+
options.host.toLowerCase() + '\n' +
|
395
|
+
options.port + '\n' +
|
396
|
+
(options.hash || '') + '\n';
|
397
|
+
|
398
|
+
if (options.ext) {
|
399
|
+
normalized += options.ext.replace('\\', '\\\\').replace('\n', '\\n');
|
400
|
+
}
|
401
|
+
|
402
|
+
normalized += '\n';
|
403
|
+
|
404
|
+
if (options.app) {
|
405
|
+
normalized += options.app + '\n' +
|
406
|
+
(options.dlg || '') + '\n';
|
407
|
+
}
|
408
|
+
|
409
|
+
return normalized;
|
410
|
+
},
|
411
|
+
|
412
|
+
calculatePayloadHash: function (payload, algorithm, contentType) {
|
413
|
+
|
414
|
+
var hash = CryptoJS.algo[algorithm.toUpperCase()].create();
|
415
|
+
hash.update('hawk.' + hawk.crypto.headerVersion + '.payload\n');
|
416
|
+
hash.update(hawk.utils.parseContentType(contentType) + '\n');
|
417
|
+
hash.update(payload);
|
418
|
+
hash.update('\n');
|
419
|
+
return hash.finalize().toString(CryptoJS.enc.Base64);
|
420
|
+
},
|
421
|
+
|
422
|
+
calculateTsMac: function (ts, credentials) {
|
423
|
+
|
424
|
+
var hash = CryptoJS['Hmac' + credentials.algorithm.toUpperCase()]('hawk.' + hawk.crypto.headerVersion + '.ts\n' + ts + '\n', credentials.key);
|
425
|
+
return hash.toString(CryptoJS.enc.Base64);
|
426
|
+
}
|
427
|
+
};
|
428
|
+
|
429
|
+
|
430
|
+
// localStorage compatible interface
|
431
|
+
|
432
|
+
hawk.internals.LocalStorage = function () {
|
433
|
+
|
434
|
+
this._cache = {};
|
435
|
+
this.length = 0;
|
436
|
+
|
437
|
+
this.getItem = function (key) {
|
438
|
+
|
439
|
+
return this._cache.hasOwnProperty(key) ? String(this._cache[key]) : null;
|
440
|
+
};
|
441
|
+
|
442
|
+
this.setItem = function (key, value) {
|
443
|
+
|
444
|
+
this._cache[key] = String(value);
|
445
|
+
this.length = Object.keys(this._cache).length;
|
446
|
+
};
|
447
|
+
|
448
|
+
this.removeItem = function (key) {
|
449
|
+
|
450
|
+
delete this._cache[key];
|
451
|
+
this.length = Object.keys(this._cache).length;
|
452
|
+
};
|
453
|
+
|
454
|
+
this.clear = function () {
|
455
|
+
|
456
|
+
this._cache = {};
|
457
|
+
this.length = 0;
|
458
|
+
};
|
459
|
+
|
460
|
+
this.key = function (i) {
|
461
|
+
|
462
|
+
return Object.keys(this._cache)[i || 0];
|
463
|
+
};
|
464
|
+
};
|
465
|
+
|
466
|
+
|
467
|
+
hawk.utils = {
|
468
|
+
|
469
|
+
storage: new hawk.internals.LocalStorage(),
|
470
|
+
|
471
|
+
setStorage: function (storage) {
|
472
|
+
|
473
|
+
var ntpOffset = hawk.utils.storage.getItem('hawk_ntp_offset');
|
474
|
+
hawk.utils.storage = storage;
|
475
|
+
if (ntpOffset) {
|
476
|
+
hawk.utils.setNtpOffset(ntpOffset);
|
477
|
+
}
|
478
|
+
},
|
479
|
+
|
480
|
+
setNtpOffset: function (offset) {
|
481
|
+
|
482
|
+
try {
|
483
|
+
hawk.utils.storage.setItem('hawk_ntp_offset', offset);
|
484
|
+
}
|
485
|
+
catch (err) {
|
486
|
+
console.error('[hawk] could not write to storage.');
|
487
|
+
console.error(err);
|
488
|
+
}
|
489
|
+
},
|
490
|
+
|
491
|
+
getNtpOffset: function () {
|
492
|
+
|
493
|
+
var offset = hawk.utils.storage.getItem('hawk_ntp_offset');
|
494
|
+
if (!offset) {
|
495
|
+
return 0;
|
496
|
+
}
|
497
|
+
|
498
|
+
return parseInt(offset, 10);
|
499
|
+
},
|
500
|
+
|
501
|
+
now: function (localtimeOffsetMsec) {
|
502
|
+
|
503
|
+
return Math.floor(((new Date()).getTime() + (localtimeOffsetMsec || 0)) / 1000) + hawk.utils.getNtpOffset();
|
504
|
+
},
|
505
|
+
|
506
|
+
escapeHeaderAttribute: function (attribute) {
|
507
|
+
|
508
|
+
return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"');
|
509
|
+
},
|
510
|
+
|
511
|
+
parseContentType: function (header) {
|
512
|
+
|
513
|
+
if (!header) {
|
514
|
+
return '';
|
515
|
+
}
|
516
|
+
|
517
|
+
return header.split(';')[0].replace(/^\s+|\s+$/g, '').toLowerCase();
|
518
|
+
},
|
519
|
+
|
520
|
+
parseAuthorizationHeader: function (header, keys) {
|
521
|
+
|
522
|
+
if (!header) {
|
523
|
+
return null;
|
524
|
+
}
|
525
|
+
|
526
|
+
var headerParts = header.match(/^(\w+)(?:\s+(.*))?$/); // Header: scheme[ something]
|
527
|
+
if (!headerParts) {
|
528
|
+
return null;
|
529
|
+
}
|
530
|
+
|
531
|
+
var scheme = headerParts[1];
|
532
|
+
if (scheme.toLowerCase() !== 'hawk') {
|
533
|
+
return null;
|
534
|
+
}
|
535
|
+
|
536
|
+
var attributesString = headerParts[2];
|
537
|
+
if (!attributesString) {
|
538
|
+
return null;
|
539
|
+
}
|
540
|
+
|
541
|
+
var attributes = {};
|
542
|
+
var verify = attributesString.replace(/(\w+)="([^"\\]*)"\s*(?:,\s*|$)/g, function ($0, $1, $2) {
|
543
|
+
|
544
|
+
// Check valid attribute names
|
545
|
+
|
546
|
+
if (keys.indexOf($1) === -1) {
|
547
|
+
return;
|
548
|
+
}
|
549
|
+
|
550
|
+
// Allowed attribute value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9
|
551
|
+
|
552
|
+
if ($2.match(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~]+$/) === null) {
|
553
|
+
return;
|
554
|
+
}
|
555
|
+
|
556
|
+
// Check for duplicates
|
557
|
+
|
558
|
+
if (attributes.hasOwnProperty($1)) {
|
559
|
+
return;
|
560
|
+
}
|
561
|
+
|
562
|
+
attributes[$1] = $2;
|
563
|
+
return '';
|
564
|
+
});
|
565
|
+
|
566
|
+
if (verify !== '') {
|
567
|
+
return null;
|
568
|
+
}
|
569
|
+
|
570
|
+
return attributes;
|
571
|
+
},
|
572
|
+
|
573
|
+
randomString: function (size) {
|
574
|
+
|
575
|
+
var randomSource = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
576
|
+
var len = randomSource.length;
|
577
|
+
|
578
|
+
var result = [];
|
579
|
+
for (var i = 0; i < size; ++i) {
|
580
|
+
result[i] = randomSource[Math.floor(Math.random() * len)];
|
581
|
+
}
|
582
|
+
|
583
|
+
return result.join('');
|
584
|
+
},
|
585
|
+
|
586
|
+
uriRegex: /^([^:]+)\:\/\/(?:[^@]*@)?([^\/:]+)(?:\:(\d+))?([^#]*)(?:#.*)?$/, // scheme://credentials@host:port/resource#fragment
|
587
|
+
parseUri: function (input) {
|
588
|
+
|
589
|
+
var parts = input.match(hawk.utils.uriRegex);
|
590
|
+
if (!parts) {
|
591
|
+
return { host: '', port: '', resource: '' };
|
592
|
+
}
|
593
|
+
|
594
|
+
var scheme = parts[1].toLowerCase();
|
595
|
+
var uri = {
|
596
|
+
host: parts[2],
|
597
|
+
port: parts[3] || (scheme === 'http' ? '80' : (scheme === 'https' ? '443' : '')),
|
598
|
+
resource: parts[4]
|
599
|
+
};
|
600
|
+
|
601
|
+
return uri;
|
602
|
+
},
|
603
|
+
|
604
|
+
base64urlEncode: function (value) {
|
605
|
+
|
606
|
+
var wordArray = CryptoJS.enc.Utf8.parse(value);
|
607
|
+
var encoded = CryptoJS.enc.Base64.stringify(wordArray);
|
608
|
+
return encoded.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
|
609
|
+
}
|
610
|
+
};
|
611
|
+
|
612
|
+
|
613
|
+
// $lab:coverage:off$
|
614
|
+
/* eslint-disable */
|
615
|
+
|
616
|
+
// Based on: Crypto-JS v3.1.2
|
617
|
+
// Copyright (c) 2009-2013, Jeff Mott. All rights reserved.
|
618
|
+
// http://code.google.com/p/crypto-js/
|
619
|
+
// http://code.google.com/p/crypto-js/wiki/License
|
620
|
+
|
621
|
+
var CryptoJS = CryptoJS || function (h, r) { var k = {}, l = k.lib = {}, n = function () { }, f = l.Base = { extend: function (a) { n.prototype = this; var b = new n; a && b.mixIn(a); b.hasOwnProperty("init") || (b.init = function () { b.$super.init.apply(this, arguments) }); b.init.prototype = b; b.$super = this; return b }, create: function () { var a = this.extend(); a.init.apply(a, arguments); return a }, init: function () { }, mixIn: function (a) { for (var b in a) a.hasOwnProperty(b) && (this[b] = a[b]); a.hasOwnProperty("toString") && (this.toString = a.toString) }, clone: function () { return this.init.prototype.extend(this) } }, j = l.WordArray = f.extend({ init: function (a, b) { a = this.words = a || []; this.sigBytes = b != r ? b : 4 * a.length }, toString: function (a) { return (a || s).stringify(this) }, concat: function (a) { var b = this.words, d = a.words, c = this.sigBytes; a = a.sigBytes; this.clamp(); if (c % 4) for (var e = 0; e < a; e++) b[c + e >>> 2] |= (d[e >>> 2] >>> 24 - 8 * (e % 4) & 255) << 24 - 8 * ((c + e) % 4); else if (65535 < d.length) for (e = 0; e < a; e += 4) b[c + e >>> 2] = d[e >>> 2]; else b.push.apply(b, d); this.sigBytes += a; return this }, clamp: function () { var a = this.words, b = this.sigBytes; a[b >>> 2] &= 4294967295 << 32 - 8 * (b % 4); a.length = h.ceil(b / 4) }, clone: function () { var a = f.clone.call(this); a.words = this.words.slice(0); return a }, random: function (a) { for (var b = [], d = 0; d < a; d += 4) b.push(4294967296 * h.random() | 0); return new j.init(b, a) } }), m = k.enc = {}, s = m.Hex = { stringify: function (a) { var b = a.words; a = a.sigBytes; for (var d = [], c = 0; c < a; c++) { var e = b[c >>> 2] >>> 24 - 8 * (c % 4) & 255; d.push((e >>> 4).toString(16)); d.push((e & 15).toString(16)) } return d.join("") }, parse: function (a) { for (var b = a.length, d = [], c = 0; c < b; c += 2) d[c >>> 3] |= parseInt(a.substr(c, 2), 16) << 24 - 4 * (c % 8); return new j.init(d, b / 2) } }, p = m.Latin1 = { stringify: function (a) { var b = a.words; a = a.sigBytes; for (var d = [], c = 0; c < a; c++) d.push(String.fromCharCode(b[c >>> 2] >>> 24 - 8 * (c % 4) & 255)); return d.join("") }, parse: function (a) { for (var b = a.length, d = [], c = 0; c < b; c++) d[c >>> 2] |= (a.charCodeAt(c) & 255) << 24 - 8 * (c % 4); return new j.init(d, b) } }, t = m.Utf8 = { stringify: function (a) { try { return decodeURIComponent(escape(p.stringify(a))) } catch (b) { throw Error("Malformed UTF-8 data"); } }, parse: function (a) { return p.parse(unescape(encodeURIComponent(a))) } }, q = l.BufferedBlockAlgorithm = f.extend({ reset: function () { this._data = new j.init; this._nDataBytes = 0 }, _append: function (a) { "string" == typeof a && (a = t.parse(a)); this._data.concat(a); this._nDataBytes += a.sigBytes }, _process: function (a) { var b = this._data, d = b.words, c = b.sigBytes, e = this.blockSize, f = c / (4 * e), f = a ? h.ceil(f) : h.max((f | 0) - this._minBufferSize, 0); a = f * e; c = h.min(4 * a, c); if (a) { for (var g = 0; g < a; g += e) this._doProcessBlock(d, g); g = d.splice(0, a); b.sigBytes -= c } return new j.init(g, c) }, clone: function () { var a = f.clone.call(this); a._data = this._data.clone(); return a }, _minBufferSize: 0 }); l.Hasher = q.extend({ cfg: f.extend(), init: function (a) { this.cfg = this.cfg.extend(a); this.reset() }, reset: function () { q.reset.call(this); this._doReset() }, update: function (a) { this._append(a); this._process(); return this }, finalize: function (a) { a && this._append(a); return this._doFinalize() }, blockSize: 16, _createHelper: function (a) { return function (b, d) { return (new a.init(d)).finalize(b) } }, _createHmacHelper: function (a) { return function (b, d) { return (new u.HMAC.init(a, d)).finalize(b) } } }); var u = k.algo = {}; return k }(Math);
|
622
|
+
(function () { var k = CryptoJS, b = k.lib, m = b.WordArray, l = b.Hasher, d = [], b = k.algo.SHA1 = l.extend({ _doReset: function () { this._hash = new m.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function (n, p) { for (var a = this._hash.words, e = a[0], f = a[1], h = a[2], j = a[3], b = a[4], c = 0; 80 > c; c++) { if (16 > c) d[c] = n[p + c] | 0; else { var g = d[c - 3] ^ d[c - 8] ^ d[c - 14] ^ d[c - 16]; d[c] = g << 1 | g >>> 31 } g = (e << 5 | e >>> 27) + b + d[c]; g = 20 > c ? g + ((f & h | ~f & j) + 1518500249) : 40 > c ? g + ((f ^ h ^ j) + 1859775393) : 60 > c ? g + ((f & h | f & j | h & j) - 1894007588) : g + ((f ^ h ^ j) - 899497514); b = j; j = h; h = f << 30 | f >>> 2; f = e; e = g } a[0] = a[0] + e | 0; a[1] = a[1] + f | 0; a[2] = a[2] + h | 0; a[3] = a[3] + j | 0; a[4] = a[4] + b | 0 }, _doFinalize: function () { var b = this._data, d = b.words, a = 8 * this._nDataBytes, e = 8 * b.sigBytes; d[e >>> 5] |= 128 << 24 - e % 32; d[(e + 64 >>> 9 << 4) + 14] = Math.floor(a / 4294967296); d[(e + 64 >>> 9 << 4) + 15] = a; b.sigBytes = 4 * d.length; this._process(); return this._hash }, clone: function () { var b = l.clone.call(this); b._hash = this._hash.clone(); return b } }); k.SHA1 = l._createHelper(b); k.HmacSHA1 = l._createHmacHelper(b) })();
|
623
|
+
(function (k) { for (var g = CryptoJS, h = g.lib, v = h.WordArray, j = h.Hasher, h = g.algo, s = [], t = [], u = function (q) { return 4294967296 * (q - (q | 0)) | 0 }, l = 2, b = 0; 64 > b;) { var d; a: { d = l; for (var w = k.sqrt(d), r = 2; r <= w; r++) if (!(d % r)) { d = !1; break a } d = !0 } d && (8 > b && (s[b] = u(k.pow(l, 0.5))), t[b] = u(k.pow(l, 1 / 3)), b++); l++ } var n = [], h = h.SHA256 = j.extend({ _doReset: function () { this._hash = new v.init(s.slice(0)) }, _doProcessBlock: function (q, h) { for (var a = this._hash.words, c = a[0], d = a[1], b = a[2], k = a[3], f = a[4], g = a[5], j = a[6], l = a[7], e = 0; 64 > e; e++) { if (16 > e) n[e] = q[h + e] | 0; else { var m = n[e - 15], p = n[e - 2]; n[e] = ((m << 25 | m >>> 7) ^ (m << 14 | m >>> 18) ^ m >>> 3) + n[e - 7] + ((p << 15 | p >>> 17) ^ (p << 13 | p >>> 19) ^ p >>> 10) + n[e - 16] } m = l + ((f << 26 | f >>> 6) ^ (f << 21 | f >>> 11) ^ (f << 7 | f >>> 25)) + (f & g ^ ~f & j) + t[e] + n[e]; p = ((c << 30 | c >>> 2) ^ (c << 19 | c >>> 13) ^ (c << 10 | c >>> 22)) + (c & d ^ c & b ^ d & b); l = j; j = g; g = f; f = k + m | 0; k = b; b = d; d = c; c = m + p | 0 } a[0] = a[0] + c | 0; a[1] = a[1] + d | 0; a[2] = a[2] + b | 0; a[3] = a[3] + k | 0; a[4] = a[4] + f | 0; a[5] = a[5] + g | 0; a[6] = a[6] + j | 0; a[7] = a[7] + l | 0 }, _doFinalize: function () { var d = this._data, b = d.words, a = 8 * this._nDataBytes, c = 8 * d.sigBytes; b[c >>> 5] |= 128 << 24 - c % 32; b[(c + 64 >>> 9 << 4) + 14] = k.floor(a / 4294967296); b[(c + 64 >>> 9 << 4) + 15] = a; d.sigBytes = 4 * b.length; this._process(); return this._hash }, clone: function () { var b = j.clone.call(this); b._hash = this._hash.clone(); return b } }); g.SHA256 = j._createHelper(h); g.HmacSHA256 = j._createHmacHelper(h) })(Math);
|
624
|
+
(function () { var c = CryptoJS, k = c.enc.Utf8; c.algo.HMAC = c.lib.Base.extend({ init: function (a, b) { a = this._hasher = new a.init; "string" == typeof b && (b = k.parse(b)); var c = a.blockSize, e = 4 * c; b.sigBytes > e && (b = a.finalize(b)); b.clamp(); for (var f = this._oKey = b.clone(), g = this._iKey = b.clone(), h = f.words, j = g.words, d = 0; d < c; d++) h[d] ^= 1549556828, j[d] ^= 909522486; f.sigBytes = g.sigBytes = e; this.reset() }, reset: function () { var a = this._hasher; a.reset(); a.update(this._iKey) }, update: function (a) { this._hasher.update(a); return this }, finalize: function (a) { var b = this._hasher; a = b.finalize(a); b.reset(); return b.finalize(this._oKey.clone().concat(a)) } }) })();
|
625
|
+
(function () { var h = CryptoJS, j = h.lib.WordArray; h.enc.Base64 = { stringify: function (b) { var e = b.words, f = b.sigBytes, c = this._map; b.clamp(); b = []; for (var a = 0; a < f; a += 3) for (var d = (e[a >>> 2] >>> 24 - 8 * (a % 4) & 255) << 16 | (e[a + 1 >>> 2] >>> 24 - 8 * ((a + 1) % 4) & 255) << 8 | e[a + 2 >>> 2] >>> 24 - 8 * ((a + 2) % 4) & 255, g = 0; 4 > g && a + 0.75 * g < f; g++) b.push(c.charAt(d >>> 6 * (3 - g) & 63)); if (e = c.charAt(64)) for (; b.length % 4;) b.push(e); return b.join("") }, parse: function (b) { var e = b.length, f = this._map, c = f.charAt(64); c && (c = b.indexOf(c), -1 != c && (e = c)); for (var c = [], a = 0, d = 0; d < e; d++) if (d % 4) { var g = f.indexOf(b.charAt(d - 1)) << 2 * (d % 4), h = f.indexOf(b.charAt(d)) >>> 6 - 2 * (d % 4); c[a >>> 2] |= (g | h) << 24 - 8 * (a % 4); a++ } return j.create(c, a) }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" } })();
|
626
|
+
|
627
|
+
hawk.crypto.internals = CryptoJS;
|
628
|
+
|
629
|
+
|
630
|
+
// Export if used as a module
|
631
|
+
|
632
|
+
if (typeof module !== 'undefined' && module.exports) {
|
633
|
+
module.exports = hawk;
|
634
|
+
}
|
635
|
+
|
636
|
+
/* eslint-enable */
|
637
|
+
// $lab:coverage:on$
|