ai 1.1.0 → 2.0.1
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-GT4HKF2X.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 -37
- 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
package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js
DELETED
@@ -1,267 +0,0 @@
|
|
1
|
-
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
2
|
-
|
3
|
-
var assert = require('assert');
|
4
|
-
|
5
|
-
var ASN1 = require('./types');
|
6
|
-
var errors = require('./errors');
|
7
|
-
|
8
|
-
|
9
|
-
///--- Globals
|
10
|
-
|
11
|
-
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
///--- API
|
16
|
-
|
17
|
-
function Reader(data) {
|
18
|
-
if (!data || !Buffer.isBuffer(data))
|
19
|
-
throw new TypeError('data must be a node Buffer');
|
20
|
-
|
21
|
-
this._buf = data;
|
22
|
-
this._size = data.length;
|
23
|
-
|
24
|
-
// These hold the "current" state
|
25
|
-
this._len = 0;
|
26
|
-
this._offset = 0;
|
27
|
-
|
28
|
-
var self = this;
|
29
|
-
this.__defineGetter__('length', function() { return self._len; });
|
30
|
-
this.__defineGetter__('offset', function() { return self._offset; });
|
31
|
-
this.__defineGetter__('remain', function() {
|
32
|
-
return self._size - self._offset;
|
33
|
-
});
|
34
|
-
this.__defineGetter__('buffer', function() {
|
35
|
-
return self._buf.slice(self._offset);
|
36
|
-
});
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
/**
|
41
|
-
* Reads a single byte and advances offset; you can pass in `true` to make this
|
42
|
-
* a "peek" operation (i.e., get the byte, but don't advance the offset).
|
43
|
-
*
|
44
|
-
* @param {Boolean} peek true means don't move offset.
|
45
|
-
* @return {Number} the next byte, null if not enough data.
|
46
|
-
*/
|
47
|
-
Reader.prototype.readByte = function(peek) {
|
48
|
-
if (this._size - this._offset < 1)
|
49
|
-
return null;
|
50
|
-
|
51
|
-
var b = this._buf[this._offset] & 0xff;
|
52
|
-
|
53
|
-
if (!peek)
|
54
|
-
this._offset += 1;
|
55
|
-
|
56
|
-
return b;
|
57
|
-
};
|
58
|
-
|
59
|
-
|
60
|
-
Reader.prototype.peek = function() {
|
61
|
-
return this.readByte(true);
|
62
|
-
};
|
63
|
-
|
64
|
-
|
65
|
-
/**
|
66
|
-
* Reads a (potentially) variable length off the BER buffer. This call is
|
67
|
-
* not really meant to be called directly, as callers have to manipulate
|
68
|
-
* the internal buffer afterwards.
|
69
|
-
*
|
70
|
-
* As a result of this call, you can call `Reader.length`, until the
|
71
|
-
* next thing called that does a readLength.
|
72
|
-
*
|
73
|
-
* @return {Number} the amount of offset to advance the buffer.
|
74
|
-
* @throws {InvalidAsn1Error} on bad ASN.1
|
75
|
-
*/
|
76
|
-
Reader.prototype.readLength = function(offset) {
|
77
|
-
if (offset === undefined)
|
78
|
-
offset = this._offset;
|
79
|
-
|
80
|
-
if (offset >= this._size)
|
81
|
-
return null;
|
82
|
-
|
83
|
-
var lenB = this._buf[offset++] & 0xff;
|
84
|
-
if (lenB === null)
|
85
|
-
return null;
|
86
|
-
|
87
|
-
if ((lenB & 0x80) == 0x80) {
|
88
|
-
lenB &= 0x7f;
|
89
|
-
|
90
|
-
if (lenB == 0)
|
91
|
-
throw newInvalidAsn1Error('Indefinite length not supported');
|
92
|
-
|
93
|
-
if (lenB > 4)
|
94
|
-
throw newInvalidAsn1Error('encoding too long');
|
95
|
-
|
96
|
-
if (this._size - offset < lenB)
|
97
|
-
return null;
|
98
|
-
|
99
|
-
this._len = 0;
|
100
|
-
for (var i = 0; i < lenB; i++)
|
101
|
-
this._len = (this._len << 8) + (this._buf[offset++] & 0xff);
|
102
|
-
|
103
|
-
} else {
|
104
|
-
// Wasn't a variable length
|
105
|
-
this._len = lenB;
|
106
|
-
}
|
107
|
-
|
108
|
-
return offset;
|
109
|
-
};
|
110
|
-
|
111
|
-
|
112
|
-
/**
|
113
|
-
* Parses the next sequence in this BER buffer.
|
114
|
-
*
|
115
|
-
* To get the length of the sequence, call `Reader.length`.
|
116
|
-
*
|
117
|
-
* @return {Number} the sequence's tag.
|
118
|
-
*/
|
119
|
-
Reader.prototype.readSequence = function(tag) {
|
120
|
-
var seq = this.peek();
|
121
|
-
if (seq === null)
|
122
|
-
return null;
|
123
|
-
if (tag !== undefined && tag !== seq)
|
124
|
-
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
125
|
-
': got 0x' + seq.toString(16));
|
126
|
-
|
127
|
-
var o = this.readLength(this._offset + 1); // stored in `length`
|
128
|
-
if (o === null)
|
129
|
-
return null;
|
130
|
-
|
131
|
-
this._offset = o;
|
132
|
-
return seq;
|
133
|
-
};
|
134
|
-
|
135
|
-
|
136
|
-
Reader.prototype.readInt = function() {
|
137
|
-
return this._readTag(ASN1.Integer);
|
138
|
-
};
|
139
|
-
|
140
|
-
|
141
|
-
Reader.prototype.readBoolean = function() {
|
142
|
-
return (this._readTag(ASN1.Boolean) === 0 ? false : true);
|
143
|
-
};
|
144
|
-
|
145
|
-
|
146
|
-
Reader.prototype.readEnumeration = function() {
|
147
|
-
return this._readTag(ASN1.Enumeration);
|
148
|
-
};
|
149
|
-
|
150
|
-
|
151
|
-
Reader.prototype.readString = function(tag, retbuf) {
|
152
|
-
if (!tag)
|
153
|
-
tag = ASN1.OctetString;
|
154
|
-
|
155
|
-
var b = this.peek();
|
156
|
-
if (b === null)
|
157
|
-
return null;
|
158
|
-
|
159
|
-
if (b !== tag)
|
160
|
-
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
161
|
-
': got 0x' + b.toString(16));
|
162
|
-
|
163
|
-
var o = this.readLength(this._offset + 1); // stored in `length`
|
164
|
-
|
165
|
-
if (o === null)
|
166
|
-
return null;
|
167
|
-
|
168
|
-
if (this.length > this._size - o)
|
169
|
-
return null;
|
170
|
-
|
171
|
-
this._offset = o;
|
172
|
-
|
173
|
-
if (this.length === 0)
|
174
|
-
return '';
|
175
|
-
|
176
|
-
var str = this._buf.slice(this._offset, this._offset + this.length);
|
177
|
-
this._offset += this.length;
|
178
|
-
|
179
|
-
return retbuf ? str : str.toString('utf8');
|
180
|
-
};
|
181
|
-
|
182
|
-
Reader.prototype.readOID = function(tag) {
|
183
|
-
if (!tag)
|
184
|
-
tag = ASN1.OID;
|
185
|
-
|
186
|
-
var b = this.peek();
|
187
|
-
if (b === null)
|
188
|
-
return null;
|
189
|
-
|
190
|
-
if (b !== tag)
|
191
|
-
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
192
|
-
': got 0x' + b.toString(16));
|
193
|
-
|
194
|
-
var o = this.readLength(this._offset + 1); // stored in `length`
|
195
|
-
if (o === null)
|
196
|
-
return null;
|
197
|
-
|
198
|
-
if (this.length > this._size - o)
|
199
|
-
return null;
|
200
|
-
|
201
|
-
this._offset = o;
|
202
|
-
|
203
|
-
var values = [];
|
204
|
-
var value = 0;
|
205
|
-
|
206
|
-
for (var i = 0; i < this.length; i++) {
|
207
|
-
var byte = this._buf[this._offset++] & 0xff;
|
208
|
-
|
209
|
-
value <<= 7;
|
210
|
-
value += byte & 0x7f;
|
211
|
-
if ((byte & 0x80) == 0) {
|
212
|
-
values.push(value);
|
213
|
-
value = 0;
|
214
|
-
}
|
215
|
-
}
|
216
|
-
|
217
|
-
value = values.shift();
|
218
|
-
values.unshift(value % 40);
|
219
|
-
values.unshift((value / 40) >> 0);
|
220
|
-
|
221
|
-
return values.join('.');
|
222
|
-
};
|
223
|
-
|
224
|
-
|
225
|
-
Reader.prototype._readTag = function(tag) {
|
226
|
-
assert.ok(tag !== undefined);
|
227
|
-
|
228
|
-
var b = this.peek();
|
229
|
-
|
230
|
-
if (b === null)
|
231
|
-
return null;
|
232
|
-
|
233
|
-
if (b !== tag)
|
234
|
-
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
235
|
-
': got 0x' + b.toString(16));
|
236
|
-
|
237
|
-
var o = this.readLength(this._offset + 1); // stored in `length`
|
238
|
-
if (o === null)
|
239
|
-
return null;
|
240
|
-
|
241
|
-
if (this.length > 4)
|
242
|
-
throw newInvalidAsn1Error('Integer too long: ' + this.length);
|
243
|
-
|
244
|
-
if (this.length > this._size - o)
|
245
|
-
return null;
|
246
|
-
this._offset = o;
|
247
|
-
|
248
|
-
var fb = this._buf[this._offset++];
|
249
|
-
var value = 0;
|
250
|
-
|
251
|
-
value = fb & 0x7F;
|
252
|
-
for (var i = 1; i < this.length; i++) {
|
253
|
-
value <<= 8;
|
254
|
-
value |= (this._buf[this._offset++] & 0xff);
|
255
|
-
}
|
256
|
-
|
257
|
-
if ((fb & 0x80) == 0x80)
|
258
|
-
value = -value;
|
259
|
-
|
260
|
-
return value;
|
261
|
-
};
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
///--- Exported API
|
266
|
-
|
267
|
-
module.exports = Reader;
|
@@ -1,36 +0,0 @@
|
|
1
|
-
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
2
|
-
|
3
|
-
|
4
|
-
module.exports = {
|
5
|
-
EOC: 0,
|
6
|
-
Boolean: 1,
|
7
|
-
Integer: 2,
|
8
|
-
BitString: 3,
|
9
|
-
OctetString: 4,
|
10
|
-
Null: 5,
|
11
|
-
OID: 6,
|
12
|
-
ObjectDescriptor: 7,
|
13
|
-
External: 8,
|
14
|
-
Real: 9, // float
|
15
|
-
Enumeration: 10,
|
16
|
-
PDV: 11,
|
17
|
-
Utf8String: 12,
|
18
|
-
RelativeOID: 13,
|
19
|
-
Sequence: 16,
|
20
|
-
Set: 17,
|
21
|
-
NumericString: 18,
|
22
|
-
PrintableString: 19,
|
23
|
-
T61String: 20,
|
24
|
-
VideotexString: 21,
|
25
|
-
IA5String: 22,
|
26
|
-
UTCTime: 23,
|
27
|
-
GeneralizedTime: 24,
|
28
|
-
GraphicString: 25,
|
29
|
-
VisibleString: 26,
|
30
|
-
GeneralString: 28,
|
31
|
-
UniversalString: 29,
|
32
|
-
CharacterString: 30,
|
33
|
-
BMPString: 31,
|
34
|
-
Constructor: 32,
|
35
|
-
Context: 128
|
36
|
-
};
|
package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js
DELETED
@@ -1,317 +0,0 @@
|
|
1
|
-
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
2
|
-
|
3
|
-
var assert = require('assert');
|
4
|
-
var ASN1 = require('./types');
|
5
|
-
var errors = require('./errors');
|
6
|
-
|
7
|
-
|
8
|
-
///--- Globals
|
9
|
-
|
10
|
-
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
|
11
|
-
|
12
|
-
var DEFAULT_OPTS = {
|
13
|
-
size: 1024,
|
14
|
-
growthFactor: 8
|
15
|
-
};
|
16
|
-
|
17
|
-
|
18
|
-
///--- Helpers
|
19
|
-
|
20
|
-
function merge(from, to) {
|
21
|
-
assert.ok(from);
|
22
|
-
assert.equal(typeof(from), 'object');
|
23
|
-
assert.ok(to);
|
24
|
-
assert.equal(typeof(to), 'object');
|
25
|
-
|
26
|
-
var keys = Object.getOwnPropertyNames(from);
|
27
|
-
keys.forEach(function(key) {
|
28
|
-
if (to[key])
|
29
|
-
return;
|
30
|
-
|
31
|
-
var value = Object.getOwnPropertyDescriptor(from, key);
|
32
|
-
Object.defineProperty(to, key, value);
|
33
|
-
});
|
34
|
-
|
35
|
-
return to;
|
36
|
-
}
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
///--- API
|
41
|
-
|
42
|
-
function Writer(options) {
|
43
|
-
options = merge(DEFAULT_OPTS, options || {});
|
44
|
-
|
45
|
-
this._buf = new Buffer(options.size || 1024);
|
46
|
-
this._size = this._buf.length;
|
47
|
-
this._offset = 0;
|
48
|
-
this._options = options;
|
49
|
-
|
50
|
-
// A list of offsets in the buffer where we need to insert
|
51
|
-
// sequence tag/len pairs.
|
52
|
-
this._seq = [];
|
53
|
-
|
54
|
-
var self = this;
|
55
|
-
this.__defineGetter__('buffer', function() {
|
56
|
-
if (self._seq.length)
|
57
|
-
throw new InvalidAsn1Error(self._seq.length + ' unended sequence(s)');
|
58
|
-
|
59
|
-
return self._buf.slice(0, self._offset);
|
60
|
-
});
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
Writer.prototype.writeByte = function(b) {
|
65
|
-
if (typeof(b) !== 'number')
|
66
|
-
throw new TypeError('argument must be a Number');
|
67
|
-
|
68
|
-
this._ensure(1);
|
69
|
-
this._buf[this._offset++] = b;
|
70
|
-
};
|
71
|
-
|
72
|
-
|
73
|
-
Writer.prototype.writeInt = function(i, tag) {
|
74
|
-
if (typeof(i) !== 'number')
|
75
|
-
throw new TypeError('argument must be a Number');
|
76
|
-
if (typeof(tag) !== 'number')
|
77
|
-
tag = ASN1.Integer;
|
78
|
-
|
79
|
-
var sz = 4;
|
80
|
-
|
81
|
-
while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000)) &&
|
82
|
-
(sz > 1)) {
|
83
|
-
sz--;
|
84
|
-
i <<= 8;
|
85
|
-
}
|
86
|
-
|
87
|
-
if (sz > 4)
|
88
|
-
throw new InvalidAsn1Error('BER ints cannot be > 0xffffffff');
|
89
|
-
|
90
|
-
this._ensure(2 + sz);
|
91
|
-
this._buf[this._offset++] = tag;
|
92
|
-
this._buf[this._offset++] = sz;
|
93
|
-
|
94
|
-
while (sz-- > 0) {
|
95
|
-
this._buf[this._offset++] = ((i & 0xff000000) >> 24);
|
96
|
-
i <<= 8;
|
97
|
-
}
|
98
|
-
|
99
|
-
};
|
100
|
-
|
101
|
-
|
102
|
-
Writer.prototype.writeNull = function() {
|
103
|
-
this.writeByte(ASN1.Null);
|
104
|
-
this.writeByte(0x00);
|
105
|
-
};
|
106
|
-
|
107
|
-
|
108
|
-
Writer.prototype.writeEnumeration = function(i, tag) {
|
109
|
-
if (typeof(i) !== 'number')
|
110
|
-
throw new TypeError('argument must be a Number');
|
111
|
-
if (typeof(tag) !== 'number')
|
112
|
-
tag = ASN1.Enumeration;
|
113
|
-
|
114
|
-
return this.writeInt(i, tag);
|
115
|
-
};
|
116
|
-
|
117
|
-
|
118
|
-
Writer.prototype.writeBoolean = function(b, tag) {
|
119
|
-
if (typeof(b) !== 'boolean')
|
120
|
-
throw new TypeError('argument must be a Boolean');
|
121
|
-
if (typeof(tag) !== 'number')
|
122
|
-
tag = ASN1.Boolean;
|
123
|
-
|
124
|
-
this._ensure(3);
|
125
|
-
this._buf[this._offset++] = tag;
|
126
|
-
this._buf[this._offset++] = 0x01;
|
127
|
-
this._buf[this._offset++] = b ? 0xff : 0x00;
|
128
|
-
};
|
129
|
-
|
130
|
-
|
131
|
-
Writer.prototype.writeString = function(s, tag) {
|
132
|
-
if (typeof(s) !== 'string')
|
133
|
-
throw new TypeError('argument must be a string (was: ' + typeof(s) + ')');
|
134
|
-
if (typeof(tag) !== 'number')
|
135
|
-
tag = ASN1.OctetString;
|
136
|
-
|
137
|
-
var len = Buffer.byteLength(s);
|
138
|
-
this.writeByte(tag);
|
139
|
-
this.writeLength(len);
|
140
|
-
if (len) {
|
141
|
-
this._ensure(len);
|
142
|
-
this._buf.write(s, this._offset);
|
143
|
-
this._offset += len;
|
144
|
-
}
|
145
|
-
};
|
146
|
-
|
147
|
-
|
148
|
-
Writer.prototype.writeBuffer = function(buf, tag) {
|
149
|
-
if (typeof(tag) !== 'number')
|
150
|
-
throw new TypeError('tag must be a number');
|
151
|
-
if (!Buffer.isBuffer(buf))
|
152
|
-
throw new TypeError('argument must be a buffer');
|
153
|
-
|
154
|
-
this.writeByte(tag);
|
155
|
-
this.writeLength(buf.length);
|
156
|
-
this._ensure(buf.length);
|
157
|
-
buf.copy(this._buf, this._offset, 0, buf.length);
|
158
|
-
this._offset += buf.length;
|
159
|
-
};
|
160
|
-
|
161
|
-
|
162
|
-
Writer.prototype.writeStringArray = function(strings) {
|
163
|
-
if ((!strings instanceof Array))
|
164
|
-
throw new TypeError('argument must be an Array[String]');
|
165
|
-
|
166
|
-
var self = this;
|
167
|
-
strings.forEach(function(s) {
|
168
|
-
self.writeString(s);
|
169
|
-
});
|
170
|
-
};
|
171
|
-
|
172
|
-
// This is really to solve DER cases, but whatever for now
|
173
|
-
Writer.prototype.writeOID = function(s, tag) {
|
174
|
-
if (typeof(s) !== 'string')
|
175
|
-
throw new TypeError('argument must be a string');
|
176
|
-
if (typeof(tag) !== 'number')
|
177
|
-
tag = ASN1.OID;
|
178
|
-
|
179
|
-
if (!/^([0-9]+\.){3,}[0-9]+$/.test(s))
|
180
|
-
throw new Error('argument is not a valid OID string');
|
181
|
-
|
182
|
-
function encodeOctet(bytes, octet) {
|
183
|
-
if (octet < 128) {
|
184
|
-
bytes.push(octet);
|
185
|
-
} else if (octet < 16384) {
|
186
|
-
bytes.push((octet >>> 7) | 0x80);
|
187
|
-
bytes.push(octet & 0x7F);
|
188
|
-
} else if (octet < 2097152) {
|
189
|
-
bytes.push((octet >>> 14) | 0x80);
|
190
|
-
bytes.push(((octet >>> 7) | 0x80) & 0xFF);
|
191
|
-
bytes.push(octet & 0x7F);
|
192
|
-
} else if (octet < 268435456) {
|
193
|
-
bytes.push((octet >>> 21) | 0x80);
|
194
|
-
bytes.push(((octet >>> 14) | 0x80) & 0xFF);
|
195
|
-
bytes.push(((octet >>> 7) | 0x80) & 0xFF);
|
196
|
-
bytes.push(octet & 0x7F);
|
197
|
-
} else {
|
198
|
-
bytes.push(((octet >>> 28) | 0x80) & 0xFF);
|
199
|
-
bytes.push(((octet >>> 21) | 0x80) & 0xFF);
|
200
|
-
bytes.push(((octet >>> 14) | 0x80) & 0xFF);
|
201
|
-
bytes.push(((octet >>> 7) | 0x80) & 0xFF);
|
202
|
-
bytes.push(octet & 0x7F);
|
203
|
-
}
|
204
|
-
}
|
205
|
-
|
206
|
-
var tmp = s.split('.');
|
207
|
-
var bytes = [];
|
208
|
-
bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));
|
209
|
-
tmp.slice(2).forEach(function(b) {
|
210
|
-
encodeOctet(bytes, parseInt(b, 10));
|
211
|
-
});
|
212
|
-
|
213
|
-
var self = this;
|
214
|
-
this._ensure(2 + bytes.length);
|
215
|
-
this.writeByte(tag);
|
216
|
-
this.writeLength(bytes.length);
|
217
|
-
bytes.forEach(function(b) {
|
218
|
-
self.writeByte(b);
|
219
|
-
});
|
220
|
-
};
|
221
|
-
|
222
|
-
|
223
|
-
Writer.prototype.writeLength = function(len) {
|
224
|
-
if (typeof(len) !== 'number')
|
225
|
-
throw new TypeError('argument must be a Number');
|
226
|
-
|
227
|
-
this._ensure(4);
|
228
|
-
|
229
|
-
if (len <= 0x7f) {
|
230
|
-
this._buf[this._offset++] = len;
|
231
|
-
} else if (len <= 0xff) {
|
232
|
-
this._buf[this._offset++] = 0x81;
|
233
|
-
this._buf[this._offset++] = len;
|
234
|
-
} else if (len <= 0xffff) {
|
235
|
-
this._buf[this._offset++] = 0x82;
|
236
|
-
this._buf[this._offset++] = len >> 8;
|
237
|
-
this._buf[this._offset++] = len;
|
238
|
-
} else if (len <= 0xffffff) {
|
239
|
-
this._shift(start, len, 1);
|
240
|
-
this._buf[this._offset++] = 0x83;
|
241
|
-
this._buf[this._offset++] = len >> 16;
|
242
|
-
this._buf[this._offset++] = len >> 8;
|
243
|
-
this._buf[this._offset++] = len;
|
244
|
-
} else {
|
245
|
-
throw new InvalidAsn1ERror('Length too long (> 4 bytes)');
|
246
|
-
}
|
247
|
-
};
|
248
|
-
|
249
|
-
Writer.prototype.startSequence = function(tag) {
|
250
|
-
if (typeof(tag) !== 'number')
|
251
|
-
tag = ASN1.Sequence | ASN1.Constructor;
|
252
|
-
|
253
|
-
this.writeByte(tag);
|
254
|
-
this._seq.push(this._offset);
|
255
|
-
this._ensure(3);
|
256
|
-
this._offset += 3;
|
257
|
-
};
|
258
|
-
|
259
|
-
|
260
|
-
Writer.prototype.endSequence = function() {
|
261
|
-
var seq = this._seq.pop();
|
262
|
-
var start = seq + 3;
|
263
|
-
var len = this._offset - start;
|
264
|
-
|
265
|
-
if (len <= 0x7f) {
|
266
|
-
this._shift(start, len, -2);
|
267
|
-
this._buf[seq] = len;
|
268
|
-
} else if (len <= 0xff) {
|
269
|
-
this._shift(start, len, -1);
|
270
|
-
this._buf[seq] = 0x81;
|
271
|
-
this._buf[seq + 1] = len;
|
272
|
-
} else if (len <= 0xffff) {
|
273
|
-
this._buf[seq] = 0x82;
|
274
|
-
this._buf[seq + 1] = len >> 8;
|
275
|
-
this._buf[seq + 2] = len;
|
276
|
-
} else if (len <= 0xffffff) {
|
277
|
-
this._shift(start, len, 1);
|
278
|
-
this._buf[seq] = 0x83;
|
279
|
-
this._buf[seq + 1] = len >> 16;
|
280
|
-
this._buf[seq + 2] = len >> 8;
|
281
|
-
this._buf[seq + 3] = len;
|
282
|
-
} else {
|
283
|
-
throw new InvalidAsn1Error('Sequence too long');
|
284
|
-
}
|
285
|
-
};
|
286
|
-
|
287
|
-
|
288
|
-
Writer.prototype._shift = function(start, len, shift) {
|
289
|
-
assert.ok(start !== undefined);
|
290
|
-
assert.ok(len !== undefined);
|
291
|
-
assert.ok(shift);
|
292
|
-
|
293
|
-
this._buf.copy(this._buf, start + shift, start, start + len);
|
294
|
-
this._offset += shift;
|
295
|
-
};
|
296
|
-
|
297
|
-
Writer.prototype._ensure = function(len) {
|
298
|
-
assert.ok(len);
|
299
|
-
|
300
|
-
if (this._size - this._offset < len) {
|
301
|
-
var sz = this._size * this._options.growthFactor;
|
302
|
-
if (sz - this._offset < len)
|
303
|
-
sz += len;
|
304
|
-
|
305
|
-
var buf = new Buffer(sz);
|
306
|
-
|
307
|
-
this._buf.copy(buf, 0, 0, this._offset);
|
308
|
-
this._buf = buf;
|
309
|
-
this._size = sz;
|
310
|
-
}
|
311
|
-
};
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
///--- Exported API
|
316
|
-
|
317
|
-
module.exports = Writer;
|
@@ -1,20 +0,0 @@
|
|
1
|
-
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
2
|
-
|
3
|
-
// If you have no idea what ASN.1 or BER is, see this:
|
4
|
-
// ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
|
5
|
-
|
6
|
-
var Ber = require('./ber/index');
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
///--- Exported API
|
11
|
-
|
12
|
-
module.exports = {
|
13
|
-
|
14
|
-
Ber: Ber,
|
15
|
-
|
16
|
-
BerReader: Ber.Reader,
|
17
|
-
|
18
|
-
BerWriter: Ber.Writer
|
19
|
-
|
20
|
-
};
|
@@ -1,63 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"author": {
|
3
|
-
"name": "Mark Cavage",
|
4
|
-
"email": "mcavage@gmail.com"
|
5
|
-
},
|
6
|
-
"contributors": [
|
7
|
-
{
|
8
|
-
"name": "David Gwynne",
|
9
|
-
"email": "loki@animata.net"
|
10
|
-
},
|
11
|
-
{
|
12
|
-
"name": "Yunong Xiao",
|
13
|
-
"email": "yunong@joyent.com"
|
14
|
-
}
|
15
|
-
],
|
16
|
-
"name": "asn1",
|
17
|
-
"description": "Contains parsers and serializers for ASN.1 (currently BER only)",
|
18
|
-
"version": "0.1.11",
|
19
|
-
"repository": {
|
20
|
-
"type": "git",
|
21
|
-
"url": "git://github.com/mcavage/node-asn1.git"
|
22
|
-
},
|
23
|
-
"main": "lib/index.js",
|
24
|
-
"engines": {
|
25
|
-
"node": ">=0.4.9"
|
26
|
-
},
|
27
|
-
"dependencies": {},
|
28
|
-
"devDependencies": {
|
29
|
-
"tap": "0.1.4"
|
30
|
-
},
|
31
|
-
"scripts": {
|
32
|
-
"pretest": "which gjslint; if [[ \"$?\" = 0 ]] ; then gjslint --nojsdoc -r lib -r tst; else echo \"Missing gjslint. Skipping lint\"; fi",
|
33
|
-
"test": "tap ./tst"
|
34
|
-
},
|
35
|
-
"_npmUser": {
|
36
|
-
"name": "mcavage",
|
37
|
-
"email": "mcavage@gmail.com"
|
38
|
-
},
|
39
|
-
"_id": "asn1@0.1.11",
|
40
|
-
"_engineSupported": true,
|
41
|
-
"_npmVersion": "1.1.0-beta-4",
|
42
|
-
"_nodeVersion": "v0.6.6",
|
43
|
-
"_defaultsLoaded": true,
|
44
|
-
"dist": {
|
45
|
-
"shasum": "559be18376d08a4ec4dbe80877d27818639b2df7",
|
46
|
-
"tarball": "http://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz"
|
47
|
-
},
|
48
|
-
"maintainers": [
|
49
|
-
{
|
50
|
-
"name": "mcavage",
|
51
|
-
"email": "mcavage@gmail.com"
|
52
|
-
}
|
53
|
-
],
|
54
|
-
"directories": {},
|
55
|
-
"_shasum": "559be18376d08a4ec4dbe80877d27818639b2df7",
|
56
|
-
"_from": "asn1@0.1.11",
|
57
|
-
"_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz",
|
58
|
-
"bugs": {
|
59
|
-
"url": "https://github.com/mcavage/node-asn1/issues"
|
60
|
-
},
|
61
|
-
"readme": "ERROR: No README data found!",
|
62
|
-
"homepage": "https://github.com/mcavage/node-asn1"
|
63
|
-
}
|