ai 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +10 -24
- package/dist/ai-stream.d.ts +18 -0
- package/dist/ai-stream.js +132 -0
- package/dist/ai-stream.mjs +13 -0
- package/dist/anthropic-stream.d.ts +5 -0
- package/dist/anthropic-stream.js +133 -0
- package/dist/anthropic-stream.mjs +8 -0
- package/dist/chunk-265FSSO4.mjs +91 -0
- package/dist/chunk-2L3ZO4UM.mjs +45 -0
- package/dist/chunk-EZJ7FC5E.mjs +33 -0
- package/dist/chunk-JGDC3BXD.mjs +22 -0
- package/dist/chunk-NK2CVBLI.mjs +38 -0
- package/dist/chunk-PEYAHBDF.mjs +43 -0
- package/dist/chunk-TJMME6CL.mjs +24 -0
- package/dist/huggingface-stream.d.ts +5 -0
- package/dist/huggingface-stream.js +121 -0
- package/dist/huggingface-stream.mjs +8 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +278 -0
- package/dist/index.mjs +35 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.js +12 -0
- package/dist/index.test.mjs +10 -0
- package/dist/langchain-stream.d.ts +12 -0
- package/dist/langchain-stream.js +102 -0
- package/dist/langchain-stream.mjs +8 -0
- package/dist/openai-stream.d.ts +5 -0
- package/dist/openai-stream.js +144 -0
- package/dist/openai-stream.mjs +8 -0
- package/dist/streaming-text-response.d.ts +17 -0
- package/dist/streaming-text-response.js +75 -0
- package/dist/streaming-text-response.mjs +9 -0
- package/package.json +78 -29
- package/react/dist/chunk-5PP6W52J.mjs +202 -0
- package/react/dist/chunk-6EH3SWMP.mjs +55 -0
- package/react/dist/chunk-PW6HSU2N.mjs +154 -0
- package/react/dist/index.d.ts +3 -0
- package/react/dist/index.js +424 -0
- package/react/dist/index.mjs +12 -0
- package/react/dist/types-f862f74a.d.ts +123 -0
- package/react/dist/use-chat.d.ts +42 -0
- package/react/dist/use-chat.js +276 -0
- package/react/dist/use-chat.mjs +8 -0
- package/react/dist/use-completion.d.ts +47 -0
- package/react/dist/use-completion.js +229 -0
- package/react/dist/use-completion.mjs +8 -0
- package/svelte/dist/chunk-6USBQIV6.mjs +177 -0
- package/svelte/dist/chunk-BQ64GHZ3.mjs +136 -0
- package/svelte/dist/chunk-CENOSGDG.mjs +493 -0
- package/svelte/dist/index.d.ts +4 -0
- package/svelte/dist/index.js +808 -0
- package/svelte/dist/index.mjs +11 -0
- package/svelte/dist/types-f862f74a.d.ts +123 -0
- package/svelte/dist/use-chat.d.ts +39 -0
- package/svelte/dist/use-chat.js +680 -0
- package/svelte/dist/use-chat.mjs +7 -0
- package/svelte/dist/use-completion.d.ts +38 -0
- package/svelte/dist/use-completion.js +640 -0
- package/svelte/dist/use-completion.mjs +7 -0
- package/.npmignore +0 -15
- package/.travis.yml +0 -4
- package/README.md +0 -21
- package/bin/ai.js +0 -22
- package/index.js +0 -32
- package/node_modules/request/.npmignore +0 -2
- package/node_modules/request/.travis.yml +0 -12
- package/node_modules/request/CHANGELOG.md +0 -954
- package/node_modules/request/LICENSE +0 -55
- package/node_modules/request/README.md +0 -421
- package/node_modules/request/index.js +0 -166
- package/node_modules/request/lib/cookies.js +0 -40
- package/node_modules/request/lib/copy.js +0 -8
- package/node_modules/request/lib/debug.js +0 -7
- package/node_modules/request/lib/getSafe.js +0 -34
- package/node_modules/request/lib/optional.js +0 -5
- package/node_modules/request/node_modules/aws-sign2/LICENSE +0 -55
- package/node_modules/request/node_modules/aws-sign2/README.md +0 -4
- package/node_modules/request/node_modules/aws-sign2/index.js +0 -202
- package/node_modules/request/node_modules/aws-sign2/package.json +0 -47
- package/node_modules/request/node_modules/forever-agent/LICENSE +0 -55
- package/node_modules/request/node_modules/forever-agent/README.md +0 -4
- package/node_modules/request/node_modules/forever-agent/index.js +0 -119
- package/node_modules/request/node_modules/forever-agent/package.json +0 -46
- package/node_modules/request/node_modules/form-data/License +0 -19
- package/node_modules/request/node_modules/form-data/Readme.md +0 -175
- package/node_modules/request/node_modules/form-data/lib/form_data.js +0 -351
- package/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +0 -3
- package/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/async/README.md +0 -1646
- package/node_modules/request/node_modules/form-data/node_modules/async/component.json +0 -11
- package/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +0 -1123
- package/node_modules/request/node_modules/form-data/node_modules/async/package.json +0 -60
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +0 -132
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +0 -186
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +0 -2
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +0 -7
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +0 -154
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +0 -99
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +0 -42
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +0 -6
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +0 -38
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +0 -21
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +0 -14
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +0 -48
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +0 -15
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +0 -18
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +0 -13
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +0 -13
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +0 -7
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +0 -61
- package/node_modules/request/node_modules/form-data/node_modules/mime/LICENSE +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/mime/README.md +0 -66
- package/node_modules/request/node_modules/form-data/node_modules/mime/mime.js +0 -114
- package/node_modules/request/node_modules/form-data/node_modules/mime/package.json +0 -59
- package/node_modules/request/node_modules/form-data/node_modules/mime/test.js +0 -84
- package/node_modules/request/node_modules/form-data/node_modules/mime/types/mime.types +0 -1588
- package/node_modules/request/node_modules/form-data/node_modules/mime/types/node.types +0 -77
- package/node_modules/request/node_modules/form-data/package.json +0 -80
- package/node_modules/request/node_modules/hawk/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/Makefile +0 -10
- package/node_modules/request/node_modules/hawk/README.md +0 -625
- package/node_modules/request/node_modules/hawk/example/usage.js +0 -78
- package/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
- package/node_modules/request/node_modules/hawk/images/logo.png +0 -0
- package/node_modules/request/node_modules/hawk/index.js +0 -1
- package/node_modules/request/node_modules/hawk/lib/browser.js +0 -507
- package/node_modules/request/node_modules/hawk/lib/client.js +0 -371
- package/node_modules/request/node_modules/hawk/lib/crypto.js +0 -118
- package/node_modules/request/node_modules/hawk/lib/index.js +0 -15
- package/node_modules/request/node_modules/hawk/lib/server.js +0 -523
- package/node_modules/request/node_modules/hawk/lib/utils.js +0 -183
- package/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/boom/README.md +0 -6
- package/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
- package/node_modules/request/node_modules/hawk/node_modules/boom/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +0 -207
- package/node_modules/request/node_modules/hawk/node_modules/boom/package.json +0 -64
- package/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +0 -245
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +0 -6
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +0 -68
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +0 -65
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +0 -101
- package/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +0 -33
- package/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +0 -10
- package/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +0 -436
- package/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
- package/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +0 -132
- package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +0 -585
- package/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +0 -70
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +0 -86
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +0 -1078
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +0 -68
- package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +0 -16
- package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +0 -25
- package/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +0 -409
- package/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +0 -65
- package/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +0 -359
- package/node_modules/request/node_modules/hawk/package.json +0 -70
- package/node_modules/request/node_modules/hawk/test/browser.js +0 -817
- package/node_modules/request/node_modules/hawk/test/client.js +0 -206
- package/node_modules/request/node_modules/hawk/test/crypto.js +0 -86
- package/node_modules/request/node_modules/hawk/test/index.js +0 -316
- package/node_modules/request/node_modules/hawk/test/message.js +0 -246
- package/node_modules/request/node_modules/hawk/test/readme.js +0 -98
- package/node_modules/request/node_modules/hawk/test/server.js +0 -686
- package/node_modules/request/node_modules/hawk/test/uri.js +0 -456
- package/node_modules/request/node_modules/hawk/test/utils.js +0 -120
- package/node_modules/request/node_modules/http-signature/.dir-locals.el +0 -6
- package/node_modules/request/node_modules/http-signature/.npmignore +0 -7
- package/node_modules/request/node_modules/http-signature/LICENSE +0 -18
- package/node_modules/request/node_modules/http-signature/README.md +0 -75
- package/node_modules/request/node_modules/http-signature/http_signing.md +0 -296
- package/node_modules/request/node_modules/http-signature/lib/index.js +0 -25
- package/node_modules/request/node_modules/http-signature/lib/parser.js +0 -304
- package/node_modules/request/node_modules/http-signature/lib/signer.js +0 -179
- package/node_modules/request/node_modules/http-signature/lib/util.js +0 -249
- package/node_modules/request/node_modules/http-signature/lib/verify.js +0 -42
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +0 -2
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +0 -19
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +0 -50
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +0 -27
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +0 -267
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +0 -36
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +0 -317
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +0 -20
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +0 -63
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +0 -172
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +0 -296
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +0 -126
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +0 -196
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +0 -38
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +0 -71
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +0 -24
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/README +0 -82
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +0 -298
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +0 -245
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +0 -1485
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +0 -944
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +0 -36
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +0 -129
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +0 -839
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/float.json +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/int.json +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/psinfo.json +0 -104
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/struct.json +0 -19
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.fail.js +0 -39
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.float.js +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.int.js +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.psinfo.js +0 -17
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.struct.js +0 -18
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.typedef.js +0 -15
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/typedef.json +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.rfloat.js +0 -767
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.wfloat.js +0 -753
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.64.js +0 -638
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.rint.js +0 -101
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wbounds.js +0 -53
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wint.js +0 -92
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.64.js +0 -451
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.roundtrip.js +0 -81
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.ruint.js +0 -95
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.wuint.js +0 -156
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicr.js +0 -50
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicw.js +0 -44
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.char.js +0 -42
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.endian.js +0 -45
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.oldwrite.js +0 -28
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.readSize.js +0 -128
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.structw.js +0 -28
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.writeStruct.js +0 -31
- package/node_modules/request/node_modules/http-signature/package.json +0 -54
- package/node_modules/request/node_modules/json-stringify-safe/LICENSE +0 -27
- package/node_modules/request/node_modules/json-stringify-safe/README.md +0 -49
- package/node_modules/request/node_modules/json-stringify-safe/package.json +0 -51
- package/node_modules/request/node_modules/json-stringify-safe/stringify.js +0 -39
- package/node_modules/request/node_modules/json-stringify-safe/test.js +0 -128
- package/node_modules/request/node_modules/mime-types/.npmignore +0 -14
- package/node_modules/request/node_modules/mime-types/.travis.yml +0 -12
- package/node_modules/request/node_modules/mime-types/LICENSE +0 -22
- package/node_modules/request/node_modules/mime-types/Makefile +0 -9
- package/node_modules/request/node_modules/mime-types/README.md +0 -101
- package/node_modules/request/node_modules/mime-types/SOURCES.md +0 -17
- package/node_modules/request/node_modules/mime-types/component.json +0 -16
- package/node_modules/request/node_modules/mime-types/lib/custom.json +0 -27
- package/node_modules/request/node_modules/mime-types/lib/index.js +0 -75
- package/node_modules/request/node_modules/mime-types/lib/mime.json +0 -3317
- package/node_modules/request/node_modules/mime-types/lib/node.json +0 -55
- package/node_modules/request/node_modules/mime-types/package.json +0 -69
- package/node_modules/request/node_modules/node-uuid/.npmignore +0 -2
- package/node_modules/request/node_modules/node-uuid/LICENSE.md +0 -2
- package/node_modules/request/node_modules/node-uuid/README.md +0 -207
- package/node_modules/request/node_modules/node-uuid/benchmark/README.md +0 -53
- package/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +0 -174
- package/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +0 -34
- package/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +0 -34
- package/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +0 -84
- package/node_modules/request/node_modules/node-uuid/component.json +0 -18
- package/node_modules/request/node_modules/node-uuid/package.json +0 -54
- package/node_modules/request/node_modules/node-uuid/test/compare_v1.js +0 -63
- package/node_modules/request/node_modules/node-uuid/test/test.html +0 -17
- package/node_modules/request/node_modules/node-uuid/test/test.js +0 -228
- package/node_modules/request/node_modules/node-uuid/uuid.js +0 -245
- package/node_modules/request/node_modules/oauth-sign/LICENSE +0 -55
- package/node_modules/request/node_modules/oauth-sign/README.md +0 -4
- package/node_modules/request/node_modules/oauth-sign/index.js +0 -43
- package/node_modules/request/node_modules/oauth-sign/package.json +0 -49
- package/node_modules/request/node_modules/oauth-sign/test.js +0 -49
- package/node_modules/request/node_modules/qs/.jshintignore +0 -1
- package/node_modules/request/node_modules/qs/.jshintrc +0 -10
- package/node_modules/request/node_modules/qs/.npmignore +0 -18
- package/node_modules/request/node_modules/qs/.travis.yml +0 -4
- package/node_modules/request/node_modules/qs/LICENSE +0 -28
- package/node_modules/request/node_modules/qs/Makefile +0 -8
- package/node_modules/request/node_modules/qs/Readme.md +0 -120
- package/node_modules/request/node_modules/qs/index.js +0 -1
- package/node_modules/request/node_modules/qs/lib/index.js +0 -15
- package/node_modules/request/node_modules/qs/lib/parse.js +0 -151
- package/node_modules/request/node_modules/qs/lib/stringify.js +0 -52
- package/node_modules/request/node_modules/qs/lib/utils.js +0 -131
- package/node_modules/request/node_modules/qs/package.json +0 -61
- package/node_modules/request/node_modules/qs/test/parse.js +0 -236
- package/node_modules/request/node_modules/qs/test/stringify.js +0 -123
- package/node_modules/request/node_modules/stringstream/.npmignore +0 -15
- package/node_modules/request/node_modules/stringstream/.travis.yml +0 -4
- package/node_modules/request/node_modules/stringstream/LICENSE.txt +0 -4
- package/node_modules/request/node_modules/stringstream/README.md +0 -38
- package/node_modules/request/node_modules/stringstream/example.js +0 -27
- package/node_modules/request/node_modules/stringstream/package.json +0 -48
- package/node_modules/request/node_modules/stringstream/stringstream.js +0 -102
- package/node_modules/request/node_modules/tough-cookie/.jshintrc +0 -70
- package/node_modules/request/node_modules/tough-cookie/.npmignore +0 -3
- package/node_modules/request/node_modules/tough-cookie/.travis.yml +0 -8
- package/node_modules/request/node_modules/tough-cookie/LICENSE +0 -78
- package/node_modules/request/node_modules/tough-cookie/README.md +0 -412
- package/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +0 -239
- package/node_modules/request/node_modules/tough-cookie/lib/cookie.js +0 -1107
- package/node_modules/request/node_modules/tough-cookie/lib/memstore.js +0 -123
- package/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +0 -69
- package/node_modules/request/node_modules/tough-cookie/lib/store.js +0 -37
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +0 -20
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +0 -176
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +0 -87
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +0 -528
- package/node_modules/request/node_modules/tough-cookie/package.json +0 -67
- package/node_modules/request/node_modules/tough-cookie/public-suffix.txt +0 -5229
- package/node_modules/request/node_modules/tough-cookie/test.js +0 -1625
- package/node_modules/request/node_modules/tunnel-agent/.jshintrc +0 -5
- package/node_modules/request/node_modules/tunnel-agent/LICENSE +0 -55
- package/node_modules/request/node_modules/tunnel-agent/README.md +0 -4
- package/node_modules/request/node_modules/tunnel-agent/index.js +0 -236
- package/node_modules/request/node_modules/tunnel-agent/package.json +0 -46
- package/node_modules/request/package.json +0 -77
- package/node_modules/request/request.js +0 -1428
- package/test/fixtures/github-response.json +0 -1367
- package/test/index.js +0 -55
@@ -1,456 +0,0 @@
|
|
1
|
-
// Load modules
|
2
|
-
|
3
|
-
var Http = require('http');
|
4
|
-
var Lab = require('lab');
|
5
|
-
var Hawk = require('../lib');
|
6
|
-
|
7
|
-
|
8
|
-
// Declare internals
|
9
|
-
|
10
|
-
var internals = {};
|
11
|
-
|
12
|
-
|
13
|
-
// Test shortcuts
|
14
|
-
|
15
|
-
var expect = Lab.expect;
|
16
|
-
var before = Lab.before;
|
17
|
-
var after = Lab.after;
|
18
|
-
var describe = Lab.experiment;
|
19
|
-
var it = Lab.test;
|
20
|
-
|
21
|
-
|
22
|
-
describe('Hawk', function () {
|
23
|
-
|
24
|
-
describe('Uri', function () {
|
25
|
-
|
26
|
-
var credentialsFunc = function (id, callback) {
|
27
|
-
|
28
|
-
var credentials = {
|
29
|
-
id: id,
|
30
|
-
key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
|
31
|
-
algorithm: 'sha256',
|
32
|
-
user: 'steve'
|
33
|
-
};
|
34
|
-
|
35
|
-
return callback(null, credentials);
|
36
|
-
};
|
37
|
-
|
38
|
-
it('should generate a bewit then successfully authenticate it', function (done) {
|
39
|
-
|
40
|
-
var req = {
|
41
|
-
method: 'GET',
|
42
|
-
url: '/resource/4?a=1&b=2',
|
43
|
-
host: 'example.com',
|
44
|
-
port: 80
|
45
|
-
};
|
46
|
-
|
47
|
-
credentialsFunc('123456', function (err, credentials) {
|
48
|
-
|
49
|
-
var bewit = Hawk.uri.getBewit('http://example.com/resource/4?a=1&b=2', { credentials: credentials, ttlSec: 60 * 60 * 24 * 365 * 100, ext: 'some-app-data' });
|
50
|
-
req.url += '&bewit=' + bewit;
|
51
|
-
|
52
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
53
|
-
|
54
|
-
expect(err).to.not.exist;
|
55
|
-
expect(credentials.user).to.equal('steve');
|
56
|
-
expect(attributes.ext).to.equal('some-app-data');
|
57
|
-
done();
|
58
|
-
});
|
59
|
-
});
|
60
|
-
});
|
61
|
-
|
62
|
-
it('should generate a bewit then successfully authenticate it (no ext)', function (done) {
|
63
|
-
|
64
|
-
var req = {
|
65
|
-
method: 'GET',
|
66
|
-
url: '/resource/4?a=1&b=2',
|
67
|
-
host: 'example.com',
|
68
|
-
port: 80
|
69
|
-
};
|
70
|
-
|
71
|
-
credentialsFunc('123456', function (err, credentials) {
|
72
|
-
|
73
|
-
var bewit = Hawk.uri.getBewit('http://example.com/resource/4?a=1&b=2', { credentials: credentials, ttlSec: 60 * 60 * 24 * 365 * 100 });
|
74
|
-
req.url += '&bewit=' + bewit;
|
75
|
-
|
76
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
77
|
-
|
78
|
-
expect(err).to.not.exist;
|
79
|
-
expect(credentials.user).to.equal('steve');
|
80
|
-
done();
|
81
|
-
});
|
82
|
-
});
|
83
|
-
});
|
84
|
-
|
85
|
-
it('should successfully authenticate a request (last param)', function (done) {
|
86
|
-
|
87
|
-
var req = {
|
88
|
-
method: 'GET',
|
89
|
-
url: '/resource/4?a=1&b=2&bewit=MTIzNDU2XDQ1MTE0ODQ2MjFcMzFjMmNkbUJFd1NJRVZDOVkva1NFb2c3d3YrdEVNWjZ3RXNmOGNHU2FXQT1cc29tZS1hcHAtZGF0YQ',
|
90
|
-
host: 'example.com',
|
91
|
-
port: 8080
|
92
|
-
};
|
93
|
-
|
94
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
95
|
-
|
96
|
-
expect(err).to.not.exist;
|
97
|
-
expect(credentials.user).to.equal('steve');
|
98
|
-
expect(attributes.ext).to.equal('some-app-data');
|
99
|
-
done();
|
100
|
-
});
|
101
|
-
});
|
102
|
-
|
103
|
-
it('should successfully authenticate a request (first param)', function (done) {
|
104
|
-
|
105
|
-
var req = {
|
106
|
-
method: 'GET',
|
107
|
-
url: '/resource/4?bewit=MTIzNDU2XDQ1MTE0ODQ2MjFcMzFjMmNkbUJFd1NJRVZDOVkva1NFb2c3d3YrdEVNWjZ3RXNmOGNHU2FXQT1cc29tZS1hcHAtZGF0YQ&a=1&b=2',
|
108
|
-
host: 'example.com',
|
109
|
-
port: 8080
|
110
|
-
};
|
111
|
-
|
112
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
113
|
-
|
114
|
-
expect(err).to.not.exist;
|
115
|
-
expect(credentials.user).to.equal('steve');
|
116
|
-
expect(attributes.ext).to.equal('some-app-data');
|
117
|
-
done();
|
118
|
-
});
|
119
|
-
});
|
120
|
-
|
121
|
-
it('should successfully authenticate a request (only param)', function (done) {
|
122
|
-
|
123
|
-
var req = {
|
124
|
-
method: 'GET',
|
125
|
-
url: '/resource/4?bewit=MTIzNDU2XDQ1MTE0ODQ2NDFcZm1CdkNWT3MvcElOTUUxSTIwbWhrejQ3UnBwTmo4Y1VrSHpQd3Q5OXJ1cz1cc29tZS1hcHAtZGF0YQ',
|
126
|
-
host: 'example.com',
|
127
|
-
port: 8080
|
128
|
-
};
|
129
|
-
|
130
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
131
|
-
|
132
|
-
expect(err).to.not.exist;
|
133
|
-
expect(credentials.user).to.equal('steve');
|
134
|
-
expect(attributes.ext).to.equal('some-app-data');
|
135
|
-
done();
|
136
|
-
});
|
137
|
-
});
|
138
|
-
|
139
|
-
it('should fail on multiple authentication', function (done) {
|
140
|
-
|
141
|
-
var req = {
|
142
|
-
method: 'GET',
|
143
|
-
url: '/resource/4?bewit=MTIzNDU2XDQ1MTE0ODQ2NDFcZm1CdkNWT3MvcElOTUUxSTIwbWhrejQ3UnBwTmo4Y1VrSHpQd3Q5OXJ1cz1cc29tZS1hcHAtZGF0YQ',
|
144
|
-
host: 'example.com',
|
145
|
-
port: 8080,
|
146
|
-
authorization: 'Basic asdasdasdasd'
|
147
|
-
};
|
148
|
-
|
149
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
150
|
-
|
151
|
-
expect(err).to.exist;
|
152
|
-
expect(err.response.payload.message).to.equal('Multiple authentications');
|
153
|
-
done();
|
154
|
-
});
|
155
|
-
});
|
156
|
-
|
157
|
-
it('should fail on method other than GET', function (done) {
|
158
|
-
|
159
|
-
credentialsFunc('123456', function (err, credentials) {
|
160
|
-
|
161
|
-
var req = {
|
162
|
-
method: 'POST',
|
163
|
-
url: '/resource/4?filter=a',
|
164
|
-
host: 'example.com',
|
165
|
-
port: 8080
|
166
|
-
};
|
167
|
-
|
168
|
-
var exp = Math.floor(Hawk.utils.now() / 1000) + 60;
|
169
|
-
var ext = 'some-app-data';
|
170
|
-
var mac = Hawk.crypto.calculateMac('bewit', credentials, {
|
171
|
-
timestamp: exp,
|
172
|
-
nonce: '',
|
173
|
-
method: req.method,
|
174
|
-
resource: req.url,
|
175
|
-
host: req.host,
|
176
|
-
port: req.port,
|
177
|
-
ext: ext
|
178
|
-
});
|
179
|
-
|
180
|
-
var bewit = credentials.id + '\\' + exp + '\\' + mac + '\\' + ext;
|
181
|
-
|
182
|
-
req.url += '&bewit=' + Hawk.utils.base64urlEncode(bewit);
|
183
|
-
|
184
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
185
|
-
|
186
|
-
expect(err).to.exist;
|
187
|
-
expect(err.response.payload.message).to.equal('Invalid method');
|
188
|
-
done();
|
189
|
-
});
|
190
|
-
});
|
191
|
-
});
|
192
|
-
|
193
|
-
it('should fail on invalid host header', function (done) {
|
194
|
-
|
195
|
-
var req = {
|
196
|
-
method: 'GET',
|
197
|
-
url: '/resource/4?bewit=MTIzNDU2XDQ1MDk5OTE3MTlcTUE2eWkwRWRwR0pEcWRwb0JkYVdvVDJrL0hDSzA1T0Y3MkhuZlVmVy96Zz1cc29tZS1hcHAtZGF0YQ',
|
198
|
-
headers: {
|
199
|
-
host: 'example.com:something'
|
200
|
-
}
|
201
|
-
};
|
202
|
-
|
203
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
204
|
-
|
205
|
-
expect(err).to.exist;
|
206
|
-
expect(err.response.payload.message).to.equal('Invalid Host header');
|
207
|
-
done();
|
208
|
-
});
|
209
|
-
});
|
210
|
-
|
211
|
-
it('should fail on empty bewit', function (done) {
|
212
|
-
|
213
|
-
var req = {
|
214
|
-
method: 'GET',
|
215
|
-
url: '/resource/4?bewit=',
|
216
|
-
host: 'example.com',
|
217
|
-
port: 8080
|
218
|
-
};
|
219
|
-
|
220
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
221
|
-
|
222
|
-
expect(err).to.exist;
|
223
|
-
expect(err.response.payload.message).to.equal('Empty bewit');
|
224
|
-
expect(err.isMissing).to.not.exist;
|
225
|
-
done();
|
226
|
-
});
|
227
|
-
});
|
228
|
-
|
229
|
-
it('should fail on invalid bewit', function (done) {
|
230
|
-
|
231
|
-
var req = {
|
232
|
-
method: 'GET',
|
233
|
-
url: '/resource/4?bewit=*',
|
234
|
-
host: 'example.com',
|
235
|
-
port: 8080
|
236
|
-
};
|
237
|
-
|
238
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
239
|
-
|
240
|
-
expect(err).to.exist;
|
241
|
-
expect(err.response.payload.message).to.equal('Invalid bewit encoding');
|
242
|
-
expect(err.isMissing).to.not.exist;
|
243
|
-
done();
|
244
|
-
});
|
245
|
-
});
|
246
|
-
|
247
|
-
it('should fail on missing bewit', function (done) {
|
248
|
-
|
249
|
-
var req = {
|
250
|
-
method: 'GET',
|
251
|
-
url: '/resource/4',
|
252
|
-
host: 'example.com',
|
253
|
-
port: 8080
|
254
|
-
};
|
255
|
-
|
256
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
257
|
-
|
258
|
-
expect(err).to.exist;
|
259
|
-
expect(err.response.payload.message).to.not.exist;
|
260
|
-
expect(err.isMissing).to.equal(true);
|
261
|
-
done();
|
262
|
-
});
|
263
|
-
});
|
264
|
-
|
265
|
-
it('should fail on invalid bewit structure', function (done) {
|
266
|
-
|
267
|
-
var req = {
|
268
|
-
method: 'GET',
|
269
|
-
url: '/resource/4?bewit=abc',
|
270
|
-
host: 'example.com',
|
271
|
-
port: 8080
|
272
|
-
};
|
273
|
-
|
274
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
275
|
-
|
276
|
-
expect(err).to.exist;
|
277
|
-
expect(err.response.payload.message).to.equal('Invalid bewit structure');
|
278
|
-
done();
|
279
|
-
});
|
280
|
-
});
|
281
|
-
|
282
|
-
it('should fail on empty bewit attribute', function (done) {
|
283
|
-
|
284
|
-
var req = {
|
285
|
-
method: 'GET',
|
286
|
-
url: '/resource/4?bewit=YVxcY1xk',
|
287
|
-
host: 'example.com',
|
288
|
-
port: 8080
|
289
|
-
};
|
290
|
-
|
291
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
292
|
-
|
293
|
-
expect(err).to.exist;
|
294
|
-
expect(err.response.payload.message).to.equal('Missing bewit attributes');
|
295
|
-
done();
|
296
|
-
});
|
297
|
-
});
|
298
|
-
|
299
|
-
it('should fail on expired access', function (done) {
|
300
|
-
|
301
|
-
var req = {
|
302
|
-
method: 'GET',
|
303
|
-
url: '/resource/4?a=1&b=2&bewit=MTIzNDU2XDEzNTY0MTg1ODNcWk1wZlMwWU5KNHV0WHpOMmRucTRydEk3NXNXTjFjeWVITTcrL0tNZFdVQT1cc29tZS1hcHAtZGF0YQ',
|
304
|
-
host: 'example.com',
|
305
|
-
port: 8080
|
306
|
-
};
|
307
|
-
|
308
|
-
Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) {
|
309
|
-
|
310
|
-
expect(err).to.exist;
|
311
|
-
expect(err.response.payload.message).to.equal('Access expired');
|
312
|
-
done();
|
313
|
-
});
|
314
|
-
});
|
315
|
-
|
316
|
-
it('should fail on credentials function error', function (done) {
|
317
|
-
|
318
|
-
var req = {
|
319
|
-
method: 'GET',
|
320
|
-
url: '/resource/4?bewit=MTIzNDU2XDQ1MDk5OTE3MTlcTUE2eWkwRWRwR0pEcWRwb0JkYVdvVDJrL0hDSzA1T0Y3MkhuZlVmVy96Zz1cc29tZS1hcHAtZGF0YQ',
|
321
|
-
host: 'example.com',
|
322
|
-
port: 8080
|
323
|
-
};
|
324
|
-
|
325
|
-
Hawk.uri.authenticate(req, function (id, callback) { callback(Hawk.error.badRequest('Boom')); }, {}, function (err, credentials, attributes) {
|
326
|
-
|
327
|
-
expect(err).to.exist;
|
328
|
-
expect(err.response.payload.message).to.equal('Boom');
|
329
|
-
done();
|
330
|
-
});
|
331
|
-
});
|
332
|
-
|
333
|
-
it('should fail on null credentials function response', function (done) {
|
334
|
-
|
335
|
-
var req = {
|
336
|
-
method: 'GET',
|
337
|
-
url: '/resource/4?bewit=MTIzNDU2XDQ1MDk5OTE3MTlcTUE2eWkwRWRwR0pEcWRwb0JkYVdvVDJrL0hDSzA1T0Y3MkhuZlVmVy96Zz1cc29tZS1hcHAtZGF0YQ',
|
338
|
-
host: 'example.com',
|
339
|
-
port: 8080
|
340
|
-
};
|
341
|
-
|
342
|
-
Hawk.uri.authenticate(req, function (id, callback) { callback(null, null); }, {}, function (err, credentials, attributes) {
|
343
|
-
|
344
|
-
expect(err).to.exist;
|
345
|
-
expect(err.response.payload.message).to.equal('Unknown credentials');
|
346
|
-
done();
|
347
|
-
});
|
348
|
-
});
|
349
|
-
|
350
|
-
it('should fail on invalid credentials function response', function (done) {
|
351
|
-
|
352
|
-
var req = {
|
353
|
-
method: 'GET',
|
354
|
-
url: '/resource/4?bewit=MTIzNDU2XDQ1MDk5OTE3MTlcTUE2eWkwRWRwR0pEcWRwb0JkYVdvVDJrL0hDSzA1T0Y3MkhuZlVmVy96Zz1cc29tZS1hcHAtZGF0YQ',
|
355
|
-
host: 'example.com',
|
356
|
-
port: 8080
|
357
|
-
};
|
358
|
-
|
359
|
-
Hawk.uri.authenticate(req, function (id, callback) { callback(null, {}); }, {}, function (err, credentials, attributes) {
|
360
|
-
|
361
|
-
expect(err).to.exist;
|
362
|
-
expect(err.message).to.equal('Invalid credentials');
|
363
|
-
done();
|
364
|
-
});
|
365
|
-
});
|
366
|
-
|
367
|
-
it('should fail on invalid credentials function response (unknown algorithm)', function (done) {
|
368
|
-
|
369
|
-
var req = {
|
370
|
-
method: 'GET',
|
371
|
-
url: '/resource/4?bewit=MTIzNDU2XDQ1MDk5OTE3MTlcTUE2eWkwRWRwR0pEcWRwb0JkYVdvVDJrL0hDSzA1T0Y3MkhuZlVmVy96Zz1cc29tZS1hcHAtZGF0YQ',
|
372
|
-
host: 'example.com',
|
373
|
-
port: 8080
|
374
|
-
};
|
375
|
-
|
376
|
-
Hawk.uri.authenticate(req, function (id, callback) { callback(null, { key: 'xxx', algorithm: 'xxx' }); }, {}, function (err, credentials, attributes) {
|
377
|
-
|
378
|
-
expect(err).to.exist;
|
379
|
-
expect(err.message).to.equal('Unknown algorithm');
|
380
|
-
done();
|
381
|
-
});
|
382
|
-
});
|
383
|
-
|
384
|
-
it('should fail on expired access', function (done) {
|
385
|
-
|
386
|
-
var req = {
|
387
|
-
method: 'GET',
|
388
|
-
url: '/resource/4?bewit=MTIzNDU2XDQ1MDk5OTE3MTlcTUE2eWkwRWRwR0pEcWRwb0JkYVdvVDJrL0hDSzA1T0Y3MkhuZlVmVy96Zz1cc29tZS1hcHAtZGF0YQ',
|
389
|
-
host: 'example.com',
|
390
|
-
port: 8080
|
391
|
-
};
|
392
|
-
|
393
|
-
Hawk.uri.authenticate(req, function (id, callback) { callback(null, { key: 'xxx', algorithm: 'sha256' }); }, {}, function (err, credentials, attributes) {
|
394
|
-
|
395
|
-
expect(err).to.exist;
|
396
|
-
expect(err.response.payload.message).to.equal('Bad mac');
|
397
|
-
done();
|
398
|
-
});
|
399
|
-
});
|
400
|
-
});
|
401
|
-
|
402
|
-
describe('#getBewit', function () {
|
403
|
-
|
404
|
-
it('should return a valid bewit value', function (done) {
|
405
|
-
|
406
|
-
var credentials = {
|
407
|
-
id: '123456',
|
408
|
-
key: '2983d45yun89q',
|
409
|
-
algorithm: 'sha256'
|
410
|
-
};
|
411
|
-
|
412
|
-
var bewit = Hawk.uri.getBewit('https://example.com/somewhere/over/the/rainbow', { credentials: credentials, ttlSec: 300, localtimeOffsetMsec: 1356420407232 - Hawk.utils.now(), ext: 'xandyandz' });
|
413
|
-
expect(bewit).to.equal('MTIzNDU2XDEzNTY0MjA3MDdca3NjeHdOUjJ0SnBQMVQxekRMTlBiQjVVaUtJVTl0T1NKWFRVZEc3WDloOD1ceGFuZHlhbmR6');
|
414
|
-
done();
|
415
|
-
});
|
416
|
-
|
417
|
-
it('should return an empty bewit on invalid credentials', function (done) {
|
418
|
-
|
419
|
-
var credentials = {
|
420
|
-
key: '2983d45yun89q',
|
421
|
-
algorithm: 'sha256'
|
422
|
-
};
|
423
|
-
|
424
|
-
var bewit = Hawk.uri.getBewit('https://example.com/somewhere/over/the/rainbow', { credentials: credentials, ttlSec: 3000, ext: 'xandyandz' });
|
425
|
-
expect(bewit).to.equal('');
|
426
|
-
done();
|
427
|
-
});
|
428
|
-
|
429
|
-
it('should return an empty bewit on invalid algorithm', function (done) {
|
430
|
-
|
431
|
-
var credentials = {
|
432
|
-
id: '123456',
|
433
|
-
key: '2983d45yun89q',
|
434
|
-
algorithm: 'hmac-sha-0'
|
435
|
-
};
|
436
|
-
|
437
|
-
var bewit = Hawk.uri.getBewit('https://example.com/somewhere/over/the/rainbow', { credentials: credentials, ttlSec: 300, ext: 'xandyandz' });
|
438
|
-
expect(bewit).to.equal('');
|
439
|
-
done();
|
440
|
-
});
|
441
|
-
|
442
|
-
it('should return an empty bewit on missing options', function (done) {
|
443
|
-
|
444
|
-
var credentials = {
|
445
|
-
id: '123456',
|
446
|
-
key: '2983d45yun89q',
|
447
|
-
algorithm: 'hmac-sha-0'
|
448
|
-
};
|
449
|
-
|
450
|
-
var bewit = Hawk.uri.getBewit('https://example.com/somewhere/over/the/rainbow');
|
451
|
-
expect(bewit).to.equal('');
|
452
|
-
done();
|
453
|
-
});
|
454
|
-
});
|
455
|
-
});
|
456
|
-
|
@@ -1,120 +0,0 @@
|
|
1
|
-
// Load modules
|
2
|
-
|
3
|
-
var Lab = require('lab');
|
4
|
-
var Hawk = require('../lib');
|
5
|
-
var Package = require('../package.json');
|
6
|
-
|
7
|
-
|
8
|
-
// Declare internals
|
9
|
-
|
10
|
-
var internals = {};
|
11
|
-
|
12
|
-
|
13
|
-
// Test shortcuts
|
14
|
-
|
15
|
-
var expect = Lab.expect;
|
16
|
-
var before = Lab.before;
|
17
|
-
var after = Lab.after;
|
18
|
-
var describe = Lab.experiment;
|
19
|
-
var it = Lab.test;
|
20
|
-
|
21
|
-
|
22
|
-
describe('Hawk', function () {
|
23
|
-
|
24
|
-
describe('Utils', function () {
|
25
|
-
|
26
|
-
describe('#parseHost', function () {
|
27
|
-
|
28
|
-
it('returns port 80 for non tls node request', function (done) {
|
29
|
-
|
30
|
-
var req = {
|
31
|
-
method: 'POST',
|
32
|
-
url: '/resource/4?filter=a',
|
33
|
-
headers: {
|
34
|
-
host: 'example.com',
|
35
|
-
'content-type': 'text/plain;x=y'
|
36
|
-
}
|
37
|
-
};
|
38
|
-
|
39
|
-
expect(Hawk.utils.parseHost(req, 'Host').port).to.equal(80);
|
40
|
-
done();
|
41
|
-
});
|
42
|
-
|
43
|
-
it('returns port 443 for non tls node request', function (done) {
|
44
|
-
|
45
|
-
var req = {
|
46
|
-
method: 'POST',
|
47
|
-
url: '/resource/4?filter=a',
|
48
|
-
headers: {
|
49
|
-
host: 'example.com',
|
50
|
-
'content-type': 'text/plain;x=y'
|
51
|
-
},
|
52
|
-
connection: {
|
53
|
-
encrypted: true
|
54
|
-
}
|
55
|
-
};
|
56
|
-
|
57
|
-
expect(Hawk.utils.parseHost(req, 'Host').port).to.equal(443);
|
58
|
-
done();
|
59
|
-
});
|
60
|
-
|
61
|
-
it('returns port 443 for non tls node request (IPv6)', function (done) {
|
62
|
-
|
63
|
-
var req = {
|
64
|
-
method: 'POST',
|
65
|
-
url: '/resource/4?filter=a',
|
66
|
-
headers: {
|
67
|
-
host: '[123:123:123]',
|
68
|
-
'content-type': 'text/plain;x=y'
|
69
|
-
},
|
70
|
-
connection: {
|
71
|
-
encrypted: true
|
72
|
-
}
|
73
|
-
};
|
74
|
-
|
75
|
-
expect(Hawk.utils.parseHost(req, 'Host').port).to.equal(443);
|
76
|
-
done();
|
77
|
-
});
|
78
|
-
|
79
|
-
it('parses IPv6 headers', function (done) {
|
80
|
-
|
81
|
-
var req = {
|
82
|
-
method: 'POST',
|
83
|
-
url: '/resource/4?filter=a',
|
84
|
-
headers: {
|
85
|
-
host: '[123:123:123]:8000',
|
86
|
-
'content-type': 'text/plain;x=y'
|
87
|
-
},
|
88
|
-
connection: {
|
89
|
-
encrypted: true
|
90
|
-
}
|
91
|
-
};
|
92
|
-
|
93
|
-
var host = Hawk.utils.parseHost(req, 'Host');
|
94
|
-
expect(host.port).to.equal('8000');
|
95
|
-
expect(host.name).to.equal('[123:123:123]');
|
96
|
-
done();
|
97
|
-
});
|
98
|
-
});
|
99
|
-
|
100
|
-
describe('#version', function () {
|
101
|
-
|
102
|
-
it('returns the correct package version number', function (done) {
|
103
|
-
|
104
|
-
expect(Hawk.utils.version()).to.equal(Package.version);
|
105
|
-
done();
|
106
|
-
});
|
107
|
-
});
|
108
|
-
|
109
|
-
describe('#unauthorized', function () {
|
110
|
-
|
111
|
-
it('returns a hawk 401', function (done) {
|
112
|
-
|
113
|
-
expect(Hawk.utils.unauthorized('kaboom').response.headers['WWW-Authenticate']).to.equal('Hawk error="kaboom"');
|
114
|
-
done();
|
115
|
-
});
|
116
|
-
});
|
117
|
-
});
|
118
|
-
});
|
119
|
-
|
120
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
Copyright Joyent, Inc. All rights reserved.
|
2
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
-
of this software and associated documentation files (the "Software"), to
|
4
|
-
deal in the Software without restriction, including without limitation the
|
5
|
-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
6
|
-
sell copies of the Software, and to permit persons to whom the Software is
|
7
|
-
furnished to do so, subject to the following conditions:
|
8
|
-
|
9
|
-
The above copyright notice and this permission notice shall be included in
|
10
|
-
all copies or substantial portions of the Software.
|
11
|
-
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
13
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
14
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
15
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
16
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
17
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
18
|
-
IN THE SOFTWARE.
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# node-http-signature
|
2
|
-
|
3
|
-
node-http-signature is a node.js library that has client and server components
|
4
|
-
for Joyent's [HTTP Signature Scheme](http_signing.md).
|
5
|
-
|
6
|
-
## Usage
|
7
|
-
|
8
|
-
Note the example below signs a request with the same key/cert used to start an
|
9
|
-
HTTP server. This is almost certainly not what you actaully want, but is just
|
10
|
-
used to illustrate the API calls; you will need to provide your own key
|
11
|
-
management in addition to this library.
|
12
|
-
|
13
|
-
### Client
|
14
|
-
|
15
|
-
var fs = require('fs');
|
16
|
-
var https = require('https');
|
17
|
-
var httpSignature = require('http-signature');
|
18
|
-
|
19
|
-
var key = fs.readFileSync('./key.pem', 'ascii');
|
20
|
-
|
21
|
-
var options = {
|
22
|
-
host: 'localhost',
|
23
|
-
port: 8443,
|
24
|
-
path: '/',
|
25
|
-
method: 'GET',
|
26
|
-
headers: {}
|
27
|
-
};
|
28
|
-
|
29
|
-
// Adds a 'Date' header in, signs it, and adds the
|
30
|
-
// 'Authorization' header in.
|
31
|
-
var req = https.request(options, function(res) {
|
32
|
-
console.log(res.statusCode);
|
33
|
-
});
|
34
|
-
|
35
|
-
|
36
|
-
httpSignature.sign(req, {
|
37
|
-
key: key,
|
38
|
-
keyId: './cert.pem'
|
39
|
-
});
|
40
|
-
|
41
|
-
req.end();
|
42
|
-
|
43
|
-
### Server
|
44
|
-
|
45
|
-
var fs = require('fs');
|
46
|
-
var https = require('https');
|
47
|
-
var httpSignature = require('http-signature');
|
48
|
-
|
49
|
-
var options = {
|
50
|
-
key: fs.readFileSync('./key.pem'),
|
51
|
-
cert: fs.readFileSync('./cert.pem')
|
52
|
-
};
|
53
|
-
|
54
|
-
https.createServer(options, function (req, res) {
|
55
|
-
var rc = 200;
|
56
|
-
var parsed = httpSignature.parseRequest(req);
|
57
|
-
var pub = fs.readFileSync(parsed.keyId, 'ascii');
|
58
|
-
if (!httpSignature.verifySignature(parsed, pub))
|
59
|
-
rc = 401;
|
60
|
-
|
61
|
-
res.writeHead(rc);
|
62
|
-
res.end();
|
63
|
-
}).listen(8443);
|
64
|
-
|
65
|
-
## Installation
|
66
|
-
|
67
|
-
npm install http-signature
|
68
|
-
|
69
|
-
## License
|
70
|
-
|
71
|
-
MIT.
|
72
|
-
|
73
|
-
## Bugs
|
74
|
-
|
75
|
-
See <https://github.com/joyent/node-http-signature/issues>.
|