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,24 +0,0 @@
|
|
1
|
-
Copyright (c) 2012-2013, Walmart.
|
2
|
-
All rights reserved.
|
3
|
-
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
6
|
-
* Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
8
|
-
* Redistributions in binary form must reproduce the above copyright
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
10
|
-
documentation and/or other materials provided with the distribution.
|
11
|
-
* Neither the name of Walmart nor the
|
12
|
-
names of its contributors may be used to endorse or promote products
|
13
|
-
derived from this software without specific prior written permission.
|
14
|
-
|
15
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
-
DISCLAIMED. IN NO EVENT SHALL WALMART BE LIABLE FOR ANY
|
19
|
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -1,11 +0,0 @@
|
|
1
|
-
test:
|
2
|
-
@node node_modules/lab/bin/lab
|
3
|
-
test-cov:
|
4
|
-
@node node_modules/lab/bin/lab -r threshold -t 100
|
5
|
-
test-cov-html:
|
6
|
-
@node node_modules/lab/bin/lab -r html -o coverage.html
|
7
|
-
complexity:
|
8
|
-
@node node_modules/complexity-report/src/cli.js -o complexity.md -f markdown lib
|
9
|
-
|
10
|
-
.PHONY: test test-cov test-cov-html complexity
|
11
|
-
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<a href="https://github.com/spumko"><img src="https://raw.github.com/spumko/spumko/master/images/from.png" align="right" /></a>
|
2
|
-

|
3
|
-
|
4
|
-
HTTP-friendly error objects
|
5
|
-
|
6
|
-
[](http://travis-ci.org/spumko/boom)
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require('./lib');
|
@@ -1,207 +0,0 @@
|
|
1
|
-
// Load modules
|
2
|
-
|
3
|
-
var Http = require('http');
|
4
|
-
var NodeUtil = require('util');
|
5
|
-
var Hoek = require('hoek');
|
6
|
-
|
7
|
-
|
8
|
-
// Declare internals
|
9
|
-
|
10
|
-
var internals = {};
|
11
|
-
|
12
|
-
|
13
|
-
exports = module.exports = internals.Boom = function (/* (new Error) or (code, message) */) {
|
14
|
-
|
15
|
-
var self = this;
|
16
|
-
|
17
|
-
Hoek.assert(this.constructor === internals.Boom, 'Error must be instantiated using new');
|
18
|
-
|
19
|
-
Error.call(this);
|
20
|
-
this.isBoom = true;
|
21
|
-
|
22
|
-
this.response = {
|
23
|
-
code: 0,
|
24
|
-
payload: {},
|
25
|
-
headers: {}
|
26
|
-
// type: 'content-type'
|
27
|
-
};
|
28
|
-
|
29
|
-
if (arguments[0] instanceof Error) {
|
30
|
-
|
31
|
-
// Error
|
32
|
-
|
33
|
-
var error = arguments[0];
|
34
|
-
|
35
|
-
this.data = error;
|
36
|
-
this.response.code = error.code || 500;
|
37
|
-
if (error.message) {
|
38
|
-
this.message = error.message;
|
39
|
-
}
|
40
|
-
}
|
41
|
-
else {
|
42
|
-
|
43
|
-
// code, message
|
44
|
-
|
45
|
-
var code = arguments[0];
|
46
|
-
var message = arguments[1];
|
47
|
-
|
48
|
-
Hoek.assert(!isNaN(parseFloat(code)) && isFinite(code) && code >= 400, 'First argument must be a number (400+)');
|
49
|
-
|
50
|
-
this.response.code = code;
|
51
|
-
if (message) {
|
52
|
-
this.message = message;
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
// Response format
|
57
|
-
|
58
|
-
this.reformat();
|
59
|
-
|
60
|
-
return this;
|
61
|
-
};
|
62
|
-
|
63
|
-
NodeUtil.inherits(internals.Boom, Error);
|
64
|
-
|
65
|
-
|
66
|
-
internals.Boom.prototype.reformat = function () {
|
67
|
-
|
68
|
-
this.response.payload.code = this.response.code;
|
69
|
-
this.response.payload.error = Http.STATUS_CODES[this.response.code] || 'Unknown';
|
70
|
-
if (this.message) {
|
71
|
-
this.response.payload.message = Hoek.escapeHtml(this.message); // Prevent XSS from error message
|
72
|
-
}
|
73
|
-
};
|
74
|
-
|
75
|
-
|
76
|
-
// Utilities
|
77
|
-
|
78
|
-
internals.Boom.badRequest = function (message) {
|
79
|
-
|
80
|
-
return new internals.Boom(400, message);
|
81
|
-
};
|
82
|
-
|
83
|
-
|
84
|
-
internals.Boom.unauthorized = function (message, scheme, attributes) { // Or function (message, wwwAuthenticate[])
|
85
|
-
|
86
|
-
var err = new internals.Boom(401, message);
|
87
|
-
|
88
|
-
if (!scheme) {
|
89
|
-
return err;
|
90
|
-
}
|
91
|
-
|
92
|
-
var wwwAuthenticate = '';
|
93
|
-
|
94
|
-
if (typeof scheme === 'string') {
|
95
|
-
|
96
|
-
// function (message, scheme, attributes)
|
97
|
-
|
98
|
-
wwwAuthenticate = scheme;
|
99
|
-
if (attributes) {
|
100
|
-
var names = Object.keys(attributes);
|
101
|
-
for (var i = 0, il = names.length; i < il; ++i) {
|
102
|
-
if (i) {
|
103
|
-
wwwAuthenticate += ',';
|
104
|
-
}
|
105
|
-
|
106
|
-
var value = attributes[names[i]];
|
107
|
-
if (value === null ||
|
108
|
-
value === undefined) { // Value can be zero
|
109
|
-
|
110
|
-
value = '';
|
111
|
-
}
|
112
|
-
wwwAuthenticate += ' ' + names[i] + '="' + Hoek.escapeHeaderAttribute(value.toString()) + '"';
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
if (message) {
|
117
|
-
if (attributes) {
|
118
|
-
wwwAuthenticate += ',';
|
119
|
-
}
|
120
|
-
wwwAuthenticate += ' error="' + Hoek.escapeHeaderAttribute(message) + '"';
|
121
|
-
}
|
122
|
-
else {
|
123
|
-
err.isMissing = true;
|
124
|
-
}
|
125
|
-
}
|
126
|
-
else {
|
127
|
-
|
128
|
-
// function (message, wwwAuthenticate[])
|
129
|
-
|
130
|
-
var wwwArray = scheme;
|
131
|
-
for (var i = 0, il = wwwArray.length; i < il; ++i) {
|
132
|
-
if (i) {
|
133
|
-
wwwAuthenticate += ', ';
|
134
|
-
}
|
135
|
-
|
136
|
-
wwwAuthenticate += wwwArray[i];
|
137
|
-
}
|
138
|
-
}
|
139
|
-
|
140
|
-
err.response.headers['WWW-Authenticate'] = wwwAuthenticate;
|
141
|
-
|
142
|
-
return err;
|
143
|
-
};
|
144
|
-
|
145
|
-
|
146
|
-
internals.Boom.clientTimeout = function (message) {
|
147
|
-
|
148
|
-
return new internals.Boom(408, message);
|
149
|
-
};
|
150
|
-
|
151
|
-
|
152
|
-
internals.Boom.serverTimeout = function (message) {
|
153
|
-
|
154
|
-
return new internals.Boom(503, message);
|
155
|
-
};
|
156
|
-
|
157
|
-
|
158
|
-
internals.Boom.forbidden = function (message) {
|
159
|
-
|
160
|
-
return new internals.Boom(403, message);
|
161
|
-
};
|
162
|
-
|
163
|
-
|
164
|
-
internals.Boom.notFound = function (message) {
|
165
|
-
|
166
|
-
return new internals.Boom(404, message);
|
167
|
-
};
|
168
|
-
|
169
|
-
|
170
|
-
internals.Boom.internal = function (message, data) {
|
171
|
-
|
172
|
-
var err = new internals.Boom(500, message);
|
173
|
-
|
174
|
-
if (data && data.stack) {
|
175
|
-
err.trace = data.stack.split('\n');
|
176
|
-
err.outterTrace = Hoek.displayStack(1);
|
177
|
-
}
|
178
|
-
else {
|
179
|
-
err.trace = Hoek.displayStack(1);
|
180
|
-
}
|
181
|
-
|
182
|
-
err.data = data;
|
183
|
-
err.response.payload.message = 'An internal server error occurred'; // Hide actual error from user
|
184
|
-
|
185
|
-
return err;
|
186
|
-
};
|
187
|
-
|
188
|
-
|
189
|
-
internals.Boom.passThrough = function (code, payload, contentType, headers) {
|
190
|
-
|
191
|
-
var err = new internals.Boom(500, 'Pass-through'); // 500 code is only used to initialize
|
192
|
-
|
193
|
-
err.data = {
|
194
|
-
code: code,
|
195
|
-
payload: payload,
|
196
|
-
type: contentType
|
197
|
-
};
|
198
|
-
|
199
|
-
err.response.code = code;
|
200
|
-
err.response.type = contentType;
|
201
|
-
err.response.headers = headers;
|
202
|
-
err.response.payload = payload;
|
203
|
-
|
204
|
-
return err;
|
205
|
-
};
|
206
|
-
|
207
|
-
|
@@ -1,64 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "boom",
|
3
|
-
"description": "HTTP-friendly error objects",
|
4
|
-
"version": "0.4.2",
|
5
|
-
"author": {
|
6
|
-
"name": "Eran Hammer",
|
7
|
-
"email": "eran@hueniverse.com",
|
8
|
-
"url": "http://hueniverse.com"
|
9
|
-
},
|
10
|
-
"contributors": [],
|
11
|
-
"repository": {
|
12
|
-
"type": "git",
|
13
|
-
"url": "git://github.com/spumko/boom"
|
14
|
-
},
|
15
|
-
"main": "index",
|
16
|
-
"keywords": [
|
17
|
-
"error",
|
18
|
-
"http"
|
19
|
-
],
|
20
|
-
"engines": {
|
21
|
-
"node": ">=0.8.0"
|
22
|
-
},
|
23
|
-
"dependencies": {
|
24
|
-
"hoek": "0.9.x"
|
25
|
-
},
|
26
|
-
"devDependencies": {
|
27
|
-
"lab": "0.1.x",
|
28
|
-
"complexity-report": "0.x.x"
|
29
|
-
},
|
30
|
-
"scripts": {
|
31
|
-
"test": "make test-cov"
|
32
|
-
},
|
33
|
-
"licenses": [
|
34
|
-
{
|
35
|
-
"type": "BSD",
|
36
|
-
"url": "http://github.com/spumko/boom/raw/master/LICENSE"
|
37
|
-
}
|
38
|
-
],
|
39
|
-
"_id": "boom@0.4.2",
|
40
|
-
"dist": {
|
41
|
-
"shasum": "7a636e9ded4efcefb19cef4947a3c67dfaee911b",
|
42
|
-
"tarball": "http://registry.npmjs.org/boom/-/boom-0.4.2.tgz"
|
43
|
-
},
|
44
|
-
"_from": "boom@0.4.x",
|
45
|
-
"_npmVersion": "1.2.18",
|
46
|
-
"_npmUser": {
|
47
|
-
"name": "hueniverse",
|
48
|
-
"email": "eran@hueniverse.com"
|
49
|
-
},
|
50
|
-
"maintainers": [
|
51
|
-
{
|
52
|
-
"name": "hueniverse",
|
53
|
-
"email": "eran@hueniverse.com"
|
54
|
-
}
|
55
|
-
],
|
56
|
-
"directories": {},
|
57
|
-
"_shasum": "7a636e9ded4efcefb19cef4947a3c67dfaee911b",
|
58
|
-
"_resolved": "https://registry.npmjs.org/boom/-/boom-0.4.2.tgz",
|
59
|
-
"bugs": {
|
60
|
-
"url": "https://github.com/spumko/boom/issues"
|
61
|
-
},
|
62
|
-
"readme": "ERROR: No README data found!",
|
63
|
-
"homepage": "https://github.com/spumko/boom"
|
64
|
-
}
|
@@ -1,245 +0,0 @@
|
|
1
|
-
// Load modules
|
2
|
-
|
3
|
-
var Lab = require('lab');
|
4
|
-
var Boom = require('../lib');
|
5
|
-
|
6
|
-
|
7
|
-
// Declare internals
|
8
|
-
|
9
|
-
var internals = {};
|
10
|
-
|
11
|
-
|
12
|
-
// Test shortcuts
|
13
|
-
|
14
|
-
var expect = Lab.expect;
|
15
|
-
var before = Lab.before;
|
16
|
-
var after = Lab.after;
|
17
|
-
var describe = Lab.experiment;
|
18
|
-
var it = Lab.test;
|
19
|
-
|
20
|
-
|
21
|
-
describe('Boom', function () {
|
22
|
-
|
23
|
-
it('returns an error with info when constructed using another error', function (done) {
|
24
|
-
|
25
|
-
var error = new Error('ka-boom');
|
26
|
-
error.xyz = 123;
|
27
|
-
var err = new Boom(error);
|
28
|
-
expect(err.data.xyz).to.equal(123);
|
29
|
-
expect(err.message).to.equal('ka-boom');
|
30
|
-
expect(err.response).to.deep.equal({
|
31
|
-
code: 500,
|
32
|
-
payload: {
|
33
|
-
code: 500,
|
34
|
-
error: 'Internal Server Error',
|
35
|
-
message: 'ka-boom'
|
36
|
-
},
|
37
|
-
headers: {}
|
38
|
-
});
|
39
|
-
done();
|
40
|
-
});
|
41
|
-
|
42
|
-
describe('#isBoom', function () {
|
43
|
-
|
44
|
-
it('returns true for Boom object', function (done) {
|
45
|
-
|
46
|
-
expect(Boom.badRequest().isBoom).to.equal(true);
|
47
|
-
done();
|
48
|
-
});
|
49
|
-
|
50
|
-
it('returns false for Error object', function (done) {
|
51
|
-
|
52
|
-
expect(new Error().isBoom).to.not.exist;
|
53
|
-
done();
|
54
|
-
});
|
55
|
-
});
|
56
|
-
|
57
|
-
describe('#badRequest', function () {
|
58
|
-
|
59
|
-
it('returns a 400 error code', function (done) {
|
60
|
-
|
61
|
-
expect(Boom.badRequest().response.code).to.equal(400);
|
62
|
-
done();
|
63
|
-
});
|
64
|
-
|
65
|
-
it('sets the message with the passed in message', function (done) {
|
66
|
-
|
67
|
-
expect(Boom.badRequest('my message').message).to.equal('my message');
|
68
|
-
done();
|
69
|
-
});
|
70
|
-
});
|
71
|
-
|
72
|
-
describe('#unauthorized', function () {
|
73
|
-
|
74
|
-
it('returns a 401 error code', function (done) {
|
75
|
-
|
76
|
-
var err = Boom.unauthorized();
|
77
|
-
expect(err.response.code).to.equal(401);
|
78
|
-
expect(err.response.headers).to.deep.equal({});
|
79
|
-
done();
|
80
|
-
});
|
81
|
-
|
82
|
-
it('sets the message with the passed in message', function (done) {
|
83
|
-
|
84
|
-
expect(Boom.unauthorized('my message').message).to.equal('my message');
|
85
|
-
done();
|
86
|
-
});
|
87
|
-
|
88
|
-
it('returns a WWW-Authenticate header when passed a scheme', function (done) {
|
89
|
-
|
90
|
-
var err = Boom.unauthorized('boom', 'Test');
|
91
|
-
expect(err.response.code).to.equal(401);
|
92
|
-
expect(err.response.headers['WWW-Authenticate']).to.equal('Test error="boom"');
|
93
|
-
done();
|
94
|
-
});
|
95
|
-
|
96
|
-
it('returns a WWW-Authenticate header when passed a scheme and attributes', function (done) {
|
97
|
-
|
98
|
-
var err = Boom.unauthorized('boom', 'Test', { a: 1, b: 'something', c: null, d: 0 });
|
99
|
-
expect(err.response.code).to.equal(401);
|
100
|
-
expect(err.response.headers['WWW-Authenticate']).to.equal('Test a="1", b="something", c="", d="0", error="boom"');
|
101
|
-
done();
|
102
|
-
});
|
103
|
-
|
104
|
-
it('sets the isMissing flag when error message is empty', function (done) {
|
105
|
-
|
106
|
-
var err = Boom.unauthorized('', 'Basic');
|
107
|
-
expect(err.isMissing).to.equal(true);
|
108
|
-
done();
|
109
|
-
});
|
110
|
-
|
111
|
-
it('does not set the isMissing flag when error message is not empty', function (done) {
|
112
|
-
|
113
|
-
var err = Boom.unauthorized('message', 'Basic');
|
114
|
-
expect(err.isMissing).to.equal(undefined);
|
115
|
-
done();
|
116
|
-
});
|
117
|
-
|
118
|
-
it('sets a WWW-Authenticate when passed as an array', function (done) {
|
119
|
-
|
120
|
-
var err = Boom.unauthorized('message', ['Basic', 'Example e="1"', 'Another x="3", y="4"']);
|
121
|
-
expect(err.response.headers['WWW-Authenticate']).to.equal('Basic, Example e="1", Another x="3", y="4"');
|
122
|
-
done();
|
123
|
-
});
|
124
|
-
});
|
125
|
-
|
126
|
-
describe('#clientTimeout', function () {
|
127
|
-
|
128
|
-
it('returns a 408 error code', function (done) {
|
129
|
-
|
130
|
-
expect(Boom.clientTimeout().response.code).to.equal(408);
|
131
|
-
done();
|
132
|
-
});
|
133
|
-
|
134
|
-
it('sets the message with the passed in message', function (done) {
|
135
|
-
|
136
|
-
expect(Boom.clientTimeout('my message').message).to.equal('my message');
|
137
|
-
done();
|
138
|
-
});
|
139
|
-
});
|
140
|
-
|
141
|
-
describe('#serverTimeout', function () {
|
142
|
-
|
143
|
-
it('returns a 503 error code', function (done) {
|
144
|
-
|
145
|
-
expect(Boom.serverTimeout().response.code).to.equal(503);
|
146
|
-
done();
|
147
|
-
});
|
148
|
-
|
149
|
-
it('sets the message with the passed in message', function (done) {
|
150
|
-
|
151
|
-
expect(Boom.serverTimeout('my message').message).to.equal('my message');
|
152
|
-
done();
|
153
|
-
});
|
154
|
-
});
|
155
|
-
|
156
|
-
describe('#forbidden', function () {
|
157
|
-
|
158
|
-
it('returns a 403 error code', function (done) {
|
159
|
-
|
160
|
-
expect(Boom.forbidden().response.code).to.equal(403);
|
161
|
-
done();
|
162
|
-
});
|
163
|
-
|
164
|
-
it('sets the message with the passed in message', function (done) {
|
165
|
-
|
166
|
-
expect(Boom.forbidden('my message').message).to.equal('my message');
|
167
|
-
done();
|
168
|
-
});
|
169
|
-
});
|
170
|
-
|
171
|
-
describe('#notFound', function () {
|
172
|
-
|
173
|
-
it('returns a 404 error code', function (done) {
|
174
|
-
|
175
|
-
expect(Boom.notFound().response.code).to.equal(404);
|
176
|
-
done();
|
177
|
-
});
|
178
|
-
|
179
|
-
it('sets the message with the passed in message', function (done) {
|
180
|
-
|
181
|
-
expect(Boom.notFound('my message').message).to.equal('my message');
|
182
|
-
done();
|
183
|
-
});
|
184
|
-
});
|
185
|
-
|
186
|
-
describe('#internal', function () {
|
187
|
-
|
188
|
-
it('returns a 500 error code', function (done) {
|
189
|
-
|
190
|
-
expect(Boom.internal().response.code).to.equal(500);
|
191
|
-
done();
|
192
|
-
});
|
193
|
-
|
194
|
-
it('sets the message with the passed in message', function (done) {
|
195
|
-
|
196
|
-
var err = Boom.internal('my message');
|
197
|
-
expect(err.message).to.equal('my message');
|
198
|
-
expect(err.response.payload.message).to.equal('An internal server error occurred');
|
199
|
-
done();
|
200
|
-
});
|
201
|
-
|
202
|
-
it('passes data on the callback if its passed in', function (done) {
|
203
|
-
|
204
|
-
expect(Boom.internal('my message', { my: 'data' }).data.my).to.equal('data');
|
205
|
-
done();
|
206
|
-
});
|
207
|
-
|
208
|
-
it('uses passed in stack if its available', function (done) {
|
209
|
-
|
210
|
-
var error = new Error();
|
211
|
-
error.stack = 'my stack line\nmy second stack line';
|
212
|
-
expect(Boom.internal('my message', error).trace[0]).to.equal('my stack line');
|
213
|
-
done();
|
214
|
-
});
|
215
|
-
});
|
216
|
-
|
217
|
-
describe('#passThrough', function () {
|
218
|
-
|
219
|
-
it('returns a pass-through error', function (done) {
|
220
|
-
|
221
|
-
var err = Boom.passThrough(499, { a: 1 }, 'application/text', { 'X-Test': 'Boom' });
|
222
|
-
expect(err.response.code).to.equal(499);
|
223
|
-
expect(err.message).to.equal('Pass-through');
|
224
|
-
expect(err.response).to.deep.equal({
|
225
|
-
code: 499,
|
226
|
-
payload: { a: 1 },
|
227
|
-
headers: { 'X-Test': 'Boom' },
|
228
|
-
type: 'application/text'
|
229
|
-
});
|
230
|
-
done();
|
231
|
-
});
|
232
|
-
});
|
233
|
-
|
234
|
-
describe('#reformat', function () {
|
235
|
-
|
236
|
-
it('encodes any HTML markup in the response payload', function (done) {
|
237
|
-
|
238
|
-
var boom = new Boom(new Error('<script>alert(1)</script>'));
|
239
|
-
expect(boom.response.payload.message).to.not.contain('<script>');
|
240
|
-
done();
|
241
|
-
});
|
242
|
-
});
|
243
|
-
});
|
244
|
-
|
245
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
Copyright (c) 2012-2013, Eran Hammer.
|
2
|
-
All rights reserved.
|
3
|
-
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
6
|
-
* Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
8
|
-
* Redistributions in binary form must reproduce the above copyright
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
10
|
-
documentation and/or other materials provided with the distribution.
|
11
|
-
* Neither the name of Eran Hammer nor the
|
12
|
-
names of its contributors may be used to endorse or promote products
|
13
|
-
derived from this software without specific prior written permission.
|
14
|
-
|
15
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
-
DISCLAIMED. IN NO EVENT SHALL ERAN HAMMER BE LIABLE FOR ANY
|
19
|
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -1,11 +0,0 @@
|
|
1
|
-
test:
|
2
|
-
@./node_modules/.bin/lab
|
3
|
-
test-cov:
|
4
|
-
@./node_modules/.bin/lab -r threshold -t 100
|
5
|
-
test-cov-html:
|
6
|
-
@./node_modules/.bin/lab -r html -o coverage.html
|
7
|
-
complexity:
|
8
|
-
@./node_modules/.bin/cr -o complexity.md -f markdown lib
|
9
|
-
|
10
|
-
.PHONY: test test-cov test-cov-html complexity
|
11
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require('./lib');
|